/* ==========================================================================
   NidhiIlakku — application stylesheet
   --------------------------------------------------------------------------
   Extracted from the inline <style> in base.html and modernized.

   Design goals:
   - Keep ALL existing variable names (--bg, --card, --accent, …) and class
     names (.card, .btn, .flash, …) so existing templates render
     unchanged. Inline styles in templates still win where present.
   - Add a proper token layer: spacing scale, type scale, radius, shadows,
     motion — so future styling stops using arbitrary pixel values.
   - Add reusable component classes for the patterns repeated inline across
     the dashboard (.metric, .progress, .chip, .stack) so templates
     can be de-duplicated incrementally without a big-bang rewrite.
   ========================================================================== */

/* ---- Fonts (UI-10B.0): self-hosted, OFL-1.1, see static/fonts/README.md ----
   No external font host. Inter covers UI + figures (₹ lives in latin-ext, which
   the browser fetches only when such a glyph is on the page). Fraunces is used
   for <h1> page titles only. font-display: swap → text is never invisible. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ==========================================================================
   UI-10B.0 DESIGN TOKENS  (spec: docs/UI10_PREMIUM_VISUAL_DESIGN.md §5)
   --------------------------------------------------------------------------
   Layer 1 — SEMANTIC tokens (--color-*, --text-*, --space-*, --radius-*,
             --shadow-*, --dur-*, --h-*, --w-*, --font-*). Defined once per
             theme; these are the only values new code should reference.
   Layer 2 — LEGACY ALIASES (--bg, --card, --accent, --ok, --warn, --fs-*, …).
             Every pre-UI-10 name is kept and re-pointed at Layer 1 with var(),
             so the ~1,900 inline var(--…) references in templates re-theme
             without template edits. Aliases hold NO literal colour values —
             there is exactly one source of truth per colour. Aliases with no remaining
             user were removed in B.11 (the ones still listed below are in use).
   Default (no data-theme attribute) = DARK "Midnight & Emerald".
   html[data-theme="light"] = LIGHT "Ivory & Forest".
   All text/background pairs are WCAG-AA verified (tests/test_ui10_foundation.py).
   ========================================================================== */
:root {
  color-scheme: dark;

  /* ---- colour: surfaces ------------------------------------------------- */
  --color-bg: #0B1220;
  --color-bg-sunken: #080E1A;
  --color-surface-1: #111A2B;
  --color-surface-2: #162133;
  --color-surface-3: #1D2A40;
  /* ---- colour: lines ---------------------------------------------------- */
  --color-border: #26344D;           /* decorative hairline */
  --color-border-strong: #3A4C6B;
  --color-border-control: #5B6D8C;   /* form-control boundary, >=3:1 */
  --color-divider: #1B2638;
  /* ---- colour: text ----------------------------------------------------- */
  --color-text: #E7ECF3;
  --color-text-2: #C2CCDA;
  --color-text-muted: #97A4B8;
  --color-text-faint: #717E93;       /* placeholder / disabled / decorative only */
  /* ---- colour: brand ---------------------------------------------------- */
  --color-brand: #45B98E;
  --color-brand-strong: #5CCB9F;
  --color-brand-weak: rgba(69, 185, 142, 0.14);
  --color-on-brand: #06140F;
  --color-brass: #CFAE6A;            /* target markers only — never a status */
  --color-brass-weak: rgba(207, 174, 106, 0.14);
  /* ---- colour: semantic status ------------------------------------------ */
  --color-positive: #55C796;
  --color-positive-weak: rgba(85, 199, 150, 0.14);
  --color-negative: #F2826F;
  --color-negative-weak: rgba(242, 130, 111, 0.14);
  --color-warning: #E3AE52;
  --color-warning-weak: rgba(227, 174, 82, 0.14);
  --color-info: #7DB1E0;
  --color-info-weak: rgba(125, 177, 224, 0.14);
  --color-neutral: #8794A8;
  --color-neutral-weak: rgba(135, 148, 168, 0.14);
  /* ---- colour: status surfaces (banners) -------------------------------- */
  --color-positive-surface: rgba(85, 199, 150, 0.10);
  --color-positive-border: rgba(85, 199, 150, 0.32);
  --color-positive-text: #BDEBD5;
  --color-negative-surface: rgba(242, 130, 111, 0.10);
  --color-negative-border: rgba(242, 130, 111, 0.34);
  --color-negative-text: #FFD0C6;
  --color-warning-surface: rgba(227, 174, 82, 0.10);
  --color-warning-border: rgba(227, 174, 82, 0.34);
  --color-warning-text: #F5DDAF;
  --color-info-surface: rgba(125, 177, 224, 0.10);
  --color-info-border: rgba(125, 177, 224, 0.32);
  --color-info-text: #CFE3F5;
  /* ---- colour: chart series (>=3:1 vs surface-1) ----------------------- */
  --color-series-1: #45B98E;   /* emerald */
  --color-series-2: #86BCA2;   /* sage    */
  --color-series-3: #CFAE6A;   /* brass   */
  --color-series-4: #7A9CC8;   /* steel   */
  --color-series-5: #D9937A;   /* clay    */
  --color-series-6: #B096BC;   /* mauve   */
  /* ---- colour: interaction --------------------------------------------- */
  --color-focus: #5CCB9F;
  --color-focus-halo: rgba(92, 203, 159, 0.30);
  --color-scrim: rgba(3, 6, 12, 0.62);
  --color-glow: rgba(69, 185, 142, 0.06);

  /* ---- elevation (dark: surfaces + borders carry depth) ---------------- */
  --shadow-1: none;
  --shadow-2: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 24px 48px rgba(0, 0, 0, 0.55);

  /* ---- typography (theme-independent) ---------------------------------- */
  --font-sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino,
    Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --text-display: 2.75rem;     /* 44 */
  --text-display-sm: 2.25rem;  /* 36 */
  --text-h1: 1.875rem;         /* 30 */
  --text-h2: 1.375rem;         /* 22 */
  --text-h3: 1.125rem;         /* 18 */
  --text-metric: 1.625rem;     /* 26 */
  --text-metric-sm: 1.25rem;   /* 20 */
  --text-body-lg: 1.0625rem;   /* 17 */
  --text-body: 0.9375rem;      /* 15 */
  --text-small: 0.8125rem;     /* 13 */
  --text-caption: 0.75rem;     /* 12 — absolute minimum */
  --leading-tight: 1.15;
  --leading-heading: 1.25;
  --leading-body: 1.55;

  /* ---- spacing (4px base; --space-1..6 values unchanged from pre-UI-10) - */
  --space-0: 0;
  --space-0-5: 2px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --space-8: 48px;
  --space-9: 64px;
  --space-10: 80px;

  /* ---- radius ---------------------------------------------------------- */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* ---- motion ---------------------------------------------------------- */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 260ms;

  /* ---- component sizing ------------------------------------------------ */
  --h-control-sm: 32px;
  --h-control: 40px;
  --h-control-lg: 48px;
  --h-nav-item: 40px;
  --h-topbar: 56px;
  --w-content-max: 1320px;
  --w-form-max: 560px;
  --w-auth: 420px;

  /* ======================= LEGACY ALIASES ================================
     Pre-UI-10 names → semantic tokens. var() only, no literal values. */
  --card: var(--color-surface-1);
  --card2: var(--color-surface-2);
  --border: var(--color-border);
  --text: var(--color-text);
  --muted: var(--color-text-muted);
  --accent: var(--color-brand);
  --ok: var(--color-positive);
  --warn: var(--color-negative);          /* --warn has always meant negative */
  --info: var(--color-info);
  --neutral: var(--color-neutral);
  --shadow-sm: var(--shadow-1);
  --ring: 0 0 0 3px var(--color-focus-halo);
  --t-fast: var(--dur-fast) ease;
  --t: var(--dur) ease;
  /* legacy type scale: same names, readable floor (min 12px). xl/2xl keep
     their pre-UI-10 sizes so existing metric/hero rows don't overflow before
     their page migrations; the larger display sizes arrive with those pages. */
  --fs-xs: var(--text-caption);   /* 11 → 12 */
  --fs-sm: var(--text-small);     /* 12 → 13 */
  --fs-base: var(--text-body);    /* 14 → 15 */
  --fs-md: var(--text-h3);        /* 16 → 18 */
  --fs-lg: var(--text-h2);        /* 20 → 22 */
  --fs-xl: var(--text-metric);    /* 26 → 26 */
  --fs-2xl: 2rem;                 /* 32 → 32 (hero metric; display sizes in B.4) */
}

/* ==========================================================================
   LIGHT THEME — "Ivory & Forest". Only colour + elevation differ; aliases
   above resolve through var() so they follow automatically.
   ========================================================================== */
html[data-theme="light"] {
  color-scheme: light;

  --color-bg: #F7F3EA;
  --color-bg-sunken: #EFE9DC;
  --color-surface-1: #FFFDF8;
  --color-surface-2: #F3EEE3;
  --color-surface-3: #EAE3D4;
  --color-border: #DED5C3;
  --color-border-strong: #B9AD95;
  --color-border-control: #8C8069;
  --color-divider: #ECE5D8;
  --color-text: #1C2722;
  --color-text-2: #3B4943;
  --color-text-muted: #5A665F;
  --color-text-faint: #7A847D;
  --color-brand: #1F5D45;
  --color-brand-strong: #174A37;
  --color-brand-weak: rgba(31, 93, 69, 0.10);
  --color-on-brand: #FFFFFF;
  --color-brass: #8A6A2E;
  --color-brass-weak: rgba(138, 106, 46, 0.12);
  --color-positive: #1D7349;
  --color-positive-weak: rgba(29, 115, 73, 0.10);
  --color-negative: #B03F2B;
  --color-negative-weak: rgba(176, 63, 43, 0.10);
  --color-warning: #8F5A0B;
  --color-warning-weak: rgba(143, 90, 11, 0.10);
  --color-info: #2A6289;
  --color-info-weak: rgba(42, 98, 137, 0.10);
  --color-neutral: #5C655F;
  --color-neutral-weak: rgba(92, 101, 95, 0.12);
  --color-positive-surface: #EAF3EC;
  --color-positive-border: #B9D8C4;
  --color-positive-text: #145238;
  --color-negative-surface: #F8E9E4;
  --color-negative-border: #E5C1B6;
  --color-negative-text: #7E2A1B;
  --color-warning-surface: #F7EEDC;
  --color-warning-border: #E2CFA3;
  --color-warning-text: #6B4306;
  --color-info-surface: #E8F0F5;
  --color-info-border: #BCD2E1;
  --color-info-text: #1E4A69;
  --color-series-1: #1F5D45;   /* forest */
  --color-series-2: #5E8F77;   /* sage   */
  --color-series-3: #A07D3A;   /* brass  */
  --color-series-4: #4A6A8C;   /* slate  */
  --color-series-5: #B06A4E;   /* clay   */
  --color-series-6: #7A5A80;   /* plum   */
  --color-focus: #1F5D45;
  --color-focus-halo: rgba(31, 93, 69, 0.28);
  --color-scrim: rgba(28, 39, 34, 0.45);
  --color-glow: rgba(31, 93, 69, 0.045);

  --shadow-1: 0 1px 2px rgba(42, 36, 24, 0.05), 0 1px 1px rgba(42, 36, 24, 0.03);
  --shadow-2: 0 4px 14px rgba(42, 36, 24, 0.07), 0 1px 3px rgba(42, 36, 24, 0.05);
  --shadow-3: 0 18px 40px rgba(42, 36, 24, 0.14), 0 4px 10px rgba(42, 36, 24, 0.06);
}

/* ==========================================================================
   Base elements (ported verbatim from base.html, with light modernization)
   ========================================================================== */
* {
  box-sizing: border-box;
}

/* UI-10B.0: 16px root (rem base) — the body text token is 15px, up from 14. */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  /* subtle depth: a faint radial lift behind the content */
  background-image: radial-gradient(
    1200px 600px at 50% -10%,
    var(--color-glow),
    transparent 60%
  );
  background-attachment: fixed;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--color-brand-weak);
  color: var(--color-text);
}

/* All financial figures line up by default (tabular + lining numerals). */
td,
th,
.num,
.money,
.metric__value {
  font-variant-numeric: tabular-nums lining-nums;
}
/* .money — opt-in class for any rupee figure outside a table/metric. */
.money {
  font-weight: 600;
  white-space: nowrap;
}

a {
  color: var(--color-brand);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color var(--t-fast);
}
a:hover {
  color: var(--color-brand-strong);
  text-decoration: underline;
}

/* Headings — UI-10 type scale. Page titles use the display serif; section and
   card titles stay in Inter. Inline font-size overrides in templates still win
   until each page is migrated (B.4+). */
h1,
h2,
h3 {
  color: var(--color-text);
  line-height: var(--leading-heading);
}
h1 {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: 500;
  letter-spacing: -0.01em;
}
h2 {
  font-size: var(--text-h2);
  font-weight: 600;
  letter-spacing: -0.01em;
}
h3 {
  font-size: var(--text-h3);
  font-weight: 600;
}

code,
pre,
kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ---- Layout ------------------------------------------------------------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}

/* ---- Card --------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
/* interactive cards (links styled as cards) lift slightly on hover */
a.card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

/* ---- Forms -------------------------------------------------------------- */
label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--muted);
  margin: 10px 0 4px;
}
input,
select,
textarea {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--color-border-control);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: var(--fs-base);
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: var(--ring);
}

/* Accessibility (Phase 4E): a clear, consistent keyboard focus ring on every
   interactive element — never relies on colour alone, works in both themes. */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- Buttons ------------------------------------------------------------ */
button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--color-on-brand);
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: var(--fs-base);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast),
    box-shadow var(--t-fast);
}
button:hover,
.btn:hover {
  background: var(--color-brand-strong);
  box-shadow: var(--shadow-sm);
}
button:active,
.btn:active {
  transform: translateY(1px);
}

/* ---- Flash messages ----------------------------------------------------- */
.flash {
  padding: 10px 14px;
  border-radius: 9px;
  margin-bottom: var(--space-3);
  font-size: var(--fs-base);
}
.flash.success {
  background: var(--color-positive-surface);
  border: 1px solid var(--color-positive-border);
  color: var(--color-positive-text);
}
.flash.danger {
  background: var(--color-negative-surface);
  border: 1px solid var(--color-negative-border);
  color: var(--color-negative-text);
}
.flash.info {
  background: var(--color-info-surface);
  border: 1px solid var(--color-info-border);
  color: var(--color-info-text);
}

/* ---- Auth box ----------------------------------------------------------- */

.muted {
  color: var(--muted);
}

/* ==========================================================================
   New reusable components — opt-in, mirror patterns repeated inline today.
   Templates can migrate to these incrementally; nothing requires them yet.
   ========================================================================== */

/* Two-column layout used by the dashboard (replaces inline grid). */

/* Vertical stack helper. */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Metric block: label + big tabular number (+ optional delta chip). */
.metric__label {
  font-size: var(--fs-sm);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.metric__value {
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.1;
}
.metric__value--ok {
  color: var(--ok);
}
.metric__value--warn {
  color: var(--warn);
}
.metric__value--accent {
  color: var(--accent);
}

/* Status chip / pill. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--card2);
  color: var(--muted);
}
.chip--ok {
  background: var(--color-positive-weak);
  color: var(--ok);
}
.chip--warn {
  background: var(--color-negative-weak);
  color: var(--warn);
}
.chip--accent {
  background: var(--color-brand-weak);
  color: var(--accent);
}

/* Progress bar — the pattern used for budget pace / emergency fund / SIP gap.
   Usage:
     <div class="progress"><span style="width:62%"></span></div>
   Add --warn / --ok modifiers for the fill colour. */
.progress {
  height: 10px;
  background: var(--card2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--t);
}

/* Inset panel (the card2 sub-boxes used throughout the dashboard). */
.panel {
  background: var(--card2);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}

/* Data table defaults (so future tables don't re-declare border/pad inline). */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table td,
.table th {
  padding: 6px 4px;
}
.table tr + tr td {
  border-top: 1px solid var(--border);
}
.table .r {
  text-align: right;
}

/* Header-style tables: a <thead> with a bottom rule, muted uppercase labels.
   Add class="table table--head" when the table has a <thead>. This variant
   drops the auto between-row top-borders (so they don't double up with a
   header rule or per-row bottom borders a template may still set). */
.table thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}
.table thead th.r {
  text-align: right;
}
.table--head tr + tr td {
  border-top: none;
}
/* Emphasised totals/summary row. */
.table .table__total td {
  border-top: 2px solid var(--border);
  font-weight: 700;
}

/* ==========================================================================
   Responsive — the dashboard's two-up grid must stack on phones
   (run.py explicitly markets phone access on the LAN).
   ========================================================================== */
@media (max-width: 720px) {
  .wrap {
    padding: var(--space-4) var(--space-3);
  }
  
  
  
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ==========================================================================
   App shell (UI-10B.2) — skip link, wordmark, sidebar / icon rail / drawer,
   top app bar, theme control, main landmark. Tokens only; no hard-coded
   colours.  Breakpoints (spec §5.6 / §11.1):
     >=1280  full sidebar (248px)           1024-1279  72px icon rail
     <1024   56px top bar + focus-trapped drawer
   ========================================================================== */
:root {
  --sidebar-w: 248px;
  --rail-w: 72px;
  --topbar-h: 56px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Skip link ---------------------------------------------------------- */
.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--color-brand);
  color: var(--color-on-brand);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
  color: var(--color-on-brand);
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
main:focus { outline: none; }

/* ---- Wordmark ----------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  color: var(--color-text);
  font-weight: 650;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--color-text); }
.brand__mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-brand);
  color: var(--color-on-brand);
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ------------------------------------------------------------ */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--color-bg-sunken);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 60;
}
html[data-theme="light"] .sidebar { border-right-color: transparent; }

.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 64px;
  height: 64px;
  padding: 0 var(--space-4);
}
.sidebar__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  padding: 0;
  cursor: pointer;
  box-shadow: none;
  border-radius: var(--radius-sm);
}
.sidebar__close:hover { background: var(--color-surface-3); color: var(--color-text); }
.sidebar__close svg, .app-topbar__menu svg { width: 20px; height: 20px; }

.sidebar__nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__group {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: var(--space-4) var(--space-3) var(--space-1);
}
.sidebar__group:first-child { padding-top: var(--space-1); }
.sidebar__nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-2);
  font-size: var(--fs-base);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar__nav a i,
.sidebar__nav a svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  stroke-width: 1.75;
}
.sidebar__nav a:hover { background: var(--color-surface-3); color: var(--color-text); text-decoration: none; }
.sidebar__nav a:focus-visible,
.sidebar__foot a:focus-visible,
.sidebar__foot button:focus-visible { outline-offset: -2px; }
.sidebar__nav a[aria-current="page"],
.sidebar__nav a.is-active {
  background: var(--color-brand-weak);
  color: var(--color-brand-strong);
  font-weight: 600;
}
.sidebar__nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset-block: 8px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--color-brand);
}

/* ---- Sidebar footer: user, theme control, logout ------------------------ */
.sidebar__foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--color-border);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--fs-sm);
}
html[data-theme="light"] .sidebar__foot { border-top-color: var(--color-divider); }
.sidebar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}
.sidebar__row .sidebar__user { flex: 1 1 auto; min-width: 0; }
.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  color: var(--color-text);
  font-weight: 500;
}
.sidebar__avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-brand-weak);
  color: var(--color-brand-strong);
  font-weight: 650;
  font-size: var(--fs-sm);
}
.sidebar__username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__logout {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-brand-strong);
  font-weight: 600;
  text-decoration: none;
}
.sidebar__logout:hover { background: var(--color-surface-3); text-decoration: none; }
.sidebar__logout svg, .sidebar__logout i { width: 18px; height: 18px; flex: 0 0 18px; }

/* Theme segmented control (System / Light / Dark). #themeToggle is the group. */
.theme-seg {
  display: flex;
  min-width: 0;
  gap: 2px;
  padding: 3px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.theme-seg__opt {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 36px;
  padding: 0 4px;
  background: transparent;
  color: var(--color-text-2);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
}
.theme-seg__opt:hover { background: var(--color-surface-3); color: var(--color-text); }
.theme-seg__opt[aria-checked="true"] {
  background: var(--color-surface-1);
  color: var(--color-text);
  font-weight: 600;
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-1);
}
.theme-seg__opt svg, .theme-seg__opt i { width: 14px; height: 14px; flex: 0 0 14px; }
.theme-seg__opt:focus-visible { outline-offset: 1px; }

/* Rail expand/collapse toggle — only offered in the 1024–1279 rail tier. */
.rail-toggle {
  display: none;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-3);
  background: transparent;
  color: var(--color-text-2);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
}
.rail-toggle:hover { background: var(--color-surface-3); color: var(--color-text); }
.rail-toggle svg, .rail-toggle i { width: 18px; height: 18px; flex: 0 0 18px; }

.sidebar__scrim { display: none; }

/* Rail tooltip (single element, positioned by JS in rail mode only). */
.nav-tip {
  position: fixed;
  z-index: 90;
  padding: 6px 10px;
  background: var(--color-surface-1);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}
.nav-tip[hidden] { display: none; }

/* ---- Main column -------------------------------------------------------- */
.app-main {
  flex: 1 1 auto;
  min-width: 0; /* allow children (tables/charts) to shrink, not overflow */
}
.app-topbar {
  display: flex; /* V2-C: global header bar visible at ALL widths so the privacy
                    control is always discoverable (menu + brand are mobile-only). */
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  background: var(--color-surface-1);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-topbar__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-inline-start: calc(var(--space-2) * -1);
  background: transparent;
  color: var(--color-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  box-shadow: none;
}
.app-topbar__menu:hover { background: var(--color-surface-3); }
.app-topbar .brand__mark { flex-basis: 28px; width: 28px; height: 28px; font-size: 15px; }
.app-topbar__title {
  margin-inline-start: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}

/* Content: centred, capped at 1320px, padding steps down with the breakpoint. */
.app-main .wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-8);
}
@media (max-width: 1279.98px) {
  .app-main .wrap { padding: var(--space-6) var(--space-6); }
}

/* ---- Rail (1024–1279): icon-only unless the user expanded it ------------ */
@media (min-width: 1024px) and (max-width: 1279.98px) {
  .rail-toggle { display: inline-flex; }
  html:not([data-nav="expanded"]) .sidebar {
    width: var(--rail-w);
    flex-basis: var(--rail-w);
  }
  html:not([data-nav="expanded"]) .sidebar__brand { justify-content: center; padding: 0; }
  html:not([data-nav="expanded"]) .sidebar .brand__text,
  html:not([data-nav="expanded"]) .sidebar .nav-label,
  html:not([data-nav="expanded"]) .sidebar .sidebar__username,
  html:not([data-nav="expanded"]) .sidebar .theme-seg__text,
  html:not([data-nav="expanded"]) .sidebar .rail-toggle__text {
    position: absolute !important;
    width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  html:not([data-nav="expanded"]) .sidebar__group {
    height: 1px;
    margin: var(--space-3) var(--space-3);
    padding: 0;
    overflow: hidden;
    font-size: 0;
    background: var(--color-divider);
  }
  html:not([data-nav="expanded"]) .sidebar__group:first-child { display: none; }
  html:not([data-nav="expanded"]) .sidebar__nav { padding-inline: var(--space-2); }
  html:not([data-nav="expanded"]) .sidebar__nav a,
  html:not([data-nav="expanded"]) .sidebar__logout,
  html:not([data-nav="expanded"]) .rail-toggle { justify-content: center; padding: 0; }
  html:not([data-nav="expanded"]) .sidebar__foot { padding-inline: var(--space-2); align-items: center; }
  html:not([data-nav="expanded"]) .sidebar__user { justify-content: center; }
  html:not([data-nav="expanded"]) .sidebar__row { flex-direction: column; }
  html:not([data-nav="expanded"]) .theme-seg { flex-direction: column; width: 100%; }
  html:not([data-nav="expanded"]) .theme-seg__opt { padding: 0; }
}

/* ---- <1024: top bar + drawer -------------------------------------------- */
@media (max-width: 1023.98px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 86vw);
    height: auto;
    transform: translateX(-100%);
    visibility: hidden;                 /* closed drawer is not tabbable */
    transition: transform var(--t), visibility 0s linear var(--dur);
    box-shadow: var(--shadow-3);
    border-right: 1px solid var(--color-border);
  }
  .sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform var(--t), visibility 0s;
  }
  .sidebar__close { display: inline-flex; }
  .sidebar__scrim.is-open {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--color-scrim);
    z-index: 55;
  }
  .app-topbar { display: flex; }
  .app-main .wrap { padding: var(--space-5) var(--space-5); }
}
@media (max-width: 767.98px) {
  .app-main .wrap { padding: var(--space-4) var(--space-4); }
}

/* ==========================================================================
   UI-1 — Design-system finalisation (ADDITIVE ONLY)
   --------------------------------------------------------------------------
   Everything below is new and opt-in. No existing token or class above was
   renamed or removed. Templates are NOT changed in UI-1; these utilities are
   available for the later page-migration phases to adopt.

   TYPOGRAPHY ROLES (use the existing --fs-* scale; no new sizes):
     Page title       -> --fs-xl  (h1)        700
     Section title    -> --fs-md  (h2)        600
     Card title       -> --fs-md               600
     Primary metric   -> --fs-xl  (.metric__value)
     Secondary metric -> --fs-lg
     Body text        -> --fs-base
     Supporting text  -> --fs-sm   (.muted)
     Labels           -> --fs-sm   (.metric__label, label)
     Table headers    -> --fs-xs   (uppercase, .table thead th)
     Small metadata   -> --fs-xs
   Secondary/supporting text uses --muted, which is tuned for AA-comfortable
   contrast in both themes; do not drop it below --fs-sm.

   SPACING ROLES (use the existing --space-* scale; no new values):
     Page gutters      -> --space-4 / --space-6 (shell .wrap already applies)
     Section spacing   -> --space-5
     Card padding      -> --space-4 (standard) / --space-3 (compact)
     Card-to-card gap  -> --space-4 (.card margin-bottom already applies)
     Compact data rows -> --space-2 vertical
     Table cell pad    -> 6px (.table already applies)
     Form spacing      -> label margins already apply
   ========================================================================== */

/* ---- Card variants (formalise existing patterns; .card is unchanged) ----- */
/* Metric card: a card whose primary content is one headline figure. Purely a
   layout hint (stack the metric block); no decoration. */
.card--metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
/* Inset panel already exists as .panel; alias for naming consistency. */
.card--inset {
  background: var(--card2);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}

/* ---- Status/semantic utilities (extend, never replace) ------------------- */
/* New metric-value status colours alongside the existing --ok/--warn/--accent. */
.metric__value--info {
  color: var(--info);
}
.metric__value--muted {
  color: var(--muted);
}
/* New chip variants alongside existing --ok/--warn/--accent chips. */
.chip--info {
  background: var(--color-info-weak);
  color: var(--info);
}
.chip--neutral {
  background: var(--color-neutral-weak);
  color: var(--neutral);
}
/* A status dot that pairs with a text label so status is NEVER colour-only.
   Usage: <span class="status"><span class="status__dot status__dot--ok"></span>
          Healthy</span> */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: var(--neutral);
}
.status__dot--ok {
  background: var(--ok);
}
.status__dot--warn {
  background: var(--warn);
}
.status__dot--info {
  background: var(--info);
}
.status__dot--neutral {
  background: var(--neutral);
}

/* ---- Disabled-state clarity (accessibility) ------------------------------ */
button:disabled,
.btn:disabled,
button[disabled],
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* (The former 861–1024px tablet gutter tier was superseded by the UI-10B.2
   shell breakpoints above: padding now steps 48 → 32 → 24 → 16px.) */

/* ==========================================================================
   UI-3B — narrowly-scoped layout utilities for the dashboard / plan command
   centre. Additive only; no existing rule changed.
   ========================================================================== */

/* KPI row children flex to equal-ish widths and wrap cleanly on narrow screens
   (replaces repeated inline flex:1;min-width on metric cards). */
.kpi-row > .card,
.kpi-row > .card--inset {
  flex: 1 1 160px;
  min-width: 150px;
  margin-bottom: 0;
}

/* Responsive: on phones KPI children go full width for readability. */
@media (max-width: 560px) {
  .kpi-row > .card,
  .kpi-row > .card--inset {
    flex: 1 1 100%;
  }
}

/* ==========================================================================
   Component library (UI-10B.3) — spec §7 / §13.3
   --------------------------------------------------------------------------
   Additive and opt-in: nothing here restyles an element that existing pages
   use without one of the new class names, so unmigrated pages render as before
   (the one exception is stated where it applies: .chip base size).
   Tokens only — no hard-coded colours. Works in both themes because every
   colour is a semantic token that html[data-theme="light"] re-points.
   Interactive behaviour lives in templates/base.html (tabs, dialog, menu,
   info-tip); every component degrades to a usable static form without JS.
   ========================================================================== */

/* ---- Component tokens (spec §5.5 spacing roles + hero surface) ----------- */
:root {
  --gap-inline: var(--space-2);
  --gap-stack: var(--space-3);
  --gap-card: var(--space-5);
  --gap-section: clamp(var(--space-6), calc((100vw - 767.98px) * 1000), var(--space-8));
  /* 24px >=768px, 16px below. A clamp() step (not a media-query redefinition) keeps
     each token defined exactly once; the 0.02px ramp at 768px is imperceptible. */
  --pad-card: clamp(var(--space-4), calc((100vw - 767.98px) * 1000), var(--space-5));
  --pad-card-compact: var(--space-4);
  --color-hero:
    radial-gradient(800px 300px at 15% 0%, var(--color-brand-weak), transparent 70%),
    linear-gradient(180deg, var(--color-surface-2) 0%, var(--color-bg) 100%);
}
html[data-theme="light"] {
  --color-hero: linear-gradient(180deg, var(--color-surface-2) 0%, var(--color-bg) 100%);
}

/* ---- Utilities used by the components ------------------------------------ */
.num, .money { font-variant-numeric: tabular-nums lining-nums; }
.num { text-align: right; }
.text-small { font-size: var(--text-small); }
.text-caption { font-size: var(--text-caption); }

/* ---- 7.1 Page header ------------------------------------------------------ */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  margin: 0 0 var(--space-6);
}
.page-head__main { flex: 1 1 320px; min-width: 0; }
.page-head__eyebrow {
  margin: 0 0 var(--space-1);
  color: var(--color-brass);
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-head__title { margin: 0; }
.page-head__sub {
  margin: var(--space-2) 0 0;
  max-width: 72ch;
  color: var(--color-text-muted);
  font-size: var(--text-body);
}
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
@media (max-width: 767.98px) {
  .page-head__actions { flex: 1 1 100%; }
  .page-head__actions > * { flex: 1 1 auto; justify-content: center; }
}
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
  color: var(--color-text-muted);
  font-size: var(--text-caption);
}
.breadcrumb li + li::before { content: "/"; margin-inline-end: var(--space-2); color: var(--color-text-faint); }
.breadcrumb a { color: var(--color-text-muted); text-decoration: underline; text-underline-offset: 2px; }
.breadcrumb a:hover { color: var(--color-text); }
.breadcrumb [aria-current="page"] { color: var(--color-text); }

/* ---- 7.2 Hero summary (one per page at most) ------------------------------ */
.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  align-items: center;
  gap: var(--space-5) var(--space-6);
  padding: calc(var(--pad-card) * 1.5);
  background: var(--color-hero);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}
html[data-theme="light"] .hero { border-color: transparent; }
/* Light brass is 4.34:1 on the hero's surface-2 start (spec §12 restricts it to decorative/large use), so the 12px eyebrow uses the AA-safe warning text token in light. */
html[data-theme="light"] .hero__eyebrow { color: var(--color-warning-text); }
.hero__eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--color-brass);
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hero__value {
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-display-sm);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums lining-nums;
  overflow-wrap: anywhere;
}
@media (min-width: 1024px) { .hero__value { font-size: var(--text-display); } }
.hero__delta { margin-top: var(--space-3); }
.hero__meta { margin: var(--space-2) 0 0; color: var(--color-text-muted); font-size: var(--text-caption); }
.hero__chart { min-width: 0; min-height: 64px; }

/* ---- 7.3 Metric card (evolves the metric_card macro) ---------------------- */
.metric-card { position: relative; }
/* 12px = the size the macro's former inline style rendered. The spec's 13px (text-small) lands with the Dashboard recomposition (B.4) so B.3 does not shift unmigrated pages. */
.metric__supporting { color: var(--color-text-muted); font-size: var(--fs-xs); }
.metric-card--quiet { background: transparent; border-color: transparent; box-shadow: none; }
.metric-card--status-positive { box-shadow: inset 3px 0 0 var(--color-positive); }
.metric-card--status-negative { box-shadow: inset 3px 0 0 var(--color-negative); }
.metric-card--status-warning { box-shadow: inset 3px 0 0 var(--color-warning); }
.metric-card--status-info { box-shadow: inset 3px 0 0 var(--color-info); }
.metric-card--status-positive .metric__value { color: var(--color-positive); }
.metric-card--status-negative .metric__value { color: var(--color-negative); }
.metric-card--status-warning .metric__value { color: var(--color-warning); }
.metric-card--status-info .metric__value { color: var(--color-info); }
a.metric-card {
  display: block;
  color: inherit;
  text-decoration: none;
}
a.metric-card:hover { background: var(--color-surface-3); box-shadow: var(--shadow-2); transform: none; text-decoration: none; }
a.metric-card:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; box-shadow: var(--ring); }
.metric-card__chevron { position: absolute; top: var(--space-4); inset-inline-end: var(--space-4); width: 16px; height: 16px; color: var(--color-text-muted); }
.metric-card__chevron svg, .metric-card__chevron i { width: 16px; height: 16px; }
.metric-card--unavailable .metric__value { color: var(--color-text-muted); font-weight: 500; }
.metric-card--loading .metric__value {
  width: 8ch; height: 1.2em; color: transparent; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-surface-3) 50%, var(--color-surface-2) 75%);
  background-size: 200% 100%;
  animation: nidhi-shimmer 1.4s linear infinite;
}
.delta { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-small); font-weight: 600; font-variant-numeric: tabular-nums; }
.delta svg, .delta i { width: 14px; height: 14px; flex: 0 0 14px; }
.delta--up { color: var(--color-positive); }
.delta--down { color: var(--color-negative); }
.delta--flat { color: var(--color-text-muted); }

/* ---- 7.4 Stat group -------------------------------------------------------- */
.stat-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--gap-card); }
.stat { min-width: 0; }
.stat__label { color: var(--color-text-muted); font-size: var(--text-caption); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.stat__value { margin-top: var(--space-1); color: var(--color-text); font-size: var(--text-metric-sm); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums lining-nums; overflow-wrap: anywhere; }
.stat__hint { margin-top: var(--space-1); color: var(--color-text-muted); font-size: var(--text-small); }
.stat--positive .stat__value { color: var(--color-positive); }
.stat--negative .stat__value { color: var(--color-negative); }
.stat--warning .stat__value { color: var(--color-warning); }
.stat--info .stat__value { color: var(--color-info); }
.stat--unavailable .stat__value { color: var(--color-text-muted); font-weight: 500; }
/* Vertical dividers suit a single row (>=lg). Wrapped rows drop them via the
   modifier, so a divider never appears at the start of a second row. */
@media (min-width: 1024px) {
  .stat-group--divided > .stat + .stat { padding-inline-start: var(--gap-card); border-inline-start: 1px solid var(--color-divider); }
}

/* ---- 7.5 Section ----------------------------------------------------------- */
.section { margin-top: var(--gap-section); }
.section:first-child { margin-top: 0; }
.section__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); }
.section__head h2, .section__title { margin: 0; }
.section__hint { color: var(--color-text-muted); font-size: var(--text-small); }
.section__action { font-size: var(--text-small); font-weight: 600; }
.section--ruled { padding-top: var(--space-5); border-top: 1px solid var(--color-divider); }

/* ---- 7.6 Card variants ----------------------------------------------------- */
.card--flush { padding: 0; overflow: hidden; }
.card--interactive { cursor: pointer; }
.card--interactive:hover { background: var(--color-surface-3); box-shadow: var(--shadow-2); }
.card--interactive:focus-visible, .card--interactive:focus-within { box-shadow: var(--ring); }

/* ---- 7.7 Progress indicators ----------------------------------------------- */
.meter {
  position: relative;
  height: 8px;
  background: var(--color-surface-3);
  border-radius: var(--radius-pill);
}
.meter--sm { height: 6px; }
.meter--lg { height: 12px; }
.meter__fill {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  max-width: 100%;
  background: var(--color-brand);
  border-radius: inherit;
  transition: width var(--t);
}
.meter--positive .meter__fill { background: var(--color-positive); }
.meter--warning .meter__fill { background: var(--color-warning); }
.meter--negative .meter__fill { background: var(--color-negative); }
.meter--info .meter__fill { background: var(--color-info); }
.meter__target {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: var(--target, 100%);
  width: 2px;
  margin-left: -1px;
  background: var(--color-brass);
  border-radius: 1px;
}
.meter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: var(--space-1) var(--space-3); }
.meter-row > .meter { grid-column: 1 / -1; }
.meter-row__label { color: var(--color-text-2); font-size: var(--text-small); font-weight: 500; }
.meter-row__value { color: var(--color-text); font-size: var(--text-small); font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }

.segbar { display: flex; gap: 2px; height: 12px; }
.segbar--lg { height: 20px; }
.segbar__seg {
  flex: var(--w, 1) 1 0;
  min-width: 2px;
  background: var(--seg-color, var(--color-neutral));
  border-radius: 3px;
}
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin: var(--space-3) 0 0; padding: 0; list-style: none; font-size: var(--text-small); color: var(--color-text-2); }
.legend__item { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }
.legend__swatch { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 3px; background: var(--seg-color, var(--color-neutral)); }
.legend__value { color: var(--color-text); font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
.legend__pct { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

.ring {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: var(--color-brand);                 /* the arc colour (currentColor) */
  background: conic-gradient(currentColor calc(var(--p, 0) * 1%), var(--color-surface-3) 0);
}
.ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--color-surface-1); }
.ring__label { position: relative; font-size: var(--text-caption); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--color-text); }
.ring--lg { flex-basis: 72px; width: 72px; height: 72px; }
.ring--positive { color: var(--color-positive); }
.ring--warning { color: var(--color-warning); }

/* ---- 7.8 Transaction row ---------------------------------------------------- */
.txn-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "date date" "main amount" "meta actions";
  gap: var(--space-1) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.txn-row__date { grid-area: date; color: var(--color-text-muted); font-size: var(--text-caption); }
.txn-row__main { grid-area: main; min-width: 0; color: var(--color-text); font-weight: 500; overflow-wrap: anywhere; }
.txn-row__amount { grid-area: amount; display: inline-flex; align-items: center; gap: var(--space-1); justify-self: end; color: var(--color-text); font-size: var(--text-metric-sm); font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
.txn-row__amount svg, .txn-row__amount i { width: 16px; height: 16px; color: var(--color-text-muted); }
.txn-row__meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; }
.txn-row__actions { grid-area: actions; display: flex; align-items: center; gap: var(--space-2); justify-self: end; }
.txn-row--pending { box-shadow: inset 3px 0 0 var(--color-warning); }
@media (min-width: 768px) {
  .txn-row { grid-template-columns: 96px minmax(0, 1fr) auto auto; grid-template-areas: "date main amount actions" "date meta amount actions"; align-items: center; }
}

/* ---- 7.9 Tables (opt-in via .table-wrap; bare .table is untouched) ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--fade-bg, var(--color-surface-1)) 30%, transparent) 0 0 / 40px 100% no-repeat local,
    linear-gradient(to left, var(--fade-bg, var(--color-surface-1)) 30%, transparent) 100% 0 / 40px 100% no-repeat local,
    linear-gradient(to right, var(--color-border), transparent) 0 0 / 14px 100% no-repeat scroll,
    linear-gradient(to left, var(--color-border), transparent) 100% 0 / 14px 100% no-repeat scroll;
}
.table-wrap--sticky { max-height: 70vh; overflow-y: auto; }
.table-wrap .table { font-size: var(--text-body); }
.table-wrap .table th, .table-wrap .table td { padding: 12px 16px; }
.table-wrap .table tr + tr td { border-top: 1px solid var(--color-divider); }
.table-wrap .table thead th {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table-wrap--sticky .table thead th { position: sticky; top: 0; z-index: 1; }
.table-wrap .table td { min-height: var(--h-control); }

.table-wrap .table .num, .table-wrap .table th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.table-wrap .table .table__total td { border-top: 2px solid var(--color-border-strong); font-weight: 600; }
.table--compact th, .table--compact td { padding: 8px 12px !important; }
.table-wrap .table--sticky-first th:first-child, .table-wrap .table--sticky-first td:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--color-surface-1);
}
.table-wrap .table--sticky-first thead th:first-child { background: var(--color-surface-2); z-index: 2; }
@media (max-width: 767.98px) {
  .table--stack thead { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table-wrap .table--stack tr { margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3); background: var(--color-surface-1); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
  .table-wrap .table--stack tr + tr td:first-child { border-top: none; }
  .table-wrap .table--stack td { display: flex; justify-content: space-between; gap: var(--space-4); padding: 6px 0; border-top: none !important; text-align: right; }
  .table--stack td::before { content: attr(data-label); flex: 0 0 auto; color: var(--color-text-muted); font-weight: 500; text-align: left; }
}

/* ---- 7.10 Chips (one pill system) ------------------------------------------- */
.chip { min-height: 24px; padding: 0 10px; font-size: var(--text-caption); line-height: 1.2; }

.chip svg,
.chip i { width: 14px; height: 14px; flex: 0 0 14px; }
.chip--positive { background: var(--color-positive-surface); color: var(--color-positive-text); box-shadow: inset 0 0 0 1px var(--color-positive-border); }
.chip--negative { background: var(--color-negative-surface); color: var(--color-negative-text); box-shadow: inset 0 0 0 1px var(--color-negative-border); }
.chip--warning { background: var(--color-warning-surface); color: var(--color-warning-text); box-shadow: inset 0 0 0 1px var(--color-warning-border); }
.chip--info { background: var(--color-info-surface); color: var(--color-info-text); box-shadow: inset 0 0 0 1px var(--color-info-border); }
.chip--neutral { background: var(--color-neutral-weak); color: var(--color-text-2); }
.chip--brand { background: var(--color-brand-weak); color: var(--color-brand-strong); box-shadow: inset 0 0 0 1px var(--color-brand); }
.chip--brass { background: var(--color-brass-weak); color: var(--color-warning-text); box-shadow: inset 0 0 0 1px var(--color-brass); }
.chip--outline { background: transparent; color: var(--color-text-2); box-shadow: inset 0 0 0 1px var(--color-border-control); }
a.chip, button.chip { text-decoration: none; cursor: pointer; }
button.chip { min-height: 32px; font-weight: 600; }
a.chip:hover, button.chip:hover { background: var(--color-surface-3); color: var(--color-text); }
button.chip.chip--brand:hover { background: var(--color-brand-weak); color: var(--color-brand-strong); }

/* ---- 7.11 Alerts and notes --------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text);
}
.alert > svg,
.alert > i { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 1px; }
.alert__body { flex: 1 1 auto; min-width: 0; }
.alert__title { margin: 0; font-size: var(--text-body); font-weight: 600; }
.alert__text { margin: 2px 0 0; font-size: var(--text-small); }
.alert__title + .alert__text, .alert__body > .alert__text:first-child { margin-top: 0; }

.alert__close { flex: 0 0 auto; width: 32px; height: 32px; margin: -6px -8px -6px 0; padding: 0; justify-content: center; background: transparent; color: inherit; box-shadow: none; }
.alert__close:hover { background: var(--color-surface-3); }
.alert--positive { background: var(--color-positive-surface); border-color: var(--color-positive-border); color: var(--color-positive-text); }
.alert--negative { background: var(--color-negative-surface); border-color: var(--color-negative-border); color: var(--color-negative-text); }
.alert--warning { background: var(--color-warning-surface); border-color: var(--color-warning-border); color: var(--color-warning-text); }
.alert--info { background: var(--color-info-surface); border-color: var(--color-info-border); color: var(--color-info-text); }
.note { display: flex; align-items: flex-start; gap: var(--space-2); margin: var(--space-2) 0 0; color: var(--color-text-muted); font-size: var(--text-caption); line-height: 1.45; }
.note > svg, .note > i { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 1px; }
details.note { display: block; }
details.note > summary { cursor: pointer; }

/* ---- 7.12 Empty state --------------------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-7) var(--space-5); text-align: center; }
.empty__icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--color-brand-weak); color: var(--color-brand-strong); }
.empty__icon svg, .empty__icon i { width: 32px; height: 32px; }
.empty__title { margin: 0; font-size: var(--text-h3); font-weight: 600; }
.empty__body { margin: 0; max-width: 48ch; color: var(--color-text-muted); font-size: var(--text-body); }

/* ---- 7.13 Goal card / 7.14 Investment summary (layout only) ------------------- */
.goal-card { display: flex; flex-direction: column; gap: var(--space-3); }
.goal-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.goal-card__title { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-h3); font-weight: 600; min-width: 0; }
.goal-card__meta { margin: 0; color: var(--color-text-muted); font-size: var(--text-small); }
.goal-card__body { display: flex; align-items: center; gap: var(--space-4); }
.goal-card__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
.invest-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); align-items: center; gap: var(--space-5) var(--space-6); }
.invest-summary__total { margin: 0; font-size: var(--text-display-sm); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums lining-nums; }

/* ---- 7.15 Segmented control + filter bar --------------------------------------- */
.seg-control { display: inline-flex; gap: 2px; padding: 3px; min-height: 36px; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.seg-control__opt {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: 28px; padding: 0 var(--space-3);
  background: transparent; color: var(--color-text-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: var(--text-small); font-weight: 500; text-decoration: none; box-shadow: none; cursor: pointer;
}
.seg-control__opt:hover { background: var(--color-surface-3); color: var(--color-text); text-decoration: none; }
.seg-control__opt[aria-checked="true"], .seg-control__opt[aria-current="true"], .seg-control__opt[aria-current="page"] {
  background: var(--color-surface-1); color: var(--color-text); font-weight: 600;
  border-color: var(--color-border-strong); box-shadow: var(--shadow-1);
}
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.filter-bar__toggle { display: none; }
@media (max-width: 767.98px) {
  /* Only collapse when JS can open the sheet; without JS the inline controls stay. */
  html.js .filter-bar__inline { display: none; }
  html.js .filter-bar__toggle { display: inline-flex; }
}

/* ---- 7.16 Tabs ------------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--color-border);
  background:
    linear-gradient(to right, var(--fade-bg, var(--color-bg)) 30%, transparent) 0 0 / 28px 100% no-repeat local,
    linear-gradient(to left, var(--fade-bg, var(--color-bg)) 30%, transparent) 100% 0 / 28px 100% no-repeat local;
}
.card .tabs { --fade-bg: var(--color-surface-1); }
.tabs [role="tab"] {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4);
  background: transparent; color: var(--color-text-muted);
  border: none; border-bottom: 2px solid transparent; border-radius: 0;
  font-size: var(--text-body); font-weight: 600; white-space: nowrap; text-decoration: none; box-shadow: none; cursor: pointer;
}
.tabs [role="tab"]:hover { background: var(--color-surface-3); color: var(--color-text); text-decoration: none; }
.tabs [role="tab"][aria-selected="true"], .tabs a[role="tab"][aria-current="page"] { color: var(--color-text); border-bottom-color: var(--color-brand); }
.tabs [role="tab"]:focus-visible { outline-offset: -2px; }
.tabs [role="tab"]:disabled { opacity: 0.5; cursor: not-allowed; }
[role="tabpanel"] { padding-top: var(--space-4); }
[role="tabpanel"][hidden] { display: none; }

/* ---- 7.17 Buttons ----------------------------------------------------------------- */
.btn-secondary { background: var(--color-surface-1); color: var(--color-text); border: 1px solid var(--color-border-control); }
.btn-secondary:hover { background: var(--color-surface-3); color: var(--color-text); }
.btn-ghost { background: transparent; color: var(--color-brand-strong); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--color-surface-3); color: var(--color-brand-strong); box-shadow: none; }
.btn-danger { background: var(--color-surface-1); color: var(--color-negative); border: 1px solid var(--color-negative); }
.btn-danger:hover { background: var(--color-negative); color: var(--color-on-brand); }
.btn--sm { min-height: var(--h-control-sm); padding: 0 12px; font-size: var(--text-small); }
.btn--lg { min-height: var(--h-control-lg); padding: 0 24px; }
.btn--icon { min-width: var(--h-control); min-height: var(--h-control); padding: 0; justify-content: center; }
.btn--icon.btn--sm { min-width: var(--h-control-sm); min-height: var(--h-control-sm); }
.btn svg, .btn i { width: 16px; height: 16px; flex: 0 0 16px; }
.btn[aria-busy="true"], button[aria-busy="true"] { position: relative; pointer-events: none; opacity: 0.85; }
.btn[aria-busy="true"]::before, button[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: nidhi-spin 0.7s linear infinite;
}

/* ---- 7.18 Forms ---------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 var(--space-4); min-width: 0; }
.field > label { margin: 0; color: var(--color-text-2); font-size: var(--text-small); font-weight: 500; }
.field > input, .field > select, .field > textarea, .field .input--money input {
  min-height: var(--h-control); padding: 0 12px; background: var(--color-surface-1);
  border-radius: var(--radius-md);
}
.field > textarea { padding: 10px 12px; min-height: 96px; }
.field__hint { margin: 0; color: var(--color-text-muted); font-size: var(--text-small); }
.field__error { display: flex; align-items: flex-start; gap: var(--space-1); margin: 0; color: var(--color-negative); font-size: var(--text-small); font-weight: 500; }
.field__error svg, .field__error i { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 2px; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--color-negative); box-shadow: 0 0 0 3px var(--color-negative-weak);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--space-4); }
.form-grid > .field { margin-bottom: 0; }
.input--money { position: relative; display: block; }
.input--money::before { content: "\20B9"; position: absolute; top: 50%; left: 12px; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.input--money input { padding-left: 30px; text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.fieldset { min-width: 0; margin: 0 0 var(--space-5); padding: var(--space-4) var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.fieldset > legend { padding: 0 var(--space-2); font-size: var(--text-h3); font-weight: 600; }
.stepper { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin: 0 0 var(--space-5); padding: 0; list-style: none; counter-reset: step; }
.stepper li { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--color-text-muted); font-size: var(--text-small); font-weight: 500; counter-increment: step; }
.stepper li::before {
  content: counter(step); display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--color-surface-3); color: var(--color-text-2); font-size: var(--text-caption); font-weight: 600;
}
.stepper [aria-current="step"] { color: var(--color-text); font-weight: 600; }
.stepper [aria-current="step"]::before { background: var(--color-brand); color: var(--color-on-brand); }

/* ---- Disclosure (native <details>) and overflow menu ------------------------------------ */
details.disclosure { background: var(--color-surface-1); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
details.disclosure[open] { background: var(--color-surface-2); }
details.disclosure > summary {
  display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 10px var(--space-4);
  font-size: var(--text-body); font-weight: 600; cursor: pointer; list-style: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after {
  content: ""; flex: 0 0 8px; width: 8px; height: 8px; margin-inline-start: auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform var(--t-fast);
}
details.disclosure[open] > summary::after { transform: rotate(-135deg); }
.disclosure__body { padding: 0 var(--space-4) var(--space-4); }

details.menu { position: relative; display: inline-block; }
details.menu > summary {
  display: inline-grid; place-items: center; width: var(--h-control); height: var(--h-control);
  border-radius: var(--radius-sm); color: var(--color-text-2); cursor: pointer; list-style: none;
}
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary:hover, details.menu[open] > summary { background: var(--color-surface-3); color: var(--color-text); }
.menu__list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 40; min-width: 180px; padding: 4px;
  background: var(--color-surface-1); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-2);
}
.menu__item {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: var(--h-control); padding: 0 var(--space-3);
  background: transparent; color: var(--color-text); border: none; border-radius: var(--radius-sm);
  font-size: var(--text-body); font-weight: 500; text-align: start; text-decoration: none; box-shadow: none; cursor: pointer;
}
.menu__item:hover { background: var(--color-surface-3); color: var(--color-text); text-decoration: none; }
.menu__item--danger { color: var(--color-negative); }
.menu__item--danger:hover { color: var(--color-negative); }

/* ---- 7.19 Dialog (native <dialog>) ---------------------------------------------------------- */
.dialog {
  width: 100%; max-width: min(480px, calc(100vw - 32px)); padding: 0;
  background: var(--color-surface-1); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-3);
}
.dialog::backdrop { background: var(--color-scrim); }
.dialog__head { padding: var(--space-5) var(--space-5) 0; }
.dialog__title { margin: 0; font-size: var(--text-h3); font-weight: 600; }
.dialog__body { padding: var(--space-3) var(--space-5); color: var(--color-text-2); font-size: var(--text-body); }
.dialog__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-5) var(--space-5); }
.dialog__foot form { display: contents; margin: 0; }
@media (min-width: 768px) and (prefers-reduced-motion: no-preference) {
  .dialog[open] { animation: nidhi-pop 160ms ease-out; }
}
@media (max-width: 767.98px) {
  .dialog--sheet { max-width: 100%; margin: auto 0 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
}
body.has-dialog { overflow: hidden; }

/* ---- 7.22 Info tip / 7.23 Skeleton ------------------------------------------------------------- */
.info-tip { position: relative; display: inline-flex; vertical-align: middle; }
.info-tip__btn {
  display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0;
  background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border-control);
  border-radius: 50%; font-size: var(--text-caption); font-weight: 700; box-shadow: none;
}
.info-tip__btn:hover { background: var(--color-surface-3); color: var(--color-text); }
.info-tip__bubble {
  position: absolute; bottom: calc(100% + 8px); left: 50%; z-index: 50; display: none;
  width: max-content; max-width: min(280px, 80vw); padding: 8px 12px; transform: translateX(-50%);
  background: var(--color-surface-1); color: var(--color-text); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2); font-size: var(--text-small); font-weight: 400; text-align: start;
}
.info-tip:hover .info-tip__bubble, .info-tip:focus-within .info-tip__bubble, .info-tip.is-open .info-tip__bubble { display: block; }
.info-tip.is-dismissed .info-tip__bubble { display: none; }
.skeleton {
  display: block; min-height: 1em; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-surface-3) 50%, var(--color-surface-2) 75%);
  background-size: 200% 100%; animation: nidhi-shimmer 1.4s linear infinite;
}

@keyframes nidhi-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes nidhi-spin { to { transform: rotate(360deg); } }
@keyframes nidhi-pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton, .metric-card--loading .metric__value { animation: none; }
  .btn[aria-busy="true"]::before, button[aria-busy="true"]::before { animation: none; }
  .dialog[open] { animation: none; }
}

/* ==========================================================================
   Dashboard (UI-10B.4) — page-scoped layout (spec §13.1 item 6). Components
   come from the B.3 library; this block only arranges them. Tokens only.
   ========================================================================== */

/* ---- Hero: sparkline beside the value on >=lg, below it on md/sm --------- */
.hero--dash { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .hero--dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.hero--dash .hero__value--negative { color: var(--color-negative); }
.hero--dash .hero__eyebrow { margin: 0 0 var(--space-2); }
.hero__chart { align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.hero__spark { position: relative; height: 64px; }
.hero__spark canvas { display: block; width: 100% !important; height: 100% !important; }
@media (min-width: 768px) { .hero__spark { height: 88px; } }
.hero__svg { display: block; width: 100%; height: 88px; }
.hero__foot {
  grid-column: 1 / -1;
  display: grid;
  gap: var(--space-4);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-divider);
}
.hero__foot .stat-group { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
@media (min-width: 768px) { .hero__foot .stat-group { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.hero__foot .legend { margin-top: var(--space-3); }

/* ---- "This month" / "Safety net" grids --------------------------------------- */
.dash-grid { display: grid; gap: var(--gap-card); grid-template-columns: minmax(0, 1fr); align-items: stretch; }
@media (min-width: 768px) {
  .dash-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid--3 > :first-child { grid-column: 1 / -1; }     /* md: spending full width, then 2-up */
}
@media (min-width: 1024px) {
  .dash-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-grid--3 > :first-child { grid-column: auto; }
}
.dash-card { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; margin-bottom: 0; }
.dash-card--link { color: inherit; text-decoration: none; }
.dash-card--link:hover { text-decoration: none; }
.dash-card__title {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.dash-card__figure {
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-metric);
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums lining-nums;
  overflow-wrap: anywhere;
}
.dash-card__of { color: var(--color-text-muted); font-size: var(--text-body); font-weight: 500; margin-inline-start: var(--space-1); }
.dash-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-1) var(--space-3); margin: 0; font-size: var(--text-small); }
.dash-line b { font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
.dash-note { margin: 0; color: var(--color-text-muted); font-size: var(--text-small); line-height: 1.5; }
.dash-link { font-size: var(--text-small); font-weight: 600; }
.dash-tone--positive { color: var(--color-positive); }
.dash-tone--negative { color: var(--color-negative); }
.dash-tone--warning { color: var(--color-warning); }
.dash-card .alert { margin: 0; }
.dash-card .empty { padding: var(--space-5) var(--space-2); }
.dash-allocation { margin-top: var(--gap-card); }
.dash-ring-row { display: flex; align-items: center; gap: var(--space-4); }
.dash-ring-row > div { min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.dash-ring-row p { margin: 0; }

/* ---- Retirement outlook ----------------------------------------------------------- */
.dash-retire { gap: var(--space-5); }
.dash-retire__sip { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@media (min-width: 768px) { .dash-retire__sip { grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); } }
.dash-retire__sip .card { margin: 0; }
.dash-projection { display: flex; flex-direction: column; gap: var(--space-4); padding-top: var(--space-5); border-top: 1px solid var(--color-divider); }
.dash-subhead { margin: 0; font-size: var(--text-h3); font-weight: 600; }
.dash-takeaway { margin: 0; max-width: 72ch; font-size: var(--text-body-lg); line-height: 1.6; }
.dash-chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.dash-chart { position: relative; height: 200px; }
@media (min-width: 768px) { .dash-chart { height: 240px; } }
@media (max-width: 767.98px) { .dash-chart-head .seg-control { width: 100%; } .dash-chart-head .seg-control__opt { flex: 1 1 0; } }
/* Tab-flavoured seg-control: B.3's seg-control marks the selected option with
   aria-checked/aria-current; this one switches panels, so it uses aria-selected. */
.seg-control__opt[aria-selected="true"] {
  background: var(--color-surface-1); color: var(--color-text); font-weight: 600;
  border-color: var(--color-border-strong); box-shadow: var(--shadow-1);
}
.dash-th-left { text-align: left; }
.dash-row--strong td { font-weight: 600; }
.dash-jump { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.dash-jump .chip { min-height: 40px; padding: 0 var(--space-4); font-size: var(--text-small); }
.dash-grid { align-items: start; }
.dash-swatch { display: inline-block; margin-inline-end: 7px; vertical-align: middle; }
.dash-card .table-wrap .table { font-size: var(--text-small); }
.dash-card .table-wrap .table--compact th, .dash-card .table-wrap .table--compact td { padding: 8px 6px !important; }
.dash-retire .stat-group { align-items: end; }
.dash-line .chip { margin-inline-start: var(--space-2); }

/* ==========================================================================
   Plan pages (UI-10B.8) — Goals, Safety, goal form, calculator. Page-scoped
   layout only (spec §13.1 item 6); components come from the B.3 library.
   ========================================================================== */
.plan-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--space-4) var(--space-6); }
.plan-fig { min-width: 0; }
.plan-fig .hero__eyebrow { margin: 0 0 var(--space-2); }
.hero--plan, .hero--safety { grid-template-columns: minmax(0, 1fr); margin-bottom: var(--gap-card); }
@media (min-width: 1024px) { .hero--safety { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.hero--safety .hero__chart { display: flex; flex-direction: column; gap: var(--space-3); }
.hero--safety .hero__foot, .hero--plan .hero__foot { gap: var(--space-3); }
.hero--plan .hero__foot .alert, .hero--safety .hero__foot .alert { margin: 0; }
.hero--safety .hero__value { font-size: var(--text-display-sm); }
.hero--plan .hero__value { font-size: var(--text-display-sm); }
@media (min-width: 1024px) { .hero--plan .hero__value { font-size: var(--text-display); } }
.hero--safety .stat-group { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.dash-tone--brand { color: var(--color-brand-strong); }

/* goal cards */
.goal-card__figs { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.goal-card .alert { margin: 0; }
.goal-card__foot { align-items: center; }
.plan-mix { display: flex; flex-direction: column; gap: var(--space-2); }
.plan-mix .legend { margin-top: 0; }
.plan-trend { margin: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.plan-spark { display: block; width: 100%; height: 50px; }
.plan-chart { position: relative; height: 180px; margin-block: var(--space-2); }
@media (min-width: 768px) { .plan-chart { height: 220px; } }
.goal-proj { margin: 0; }
.plan-unalloc { border-style: dashed; }
.plan-unalloc .empty { padding: var(--space-5) var(--space-3); }

/* forms: goal form, calculator, safety */
.plan-form { max-width: var(--w-form-max); }
.plan-form__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }
.field--check > label { display: flex; align-items: flex-start; gap: var(--space-3); color: var(--color-text-2); font-size: var(--text-body); font-weight: 400; }
input.check { flex: 0 0 20px; width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--color-brand); cursor: pointer; }
input.check:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.plan-modes { flex-wrap: wrap; margin-bottom: var(--space-5); }
.plan-calc { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; }
.plan-result { margin-top: var(--space-1); font-size: var(--text-display-sm); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums lining-nums; }
.plan-calc .card { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: 0; }
.plan-calc .card .plan-save .field { margin-bottom: 0; }
.plan-calc .card .alert { margin: 0; }
.plan-save { margin-top: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--color-divider); }
.plan-save__row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.plan-save__row input { flex: 1 1 160px; min-width: 0; }
.plan-inline-form .plan-save__row input { flex: 0 1 160px; }

/* safety */
.plan-panel { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
.plan-panel .alert { margin: 0; }
.plan-row-form { display: inline; margin: 0; }
.plan-cap { text-transform: capitalize; }
.plan-add-grid { margin-bottom: var(--space-3); }
.table-wrap .table th.plan-row-head { text-align: left; font-weight: 500; color: var(--color-text); background: var(--color-surface-1); text-transform: none; letter-spacing: 0; font-size: var(--text-body); border-bottom: none; }
.table-wrap .table th.plan-role-col, .table-wrap .table td.plan-role-col { text-align: center; }
.table-wrap--sticky { max-height: 60vh; }
/* .sr-only is position:absolute; inside a scroll wrapper its containing block must be inside the wrapper or it escapes the clip and widens the page. */
.table-wrap .table th.plan-th-action { position: relative; }
.plan-fig { display: flex; flex-direction: column; justify-content: flex-end; }
.plan-form .form-grid, .dash-card form > .form-grid { margin-bottom: var(--space-4); }
.plan-form .field--check { margin-bottom: var(--space-4); }

/* ==========================================================================
   Financial Planning (UI-10B.5) — page-scoped layout (spec §9.1). Reuses the B.3
   components and the B.4/B.8 page blocks (.dash-grid, .dash-card, .dash-ring-row,
   .hero__foot, .dash-jump); only what the page needs beyond them is added here.
   ========================================================================== */
.plan-anchors { position: sticky; top: 0; z-index: 30; margin: 0 0 var(--space-5); box-shadow: var(--shadow-2); }
/* V2.4-navfix: equal-width horizon options (flex:1 1 0), scoped to .plan-anchors. */
.plan-anchors { display: flex; }
.plan-anchors .seg-control__opt { flex: 1 1 0; min-width: 0; white-space: nowrap; }
@media (max-width: 1023.98px) { .plan-anchors { top: calc(var(--topbar-h) + var(--space-2)); } }
@media (max-width: 479.98px) { .plan-anchors .seg-control__opt { padding: 0 var(--space-2); } }
.plan-horizon { scroll-margin-top: calc(var(--topbar-h) + 72px); }
.plan-band { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-4); margin: var(--gap-section) 0 var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-divider); }
#now .plan-band { margin-top: var(--space-4); padding-top: 0; border-top: 0; }
.plan-band h2 { margin: 0; }
.plan-band__hint { color: var(--color-text-muted); font-size: var(--text-small); }
.hero--cash { grid-template-columns: minmax(0, 1fr); margin-bottom: var(--gap-section); }
.hero--cash .hero__main { display: flex; flex-direction: column; gap: var(--space-2); }
.hero--cash .hero__eyebrow, .hero--cash .hero__meta, .hero--cash .hero__value { margin: 0; }
.plan-fig-label { margin: 0; color: var(--color-text-muted); font-size: var(--text-small); font-weight: 500; }
.plan-alert ul { margin: 0; padding-inline-start: 1.2em; }
.plan-alert { margin: var(--space-2) 0 0; }
.plan-list { margin: 0; padding-inline-start: 1.2em; }
.plan-pair { margin-block: var(--gap-section) var(--gap-card); }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: var(--gap-card); align-items: start; }
.plan-cards .dash-line { justify-content: flex-start; gap: var(--space-2); }
.plan-sub { font-size: var(--text-small); font-weight: 400; text-transform: none; letter-spacing: 0; }
.plan-highlight { margin-bottom: var(--space-4); border-color: var(--color-brand); }
.plan-gap { margin-bottom: var(--space-3); }
.plan-cap-note { display: block; color: var(--color-text-muted); font-size: var(--text-caption); font-weight: 400; }
.plan-signals { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.plan-signals li { padding: var(--space-3) 0; border-top: 1px solid var(--color-divider); }
.plan-signals li:first-child { border-top: 0; padding-top: 0; }
.plan-signal__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-1); }
.plan-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.plan-title-row .chip, .plan-signal__head .chip { text-transform: none; letter-spacing: 0; }
.plan-horizon > .section, .plan-horizon > .hero { margin-top: 0; }
.plan-horizon .section { margin-top: var(--gap-section); }
.plan-horizon .plan-band + .section, .plan-horizon .plan-band + .hero { margin-top: 0; }
@media (max-width: 767.98px) { .plan-cap-note { display: inline; margin-inline-start: var(--space-2); } }
/* six related figures read best as an even 3x2 (2-up on phones), never 5+1 */
.plan-six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--space-5); }
@media (min-width: 768px) { .plan-six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ==========================================================================
   Money pages (UI-10B.6) — Transactions, Accounts, Budget (spec §9.2-§9.4). Page-scoped
   layout only; components come from B.3, with the .dash-*/.plan-* helpers from B.4/B.8.
   ========================================================================== */
.txn-inline { display: inline; margin: 0; }
.status__dot--pending { background: var(--color-warning); }

/* -- Transactions: filter bar (inline >=768px; sheet <768px when JS can open it) -- */
.txn-filters { margin: 0 0 var(--space-4); }
.txn-filters .filter-bar__inline, .txn-sheet { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-4); }
.txn-sheet { flex-direction: column; align-items: stretch; }
.txn-dates { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2) var(--space-3); margin: 0; }
.txn-dates .field { margin: 0; }
.txn-dates input[type="date"] { width: auto; }
.txn-presets { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.txn-presets .chip { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-small); }
.txn-sheet .txn-presets .chip, .txn-sheet .seg-control__opt { min-height: 40px; }
.txn-sheet .seg-control { align-self: flex-start; flex-wrap: wrap; }
@media (min-width: 1280px) {
  .txn-filters { position: sticky; top: 0; z-index: 30; padding: var(--space-3) 0; background: var(--color-bg); box-shadow: 0 1px 0 var(--color-divider); }
}
.txn-confirm-all { display: inline; margin: 0; }
.txn-summary { margin: 0 0 var(--gap-card); }
.txn-card { margin-bottom: var(--gap-card); }
.txn-card--list { padding: 0; }
.txn-cats { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-5); }
.txn-donut { position: relative; flex: 0 0 170px; width: 170px; height: 170px; }
.txn-catlist { flex: 1 1 300px; min-width: min(100%, 260px); display: flex; flex-direction: column; gap: var(--space-2); }
.txn-catnote { margin: calc(var(--space-1) * -1) 0 var(--space-2); }
.txn-list { margin: 0; padding: 0; list-style: none; }
.txn-list > .txn-row:last-child { border-bottom: 0; }
.txn-acct { color: var(--color-text-muted); font-size: var(--text-small); }
.txn-cat { display: inline-flex; gap: var(--space-1); margin: 0; }
.txn-cat input { width: 9rem; min-height: var(--h-control-sm); padding: 0 var(--space-2); font-size: var(--text-small); border-color: var(--color-border); background: transparent; }
.txn-cat input:hover, .txn-cat input:focus { background: var(--color-surface-1); border-color: var(--color-border-control); }
.txn-row .status { font-size: var(--text-small); }
.txn-empty { padding: var(--space-6) var(--space-4); }
.txn-empty .empty__body a { text-decoration: underline; }

/* -- Accounts -- */
.hero--acct, .hero--bud { grid-template-columns: minmax(0, 1fr); margin-bottom: var(--gap-card); }
@media (min-width: 1024px) { .hero--acct { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.hero--acct .hero__main, .hero--bud .hero__main { display: flex; flex-direction: column; gap: var(--space-2); }
.hero--acct .hero__eyebrow, .hero--acct .hero__value, .hero--acct .hero__meta, .hero--bud .hero__eyebrow, .hero--bud .hero__value, .hero--bud .hero__delta { margin: 0; }
.acct-hero-side { align-self: center; }
.acct-card { margin-bottom: var(--gap-card); }
.acct-sub { display: block; margin-top: var(--space-1); color: var(--color-text-muted); font-size: var(--text-caption); font-weight: 400; }
.acct-purpose { text-transform: capitalize; }
.acct-actions { white-space: nowrap; }
.acct-actions > * { vertical-align: middle; }
.acct-due { white-space: nowrap; }
.acct-util { display: flex; align-items: center; gap: var(--space-2); min-width: 96px; }
.acct-util .meter { flex: 1 1 60px; }
.acct-pct { color: var(--color-text-muted); font-size: var(--text-small); font-variant-numeric: tabular-nums; }
.acct-tip .info-tip__bubble { position: fixed; top: 0; left: 0; bottom: auto; z-index: 60; transform: none; }

/* -- Budget -- */
.bud-settings { margin-bottom: var(--space-3); }
.bud-cyclenote { margin: 0 0 var(--gap-card); }
.hero--bud .hero__foot { gap: var(--space-3); }
.bud-util { display: flex; flex-direction: column; gap: var(--space-4); }
.bud-pin { min-height: 20px; margin-inline-start: var(--space-2); padding: 0 var(--space-2); font-size: var(--text-caption); }
.bud-input { width: 7.5rem; min-height: var(--h-control-sm); padding: 0 var(--space-2); text-align: right; font-variant-numeric: tabular-nums; }
.bud-savebar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.bud-reset { margin: var(--space-4) 0 var(--space-3); }
@media (max-width: 767.98px) {
  .bud-savebar { position: sticky; bottom: 0; z-index: 20; margin-inline: calc(var(--space-4) * -1); padding: var(--space-3) var(--space-4); background: var(--color-bg); border-top: 1px solid var(--color-divider); }
}
.txn-catlist .legend__swatch { display: inline-block; vertical-align: -1px; margin-right: var(--space-1); }

/* ==========================================================================
   Invest pages (UI-10B.7) — Portfolio, Tax, Research, Fund Decisions, Sell (spec §9.5-§9.8, §9.13).
   Page-scoped layout only; components come from B.3, helpers from B.4/B.6.
   ========================================================================== */
.pf-sync { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin: calc(-1 * var(--space-2)) 0 var(--space-4); color: var(--color-text-muted); font-size: var(--text-small); }
.pf-import { margin: 0 0 var(--space-4); }
.pf-import summary { display: flex; align-items: center; gap: var(--space-2); }
.pf-import__form { display: grid; gap: var(--space-3); max-width: 640px; padding-top: var(--space-3); }
.pf-card { margin-top: var(--space-4); }
.pf-card--table { padding: 0; overflow: hidden; }
.pf-scope { color: var(--color-text-muted); }
.invest-summary .stat-group { margin: 0; }
.pf-signed { display: inline-flex; align-items: center; gap: var(--space-1); font-variant-numeric: tabular-nums lining-nums; font-weight: 600; white-space: nowrap; }
.pf-alloc { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-5); }
.pf-alloc__donut { position: relative; width: 180px; height: 180px; flex: 0 0 auto; }
.pf-alloc__bars { flex: 1 1 280px; min-width: 220px; display: grid; gap: var(--space-3); }
.pf-alloc__meter .meter__fill { background: var(--seg-color, var(--color-brand)); }
.pf-health__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2); }
.pf-health__head .dash-card__title { margin: 0; }
.pf-health__more { margin-top: var(--space-3); }
.pf-sub { margin-top: var(--space-3); }
.pf-flags { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-3); }
.pf-flag { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3); background: var(--color-surface-2); border-radius: var(--radius-md); border-left: 3px solid var(--color-border-strong, var(--color-border)); }
.pf-flag--warning { border-left-color: var(--color-warning); }
.pf-flag--positive { border-left-color: var(--color-positive); }
.pf-flag--info { border-left-color: var(--color-info, var(--color-brand)); }
.pf-flag__icon { display: inline-flex; margin-top: 2px; color: var(--color-text-2); }
.pf-flag--warning .pf-flag__icon { color: var(--color-warning); }
.pf-flag--positive .pf-flag__icon { color: var(--color-positive); }
.pf-flag__body { flex: 1 1 auto; min-width: 0; }
.pf-flag__row { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }
.pf-flag__metric { font-variant-numeric: tabular-nums lining-nums; font-weight: 600; white-space: nowrap; }
.pf-tabs { margin-top: var(--space-5); }
.pf-class { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-3); }
.pf-class__value { margin: 0; font-size: var(--text-h2, 1.5rem); font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
.pf-class__gain { text-align: right; }
.pf-class__gain .dash-note, .pf-class__gl { margin: 0; }
.pf-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.pf-bulk select { width: auto; min-height: var(--h-control-sm); }
.pf-ledger-note { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
.pf-ledger-note .alert { margin: 0; }
.pf-table { min-width: 880px; }
.pf-table .pf-col-check { width: 44px; }
.pf-table input.check { margin: 0; }
.pf-note { font-size: var(--text-small); }
.pf-nowrap { white-space: nowrap; }
.pf-score { margin-left: var(--space-2); text-decoration: none; vertical-align: middle; }
.pf-earmark { width: auto; max-width: 160px; min-height: var(--h-control-sm); }
.pf-actions { white-space: nowrap; }
.table-wrap .table.pf-table th .sr-only { position: absolute; }
.table-wrap .table.pf-table th:last-child { position: relative; }
.pf-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: var(--space-4); margin-top: var(--space-5); }
.pf-tool { display: flex; flex-direction: column; gap: var(--space-2); color: inherit; text-decoration: none; margin: 0; }
.pf-tool .hero__eyebrow, .pf-tool p { margin: 0; }
.pf-tool__body { font-size: var(--text-body); }
.pf-tool__go { margin-top: auto; color: var(--color-brand-strong); font-weight: 600; font-size: var(--text-small); }
@media (min-width: 768px) {
  .pf-table .pf-col-name { position: sticky; left: 44px; background: var(--color-surface-1); z-index: 1; }
  .pf-table thead .pf-col-name { background: var(--color-surface-2); z-index: 2; }
}

/* -- Tax -- */
.tax-lead { margin: 0 0 var(--space-2); font-weight: 600; }
.tax-body { margin: var(--space-3) 0; font-size: var(--text-small); line-height: 1.55; }
.tax-body.muted { color: var(--color-text-muted); }
.tax-status { margin-top: var(--space-4); border-left: 3px solid var(--color-info, var(--color-brand)); }
.tax-status--warning { border-left-color: var(--color-warning); }
.tax-status--positive { border-left-color: var(--color-positive); }
.tax-status__head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2); }
.tax-status__head .dash-card__title { margin: 0; }
.tax-sub { margin: var(--space-3) 0; }
.tax-hero { margin-top: var(--space-4); }
.tax-hero .stat-group { margin: 0; }
.tax-law, .tax-realised, .tax-sec, .tax-foot { margin-top: var(--space-4); }
.tax-warning-text { font-weight: 400; }
.tax-realised-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin: var(--space-4) 0; }
.tax-realised-form .field { margin: 0; flex: 1 1 280px; max-width: 420px; }
.tax-strategy { margin: var(--space-4) 0 var(--space-1); font-size: var(--text-body); font-weight: 600; }
.tax-estimate { margin: var(--space-3) 0 0; font-size: var(--text-body); font-weight: 600; }
.tax-table .tax-then { white-space: normal; min-width: 180px; }
.tax-lots { display: inline; }
.tax-lots > summary { display: inline; cursor: pointer; font-size: var(--text-caption); }
.tax-lots > summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.tax-lots__list { margin-top: var(--space-1); padding-left: var(--space-2); }
.table-wrap .table .table__total td { font-weight: 600; border-top: 2px solid var(--color-border); }

/* -- Sell -- */
.sell-legend { font-size: var(--text-small); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.sell-sec { margin-top: var(--space-4); }
.sell-sec--warn { border-left: 3px solid var(--color-warning); }
.sell-sec__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-2); }
.sell-sec__head .dash-card__title { margin: 0; }
.sell-sm { font-size: var(--text-caption); }
.sell-warn { margin: var(--space-2) 0; }
.sell-warn .alert { margin: 0; }
.sell-warn ul { margin: var(--space-1) 0 0; padding-left: var(--space-5); }
.sell-table .sell-why { min-width: 220px; max-width: 340px; }
.sell-table .sell-bench { min-width: 150px; max-width: 200px; }
.sell-table .sell-fundname { min-width: 160px; max-width: 200px; }
.sell-reason { font-size: var(--text-small); margin-bottom: var(--space-1); }
.sell-panel { margin: var(--space-3) 0; padding: var(--space-3) var(--space-4); background: var(--color-surface-2); border-radius: var(--radius-md); font-size: var(--text-small); }
.sell-alloc { margin-top: var(--space-1); display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.sell-pair { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--color-border); }
.sell-sim { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-4); }
.sell-sim .field { margin: 0; }
.sell-sim input[type="text"] { width: 130px; }
.sell-sim select { min-width: 220px; }
.sell-disclosure { font-style: italic; }
.sell-dq { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-2); font-size: var(--text-small); line-height: 1.55; }

/* -- Fund decisions -- */
.dec-legend { font-size: var(--text-small); margin-top: 0; }
.dec-list { margin: var(--space-1) 0; padding-left: var(--space-5); font-size: var(--text-small); line-height: 1.55; display: grid; gap: 2px; }
.dec-attn, .dec-overview, .dec-dups, .dec-alloc, .dec-planner { margin-top: var(--space-4); }
.dec-counts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); list-style: none; margin: var(--space-3) 0 0; padding: 0; }
.dec-counts li { display: inline-flex; align-items: center; gap: var(--space-2); }
.dec-counts__label { font-size: var(--text-small); color: var(--color-text-muted); font-weight: 600; }
.dec-fund { margin-top: var(--space-4); }
.dec-fund__head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3) var(--space-5); margin-bottom: var(--space-3); }
.dec-fund__id { flex: 1 1 320px; min-width: 0; }
.dec-fund__id .dash-note, .dec-fund__decision .dash-note { margin: var(--space-1) 0 0; }
.dec-fund__name { margin: 0; font-size: var(--text-h3); font-weight: 600; }
.dec-fund__decision { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); text-align: right; max-width: 360px; }
.dec-fund__chip .chip { font-size: var(--text-small); padding: 4px 12px; }
.dec-fund__link { font-size: var(--text-small); }
.dec-quality { margin-top: var(--space-3); font-size: var(--text-small); }
.dec-quality__label { color: var(--color-text-muted); }
.dec-score { font-size: var(--text-body); font-variant-numeric: tabular-nums lining-nums; }
.dec-reasons, .dec-suit { margin-top: var(--space-3); }
.dec-suit { border-top: 1px solid var(--color-border); padding-top: var(--space-3); font-size: var(--text-small); }
.dec-suit__row { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.dec-more { margin-top: var(--space-3); }
.dec-hist { margin: var(--space-3) 0; padding: var(--space-3); border: 1px dashed var(--color-border-control, var(--color-border)); border-radius: var(--radius-md); font-size: var(--text-small); }
.dec-form { display: grid; gap: var(--space-4); margin-top: var(--space-3); }
.dec-budget { max-width: 260px; margin: 0; }
.dec-targets { border: 0; margin: 0; padding: 0; min-width: 0; }
.dec-targets legend { padding: 0; margin-bottom: var(--space-2); }
.dec-targets .form-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.dec-pct { position: relative; max-width: 120px; }
.dec-pct input { width: 100%; min-width: 88px; padding-right: 26px; text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.dec-pct::after { content: "%"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.dec-illus { margin: var(--space-2) 0 0; color: var(--color-brand-strong); font-weight: 600; font-size: var(--text-small); }
.dec-foot { margin-top: var(--space-4); }
.dec-table { min-width: 560px; }

/* -- Research -- */
.res-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-3); }
.res-tabs { margin: var(--space-4) 0; }
.res-tabs a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-4); color: var(--color-text-muted); border-bottom: 2px solid transparent; font-weight: 600; white-space: nowrap; text-decoration: none; }
.res-tabs a:hover { background: var(--color-surface-3); color: var(--color-text); text-decoration: none; }
.res-tabs a[aria-current="page"] { color: var(--color-text); border-bottom-color: var(--color-brand); }
.res-tabs a:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.res-lead { margin: 0 0 var(--space-2); font-weight: 600; }
.res-sm { font-size: var(--text-caption); }
.res-sec { margin-top: var(--space-4); }
.res-sec--table { padding: 0; overflow: hidden; }
.res-pad { padding: var(--space-4) var(--space-4) 0; }
.res-sec > .dash-note { padding: 0 var(--space-4) var(--space-3); }
.res-feed { margin-top: var(--space-4); }
.res-feed__head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: var(--space-2); }
.res-feed__name { margin: 0; font-size: var(--text-h3); font-weight: 600; }
.res-feed__name .muted { font-size: var(--text-small); font-weight: 400; }
.res-news { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-3); }
.res-news li { border-top: 1px solid var(--color-border); padding-top: var(--space-3); }
.res-news a { color: var(--color-text); text-decoration: none; line-height: 1.45; }
.res-news a:hover { text-decoration: underline; }
.res-edges { list-style: none; margin: 0; padding: 0; font-size: var(--text-small); }
.res-edges li { padding: var(--space-1) 0; border-bottom: 1px solid var(--color-border); }
.res-nodata { text-align: center; }
.res-link { margin-left: var(--space-2); }
.res-deep { margin-top: var(--space-4); }
.res-group th { text-align: left; font-size: var(--text-caption); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); background: var(--color-surface-2); padding: var(--space-2) var(--space-3); }
.res-group__n { opacity: 0.8; }
.res-unscored td { opacity: 0.85; }
.res-caveat { cursor: help; margin-left: var(--space-1); vertical-align: middle; }
.res-caveat:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.res-held td { background: var(--color-surface-2); }
.res-held-chip { margin-left: var(--space-2); }
.res-stocklink { color: inherit; text-decoration: none; }
.res-analyse { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin: 0; }
.res-analyse .field { margin: 0; flex: 1 1 260px; }
.res-analyse select { width: auto; min-width: 240px; }
.res-grow { flex: 1 1 200px; width: auto; }
.res-upper { text-transform: uppercase; }
.res-ret { display: inline-flex; align-items: center; gap: var(--space-2); justify-content: flex-end; }
.bar-inline { position: relative; display: inline-block; width: 64px; height: 6px; background: var(--color-surface-3); border-radius: 3px; flex: 0 0 auto; }
.bar-inline::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--color-border-strong, var(--color-border)); }
.bar-inline__fill { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.bar-inline__fill--pos { left: 50%; width: calc(var(--w, 0) * 0.5%); background: var(--color-positive); }
.bar-inline__fill--neg { right: 50%; width: calc(var(--w, 0) * 0.5%); background: var(--color-negative); }
.res-card-accent { border-left: 3px solid var(--color-brand); margin-top: var(--space-4); }
.res-block { margin-top: var(--space-4); }
.res-block--ruled { border-top: 2px solid var(--color-border); padding-top: var(--space-3); }
.res-block__title { margin: 0 0 var(--space-2); font-size: var(--text-small); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.res-title-note { text-transform: none; letter-spacing: 0; font-weight: 400; }
.res-stats { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); font-size: var(--text-small); }
.res-month { margin-top: var(--space-4); border-top: 1px solid var(--color-border); padding-top: var(--space-3); }
.res-upload { margin-top: var(--space-3); padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); font-size: var(--text-small); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.res-upload > div { flex: 1 1 100%; }
.res-upload select, .res-upload input[type="text"] { width: auto; min-height: var(--h-control-sm); }
.res-deep__head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: var(--space-2); }
.res-deep__name { margin: 0; font-size: var(--text-h2, 1.375rem); font-weight: 600; }
.res-deep__name .muted { font-size: var(--text-small); font-weight: 400; }
.res-deep--positive { border-left: 3px solid var(--color-positive); }
.res-deep--warning { border-left: 3px solid var(--color-warning); }
.res-deep--negative { border-left: 3px solid var(--color-negative); }
.res-deep--neutral { border-left: 3px solid var(--color-border-strong, var(--color-border)); }
.res-verdict { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); margin-top: var(--space-4); }
.res-verdict__word .chip { font-size: var(--text-body); padding: 6px 16px; letter-spacing: 0.04em; }
.res-verdict__why { margin: 0; flex: 1 1 280px; font-size: var(--text-body); line-height: 1.5; }
.res-verdict__score { text-align: center; min-width: 92px; }
.res-verdict__num { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums lining-nums; }
.res-verdict__num .muted { font-size: var(--text-small); font-weight: 400; }
.res-beginner { margin-top: var(--space-4); padding: var(--space-3) var(--space-4); background: var(--color-surface-2); border-radius: var(--radius-md); font-size: var(--text-small); line-height: 1.55; }
.res-table .res-ret { min-width: 118px; }
.pf-tip .info-tip__bubble { position: fixed; top: 0; left: 0; bottom: auto; z-index: 60; transform: none; width: min(280px, calc(100vw - 16px)); }
.tax-law > .dash-card__title, .tax-realised > .dash-card__title, .tax-sec > .dash-card__title { margin-bottom: var(--space-3); }

/* ==========================================================================
   Import & auth pages (UI-10B.9) — Statements, Gmail, SMS, Login, Register, Onboarding, Error (spec §9.11, §9.12).
   Page-scoped layout only; components come from B.3, helpers from B.4/B.6.
   ========================================================================== */
.imp-intro { margin: calc(-1 * var(--space-2)) 0 var(--space-4); max-width: 72ch; }
.imp-card { margin-top: var(--space-4); }
.imp-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-2); }
.imp-head .dash-card__title { margin: 0; }
.imp-cap { text-transform: capitalize; }
.imp-steps { margin: var(--space-3) 0; padding-left: var(--space-5); display: grid; gap: var(--space-2); font-size: var(--text-small); line-height: 1.7; }
.imp-steps ul { margin: var(--space-1) 0 0; padding-left: var(--space-5); }
.imp-steps li, .imp-steps ul { min-width: 0; }
.code-block { max-width: 100%; min-width: 0; }
.imp-stepper .is-done::before { content: "\2713"; background: var(--color-brand-weak); color: var(--color-brand-strong); }
.imp-stepper .is-done { color: var(--color-text-2); }
.imp-card > .alert { margin: var(--space-3) 0; }
.imp-card code, .imp-intro code, .imp-steps code { font-size: var(--text-caption); }
.imp-card > .flash { margin-top: var(--space-3); }
.imp-regen { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-3); }
.imp-test .field { margin-bottom: var(--space-2); }
.imp-test textarea { width: 100%; }
.imp-result { margin-top: var(--space-3); }
.imp-result .alert { margin: 0; }
.imp-raw { margin-top: var(--space-3); }
.imp-raw pre { margin: var(--space-2) 0 0; padding: var(--space-3); background: var(--color-surface-2); border-radius: var(--radius-md); font-family: var(--font-mono); font-size: var(--text-caption); overflow-x: auto; white-space: pre-wrap; word-break: break-word; }

/* code block (spec §9.11): mono, surface-2, optional copy button (non-secret blocks only) */
.code-block { position: relative; margin: var(--space-3) 0; }
.code-block pre { margin: 0; padding: var(--space-3) var(--space-4); background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-md); font-family: var(--font-mono); font-size: var(--text-small); line-height: 1.6; overflow-x: auto; }
.code-block pre:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.code-block__copy { position: absolute; top: var(--space-2); right: var(--space-2); }
.code-block__copy[hidden] { display: none; }
.code-block--copy pre { padding-right: 7rem; }

/* review-step Import bar: sticks to the bottom while the review is on screen; never covers focused controls */
.imp-group { min-width: 0; }
.imp-bar { position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); margin: var(--space-4) 0 0; padding: var(--space-3) var(--space-4); background: var(--color-surface-1); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-2); }
.imp-bar__text { color: var(--color-text-muted); font-size: var(--text-small); }
.imp-review :is(a, button, input, select, textarea, summary, [tabindex]) { scroll-margin-bottom: 6rem; }
@media (max-width: 479px) { .imp-bar button { width: 100%; } }
@media (max-height: 500px) { .imp-bar { position: static; } }

/* guest pages: theme control + split auth layout */
.guest-theme { position: absolute; top: var(--space-3); right: var(--space-3); z-index: 30; }
.guest-main--auth { min-height: 100dvh; }
.guest-main--auth > .wrap { max-width: none; padding: 0; }
.guest-main--auth > .wrap > .flash { margin: var(--space-4) var(--space-4) 0; padding-right: 0; }
.auth-split { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
.auth-brand { display: flex; flex-direction: column; justify-content: center; gap: var(--space-4); padding: var(--space-7) var(--space-5) var(--space-5); background: linear-gradient(160deg, var(--color-surface-2), var(--color-bg)); }
.auth-brand__id { display: flex; align-items: center; gap: var(--space-3); }
.auth-brand__name { font-size: var(--text-h2); font-weight: 600; }
.auth-brand__tag { margin: 0; font-family: var(--font-display); font-size: var(--text-h2); line-height: 1.2; letter-spacing: -0.01em; color: var(--color-text); }
.auth-brand__points { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.auth-brand__points li { display: flex; align-items: center; gap: var(--space-3); color: var(--color-text-2); font-size: var(--text-body); }
.auth-brand__points i, .auth-brand__points svg { color: var(--color-brand-strong); flex: 0 0 20px; }
.auth-split > .auth-card { align-self: start; width: 100%; max-width: var(--w-auth); margin: var(--space-5) auto var(--space-7); }
.auth-card__title { margin: 0 0 var(--space-4); font-size: var(--text-h2); }
.auth-card__submit { width: 100%; margin-top: var(--space-3); }
.auth-card__alt { margin: var(--space-4) 0 0; color: var(--color-text-muted); font-size: var(--text-small); }
@media (min-width: 1024px) {
  .auth-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .auth-brand { padding: var(--space-8) var(--space-8); }
  .auth-brand__tag { font-size: var(--text-display-sm); max-width: 14ch; }
  .auth-split > .auth-card { align-self: center; margin: var(--space-5) auto; }
}

/* onboarding */
.ob-wrap { max-width: 640px; margin: 0 auto; }
.ob-form { margin-top: var(--space-4); }
.ob-fieldset { margin-bottom: var(--space-4); }
.ob-ages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ob-more { margin-bottom: var(--space-5); }
.ob-more__body { padding-top: var(--space-3); }
.ob-submit { width: 100%; }
@media (max-width: 539px) { .ob-ages { grid-template-columns: 1fr; } }

/* error pages */
.err-card { max-width: 520px; margin: var(--space-7) auto; }
.err-title { font-size: var(--text-h2); }

/* ==========================================================================
   Charts pass (UI-10B.10) — the .chart figure container (spec §10.4).
   data-state: loading (skeleton) | ready (canvas) | failed / empty / no-JS (text fallback).
   ========================================================================== */
.chart { margin: 0; min-width: 0; }
.chart__canvas { position: relative; }
.chart__skeleton { display: none; position: absolute; inset: 0; border-radius: var(--radius-md); }
html.js .chart[data-state="loading"] .chart__skeleton { display: block; }
html.js .chart[data-state="loading"] canvas { visibility: hidden; }
.chart__caption { margin: var(--space-2) 0 0; color: var(--color-text-muted); font-size: var(--text-small); line-height: 1.5; }
.chart__fallback, .chart__empty { display: none; margin: var(--space-2) 0 0; padding: var(--space-3); background: var(--color-surface-2); border-radius: var(--radius-md); color: var(--color-text-2); font-size: var(--text-small); line-height: 1.5; }
html:not(.js) .chart__fallback, .chart[data-state="failed"] .chart__fallback { display: block; }
.chart[data-state="empty"] .chart__empty { display: block; }
html:not(.js) .chart__canvas, .chart[data-state="failed"] .chart__canvas, .chart[data-state="empty"] .chart__canvas { display: none; }
.chart[data-state="empty"] .chart__caption, .chart[data-state="failed"] .chart__caption { display: none; }
.chart--donut { height: auto; flex: 0 0 180px; width: 180px; }
.chart--donut .chart__canvas { width: 100%; aspect-ratio: 1; }
.chart--donut.txn-donut { flex-basis: 170px; width: 170px; }
.chart--donut .chart__caption, .chart--donut .chart__fallback, .chart--donut .chart__empty { font-size: var(--text-caption); }


/* ==========================================================================
   Cleanup pass (UI-10B.11) — page-scoped helpers that replace static inline styles
   (spec §13.2) in Research > Funds, plus the shared hidden state used by JS-toggled
   form fields. Tokens only; no new colours. Data-driven values stay inline
   (--w, --seg-color, --p, --target, --x, width:{{…}}).
   ========================================================================== */
/* A hidden STATE must always win (it replaces an inline style="display:none", which also beat every selector), e.g. .hero__spark canvas { display: block }. */
.is-hidden { display: none !important; }
.status__detail { font-weight: 400; font-size: var(--text-small); }

/* Research > Funds helpers (replace ~100 repeated inline fragments). .res-sm already exists (caption size). */
.res-md { font-size: var(--text-small); }
.res-fs-14 { font-size: 0.875rem; }
.res-fs-16 { font-size: 1rem; }
.res-lh { line-height: 1.5; }
.res-bold { font-weight: 700; }
.res-tnum { font-variant-numeric: tabular-nums; }
.res-eyebrow { text-transform: uppercase; letter-spacing: 0.5px; }
.res-w160, .res-upload input.res-w160 { width: 160px; }      /* the 2nd selector outranks .res-upload input[type="text"] { width: auto } */
.res-col { flex: 1 1 220px; }
.res-flexrow { display: flex; gap: 18px; flex-wrap: wrap; }
.res-plain { text-decoration: none; color: inherit; }
.res-pl-18 { padding-left: 18px; }
.res-ml-6 { margin-left: 6px; }
.res-mt-2 { margin-top: 2px; }
.res-mt-3 { margin-top: 3px; }
.res-mt-4 { margin-top: 4px; }
.res-mt-6 { margin-top: 6px; }
.res-mt-8 { margin-top: 8px; }
.res-mt-10 { margin-top: 10px; }
.res-mt-12 { margin-top: 12px; }
.res-mb-4 { margin-bottom: 4px; }
.res-mb-8 { margin-bottom: 8px; }
.res-my-2 { margin-top: 2px; margin-bottom: 2px; }
.res-my-4 { margin-top: 4px; margin-bottom: 4px; }
.res-my-6 { margin-top: 6px; margin-bottom: 6px; }
/* Tone modifiers (semantic text colours; a status always also carries its text label). */
.res-tone--pos { color: var(--color-positive); }
.res-tone--neg { color: var(--color-negative); }
.res-tone--brand { color: var(--color-brand-strong); }
.res-tone--warn { color: var(--color-warning-text); }
.res-tone--muted { color: var(--color-text-muted); }
.res-tone--text { color: var(--color-text); }

/* ==========================================================================
   Privacy Mode (Dashboard V2-B)
   Amounts are wrapped server-side in <span class="amt" data-amt> (app.py
   _wrap_monetary_amounts); html[data-privacy="on"] (default, set pre-paint)
   masks them. V2-C.1: a FIXED six-dot mask (••••••) replaces the old blur, so no
   value, length, sign, decimals or currency symbol leaks. DISPLAY ONLY — real
   values stay in the DOM/chart JSON (needed to draw and to reveal); not
   protection against devtools. Proportions/%/dates stay visible.
   ========================================================================== */
.amt { color: inherit; }
@media (prefers-reduced-motion: no-preference) {
  .amt { transition: color 160ms ease; }
}
/* Hidden: collapse the real amount to zero width (no length/symbol/sign leak;
   the text stays in the DOM for reveal) and render a FIXED six-dot mask via
   ::before. No blur. The dots read as intentional text (normal size + colour). */
html[data-privacy="on"] .amt {
  font-size: 0;                       /* real digits: zero-width, still in DOM */
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}
html[data-privacy="on"] .amt::before {
  content: "\2022\2022\2022\2022\2022\2022";   /* •••••• — six U+2022 bullets */
  font-size: 1rem;                    /* restore readable size for the mask */
  letter-spacing: 0.08em;
  color: var(--color-text);
  -webkit-user-select: none;
  user-select: none;
}
.app-topbar__privacy,
.sidebar__privacy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: transparent;
  color: var(--color-text-muted);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: none;
}
.app-topbar__privacy {
  /* V2-C: icon + visible text, pushed to the far right of the global header. */
  margin-inline-start: auto;
  height: 36px;
  padding: 0 var(--space-3);
  gap: var(--space-2);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
}
.app-topbar__privacy .privacy-label { white-space: nowrap; }
.sidebar__privacy {
  width: 100%;
  justify-content: flex-start;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-small);
  font-weight: 500;
  margin-top: var(--space-2);
}
.app-topbar__privacy:hover,
.sidebar__privacy:hover { background: var(--color-surface-3); color: var(--color-text); }
.app-topbar__privacy:focus-visible,
.sidebar__privacy:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.privacy-ico { width: 20px; height: 20px; }
.js-privacy-toggle .privacy-ico--shown { display: none; }
.js-privacy-toggle[aria-pressed="true"] .privacy-ico--hidden { display: none; }
.js-privacy-toggle[aria-pressed="true"] .privacy-ico--shown { display: inline-flex; }
/* V2-C: on desktop the sidebar carries nav + brand, so the global top bar shows
   only the title and the always-visible privacy control. */
@media (min-width: 1024px) {
  .app-topbar__menu { display: none; }
  .app-topbar > .brand { display: none; }
  .app-topbar__title { margin-inline-start: 0; }   /* title left; privacy auto-pushes right */
}
@media (min-width: 1024px) and (max-width: 1279.98px) {
  html:not([data-nav="expanded"]) .sidebar__privacy .privacy-label { display: none; }
  html:not([data-nav="expanded"]) .sidebar__privacy { justify-content: center; }
}

/* ==========================================================================
   Dashboard V2-C — cash-flow doughnut + safety progress rings (display-only;
   reuses tokens, the .chart state machine, .legend and the .ring component).
   ========================================================================== */
.dash-donut { margin: var(--space-3) 0 0; }
.dash-donut__canvas { position: relative; height: 200px; }
@media (min-width: 768px) { .dash-donut__canvas { height: 220px; } }
.dash-donut__legend { margin-top: var(--space-3); gap: var(--space-2) var(--space-4); }
@media (prefers-reduced-motion: no-preference) {
  .dash-donut__canvas canvas { animation: dash-fade-in 500ms ease both; }
}
@keyframes dash-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Net-worth COMPOSITION donut (V2.4), scoped to .nw-compose. Legend rows are a
   grid (swatch|name|amount|%) that aligns amounts/% and never clips. */
.nw-compose { margin-top: var(--space-4); }
.nw-compose .dash-donut__legend {
  margin-top: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.nw-compose .dash-donut__legend .legend__item,
#this-month .legend__item {
  display: grid; grid-template-columns: auto 1fr auto auto;
  align-items: baseline; gap: var(--space-2) var(--space-3); width: 100%;
}
.nw-compose .dash-donut__legend .legend__swatch,
#this-month .legend__swatch { align-self: center; }
.nw-compose .dash-donut__legend .legend__value { text-align: end; white-space: nowrap; }
.nw-compose .dash-donut__legend .legend__pct,
#this-month .legend__pct { text-align: end; min-width: 3ch; justify-self: end; }
.nw-compose .dash-donut__legend .legend__item--total {
  margin-top: var(--space-2); padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
  grid-template-columns: 1fr auto; font-weight: 600;
}
@media (min-width: 768px) {
  .nw-compose {
    display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
    align-items: center; gap: var(--space-5);
  }
  .nw-compose .dash-donut__canvas { height: 240px; }
  .nw-compose .dash-donut__legend { margin-top: 0; }
  .nw-compose .chart__fallback { grid-column: 1 / -1; }
}
.safety-rings { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .safety-rings { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.safety-ring { display: flex; gap: var(--space-4); align-items: center; }
.safety-ring__body { min-width: 0; }
.safety-ring--untracked .ring { color: var(--color-text-faint); }

/* ==========================================================================
   Net Worth page (V2.2) — presentation only; reuses .hero--dash, .dash-grid,
   .dash-donut, .chart, .disclosure, .table. Only page-specific spacing/heights.
   ========================================================================== */
.hero__explore { margin: var(--space-4) 0 0; }
.nw-history .hero__spark { height: 160px; }
@media (min-width: 768px) { .nw-history .hero__spark { height: 200px; } }
.nw-history__single, .nw-history__empty { align-self: center; max-width: 42ch; }
.nw-detail .disclosure + .disclosure { margin-top: var(--space-3); }

/* Dashboard "This month" cards (V2.5–V3.2), scoped to #this-month: 160px donut,
   stacked legend, dividers, 5-row subgrid aligning sections at desktop. */
#this-month .tm-head, #this-month .tm-figure, #this-month .tm-support,
#this-month .dash-donut, #this-month .dash-donut__legend {
  display: flex; flex-direction: column; gap: var(--space-2); margin: 0;
}
#this-month .tm-head { gap: var(--space-1); }
#this-month .tm-sub { margin: 0; font-weight: 600; }
#this-month .tm-chart, #this-month .tm-support { border-top: 1px solid var(--color-divider); padding-top: var(--space-3); }
#this-month .dash-donut { gap: var(--space-3); }
#this-month .dash-donut__canvas { flex: none; width: 160px; height: 160px; margin-inline: auto; }
#this-month .legend__name { min-width: 0; overflow-wrap: anywhere; }
#this-month .tm-foot { margin-top: var(--space-2); }
@media (min-width: 1024px) {
  #this-month .dash-grid--3 { align-items: stretch; }
  @supports (grid-template-rows: subgrid) {
    #this-month .dash-grid--3 { grid-template-rows: auto auto auto 1fr auto; }
    #this-month .tm-card { display: grid; grid-row: span 5; grid-template-rows: subgrid; gap: var(--space-3); }
  }
}

/* ==========================================================================
   Financial Planning calendar + list (PR-FINPLAN-P4) — page-scoped, tokens
   only. ADDED as a new block (after the B.5/B.8/B.11 blocks, which stay
   byte-identical) so earlier page-scoped tests are unaffected. Presentation
   only: amounts use the shared .amt mask; status pills carry text labels so
   meaning never depends on colour alone. Radio-driven view/filter switches
   (no new buttons, no <details>) keep the existing page contract intact; the
   List view is the no-CSS/no-JS default.
   ========================================================================== */
/* view + filter switches reuse .seg-control; hide the backing radios */
.plan-view-radio, .plan-filter-radio { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.plan-view-switch, .plan-filter { flex-wrap: wrap; }
.plan-view-radio:checked + label.seg-control__opt,
.plan-filter-radio:checked + label.seg-control__opt { background: var(--color-brand-weak); color: var(--color-brand-strong); font-weight: 600; }
.plan-view-radio:focus-visible + label.seg-control__opt,
.plan-filter-radio:focus-visible + label.seg-control__opt { outline: 2px solid var(--color-brand); outline-offset: 2px; }

.plan-views { margin-bottom: var(--space-4); }
.plan-list-controls { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; margin: var(--space-3) 0; }
.plan-sort { display: flex; align-items: center; gap: var(--space-2); }
.plan-sort-select { font-size: var(--fs-sm); padding: var(--space-1) var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-1); color: var(--color-text); }

/* default: show List, hide Calendar/Overview. The JS switch sets
   .plan-views--cal / --overview / --list (authoritative, works everywhere);
   CSS :has() is kept as a progressive enhancement for no-JS browsers. */
.plan-view--cal, .plan-view--overview { display: none; }
.plan-views--cal .plan-view--cal { display: block; }
.plan-views--cal .plan-view--list, .plan-views--cal .plan-view--overview { display: none; }
.plan-views--overview .plan-view--overview { display: block; }
.plan-views--overview .plan-view--list, .plan-views--overview .plan-view--cal { display: none; }
.plan-views--list .plan-view--cal, .plan-views--list .plan-view--overview { display: none; }
.plan-views:has(#plan-view-cal:checked) .plan-view--cal { display: block; }
.plan-views:has(#plan-view-cal:checked) .plan-view--list,
.plan-views:has(#plan-view-cal:checked) .plan-view--overview { display: none; }
.plan-views:has(#plan-view-overview:checked) .plan-view--overview { display: block; }
.plan-views:has(#plan-view-overview:checked) .plan-view--list,
.plan-views:has(#plan-view-overview:checked) .plan-view--cal { display: none; }

/* calendar grid */
.plan-cal { margin-top: var(--space-3); }
.plan-cal__nojs { margin: 0; }
.plan-cal:has(.plan-cal__grid) .plan-cal__nojs { display: none; }
.plan-cal__head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); flex-wrap: wrap; }
.plan-cal__title { margin: 0; font-size: var(--fs-md); flex: 1 1 auto; text-align: center; }
.plan-cal__nav { display: inline-flex; align-items: center; justify-content: center; min-width: 2.25rem; min-height: 2.25rem; padding: 0 var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text); text-decoration: none; font-size: var(--fs-md); }
.plan-cal__nav:hover { background: var(--color-surface-2); }
.plan-cal__nav:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }

.plan-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--space-1); }
.plan-cal__dow { font-size: var(--fs-xs); font-weight: 600; color: var(--color-text-muted); text-align: center; padding: var(--space-1) 0; }
.plan-cal__cell { position: relative; min-height: 84px; border: 1px solid var(--color-divider); border-radius: var(--radius-sm); padding: var(--space-1); background: var(--color-surface-1); overflow: hidden; }
.plan-cal__cell--adj { background: var(--color-surface-2); opacity: 0.7; }
.plan-cal__cell--today { border-color: var(--color-brand); box-shadow: inset 0 0 0 1px var(--color-brand); }
.plan-cal__cell--selected { outline: 2px solid var(--color-brand); outline-offset: -2px; }
.plan-cal__daynum { display: inline-block; font-size: var(--fs-xs); font-weight: 600; color: var(--color-text); text-decoration: none; padding: 2px 4px; border-radius: var(--radius-sm); }
.plan-cal__daynum:hover { background: var(--color-surface-2); }
.plan-cal__daynum:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 1px; }
.plan-cal__add { position: absolute; top: var(--space-1); right: var(--space-1); font-size: var(--fs-sm); line-height: 1; color: var(--color-text-muted); text-decoration: none; padding: 2px 5px; border-radius: var(--radius-sm); }
.plan-cal__add:hover { background: var(--color-brand-weak); color: var(--color-brand-strong); }
.plan-cal__add:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 1px; }
.plan-cal__cellentries { list-style: none; margin: var(--space-1) 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.plan-cal__dot { font-size: var(--fs-xs); line-height: 1.3; padding: 1px var(--space-1); border-radius: var(--radius-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--color-text-muted); }
.plan-cal__dot--planned { border-left-color: var(--color-text-muted); background: var(--color-surface-2); }
.plan-cal__dot--reserved { border-left-color: var(--color-info); background: var(--color-info-surface); }
.plan-cal__dot--completed { border-left-color: var(--color-positive); background: var(--color-positive-surface); }
.plan-cal__dot--overdue { border-left-color: var(--color-warning); background: var(--color-warning-surface); }

/* day details panel */
.plan-cal-day { margin-top: var(--space-4); }
.plan-cal-day__title { margin: 0 0 var(--space-2); font-size: var(--fs-md); }
.plan-cal-day__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.plan-cal-entry { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2); border: 1px solid var(--color-divider); border-radius: var(--radius-sm); background: var(--color-surface-1); }
.plan-cal-entry__name { font-weight: 600; }
.plan-cal-day__open { margin-left: auto; font-size: var(--fs-sm); color: var(--color-brand-strong); text-decoration: none; }
.plan-cal-day__open:hover { text-decoration: underline; }
.plan-cal-day__open:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }

/* status pills (text label + colour; never colour alone) */
.plan-pill { font-size: var(--fs-xs); font-weight: 600; padding: 1px var(--space-2); border-radius: 999px; }
.plan-pill--planned { background: var(--color-surface-2); color: var(--color-text-muted); }
.plan-pill--reserved { background: var(--color-info-surface); color: var(--color-info); }
.plan-pill--completed { background: var(--color-positive-surface); color: var(--color-positive-text); }
.plan-pill--overdue { background: var(--color-warning-surface); color: var(--color-warning-text); }

/* mobile: a single-column, taller-cell calendar with the day panel below */
@media (max-width: 640px) {
  .plan-cal__cell { min-height: 56px; }
  .plan-cal__dot { font-size: var(--fs-xs); }
  .plan-cal__title { font-size: var(--fs-md); }
  .plan-list-controls { flex-direction: column; align-items: stretch; }
}

/* ==========================================================================
   Upcoming commitments reminders (PR-FINPLAN-P5) — page-scoped, tokens only.
   Dashboard compact summary (.dash-rem*) + /plan reminder list (.plan-rem*).
   Presentation only; amounts use the shared .amt mask. Status is conveyed by a
   text-labelled chip, never colour alone. Radio-driven filter (no buttons, no
   <details>).
   ========================================================================== */
/* --- shared summary stat tiles (dashboard + plan) --- */
.dash-rem__stats, .plan-rem-summary { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.dash-rem__stat, .plan-rem-stat { flex: 1 1 auto; min-width: 7rem; display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-3); border: 1px solid var(--color-divider); border-radius: var(--radius-sm); background: var(--color-surface-1); }
.dash-rem__num, .plan-rem-stat__num { font-size: var(--fs-lg); font-weight: 700; line-height: 1.1; }
.dash-rem__label, .plan-rem-stat__label { font-size: var(--fs-xs); color: var(--color-text-muted); }
.dash-rem__stat--overdue, .plan-rem-stat--overdue { border-color: var(--color-warning); background: var(--color-warning-surface); }
.dash-rem__stat--overdue .dash-rem__num, .plan-rem-stat--overdue .plan-rem-stat__num { color: var(--color-warning-text); }
.dash-rem__stat--today, .plan-rem-stat--today { border-color: var(--color-info); background: var(--color-info-surface); }
.dash-rem__stat--today .dash-rem__num, .plan-rem-stat--today .plan-rem-stat__num { color: var(--color-info); }
.plan-rem-stat--muted { opacity: 0.85; }

/* --- dashboard compact preview list --- */
.dash-rem__list { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.dash-rem__item { border-radius: var(--radius-sm); }
.dash-rem__link { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2); border: 1px solid var(--color-divider); border-radius: var(--radius-sm); text-decoration: none; color: var(--color-text); background: var(--color-surface-1); }
.dash-rem__link:hover { background: var(--color-surface-2); }
.dash-rem__link:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.dash-rem__name { font-weight: 600; flex: 1 1 10rem; }
.dash-rem__rec { color: var(--color-text-muted); }
.dash-rem__due { font-size: var(--fs-sm); color: var(--color-text-muted); display: inline-flex; align-items: center; gap: var(--space-1); }
.dash-rem__amt { margin-left: auto; font-variant-numeric: tabular-nums; }
.dash-rem__item--overdue .dash-rem__link { border-left: 3px solid var(--color-warning); }
.dash-rem__item--today .dash-rem__link { border-left: 3px solid var(--color-info); }

/* --- plan-page reminder filter (reuses .seg-control) --- */
.plan-rem-radio { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.plan-rem-filter { flex-wrap: wrap; margin: 0 0 var(--space-3); }
.plan-rem-radio:checked + label.seg-control__opt { background: var(--color-brand-weak); color: var(--color-brand-strong); font-weight: 600; }
.plan-rem-radio:focus-visible + label.seg-control__opt { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.plan-rem-empty { margin: var(--space-2) 0 0; }

@media (max-width: 640px) {
  .dash-rem__stat, .plan-rem-stat { min-width: calc(50% - var(--space-2)); }
  .dash-rem__amt { margin-left: 0; }
}

/* ==========================================================================
   Planning outlook / commitment forecast (PR-FINPLAN-P6) — page-scoped,
   tokens only. Dashboard compact outlook (.dash-fc*) + /plan detailed forecast
   (.plan-fc*). Presentation only; amounts use money()/|inr0 → the shared .amt
   mask. The planned/reserved meter uses a percentage (proportion), never an
   amount, so nothing monetary reaches an attribute. Reuses existing card /
   stat-group / meter components.
   ========================================================================== */
/* dashboard compact outlook row */
.dash-fc__row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.dash-fc__cell { flex: 1 1 8rem; display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-3); border: 1px solid var(--color-divider); border-radius: var(--radius-sm); background: var(--color-surface-1); }
.dash-fc__k { font-size: var(--fs-xs); color: var(--color-text-muted); }
.dash-fc__v { font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.dash-fc__n { font-size: var(--fs-xs); color: var(--color-text-muted); }
.dash-fc__cell--overdue { border-color: var(--color-warning); background: var(--color-warning-surface); }
.dash-fc__cell--overdue .dash-fc__v { color: var(--color-warning-text); }

/* /plan detailed forecast cards */
.plan-fc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
.plan-fc-card { display: flex; flex-direction: column; gap: var(--space-1); }
.plan-fc-total { font-size: var(--fs-lg); font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.plan-fc-sub { font-size: var(--fs-sm); color: var(--color-text-muted); margin: 0 0 var(--space-2); }
.plan-fc-split { margin-bottom: var(--space-2); }
.plan-fc-overdue { margin-bottom: var(--space-3); }
.plan-fc-overdue--active { border-color: var(--color-warning); }
.plan-fc-high { margin-top: var(--space-2); }

@media (max-width: 640px) {
  .dash-fc__cell { flex: 1 1 calc(50% - var(--space-2)); }
  .plan-fc-grid { grid-template-columns: 1fr; }
}

/* PR-FINPLAN-P7.1 — visible calendar shortcut in the "Next 12 months" band. */
.plan-band__link { margin-left: var(--space-2); font-size: var(--fs-sm); color: var(--color-brand-strong); text-decoration: none; white-space: nowrap; }
.plan-band__link:hover { text-decoration: underline; }
.plan-band__link:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }

/* ==========================================================================
   12-month planning overview (PR-FINPLAN-P7.2) — page-scoped, tokens only.
   A responsive grid of month tiles that jump the existing P7.1 calendar to a
   month (no second calendar grid). Amounts use money()/the shared .amt mask;
   counts + text-labelled status chips stay visible; nothing monetary is placed
   in an attribute (data-month carries only a YYYY-MM key).
   ========================================================================== */
.plan-months { list-style: none; margin: var(--space-3) 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: var(--space-2); }
.plan-month { display: flex; }
.plan-month__link { display: flex; flex-direction: column; gap: var(--space-1); width: 100%; padding: var(--space-3); border: 1px solid var(--color-divider); border-radius: var(--radius-sm); background: var(--color-surface-1); color: var(--color-text); text-decoration: none; }
.plan-month__link:hover { background: var(--color-surface-2); }
.plan-month__link:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.plan-month--current .plan-month__link { border-color: var(--color-brand); box-shadow: inset 0 0 0 1px var(--color-brand); }
.plan-month--empty .plan-month__link { opacity: 0.8; }
.plan-month__label { font-weight: 600; display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.plan-month__tag { font-size: var(--fs-xs); font-weight: 600; color: var(--color-brand-strong); background: var(--color-brand-weak); padding: 0 var(--space-1); border-radius: var(--radius-sm); }
.plan-month__total { font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-month__meta { font-size: var(--fs-sm); color: var(--color-text-muted); }
.plan-month__meta--empty { font-style: italic; }
.plan-month__chips { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }

.plan-cal-back { margin: 0 0 var(--space-2); }
.plan-cal-back__link { font-size: var(--fs-sm); color: var(--color-brand-strong); text-decoration: none; }
/* PR-FINPLAN-P7.4: comfortable mobile tap target for the "Back to 12-month
   overview" link (was a bare ~13px text link). Inline-block with padding +
   min-height keeps it a generous touch target without changing layout or
   causing horizontal overflow; behaviour is unchanged. */
.plan-cal-back__link {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  min-height: 44px;
  line-height: 1.9;
}
.plan-cal-back__link:hover { text-decoration: underline; }
.plan-cal-back__link:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
/* PR-FINPLAN-R3.12: prominent "Manage Reservations" primary action under the
   Financial Planning page head + its one-line explanatory note. */
.plan-primary-actions { margin: var(--space-2) 0 var(--space-1); }
.plan-primary-actions__note { margin: 0 0 var(--space-3); }

@media (max-width: 640px) {
  .plan-months { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .plan-months { grid-template-columns: 1fr; }
}

/* PR-FINPLAN-P7.3 — annual payments (AnnualExpense) as a distinct, read-only
   category in the planning views. Tokens only; amounts use the shared .amt mask;
   month/year labels stay visible (no amount in any attribute). */
.plan-month__annual { display: flex; flex-direction: column; gap: 2px; margin-top: var(--space-1); }
.plan-annual-list { margin-top: var(--space-4); }
.plan-annual-list__title { margin: 0 0 var(--space-2); font-size: var(--fs-md); }
.plan-cal-annual { margin-top: var(--space-4); }
.plan-cal-annual__title { margin: 0 0 var(--space-1); font-size: var(--fs-md); }
.plan-cal-annual__list { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.plan-cal-annual__item { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2); border: 1px dashed var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-1); }
.plan-cal-annual__name { font-weight: 600; }
.plan-cal-annual__when { font-size: var(--fs-sm); color: var(--color-text-muted); margin-left: auto; }

/* PR-FINPLAN-P7.4 — annual subtotal inside a Planning Outlook window card. */
.plan-fc-annual { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px dashed var(--color-divider); }
.plan-fc-annual__amt { font-weight: 600; font-variant-numeric: tabular-nums; }

/* PR-FINPLAN-P7.5 — editable annual payments + exact-date markers (tokens only).
   The exact-date annual day marker and the inline edit disclosure on the Safety
   page. Amounts stay in masked .amt spans / money() — never in attributes. */
.plan-cal__dot--annual { border-left: 3px dashed var(--color-brass, var(--color-text-muted)); background: var(--color-surface-2); font-style: italic; }
.plan-cal__cellentries--annual { margin-top: 2px; }
.plan-annual-actions { display: flex; align-items: center; gap: var(--space-1); justify-content: flex-end; }
.plan-annual-edit > summary { cursor: pointer; }
.plan-annual-edit__form { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); padding: var(--space-2); border: 1px solid var(--color-divider); border-radius: var(--radius-sm); background: var(--color-surface-1); text-align: left; }
.plan-annual-edit__actions { margin-top: var(--space-1); }

/* PR-FINPLAN-P8.6: contextual "Reserve" selection highlight on the reservation
   hub. When the user arrives from a per-obligation Reserve link, the matching
   (owner-scoped) row is emphasised and its contribution form opened. Tokens
   only; no amount is ever placed in an attribute (privacy mask untouched). */
.resv-row--selected { background: var(--color-brand-weak); box-shadow: inset 3px 0 0 0 var(--color-brand); }
.resv-selected-tag { margin-left: var(--space-1); }
.plan-annual-reserve-link { margin-left: var(--space-1); }
