/* ==========================================================================
   Budget.io — design tokens & shell
   Dark-first. Every colour is a role, so light mode is a value swap, not a
   rewrite, and chart marks theme for free.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* surfaces */
  --surface-0: #0b0d10;      /* app background */
  --surface-1: #12151a;      /* cards */
  --surface-2: #171b21;      /* raised / pressed */
  --surface-3: #1e242c;      /* inputs, chips */
  --hairline:  #232a33;
  --hairline-soft: #1a1f26;

  /* ink — every value below is >= 4.5:1 on surface-0, -1 and -3 (scripts/contrast.mjs) */
  --text-primary:   #eef1f6;
  --text-secondary: #99a3b2;
  --text-muted:     #828b9b;

  /* categorical — validated 3-slot set (dark steps) */
  --series-1: #3987e5;   /* needs   */
  --series-2: #d95926;   /* wants   */
  --series-3: #199e70;   /* savings */

  /* sequential (single-hue magnitude ramp, blue) */
  --seq-100: #cde2fb; --seq-250: #86b6ef; --seq-400: #3987e5;
  --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;

  /* status — reserved, never reused as a series colour, and readable as TEXT */
  --good:     #199e70;
  --warning:  #c98500;
  --serious:  #e86736;
  --critical: #e66767;

  /* The review badge is the one place a status colour is a BACKGROUND with white
     on top, and the two requirements pull opposite ways: --serious has to be
     light enough to read as text on --surface-0 (>= 4.5:1 needs L >= 0.194),
     white on it needs L <= 0.183. No single value satisfies both, so the badge
     gets its own darker step of the same hue — white 4.95:1, and the pill itself
     still 3.70:1 against the tab bar. */
  --badge-bg:  #c9410f;
  --badge-ink: #ffffff;

  /* The partial current month, de-emphasised but still a data mark. --seq-600 is
     the right ramp step on a light background and only 2.26:1 on a dark one. */
  --bar-dim: #256abf;   /* = --seq-500 */

  --accent: #4c9af9;
  --accent-ink: #08121c;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 30px rgba(0,0,0,.45);
  --shadow-sheet: 0 -12px 48px rgba(0,0,0,.6);

  --tab-h: 58px;
  --ease: cubic-bezier(.32,.72,0,1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

:root[data-theme='light'] {
  color-scheme: light;
  --surface-0: #f6f7f9;
  --surface-1: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e9ecf1;
  --hairline:  #e2e6ec;
  --hairline-soft: #eef0f4;
  --text-primary:   #0d1117;
  --text-secondary: #59626f;
  --text-muted:     #636b76;
  /* Marks, not text: the 3:1 floor. The previous orange (2.99 on the page) and
     green (2.63) fell under it, which is a goal bar you can't see how full. */
  --series-1: #2a78d6;
  --series-2: #d14d1c;
  --series-3: #0f8a5f;
  --good: #007a4a; --warning: #975100; --serious: #b53600; --critical: #c82e32;
  --badge-bg: #b53600; --badge-ink: #ffffff;
  --bar-dim: #184f95;   /* = --seq-600; correct direction on a light surface */
  --accent: #025db9;
  --accent-ink: #ffffff;
  --shadow-1: 0 1px 2px rgba(16,24,40,.06);
  --shadow-2: 0 10px 34px rgba(16,24,40,.10);
  --shadow-sheet: 0 -12px 48px rgba(16,24,40,.18);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
/* Kill the browser's own bounce/pull-to-refresh once installed — we ship our own. */
@media (display-mode: standalone) {
  html, body { overscroll-behavior: none; }
}
.ui, button, .tap {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* Small controls whose visible box is under 44px. The pseudo-element extends
   the *hit* area to 44x44 without touching layout or the visual box, which is
   what padding + negative margin would do at the cost of a different layout in
   every one of the five places this is used. */
.hit { position: relative; }
.hit::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 100%; height: 100%; min-width: 44px; min-height: 44px;
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input, select { font: inherit; color: inherit; }

/* Every money figure. Non-negotiable — proportional digits make columns wobble. */
.num, .money { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ---------- app shell ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--tab-h) + var(--safe-b) + 28px);
  max-width: 780px;
  margin-inline: auto;
  width: 100%;
  animation: screen-in .28s var(--ease) both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 10px 2px 18px;
}
.topbar h1 { font-size: 26px; line-height: 1.15; font-weight: 680; letter-spacing: -.02em; margin: 0; }
.topbar .sub { color: var(--text-muted); font-size: 13px; }
/* "Synced 12 minutes ago." Deliberately the quietest text on the screen: a
   daily green tick is how you teach someone to ignore the red one. */
.sync-line { color: var(--text-muted); font-size: 12px; margin-top: 2px; opacity: .85; }

/* ---------- cards ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.card-head h2 { font-size: 14px; font-weight: 600; margin: 0; color: var(--text-secondary); letter-spacing: .01em; }
.card-head .action { font-size: 13px; color: var(--accent); font-weight: 550; }

/* ---------- hero ---------- */
.hero {
  background:
    radial-gradient(120% 140% at 50% -10%, color-mix(in oklab, var(--accent) 16%, transparent) 0%, transparent 62%),
    var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  padding: 24px 20px 20px;
  margin-bottom: 12px;
  text-align: center;
}
.hero .label { font-size: 13px; color: var(--text-secondary); font-weight: 550; letter-spacing: .02em; }
.hero .amount {
  font-size: clamp(38px, 11vw, 54px); font-weight: 700; letter-spacing: -.035em;
  line-height: 1.05; margin: 6px 0 2px;
  /* A seven-figure balance is one unbreakable "word": without this it pushes
     the document wider than the viewport on a 320px screen. */
  overflow-wrap: anywhere;
}
.hero .amount .cur { font-size: .42em; font-weight: 600; color: var(--text-secondary); vertical-align: .45em; margin-right: .28em; letter-spacing: 0; }
.hero .amount .frac { color: var(--text-secondary); font-weight: 600; }
.hero .amount.neg { color: var(--critical); }
.hero .meta { font-size: 13.5px; color: var(--text-secondary); margin-top: 6px; }
.hero .meta b { color: var(--text-primary); font-weight: 600; }

/* ---------- pace bar ---------- */
.pace { margin-top: 18px; }
.pace-track {
  position: relative; height: 10px; border-radius: 999px;
  background: var(--surface-3); overflow: visible;
}
.pace-fill {
  position: absolute; inset: 0 auto 0 0; border-radius: 999px;
  background: var(--accent);
  transition: width .6s var(--ease);
}
.pace-fill.over { background: var(--serious); }
.pace-fill.ahead { background: var(--good); }
/* "you should be here" marker */
.pace-marker {
  position: absolute; top: -5px; width: 2px; height: 20px; border-radius: 2px;
  background: var(--text-primary); opacity: .55;
  box-shadow: 0 0 0 2px var(--surface-1);
}
.pace-legend {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 9px; font-size: 12.5px; color: var(--text-muted);
}
.pace-legend .st { font-weight: 600; }
.st.good { color: var(--good); } .st.warn { color: var(--warning); }
.st.serious { color: var(--serious); } .st.critical { color: var(--critical); }

/* ---------- allocation split ---------- */
.alloc-bar {
  display: flex; gap: 2px; height: 12px; border-radius: 999px; overflow: hidden;
  background: var(--surface-3); margin-bottom: 12px;
}
.alloc-seg { height: 100%; }
.alloc-list { display: grid; gap: 9px; }
.alloc-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.alloc-row .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.alloc-row .nm { flex: 1; color: var(--text-secondary); }
.alloc-row .vl { font-weight: 600; }

/* ---------- category rows ---------- */
.cat-list { display: grid; gap: 15px; }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.cat-top { display: contents; }
.cat-name { font-size: 14.5px; font-weight: 550; display: flex; align-items: center; gap: 8px; }
.cat-val { font-size: 14.5px; font-weight: 600; }
.cat-val .of { color: var(--text-muted); font-weight: 500; font-size: 13px; }
.cat-track {
  grid-column: 1 / -1; height: 7px; border-radius: 999px;
  background: var(--surface-3); overflow: hidden; margin-top: 3px;
}
.cat-fill { height: 100%; border-radius: 999px; transition: width .6s var(--ease); }
.cat-sub { grid-column: 1/-1; font-size: 12px; color: var(--text-muted); }

/* ---------- transaction rows ---------- */
.txn-list { display: flex; flex-direction: column; }
/* `1fr` is `minmax(auto, 1fr)`, and `auto` as a MINIMUM means min-content — so
   the middle track refused to shrink below the widest unbreakable merchant
   name, the row overflowed its card, and at 320px the meta line was hard-cut
   mid-character while `text-overflow: ellipsis` on `.txn-name` never fired
   (the element wasn't overflowing; its track was). `minmax(0, 1fr)` is what
   lets the child's own `min-width: 0` do its job. */
.txn {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center;
  gap: 12px; padding: 12px 16px; width: 100%; text-align: left;
  border-bottom: 1px solid var(--hairline-soft);
  transition: background .12s ease;
}
.txn:last-child { border-bottom: 0; }
.txn:active { background: var(--surface-2); }
.txn-ic {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-3); font-size: 16px;
}
.txn-main { min-width: 0; }
.txn-name {
  font-size: 15px; font-weight: 550; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
/* Wrapping rows — the review queue, where the text IS the content.
   `white-space: normal` alone was not enough: `text-overflow: ellipsis` stayed
   in force, so every wrapped line was truncated and the one string the deploy
   guide asks the owner to send on — the template fingerprint — rendered as
   `(fe4afb6132a…`. Overflow and text-overflow have to be reset with it. */
.txn-name.wrap {
  white-space: normal; overflow: visible; text-overflow: clip;
  overflow-wrap: anywhere; font-size: 14px; font-weight: 500; line-height: 1.35;
}
.txn-meta.wrap { white-space: normal; overflow: visible; overflow-wrap: anywhere; display: block; }
/* Anything the owner may need to copy out of the app verbatim. */
.selectable { user-select: text; -webkit-user-select: text; }
/* min-width/overflow, so the meta row stays inside its column. At 320px the
   category chip used to spill out of the 1fr cell and sit ON TOP of the amount,
   leaving both unreadable — a flex item's default min-width is its content, so
   nothing was containing it. */
.txn-meta {
  font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center;
  gap: 6px; margin-top: 1px; min-width: 0; overflow: hidden; white-space: nowrap;
}
.txn-meta > * { flex: 0 0 auto; }
/* Anything still too wide fades out rather than ending on a cut-off letter. */
.txn-meta { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 14px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 14px), transparent); }
/* Below ~360px there is no room for the category name next to the amount. The
   icon carries it; hold / FX / "needs category" stay, because nothing else on
   this screen says those. */
@media (max-width: 359.98px) {
  .txn-meta .chip.cat { display: none; }
  /* At 320px the middle column was down to 93px — narrower than "Yesterday ·
     12:04" — so the date/time, the one thing on the meta line that is always
     present, was being cut mid-digit. 32px of horizontal padding, 24px of gaps
     and a 38px icon were spending width the text needed. Tightened, the middle
     track is ~128px and the timestamp fits whole; the chips that follow it
     still fade out, which is what the fade is for. */
  .txn { padding: 12px; gap: 8px; grid-template-columns: 32px minmax(0, 1fr) auto; }
  .txn-ic { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; }
  .txn-name { font-size: 14.5px; }
  /* And then it wraps rather than fades. The fade is the right answer at 390px,
     where it only ever eats a trailing chip; at 320px it was eating the
     timestamp itself — "07 Aug · 16:0" — and a date you can't finish reading is
     not a design decision, it's a bug. One extra line per row is the price. */
  .txn-meta {
    font-size: 12px; white-space: normal; overflow: visible;
    flex-wrap: wrap; row-gap: 3px;
    -webkit-mask-image: none; mask-image: none;
  }
  /* A salary row's amount ("OMR 1,240.000") is 40px wider than a coffee's, and
     the middle track pays for it — down to 145px on that row alone. `flex: 0 0
     auto` then pinned "02 Aug · 16:00" at its max-content width and pushed it
     straight out of the box. Allowing these to shrink lets the date wrap at its
     own space instead. */
  .txn-meta > * { flex: 0 1 auto; min-width: 0; }
  .card-head { padding-left: 12px !important; padding-right: 12px !important; }
  /* Rows whose meta line carries several chips (subscriptions, leaks) wrap
     rather than fade out mid-word. The ledger's own rows deliberately do not:
     there the fade is the design, and every chip on them is one short word. */
  .txn-meta.wrap-narrow {
    white-space: normal; overflow: visible; flex-wrap: wrap; row-gap: 3px;
    -webkit-mask-image: none; mask-image: none;
  }
}
.txn-amt { font-size: 15px; font-weight: 620; white-space: nowrap; }
.txn-amt.credit { color: var(--good); }
.txn-amt .frac { color: var(--text-muted); font-weight: 500; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-secondary);
}
/* Tinted over surface-2 at 12%: a self-tinted chip eats its own contrast, and
   these three land >= 4.5:1 only at this strength. --series-1 is a chart mark
   (3:1 floor), so the FX chip takes the text-grade blue instead. */
.chip.hold { background: color-mix(in oklab, var(--warning) 12%, var(--surface-2)); color: var(--warning); }
.chip.fx   { background: color-mix(in oklab, var(--accent) 12%, var(--surface-2)); color: var(--accent); }
.chip.rev  { background: color-mix(in oklab, var(--serious) 12%, var(--surface-2)); color: var(--serious); }

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 15px; border-radius: var(--radius);
  border: 1px solid color-mix(in oklab, var(--warning) 35%, var(--hairline));
  background: color-mix(in oklab, var(--warning) 10%, var(--surface-1));
  margin-bottom: 12px;
}
.banner .ic { font-size: 17px; }
.banner .tx { flex: 1; font-size: 13.5px; line-height: 1.4; }
.banner .tx b { font-weight: 620; }
.banner .go { color: var(--text-muted); font-size: 18px; }
.banner.info {
  border-color: color-mix(in oklab, var(--series-1) 35%, var(--hairline));
  background: color-mix(in oklab, var(--series-1) 10%, var(--surface-1));
}

/* ---------- bottom nav ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in oklab, var(--surface-1) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--hairline);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10.5px; font-weight: 550; color: var(--text-muted);
  transition: color .15s ease;
}
.tab svg { width: 23px; height: 23px; }
.tab[aria-current='page'] { color: var(--accent); }
.tab { position: relative; }
.tab .badge {
  position: absolute; top: 4px; left: 50%; margin-left: 4px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--badge-bg); color: var(--badge-ink); font-size: 10px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface-1);
}
/* `display: grid` above outranks the UA sheet's `[hidden] { display: none }`,
   which is how a red 0 stayed pinned to the tab bar. */
.tab .badge[hidden] { display: none; }

/* ---------- sheet ---------- */
/* Scroll lock while a sheet is open. `top` is set inline to the scroll offset
   so the page does not jump, and restored on close. */
body.sheet-open { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  opacity: 0; transition: opacity .3s var(--ease);
  backdrop-filter: blur(2px);
}
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  background: var(--surface-1);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-sheet);
  padding: 8px 18px calc(24px + var(--safe-b));
  max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  transform: translateY(100%);
  transition: transform .34s var(--ease);
  max-width: 680px; margin-inline: auto;
  border: 1px solid var(--hairline); border-bottom: 0;
}
.sheet.open { transform: translateY(0); }
.grabber {
  width: 38px; height: 4px; border-radius: 999px; background: var(--surface-3);
  margin: 6px auto 14px;
}
.sheet h3 { margin: 0 0 4px; font-size: 20px; font-weight: 650; letter-spacing: -.015em; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 14px; margin-top: 16px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; text-align: right; font-weight: 550; word-break: break-word; }

.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.pick {
  padding: 9px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 550;
  background: var(--surface-3); color: var(--text-secondary);
  border: 1px solid transparent; transition: all .15s ease;
}
.pick[aria-pressed='true'] {
  background: color-mix(in oklab, var(--accent) 12%, var(--surface-3));
  color: var(--accent); border-color: color-mix(in oklab, var(--accent) 45%, transparent);
}

/* ---------- controls ---------- */
.seg {
  display: flex; gap: 3px; padding: 3px; background: var(--surface-3);
  border-radius: 12px; margin-bottom: 14px;
}
/* 44px minimum, not 30. These four are how the Activity tab is actually
   filtered on a phone, and they were the smallest touch targets in the app. */
.seg button {
  flex: 1; min-height: 44px; padding: 8px 6px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 550;
  color: var(--text-secondary); transition: all .18s var(--ease);
}
.seg button[aria-pressed='true'] {
  background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow-1);
}
.search {
  width: 100%; padding: 11px 14px; border-radius: 12px; margin-bottom: 12px;
  background: var(--surface-3); border: 1px solid transparent; font-size: 15px;
}
.search:focus { border-color: color-mix(in oklab, var(--accent) 50%, transparent); }
.search::placeholder { color: var(--text-muted); }

/* ---------- goals ---------- */
.goal { padding: 15px 0; border-bottom: 1px solid var(--hairline-soft); }
.goal:last-child { border-bottom: 0; padding-bottom: 0; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.goal-name { font-size: 15px; font-weight: 600; }
.goal-pct { font-size: 13px; color: var(--text-secondary); font-weight: 550; }
.goal-track { height: 8px; border-radius: 999px; background: var(--surface-3); margin: 9px 0 8px; overflow: hidden; }
.goal-fill { height: 100%; border-radius: 999px; background: var(--series-3); transition: width .7s var(--ease); }
.goal-meta {
  font-size: 12.5px; color: var(--text-muted);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px;
}
.goal-meta .late { color: var(--warning); font-weight: 550; }
.goal-meta .ontrack { color: var(--good); font-weight: 550; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid { stroke: var(--hairline-soft); stroke-width: 1; }
.chart .axis-label { fill: var(--text-muted); font-size: 10.5px; }
.chart .bar { fill: var(--seq-400); }
.chart .bar.dim { fill: var(--bar-dim); }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .area { fill: url(#areaGrad); }

.tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: 10px; padding: 7px 10px; font-size: 12.5px;
  box-shadow: var(--shadow-2); opacity: 0; transition: opacity .12s ease;
  white-space: nowrap;
}
.tip.on { opacity: 1; }
.tip .t-lbl { color: var(--text-muted); }
.tip .t-val { font-weight: 650; }

/* ---------- sign-in / lock ----------
   These own the whole viewport: no tab bar, nothing to navigate to. The screen
   padding that reserves room for the tab bar has to come back off, or the card
   sits visibly above centre. */
body.no-chrome .screen { padding-bottom: calc(var(--safe-b) + 28px); }
/* `el.hidden = true` alone does NOTHING here: the UA's `[hidden]{display:none}`
   is a type-selector-strength rule and `.tabbar{display:flex}` outranks it. The
   property was set, the assertion that read `.hidden` passed, and four
   unreachable tabs sat under the sign-in screen anyway. Verified in a
   screenshot, not in a DOM query — which is why the sweep now measures the
   rendered box rather than the attribute. */
body.no-chrome .tabbar,
body.no-chrome .ptr,
.tabbar[hidden],
.ptr[hidden] { display: none !important; }
.screen.auth {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh;
}
.auth-card {
  width: 100%; max-width: 380px; text-align: center;
  padding: 8px 4px 24px;
}
.auth-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 8px; }
.auth-mark { font-size: 40px; line-height: 1; margin-bottom: 12px; opacity: .75; }
.auth-sub {
  font-size: 14px; line-height: 1.6; color: var(--text-secondary);
  margin: 0 0 22px; text-wrap: pretty;
}
.auth-input { text-align: center; margin-bottom: 12px; }
.auth-code {
  font-size: 26px; font-weight: 650; letter-spacing: .34em; padding: 15px 10px 15px 14px;
}
.auth-primary {
  width: 100%; padding: 14px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 15px;
}
.auth-primary[disabled] { opacity: .55; }
.auth-link {
  display: block; width: 100%; margin-top: 12px; padding: 10px;
  font-size: 13.5px; color: var(--accent); font-weight: 550;
}
.auth-link[disabled] { color: var(--text-muted); }
.auth-error, .auth-notice {
  text-align: left; font-size: 13.5px; line-height: 1.5; padding: 11px 13px;
  border-radius: 12px; margin-bottom: 14px; overflow-wrap: anywhere;
}
.auth-error {
  color: var(--critical);
  background: color-mix(in oklab, var(--critical) 11%, var(--surface-1));
  border: 1px solid color-mix(in oklab, var(--critical) 32%, var(--hairline));
}
.auth-notice {
  color: var(--text-secondary);
  background: var(--surface-1); border: 1px solid var(--hairline);
}
.auth-foot {
  font-size: 12px; line-height: 1.55; color: var(--text-muted);
  margin-top: 26px; text-wrap: pretty;
}

/* ---------- misc ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--text-muted); font-size: 14px; }
.empty .big { font-size: 34px; margin-bottom: 12px; opacity: .55; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 13px;
}
.stat .v { font-size: 19px; font-weight: 680; letter-spacing: -.02em; }
.stat .k { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.section-title {
  font-size: 12px; font-weight: 620; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); margin: 22px 2px 10px;
}
.list-note { font-size: 12.5px; color: var(--text-muted); padding: 10px 16px 2px; line-height: 1.45; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  transform: translate(-50%, 20px); z-index: 70;
  background: var(--surface-2); border: 1px solid var(--hairline);
  color: var(--text-primary); padding: 11px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 550; box-shadow: var(--shadow-2);
  opacity: 0; transition: all .3s var(--ease); pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* pull to refresh */
.ptr {
  position: absolute; top: calc(var(--safe-t) + 4px); left: 50%;
  transform: translateX(-50%); opacity: 0; transition: opacity .2s;
  color: var(--text-muted); font-size: 12px;
}
.ptr.on { opacity: 1; }

/* ---------- desktop ---------- */
@media (min-width: 860px) {
  #app { flex-direction: row; }
  .tabbar {
    order: -1;                      /* sidebar leads, content follows */
    position: sticky; top: 0; left: 0; right: auto; bottom: auto;
    height: 100dvh; width: 232px; flex: none;
    grid-template-columns: 1fr; grid-auto-rows: max-content;
    align-content: start; gap: 4px; padding: 26px 14px;
    border-top: 0; border-right: 1px solid var(--hairline);
    background: var(--surface-1); backdrop-filter: none;
  }
  .tabbar::before {
    content: 'Budget.io'; display: block; padding: 0 12px 22px;
    font-size: 17px; font-weight: 680; color: var(--text-primary); letter-spacing: -.02em;
  }
  .tab {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 12px; border-radius: 11px; font-size: 14.5px;
  }
  .tab[aria-current='page'] { background: color-mix(in oklab, var(--accent) 14%, transparent); }
  .tab .badge { position: static; margin: 0 0 0 auto; box-shadow: none; }
  .screen { padding: 30px 34px 60px; max-width: 900px; margin: 0; }
  .hero .amount { font-size: 52px; }
  .sheet {
    max-width: 520px; border-radius: var(--radius-xl); bottom: auto;
    top: 50%; left: 50%; right: auto;
    transform: translate(-50%, -46%) scale(.97); opacity: 0;
    transition: opacity .22s var(--ease), transform .22s var(--ease);
    border-bottom: 1px solid var(--hairline);
  }
  .sheet.open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .grabber { display: none; }
  .toast { bottom: 26px; left: auto; right: 26px; transform: translateY(20px); }
  .toast.on { transform: translateY(0); }
}

@media (min-width: 1180px) {
  /* Multi-column card flow — the phone layout stacked twice over is a waste of
     a 1440px screen, but a bespoke desktop layout would be a second app to
     maintain. Columns give a dense dashboard from the same markup. */
  .screen { max-width: 1240px; columns: 2; column-gap: 18px; }
  .screen > * { break-inside: avoid; }
  .topbar, .hero { column-span: all; }
  .hero { max-width: 560px; margin-inline: auto; }
}

/* Charts get an explicit height; an SVG with no height fills its container and
   stretches the marks vertically. */
.chart[data-h] { width: 100%; display: block; }
