/* ==========================================================================
   Design tokens + components (from Kept). Change the accent primitives for
   each app; components only read semantic tokens
   Layers: 1 primitives → 2 semantic → 3 component.  .theme-dark swaps the
   semantic layer, so the whole app follows.
   ========================================================================== */

:root {
  /* ---------- 1. Primitives ---------- */
  /* Accent: monochrome. Black on light, white on dark */
  --black:#000000; --white:#FFFFFF;

  --ink-0:#FFFFFF; --ink-25:#FAFAFB; --ink-50:#F4F4F6; --ink-100:#ECEBF0; --ink-200:#E0DFE6;
  --ink-300:#C9C8D2; --ink-400:#A3A2AE; --ink-500:#6B6A77; --ink-600:#55545F; --ink-700:#3D3C46;
  --ink-800:#24232B; --ink-900:#16161B; --ink-950:#0D0D11;

  --green-50:#E7F6EE; --green-500:#127A47; --green-400:#3DBE7E;
  --red-50:#FCEBEA;   --red-500:#B8322A;   --red-400:#F0685C;
  --amber-50:#FDF2E1; --amber-500:#8F5309; --amber-400:#F0A43A;

  /* ---------- 2. Semantic (light) ---------- */
  --bg-canvas:var(--ink-50);
  --bg-surface:var(--ink-0);
  --bg-subtle:var(--ink-50);
  --bg-muted:var(--ink-100);
  --bg-inverse:var(--ink-950);
  --bg-overlay:rgba(13,13,17,.36);

  --fg-default:var(--ink-950);
  --fg-muted:var(--ink-600);
  --fg-subtle:var(--ink-500);
  --fg-disabled:var(--ink-400);
  --fg-placeholder:#75747F; /* 4.6:1 on surface */
  --fg-inverse:var(--ink-0);
  --fg-on-accent:#FFFFFF;

  --border-default:var(--ink-100);
  --border-strong:var(--ink-300);
  --border-control:#8A8996; /* edges that show where a field or switch is: 3.4:1 on surface, 3.1:1 on canvas (WCAG 1.4.11) */
  --border-focus:var(--ink-700);

  --accent:var(--black);
  --accent-hover:var(--ink-800);
  --accent-fg:var(--black);
  --accent-soft:var(--ink-100);
  --accent-softer:var(--ink-25);
  --accent-border:var(--ink-300); /* edge for accent-softer boxes, which alone vanish on canvas */
  --accent-on-inverse:var(--ink-300);

  --positive:var(--green-500); --positive-soft:var(--green-50);
  --negative:var(--red-500);   --negative-soft:var(--red-50);
  --warning:var(--amber-500);  --warning-soft:var(--amber-50);


  /* ---------- Type ---------- */
  --font-sans:"Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:"Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fs-display:64px; --lh-display:1;    --ls-display:-0.035em;
  --fs-h1:40px;      --lh-h1:1.05;      --ls-h1:-0.03em;
  --fs-h2:28px;      --lh-h2:1.15;      --ls-h2:-0.02em;
  --fs-h3:20px;      --lh-h3:1.25;      --ls-h3:-0.01em;
  --fs-body:15px;    --lh-body:1.5;
  --fs-sm:13px;      --lh-sm:1.45;
  --fs-xs:12px;      --lh-xs:1.4;
  --fs-num-xl:48px;  --fs-num-lg:36px;  --fs-num-md:24px;

  /* ---------- Space (4px base) ---------- */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px;
  --sp-8:32px; --sp-10:40px; --sp-12:48px; --sp-14:56px; --sp-18:72px;

  /* ---------- Radius ---------- */
  --r-xs:8px; --r-sm:12px; --r-md:16px; --r-lg:24px; --r-xl:32px; --r-pill:999px;

  /* ---------- Elevation ---------- */
  --shadow-xs:0 1px 2px rgba(16,16,24,.04);
  --shadow-sm:0 1px 2px rgba(16,16,24,.04), 0 6px 20px rgba(16,16,24,.04);
  --shadow-md:0 2px 6px rgba(16,16,24,.06), 0 16px 40px rgba(16,16,24,.08);
  --shadow-lg:0 4px 12px rgba(16,16,24,.08), 0 32px 80px rgba(16,16,24,.16);
  --ring-focus:0 0 0 4px rgba(13,13,17,.18);

  /* ---------- Controls ---------- */
  --ctl-sm:36px; --ctl-md:44px; --ctl-lg:52px;

  /* ---------- Motion ---------- */
  --ease-out:cubic-bezier(.2,.8,.2,1); --ease-in-out:cubic-bezier(.65,0,.35,1);
  --dur-1:120ms; --dur-2:200ms; --dur-3:320ms;
}

/* ---------- 2b. Semantic (dark) ---------- */
.theme-dark {
  --bg-canvas:#0B0B0F; --bg-surface:#15151B; --bg-subtle:#1B1B22; --bg-muted:#23232C;
  --bg-inverse:#F3F3F6; --bg-overlay:rgba(0,0,0,.6);
  --fg-default:#F3F3F6; --fg-muted:#B4B3BF; --fg-subtle:#8F8E9B; --fg-disabled:#5E5D69; --fg-placeholder:#8A8996;
  --fg-inverse:#0D0D11;
  --border-default:#24242D; --border-strong:#44444F; --border-control:#6A6976; /* 3.4:1 on surface */
  --border-focus:#B4B3BF; --ring-focus:0 0 0 4px rgba(243,243,246,.22);
  --fg-on-accent:var(--black);
  --accent:var(--white); --accent-hover:#E0DFE6; --accent-fg:var(--white);
  --accent-soft:#2A2A33; --accent-softer:#1D1D24; --accent-border:#44444F; --accent-on-inverse:var(--ink-950);
  --positive:#4CC98A; --positive-soft:#12301F;
  --negative:#F37B70; --negative-soft:#3A1715;
  --warning:#F2B25C;  --warning-soft:#35260F;
  --shadow-xs:none; --shadow-sm:none;
  --shadow-md:0 16px 40px rgba(0,0,0,.5); --shadow-lg:0 32px 80px rgba(0,0,0,.6);
}

/* ==========================================================================
   Base
   ========================================================================== */
.app { font-family:var(--font-sans); font-size:var(--fs-body); line-height:var(--lh-body);
  color:var(--fg-default); background:var(--bg-canvas); -webkit-font-smoothing:antialiased;
  box-sizing:border-box; font-feature-settings:"ss01"; }
.app *, .app *::before, .app *::after { box-sizing:border-box; }
:where(.app) :where(button, input, select, textarea) { font:inherit; color:inherit; } /* zero specificity so .btn-primary etc. always win */
.app h1, .app h2, .app h3, .app h4, .app p { margin:0; }

/* Type */
.t-display { font-size:var(--fs-display); line-height:var(--lh-display); letter-spacing:var(--ls-display); font-weight:500; }
.t-h1 { font-size:var(--fs-h1); line-height:var(--lh-h1); letter-spacing:var(--ls-h1); font-weight:500; }
.t-h2 { font-size:var(--fs-h2); line-height:var(--lh-h2); letter-spacing:var(--ls-h2); font-weight:500; }
.t-h3 { font-size:var(--fs-h3); line-height:var(--lh-h3); letter-spacing:var(--ls-h3); font-weight:500; }
.t-body { font-size:var(--fs-body); line-height:var(--lh-body); }
.t-sm { font-size:var(--fs-sm); line-height:var(--lh-sm); }
.t-xs { font-size:var(--fs-xs); line-height:var(--lh-xs); }
.t-mono { font-family:var(--font-mono); letter-spacing:0; }
.t-num { font-variant-numeric:tabular-nums; letter-spacing:-0.02em; }
.t-num-xl { font-size:var(--fs-num-xl); line-height:1; letter-spacing:-0.035em; font-weight:500; font-variant-numeric:tabular-nums; }
.t-num-lg { font-size:var(--fs-num-lg); line-height:1; letter-spacing:-0.03em; font-weight:500; font-variant-numeric:tabular-nums; }
.t-num-md { font-size:var(--fs-num-md); line-height:1.1; letter-spacing:-0.02em; font-weight:500; font-variant-numeric:tabular-nums; }
.t-strong { font-weight:600; }
.t-medium { font-weight:500; }
.fg-muted { color:var(--fg-muted); }
.fg-subtle { color:var(--fg-subtle); }
.fg-accent { color:var(--accent-fg); }
.fg-pos { color:var(--positive); }
.fg-neg { color:var(--negative); }
.cents { color:var(--fg-subtle); }

/* ==========================================================================
   Atoms
   ========================================================================== */

/* Button */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; height:var(--ctl-md);
  padding:0 20px; border-radius:var(--r-pill); border:1px solid transparent; font-size:var(--fs-body);
  font-weight:500; white-space:nowrap; cursor:pointer; text-decoration:none;
  transition:background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out); }
.btn svg { width:18px; height:18px; flex-shrink:0; }
.btn-primary { background:var(--accent); color:var(--fg-on-accent); }
.btn-primary:hover { background:var(--accent-hover); }
.btn-secondary { background:var(--bg-surface); color:var(--fg-default); border-color:var(--border-strong); }
.btn-secondary:hover { background:var(--bg-subtle); }
.btn-tonal { background:var(--accent-soft); color:var(--accent-fg); }
.btn-ghost { background:transparent; color:var(--fg-default); }
.btn-ghost:hover { background:var(--bg-muted); }
.btn-ghost.fg-neg { color:var(--negative); }
.btn-danger { background:var(--negative-soft); color:var(--negative); }
.btn-inverse { background:var(--bg-inverse); color:var(--fg-inverse); }
.btn-sm { height:var(--ctl-sm); padding:0 14px; font-size:var(--fs-sm); }
.btn-lg { height:var(--ctl-lg); padding:0 24px; font-size:16px; }
.btn-block { width:100%; }
.btn[disabled], .btn.is-disabled { background:var(--bg-muted); color:var(--fg-disabled); border-color:transparent; cursor:not-allowed; }
.btn.is-focus { box-shadow:var(--ring-focus); }

/* Icon button (44 circle) */
.icon-btn { display:inline-flex; align-items:center; justify-content:center; width:var(--ctl-md); height:var(--ctl-md);
  border-radius:var(--r-pill); background:var(--bg-surface); border:1px solid var(--border-default);
  color:var(--fg-default); cursor:pointer; flex-shrink:0; padding:0; }
.icon-btn svg { width:20px; height:20px; }
.icon-btn-lg { width:var(--ctl-lg); height:var(--ctl-lg); }
.icon-btn-ghost { background:transparent; border-color:transparent; }
.icon-btn-accent { background:var(--accent); color:var(--fg-on-accent); border-color:transparent; }
/* Quiet row action (edit): small, muted, comes forward when its row is hovered */
.icon-btn-quiet { width:32px; height:32px; border-radius:var(--r-xs); background:transparent; border-color:transparent; color:var(--fg-subtle); }
.icon-btn-quiet svg { width:16px; height:16px; }
tr:hover .icon-btn-quiet { color:var(--fg-default); }
.icon-btn-quiet:hover { color:var(--fg-default); background:var(--bg-muted); }
.icon-btn-quiet:focus-visible { outline:none; box-shadow:var(--ring-focus); color:var(--fg-default); }

/* Nav pill (desktop top nav) */
.nav { display:flex; align-items:center; gap:8px; }
.nav-pill { display:inline-flex; align-items:center; height:var(--ctl-lg); padding:0 24px; border-radius:var(--r-pill);
  background:var(--bg-surface); color:var(--fg-default); font-size:16px; text-decoration:none; border:1px solid transparent; }
.nav-pill.is-active { background:var(--accent); color:var(--fg-on-accent); }
.nav-pill:hover:not(.is-active) { border-color:var(--border-strong); }

/* Chip / delta badge */
.chip { display:inline-flex; align-items:center; gap:6px; height:30px; padding:0 12px; border-radius:var(--r-pill);
  background:var(--bg-surface); color:var(--fg-muted); font-size:var(--fs-sm); white-space:nowrap;
  font-variant-numeric:tabular-nums; border:1px solid var(--border-default); }
.chip svg { width:14px; height:14px; }
.chip-pos { background:var(--positive-soft); color:var(--positive); border-color:transparent; }
.chip-neg { background:var(--negative-soft); color:var(--negative); border-color:transparent; }
.chip-accent { background:var(--accent-soft); color:var(--accent-fg); border-color:transparent; }
.chip-muted { background:var(--bg-muted); border-color:transparent; }
.chip-warn { background:var(--warning-soft); color:var(--warning); border-color:transparent; cursor:pointer; font:inherit; font-size:var(--fs-sm); }

/* Filter pill (selectable chip) */
.fpill { display:inline-flex; align-items:center; height:var(--ctl-sm); padding:0 14px; border-radius:var(--r-pill);
  font-size:var(--fs-sm); background:transparent; border:1px solid var(--border-strong); color:var(--fg-muted); cursor:pointer; }
.fpill.is-active { background:var(--fg-default); border-color:var(--fg-default); color:var(--bg-surface); }

/* Segmented control */
.seg { display:inline-flex; align-items:center; gap:4px; padding:4px; border-radius:var(--r-pill); background:var(--bg-subtle); }
.seg button { height:36px; padding:0 18px; border-radius:var(--r-pill); border:0; background:transparent; color:var(--fg-muted);
  font-size:var(--fs-sm); cursor:pointer; }
.seg button.is-active { background:var(--accent); color:var(--fg-on-accent); }
.seg-plain { background:transparent; padding:0; }

/* Field */
.field { display:flex; flex-direction:column; gap:8px; }
.label { font-size:var(--fs-sm); font-weight:500; color:var(--fg-default); }
.help { font-size:var(--fs-xs); color:var(--fg-subtle); }
.error-text { font-size:var(--fs-xs); color:var(--negative); }
.input { height:var(--ctl-lg); width:100%; padding:0 16px; border-radius:var(--r-md); border:1px solid var(--border-control);
  background:var(--bg-surface); font-size:var(--fs-body); color:var(--fg-default); outline:none; }
.input::placeholder { color:var(--fg-placeholder); }
.input.is-focus, .input:focus { border-color:var(--border-focus); box-shadow:var(--ring-focus); }
.input.is-error, .input.is-error:focus { border-color:var(--negative); box-shadow:0 0 0 4px var(--negative-soft); }
.field-error { font-size:var(--fs-sm); margin-top:-2px; }
.input-wrap { position:relative; display:flex; align-items:center; }
.input-wrap .affix { position:absolute; left:16px; color:var(--fg-subtle); font-variant-numeric:tabular-nums; pointer-events:none; }
.input-wrap .affix-r { position:absolute; right:14px; color:var(--fg-subtle); display:flex; }
.input-wrap .input { padding-left:34px; }
.input-money { font-variant-numeric:tabular-nums; font-size:17px; }
.input-hero { height:72px; font-size:36px; letter-spacing:-0.03em; border-radius:var(--r-lg); padding-left:44px !important; }
.select { display:flex; align-items:center; justify-content:space-between; gap:8px; height:var(--ctl-lg); width:100%;
  padding:0 14px 0 16px; border-radius:var(--r-md); border:1px solid var(--border-control); background:var(--bg-surface);
  font-size:var(--fs-body); cursor:pointer; text-align:left; }
.select svg { width:18px; height:18px; color:var(--fg-subtle); }

/* Toggle */
/* off: an outlined track with a grey knob, both 3:1 or more against the card; on: the filled accent track */
.toggle { position:relative; width:44px; height:26px; border-radius:var(--r-pill); background:var(--bg-surface); box-shadow:inset 0 0 0 2px var(--border-control); border:0; padding:0; cursor:pointer; flex-shrink:0; }
.toggle::after { content:""; position:absolute; top:5px; left:5px; width:16px; height:16px; border-radius:50%; background:var(--fg-subtle); }
.toggle.is-on { background:var(--accent); box-shadow:none; }
.toggle.is-on::after { top:3px; left:21px; width:20px; height:20px; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.2); }

/* Checkbox */
.check { width:20px; height:20px; border-radius:6px; border:1.5px solid var(--border-control); background:var(--bg-surface); display:inline-flex; align-items:center; justify-content:center; flex-shrink:0; }
.check.is-on { background:var(--accent); border-color:var(--accent); color:var(--fg-on-accent); }
.check svg { width:14px; height:14px; }

/* Avatar */
.avatar { width:var(--ctl-lg); height:var(--ctl-lg); border-radius:50%; background:var(--accent-soft); color:var(--accent-fg);
  display:inline-flex; align-items:center; justify-content:center; font-weight:600; font-size:16px; flex-shrink:0;
  border:2px solid var(--bg-surface); box-shadow:0 0 0 1px var(--border-strong); }
.avatar-sm { width:36px; height:36px; font-size:13px; }

/* Progress */
.progress { height:8px; border-radius:var(--r-pill); background:var(--bg-muted); overflow:hidden; }
.progress > span { display:block; height:100%; border-radius:inherit; background:var(--accent); }

/* Divider, dot, kbd */
.divider { height:1px; background:var(--border-default); border:0; width:100%; }
.dot { width:8px; height:8px; border-radius:50%; display:inline-block; flex-shrink:0; }
.legend-line { width:18px; height:3px; border-radius:2px; display:inline-block; }
.kbd { font-family:var(--font-mono); font-size:11px; padding:2px 6px; border-radius:6px; border:1px solid var(--border-strong); color:var(--fg-subtle); }

/* Logo */
.logo { display:inline-flex; align-items:center; gap:10px; font-weight:600; font-size:22px; letter-spacing:-0.03em; color:var(--fg-default); text-decoration:none; }
.logo-mark { width:32px; height:32px; }
.logo-word { display:block; height:24px; width:auto; aspect-ratio:371/141; }

/* ==========================================================================
   Molecules
   ========================================================================== */

/* Stat block: label / value + delta chip */
.stat { display:flex; flex-direction:column; gap:14px; }
.stat-label { font-size:var(--fs-body); color:var(--fg-muted); display:flex; align-items:center; gap:8px; }
.stat-value-row { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }

/* List row (icon disc + title/sub + meta) */
.row { display:flex; align-items:center; gap:16px; padding:14px 0; }
.row-icon { width:48px; height:48px; border-radius:50%; background:var(--bg-subtle); display:flex; align-items:center; justify-content:center; flex-shrink:0; color:var(--fg-default); }
.row-icon svg { width:20px; height:20px; }
.row-icon-accent { background:var(--accent-soft); color:var(--accent-fg); }
.row-main { flex:1; min-width:0; display:flex; flex-direction:column; gap:4px; }
.row-title { font-size:16px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row-sub { font-size:var(--fs-sm); color:var(--fg-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row-sub.fg-neg { color:var(--negative); } /* .row-sub comes after .fg-neg, so the tone needs saying again here */
.row-meta { display:flex; flex-direction:column; align-items:flex-end; gap:4px; text-align:right; }
.row-amount { font-size:16px; font-weight:500; font-variant-numeric:tabular-nums; white-space:nowrap; }
.row + .row { border-top:1px solid var(--border-default); }

/* Tooltip (chart) */
.tip { background:var(--bg-surface); border-radius:var(--r-md); box-shadow:var(--shadow-md); padding:14px 16px; display:flex; flex-direction:column; gap:8px; min-width:180px; font-size:var(--fs-sm); border:1px solid var(--border-default); }
.tip-row { display:flex; align-items:center; justify-content:space-between; gap:24px; font-variant-numeric:tabular-nums; }

/* Toast */
.toast { display:flex; align-items:center; gap:12px; padding:12px 16px 12px 12px; border-radius:var(--r-pill); background:var(--bg-inverse); color:var(--fg-inverse); box-shadow:var(--shadow-md); font-size:var(--fs-sm); }
.toast-icon { width:28px; height:28px; border-radius:50%; background:var(--positive); color:#fff; display:flex; align-items:center; justify-content:center; }
.toast-icon svg { width:16px; height:16px; }

/* Empty state */
.empty { display:flex; flex-direction:column; align-items:center; text-align:center; gap:12px; padding:40px 24px; }
.empty-art { width:64px; height:64px; border-radius:50%; background:var(--accent-softer); color:var(--accent-fg); display:flex; align-items:center; justify-content:center; }

/* Stepper */
.steps { display:flex; gap:8px; }
.steps span { flex:1; height:4px; border-radius:2px; background:var(--bg-muted); }
.steps span.is-done { background:var(--accent); }

/* ==========================================================================
   Organisms
   ========================================================================== */

/* Card */
.card { background:var(--bg-surface); border-radius:var(--r-lg); padding:28px; box-shadow:var(--shadow-xs); border:1px solid var(--border-default); }
.card-flat { box-shadow:none; }
.card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.card-title { font-size:var(--fs-h3); font-weight:500; letter-spacing:-0.01em; }
.card-sub { font-size:var(--fs-sm); color:var(--fg-muted); margin-top:6px; }

/* Desktop top bar */
.topbar { display:flex; align-items:center; justify-content:space-between; gap:24px; }

/* Page header */
.page-head { display:flex; align-items:flex-end; justify-content:space-between; gap:24px; }

/* Table */
.table { width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums; }
.table th { text-align:left; font-weight:500; font-size:var(--fs-sm); color:var(--fg-subtle); padding:0 16px 12px; border-bottom:1px solid var(--border-default); }
.table td { padding:16px; border-bottom:1px solid var(--border-default); font-size:var(--fs-body); }
.table tr:last-child td { border-bottom:0; }
.table .num { text-align:right; }
.table th:first-child, .table td:first-child { padding-left:0; }
.table th:last-child, .table td:last-child { padding-right:0; }
.table tr.is-selected td { background:var(--accent-softer); }

/* Modal & sheet */
.scrim { background:var(--bg-overlay); }
.modal { background:var(--bg-surface); border-radius:var(--r-xl); box-shadow:var(--shadow-lg); padding:32px; display:flex; flex-direction:column; gap:24px; }
.sheet { background:var(--bg-surface); border-radius:var(--r-xl) var(--r-xl) 0 0; box-shadow:var(--shadow-lg); padding:12px 20px 28px; display:flex; flex-direction:column; gap:20px; }
.sheet-grab { width:40px; height:5px; border-radius:3px; background:var(--border-strong); align-self:center; }

/* Mobile tab bar */
.tabbar { display:flex; align-items:center; justify-content:space-around; height:76px; padding:0 8px 12px; background:var(--bg-surface); border-top:1px solid var(--border-default); }
.tab { display:flex; flex-direction:column; align-items:center; gap:4px; min-width:56px; padding-top:10px; font-size:11px; color:var(--fg-subtle); text-decoration:none; }
.tab svg { width:22px; height:22px; }
.tab.is-active { color:var(--accent-fg); }
.tab-fab { width:52px; height:52px; border-radius:50%; background:var(--accent); color:var(--fg-on-accent); display:flex; align-items:center; justify-content:center; margin-top:-8px; box-shadow:0 8px 20px rgba(0,0,0,.25); border:0; }
.tab-fab svg { width:24px; height:24px; }

/* Mobile app bar */
.appbar { display:flex; align-items:center; justify-content:space-between; gap:12px; height:64px; }

/* Settings list */
.set-group { background:var(--bg-surface); border-radius:var(--r-lg); border:1px solid var(--border-default); overflow:hidden; }
.set-row { display:flex; align-items:center; gap:14px; min-height:60px; padding:12px 20px; }
.set-row + .set-row { border-top:1px solid var(--border-default); }
.set-row .grow { flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.set-row .val { color:var(--fg-muted); font-size:var(--fs-sm); display:flex; align-items:center; gap:6px; }


/* Icons: inline 24×24 stroke SVGs, class="ic" */
.ic { fill:none; stroke:currentColor; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; }

/* ==========================================================================
   Feedback: account menu + report a bug (→ <prefix>_bug_reports → fix-bugs skill)
   ========================================================================== */
.menu { background:var(--bg-surface); border:1px solid var(--border-default); border-radius:var(--r-lg); box-shadow:var(--shadow-md); padding:8px; display:flex; flex-direction:column; gap:2px; min-width:260px; }
.menu-head { display:flex; align-items:center; gap:12px; padding:10px 12px 12px; }
.menu-item { display:flex; align-items:center; gap:12px; height:44px; padding:0 12px; border-radius:var(--r-sm); border:0; background:transparent; font-size:var(--fs-body); color:var(--fg-default); text-decoration:none; cursor:pointer; text-align:left; width:100%; }
.menu-item svg { width:18px; height:18px; color:var(--fg-muted); }
.menu-item:hover, .menu-item.is-hover { background:var(--bg-subtle); }
.menu-item.is-danger, .menu-item.is-danger svg { color:var(--negative); }
.menu-sep { height:1px; background:var(--border-default); margin:6px 4px; }
.menu-label { font-size:var(--fs-xs); color:var(--fg-subtle); padding:8px 12px 4px; }
.seg-icons { display:flex; box-sizing:border-box; }
.seg-icons button { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-width:0; padding:0 8px; white-space:nowrap; }
.seg-icons svg { width:15px; height:15px; flex-shrink:0; }

.textarea { width:100%; min-height:128px; padding:14px 16px; border-radius:var(--r-md); border:1px solid var(--border-control); background:var(--bg-surface); font-size:var(--fs-body); line-height:var(--lh-body); color:var(--fg-default); resize:vertical; outline:none; }
.textarea::placeholder { color:var(--fg-placeholder); }
.textarea.is-focus, .textarea:focus { border-color:var(--border-focus); box-shadow:var(--ring-focus); }

.report { display:flex; flex-direction:column; gap:8px; padding:16px 0; }
.report + .report { border-top:1px solid var(--border-default); }
.report-top { display:flex; align-items:center; justify-content:space-between; gap:12px; font-size:var(--fs-sm); color:var(--fg-subtle); }
.report-text { font-size:var(--fs-body); color:var(--fg-default); }
.report-note { display:flex; gap:10px; align-items:flex-start; padding:10px 12px; border-radius:var(--r-sm); background:var(--bg-subtle); font-size:var(--fs-sm); color:var(--fg-muted); }
.report-note svg { width:16px; height:16px; color:var(--positive); flex-shrink:0; margin-top:2px; }
.report-remove { align-self:flex-start; height:32px; padding:0 12px; border-radius:var(--r-pill); border:1px solid var(--border-strong); background:transparent; font-size:var(--fs-sm); color:var(--fg-muted); cursor:pointer; }
.chip-sm { height:24px; padding:0 10px; font-size:var(--fs-xs); }

/* ==========================================================================
   Motion — uses --dur-* / --ease-* tokens. Everything is transform/opacity only.
   Entrance: content rises in, staggered.
   Overlays: scrim fades, modal scales, sheet slides up, menu pops from its anchor.
   Micro: buttons press, cards lift on hover, toggles slide.
   ========================================================================== */
@keyframes sv-rise    { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }
@keyframes sv-fade    { from { opacity:0; } to { opacity:1; } }
@keyframes sv-scale   { from { opacity:0; transform:translateY(8px) scale(.97); } to { opacity:1; transform:none; } }
@keyframes sv-sheet   { from { transform:translateY(100%); } to { transform:none; } }
@keyframes sv-pop     { from { opacity:0; transform:translateY(-6px) scale(.96); } to { opacity:1; transform:none; } }
@keyframes sv-pulse   { 0%,100% { transform:scale(1); } 50% { transform:scale(1.35); } }
@keyframes sv-float   { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-8px); } }
@keyframes sv-toast   { 0% { opacity:0; transform:translateY(24px) scale(.9); } 60% { opacity:1; transform:translateY(-3px) scale(1.01); } 100% { opacity:1; transform:none; } }
@keyframes sv-toast-out { from { opacity:1; transform:none; } to { opacity:0; transform:translateY(12px) scale(.94); } }
@keyframes sv-toast-swap { from { opacity:.4; transform:scale(.97); } to { opacity:1; transform:none; } }
@keyframes sv-toast-icon { 0% { transform:scale(0) rotate(-45deg); } 70% { transform:scale(1.15) rotate(0); } 100% { transform:none; } }

/* entrance: stat, cards, rows, set-groups, reports */
.card, .stat, .set-group, .page-head, .report, .row { animation:sv-rise var(--dur-3) var(--ease-out) both; }
.stat:nth-child(2), .card:nth-child(2), .row:nth-child(3), .report:nth-child(3) { animation-delay:60ms; }
.stat:nth-child(3), .card:nth-child(3), .row:nth-child(4), .report:nth-child(4) { animation-delay:120ms; }
.stat:nth-child(4), .card:nth-child(4), .row:nth-child(5) { animation-delay:180ms; }
section:nth-of-type(3) > .card { animation-delay:160ms; }
section:nth-of-type(4) > .card { animation-delay:240ms; }
.anim-rise { animation:sv-rise 480ms var(--ease-out) both; animation-delay:var(--d, 0ms); }
.anim-float { animation:sv-float 6s var(--ease-in-out) infinite; animation-delay:var(--d, 0ms); }

.progress > span { transform-origin:left; animation:sv-grow-x 900ms var(--ease-out) both 200ms; }
@keyframes sv-grow-x { from { transform:scaleX(0); } to { transform:scaleX(1); } }

/* overlays */
.scrim { animation:sv-fade var(--dur-2) var(--ease-out) both; }
.modal { animation:sv-scale var(--dur-3) var(--ease-out) both 60ms; }
.sheet { animation:sv-sheet var(--dur-3) var(--ease-out) both; }
.menu { transform-origin:top right; animation:sv-pop var(--dur-2) var(--ease-out) both; }
.toast { animation:sv-toast 420ms var(--ease-out) both; will-change:transform, opacity; }
.toast .toast-icon { animation:sv-toast-icon 360ms var(--ease-out) both 120ms; }
.toast.is-swap { animation:sv-toast-swap var(--dur-2) var(--ease-out) both; }
.toast.is-swap .toast-icon { animation:none; }
.toast.is-leaving { animation:sv-toast-out var(--dur-2) var(--ease-in-out) both; pointer-events:none; }

/* micro-interactions */
.btn, .icon-btn, .nav-pill, .fpill, .seg button, .tab-fab, .menu-item { transition:background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.btn:active, .icon-btn:active, .tab-fab:active, .fpill:active, .nav-pill:active { transform:scale(.97); }
.btn-primary:hover { box-shadow:0 8px 20px rgba(109,77,240,.28); }
.card { transition:transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.card:hover { box-shadow:var(--shadow-sm); }
.toggle, .toggle::after { transition:background var(--dur-2) var(--ease-out), left var(--dur-2) var(--ease-out), top var(--dur-2) var(--ease-out), width var(--dur-2) var(--ease-out), height var(--dur-2) var(--ease-out); }
.row, .set-row, .table td { transition:background var(--dur-1) var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:1ms !important; animation-delay:0ms !important; animation-iteration-count:1 !important; transition-duration:1ms !important; }
}

/* ==========================================================================
   Pages
   ========================================================================== */
body.app { margin:0; min-height:100vh; min-height:100dvh; }
.fg-accent a, a.fg-accent { text-decoration:none; }

/* Sign in and the forced password change: one column, phone first. Heavy title,
   grey filled inputs, a pill button */
.auth { min-height:100vh; min-height:100dvh; display:flex; flex-direction:column; gap:40px; background:var(--bg-surface);
  padding:max(16px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom)); }
.auth-top { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.auth-form { width:100%; max-width:420px; margin:0 auto; display:flex; flex-direction:column; gap:20px; }
.auth-head { display:flex; flex-direction:column; gap:10px; }
.auth-title { font-size:36px; line-height:1.05; letter-spacing:-0.035em; font-weight:700; margin-bottom:8px; }
.auth-head .auth-title { margin-bottom:0; }
.auth .input { background:var(--bg-muted); border-color:transparent; border-radius:var(--r-sm); font-size:16px; }
.auth .input:focus { background:var(--bg-surface); border-color:var(--border-focus); }
.auth .btn-primary { margin-top:8px; }
.auth-form .error-text { font-size:var(--fs-sm); }
.auth-form .error-text:empty { display:none; }
@media (min-width:1024px) {
  .auth { padding:32px 48px; gap:12vh; }
  .auth-title { font-size:48px; }
}

/* ==========================================================================
   App shell (Main / M-Dashboard): top bar on desktop, app bar + tab bar on phones
   ========================================================================== */
.visually-hidden { position:absolute !important; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.truncate { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.skip { position:absolute; left:-9999px; top:8px; z-index:300; }
.skip:focus { left:16px; background:var(--bg-surface); padding:8px 14px; border-radius:var(--r-pill); }
.boot { min-height:100vh; display:flex; align-items:center; justify-content:center; }
.boot .logo-mark { width:48px; height:48px; animation:sv-pulse 1.4s var(--ease-in-out) infinite; }
.boot.is-error { flex-direction:column; gap:14px; text-align:center; padding:0 32px; }
.boot.is-error .logo-mark { animation:none; margin-bottom:6px; }
.boot.is-error p { max-width:340px; }
body.has-overlay { overflow:hidden; }

.shell-top { display:flex; align-items:center; justify-content:space-between; gap:24px; max-width:1440px; margin:0 auto; padding:40px 56px 0; }
.shell-actions { display:flex; align-items:center; gap:10px; }
.shell-avatar { cursor:pointer; padding:0; }
.shell-view { max-width:1440px; margin:0 auto; padding:48px 56px 72px; outline:none; }
.shell-tabbar { display:none; }
#app[data-mode="bare"] .shell-nav, #app[data-mode="bare"] .shell-actions, #app[data-mode="bare"] .shell-tabbar { display:none !important; }

.page { display:flex; flex-direction:column; gap:48px; }
.page-head { flex-wrap:wrap; align-items:flex-end; }
.page-title { display:flex; flex-direction:column; gap:10px; }
.page-sub { font-size:17px; }
.page-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
/* the big figures scale with their column, like the phone cards (#31), so they never run into the next one */
.grid-3 { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:20px; }
.grid-2 { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:20px; align-items:start; }
.card { display:flex; flex-direction:column; gap:20px; }
.card-title { font-size:24px; }
.rows { display:flex; flex-direction:column; }
.row-btn { width:100%; background:none; border:0; text-align:left; cursor:pointer; border-radius:var(--r-sm); font:inherit; color:inherit; }
.row-btn:hover .row-title { color:var(--accent-fg); }
.row-btn:focus-visible { outline:2px solid var(--border-focus); outline-offset:2px; }
.rows .row + .row { border-top:1px solid var(--border-default); }
.card.empty { align-items:center; text-align:center; padding:56px 28px; gap:14px; }

.no-anim .card, .no-anim .stat, .no-anim .row, .no-anim .report, .no-anim .set-group, .no-anim .page-head,

.still, .still * { animation:none !important; }

/* overlays: centred modal on desktop, bottom sheet on phones (ui.js picks) */
.overlay { position:fixed; inset:0; z-index:100; display:flex; align-items:center; justify-content:center; padding:24px; }
.overlay-scrim { position:absolute; inset:0; }
.overlay-box { position:relative; width:480px; max-width:100%; max-height:calc(100vh - 48px); max-height:calc(100dvh - 48px); overflow:auto; outline:none; --pad-b:32px; }
.overlay-box.is-wide { width:600px; }
.overlay-body { display:flex; flex-direction:column; gap:20px; }
.overlay-foot { display:flex; align-items:center; justify-content:flex-end; gap:10px; flex-wrap:wrap; }
/* when a sheet's content is taller than the screen, its buttons stay in view: the footer sticks to the bottom
   and covers the box's bottom padding (--pad-b) so nothing scrolls visibly behind it */
.overlay-foot { position:sticky; z-index:1; bottom:calc(-1 * var(--pad-b)); margin-bottom:calc(-1 * var(--pad-b)); padding-bottom:var(--pad-b); background:var(--bg-surface); }
.form-stack { display:flex; flex-direction:column; gap:20px; }
.select-wrap { position:relative; }
.select-wrap select { appearance:none; -webkit-appearance:none; padding-right:40px; cursor:pointer; }
.select-wrap svg { position:absolute; right:14px; top:50%; transform:translateY(-50%); color:var(--fg-subtle); pointer-events:none; }
/* custom dropdown (select.js): a button over the hidden <select>, plus a floating listbox */
.select-btn { display:flex; align-items:center; text-align:left; padding-right:40px; cursor:pointer; }
.select-btn:disabled { cursor:not-allowed; color:var(--fg-disabled); }
.select-btn[aria-expanded="true"] { border-color:var(--border-focus); box-shadow:var(--ring-focus); }
.select-wrap svg { transition:transform var(--dur-2) var(--ease-out); }
.select-btn[aria-expanded="true"] ~ svg { transform:translateY(-50%) rotate(180deg); }
.select-list { position:fixed; z-index:400; min-width:160px; max-width:calc(100vw - 16px); overflow-y:auto; overscroll-behavior:contain;
  gap:2px; padding:6px; border-radius:var(--r-md); transform-origin:top center; }
.select-list.is-up { transform-origin:bottom center; }
.select-option { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:40px; padding:0 12px;
  border-radius:var(--r-xs); font-size:var(--fs-body); color:var(--fg-default); cursor:pointer; flex-shrink:0; user-select:none;
  font-variant-numeric:tabular-nums; }
.select-option svg { width:16px; height:16px; color:var(--accent-fg); visibility:hidden; flex-shrink:0; }
.select-option.is-active { background:var(--bg-subtle); }
.select-option.is-selected { color:var(--accent-fg); font-weight:500; }
.select-option.is-selected svg { visibility:visible; }
.select-option[aria-disabled="true"] { color:var(--fg-disabled); cursor:default; }

/* browser autofill keeps the theme instead of painting fields pale yellow/blue */
.input:-webkit-autofill, .input:-webkit-autofill:hover, .input:-webkit-autofill:focus {
  -webkit-text-fill-color:var(--fg-default); caret-color:var(--fg-default);
  -webkit-box-shadow:0 0 0 1000px var(--bg-surface) inset; transition:background-color 9999s ease-out 0s; }
.input:-webkit-autofill:focus { -webkit-box-shadow:0 0 0 1000px var(--bg-surface) inset, var(--ring-focus); }
.input, .textarea { caret-color:var(--accent); }
::selection { background:var(--accent-soft); color:var(--fg-default); }
input[type="password"]::-ms-reveal, input[type="password"]::-ms-clear { display:none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance:none; }

/* scrollbars: thin, rounded, themed. Chromium 121+ and Firefox use the standard
   properties; Safari only reads the ::-webkit-scrollbar ones, which Chromium
   ignores once scrollbar-color is set, so both can live together. */
html { scrollbar-color:var(--border-strong) transparent; }
/* no double-tap zoom: the app should feel native on phones */
html { touch-action:manipulation; }
* { scrollbar-width:thin; }
::-webkit-scrollbar { width:12px; height:12px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border-strong); border-radius:999px; border:3px solid transparent; background-clip:padding-box; }
::-webkit-scrollbar-thumb:hover { background-color:var(--fg-disabled); }
::-webkit-scrollbar-button { display:none; }
.error-text:empty { display:none; }
.shell-menu { position:absolute; z-index:150; width:300px; }
.menu-in-sheet { border:0; box-shadow:none; padding:0; animation:none; min-width:0; }
.menu-in-sheet .menu-head { display:none; }
.bug-list .report-remove { height:36px; }

.toast-wrap { position:fixed; left:0; right:0; bottom:28px; z-index:200; display:flex; justify-content:center; pointer-events:none; padding:0 16px; }
.toast { pointer-events:auto; }
.toast.is-error .toast-icon { background:var(--negative); }
.toast-action { background:transparent; border:0; color:var(--accent-on-inverse); font:inherit; font-weight:600; cursor:pointer; padding:4px 8px; margin-left:4px; }

/* Settings: one column of grouped rows */
.settings { display:flex; flex-direction:column; gap:32px; max-width:720px; }
.settings section { display:flex; flex-direction:column; gap:12px; }
.settings .set-row .btn { flex-shrink:0; }
.settings .seg { align-self:flex-start; }

/* ==========================================================================
   Landing (signed out "/")
   ========================================================================== */
.lp { overflow-x:hidden; }
.lp a { text-decoration:none; }
.lp-top { position:sticky; top:0; z-index:40; display:flex; align-items:center; justify-content:space-between; gap:24px; max-width:1440px; margin:0 auto; padding:22px 56px;
  background:color-mix(in srgb, var(--bg-canvas) 86%, transparent); -webkit-backdrop-filter:saturate(1.4) blur(14px); backdrop-filter:saturate(1.4) blur(14px); }
.lp-top-actions { display:flex; align-items:center; gap:8px; }
.lp-hero { display:flex; flex-direction:column; align-items:center; text-align:center; gap:28px; padding:96px 56px 0; max-width:1440px; margin:0 auto; }
.lp-h1 { font-size:clamp(44px, 7vw, 88px); line-height:.98; letter-spacing:-0.045em; font-weight:500; max-width:1040px; text-wrap:balance; margin:0; }
.lp-lead { font-size:21px; line-height:1.5; color:var(--fg-muted); max-width:640px; text-wrap:pretty; }
.lp-ctas { display:flex; gap:12px; flex-wrap:wrap; justify-content:center; }
.lp-section { max-width:1200px; margin:0 auto; padding:120px 56px 0; display:flex; flex-direction:column; gap:32px; }
.lp-steps { list-style:none; margin:0; padding:0; display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:20px; }
.lp-steps .card { gap:12px; }
.lp-step-n { width:36px; height:36px; border-radius:50%; background:var(--accent-soft); color:var(--accent-fg); display:inline-flex; align-items:center; justify-content:center; font-weight:600; }
.lp-footer { max-width:1200px; margin:0 auto; padding:120px 56px 48px; display:flex; justify-content:space-between; gap:16px; }

@media (max-width:1023px) {
  /* no zoom, like a native app: iOS zooms into fields under 16px on focus */
  .input, .textarea { font-size:16px; }
  .shell-top { padding:8px 20px; height:64px; }
  .shell-nav { display:none; }
  .shell-avatar { width:44px; height:44px; font-size:14px; }
  .shell-view { padding:16px 20px calc(48px + env(safe-area-inset-bottom)); }
  .page { gap:28px; }
  .page-head { align-items:stretch; flex-direction:column; gap:16px; }
  .page-head .t-display { font-size:40px; }
  .card { padding:20px; }
  .card-title { font-size:20px; }
  .overlay { padding:0; align-items:flex-end; }
  .overlay-box, .overlay-box.is-wide { width:100%; max-height:92vh; max-height:92dvh; --pad-b:calc(28px + env(safe-area-inset-bottom)); padding-bottom:var(--pad-b); }
  .overlay-foot .btn { flex:1; }
  .toast-wrap { bottom:calc(28px + env(safe-area-inset-bottom)); }
  .set-row { flex-wrap:wrap; padding:16px 20px; }
  .set-row .grow { flex-basis:100%; }
  .lp-top { padding:14px 20px; }
  .lp-top-actions .btn-ghost { display:none; }
  .lp-hero { padding:56px 20px 0; }
  .lp-lead { font-size:18px; }
  .lp-section { padding:72px 20px 0; }
  .lp-steps { grid-template-columns:minmax(0, 1fr); }
  .lp-footer { padding:72px 20px 32px; }
}
