/* Stock Guesser console — design system.
 *
 * Mobile first, in the spirit of Wealthsimple: warm off-white canvas, white
 * cards, near-black type, one big number per screen, hairline-separated
 * lists, pill buttons, green/red only for money moving. Dark mode follows the
 * OS. Pages compose these classes; page templates should need little or no
 * CSS of their own.
 *
 * Layout ......... .app (shell) · .page · .page-head · .stack · .grid-2/.grid-3
 * Type ........... .eyebrow · .title · .subtitle · .muted · .small · .num
 * Surfaces ....... .card · .card-head · .card-title · .card-link
 * Numbers ........ .hero (.hero-label/.hero-value/.hero-change) · .stats > .stat
 * Lists .......... .list > .row (.row-avatar · .row-main · .row-title · .row-sub · .row-end · .row-value · .row-meta)
 * Key/value ...... .kv > div > dt/dd
 * Status ......... .pill (+ .pos/.neg/.warn/.info/.dark) · .dot · .banner (+ .ok/.warn/.error)
 * Actions ........ .btn (+ .btn-primary/.btn-secondary/.btn-ghost/.btn-danger/.btn-sm/.btn-block) · .actions
 * Forms .......... .field (label · input/select/textarea · .hint) · .switch · .segmented
 * Tables ......... .table-wrap > table.table (td[data-label] stacks into cards on phones)
 * Misc ........... .empty · .tabs · .sheet (modal) · .skeleton · .chart
 */

/* Inter (SIL OFL 1.1, fonts/Inter-LICENSE.txt), self-hosted so every device
   gets the same type. */
@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #ffffff;
  --surface: #f5f4f1;
  --surface-2: #ecebe7;
  --surface-3: #e2e0db;
  --raised: #ffffff;
  --border: #ebe9e5;
  --border-strong: #d6d3cd;
  --text: #171717;
  --text-2: #64625e;
  --text-3: #9a9792;
  --accent: #171717;
  --accent-text: #ffffff;
  --pos: #0f7b55;
  --pos-bg: #e2f2ea;
  --neg: #cc3a1f;
  --neg-bg: #fbe8e3;
  --warn: #946100;
  --warn-bg: #faf0d8;
  --info: #2a5bd7;
  --info-bg: #e8eefc;
  --focus: #2a5bd7;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font);
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 20px;
  --shadow: none;
  --shadow-lg: 0 16px 48px rgba(23, 23, 23, .18);

  --tabbar-h: 64px;
  --header-h: 56px;
  --rail-w: 240px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --surface-3: #2f2e2c;
    --raised: #1f1f1e;
    --border: #2a2a28;
    --border-strong: #3d3b37;
    --text: #f4f2ec;
    --text-2: #b4afa4;
    --text-3: #847f75;
    --accent: #f4f2ec;
    --accent-text: #131312;
    --pos: #3fcf8e;
    --pos-bg: #12301f;
    --neg: #ff7a5c;
    --neg-bg: #3a1a12;
    --warn: #f0b44c;
    --warn-bg: #352812;
    --info: #7fa6ff;
    --info-bg: #17223d;
    --focus: #7fa6ff;
    --shadow: none;
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ── base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
code, pre, .mono { font-family: var(--font-mono); font-size: .875em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.num, .row-value, .stat-value, .hero-value, .hero-change, .pill, td.num, .table .num, .kv dd {
  font-variant-numeric: tabular-nums;
}
time[data-utc] { white-space: nowrap; }

/* ── app shell ──────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  height: var(--header-h);
  padding: 0 1rem;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
}
.app-header.scrolled { border-bottom-color: var(--border); }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  font: 700 15px/1 var(--font-display);
}
.header-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin-left: -.5rem; border-radius: 50%;
}
.header-back:hover { background: var(--surface-2); }
.header-title { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-end { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text); font-weight: 600; font-size: .85rem;
}

.header-search { flex: 1; max-width: 420px; display: none; }
.header-search input {
  width: 100%; height: 40px; padding: 0 1rem 0 2.4rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238e897f' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: .9rem 50%;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .7rem; font-weight: 500; color: var(--text-3);
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--text); }
.tab .tab-badge {
  position: absolute; transform: translate(12px, -14px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--neg); color: #fff; font-size: .65rem; font-weight: 700;
  display: grid; place-items: center;
}

.rail { display: none; }

.app-main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1.5rem); }
.app.no-nav .app-main { padding-bottom: 2rem; }

@media (min-width: 1024px) {
  .tabbar { display: none; }
  .header-search { display: block; }
  .rail {
    display: flex; flex-direction: column; gap: .15rem;
    position: fixed; top: 0; bottom: 0; left: 0; width: var(--rail-w);
    padding: 1.1rem .9rem; border-right: 1px solid var(--border); background: var(--bg);
    overflow-y: auto;
  }
  .rail .brand { padding: .15rem .6rem 1.25rem; }
  .rail-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .75rem; border-radius: 10px; color: var(--text-2); font-weight: 500;
  }
  .rail-link svg { width: 20px; height: 20px; }
  .rail-link:hover { background: var(--surface-2); color: var(--text); }
  .rail-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
  .rail-section { margin: 1.25rem .75rem .35rem; font-size: .72rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
  .rail-foot { margin-top: auto; padding-top: 1rem; }
  .app.has-nav .app-header, .app.has-nav .app-main { margin-left: var(--rail-w); }
  .app.has-nav .app-header .brand { display: none; }
  .app-main { padding-bottom: 3rem; }
}

/* ── page layout ────────────────────────────────────────────────────────── */
.page { width: 100%; max-width: 760px; margin: 0 auto; padding: 1rem 1rem 0; }
.page.wide { max-width: 1120px; }
.page-head { margin: .5rem 0 1.25rem; }
.page-head .actions { margin-top: 1rem; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.eyebrow { font-size: .82rem; font-weight: 600; color: var(--text-3); margin-bottom: .3rem; }
.title { font: 700 1.9rem/1.12 var(--font-display); letter-spacing: -.03em; }
.subtitle { color: var(--text-2); margin-top: .35rem; }
.section { margin-top: 2rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.section-title { font-size: 1.1rem; font-weight: 650; letter-spacing: -.01em; }
.section-link { font-size: .9rem; font-weight: 600; color: var(--text-2); }
.section-link:hover { color: var(--text); }
.stack > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: .5rem; }
.grid-2, .grid-3 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page { padding: 1.5rem 1.5rem 0; }
  .title { font-size: 2.25rem; }
}
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.strong { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hidden { display: none !important; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.flat { color: var(--text-2); }

/* ── cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--r-lg); padding: 1.1rem 1.15rem;
}
.card.outline { background: var(--bg); border: 1px solid var(--border); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 1.1rem 1.15rem .25rem; }
.card.tint { background: var(--surface-2); }
.card.dark { background: var(--accent); color: var(--accent-text); }
.card.dark .muted, .card.dark .card-sub { color: color-mix(in srgb, var(--accent-text) 70%, transparent); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.card-title { font-weight: 650; font-size: 1rem; }
.card-sub { color: var(--text-2); font-size: .875rem; margin-top: .15rem; }
.card-link { font-size: .875rem; font-weight: 600; color: var(--text-2); }
a.card:hover { background: var(--surface-2); }

/* ── hero number ────────────────────────────────────────────────────────── */
.hero { margin: .25rem 0 1.25rem; }
.hero-label { color: var(--text-2); font-weight: 500; font-size: .95rem; }
.hero-value { font-size: 2.6rem; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; margin-top: .2rem; }
.hero-change { margin-top: .35rem; font-weight: 600; font-size: .95rem; }
@media (min-width: 720px) { .hero-value { font-size: 3rem; } }

/* ── stats ──────────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
@media (min-width: 720px) { .stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } .stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { background: var(--surface); border-radius: var(--r); padding: .9rem 1rem; min-width: 0; }
.stats.plain .stat { background: transparent; border: 0; padding: 0; }
.stat-label { color: var(--text-2); font-size: .82rem; font-weight: 500; }
.stat-value { font-size: 1.3rem; font-weight: 650; letter-spacing: -.02em; margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { color: var(--text-3); font-size: .8rem; margin-top: .1rem; }

/* ── lists ──────────────────────────────────────────────────────────────── */
.list { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.list.plain { background: transparent; border: 0; box-shadow: none; border-radius: 0; }
.list > .row + .row, .list > * + .row { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: .85rem; padding: .85rem 1.1rem; min-height: 64px; }
a.row:hover, button.row:hover { background: var(--surface-2); }
.list.plain .row { padding-left: 0; padding-right: 0; }
.row-avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text); font-weight: 700; font-size: .72rem; letter-spacing: -.01em;
}
.row-avatar.pos { background: var(--pos-bg); color: var(--pos); }
.row-avatar.neg { background: var(--neg-bg); color: var(--neg); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Subtitles wrap to two lines rather than cutting off dates and amounts. */
.row-sub {
  color: var(--text-2); font-size: .85rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-end { flex: 0 0 auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; }
.row-value { font-weight: 600; white-space: nowrap; }
.row-meta { color: var(--text-2); font-size: .85rem; white-space: nowrap; }
.row-chevron { flex: none; color: var(--text-3); }

/* ── key/value ──────────────────────────────────────────────────────────── */
.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.kv > div:first-child { border-top: 0; padding-top: 0; }
.kv > div:last-child { padding-bottom: 0; }
.kv dt { color: var(--text-2); font-size: .92rem; }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }

/* ── pills, dots, banners ───────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .6rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  font-size: .78rem; font-weight: 600; white-space: nowrap; line-height: 1.4;
}
.pill.pos { background: var(--pos-bg); color: var(--pos); }
.pill.neg { background: var(--neg-bg); color: var(--neg); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.dark { background: var(--accent); color: var(--accent-text); }
.pill.outline { background: transparent; border: 1px solid var(--border-strong); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.pos { background: var(--pos); } .dot.neg { background: var(--neg); } .dot.warn { background: var(--warn); } .dot.info { background: var(--info); }

.banner {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .85rem 1rem; border-radius: var(--r);
  background: var(--info-bg); color: var(--text); font-size: .92rem;
}
.banner .banner-icon { flex: none; margin-top: .1rem; color: var(--info); }
.banner.ok { background: var(--pos-bg); } .banner.ok .banner-icon { color: var(--pos); }
.banner.warn { background: var(--warn-bg); } .banner.warn .banner-icon { color: var(--warn); }
.banner.error { background: var(--neg-bg); } .banner.error .banner-icon { color: var(--neg); }
.banner-title { font-weight: 650; }
.banner + .banner { margin-top: .5rem; }

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; padding: 0 1.25rem;
  border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .95rem; line-height: 1; white-space: nowrap;
  cursor: pointer; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); opacity: .88; }
.btn-secondary { background: var(--surface-2); border-color: transparent; }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--neg) 45%, transparent); color: var(--neg); }
.btn-danger:hover { background: var(--neg-bg); }
.btn-danger.solid { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-pos { background: var(--pos); border-color: var(--pos); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 .9rem; font-size: .85rem; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions.end { justify-content: flex-end; }
.actions form { margin: 0; }
.inline-form { display: inline; margin: 0; }

/* ── forms ──────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 1rem; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .input {
  width: 100%; min-height: 48px; padding: .7rem .9rem;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: 16px; /* no iOS zoom */
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}
.field .hint { color: var(--text-3); font-size: .82rem; margin-top: .35rem; }
.field .error-text { color: var(--neg); font-size: .82rem; margin-top: .35rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.input-affix { position: relative; }
.input-affix > span { position: absolute; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-affix > .prefix { left: .9rem; }
.input-affix > .prefix + input, .field .input-affix > .prefix + input { padding-left: 1.9rem; }
.field .input-affix > input:has(+ .suffix) { padding-right: 2.4rem; }
.input-affix > .suffix { right: .9rem; }
select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238e897f' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .9rem center; padding-right: 2.4rem !important; }
.check { display: flex; align-items: flex-start; gap: .65rem; padding: .55rem 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: .1rem 0 0; accent-color: var(--accent); flex: none; }

.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--pos); }
.switch input:checked + span::after { transform: translateX(18px); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); max-width: 100%; overflow-x: auto; }
.segmented > a, .segmented > button, .segmented > label {
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  padding: .4rem .9rem; border-radius: 999px; font-size: .88rem; font-weight: 600; color: var(--text-2);
}
.segmented > .active, .segmented > [aria-pressed="true"], .segmented input:checked + span {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.segmented input { display: none; }

.tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs > a, .tabs > button { padding: .7rem 0; border: 0; background: none; border-bottom: 2px solid transparent; font-weight: 600; color: var(--text-2); white-space: nowrap; cursor: pointer; }
.tabs > .active { color: var(--text); border-bottom-color: var(--text); }

.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; }
.chip { flex: none; padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .85rem; font-weight: 600; color: var(--text-2); cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ── tables (stack into cards on phones) ───────────────────────────────── */
.table-wrap { background: var(--surface); border-radius: var(--r-lg); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; font-size: .78rem; color: var(--text-3); padding: .75rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .8rem 1rem; border-top: 1px solid var(--border); vertical-align: middle; }
.table tr:first-child td { border-top: 0; }
.table .num, .table th.num { text-align: right; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.highlight td { background: var(--surface-2); }
@media (max-width: 719px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: .8rem 1.1rem; border-top: 1px solid var(--border); }
  .table.stack tr:first-child { border-top: 0; }
  .table.stack td { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; border: 0; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--text-2); text-align: left; font-weight: 500; }
  .table.stack td[data-label=""]::before, .table.stack td:not([data-label])::before { content: none; }
  .table.stack td.primary { font-weight: 650; font-size: 1rem; padding-bottom: .35rem; justify-content: flex-start; text-align: left; }
  .table.stack .num { text-align: right; }
}

/* ── empty / loading ────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 2.5rem 1.25rem; color: var(--text-2); }
.empty-icon { width: 52px; height: 52px; margin: 0 auto .9rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.empty-title { font-weight: 650; color: var(--text); font-size: 1.05rem; margin-bottom: .25rem; }
.empty .actions { justify-content: center; margin-top: 1rem; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── sheet / modal ──────────────────────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 15, 14, .45); display: none; align-items: flex-end; justify-content: center; }
.sheet-backdrop.open { display: flex; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding: .75rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
}
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 1rem; }
.sheet-title { font: 700 1.4rem/1.2 var(--font-display); letter-spacing: -.02em; margin-bottom: .35rem; }

/* ── overflow menu (<details class="menu">) ────────────────────────────── */
.menu { position: relative; flex: none; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 200px;
  background: var(--raised); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: .35rem; display: flex; flex-direction: column;
}
.menu-list > a, .menu-list > button, .menu-list form > button {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .65rem .75rem; border: 0; border-radius: 10px; background: none; cursor: pointer;
  text-align: left; font-size: .92rem; font-weight: 500; color: var(--text);
}
.menu-list > a:hover, .menu-list > button:hover, .menu-list form > button:hover { background: var(--surface); }
.menu-list .danger { color: var(--neg); }
.menu-list form { margin: 0; }
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; padding: 1.5rem; }
  .sheet::before { display: none; }
}

/* ── flash toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1rem);
  max-width: min(92vw, 520px); padding: .8rem 1.1rem; border-radius: 14px;
  background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-lg);
  font-size: .92rem; font-weight: 500;
  animation: toast-in .25s ease-out, toast-out .3s ease-in 6s forwards;
}
@media (min-width: 1024px) { .toast { bottom: 1.5rem; left: calc(50% + var(--rail-w) / 2); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }

/* ── charts ─────────────────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; overflow: visible; }
.chart .line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.pos { stroke: var(--pos); } .chart .line.neg { stroke: var(--neg); }
.chart .area { opacity: .12; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart text { fill: var(--text-3); font-size: 11px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--text); }
.bar > span.pos { background: var(--pos); } .bar > span.neg { background: var(--neg); }

/* ── public sign-in / landing ──────────────────────────────────────────── */
.landing { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 2rem 1.5rem; max-width: 520px; margin: 0 auto; }
.landing .title { font-size: 2.6rem; }
