/* Financial Assistant site styles (PLAN 8.4).
   1. Tokens: copied from the design system's tokens.json
      (https://claude.ai/artifact/3TqdKJjmTPjH3zKZK9FwU3). Light by default,
      dark when the device asks for it.
   2. Components: the design system's components/bundle.css, unchanged
      apart from scoping base type and focus to the whole page.
   3. Layout: page frame, navigation and the helpers that replace inline
      styles (the CSP forbids style attributes).
   Change a value in the design system first, then copy it here. */

/* 1. Tokens ------------------------------------------------------------ */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-sunken: #edf0ee; --line: #d5dbd8; --border-strong: #8a9590;
  --ink: #18211d; --ink-muted: #56625c; --accent: #1d5ea8; --on-accent: #ffffff; --negative: #b3261e;
  --focus-ring: #1d5ea8;
  --within-ink: #1b6b3a; --within-tint: #e2f2e7; --near-ink: #8a4a00; --near-tint: #fcefd9;
  --breached-ink: #a52d16; --breached-tint: #fbe4de; --neutral-ink: #4d5853; --neutral-tint: #e9ecea;
  --shadow-bar: 0 -1px 0 #d5dbd8, 0 -4px 12px rgba(24, 33, 29, 0.06);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 40px;
  --radius-sm: 4px; --radius-md: 8px; --radius-pill: 999px;
  --font-sans: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513; --surface: #191e1b; --surface-sunken: #202623; --line: #2f3633; --border-strong: #6f7a75;
    --ink: #e5ebe7; --ink-muted: #9ca8a2; --accent: #86b4ee; --on-accent: #0c1a2b; --negative: #f2897f;
    --focus-ring: #86b4ee;
    --within-ink: #8ed4a6; --within-tint: #17301f; --near-ink: #efc27c; --near-tint: #372a12;
    --breached-ink: #f5a291; --breached-tint: #3b1d17; --neutral-ink: #b4bfb9; --neutral-tint: #252b28;
    --shadow-bar: 0 -1px 0 #2f3633;
    color-scheme: dark;
  }
}

/* 2. Components (design system) ---------------------------------------- */
/* Financial Assistant components. Every colour, space and radius is a token
   from tokens.json (var(--name)); nothing here is a literal colour. These
   classes become the site's static/app.css in PLAN 8.4. */

.fa-page, body.fa-root { font-family: var(--font-sans); font-size: 15px; line-height: 22px; color: var(--ink);
  background: var(--bg); padding: var(--space-4); }
*, *::before, *::after { box-sizing: border-box; }
.fa-num, .fa-table td.fa-n, .fa-table th.fa-n, .fa-stat-value { font-variant-numeric: tabular-nums; }

/* Focus: one ring for every control. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, summary:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Stack: vertical rhythm between siblings. */
.fa-stack { display: grid; align-content: start; gap: var(--space-3); }

/* Card */
.fa-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-4); display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--space-3); min-width: 0; }
.fa-card > * { min-width: 0; }
.fa-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.fa-card-title { margin: 0; font-size: 18px; line-height: 24px; font-weight: 600; }
.fa-sub { margin: 0; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-muted); }
.fa-note { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
@media (min-width: 720px) { .fa-card { padding: var(--space-5); } }

/* Stat tiles */
.fa-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: var(--space-3); }
.fa-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-3); display: grid; gap: var(--space-1); }
.fa-stat-label { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-muted); }
.fa-stat-value { font-size: 22px; line-height: 28px; font-weight: 600; white-space: nowrap; }
.fa-stat-value .fa-ccy { font-size: 15px; font-weight: 400; color: var(--ink-muted); margin-right: var(--space-1); }
@media (min-width: 720px) and (max-width: 999px) { .fa-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 719px) {
  /* Phone: the first figure full width, the rest two to a row, smaller. */
  .fa-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fa-stats > .fa-stat:first-child { grid-column: 1 / -1; }
  .fa-stats > .fa-stat:not(:first-child) .fa-stat-value { font-size: 18px; line-height: 24px; }
  /* The first tile already names the currency. */
  .fa-stats > .fa-stat:not(:first-child) .fa-ccy { display: none; }
  /* No tile alone on the last row. */
  .fa-stats > .fa-stat:last-child:nth-child(even) { grid-column: 1 / -1; }
}

/* Tables: numbers right, scroll inside the card on a phone, first column stays put. */
.fa-table-wrap { min-width: 0; overflow-x: auto; margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); }
.fa-table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 22px; }
.fa-table th { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-muted); text-align: left; background: var(--surface-sunken); white-space: nowrap; }
.fa-table th, .fa-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.fa-table .fa-n { text-align: right; white-space: nowrap; }
.fa-table th:first-child, .fa-table td:first-child { position: sticky; left: 0; background: var(--surface); }
.fa-table th:first-child { background: var(--surface-sunken); }
.fa-table tr.fa-voided td { color: var(--ink-muted); text-decoration: line-through; }
.fa-neg { color: var(--negative); }
.fa-nowrap { white-space: nowrap; }
.fa-root a.fa-link-danger, a.fa-link-danger, summary.fa-link-danger { color: var(--negative); }
@media (max-width: 719px) { .fa-table { font-size: 13px; line-height: 18px; } }

/* State pills: colour plus the word, never colour alone. */
.fa-state { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0 var(--space-2);
  border-radius: var(--radius-pill); font-size: 13px; line-height: 22px; font-weight: 600; white-space: nowrap; }
.fa-state::before { content: ""; width: 6px; height: 6px; border-radius: var(--radius-pill); background: currentColor; }
.fa-state-within { color: var(--within-ink); background: var(--within-tint); }
.fa-state-near { color: var(--near-ink); background: var(--near-tint); }
.fa-state-breached { color: var(--breached-ink); background: var(--breached-tint); }
.fa-state-needs { color: var(--neutral-ink); background: var(--neutral-tint); }
.fa-mark { font-size: 13px; line-height: 18px; color: var(--neutral-ink); font-style: italic; }

/* Badges: symbols, tactical, scenario exposure. */
.fa-badges { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.fa-badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0 var(--space-2);
  border-radius: var(--radius-pill); font-size: 13px; line-height: 22px; font-weight: 600;
  background: var(--neutral-tint); color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fa-badge-accent { color: var(--accent); background: var(--surface-sunken); }

/* Buttons */
.fa-btn { font: inherit; font-weight: 600; min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-sm);
  border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; }
.fa-btn-secondary { background: var(--surface); color: var(--accent); }
.fa-btn-danger { background: var(--surface); color: var(--negative); border-color: var(--negative); }
.fa-btn-link { background: none; border: none; color: var(--accent); padding: 0; min-height: 0; font-weight: 400; text-decoration: underline; }
.fa-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.fa-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* Forms */
.fa-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }
.fa-field { display: grid; gap: var(--space-1); font-size: 13px; line-height: 18px; color: var(--ink-muted); font-weight: 600; min-width: 0; }
.fa-field input, .fa-field select { font: inherit; font-size: 15px; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); min-height: 44px; padding: 0 var(--space-3); width: 100%; }
.fa-field-wide { grid-column: 1 / -1; }
.fa-field-error input, .fa-field-error select { border-color: var(--breached-ink); }
.fa-field-msg { font-weight: 400; color: var(--breached-ink); }
.fa-check { display: flex; align-items: center; gap: var(--space-2); font-size: 15px; color: var(--ink); min-height: 44px; }
.fa-check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Alerts */
.fa-alert { border-radius: var(--radius-sm); padding: var(--space-3); font-size: 15px; line-height: 22px; display: grid; gap: var(--space-1); }
.fa-alert strong { font-weight: 600; }
.fa-alert ul { margin: 0; padding-left: var(--space-5); }
.fa-alert-error { color: var(--breached-ink); background: var(--breached-tint); }
.fa-alert-warn { color: var(--near-ink); background: var(--near-tint); }
.fa-alert-info { color: var(--ink); background: var(--surface-sunken); }

/* Empty state */
.fa-empty { text-align: left; padding: var(--space-5) 0; display: grid; gap: var(--space-2); max-width: 46ch; }
.fa-empty-title { margin: 0; font-weight: 600; }

/* Report items (Highlights) and citations */
.fa-report { display: grid; align-content: start; gap: var(--space-3); max-width: 70ch; }
.fa-item { margin: 0; }
.fa-item b { font-weight: 600; }
.fa-cite { font-size: 12px; line-height: 16px; color: var(--accent); text-decoration: none; padding: 0 2px;
  vertical-align: super; display: inline-block; min-width: 20px; text-align: center; }
.fa-cite:hover { text-decoration: underline; }

/* Scenario */
.fa-scenario { display: grid; gap: var(--space-2); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.fa-scenario:first-of-type, .fa-sub + .fa-scenario { border-top: none; padding-top: 0; }

/* Navigation: top bar on desktop, bottom bar on a phone. */
.fa-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 var(--space-4); min-height: 56px; }
.fa-top nav { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.fa-top a { color: var(--ink); text-decoration: none; font-weight: 600; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.fa-top .fa-btn-link { white-space: nowrap; }
.fa-top a[aria-current="page"] { color: var(--accent); background: var(--surface-sunken); }
.fa-bottom { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); box-shadow: var(--shadow-bar); }
.fa-bottom a { display: grid; justify-items: center; gap: 2px; padding: var(--space-2) 2px; min-height: 56px; min-width: 0; color: var(--ink-muted);
  text-decoration: none; font-size: 11px; line-height: 14px; font-weight: 600; white-space: nowrap; }
.fa-bottom a[aria-current="page"] { color: var(--accent); }
.fa-bottom svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Disclosure */
.fa-details { border-top: 1px solid var(--line); padding: var(--space-2) 0; }
.fa-details:first-child { border-top: none; }
.fa-details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: var(--space-2); list-style: none; }
.fa-details summary::-webkit-details-marker { display: none; }
.fa-details summary::before { content: "\25B8"; color: var(--ink-muted); width: 1em; }
.fa-details[open] > summary::before { content: "\25BE"; }
.fa-details[open] > summary { margin-bottom: var(--space-2); }

/* 3. Layout ------------------------------------------------------------ */
body { margin: 0; min-height: 100vh; }
body.fa-root a { color: var(--accent); }
/* Navigation keeps its own colours: the current page in accent, the rest neutral. */
body.fa-root .fa-top nav a { color: var(--ink); }
body.fa-root .fa-top nav a[aria-current="page"] { color: var(--accent); }
body.fa-root .fa-bottom > a { color: var(--ink-muted); }
body.fa-root .fa-bottom > a[aria-current="page"] { color: var(--accent); }
body.fa-root .fa-more-menu a { color: var(--ink); }
body.fa-root .fa-more-menu a[aria-current="page"] { color: var(--accent); }
code { font-family: var(--font-mono); font-size: 13px; }
h1, h2, h3 { text-wrap: balance; }
.fa-main { max-width: 1120px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-6);
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--space-4); }
.fa-main > * { min-width: 0; }
.fa-main-narrow { max-width: 860px; }
.fa-main-login { max-width: 420px; min-height: 100vh; align-content: center; }
.fa-h1 { margin: 0; font-size: 26px; line-height: 32px; font-weight: 650; letter-spacing: -0.01em; }
.fa-titlerow { display: flex; justify-content: space-between; align-items: end; gap: var(--space-3); flex-wrap: wrap; }
.fa-titleblock { display: grid; gap: var(--space-1); min-width: 0; }
.fa-field-sm { width: 120px; }
.fa-field-md { width: 280px; max-width: 100%; }
.fa-lead { font-size: 17px; line-height: 24px; font-weight: 600; margin: 0; }
.fa-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: var(--space-4); align-items: start; }
.fa-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: var(--space-4); align-items: start; }
.fa-acct { display: block; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.fa-chat { display: flex; gap: var(--space-3); align-items: end; flex-wrap: wrap; }
.fa-chat .fa-field { flex: 1 1 260px; }
.fa-jump { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.fa-jump a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-weight: 600; font-size: 13px; }
.fa-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-3); }
.fa-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 var(--space-4); }
.fa-row-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: end; }
.fa-scenario.fa-voided .fa-item { text-decoration: line-through; color: var(--ink-muted); }
.fa-chart canvas { width: 100%; max-height: 260px; }
.fa-back { font-size: 13px; display: inline-flex; align-items: center; min-height: 44px; }
/* Inline actions (Edit, Void) with a 44px touch area. */
.fa-tap { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-2); }
.fa-row-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 var(--space-3); }
.fa-row-actions .fa-details { border-top: none; padding: 0; }
/* Skip link: hidden until it gets keyboard focus. */
.fa-skip { position: absolute; left: var(--space-4); top: -100px; z-index: 20; background: var(--surface); padding: var(--space-2) var(--space-3);
  border: 2px solid var(--focus-ring); border-radius: var(--radius-sm); font-weight: 600; }
.fa-skip:focus { top: var(--space-2); }
.fa-inline { display: inline; margin: 0; }
.fa-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Navigation: the top bar from 900px; below that the five-slot bottom bar,
   whose More slot is a native <details> (no script needed). */
.fa-top { position: sticky; top: 0; z-index: 10; }
.fa-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding-bottom: env(safe-area-inset-bottom, 0px); }
.fa-more { position: relative; display: grid; }
.fa-more > summary { display: grid; justify-items: center; gap: 2px; padding: var(--space-2) 2px; min-height: 56px; cursor: pointer;
  color: var(--ink-muted); font-size: 11px; line-height: 14px; font-weight: 600; list-style: none; }
.fa-more > summary::-webkit-details-marker { display: none; }
.fa-more[open] > summary, .fa-more.fa-current > summary { color: var(--accent); }
.fa-more-menu { position: absolute; right: var(--space-2); bottom: calc(100% + var(--space-2)); min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-2);
  display: grid; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.fa-bottom .fa-more-menu a, .fa-more-menu button { display: flex; align-items: center; min-height: 44px; padding: 0 var(--space-3);
  font-size: 15px; font-weight: 600; color: var(--ink); text-decoration: none; border-radius: var(--radius-sm); justify-items: start; }
.fa-more-menu a[aria-current="page"] { color: var(--accent); background: var(--surface-sunken); }
.fa-more-menu form { margin: 0; }
.fa-more-menu button { width: 100%; background: none; border: none; font: inherit; font-weight: 600; cursor: pointer; }
@media (min-width: 900px) { .fa-bottom { display: none; } }
@media (max-width: 899px) {
  .fa-top { display: none; }
  body.fa-root { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .fa-main { padding-top: var(--space-4); gap: var(--space-3); }
}

/* Show one of two layouts of the same data (the ledger). */
@media (max-width: 719px) { .fa-only-wide, .fa-hide-narrow { display: none; } }
@media (max-width: 719px) {
  /* Rule tables on a phone: the rule name takes half the width, the draft mark sits under the pill. */
  .fa-rules td:first-child { width: 50%; }
  .fa-rules .fa-mark { display: block; }
  .fa-rules .fa-state { white-space: normal; }
  .fa-table th, .fa-table td { padding: var(--space-2); }
}
@media (min-width: 720px) { .fa-only-narrow { display: none; } }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
