/* ---- Buttons ------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 42px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out),
              background-color var(--dur-2) var(--ease-out),
              border-color var(--dur-2) var(--ease-out),
              box-shadow var(--dur-2) var(--ease-out),
              filter var(--dur-2) var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn[disabled], .btn.is-disabled { opacity: 0.55; pointer-events: none; }

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--text-on-accent);
  --btn-bd: transparent;
  box-shadow: var(--shadow-sm);
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--accent-strong); box-shadow: var(--glow-accent); }
  .btn-secondary:hover { background: var(--surface-3); border-color: var(--accent-border); }
  .btn-ghost:hover { background: var(--surface-2); }
  .btn-danger:hover { filter: brightness(1.05); box-shadow: 0 8px 24px var(--danger-soft); }
}

.btn-secondary { --btn-bg: var(--surface-2); --btn-fg: var(--text); --btn-bd: var(--border-strong); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--text-muted); --btn-bd: transparent; }
.btn-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger-text); --btn-bd: var(--border); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--sp-3); font-size: 13px; }
.btn-lg { min-height: 48px; padding: 0 var(--sp-6); font-size: 15px; }

/* Icon-only button */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { color: var(--text); border-color: var(--accent-border); background: var(--surface-3); }
}

/* ---- Forms --------------------------------------------------------------- */
.form-grid { display: grid; gap: var(--sp-4); }
.form-row, .form-item { display: grid; gap: var(--sp-2); min-width: 0; }
.form-row > label, .form-item > label,
.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}
.form-help, .field-help { font-size: 12px; color: var(--text-subtle); line-height: 1.4; }

.input, .select, textarea.input {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  color: var(--text);
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out);
}
.input::placeholder, textarea.input::placeholder { color: var(--text-subtle); }
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }

select:not([multiple]) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%2398989d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: calc(100% - 14px) 50%;
  background-size: 16px 16px;
  background-repeat: no-repeat;
}
select::-ms-expand { display: none; }

/* Password / input with trailing action */
.input-with-action { position: relative; }
.input-with-action .input { padding-right: 46px; }
.password-toggle {
  position: absolute;
  top: 50%; right: 7px;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  color: var(--text-subtle);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.password-toggle:hover { background: var(--surface-3); color: var(--text); }
.password-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .eye-closed { display: none; }
.password-toggle.is-visible .eye-open { display: none; }
.password-toggle.is-visible .eye-closed { display: block; }

.error-message { min-height: 18px; margin: 0; color: var(--danger-text); font-size: 13px; }
.success-message { margin: 0; color: var(--success-text); font-weight: 600; }

/* ---- Cards / panels ------------------------------------------------------ */
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}
.panel { padding: var(--sp-5); }
.card { padding: var(--sp-4); }
.panel-title { margin: 0 0 var(--sp-4); font-size: 17px; }
.panel-soft { background: var(--surface-3); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
}

/* Stat / metric card */
.stat-card {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}
.stat-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.stat-card__label { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-muted); }
.stat-card__value { font-family: var(--font-display); font-weight: 800; font-size: clamp(26px, 3vw, 34px); line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-card__value.is-negative { color: var(--danger-text); }
.stat-card__note { margin: 0; font-size: 13px; color: var(--text-muted); }
.stat-card__icon {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-card__icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Status / badges ----------------------------------------------------- */
.pill, .status-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.status-success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-soft); }
.status-failed, .status-danger { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-soft); }
.status-processing, .status-info { background: var(--info-soft); color: var(--info-text); border-color: var(--info-soft); }
.status-nonCommercial { background: var(--purple-soft); color: var(--purple-text); border-color: var(--purple-soft); }
.status-other, .status-warn { background: var(--warn-soft); color: var(--warn-text); border-color: var(--warn-soft); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-neutral { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }

/* ---- Tables -------------------------------------------------------------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  --row-padding: 13px 16px;
}
.table-card[data-density="compact"] { --row-padding: 9px 14px; }
.table-card[data-density="cozy"] { --row-padding: 17px 18px; }

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.table-head__title { margin: 0; font-size: 16px; }
.table-head__meta { display: flex; gap: var(--sp-4); flex-wrap: wrap; color: var(--text-muted); font-size: 13px; }
.table-toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

.table-scroll { overflow: auto; max-height: 62vh; }
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 2px solid var(--surface); }

table.data-table { width: 100%; border-collapse: collapse; min-width: 920px; }
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: var(--row-padding);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: var(--row-padding);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .data-table tbody tr.data-row:hover { background: var(--surface-3); }
}
.data-table th.center, .data-table td.center { text-align: center; }
.data-table th.right, .data-table td.right { text-align: right; }

.th-sort { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font: inherit; color: inherit; font-weight: 600; }
.th-sort:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-xs); }
.th-sort.is-active.is-asc::after { content: "↑"; font-size: 11px; }
.th-sort.is-active.is-desc::after { content: "↓"; font-size: 11px; }
.table-empty { padding: var(--sp-10) var(--sp-5); text-align: center; color: var(--text-muted); }

/* ---- Pagination ---------------------------------------------------------- */
.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--surface-3);
}
.pagination__pages { grid-column: 2; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; justify-self: center; }
.pagination__jump { grid-column: 3; justify-self: end; display: flex; gap: var(--sp-2); align-items: center; color: var(--text-muted); font-size: 13px; }
.pagination__jump .select { width: auto; min-width: 84px; min-height: 38px; }
.page-btn {
  min-width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.page-btn.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.page-btn.disabled { color: var(--text-subtle); pointer-events: none; opacity: 0.6; }
@media (hover: hover) and (pointer: fine) { .page-btn:not(.active):not(.disabled):hover { border-color: var(--accent-border); } }

/* ---- Dropdown / popover ----------------------------------------------
   Materialize via JS spring (scripts/motion.js), not a CSS transition, so
   the open/close can be interrupted and re-targeted mid-flight. The CSS
   here only owns the resting open/closed states; --origin-x/--origin-y are
   set inline by JS to anchor the scale-in to the trigger element. */
.dropdown {
  position: absolute;
  z-index: var(--z-dropdown);
  min-width: 220px;
  background: var(--material-thin-bg);
  backdrop-filter: blur(var(--material-thin-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--material-thin-blur)) saturate(160%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: var(--origin-x, 100%) var(--origin-y, 0%);
  pointer-events: none;
}
.dropdown[aria-hidden="false"] { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.dropdown h4 { margin: 0; padding: var(--sp-3) var(--sp-4); font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.dropdown a { display: block; padding: var(--sp-3) var(--sp-4); transition: background-color var(--dur-1) var(--ease-out); }
.dropdown a:hover { background: var(--surface-3); }

/* ---- Custom select (styled dropdown replacing native <select>) ----------- */
.custom-select { position: relative; min-width: 0; }
.custom-select__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out);
}
.custom-select__trigger:hover { border-color: var(--accent-border); }
.custom-select.is-open .custom-select__trigger,
.custom-select__trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}
.custom-select__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select__chevron { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--text-muted); transition: transform var(--dur-2) var(--ease-out); }
.custom-select.is-open .custom-select__chevron { transform: rotate(180deg); }
.custom-select__list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: var(--z-dropdown);
  padding: 6px;
  margin: 0;
  list-style: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--material-thin-bg);
  backdrop-filter: blur(var(--material-thin-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--material-thin-blur)) saturate(160%);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 2px;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: var(--origin-x, 50%) var(--origin-y, 0%);
  pointer-events: none;
  /* Open/close is spring-driven from scripts/sidebar.js via motion.js — no
     CSS transition here so a re-open mid-close can retarget instead of
     restarting from the closed state. */
}
.custom-select.is-open .custom-select__list { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.custom-select__list[hidden] { display: none; }
.custom-select__list--scroll { max-height: 240px; overflow-y: auto; }

/* Floating dropdown state: sidebar.js moves the list to document.body while
   open (the settings modal has overflow:hidden + a permanent transform, which
   makes it the containing block for position:fixed descendants — the only
   escape is detaching). Once detached the list is no longer a descendant of
   `.custom-select.is-open`, so this class must carry ALL the "open" styles
   itself: position, visibility, and a z-index above the modal (1300). */
.custom-select__list--floating {
  position: fixed; top: auto; left: auto; right: auto;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  z-index: var(--z-tooltip);
}
.custom-select__option {
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out);
}
.custom-select__option:hover { background: var(--surface-3); }
.custom-select__option.is-selected { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---- Segmented control --------------------------------------------------- */
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.segmented__item {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.segmented__item:hover { color: var(--text); }
.segmented__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented__item.is-active svg { color: var(--accent); }
.segmented__item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Modal / dialog ----------------------------------------------------
   A modal is a blocking task, so per the materials model (skill §12) it
   pairs an opaque, solid dialog surface with a dimming + blurred scrim
   behind it — translucency belongs to the scrim, not the task surface.
   Open/close motion is a JS spring (scripts/motion.js): this CSS only
   defines the resting hidden/visible states so an interrupted close can
   retarget back open from wherever it currently is. */
.modal {
  position: fixed; inset: 0;
  z-index: var(--z-modal);
  display: grid; place-items: center;
  padding: clamp(16px, 3vw, 34px);
  opacity: 0;
  pointer-events: none;
}
.modal.is-visible { opacity: 1; pointer-events: auto; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(var(--material-regular-blur));
  -webkit-backdrop-filter: blur(var(--material-regular-blur));
}
.modal__dialog {
  position: relative;
  width: min(100%, 520px);
  padding: clamp(22px, 3vw, 30px);
  border-radius: var(--r-2xl);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: var(--sp-4);
  transform: translateY(8px) scale(0.97);
  transform-origin: var(--origin-x, 50%) var(--origin-y, 50%);
}
.modal.is-visible .modal__dialog { transform: translateY(0) scale(1); }

/* ---- Tooltip / help popover --------------------------------------------- */
.help { position: relative; display: inline-flex; }
.help__trigger {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.help__panel {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  width: min(420px, calc(100vw - 48px));
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--material-thin-bg);
  backdrop-filter: blur(var(--material-thin-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--material-thin-blur)) saturate(160%);
  box-shadow: var(--shadow-lg);
  color: var(--text-muted);
  font-size: 13px; line-height: 1.45;
  z-index: var(--z-dropdown);
  opacity: 0; transform: translateY(-6px) scale(0.98);
  transform-origin: var(--origin-x, 100%) var(--origin-y, 0%);
  visibility: hidden; pointer-events: none;
  transition: visibility 0s linear var(--dur-2);
}
.help.is-open .help__panel { opacity: 1; transform: translateY(0) scale(1); visibility: visible; pointer-events: auto; transition-delay: 0s; }
.help__panel a { color: var(--accent); }

/* ---- Theme toggle -------------------------------------------------------- */
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
:root[data-theme="light"] .theme-toggle .sun { display: block; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="dark"]):not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

/* ---- Amount helpers ------------------------------------------------------ */
.amount-positive { color: var(--success-text); }
.amount-negative { color: var(--danger-text); }

/* ============================================================================
   Compatibility layer — styles the existing shared markup used across the
   data pages (sessions / finances / activities / devices) so their
   inner table/toolbar/pagination structure works on the new token system.
   ========================================================================== */
.table-head-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
}
.table-head-main > strong { font-size: 16px; font-family: var(--font-display); }
.page-meta { display: flex; gap: var(--sp-4); flex-wrap: wrap; color: var(--text-muted); font-size: 13px; margin: 0; }
.page-meta strong { color: var(--text); }

.toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.tool-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out);
}
select.tool-btn { padding-right: 38px; }
.tool-btn:hover { border-color: var(--accent-border); background: var(--surface-3); }

.custom-select--tool { width: auto; }
.custom-select--tool .custom-select__trigger {
  width: auto;
  min-height: 40px;
  padding: 0 14px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 13px;
}
.custom-select--tool .custom-select__list {
  left: auto; right: 0;
  width: max-content;
  min-width: 100%;
  font-size: 13px;
}
.custom-select--tool .custom-select__option { white-space: nowrap; }
.custom-select--tool.custom-select--fixed .custom-select__list { position: fixed; top: auto; left: auto; right: auto; }

/* Bare <table> inside a scroll region */
.table-scroll table { width: 100%; border-collapse: collapse; min-width: 920px; }
.table-scroll thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12px; font-weight: 600;
  text-align: left;
  padding: var(--row-padding, 13px 16px);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-scroll tbody td {
  padding: var(--row-padding, 13px 16px);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table-scroll tbody tr:last-child td { border-bottom: 0; }
.table-scroll tbody tr.data-row { transition: background-color var(--dur-1) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .table-scroll tbody tr.data-row:hover { background: var(--surface-3); }
}
.table-scroll th.center, .table-scroll td.center { text-align: center; }
.table-scroll th.right, .table-scroll td.right { text-align: right; }
.table-scroll .mono { font-variant-numeric: tabular-nums; white-space: nowrap; }

th button[data-sort] {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  font-weight: 600;
  transition: color var(--dur-2) var(--ease-out);
}
th button[data-sort]:hover { color: var(--text); }
th.right button[data-sort] { justify-content: flex-end; width: 100%; }
th.center button[data-sort] { justify-content: center; width: 100%; }
th button[data-sort]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-xs); }
th button[data-sort].is-active { color: var(--text); }
th button[data-sort].is-active.is-asc::after { content: "↑"; font-size: 11px; color: var(--accent); }
th button[data-sort].is-active.is-desc::after { content: "↓"; font-size: 11px; color: var(--accent); }

.pagination-pages { grid-column: 2; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; justify-self: center; }
.page-jump { grid-column: 3; justify-self: end; display: flex; gap: var(--sp-2); align-items: center; color: var(--text-muted); font-size: 13px; }
.page-jump .select { width: auto; min-width: 84px; min-height: 38px; }
.page-jump .custom-select--tool { min-width: 72px; }
.page-jump label { font-size: 13px; }

@media (max-width: 640px) {
  .pagination { grid-template-columns: 1fr; justify-items: center; gap: var(--sp-3); }
  .pagination-pages, .pagination__pages,
  .page-jump, .pagination__jump {
    grid-column: 1;
    justify-self: center;
  }
  .pagination-pages, .pagination__pages { gap: var(--sp-1); flex-wrap: nowrap; }
  .pagination-pages .page-btn, .pagination__pages .page-btn { min-width: 34px; padding: 0 6px; }
}

/* Mobile card fallback for tables */
.cards-mobile { display: none; }
.session-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: grid;
  gap: var(--sp-2);
}
.session-card .session-card-row { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: baseline; }
.session-card .session-card-label { color: var(--text-muted); font-size: 12px; }

/* Quest icon in tables */
.quest-cell { display: inline-flex; align-items: center; gap: var(--sp-2); }
.quest-icon {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  object-fit: cover;
  flex: 0 0 28px;
  user-select: none;
  -webkit-user-drag: none;
}
.quest-name { font-weight: 600; color: var(--accent); }
