/* ============================================================
   iSpend — shared styles: reset, typography, app shell, components.
   Tokens live in tokens.css. Page-specific rules live in css/pages/.
   ============================================================ */

/* Inter ships in two pieces: a Latin subset that every page needs (a third of the size), and the
   full face for everything else, which a browser only fetches when a page actually shows a
   character outside Latin — a merchant name in another script, say. The ranges do not overlap,
   so a Latin-only page never touches the big file. The subset also carries the few symbols the UI
   itself prints (⌘ ↵ ⇧ ≈ ≤ ≥ ≠), and claims ⇄ ⋯ ✕ — which Inter lacks — so they fall back to a system
   font without a detour through the big file. /fonts/ is cached immutable: a new subset needs a new
   file name (-v2, -v3…). */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/InterVariable-latin-v2.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+21B5, U+21C4, U+21E7, U+2212, U+2215, U+2248, U+2260, U+2264-2265, U+22EF, U+2318, U+2325, U+25B2-25BC, U+2713-2715, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-0130, U+0132-0151, U+0154-02BA, U+02BD-02C5, U+02C7-02D9, U+02DB, U+02DD-0303, U+0305-0307, U+0309-0328, U+032A-1FFF, U+2070-20AB, U+20AD-2121, U+2123-218F, U+219A-21B4, U+21B6-21C3, U+21C5-21E6, U+21E8-2211, U+2213-2214, U+2216-2247, U+2249-225F, U+2261-2263, U+2266-22EE, U+22F0-2317, U+2319-2324, U+2326-25B1, U+25BD-2712, U+2716-FEFE, U+FF00-FFFC, U+FFFE-10FFFF;
}
/* The stand-in while Inter loads: Arial, scaled so its lines and widths match Inter's, so the
   swap moves nothing (metrics computed from both fonts' tables). */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial'), local('ArialMT');
  size-adjust: 107.47%;
  ascent-override: 90.14%;
  descent-override: 22.44%;
  line-gap-override: 0%;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss03';
}
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: none !important; }
a { color: var(--accent); text-decoration: none; }
@media (hover: hover) { a:hover { text-decoration: underline; } }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a, button, input, select, textarea, label, summary, [role="button"], [role="tab"], [role="radio"] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
html.is-locked, html.is-locked body { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { color: var(--text-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-soft); }
.num, .tnum, td, th, kbd { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.92em; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-md); z-index: 1000; }
.skip:focus { left: 8px; }
.ico { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.ico-sm { width: 14px; height: 14px; }
.ico-lg { width: 24px; height: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Text utilities ---------- */
.text-1 { color: var(--text-1); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-4 { color: var(--text-4); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger-text); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.fs-xs { font-size: var(--fs-xs); }
.fs-sm { font-size: var(--fs-sm); }
.fs-base { font-size: var(--fs-base); }
.fs-lg { font-size: var(--fs-lg); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.section-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.hint { font-size: var(--fs-sm); color: var(--text-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; gap: var(--sp-2); }
.wrap { flex-wrap: wrap; }
.m-0 { margin: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); } .gap-6 { gap: var(--sp-6); }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.grid { display: grid; gap: var(--sp-4); }
.grid > * { min-width: 0; } /* 1fr tracks otherwise inherit min-content and push the page wider than the viewport */
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-1 { grid-template-columns: 1fr 1fr; }
@media (max-width: 960px) { .grid-2, .grid-3, .grid-2-1, .grid-1-1 { grid-template-columns: 1fr; } }

/* ---------- App shell ---------- */
html[data-sidebar="full"] { --sidebar-cur: var(--sidebar-w); }
html[data-sidebar="rail"] { --sidebar-cur: var(--sidebar-rail-w); }
html[data-sidebar="hidden"] { --sidebar-cur: 0px; }
.shell { margin-left: var(--sidebar-cur, var(--sidebar-w)); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; transition: margin-left var(--dur-3) var(--ease-out); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 300;
  width: var(--sidebar-cur, var(--sidebar-w));
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out);
  overflow: hidden;
}
html[data-sidebar="hidden"] .sidebar { width: var(--sidebar-w); transform: translateX(-100%); }
html[data-sidebar="hidden"] body.sidebar-open .sidebar { transform: none; box-shadow: var(--sh-3); }
.sidebar-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 290; opacity: 0; pointer-events: none; transition: opacity var(--dur-3); }
html[data-sidebar="hidden"] body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

.sb-brand { display: flex; align-items: center; gap: 10px; height: calc(var(--topbar-h) + var(--safe-top)); padding: var(--safe-top) 14px 0 16px; flex: 0 0 auto; }
.sb-mark { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; }
.sb-mark .brand-mark { width: 26px; height: 26px; display: block; }
.sb-name { font-weight: 650; font-size: 0.9375rem; letter-spacing: -0.01em; flex: 1; white-space: nowrap; }
.sb-collapse { width: 28px; height: 28px; border-radius: var(--r-sm); color: var(--text-3); display: grid; place-items: center; flex: 0 0 auto; }
@media (hover: hover) { .sb-collapse:hover { background: var(--surface-2); color: var(--text-1); } }
.sb-collapse .ico { width: 16px; height: 16px; }
/* Profile switcher: which books are on screen */
.sb-profile-wrap { padding: 0 10px 2px; flex: 0 0 auto; }
.sb-profile { display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-control); border-radius: var(--r-md); background: var(--surface); color: var(--text-1); font-weight: 550; font-size: var(--fs-sm); text-align: left; }
.sb-profile .dot, .tb-profile .dot { width: 10px; height: 10px; }
.sb-profile-name { flex: 1 1 auto; min-width: 0; }
.sb-profile .ico { color: var(--text-3); flex: 0 0 auto; }
@media (hover: hover) { .sb-profile:hover { background: var(--surface-2); } }
html[data-sidebar="rail"] .sb-profile-wrap { padding: 0 13px 2px; }
html[data-sidebar="rail"] .sb-profile { width: 38px; justify-content: center; padding: 0; }
html[data-sidebar="rail"] .sb-profile-name, html[data-sidebar="rail"] .sb-profile .ico { display: none; }
.tb-profile { display: none; }
.sb-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 4px 10px 12px; }
.sb-group { margin-top: 14px; }
.sb-group-label { padding: 0 8px 6px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4); white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; margin-bottom: 2px;
  border-radius: var(--r-md); color: var(--text-2); font-weight: 500; font-size: var(--fs-base);
  white-space: nowrap; position: relative; text-decoration: none;
  transition: background var(--dur-1), color var(--dur-1);
}
@media (hover: hover) { .nav-item:hover { background: var(--surface-2); color: var(--text-1); text-decoration: none; } }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-item .ico { width: 18px; height: 18px; }
.nav-item .pill { margin-left: auto; }
.nav-item--sub { height: 30px; padding-left: 34px; font-size: var(--fs-sm); font-weight: 450; }
.nav-item--sub .ico { width: 14px; height: 14px; }
html[data-sidebar="rail"] .nav-item--sub { display: none; }
.sb-foot { border-top: 1px solid var(--border); padding: 10px; flex: 0 0 auto; }
html[data-sidebar="rail"] .sb-name, html[data-sidebar="rail"] .sb-group-label, html[data-sidebar="rail"] .sb-collapse { display: none; }
html[data-sidebar="rail"] .nav-item .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* keeps the link's accessible name */
html[data-sidebar="rail"] .sb-brand { justify-content: center; padding: 0; }
html[data-sidebar="rail"] .sb-nav { padding: 4px 13px 12px; }
html[data-sidebar="rail"] .nav-item { justify-content: center; padding: 0; width: 38px; }
html[data-sidebar="rail"] .nav-item .pill { position: absolute; top: 4px; right: 2px; margin: 0; min-width: 16px; height: 16px; font-size: var(--fs-xs); padding: 0 4px; }
html[data-sidebar="rail"] .sb-group { margin-top: 10px; }
html[data-sidebar="rail"] .sb-group + .sb-group { border-top: 1px solid var(--border); padding-top: 8px; }
html[data-sidebar="rail"] .nav-item::after {
  content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--text-1); color: var(--bg); font-size: var(--fs-sm); padding: 4px 8px; border-radius: var(--r-sm);
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--dur-1); z-index: 400;
}
@media (hover: hover) { html[data-sidebar="rail"] .nav-item:hover::after { opacity: 1; } }
html[data-sidebar="rail"] .sb-foot { padding: 8px 6px; }
.sb-expand { display: none; width: 100%; height: 34px; border-radius: var(--r-md); color: var(--text-3); place-items: center; }
@media (hover: hover) { .sb-expand:hover { background: var(--surface-2); color: var(--text-1); } }
html[data-sidebar="rail"] .sb-expand { display: grid; }

.topbar {
  position: sticky; top: 0; z-index: 200; height: calc(var(--topbar-h) + var(--safe-top));
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--safe-top) var(--sp-6) 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.tb-title { font-weight: 600; font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; transition: opacity var(--dur-2); }
.btn.tb-primary, .btn.page-more, .phone-only, .btn.phone-only { display: none; }
.btn.tb-menu { display: none; }
.tb-search {
  margin-left: auto; height: 36px; width: clamp(200px, 32vw, 460px);
  display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px;
  border: 1px solid var(--border-control); border-radius: var(--r-md); background: var(--surface);
  color: var(--text-3); font-size: var(--fs-base); text-align: left;
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
@media (hover: hover) { .tb-search:hover { border-color: var(--text-4); } }
.tb-search span { flex: 1; }
.tb-search kbd { margin-left: auto; }
.tb-actions { display: flex; align-items: center; gap: 4px; }
.tb-avatar-btn { height: var(--control-h); padding: 0 6px 0 6px; border-radius: var(--r-md); display: flex; align-items: center; gap: 8px; }
@media (hover: hover) { .tb-avatar-btn:hover { background: var(--surface-2); } }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: var(--fs-xs); font-weight: 700; display: grid; place-items: center; letter-spacing: 0.02em; flex: 0 0 auto; text-transform: uppercase; }

.main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: var(--sp-4) var(--sp-6) var(--sp-12); }
.main--narrow { max-width: 880px; }
.main--wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin: var(--sp-2) 0 var(--sp-5); flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-xl); }
.page-sub { color: var(--text-3); font-size: var(--fs-base); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

.bottomnav { display: none; }

/* Responsive ladder: 1280 (sidebar full, nav.js) / 960 (rail, off-canvas) / 768 (bottom nav, card-mode tables) / 640 (2-col stats, stacked headers) / 480 (compact stats). qa/e2e/css_audit.py --check rejects other widths. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 14px; border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; background: var(--surface); color: var(--text-1);
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), box-shadow var(--dur-1), transform var(--dur-1);
  user-select: none; text-decoration: none; position: relative;
}
@media (hover: hover) { .btn:hover { text-decoration: none; } }
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--accent-solid); color: var(--accent-solid-fg); }
@media (hover: hover) { .btn-primary:hover { background: var(--accent-solid-hover); } }
.btn-secondary { border-color: var(--border-control); background: var(--surface); }
@media (hover: hover) { .btn-secondary:hover { background: var(--surface-2); } }
.btn-ghost { background: transparent; color: var(--text-2); }
@media (hover: hover) { .btn-ghost:hover { background: var(--surface-2); color: var(--text-1); } }
.btn-danger { background: transparent; color: var(--danger-text); }
@media (hover: hover) { .btn-danger:hover { background: var(--danger-soft); } }
.btn-danger-solid { background: var(--danger-solid); color: #fff; }
@media (hover: hover) { .btn-danger-solid:hover { filter: brightness(0.94); } }
.btn-sm { height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-sm); }
.btn-xs { height: 26px; padding: 0 8px; font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn-icon.btn-xs { width: 26px; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading:disabled, .btn.is-loading[aria-busy="true"] { opacity: 1; cursor: progress; }
.btn.is-loading::after { content: ''; position: absolute; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; color: var(--text-3); }
.btn-primary.is-loading::after { color: var(--accent-solid-fg); }
.btn-block { width: 100%; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-right-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
.spinner-lg { width: 28px; height: 28px; }

/* ---------- Inputs ---------- */
.input, .select, .textarea {
  width: 100%; height: var(--control-h); padding: 0 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-control); background: var(--surface); color: var(--text-1);
  font-size: var(--fs-md); transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
:root[data-theme="dark"] .input, :root[data-theme="dark"] .select, :root[data-theme="dark"] .textarea { background-color: var(--surface-2); } /* background-color, not the shorthand: .select keeps its chevron image */
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.6; }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.input-sm, .select-sm { height: var(--control-h-sm); padding: 0 8px; font-size: var(--fs-base); }
.textarea { height: auto; min-height: 84px; padding: 8px 12px; resize: vertical; line-height: 1.45; }
.select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: var(--select-chevron); background-repeat: no-repeat; background-position: right 8px center; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ico { position: absolute; left: 10px; color: var(--text-3); width: 16px; height: 16px; pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.input-group > .btn-icon.trailing { position: absolute; right: 2px; }
.input-group > .input.has-trailing { padding-right: 36px; }
.input-group.pw-group > .input { padding-left: 12px; }
.input-group.pw-group > .input-sm { padding-left: 8px; }
.input-group .ico-wrap { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-4); display: flex; pointer-events: none; }
.input-group .ico-wrap .ico { width: 15px; height: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field > label, .field > legend, .label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
fieldset.field { border: 0; padding: 0; min-width: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 6px; }
.btn .label { color: inherit; font-size: inherit; font-weight: inherit; }
.field .hint { margin-top: -2px; }
.field-error { display: flex; align-items: flex-start; gap: 6px; margin-top: -2px; font-size: var(--fs-sm); color: var(--danger-text); }
.field-error .ico { flex: 0 0 auto; margin-top: 1px; }
.field > label[data-required]::after { content: ' *'; color: var(--danger-text); }
.field.is-invalid > label { color: var(--danger-text); }
.field-row { display: flex; gap: var(--sp-3); }
.field-row > .field { flex: 1; min-width: 0; }
.check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.radio-list { display: flex; flex-direction: column; gap: 6px; }
.radio-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-control); border-radius: var(--r-md); cursor: pointer; transition: background var(--dur-1), border-color var(--dur-1); }
@media (hover: hover) { .radio-item:hover { background: var(--surface-2); } }
.radio-item.is-checked { border-color: var(--accent); background: var(--accent-soft); }
.radio-item input { accent-color: var(--accent); margin: 0; }
.radio-item .radio-title { font-weight: 500; font-size: var(--fs-base); }
.radio-item .radio-desc { font-size: var(--fs-sm); color: var(--text-3); }
.radio-item.is-checked .radio-desc { color: var(--text-2); }
.kbd, kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--text-3); font-family: var(--font); font-size: var(--fs-xs); font-weight: 500; border: 1px solid var(--border); border-bottom-width: 2px; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-base); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 36px; height: 20px; border-radius: var(--r-pill); background: var(--switch-off); position: relative; transition: background var(--dur-2); flex: 0 0 auto; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform var(--dur-2) var(--ease-out); }
.switch input:checked + .switch-track { background: var(--accent-solid); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-ring); }
.switch-sm .switch-track { width: 30px; height: 17px; }
.switch-sm .switch-track::after { width: 13px; height: 13px; }
.switch-sm input:checked + .switch-track::after { transform: translateX(13px); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-body { padding: var(--sp-5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 60px; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); } /* equal header height whether it holds text or a small button */
.card-head h2, .card-head h3 { font-size: var(--fs-md); font-weight: 600; }
.card-actions { display: flex; align-items: center; gap: var(--sp-2); }
.card + .card { margin-top: var(--sp-4); }
.grid > .card + .card, .grid > .card { margin-top: 0; } /* grid gap spaces cards; no stacked margin */
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }

/* ---------- Badges, chips, dots ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge .ico { width: 12px; height: 12px; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--accent); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--accent-solid); color: var(--accent-solid-fg); }
.pill-soft { background: var(--accent-soft); color: var(--accent); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-pill); border: 1px solid var(--border-control); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); white-space: nowrap; transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1); }
@media (hover: hover) { button.chip:hover { background: var(--surface-2); color: var(--text-1); } }
.chip.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip .ico { width: 14px; height: 14px; }
.chip-ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip-err { background: var(--danger-soft); color: var(--danger-text); border-color: transparent; }
.chip-warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--chart-muted)); flex: 0 0 auto; }
.catchip { display: inline-flex; align-items: center; gap: 7px; height: 26px; max-width: 100%; padding: 0 9px 0 8px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid transparent; font-size: var(--fs-sm); font-weight: 500; color: var(--text-1); white-space: nowrap; transition: background var(--dur-1), border-color var(--dur-1); }
.catchip .catchip-label { overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) { button.catchip:hover { background: var(--surface-3); border-color: var(--border-control); } }
.catchip--empty { background: transparent; border: 1px dashed var(--border-control); color: var(--text-3); }
.catchip--empty .dot { background: var(--warning); }
@media (hover: hover) { button.catchip--empty:hover { color: var(--text-1); border-style: solid; } }
.catchip--suggested { background: var(--info-soft); color: var(--accent); }
.catchip--split { background: var(--surface); border-color: var(--border-control); }
/* ‹ [period] › stepper: dashboard, budgets, transactions and reports all use this group */
.month-nav { display: inline-flex; align-items: center; gap: 4px; }
.month-nav .btn-icon { width: var(--control-h); padding: 0; }
.month-nav [data-period="pick"], .month-nav #month-btn { gap: 6px; justify-content: space-between; }
.catchip--split .catchip-count { color: var(--text-3); font-weight: 500; }
.catchip .ico { width: 13px; height: 13px; }
.cat-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-md); background: color-mix(in srgb, var(--c, var(--chart-muted)) 16%, transparent); color: var(--c, var(--chart-muted)); flex: 0 0 auto; }
.cat-icon .ico { width: 15px; height: 15px; }
.cat-icon-lg { width: 36px; height: 36px; border-radius: var(--r-md); }
.cat-icon-lg .ico { width: 18px; height: 18px; }
.acct { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.acct-mark { width: 18px; height: 18px; border-radius: var(--r-xs); background: color-mix(in srgb, var(--c, var(--chart-muted)) 75%, black); color: #fff; font-size: var(--fs-xs); font-weight: 700; display: grid; place-items: center; flex: 0 0 auto; }

/* ---------- Amounts ---------- */
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt--expense { color: var(--text-1); }
.amt--income { color: var(--success); }
.amt--transfer, .amt--excluded { color: var(--text-3); }
/* tags: neutral chip with the tag's colour as a dot (keeps text contrast in both themes) */
.tagchip { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px 0 6px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 500; white-space: nowrap; max-width: 150px; vertical-align: middle; }
.tagchip > .truncate { min-width: 0; }
.tagchip--more { padding: 0 7px; }
.tagchip .tagchip-x { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: -4px; border-radius: 50%; color: var(--text-3); }
@media (hover: hover) { .tagchip .tagchip-x:hover { background: var(--surface); color: var(--danger-text); } }
.tagchips { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1); }
.tbl-wrap--flush { border: 0; box-shadow: none; border-radius: 0; } /* a table that sits inside a card */
.tbl { width: 100%; font-size: var(--fs-base); }
.tbl th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th.right, .tbl td.right { text-align: right; }
.tbl td { padding: var(--cell-py) 12px; border-bottom: 1px solid var(--border); vertical-align: middle; height: var(--row-h); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background var(--dur-1); }
@media (hover: hover) { .tbl tbody tr:hover { background: var(--surface-2); } }
.tbl tbody tr.is-focused { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.tbl tbody tr[aria-selected="true"] { background: var(--accent-soft); }
.tbl tbody tr.is-clickable { cursor: pointer; }
.tbl th.sortable { cursor: pointer; user-select: none; }
@media (hover: hover) { .tbl th.sortable:hover { color: var(--text-1); } }
.tbl th.sortable::after { content: ''; display: inline-block; width: 0; height: 0; margin-left: 6px; border: 4px solid transparent; opacity: 0.35; vertical-align: 1px; }
.tbl th[aria-sort="ascending"]::after { border-bottom-color: currentColor; border-top: 0; opacity: 1; }
.tbl th[aria-sort="descending"]::after { border-top-color: currentColor; border-bottom: 0; opacity: 1; }
.tbl .col-check { width: 36px; padding-right: 0; }
.tbl .col-actions { width: 1%; white-space: nowrap; }
.tbl td.num, .tbl td.amt { white-space: nowrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions > .btn-icon { opacity: 0.45; transition: opacity var(--dur-1); } /* icon actions stay discoverable at rest; text buttons keep full contrast */
tr:focus-within .row-actions > .btn-icon, tr.is-focused .row-actions > .btn-icon, .row-actions > .btn-icon:focus-visible { opacity: 1; }
@media (hover: hover) { tr:hover .row-actions > .btn-icon { opacity: 1; } }
.tbl-toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.is-fade-end { mask-image: linear-gradient(90deg, black calc(100% - 32px), transparent); }
.is-fade-start { mask-image: linear-gradient(90deg, transparent, black 32px); }
.is-fade-start.is-fade-end { mask-image: linear-gradient(90deg, transparent, black 32px, black calc(100% - 32px), transparent); }
.seg.is-scrollable { mask-image: linear-gradient(90deg, black calc(100% - 28px), transparent); } /* the clipped edge fades so a scrolling seg reads as scrollable */
.tbl-summary { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--fs-base); color: var(--text-3); padding: 0 2px; margin-bottom: var(--sp-2); }
.tbl-summary b { color: var(--text-1); font-weight: 600; }
.tbl-sentinel { height: 1px; }
.merchant { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.merchant-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.merchant-raw { font-size: var(--fs-xs); color: var(--text-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-4); }
.stat { position: relative; padding: var(--sp-4) var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); min-height: 112px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.stat-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); }
.stat-value { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); }
.stat-delta .ico { width: 13px; height: 13px; }
.stat-delta--good { color: var(--success); }
.stat-delta--bad { color: var(--danger-text); }
.stat-skel { position: absolute; left: 20px; top: 44px; width: 120px; height: 26px; }
.stat:not(.is-loading) .stat-skel { display: none; }
.stat-delta-vs { color: var(--text-4); font-weight: 400; }
.stat-spark { position: absolute; right: 12px; bottom: 10px; width: 96px; height: 32px; opacity: 0.9; }
.stat.is-loading .stat-value, .stat.is-loading .stat-delta { visibility: hidden; }

/* ---------- Chart cards ---------- */
.chart-card .chart-body { position: relative; height: var(--h, 260px); padding: var(--sp-4) var(--sp-5) var(--sp-3); }
.chart-body.is-loading::after { content: ''; position: absolute; inset: var(--sp-4) var(--sp-5); border-radius: var(--r-md); background: var(--surface-3); animation: skel-pulse 1.4s ease-in-out infinite; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0 var(--sp-5) var(--sp-4); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; font-size: var(--fs-sm); color: var(--text-2); padding: 2px 6px; border-radius: var(--r-sm); border: 0; background: none; cursor: pointer; }
@media (hover: hover) { .legend-item:hover { background: var(--surface-2); } }
.legend-item.is-off { opacity: 0.4; text-decoration: line-through; }
.legend-item .legend-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.legend-item .legend-val { color: var(--text-3); font-variant-numeric: tabular-nums; }
.legend-list .legend-val { display: inline-flex; align-items: center; gap: 6px; }
.legend-list .legend-drill { width: 14px; height: 14px; flex: none; } /* same slot whether or not the row can drill, so amounts share a right edge */
.legend-list { display: flex; flex-direction: column; gap: 2px; }
.legend-list .legend-item { display: flex; width: 100%; justify-content: space-between; padding: 6px 8px; }
.legend-list .legend-item .legend-name { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-control); border-radius: var(--r-md); padding: 2px; gap: 2px; }
.seg-btn { height: 26px; padding: 0 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); transition: background var(--dur-1), color var(--dur-1); white-space: nowrap; }
@media (hover: hover) { .seg-btn:hover { color: var(--text-1); } }
.seg-btn.active { background: var(--surface); color: var(--text-1); box-shadow: var(--sh-1); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.tabs > .tab { flex: 0 0 auto; scroll-snap-align: start; }
.tab { height: 38px; padding: 0 12px; font-size: var(--fs-base); font-weight: 500; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; transition: color var(--dur-1), border-color var(--dur-1); }
@media (hover: hover) { .tab:hover { color: var(--text-1); } }
.tab.active, .tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Tabbed sub-page layout (Settings, Admin): a sticky side nav beside a panel column,
   collapsing to a horizontal scroller on narrow screens. */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: var(--sp-6); align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + var(--safe-top) + 16px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav .nav-item { height: 34px; }
@media (pointer: coarse) { .settings-nav .nav-item { height: var(--tap); } }
.settings-section { margin-bottom: var(--sp-6); }
.settings-section h2 { font-size: var(--fs-lg); margin-bottom: 4px; }
.settings-section .sub { color: var(--text-3); font-size: var(--fs-base); margin-bottom: var(--sp-4); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .title { font-weight: 500; font-size: var(--fs-md); }
.setting-row .desc { color: var(--text-3); font-size: var(--fs-sm); margin-top: 2px; }
.user-status { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 960px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; }
  .settings-nav .nav-item { flex: 0 0 auto; }
}

/* ---------- Layers: popover, menu, modal, drawer ---------- */
/* Dark layers are lighter than the page (elevation), so anything filled with --surface-2 inside them
   (inputs, tiles, active menu rows, segmented tracks) steps up to --surface-3 to stay visible. */
:root[data-theme="dark"] :is(.modal, .popover, .palette, .toast, .drawer) { --surface-2: var(--surface-3); }
.popover { position: fixed; z-index: 650; min-width: 200px; background: var(--surface-overlay); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-2); animation: pop-in var(--dur-2) var(--ease-out); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.tooltip { position: fixed; z-index: 660; max-width: 260px; padding: 5px 8px; font-size: var(--fs-sm); line-height: 1.35; background: var(--text-1); color: var(--bg); border-radius: var(--r-sm); box-shadow: var(--sh-1); pointer-events: none; animation: pop-in var(--dur-1); }
.menu { padding: 4px; min-width: 180px; max-height: 70vh; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px; border-radius: var(--r-md); font-size: var(--fs-base); color: var(--text-1); text-align: left; white-space: nowrap; text-decoration: none; }
.menu-item.is-active { background: var(--surface-2); text-decoration: none; }
@media (hover: hover) { .menu-item:hover { background: var(--surface-2); text-decoration: none; } }
.menu-item .ico { width: 16px; height: 16px; color: var(--text-3); }
.menu-item.danger { color: var(--danger-text); }
.menu-item.danger .ico { color: var(--danger-text); }
.menu-item .menu-check { margin-left: auto; width: 16px; color: var(--accent); }
.menu-item .menu-count { margin-left: auto; color: var(--text-4); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.menu-label { padding: 8px 10px 4px; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-4); }
.menu-search { padding: 4px 4px 6px; }
.amount-filter { width: 260px; padding: 4px 10px 8px; }
.amount-filter .field { margin-bottom: var(--sp-3); }
.mv-row { gap: var(--sp-3); }
.drp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.drp-custom { border-left: 1px solid var(--border); padding-left: 10px; }
.mp { width: 300px; padding: var(--sp-2); }
.mp-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 var(--sp-2); }
.mp-year { font-weight: 600; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.mp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-1); }
.mp-month { height: var(--control-h); border-radius: var(--r-md); font-size: var(--fs-base); font-weight: 500; color: var(--text-2); border: 1px solid transparent; }
.mp-month.active { background: var(--accent-solid); color: var(--accent-solid-fg); }
.mp-month:disabled { color: var(--text-4); opacity: 0.5; cursor: not-allowed; }
.mp-month:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) { .mp-month:not(:disabled):not(.active):hover { background: var(--surface-2); color: var(--text-1); } }
.menu-opts { max-height: calc(70vh - 96px); overflow-y: auto; overscroll-behavior: contain; }
.menu-item .check-fake { width: 16px; height: 16px; flex: 0 0 auto; border: 1.5px solid var(--border-control); border-radius: var(--r-xs); background: var(--surface); position: relative; }
.menu-item[aria-checked="true"] .check-fake { background: var(--accent-solid); border-color: var(--accent-solid); }
.menu-item[aria-checked="true"] .check-fake::after { content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid var(--accent-solid-fg); border-width: 0 2px 2px 0; transform: rotate(45deg); }

.modal-backdrop { position: fixed; inset: 0; z-index: 600; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); animation: fade-in var(--dur-2); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface-overlay); border-radius: var(--r-xl); box-shadow: var(--sh-3); animation: modal-in var(--dur-3) var(--ease-out); border: 1px solid var(--border); }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5) 0; }
.modal-head h2 { font-size: var(--fs-lg); }
.modal-body { padding: var(--sp-4) var(--sp-5); overflow-y: auto; }
.modal-body p { font-size: var(--fs-base); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: 0 var(--sp-5) var(--sp-5); }
.modal-lg { max-width: 680px; }
/* split editor */
.split-head { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: baseline; margin-bottom: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); }
.split-line { display: grid; grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr) 32px; gap: 8px; align-items: center; margin-bottom: 8px; }
.split-line .catbtn { max-width: 100%; justify-content: flex-start; }
.split-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-2); }
.split-remaining { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.split-remaining b { font-variant-numeric: tabular-nums; color: var(--success); }
.split-remaining.is-off b { color: var(--danger-text); }
.txd-split-line { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: var(--fs-sm); }
.txd-split-line .num { margin-left: auto; font-variant-numeric: tabular-nums; }
.modal-xl { max-width: 900px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 550; background: var(--overlay); animation: fade-in var(--dur-2); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 560; width: min(480px, 100vw); padding-top: var(--safe-top); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--sh-3); display: flex; flex-direction: column; animation: drawer-in var(--dur-3) var(--ease-out); }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
.drawer-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); flex: 0 0 auto; }
.drawer-head h2 { font-size: var(--fs-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-5); }
.drawer-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); display: flex; gap: var(--sp-2); justify-content: flex-end; flex: 0 0 auto; }

/* ---------- Command palette ---------- */
.palette-backdrop { position: fixed; inset: 0; z-index: 700; background: var(--overlay); display: flex; justify-content: center; align-items: flex-start; padding: 12vh var(--sp-4) var(--sp-4); animation: fade-in var(--dur-2); }
.palette { width: 100%; max-width: 600px; background: var(--surface-overlay); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-3); overflow: hidden; animation: modal-in var(--dur-3) var(--ease-out); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 52px; border-bottom: 1px solid var(--border); }
.palette-input .ico { color: var(--text-3); }
.palette-input input { flex: 1; height: 100%; border: 0; background: none; outline: none; font-size: var(--fs-lg); }
.palette-list { max-height: 60vh; overflow-y: auto; padding: 6px; }
.palette-group { padding: 8px 10px 4px; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-4); }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-md); text-align: left; font-size: var(--fs-base); color: var(--text-1); }
.palette-item.is-active { background: var(--surface-2); }
@media (hover: hover) { .palette-item:hover { background: var(--surface-2); } }
.palette-item .ico { color: var(--text-3); width: 16px; height: 16px; }
.palette-item .sub { color: var(--text-3); font-size: var(--fs-sm); margin-left: auto; white-space: nowrap; }
.palette-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: var(--fs-base); }

/* ---------- Toasts ---------- */
#toast-root { position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 800; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; background: var(--surface-overlay); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-2); font-size: var(--fs-base); animation: toast-in var(--dur-3) var(--ease-out); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--dur-2), transform var(--dur-2); }
.toast .ico { width: 16px; height: 16px; }
.toast-success .ico { color: var(--success); }
.toast-error .ico { color: var(--danger); }
.toast-info .ico { color: var(--accent); }
.toast-msg { flex: 1; min-width: 0; }
.toast-count { font-size: var(--fs-xs); color: var(--text-4); font-variant-numeric: tabular-nums; }
.toast-action { color: var(--accent); font-weight: 600; padding: 4px 6px; border-radius: var(--r-sm); white-space: nowrap; }
@media (hover: hover) { .toast-action:hover { background: var(--accent-soft); } }
.toast-close { color: var(--text-4); width: 24px; height: 24px; border-radius: var(--r-sm); display: grid; place-items: center; }
@media (hover: hover) { .toast-close:hover { background: var(--surface-2); color: var(--text-1); } }

/* ---------- Skeleton, empty, error ---------- */
/* Placeholders pulse in opacity — composited, so dozens of them cost no repaint per frame (a moving
   background-position gradient repainted every one on every frame while the page was still loading). */
.skel { display: block; border-radius: var(--r-sm); background: var(--surface-3); animation: skel-pulse 1.4s ease-in-out infinite; }
@keyframes skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .skel, .chart-body.is-loading::after { animation: none; } }
.skel-row td { height: var(--row-h); }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--sp-10) var(--sp-5); gap: 6px; }
.empty-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); display: grid; place-items: center; margin-bottom: 6px; }
.empty-icon .ico { width: 20px; height: 20px; }
.empty-title { font-weight: 600; font-size: var(--fs-md); }
.empty-body { font-size: var(--fs-base); color: var(--text-3); max-width: 360px; }
.empty .btn { margin-top: 10px; }
.error-box { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger-text); font-size: var(--fs-base); }
.error-box .ico { flex: 0 0 auto; margin-top: 1px; }
.error-box .btn { margin-left: auto; }
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--info-soft); color: var(--text-1); font-size: var(--fs-base); border: 1px solid transparent; }
.notice .ico { color: var(--accent); flex: 0 0 auto; margin-top: 1px; }
.notice-warning { background: var(--warning-soft); }
.notice-warning .ico { color: var(--warning); }

/* ---------- Dropzone, stepper, progress ---------- */
.dropzone { border: 2px dashed var(--border-control); border-radius: var(--r-xl); min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: var(--sp-8); text-align: center; background: var(--surface); transition: border-color var(--dur-2), background var(--dur-2); cursor: pointer; }
@media (hover: hover) { .dropzone:hover { border-color: var(--text-4); } }
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { width: 48px; height: 48px; border-radius: var(--r-lg); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.dropzone-icon .ico { width: 22px; height: 22px; }
.dropzone-title { font-weight: 600; font-size: var(--fs-md); }
.dropzone-sub { color: var(--text-3); font-size: var(--fs-base); }
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: var(--sp-5); }
.step { display: flex; align-items: center; gap: 8px; font-size: var(--fs-base); color: var(--text-3); font-weight: 500; }
.step-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 600; background: var(--surface-3); color: var(--text-3); }
.step.active { color: var(--text-1); }
.step.active .step-num { background: var(--accent-solid); color: var(--accent-solid-fg); }
.step.done .step-num { background: var(--success-soft); color: var(--success); }
.step-line { flex: 0 0 32px; height: 1px; background: var(--border-strong); }
.progress { width: 100%; height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent-solid); border-radius: inherit; transition: width var(--dur-3) var(--ease-out); }
.progress-thin { height: 3px; }

/* ---------- Bars (save/bulk) ---------- */
.floatbar { position: fixed; left: calc(50% + var(--sidebar-cur, 0px) / 2); bottom: 24px; transform: translateX(-50%); z-index: 450; display: flex; align-items: center; gap: var(--sp-3); padding: 10px 12px 10px 16px; background: var(--text-1); color: var(--bg); border-radius: var(--r-pill); box-shadow: var(--sh-3); font-size: var(--fs-base); animation: toast-in var(--dur-3) var(--ease-out); white-space: nowrap; max-width: calc(100vw - 32px); }
.floatbar .btn { height: 30px; }
.floatbar .btn-ghost { color: var(--bg); }
@media (hover: hover) { .floatbar .btn-ghost:hover { background: color-mix(in srgb, var(--bg) 14%, transparent); } }
.floatbar .btn-primary { background: var(--bg); color: var(--text-1); }
@media (hover: hover) { .floatbar .btn-primary:hover { filter: brightness(0.95); } }
.floatbar .sep { width: 1px; height: 20px; background: rgba(128,128,128,0.4); }

/* ---------- Misc ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: var(--sp-3); padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; background: var(--c); border: 2px solid transparent; cursor: pointer; position: relative; transition: transform var(--dur-1); }
@media (hover: hover) { .swatch:hover { transform: scale(1.1); } }
.swatch.active { border-color: var(--text-1); box-shadow: 0 0 0 2px var(--surface); }
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.icon-grid button { width: 34px; height: 34px; border-radius: var(--r-md); display: grid; place-items: center; color: var(--text-2); }
@media (hover: hover) { .icon-grid button:hover { background: var(--surface-2); color: var(--text-1); } }
.icon-grid button.active { background: var(--accent-soft); color: var(--accent); }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding-bottom: 14px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.tl-dot .ico { width: 11px; height: 11px; }
.tl-text { font-size: var(--fs-base); }
.tl-time { font-size: var(--fs-xs); color: var(--text-4); }
.shortcuts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; font-size: var(--fs-base); }
.shortcuts-grid div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; }
.shortcuts-grid .keys { display: flex; gap: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .btn.tb-menu { display: inline-flex; }
  .main { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .topbar { padding: var(--safe-top) var(--sp-4) 0; }
}
@media (max-width: 768px) {
  .input-sm, .select-sm { font-size: var(--fs-md); }
  .modal, .modal-body, .drawer, .drawer-body, .popover, .menu-opts, .sb-nav { overscroll-behavior: contain; }
  .main { padding-left: calc(var(--sp-4) + var(--safe-left)); padding-right: calc(var(--sp-4) + var(--safe-right)); }
  .topbar { padding-left: calc(var(--sp-4) + var(--safe-left)); padding-right: calc(var(--sp-4) + var(--safe-right)); }
  .drawer-foot { padding-bottom: calc(var(--sp-3) + var(--safe-bottom)); }
  .modal-foot { padding-bottom: calc(var(--sp-5) + var(--safe-bottom)); }
  /* opaque on phones: a translucent bar lets charts and amounts show through as you scroll */
  .topbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .tb-search { width: auto; margin-left: auto; }
  .tb-search span, .tb-search kbd { display: none; }
  .tb-search { width: var(--control-h); height: var(--control-h); padding: 0; justify-content: center; }
  .tb-username { display: none; }
  .tb-profile:not([hidden]) { display: inline-flex; align-items: center; gap: 6px; max-width: 40vw; height: 32px; padding: 0 12px; border: 1px solid var(--border-control); border-radius: var(--r-pill); background: var(--surface); color: var(--text-1); font-size: var(--fs-sm); font-weight: 550; }
  .main { padding-bottom: calc(88px + var(--safe-bottom)); }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 250; height: calc(64px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--border); padding: 6px calc(4px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(4px + var(--safe-left)); }
  .bn-item { flex: 1 1 auto; min-width: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); text-decoration: none; border-radius: var(--r-md); position: relative; }
  .bn-ico { position: relative; display: grid; place-items: center; width: 56px; height: 30px; border-radius: var(--r-pill); transition: background var(--dur-2); }
  .bn-item .ico { width: 22px; height: 22px; }
  .bn-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bn-item[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .bn-item[aria-current="page"] .bn-ico { background: var(--accent-soft); }
  .bn-item .pill { position: absolute; top: -4px; left: calc(50% + 4px); }
  .bn-item .pill-dot { min-width: 0; width: 10px; height: 10px; padding: 0; top: 0; left: calc(50% + 8px); box-shadow: 0 0 0 2px var(--surface); }
  /* phone chrome: no hamburger or theme toggle (both live in More), a "+" for the page's main action */
  .btn.tb-menu, #tb-theme, .tb-avatar-btn > .ico { display: none; }
  .btn.tb-primary { display: inline-flex; border-radius: var(--r-pill); }
  .phone-only, .btn.phone-only { display: inline-flex; }
  #main [data-primary-action], #main .page-head [data-overflow] { display: none; }
  .page-head { position: relative; }
  .btn.page-more { display: inline-flex; position: absolute; top: 0; right: 0; }
  .page-head:has(.page-more) > div:first-child { padding-right: calc(var(--control-h) + var(--sp-2)); }
  .page-actions:not(:has(> :not([data-overflow]):not([data-primary-action]):not([hidden]))) { display: none; }
  .topbar:not(.show-title) .tb-title { opacity: 0; }
  .page-head h1 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: var(--lh-tight); }
  .drawer { width: 100vw; border-left: 0; }
  .modal { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .modal-backdrop { padding: var(--sp-2); align-items: flex-end; }
  .modal-backdrop.is-sheet { padding: 0 0 var(--kb-inset); }
  .modal--sheet { position: relative; max-width: none !important; max-height: calc(100vh - 24px - var(--kb-inset)); max-height: calc(100dvh - 24px - var(--kb-inset)); border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; padding-left: var(--safe-left); padding-right: var(--safe-right); animation: sheet-in var(--dur-3) var(--ease-out); transition: transform var(--dur-2) var(--ease-out); }
  .modal--sheet::before, .popover--sheet::before { content: ''; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: var(--r-pill); background: var(--border-strong); }
  .modal--sheet .modal-head { padding-top: var(--sp-6); }
  .modal--sheet .modal-foot > .btn { flex: 1 1 0; }
  /* popovers (menus, pickers, filters) become bottom sheets over a backdrop */
  .sheet-backdrop { position: fixed; inset: 0; z-index: 640; background: var(--overlay); animation: fade-in var(--dur-2); }
  .popover--sheet { top: auto !important; left: 0 !important; right: 0; bottom: var(--kb-inset); width: auto !important; min-width: 0 !important; max-height: calc(100vh - 48px - var(--kb-inset)); max-height: calc(100dvh - 48px - var(--kb-inset)); overflow-y: auto; overscroll-behavior: contain; border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; padding: var(--sp-6) calc(var(--sp-3) + var(--safe-right)) calc(var(--sp-3) + var(--safe-bottom)) calc(var(--sp-3) + var(--safe-left)); box-shadow: var(--sh-3); animation: sheet-in var(--dur-3) var(--ease-out); transition: transform var(--dur-2) var(--ease-out); }
  .popover--sheet .drp-grid { grid-template-columns: 1fr; }
  .popover--sheet .drp-custom { border-left: 0; padding-left: 0; }
  .popover--sheet .drp-grid [role="radiogroup"] { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
  .popover--sheet .drp-grid [data-preset] { border: 1px solid var(--border-control); justify-content: center; }
  .popover--sheet .drp-grid [data-preset][aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
  .popover--sheet .drp-grid [data-preset] .menu-check { display: none; }
  .popover--sheet .drp-grid [data-preset] .grow { flex: 0 1 auto; }
  .popover--sheet .drp-custom { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--sp-2); padding-top: var(--sp-3); }
  .popover--sheet .drp-custom > .menu-label, .popover--sheet .drp-custom > [data-act="apply"] { grid-column: 1 / -1; }
  .popover--sheet [data-act="apply"] { height: var(--tap); font-size: var(--fs-md); position: sticky; bottom: 0; }
  .popover--sheet .menu-item { height: var(--tap); }
  .popover--sheet.mp .mp-grid { grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
  .popover--sheet.mp .mp-month { height: 48px; border-color: var(--border-control); }
  .popover--sheet.mp .mp-head { padding-bottom: var(--sp-3); }
  .modal--sheet .modal-foot { position: sticky; bottom: 0; padding-top: var(--sp-3); padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); background: var(--surface-overlay); border-top: 1px solid var(--border); }
  .modal--sheet .modal-foot .btn, .modal--sheet .split-line .input, .modal--sheet .split-line .catbtn { min-height: 44px; }
  .split-line { grid-template-columns: minmax(0, 1fr) 110px 32px; }
  .split-line [data-sl-note] { grid-column: 1 / -1; }
  .page-head { margin-bottom: var(--sp-4); }
  .stat { min-height: 96px; }
  .stat-value { font-size: 1.375rem; }
  .shortcuts-grid { grid-template-columns: 1fr; }
  #toast-root { right: var(--sp-3); left: var(--sp-3); bottom: calc(76px + var(--safe-bottom)); max-width: none; }
  .floatbar { bottom: calc(76px + var(--safe-bottom)); left: calc(var(--sp-2) + var(--safe-left)); right: calc(var(--sp-2) + var(--safe-right)); transform: none; max-width: none; overflow-x: auto; scrollbar-width: none; border-radius: var(--r-lg); }
  .floatbar .btn { height: var(--control-h-sm); flex: 0 0 auto; }
  body:has(.floatbar:not([hidden])) #toast-root { bottom: calc(136px + var(--safe-bottom)); }
  .field-row { flex-direction: column; gap: 0; }
}
@media (max-width: 768px) {
  /* .tbl--cards: one card per row, header labels painted from td[data-label]; the actions cell pins top-right */
  .tbl--cards thead { display: none; }
  .tbl--cards, .tbl--cards tbody, .tbl--cards tr { display: block; width: 100%; }
  .tbl--cards tr { position: relative; padding: 10px 44px 10px 12px; border-bottom: 1px solid var(--border); }
  .tbl--cards tr:last-child { border-bottom: 0; }
  .tbl--cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 2px 0; border: 0; height: auto; width: auto; max-width: none; text-align: left; white-space: normal; }
  .tbl--cards td.right { text-align: left; }
  .tbl--cards td[data-label]::before { content: attr(data-label); color: var(--text-4); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; flex: 0 0 auto; }
  .tbl--cards td:first-child { font-size: var(--fs-md); margin-bottom: 4px; }
  .tbl--cards td.col-actions { position: absolute; top: 8px; right: 6px; width: auto; padding: 0; margin: 0; } /* beats .tbl .col-actions { width: 1% } */
  .tbl--cards td.col-actions .row-actions, .tbl--cards td.col-actions .row-actions > .btn-icon { opacity: 1; }
  .tbl--cards td.hide-mobile { display: none; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
  .stat-grid > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* the title takes the line and wraps inside itself; actions stay on its right, or drop below it
     still right-aligned when there is no room */
  .card-head { flex-wrap: wrap; min-height: 0; }
  .card-head > h2, .card-head > h3 { flex: 1 1 10rem; min-width: 0; }
  .card-head > .card-actions { margin-left: auto; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions > .seg { flex: 1 1 100%; display: flex; }
  .page-actions > .seg > .seg-btn { flex: 1 1 auto; }
  .page-actions > .btn-primary, .page-actions > .btn-secondary { flex: 1 1 auto; }
}
@media (max-width: 480px) {
  .stat { padding: 12px 14px; min-height: 84px; gap: 4px; }
  .stat-value { font-size: clamp(1.125rem, 6vw, var(--fs-xl)); } /* "+$4,170.93" fits a 320px half-width card */
  .stat-spark { display: none; }
  .stat-delta { font-size: var(--fs-xs); flex-wrap: wrap; row-gap: 0; }
}
@media (hover: none) {
  .row-actions, .row-actions > .btn-icon, .cat-actions, .rule-actions, .rec-dismiss, .tbl-tx .row-actions { opacity: 1; }
}
@media (pointer: coarse) {
  /* Every small control keeps its look but gets a --tap (44px) hit area: an invisible ::before that
     only grows past the element's own box (min(0, (100% - 44px) / 2) on each side). */
  .btn-sm, .btn-xs, .seg-btn, .catchip, .chip, .tab, .menu-item, .legend-item, .bd-toggle, .cat-chevron, .toast-close, .tagchip-x, .switch, .sb-collapse, .row-link { position: relative; }
  .btn-sm::before, .btn-xs::before, .seg-btn::before, .catchip::before, .chip::before, .legend-item::before, .bd-toggle::before, .cat-chevron::before,
  .toast-close::before, .tagchip-x::before, .switch-track::before, .row-link::before {
    content: ''; position: absolute;
    top: min(0px, calc((100% - var(--tap)) / 2)); bottom: min(0px, calc((100% - var(--tap)) / 2));
    left: min(0px, calc((100% - var(--tap)) / 2)); right: min(0px, calc((100% - var(--tap)) / 2));
  }
  .btn-xs, .seg-btn, .catchip { min-height: 36px; }
  .seg-btn { min-width: var(--tap); flex-shrink: 0; }
  .page-actions > .seg > .seg-btn { min-width: fit-content; }
  .switch, .row-link, .legend-list .legend-item { min-height: var(--tap); }
  .btn-icon.btn-xs { width: 36px; }
  .menu-item { height: var(--tap); }
  .tab { height: var(--tap); }
  .nav-item { height: var(--tap); }
  .check { width: 22px; height: 22px; }
  .catcell .sugg-act .btn { width: 36px; height: 36px; }
  .btn:active, .seg-btn:active, .chip:active, .catchip:active, .menu-item:active, .nav-item:active, .bn-item:active { filter: brightness(0.94); }
  :root[data-theme="dark"] .btn:active, :root[data-theme="dark"] .menu-item:active, :root[data-theme="dark"] .nav-item:active { filter: brightness(1.18); }
}

.notice-info { background: var(--info-soft); border-color: transparent; color: var(--text-1); }
.notice-info .ico { color: var(--accent); }

.avatar-xs { width: 20px; height: 20px; font-size: var(--fs-xs); }

/* multiFilter header with All / None */
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 2px 10px; }
.menu-head .menu-label { padding: 0; }
.menu-head-actions { display: inline-flex; align-items: center; gap: 2px; }
.menu-head-actions .menu-count { font-size: var(--fs-xs); color: var(--text-4); margin-right: 4px; }
.menu-item--child .grow { color: var(--text-2); }

.skip-nav { display: contents; }

/* .dots: a wrapping meta line whose items are separated by "·". Each dot sits in its item's left
   padding and the list is pulled 1 dot-width left and clipped there, so an item that starts a line
   never shows a stray dot. Children must be elements (text nodes get no dot). */
.dots { --dot-w: 0.875rem; display: flex; flex-wrap: wrap; align-items: center; row-gap: 2px; min-width: 0; margin-left: calc(-1 * var(--dot-w)); clip-path: inset(-6px -6px -6px var(--dot-w)); }
.dots > * { position: relative; padding-left: var(--dot-w); min-width: 0; }
.dots > *::before { content: '·'; position: absolute; left: 0; top: 0; bottom: 0; width: var(--dot-w); display: flex; align-items: center; justify-content: center; color: var(--text-4); }
.dots > .dots-group { display: inline-flex; align-items: center; gap: 6px; }

.row-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; min-height: 24px; }
@media (hover: hover) { .row-link:hover { text-decoration: underline; } }
.row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }

/* Full-width notice above the page content (trial, grace, read-only, unverified email). */
.app-banner { border-radius: 0; padding: var(--sp-3) var(--sp-6); align-items: center; }
.shell > .app-banner + .app-banner { border-top: 1px solid var(--border); }
/* Read-only accounts: primary create actions are dimmed so they read as intentional rather than
   broken. Anything not marked still degrades to the 402 toast. */
body[data-readonly] [data-needs-write] { opacity: 0.45; pointer-events: none; }

/* ---------- Swipe rows (ui.swipe) ---------- */
.is-swiping { position: relative; overflow: hidden; isolation: isolate; }
.is-swiping > :not(.swipe-back) { transform: translateX(var(--swipe-x, 0)); transition: none; background: var(--surface); }
.swipe-back { position: absolute; inset: 0; z-index: -1; display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-5); font-weight: 600; color: #fff; background: var(--accent-solid); }
.swipe-back--left { justify-content: flex-end; }
.swipe-back.is-ok { background: var(--success); }
.swipe-back.is-muted { background: var(--text-3); }
.swipe-back .ico { width: 20px; height: 20px; }
[data-tip]:not(button):not(a):not(input) { -webkit-touch-callout: none; }

/* ---------- More sheet (phone) ---------- */
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.more-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 80px; padding: var(--sp-2); border-radius: var(--r-lg); background: var(--surface-2); color: var(--text-1); font-size: var(--fs-sm); font-weight: 500; text-align: center; text-decoration: none; }
.more-tile .ico { width: 24px; height: 24px; color: var(--text-2); }
.more-tile[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.more-tile .pill { position: absolute; top: 8px; right: 8px; }
.more-tile[aria-current="page"] .ico { color: var(--accent); }
.more-tile:active { filter: brightness(0.95); }
.more-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.more-row { display: flex; align-items: center; gap: var(--sp-3); min-height: 52px; padding: 0 var(--sp-4); color: var(--text-1); text-decoration: none; text-align: left; width: 100%; font-size: var(--fs-md); }
.more-row + .more-row { border-top: 1px solid var(--border); }
.more-row.danger { color: var(--danger-text); }
.more-theme { display: flex; width: 100%; }
.more-theme .seg-btn { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.more-sheet .modal-body { padding-bottom: calc(var(--sp-5) + var(--safe-bottom)); }

/* ---------- .tbl--list: phone list rows for record tables (with .tbl--cards) ----------
   The first cell is the title line; the other cells run together underneath as one quiet meta line
   separated by dots, without the UPPERCASE label stacks. data-unit="transactions" appends a unit to a
   bare number. Desktop is unaffected. */
@media (max-width: 768px) {
  /* rows are a wrapping flex line: the title fills the first line, the meta cells follow with a "·"
     in each cell's left padding. The row's left inset is a transparent border and the row clips at
     it, and every meta cell is shifted one dot-width left, so a cell that starts a line hides its dot. */
  .tbl--list.tbl--cards tr { --dot-w: 0.875rem; display: flex; flex-wrap: wrap; align-items: center; align-content: center; row-gap: 2px; padding: 12px 60px 12px 0; border-left: var(--sp-4) solid transparent; overflow: hidden; min-height: 64px; line-height: 1.45; }
  .tbl--list.tbl--cards tr:has(.row-actions > :nth-child(2)) { padding-right: 108px; }
  .tbl--list.tbl--cards tr:has(.row-actions > .btn:not(.btn-icon)) { padding-right: 150px; }
  .tbl--list.tbl--cards td { display: block; flex: 0 1 auto; min-width: 0; position: relative; left: calc(-1 * var(--dot-w)); padding: 0 0 0 var(--dot-w); font-size: var(--fs-sm); color: var(--text-3); white-space: normal; }
  .tbl--list.tbl--cards td.hide-mobile, .tbl--list.tbl--cards td:empty { display: none; }
  .tbl--list.tbl--cards td:first-child { flex: 0 0 100%; left: 0; padding: 0; margin: 0 0 2px; font-size: var(--fs-md); color: var(--text-1); }
  .tbl--list.tbl--cards td[data-label]::before { content: none; }
  .tbl--list.tbl--cards td:not(:first-child):not(.col-actions)::before { content: '·'; position: absolute; left: 0; top: 0; bottom: 0; width: var(--dot-w); display: flex; align-items: center; justify-content: center; color: var(--text-4); }
  .tbl--list.tbl--cards td[data-unit]::after { content: attr(data-unit); }
  .tbl--list.tbl--cards td.num, .tbl--list.tbl--cards td[data-unit] { white-space: nowrap; }
  .tbl--list.tbl--cards td.col-actions { display: block; position: absolute; left: auto; padding: 0; top: 50%; transform: translateY(-50%); right: var(--sp-2); }
  .tbl--list.tbl--cards .st-counts { display: inline; }
  .tbl--list.tbl--cards .st-counts .muted { margin-left: 4px; }
  .tbl--list.tbl--cards .st-status { display: inline-flex; vertical-align: middle; }
}
@media (pointer: coarse) { .row-actions { gap: 6px; } a.row-link { min-height: var(--tap); } }

/* ---------- Screen changes ----------
   Every screen is its own page; a cross-document view transition keeps the old screen up until the
   new one can paint, then crossfades the content while the topbar, bottom nav and sidebar stay put
   (each is its own transition group, so only a changed active tab fades). Browsers without support
   (Safari < 18.2, Chrome < 126) and Reduce Motion simply swap. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.topbar { view-transition-name: topbar; }
.bottomnav { view-transition-name: bottomnav; }
.sidebar { view-transition-name: sidebar; }
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) { animation-duration: var(--dur-2); animation-timing-function: var(--ease-out); }

/* ---------- Touch feedback ----------
   Tapping should answer at once. Tappable rows darken while pressed; the change waits 60 ms, so a
   finger that starts scrolling (which cancels :active) never flashes the rows it crosses, and fades
   back on release. iOS only applies :active because ui.js registers a passive touchstart listener. */
html { -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  .tbl-tx tbody tr[data-id], .tbl tbody tr.is-clickable, .list-item.is-clickable, .cat-row, .rule, .more-row,
  .fs-row, .palette-item, .tb-search, .tb-avatar-btn, .bd-row {
    transition: background-color var(--dur-2) var(--ease-out);
  }
  .tbl-tx tbody tr[data-id]:active, .tbl tbody tr.is-clickable:active, .list-item.is-clickable:active, .cat-row:active,
  .rule:active, .more-row:active, .fs-row:active, .palette-item:active, .tb-search:active, .tb-avatar-btn:active, .bd-row:active {
    background-color: var(--surface-2);
    transition-duration: 0s;
    transition-delay: 60ms;
  }
  /* The tab just tapped lights up while the next screen loads (nav.js), and the old one lets go. */
  .bottomnav.is-going .bn-item[aria-current="page"]:not(.is-going) { color: var(--text-3); font-weight: 500; }
  .bottomnav.is-going .bn-item[aria-current="page"]:not(.is-going) .bn-ico { background: none; }
  .bn-item.is-going { color: var(--accent); font-weight: 600; }
  .bn-item.is-going .bn-ico { background: var(--accent-soft); }
}

/* ---------- Problem reports (report.js: the form opens on any page; Help reuses the picker) ---------- */
.rp-kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: var(--sp-2); margin: 0 0 var(--sp-4); padding: 0; border: 0; }
.rp-kinds legend { margin-bottom: var(--sp-2); }
.rp-kind { position: relative; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-control); border-radius: var(--r-md); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1); }
.rp-kind input, .rp-chip input { position: absolute; opacity: 0; pointer-events: none; }
.rp-kind .ico { flex: 0 0 auto; color: var(--text-3); }
.rp-kind:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--text-1); }
.rp-kind:has(input:checked) .ico { color: var(--accent); }
.rp-kind:has(input:focus-visible), .rp-chip:has(input:focus-visible) { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
@media (hover: hover) { .rp-kind:hover, .rp-chip:hover { border-color: var(--text-4); } }
.rp-impact { border: 0; padding: 0; margin: 0 0 var(--sp-4); }
.rp-impact legend { margin-bottom: 6px; }
.rp-impacts { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.rp-chip { position: relative; display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px; border: 1px solid var(--border-control); border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.rp-chip:has(input:checked) { border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rp-suggest { margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--info-soft); }
.rp-suggest .section-label { margin-bottom: 4px; }
.rp-answer summary { cursor: pointer; padding: 4px 0; font-weight: 500; color: var(--text-1); }
.rp-answer p { margin: 2px 0 8px; color: var(--text-2); font-size: var(--fs-sm); }
.rp-answer:not([open]) > p { display: none; }
.rp-files { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.rp-files:empty { display: none; }
.rp-thumb { position: relative; width: 96px; height: 72px; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.rp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.btn.rp-thumb-x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: var(--r-pill); background: var(--surface-overlay); color: var(--text-1); }
.rp-drop { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: var(--sp-3); border: 2px dashed var(--border-control); border-radius: var(--r-md); color: var(--text-3); font-size: var(--fs-sm); cursor: pointer; transition: border-color var(--dur-2), background var(--dur-2); }
.rp-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.rp-drop.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.rp-drop:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.rp-drop-touch { display: none; }
@media (pointer: coarse) { .rp-drop-mouse { display: none; } .rp-drop-touch { display: inline; font-weight: 500; color: var(--accent); } }
.rp-tech { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.rp-tech-toggle { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; min-height: 32px; }
.rp-tech-details summary { cursor: pointer; margin-top: 4px; color: var(--accent); font-size: var(--fs-sm); font-weight: 500; }
.rp-tech-details .hint { margin: var(--sp-2) 0; }
.rp-tech-details.is-off .rp-json { opacity: 0.5; text-decoration: line-through; }
.rp-json { max-height: 220px; overflow: auto; margin: 0; padding: var(--sp-3); border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.rp-sent { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-4); }
.rp-sent-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success); }
.rp-sent-icon .ico { width: 28px; height: 28px; }
.rp-sent-title { font-size: var(--fs-lg); font-weight: 600; }
.rp-ref { font-size: var(--fs-md); }
.rp-sent p { max-width: 420px; margin: var(--sp-2) 0 0; }
