/* ============================================================
   Plot — Design System  ·  "Apple"
   SF Pro typography · neutral canvas · frosted chrome ·
   soft depth · vibrant system accents · reusable components
   ============================================================ */

:root {
  /* ── text ── */
  --ink:    #1D1D1F;   /* primary label */
  --ink-2:  #515154;   /* secondary label */
  --ink-3:  #6B6B70;   /* tertiary label — AA 4.5:1 on white & 4.87:1 on the F5F5F7 inset (was #86868B = 3.3:1, failed) */
  --ink-4:  #AEAEB2;   /* quaternary / disabled */

  /* ── surfaces ── */
  --canvas:        #F5F5F7;   /* app background */
  --paper:         #F5F5F7;
  --paper-2:       #ECECEF;
  --surface:       #FFFFFF;   /* cards */
  --surface-2:     #F5F5F7;   /* insets / fills */
  --surface-hover: #FAFAFB;
  --frost:         rgba(255,255,255,0.72);

  /* ── system accents ── */
  --blue:    #0A84FF;  --blue-press: #0060DF;  --blue-soft: rgba(10,132,255,.12);
  --blue-text: #0066CC;  /* AA 5.6:1 on white — use for blue TEXT/links; --blue stays for fills & rings */
  --green:   #248A3D;  --green-soft: rgba(48,168,80,.14);   --green-vivid: #30D158;
  --red:     #E0301E;  --red-soft: rgba(224,48,30,.12);
  --orange:  #F56300;  --orange-soft: rgba(245,99,0,.12);
  --amber:   #C77700;  --amber-soft: rgba(199,119,0,.14);
  --purple:  #5E5CE6;  --purple-soft: rgba(94,92,230,.13);
  --coral:   #FF5A2C;  --coral-2: #E8410F;  --coral-soft: rgba(255,90,44,.12);

  /* ── semantic TEXT colors (AA on the matching soft tints) — one source for the
     darker label hexes that pills/labels used to hardcode + hand-patch for dark ── */
  --green-text: #18742F;  --red-text: #C42410;  --amber-text: #8a5500;
  --coral-text: #C53407;  --purple-text: #4B48C4;

  /* ── lines & depth ── */
  --border:    rgba(0,0,0,0.08);
  --border-2:  rgba(0,0,0,0.14);
  --hair:      rgba(0,0,0,0.06);
  --sh-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
  --sh:    0 2px 6px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --sh-md: 0 4px 12px rgba(0,0,0,.07), 0 18px 44px rgba(0,0,0,.09);
  --sh-lg: 0 24px 64px rgba(0,0,0,.18);
  --inset-hi: inset 0 0 0 .5px rgba(0,0,0,.02);

  /* ── type ── */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --font-mono:    "SF Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;

  /* ── metrics ── */
  --sidebar-w: 252px;
  --topbar-h:  60px;
  --radius-xs: 8px;
  --radius-sm: 11px;
  --radius-md: 14px;
  --radius:    18px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --ease:        cubic-bezier(.32,.72,0,1);    /* apple spring-ish */
  --ease-out:    cubic-bezier(.2,.7,.2,1);     /* gentle deceleration */
  --ease-spring: cubic-bezier(.2,1.3,.4,1);    /* overshoot / pop */
  --dur-fast: .12s;  --dur-base: .2s;  --dur-slow: .4s;

  /* ── type / weight / spacing scale ──
     Named ramps so "matching two components" stops being a guessing game. Built
     around the sizes already clustered across the app; migrate surfaces onto these
     incrementally (with eyeball review — snapping 12.5→13 needs eyes, not sed). */
  --text-xs: 11px;  --text-sm: 12.5px;  --text-base: 14px;  --text-md: 15px;
  --text-lg: 17px;  --text-xl: 21px;    --text-2xl: 28px;
  --w-normal: 450;  --w-medium: 510;  --w-semi: 590;  --w-bold: 700;
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;  --space-4: 16px;
  --space-5: 22px;  --space-6: 32px;

  /* ── segmented controls (one source of truth for the "track + sliding pill"
     family: .auth-seg / .seg / .segmented / .admin-seg). Each keeps its own
     padding/layout; only the shared look is tokenized. ── */
  --seg-trough: var(--surface-2);   /* the recessed track */
  --seg-radius: 11px;               /* track corner */
  --seg-pill-radius: 8px;           /* active button corner */

  /* ── derived aliases (referenced across plot-features.css) ── */
  --bg: var(--surface);               /* opaque field/popover background; tracks dark */
  --fill: rgba(120,120,128,.12);      /* neutral chip fill (theme-agnostic) */
  --overlay-hover: rgba(0,0,0,.05);   /* subtle hover wash (overridden in dark) */
  --control-h: 38px;                  /* shared height for btn/input/select/rs-btn */
  --focus-ring: 0 0 0 3px var(--blue-soft), 0 0 0 1px var(--blue);
  --glow-blue: 0 5px 16px rgba(10,132,255,.28);

  /* cream tokens used by the (always-dark) sidebar chips — define for light too */
  --cream: var(--ink); --cream-2: var(--ink-3); --cream-3: var(--ink-4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* the [hidden] attribute must always win over display-setting class rules */
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; text-rendering: optimizeLegibility; scrollbar-gutter: stable; background: var(--canvas);
  /* Stop Safari/Chrome from inflating body text in landscape, which breaks the
     15px/1.47 rhythm and tabular-num alignment. */
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -0.012em;
  color: var(--ink);
  background: var(--canvas);
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.1; letter-spacing: -0.022em; color: var(--ink); }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 14px; }
a { color: inherit; text-decoration: none; }

/* tabular numerals everywhere money lives — the Apple Wallet/Stocks look */
.num, .mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; letter-spacing: -0.01em; white-space: nowrap; }
.num-display { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; letter-spacing: -0.03em; white-space: nowrap; }
.muted { color: var(--ink-3); }
.dim   { color: var(--ink-2); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.text-right { text-align: right; }
.text-sm { font-size: 13px; }
.text-amber { color: var(--amber); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }

/* ─── layout ─── */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }  /* dvh: exclude the mobile URL bar */

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--frost);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--hair);
  display: flex; flex-direction: column; z-index: 100;
}
.sidebar-logo { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 20px; transition: opacity .15s var(--ease); }
.sidebar-logo:hover { opacity: .82; }
.sidebar-logo:active { opacity: .65; }
.sidebar-logo .logo-mark { transition: transform .2s var(--ease-spring); }
.sidebar-logo:hover .logo-mark { transform: rotate(-4deg) scale(1.04); }
.logo-mark { width: 28px; height: 28px; flex: none; border-radius: 8px; box-shadow: var(--sh-sm); }
.logo-text { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -0.03em; color: var(--ink); }
.logo-text .dot { color: var(--blue); }

/* flex:1 + min-height:0 lets the nav scroll when the viewport is short, instead of
   pushing the footer (and its Sign out button) off the bottom and clipping it. */
.sidebar-nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; font-size: 14.5px; letter-spacing: -0.01em;
  transition: background .18s var(--ease), color .18s var(--ease), box-shadow .22s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; flex: none; color: var(--ink-3); transition: color .18s; }
.nav-item:hover { background: var(--overlay-hover); color: var(--ink); }
.nav-item:hover svg { color: var(--ink-2); }
.nav-item.active { background: var(--blue); color: #fff; box-shadow: var(--glow-blue); }
.nav-item.active svg { color: #fff; }
.nav-divider { height: 1px; background: var(--hair); margin: 8px 12px; }

.sidebar-foot { flex: none; padding: 14px 20px; border-top: 1px solid var(--hair); font-size: 12px; color: var(--ink-3); line-height: 1.45; }
.sidebar-foot strong { color: var(--ink-2); font-weight: 600; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.main { overflow-x: clip; }
/* `clip` (not hidden) preserves position:sticky on .topbar and doesn't create a scroll container */

.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; padding: 0 32px;
  background: var(--frost);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hair);
}
.topbar .bar { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 1240px; margin: 0 auto; gap: 16px; }
.topbar .bar > div:first-of-type { min-width: 0; }
.topbar .page-title { font-size: 21px; font-weight: 600; letter-spacing: -0.024em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; letter-spacing: -0.01em; }

.content { padding: 28px 32px 72px; max-width: 1240px; margin: 0 auto; }

/* staggered reveal — FIRST LOAD ONLY (body.boot is removed shortly after load).
   Gating to .boot stops it replaying on navigation and, crucially, stops its
   staggered animation-delay from leaking onto dialogs opened later (which caused
   a show→vanish→show flicker). Dialogs/scripts are excluded outright. */
@media (prefers-reduced-motion: no-preference) {
  .boot .content > *:not(dialog):not(script) { animation: rise .55s var(--ease) backwards; }
  .boot .content > *:nth-child(1){animation-delay:.02s}
  .boot .content > *:nth-child(2){animation-delay:.07s}
  .boot .content > *:nth-child(3){animation-delay:.12s}
  .boot .content > *:nth-child(4){animation-delay:.17s}
  .boot .content > *:nth-child(5){animation-delay:.22s}
  .boot .content > *:nth-child(6){animation-delay:.27s}
  .boot .content > *:nth-child(7){animation-delay:.32s}
  .boot .content > *:nth-child(n+8){animation-delay:.36s}
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* a dialog must never inherit a reveal delay — it animates only on open */
dialog { animation-delay: 0s !important; }

/* ─── segmented month selector (Apple) ─── */
.month-pick {
  display: inline-flex; align-items: center; gap: 2px;
  background: rgba(120,120,128,.12); border-radius: 10px; padding: 2px;
}
.month-arrow { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-2); transition: all .15s var(--ease); }
.month-arrow:hover { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); }
.month-label { font-weight: 600; font-size: 14px; padding: 0 12px; min-width: 134px; text-align: center; letter-spacing: -0.01em; }
.month-today { font-size: 13px; color: var(--blue-text); font-weight: 590; margin-left: 6px; padding: 6px 12px; border-radius: 9px; }
.month-today:hover { background: var(--blue-soft); }

/* ─── cards ─── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--sh-sm), var(--inset-hi); }
.card-pad { padding: 22px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 17px 24px; border-bottom: 1px solid var(--hair); }
.card-head h3 { font-size: 16px; font-weight: 600; }
.grid { display: grid; gap: 18px; }
/* Grid children default to min-width:auto, so a responsive Chart.js canvas (whose
   pixel width is set to the track width each frame) can ratchet the track — and
   the whole page — ever wider, an un-scrollable runaway. Letting children shrink
   below their content breaks that feedback loop; charts then size to the track. */
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ─── stat tiles ─── */
.stat {
  position: relative; overflow: hidden; background: var(--surface);
  border-radius: var(--radius); padding: 18px 22px 20px; box-shadow: var(--sh-sm), var(--inset-hi);
  transition: transform .28s var(--ease), box-shadow .28s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--sh); }
.stat .label { font-size: 13px; font-weight: 510; color: var(--ink-3); letter-spacing: -0.01em; }
.stat .value { font-family: var(--font-display); font-weight: 600; font-size: 28px; letter-spacing: -0.03em; margin-top: 7px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.stat::after { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--ink-4); }
.stat.accent-blue::after   { background: var(--blue); }
.stat.accent-green::after  { background: var(--green-vivid); }
.stat.accent-orange::after { background: var(--orange); }
.stat.accent-purple::after { background: var(--purple); }
.stat.accent-coral::after  { background: var(--coral); }
.stat.accent-amber::after  { background: var(--amber); }

/* ─── buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-body); font-weight: 590; font-size: 14px; letter-spacing: -0.01em;
  min-height: var(--control-h);
  padding: 8px 15px; border-radius: 980px; border: none; background: rgba(120,120,128,.12); color: var(--ink);
  cursor: pointer; transition: transform .12s var(--ease), background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { background: rgba(120,120,128,.2); }
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-blue { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(10,132,255,.3); }
.btn-blue:hover { background: var(--blue-press); }
.btn-coral { background: var(--coral); color: #fff; }
.btn-coral:hover { background: var(--coral-2); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--blue-text); }
.btn-ghost:hover { background: var(--blue-soft); }

/* ─── pills / badges ─── */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 590; padding: 3px 10px; border-radius: 980px; letter-spacing: -0.005em; }
.pill-green { background: var(--green-soft); color: var(--green-text); }  /* AA on green-soft */
.pill-red   { background: var(--red-soft); color: var(--red-text); }      /* AA on red-soft */
.pill-amber { background: var(--amber-soft); color: var(--amber-text); }  /* AA on the soft tint */
.pill-blue  { background: var(--blue-soft); color: var(--blue-text); }
.pill-coral { background: var(--coral-soft); color: var(--coral-text); }  /* AA on coral-soft */
.pill-purple { background: var(--purple-soft); color: var(--purple-text); }  /* was undefined → Admin/Lifetime pills had no fill */
.pill-grey  { background: rgba(120,120,128,.14); color: var(--ink-2); }
.pill-transfer { background: var(--purple-soft); color: var(--purple-text); }
.dot-mark { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ─── Ready to Assign ─── */
.rta {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 22px 26px; border-radius: var(--radius); color: #fff; box-shadow: var(--sh);
}
.rta.is-ready { background: linear-gradient(125deg, #0A84FF, #0060DF); }
.rta.is-zero  { background: linear-gradient(125deg, #30D158, #248A3D); }
.rta.is-over  { background: linear-gradient(125deg, #FF6155, #E0301E); }
.rta .rta-label { font-size: 12.5px; font-weight: 590; letter-spacing: .01em; opacity: .85; text-transform: uppercase; }
.rta .amount { font-family: var(--font-display); font-weight: 700; font-size: 33px; letter-spacing: -0.035em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.rta .rta-msg { font-size: 13.5px; opacity: .9; max-width: 330px; text-align: right; line-height: 1.4; }
.rta.pulse { animation: rtapulse .7s var(--ease); }
@keyframes rtapulse { 0%{transform:scale(1)} 38%{transform:scale(1.012)} 100%{transform:scale(1)} }

/* ─── budget grid ─── */
/* overflow-x:auto (not hidden) so a too-narrow viewport scrolls to reveal the
   Available column instead of silently clipping it; y stays hidden to clip the
   table to the card's rounded corners as before. */
.budget-wrap { overflow-x: auto; overflow-y: hidden; }
.budget-grid { width: 100%; border-collapse: collapse; }
.budget-grid thead th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 2px 14px 12px; text-align: right; }
.budget-grid thead th.col-name { text-align: left; padding-left: 24px; }
.group-row td { background: var(--surface-2); padding: 10px 14px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.group-row td.col-name { padding-left: 24px; }
.group-row .gtotal { text-align: right; font-variant-numeric: tabular-nums; font-weight: 510; font-size: 13px; }
.cat-row { border-top: 1px solid var(--hair); transition: background .12s; }
.cat-row:hover { background: var(--surface-hover); }
.cat-row td { padding: 9px 14px; text-align: right; vertical-align: middle; }
.cat-row td.col-name { text-align: left; padding-left: 24px; font-weight: 500; }
.cat-progress { display: inline-block; width: 44px; height: 5px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.cat-progress span { display: block; height: 100%; background: var(--blue); border-radius: 3px; transition: width .5s var(--ease); }
.cat-progress.over span { background: var(--red); }
.cat-link { color: var(--ink); transition: color .14s; }
.cat-link:hover { color: var(--blue-text); }

.assign-input {
  font-family: var(--font-body); font-size: 14px; text-align: right; width: 112px;
  padding: 6px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--ink); transition: all .14s; font-variant-numeric: tabular-nums;
}
.assign-input:hover { background: var(--surface-2); }
.assign-input:focus { outline: none; background: var(--surface); box-shadow: var(--focus-ring); border-color: var(--blue); }

.avail-pill { display: inline-block; min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 510; padding: 5px 11px; border-radius: 980px; }
.avail-pos  { background: var(--green-soft); color: var(--green); }
.avail-zero { background: rgba(120,120,128,.12); color: var(--ink-2); }
.avail-neg  { background: var(--red-soft); color: var(--red); }

.budget-grid tfoot td { padding: 16px 14px; border-top: 1px solid var(--border-2); font-variant-numeric: tabular-nums; font-weight: 590; text-align: right; font-size: 14px; }
.budget-grid tfoot td.col-name { text-align: left; padding-left: 24px; font-weight: 600; }
/* +12px = the avail-pill's own interior padding, so the grand-total figure aligns
   with the numbers *inside* the pills above it (not the pill borders). */
.budget-grid tfoot td.num:last-child { padding-right: 30px; }

/* ── budget grid · polish ── */
/* Collapse / expand a group; the chevron rotates and rows hide instantly (snappy). */
.group-collapse {
  display: inline-grid; place-items: center; width: 22px; height: 22px; margin: 0 1px 0 -4px;
  border: none; background: transparent; color: var(--ink-3); cursor: pointer; border-radius: 6px;
  vertical-align: middle; transition: background .14s, color .14s;
}
.group-collapse svg { width: 15px; height: 15px; transition: transform .22s var(--ease); }
.group-collapse:hover { background: var(--paper-2); color: var(--ink); }
.group-row.collapsed .group-collapse svg { transform: rotate(-90deg); }
.cat-row.row-collapsed { display: none; }

/* Empty categories (nothing assigned, spent, or available, no target) recede so the
   rows that actually need attention stand out — they light back up on hover. */
.cat-row.is-empty td.col-name .cat-link { color: var(--ink-3); font-weight: 450; }
.cat-row.is-empty .assign-input { color: var(--ink-4); }
.cat-row.is-empty .avail-pill.avail-zero { background: transparent; color: var(--ink-4); }
.cat-row.is-empty:hover td.col-name .cat-link,
.cat-row.is-empty:hover .assign-input { color: var(--ink); }

/* The Assigned cell reads as money (accounting style: $ pinned left, figure right);
   a faint baseline on hover signals it's editable. */
.assign-cur { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; user-select: none; padding-left: 2px; }
.assign-input:hover { box-shadow: inset 0 -1.5px 0 var(--border-2); }
.assign-input:focus { box-shadow: var(--focus-ring); }
.cat-row.is-empty .assign-cur { color: var(--ink-4); }
.cat-row.is-empty:hover .assign-cur { color: var(--ink-3); }

/* ─── tables ─── */
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--hair); }
.table th.text-right { text-align: right; }
.table td { padding: 12px 18px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }
/* horizontal-scroll wrapper so wide registers never get clipped on small screens */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); scrollbar-gutter: stable; }
.table-scroll > .table { min-width: 700px; }
/* The register (#txn-table, table-layout:fixed — see plot-features.css) carries
   more columns than a plain table. Give it a higher floor so a cramped viewport
   scrolls horizontally instead of collapsing Payee — the sole width-less column,
   which otherwise absorbs the entire deficit and shrinks to nothing. Reset to 0
   in the mobile card layout (plot-features.css). */
.table-scroll > #txn-table { min-width: 860px; }

.clear-toggle { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-2); background: var(--surface); color: var(--ink-4); cursor: pointer; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; transition: all .16s var(--ease); }
.clear-toggle.cleared { background: var(--green-vivid); border-color: var(--green-vivid); color: #fff; animation: pop .3s var(--ease); }
.clear-toggle:hover { border-color: var(--green-vivid); transform: scale(1.1); }
@keyframes pop { 0%{transform:scale(.6)} 60%{transform:scale(1.16)} 100%{transform:scale(1)} }
.payee { font-weight: 510; }
.memo { font-size: 12.5px; color: var(--ink-3); }
.cat-tag { font-size: 12.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }

/* ─── account rows ─── */
.account-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--hair); transition: background .12s; }
.account-row:last-child { border-bottom: none; }
.account-row:hover { background: var(--surface-hover); }
/* Non-navigable rows (invitations, settle balances, split summaries): a plain list
   row, not a link — no pointer cursor, no hover highlight promising a tap target. */
.account-row--static { cursor: default; }
.account-row--static:hover { background: transparent; }
.account-icon { width: 40px; height: 40px; border-radius: 11px; flex: none; display: grid; place-items: center; color: #fff; box-shadow: var(--sh-sm); }
.account-icon svg { width: 20px; height: 20px; }
.acc-checking   { background: linear-gradient(160deg, #3F93FF, #0A84FF); }
.acc-savings    { background: linear-gradient(160deg, #34D158, #248A3D); }
.acc-cash       { background: linear-gradient(160deg, #FFB340, #F56300); }
.acc-credit     { background: linear-gradient(160deg, #7A78F0, #5E5CE6); }
.acc-investment { background: linear-gradient(160deg, #FF7A5A, #E8410F); }
.account-meta { flex: 1; min-width: 0; }
.account-name { font-weight: 590; font-size: 15px; letter-spacing: -0.01em; }
.account-type { font-size: 12.5px; color: var(--ink-3); text-transform: capitalize; }

/* ─── insights ─── */
.insight { display: flex; gap: 14px; padding: 17px 19px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--sh-sm), var(--inset-hi); transition: transform .26s var(--ease), box-shadow .26s; }
.insight:hover { transform: translateY(-2px); box-shadow: var(--sh); }
.insight-icon { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center; }
.insight-icon svg { width: 19px; height: 19px; }
.insight-good .insight-icon { background: var(--green-soft); color: var(--green); }
.insight-info .insight-icon { background: var(--blue-soft); color: var(--blue); }
.insight-warn .insight-icon { background: var(--amber-soft); color: var(--amber); }
.insight-bad  .insight-icon { background: var(--red-soft); color: var(--red); }
.insight-title { font-weight: 600; font-size: 15px; letter-spacing: -0.015em; }
.insight-body { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; line-height: 1.45; }
/* Call-to-action linking an insight to where you act on it (CSS chevron, no glyph). */
.insight-cta { display: inline-flex; align-items: center; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--blue); }
.insight-cta::after { content: ""; width: 5px; height: 5px; margin-left: 6px; border-right: 1.6px solid currentColor; border-top: 1.6px solid currentColor; transform: rotate(45deg); transition: transform .15s var(--ease-out, ease); }
.insight-cta:hover::after { transform: rotate(45deg) translate(1px, -1px); }

/* ─── forms ─── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 510; color: var(--ink-2); }
.input, .select {
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  min-height: var(--control-h);
  padding: 9px 13px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--surface); width: 100%;
  caret-color: var(--blue);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  -webkit-appearance: none; appearance: none;
}
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868B' stroke-width='2.4' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 15px; padding-right: 34px; }
.input:focus, .select:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus-ring); }
/* Checkboxes & radios pick up Plot Blue everywhere (inherits the lifted #5B8BFF in
   dark mode) instead of the OS default accent — see BRAND anti-pattern "generic
   system-default form controls". */
input[type="checkbox"], input[type="radio"] { accent-color: var(--blue); }
.input::placeholder, .select::placeholder, textarea.input::placeholder { color: var(--ink-4); opacity: 1; }
/* meaningful placeholder hints must meet AA — raise above the --ink-4 token without affecting disabled/quaternary fills.
   cmdk-input/rs-search/inline-edit carry a bare-class placeholder rule in plot-features.css (loads later);
   the `input.` qualifier wins on specificity so this AA color applies to them too. */
.input::placeholder, .select::placeholder, textarea.input::placeholder,
input.cmdk-input::placeholder, input.rs-search::placeholder, input.inline-edit::placeholder { color: #767579; opacity: 1; } /* 4.55:1 on white */
html[data-theme="dark"] .input::placeholder, html[data-theme="dark"] .select::placeholder,
html[data-theme="dark"] textarea.input::placeholder, html[data-theme="dark"] input.cmdk-input::placeholder,
html[data-theme="dark"] input.rs-search::placeholder, html[data-theme="dark"] input.inline-edit::placeholder { color: #7E7E87; } /* ~4.6:1 on dark surface */
.input:disabled, .select:disabled, textarea.input:disabled {
  background: var(--surface-2); color: var(--ink-3); cursor: not-allowed;
  border-color: var(--border); -webkit-text-fill-color: var(--ink-3); opacity: 1;
}
.input:-webkit-autofill, .input:-webkit-autofill:hover, .input:-webkit-autofill:focus, .select:-webkit-autofill, .rs-search:-webkit-autofill, .inline-edit:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--blue);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  transition: background-color 600000s 0s, color 600000s 0s;
}
.input:-webkit-autofill:focus, .select:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--surface) inset, var(--focus-ring); }
.input.num { font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.add-row { background: var(--surface-2); box-shadow: inset 0 1px 0 var(--hair), inset 2px 0 0 var(--blue); }
.add-row td:first-child { position: relative; }
.add-row td { padding: 9px 12px; }
.add-row .input, .add-row .select { padding: 8px 10px; font-size: 14px; }

dialog {
  /* the `* { margin:0 }` reset kills the UA's auto-centering — restore it */
  position: fixed; inset: 0; margin: auto;
  border: .5px solid var(--border); padding: 0; border-radius: var(--radius-lg);
  box-shadow: var(--sh-lg); background: var(--surface); color: var(--ink);
  max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  /* animate BOTH open and close via @starting-style + discrete transitions */
  opacity: 0; transform: scale(.95) translateY(10px);
  transition: opacity .26s var(--ease), transform .32s var(--ease),
              overlay .32s var(--ease) allow-discrete, display .32s var(--ease) allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: scale(.95) translateY(10px); } }
dialog::backdrop {
  background: rgba(0,0,0,.30);
  backdrop-filter: saturate(140%) blur(6px); -webkit-backdrop-filter: saturate(140%) blur(6px);
  opacity: 0;
  transition: opacity .32s var(--ease), overlay .32s allow-discrete, display .32s allow-discrete;
}
dialog[open]::backdrop { opacity: 1; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }

/* ─── charts ─── */
/* overflow:visible so the floating chart tooltip (.plot-tip) isn't clipped at the
   box edge. Runaway width is already prevented by min-width:0 on grid children +
   `canvas{max-width:100%}` below, so we don't need to hide overflow for that. */
.chart-box { position: relative; height: 260px; padding: 6px 2px; min-width: 0; max-width: 100%; overflow: visible; }
.chart-box.tall { height: 320px; }
/* Belt-and-braces: never let a chart canvas paint wider than its box. */
.chart-box > canvas { max-width: 100%; }

/* custom floating chart tooltip — frosted, Apple-style */
.plot-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 14px)); pointer-events: none;
  background: rgba(255,255,255,.84);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border: .5px solid var(--border); border-radius: 13px; box-shadow: var(--sh-md);
  padding: 9px 12px; min-width: 122px; z-index: 30; opacity: 0;
  transition: opacity .14s ease, left .09s var(--ease), top .09s var(--ease);
}
.plot-tip-title { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 5px; }
.plot-tip-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.plot-tip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.plot-tip-label { color: var(--ink-2); font-size: 12.5px; flex: 1; white-space: nowrap; }
.plot-tip-val { font-family: var(--font-body); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; color: var(--ink); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; }
.bar-track { height: 8px; border-radius: 980px; background: var(--paper-2); overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 980px; }
.bar-fill.assigned { background: var(--ink-4); }
.bar-fill.spent { background: var(--blue); }
.bva-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--hair); }
.bva-row:last-child { border-bottom: none; }

/* ─── misc ─── */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 52px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink-2); font-size: 16px; font-weight: 600; margin-bottom: 2px; letter-spacing: -0.018em; }
.empty p { max-width: 38ch; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); margin: 0 auto; }
.empty svg { width: 30px; height: 30px; color: var(--ink-4); stroke-width: 1.5; margin-bottom: 8px; }
.empty svg path, .empty svg circle, .empty svg line, .empty svg polyline { vector-effect: non-scaling-stroke; }
td > .empty { margin-inline: auto; max-width: 420px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.row-gap { display: flex; align-items: center; gap: 10px; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-title h2 { font-size: 20px; font-weight: 650; }
.divider { height: 1px; background: var(--hair); margin: 26px 0; }

/* ─── motion: seamless nav + progress + feedback ─── */
#plot-progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 9999; background: var(--blue); box-shadow: 0 0 10px rgba(10,132,255,.6); opacity: 0; transition: width .25s var(--ease), opacity .35s ease; border-radius: 0 3px 3px 0; }
/* Always freeze the root cross-fade so only the .content area transitions — this
   must apply even under reduced-motion (otherwise the whole page still crossfades). */
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
@media (prefers-reduced-motion: no-preference) {
  .content { view-transition-name: plot-content; }
  ::view-transition-group(plot-content) { animation-duration: .4s; }
  ::view-transition-old(plot-content) { animation: vt-out .22s cubic-bezier(.4,0,1,1) both; }
  ::view-transition-new(plot-content) { animation: vt-in .4s var(--ease) both; }
}
@keyframes vt-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes vt-in  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes rowflash { 0% { background: var(--green-soft); } 100% { background: transparent; } }
@keyframes pillpop  { 0%, 28% { transform: scale(1.06); } 100% { transform: scale(1); } }
.cat-row.flash { animation: rowflash 1.1s ease-out; }
.cat-row.flash .avail-pill { animation: pillpop 1.1s var(--ease); }

.account-row { position: relative; }
/* Chevron + value-slide is the "this row opens something" affordance — scope it to
   real links so non-navigable rows (invite/settle/split summaries) don't promise
   navigation that doesn't exist. */
a.account-row::after { content: "›"; position: absolute; right: 16px; color: var(--ink-4); font-size: 19px; opacity: 0; transform: translateX(-5px); transition: all .18s var(--ease); }
a.account-row:hover::after { opacity: 1; transform: translateX(0); }
a.account-row:hover .num, a.account-row:hover .nw-share { transform: translateX(-12px); }
a.account-row .num { transition: transform .18s var(--ease); }

/* A solid 2px ring meets WCAG 1.4.11 (3:1) — the old 12%-alpha blue-soft glow
   did not — and survives forced-colors mode (outlines are preserved there). */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
/* inputs already define their own focus ring + radius; don't double up or reshape */
.input:focus-visible, .select:focus-visible, .assign-input:focus-visible, .cat-select:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Kill the default mobile grey tap flash + long-press callout on our own
   controls — the bespoke :active states already own the press feedback, and the
   grey flash reads distinctly un-Apple. */
a, button, summary, label, [role="button"], .btn, .nav-item, .row-act,
input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, summary, [role="button"], .btn, .nav-item, .row-act, .quick-fab { -webkit-touch-callout: none; }

/* visually-hidden accessible text (screen-reader only); stays in the a11y tree + tab order */
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.sr-only-focusable:focus,.sr-only-focusable:focus-within{position:static!important;width:auto;height:auto;margin:0;overflow:visible;clip:auto;white-space:normal}

/* dark theme already passes for blue text (#5B8BFF = 5.66:1); the dark token block lives in
   plot-features.css, so point --blue-text back to --blue under dark here in this file. */
html[data-theme="dark"] { --blue-text: var(--blue); }

/* In dark mode the lifted accents (--green #34C28C / --red #FF6452 / --coral-2
   #FF8A64) pass on the dark soft tints, so the semantic text tokens point back at
   them — one place, no per-component overrides. Amber keeps its light value. */
html[data-theme="dark"] {
  --green-text: var(--green);
  --red-text: var(--red);
  --coral-text: var(--coral-2);
  --purple-text: #B7B6F5;
  --frost: rgba(20,20,23,0.72);   /* frosted chrome (tab bar, section bar, tooltips) */
}
/* Chart tooltip + month-ahead track hardcoded light values — give them dark ones. */
html[data-theme="dark"] .plot-tip { background: rgba(28,28,32,0.86); border-color: var(--hair); }
html[data-theme="dark"] .ma-bar { background: rgba(255,255,255,0.10); }

/* High-contrast / forced-colors (Windows high-contrast, etc.): frosted
   translucency and 6-8%-alpha hairlines disappear, so the chrome loses its
   structure. Give the key surfaces opaque system fills + visible borders. */
@media (forced-colors: active) {
  .sidebar, .topbar, .plot-tip, .card, dialog { background: Canvas; border: 1px solid CanvasText; }
  .nav-item.active { outline: 1px solid CanvasText; }
  :focus-visible { outline-color: Highlight; }
}
/* No backdrop-filter support: the frost (rgba ~.72) reads as see-through over
   content. Swap the blurred chrome for an opaque token so it stays legible. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sidebar, .topbar, .plot-tip { background: var(--surface); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr; } .span-2 { grid-column: span 1; } }

/* Desktop: the hamburger + backdrop don't exist. */
.menu-toggle { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 860px) {
  .main { margin-left: 0; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
  /* Sidebar becomes an off-canvas drawer reachable via the topbar hamburger. */
  .sidebar {
    display: flex; position: fixed; top: 0; left: 0; bottom: 0; width: 250px;
    transform: translateX(-100%); transition: transform .26s var(--ease, ease), visibility .26s;
    visibility: hidden;   /* keep the drawer's nav links out of the tab order while closed */
    z-index: 80; box-shadow: 0 0 48px rgba(0,0,0,.20);
  }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--hair);
    background: var(--surface); color: var(--ink-2); margin-right: 10px; flex: none; cursor: pointer;
  }
  .menu-toggle svg { width: 20px; height: 20px; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.32);
    opacity: 0; pointer-events: none; transition: opacity .26s ease; z-index: 70;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; touch-action: none; }
  /* the drawer + backdrop are position:fixed, so locking body scroll is safe */
}

@media (max-width: 600px) {
  .notif-panel { width: calc(100vw - 32px); right: -8px; }
  .loan-figs { gap: 12px; }
  .budget-stats.grid-4 { grid-template-columns: 1fr 1fr; }
  .budget-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-gutter: stable; }
  .budget-wrap > .budget-grid { min-width: 560px; }
  .budget-grid thead th, .cat-row td, .group-row td { padding-left: 12px; padding-right: 12px; }
  .budget-grid thead th.col-name, .cat-row td.col-name, .group-row td.col-name { padding-left: 14px; }
}
