/* Theme tokens.
 *
 * Dark is the document default (declared on :root). body[data-theme="light"]
 * overrides; body[data-theme="auto"] inherits dark unless the OS prefers light
 * (the @media block below). data-theme attribute is set by base.html from
 * users.theme (default 'auto').
 *
 * Overlay tokens (--overlay-*, --nav-bg, --chart-*) hold the rgba values that
 * used to be hardcoded as `rgba(255,255,255,0.x)` (dark-only). Routing them
 * through tokens lets light theme invert to `rgba(0,0,0,0.x)` without
 * touching every callsite. */
:root {
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter',
          'PingFang TC', 'Heiti TC', 'Microsoft JhengHei UI', 'Microsoft JhengHei',
          'Noto Sans TC', 'Source Han Sans TC',
          system-ui, sans-serif;
  --ease-apple: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* Dark palette — default. */
  --bg: #0c1017;
  --surface: #161b24;
  --surface2: #1e2430;
  --surface3: #252c3a;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(108,142,245,0.25);
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #8b9db3;
  --accent: #6c8ef5;
  --accent-dim: #1e2d5a;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
  --overlay-soft: rgba(255,255,255,0.06);
  --overlay-medium: rgba(255,255,255,0.08);
  --overlay-strong: rgba(255,255,255,0.2);
  --nav-bg: rgba(22,27,36,0.82);
  --bottom-nav-bg: rgba(22,27,36,0.88);
  --modal-overlay: rgba(0,0,0,0.4);
  --chart-tooltip-bg: rgba(22,27,36,0.95);
  --chart-tooltip-border: rgba(255,255,255,0.08);
  --chart-grid: #252c3a;
  --alert-warning-bg: rgba(251,191,36,0.12);
  --alert-warning-border: rgba(251,191,36,0.35);
  --row-hover: rgba(255,255,255,0.03);
  --row-divider: rgba(255,255,255,0.04);
  --row-divider-strong: rgba(255,255,255,0.06);
  --bg-gradient-radial: rgba(255,255,255,0.03);
  /* Admin cohort retention cells. Order: 100% retained → 0% → future. */
  --cohort-r-100: rgba(34,197,94,0.30);
  --cohort-r-75:  rgba(34,197,94,0.20);
  --cohort-r-50:  rgba(251,191,36,0.20);
  --cohort-r-25:  rgba(248,113,113,0.18);
  --cohort-r-0:   rgba(148,163,184,0.10);
}

body[data-theme="light"] {
  /* Light theme palette shifted one step darker on bg + surface2/3 so
   * the white card surfaces stand out against the page. Pre-2026-05-08
   * --bg #f8fafc on --surface #ffffff was a 0.6% luminance gap; cards
   * disappeared into the page on properties/insurance/vehicles empty
   * states (UX review P0-1). Now slate-100 → white = ~3% gap. The
   * --shadow-sm token below also kicks in on cards via .card. */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #e2e8f0;
  --surface3: #cbd5e1;
  --border: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(79,109,217,0.4);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #4f6dd9;
  --accent-dim: #dbe4ff;
  --green: #059669;
  --red: #dc2626;
  --yellow: #d97706;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 8px 32px rgba(15,23,42,0.12);
  --overlay-soft: rgba(15,23,42,0.04);
  --overlay-medium: rgba(15,23,42,0.06);
  --overlay-strong: rgba(15,23,42,0.18);
  --nav-bg: rgba(255,255,255,0.85);
  --bottom-nav-bg: rgba(255,255,255,0.92);
  --modal-overlay: rgba(15,23,42,0.35);
  --chart-tooltip-bg: rgba(255,255,255,0.97);
  --chart-tooltip-border: rgba(15,23,42,0.08);
  --chart-grid: #e2e8f0;
  --alert-warning-bg: rgba(217,119,6,0.10);
  --alert-warning-border: rgba(217,119,6,0.32);
  --row-hover: rgba(15,23,42,0.03);
  --row-divider: rgba(15,23,42,0.04);
  --row-divider-strong: rgba(15,23,42,0.07);
  --bg-gradient-radial: rgba(15,23,42,0.02);
  /* Cohort cells — slightly more saturated on light to stay readable
   * against the lighter surface. */
  --cohort-r-100: rgba(5,150,105,0.22);
  --cohort-r-75:  rgba(5,150,105,0.14);
  --cohort-r-50:  rgba(217,119,6,0.16);
  --cohort-r-25:  rgba(220,38,38,0.14);
  --cohort-r-0:   rgba(100,116,139,0.10);
}

@media (prefers-color-scheme: light) {
  body[data-theme="auto"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface2: #f1f5f9;
    --surface3: #e2e8f0;
    --border: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(79,109,217,0.4);
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent: #4f6dd9;
    --accent-dim: #dbe4ff;
    --green: #059669;
    --red: #dc2626;
    --yellow: #d97706;
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
    --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
    --shadow-lg: 0 8px 32px rgba(15,23,42,0.12);
    --overlay-soft: rgba(15,23,42,0.04);
    --overlay-medium: rgba(15,23,42,0.06);
    --overlay-strong: rgba(15,23,42,0.18);
    --nav-bg: rgba(255,255,255,0.85);
    --bottom-nav-bg: rgba(255,255,255,0.92);
    --modal-overlay: rgba(15,23,42,0.35);
    --chart-tooltip-bg: rgba(255,255,255,0.97);
    --chart-tooltip-border: rgba(15,23,42,0.08);
    --chart-grid: #e2e8f0;
    --alert-warning-bg: rgba(217,119,6,0.10);
    --alert-warning-border: rgba(217,119,6,0.32);
    --row-hover: rgba(15,23,42,0.03);
    --row-divider: rgba(15,23,42,0.04);
    --row-divider-strong: rgba(15,23,42,0.07);
    --bg-gradient-radial: rgba(15,23,42,0.02);
    --cohort-r-100: rgba(5,150,105,0.22);
    --cohort-r-75:  rgba(5,150,105,0.14);
    --cohort-r-50:  rgba(217,119,6,0.16);
    --cohort-r-25:  rgba(220,38,38,0.14);
    --cohort-r-0:   rgba(100,116,139,0.10);
  }
}

/* Region gating: hide Taiwan-specific UI for intl-region users (tax
   breakdown, detailed payroll fields). Now keyed on data-region (set
   in base.html) instead of data-locale, so a user with English UI
   (locale='intl') + Taiwan features (region='tw') sees the TW-only
   UI in English. Pre-2026-05-05 these were locked together. */
body[data-region="intl"] .tw-only { display: none !important; }
body[data-region="tw"]   .intl-only { display: none !important; }

/* /home first-run AI-report tip pill (B3) — basic-tier users who
 * have data but haven't burned welcome see this nudging them to /reports. */
.ai-tip-pill {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(108,142,245,0.12), rgba(168,85,247,0.12));
  border: 1px solid var(--accent-dim);
  text-decoration: none; color: var(--text); font-size: 13px;
  margin-bottom: 16px;
  transition: filter 0.2s var(--ease-apple);
}
.ai-tip-pill:hover { filter: brightness(1.1); text-decoration: none; color: var(--text); }
.ai-tip-icon { font-size: 16px; flex-shrink: 0; }

/* One-time celebration banner shown on first /home after onboarding.
   More prominent than ai-tip-pill since it's a single-fire moment. */
.onb-celebration {
  border: 1px solid var(--accent-dim);
  background: linear-gradient(135deg, rgba(108,142,245,0.10), rgba(168,85,247,0.10));
}
.onb-celebration-body { display: flex; align-items: flex-start; gap: 14px; padding: 4px; }
.onb-celebration-icon { font-size: 28px; flex-shrink: 0; line-height: 1; }
.onb-celebration-cta { display: flex; flex-wrap: wrap; gap: 8px; }
.onb-celebration-close { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; flex-shrink: 0; }
.onb-celebration-close:hover { color: var(--text); }

/* One-time KPI explainer — same shape as the celebration banner but
 * neutral surface (no gradient) so it doesn't compete with the AI tip
 * pill or AI Insights card visually. */
.kpi-tip { border: 1px solid var(--border); background: var(--surface); }
.kpi-tip-body { display: flex; align-items: flex-start; gap: 14px; padding: 4px; }
.kpi-tip-icon { font-size: 22px; flex-shrink: 0; line-height: 1.2; }

/* /reports first-run readiness checklist (B2) — surfaced when the
 * user has zero past reports. Each item shows ✓ done (green) or ○ todo
 * (muted) with an inline link to the relevant page. */
.readiness-list { list-style: none; padding: 0; margin: 8px 0; max-width: 360px; margin-left: auto; margin-right: auto; }
.readiness-list li { padding: 8px 12px; border-radius: var(--radius-xs); margin-bottom: 4px; font-size: 13px; text-align: left; display: flex; align-items: center; gap: 6px; }
.readiness-done { background: rgba(34,197,94,0.08); color: var(--text-secondary); }
.readiness-todo { background: var(--surface2); color: var(--text); }
.readiness-icon { font-weight: 700; width: 16px; display: inline-block; text-align: center; }
.readiness-done .readiness-icon { color: #22c55e; }
.readiness-todo .readiness-icon { color: var(--text-muted); }

/* Demo mode banner — appears at the very top of every authed page when
 * the active session is the curated demo tenant (is_demo=1). The
 * accent gradient + 🎬 emoji telegraphs "this isn't your data" without
 * being noisy. Pushes the rest of the page down by its own height
 * (no fixed positioning) so layout calculations don't have to know
 * about it. body[data-demo="1"] could be used to add `padding-top` if
 * that ever becomes a problem. */
.demo-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(108,142,245,0.18), rgba(168,85,247,0.18));
  border-bottom: 0.5px solid var(--accent-dim);
  font-size: 12px; color: var(--text);
  flex-wrap: wrap;
  /* Stick directly under the fixed nav. z-index 199 sits below the nav
   * (200) so the nav's blur+saturate layer covers the banner edge when
   * they meet, and above page content (cards default ~0) so the banner
   * doesn't get covered when scrolling. Solid rgba background (no
   * transparency at the section level — gradient already provides the
   * brand wash) keeps it readable when content scrolls underneath. */
  position: sticky;
  /* -1px to slide under the nav's bottom border, otherwise a thin
   * 0.5/1px line of bare page colour shows between the two on hi-DPI
   * displays (esp. in light theme where the border colour contrasts
   * more). The banner's own gradient + backdrop-blur cover the seam. */
  top: calc(52px + env(safe-area-inset-top, 0px) - 1px);
  z-index: 199;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  /* Compositing hint — see .bottom-nav for full rationale (iOS keyboard
   * drift on position:sticky+backdrop-filter without an explicit layer). */
  transform: translateZ(0);
  will-change: transform;
}
/* When demo banner is present, drop the nav's bottom border. Pre-fix a
 * thin 0.5/1px slice of the nav border was visible on mobile / hi-DPI
 * displays between nav and banner even with the banner pulled up 1px;
 * the banner's gradient + backdrop-blur provide the visual separator
 * so the nav doesn't need its own bottom edge. */
body[data-demo="1"] nav { border-bottom: none; }

/* "Try auto-tune" pill next to the FIRE sliders. Visible only when the
 * user has manually dragged the slider (is_auto_tuned=0). Pre-2026-05-19
 * this was an icon-only ↻ — users couldn't tell whether clicking it
 * was destructive. Now: explicit "🪄 + label" pill with preview-only
 * click behavior. */
.autotune-reset {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px; line-height: 1.2; font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
  align-self: flex-end; margin-bottom: 2px;
  white-space: nowrap;
  transition: all 0.15s var(--ease-apple);
}
.autotune-reset:hover { color: var(--accent); border-color: var(--accent); background: var(--surface2); }
.autotune-reset-icon { font-size: 13px; line-height: 1; }
.demo-banner-icon { font-size: 14px; }
.demo-banner-text { font-weight: 500; }
.demo-banner-cta {
  font-weight: 600; color: var(--accent); text-decoration: none; padding: 2px 8px;
  border-radius: var(--radius-xs); background: var(--surface);
}
.demo-banner-cta:hover { background: var(--accent-dim); color: var(--accent); }
.demo-banner-actions { display: inline-flex; gap: 10px; align-items: center; }
.demo-banner-link {
  color: var(--text-muted); text-decoration: none; font-size: 11px;
  padding: 2px 6px; border-radius: var(--radius-xs);
}
.demo-banner-link:hover { color: var(--text); background: var(--surface); }

/* Payroll Simple/Advanced toggle (TW-region users only).
   Default = Simple: hide every tw-only element inside the payroll section
   + Add Salary modal so the user sees only Date / Gross / Tax / Net Pay.
   When body has .payroll-advanced (toggled by Salary section's button +
   persisted in localStorage), the rule above does NOT apply, so all
   detail fields/columns appear. Scope is intentionally tight — tax-params,
   home page, etc. retain tw-only behavior. */
body[data-region="tw"]:not(.payroll-advanced) #payroll-section .tw-only:not(#btn-payroll-mode),
body[data-region="tw"]:not(.payroll-advanced) #add-modal .tw-only {
  display: none !important;
}

/* Add Salary modal + payroll table — Simple/Detailed branch.
   Default = Simple: show Amount + Type dropdown in form, AND collapse the
   payroll table to [Date, Amount, Actions] only (the breakdown columns
   carry .detailed-mode-only on each th/td/tfoot cell).
   payroll-advanced flips it: full breakdown form fields + 14-col table.
   Universal across locales (intl users can only ever be in Simple
   since the toggle button is tw-only — they see Amount + Type natively).
   `display: revert` lets each element fall back to its UA default
   (block for div, table-cell for th/td, inline for span) instead of
   forcing block on a table cell which would break layout. */
.detailed-mode-only { display: none !important; }
body.payroll-advanced .simple-mode-only { display: none !important; }
body.payroll-advanced .detailed-mode-only { display: revert !important; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ── */
nav {
  background: var(--nav-bg);
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  min-height: 52px;
  height: auto;
  padding-top: env(safe-area-inset-top, 0);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  /* iOS Safari compositing hint — see .bottom-nav for full rationale. */
  transform: translateZ(0);
  will-change: transform;
}

.nav-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-right: 28px;
  letter-spacing: -0.3px;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }
.mobile-page-title { display: none; }

/* overflow:hidden (not overflow-x:auto) — fitNavLinks() in base.html
 * measures and moves trailing items into the More dropdown so the user
 * never sees a horizontal scroller in the top nav. The :hidden serves
 * as a safety net during the brief frame between resize and JS catch-up. */
.nav-links { display: flex; gap: 2px; flex: 1; align-items: center; overflow: hidden; min-width: 0; }

.nav-sep {
  width: 1px;
  height: 20px;
  background: var(--overlay-medium);
  margin: 0 8px;
  flex-shrink: 0;
}

.nav-links a, .nav-links .nav-logout-form button {
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s var(--ease-apple);
  white-space: nowrap;
}
.nav-links a:hover, .nav-links .nav-logout-form button:hover {
  background: var(--surface2); color: var(--text); text-decoration: none;
}
.nav-links a.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
/* Logout/demo-signup CTAs post via inline forms (POST-only — GET would let
 * cross-site links force-logout via SameSite=Lax). Button reset so it
 * matches surrounding text-link look; per-CTA classes paint the rest. */
.nav-logout-form, .bnav-logout-form, .demo-banner-cta-form, .demo-cta-form {
  display: inline; margin: 0; padding: 0;
}
/* :where() keeps specificity at 0 so per-button classes (.demo-banner-cta,
 * .btn-link, etc.) still win on background/color/padding. */
:where(.nav-logout-form, .bnav-logout-form, .demo-banner-cta-form, .demo-cta-form) button {
  background: transparent; border: none; cursor: pointer; font-family: inherit;
  color: inherit; font-size: inherit; text-align: left;
}

.nav-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; margin-left: 12px; }

/* ── Layout ── */
body { padding-top: calc(52px + env(safe-area-inset-top, 0px)); }
.container { max-width: 1400px; margin: 0 auto; padding: 24px 28px; }

/* AI consent modal bullet list — extracted from inline style="..." that
 * CSP rejects (review caught this 2026-05-09). Sized to read clearly at
 * the modal's compact width. */
.ai-consent-bullets { padding-left: 18px; line-height: 1.6; }

/* Quiet footer with legal links — required for Google OAuth verification
 * reviewer to find /privacy + /terms easily from any authed page. */
.site-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 28px 24px;
  text-align: center;
  border-top: 0.5px solid var(--row-divider);
}
.site-footer a { color: var(--text-muted); text-decoration: none; padding: 0 4px; }
.site-footer a:hover { color: var(--text-secondary); text-decoration: underline; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; letter-spacing: -0.4px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.3s var(--ease-apple), box-shadow 0.3s var(--ease-apple);
}
@media (hover: hover) {
  .card:hover { border-color: var(--border-hover); box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
}
/* Light theme: subtle resting shadow so cards lift off the slate-100 bg
 * even without hover (dark theme uses border + bg-luminance-step alone). */
body[data-theme="light"] .card { box-shadow: var(--shadow-sm); }
@media (prefers-color-scheme: light) {
  body[data-theme="auto"] .card { box-shadow: var(--shadow-sm); }
}

/* Details/Summary accordion with card styling */
details > summary.card { border-radius: var(--radius); position: relative; padding-right: 44px; }
details[open] > summary.card { border-radius: var(--radius) var(--radius) 0 0; border-bottom: none; margin-bottom: 0; }
details > summary.card::marker, details > summary.card::-webkit-details-marker { display: none; }
/* Chevron upgraded 2026-05-12 from 12px muted → 18px accent so the
 * "this expands" affordance is unambiguous on default-collapsed cards.
 * Bumped from ▸ char to ⌃ (larger surface, cleaner glyph). Pre-2026-05-13
 * used `float: right` which fell to a new line after the (block) <h2>
 * title and landed visually at the BOTTOM-right corner of the summary
 * box instead of vertically centered with the heading. Now absolute-
 * positioned at the vertical center of the summary, with parent gaining
 * padding-right to leave room (otherwise long titles slide under). */
details > summary.card::after {
  content: '⌄';
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  font-size: 18px;
  line-height: 1;
  color: var(--accent);
  transition: transform 0.25s var(--ease-apple);
}
details[open] > summary.card::after { transform: translateY(-50%) rotate(180deg); }

.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Property toggle chip */
.prop-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; min-height: 36px; border: 1.5px solid var(--accent);
  background: var(--accent); color: #fff;
  transition: all 0.2s var(--ease-apple); user-select: none;
}
.prop-chip.off {
  background: transparent; color: var(--text-muted); border-color: var(--border);
}
@media (hover: hover) { .prop-chip:hover { filter: brightness(1.15); } }

/* KPI card with left color bar */
.kpi-card {
  position: relative;
  padding-left: 28px;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}
.kpi-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--bg-gradient-radial) 0%, transparent 60%);
  pointer-events: none;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-value-hero {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.8px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Edit mode: icon buttons for table rows. 36×36 floor (was 32×32
 * pre-2026-05-04) so row-edit ✎/✕ controls meet the tap-target
 * minimum on mobile + tablet without an extra @media override. */
.btn-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface2);
  border: 0.5px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease-apple);
  position: relative;
}
.btn-icon-sm::before {
  content: '';
  position: absolute;
  inset: -6px;
}
.btn-icon-sm:hover { background: var(--surface3); border-color: var(--border-hover); color: var(--text); }
.btn-icon-sm.btn-danger { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.25); color: var(--red); }
.btn-icon-sm.btn-danger:hover { background: rgba(248,113,113,0.2); border-color: var(--red); }

/* Demo-blocked buttons: visually dimmed but still clickable so the
 * click handler can fire an explanation toast instead of the action.
 * Used on /home's Refresh + Generate AI Report when is_demo=1. */
.demo-blocked { opacity: 0.55; cursor: help; }
.demo-blocked:hover { opacity: 0.75; }
th.edit-actions, td.edit-actions { display: none !important; width: 0; padding: 0; border: none; }
span.edit-actions, div.edit-actions { display: none !important; }
.edit-mode th.edit-actions { display: table-cell !important; width: auto; padding: 6px 8px; }
.edit-mode td.edit-actions { display: flex !important; gap: 4px; align-items: center; width: auto; padding: 6px 8px; }
.edit-mode span.edit-actions { display: inline-flex !important; gap: 4px; align-items: center; }
.edit-mode div.edit-actions { display: flex !important; gap: 4px; align-items: center; }
.edit-mode .edit-toggle-btn { background: var(--accent); color: #fff; border-color: var(--accent); }
.edit-mode .edit-add-btn { display: inline-block !important; }

/* ── Grid ── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
/* auto-fit grid: adapts to N children without leaving orphan empty cells.
 * Use when child count is variable (e.g. family-member cards) and you'd
 * otherwise pick `.grid-N` arbitrarily and end up with awkward partial
 * rows at narrow widths. Cards stretch to fill, wrap as needed. */
.grid-auto-fit-160 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }

/* ── Tablet ── */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .container { padding: 16px; }
  .prop-summary-grid { grid-template-columns: 1fr !important; }
  /* P2-2: Property KPIs 2x2 instead of 1x4 stack */
  .prop-kpi-stack { flex-direction: row !important; flex-wrap: wrap !important; }
  .prop-kpi-stack > .card { flex: 1 0 calc(50% - 4px) !important; }
  .prop-kpi-stack .mono { font-size: 16px !important; }
}
/* Holdings/Property 3-chart row — stack to 1-col below 1100px (not 900).
 * 901-1100 was previously a 3-col grid but Chart.js canvas min-widths
 * forced uneven columns: at 920px the bar-chart card grabbed 342px while
 * Property Equity got squeezed to 219px (caught 2026-05-04). Stacking up
 * to 1100 gives each card the full container width so the line chart and
 * its slider/legend can render properly. ≥1101 keeps the 3-col grid
 * with `minmax(0, 1fr)` (set in inline_residual.css [data-s=home-20])
 * so the columns are forced equal width regardless of content min.
 *
 * `minmax(0, 1fr)` (NOT bare `1fr`, which is `minmax(auto, 1fr)`) is
 * critical here — Chart.js sets `style.width: NNNpx` inline on canvases.
 * When the viewport shrinks dynamically, that inline width prevents the
 * card from shrinking, causing horizontal page overflow until the user
 * reloads (caught 2026-05-05 from a live drag-resize repro). The 0-min
 * lets the card ignore content min-content so the grid column can
 * actually shrink, then the `canvas { max-width: 100% }` rule below
 * forces the canvas to follow, and Chart.js's ResizeObserver re-renders
 * at the new width. */
@media (max-width: 1100px) {
  .holdings-chart-grid { grid-template-columns: minmax(0, 1fr) !important; }
}
/* Global canvas overflow defense — Chart.js sets inline style.width on
 * every responsive canvas. Without max-width:100% the canvas keeps its
 * old wider size during a drag-resize and overflows the parent (caught
 * 2026-05-05). Non-responsive canvases (like #nw-sparkline with
 * responsive:false at 80px) are smaller than any parent, so the rule
 * is a no-op for them. */
canvas { max-width: 100%; }

.desktop-hide { display: none; }
.mobile-only { display: none; }

/* Chart accordion: summary visible on all viewports (collapsed-by-
 * default state needs an obvious expand affordance everywhere, not
 * just mobile). Pre-2026-05-12 desktop hid the summary entirely and
 * forced `open`; now the open attribute is gone from HTML so chart
 * starts collapsed everywhere with the standard ⌄ chevron header. */

/* ── More dropdown ── */
.more-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  border: 0.5px solid var(--overlay-medium);
  border-radius: var(--radius);
  padding: 6px;
  z-index: 999;
  min-width: 150px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}
.more-dropdown.open { display: flex; flex-direction: column; }
.more-dropdown a, .more-dropdown .bnav-logout-form button, .more-dropdown .demo-cta-form button {
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s var(--ease-apple);
  /* match the <a> in this dropdown which expects flex layout via parent gap */
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
}
.more-dropdown a:hover, .more-dropdown .bnav-logout-form button:hover, .more-dropdown .demo-cta-form button:hover {
  background: var(--surface2); color: var(--text);
}
.more-dropdown a.active { background: var(--accent-dim); color: var(--accent); }
/* Overflow nav items moved here by fitNavLinks() at narrow widths.
 * Border-bottom acts as a visual separator from the always-present
 * Settings/Reports/Manual rows below. Hidden when empty. */
.nav-overflow-section { display: flex; flex-direction: column; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.nav-overflow-section.hide { display: none; }
.nav-overflow-section a { padding: 8px 12px; border-radius: var(--radius-xs); color: var(--text-secondary); font-size: 13px; text-decoration: none; }
.nav-overflow-section a:hover { background: var(--surface2); color: var(--text); }
.nav-overflow-section a.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }

/* ── Bottom nav (mobile) ── */
.bottom-nav {
  display: none;
  position: fixed;
  top: auto;
  bottom: 0; left: 0; right: 0;
  /* min-height (not height) so the safe-area padding-bottom EXPANDS the
     container on iPhones with home indicator, instead of eating into
     the 60px and pushing button min-height (44px) out of the visible
     background. */
  min-height: 60px;
  background: var(--bottom-nav-bg);
  border-top: 0.5px solid var(--row-divider-strong);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding-bottom: env(safe-area-inset-bottom, 0);
  /* iOS Safari + backdrop-filter on position-fixed elements can drift during
     virtual keyboard show/hide (visual viewport ≠ layout viewport). Forcing
     a separate compositing layer via translateZ(0) makes Safari handle the
     transition robustly — the nav stays pinned during keyboard animation
     instead of jumping mid-transition. `will-change` hints the GPU. */
  transform: translateZ(0);
  will-change: transform;
}

/* Body scroll lock while a modal-overlay is open. Prevents iOS Safari's
   virtual keyboard from scrolling the page underneath, which then leaves
   a visual offset when the keyboard closes (the "nav drift" symptom).
   `touch-action: none` is intentionally NOT set — it would block scroll
   inside tall modal content too. `overflow: hidden` is enough to disable
   page scroll while keeping modal-internal scroll working. */
body.modal-locked {
  overflow: hidden;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 0 4px;
  min-height: 44px;
  flex: 1;
  transition: color 0.2s var(--ease-apple);
}
.bottom-nav a.active, .bottom-nav button.active { color: var(--accent); font-weight: 600; background: rgba(108,142,245,0.1); border-radius: var(--radius-sm); }
.bottom-nav .tab-icon { width: 22px; height: 22px; }
.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 8px 0 4px;
  min-height: 44px;
  flex: 1;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.2s var(--ease-apple);
}

/* ── Bottom More popup (slides up from bottom nav) ── */
.bottom-more-popup {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  left: 0; right: 0;
  background: var(--surface);
  border-top: 0.5px solid var(--overlay-medium);
  padding: 12px 16px 8px;
  z-index: 101;
  box-shadow: 0 -8px 32px var(--modal-overlay);
  flex-direction: column;
  gap: 2px;
  display: flex;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s var(--ease-apple), opacity 0.25s var(--ease-apple);
  border-radius: 16px 16px 0 0;
}
.bottom-more-popup.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.bottom-more-popup a, .bottom-more-popup button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s var(--ease-apple);
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  width: 100%;
  min-height: 44px;
}
.bottom-more-popup a:hover, .bottom-more-popup button:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.bottom-more-popup a.active { background: var(--accent-dim); color: var(--accent); }
.bottom-more-popup .bottom-more-link-quiet { color: var(--text-muted); font-size: 13px; min-height: 38px; padding: 8px 16px; }
.bottom-more-popup svg { width: 20px; height: 20px; flex-shrink: 0; }
.bottom-more-sep { height: 1px; background: var(--border); margin: 4px 0; }
.bottom-more-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-apple);
}
.bottom-more-backdrop.open { opacity: 1; pointer-events: auto; }

/* ── Mobile ── */
@media (max-width: 600px) {
  .bottom-nav { display: flex; }
  /* body padding-bottom keeps content above the fixed bottom nav (which
     is min-height 60px + safe-area-inset-bottom ~34px on iPhones). The
     historical extra `.container { padding-bottom: 84px }` rule below
     was DOUBLED on top of body's, leaving ~74px of unintended blank
     space between content and the nav — visible when scrolling to end
     of page on mobile. Body alone is sufficient. */
  /* padding-bottom = 60px (bottom-nav min-height) + safe-area + 16px
   * gap so the last card / chart doesn't land under the fixed nav.
   * 2026-05-05 had pushed this to +48px to fix chart-canvas overlap on
   * /holdings/cashflow/insurance — but on text-end pages (/home etc.)
   * it left a visible 48px gap of bare bg. 2026-05-12 audit: with the
   * card-level margin-bottom already in place from Phase 1 cleanup,
   * +16px is enough — no overlap recurrence at 375×812. If a future
   * full-bleed chart at page-end overlaps, add explicit margin-bottom
   * on that chart's container instead of bumping body padding. */
  body { padding-top: calc(44px + env(safe-area-inset-top, 0px)) !important; padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 16px) !important; }
  nav .nav-links { display: none !important; }
  nav .nav-sep { display: none; }
  nav .nav-actions { display: none !important; }

  nav {
    min-height: 44px;
    height: auto;
    padding: env(safe-area-inset-top, 0) 16px 0;
  }
  /* Mobile nav is 44px (not 52px), so the sticky banner needs to anchor
   * at 44px - 1px = 43px to sit flush. Otherwise a 7-9px slice of bare
   * page color shows between nav-bottom (44) and banner-top (51). */
  .demo-banner {
    top: calc(44px + env(safe-area-inset-top, 0px) - 1px);
  }
  .nav-brand { font-size: 14px; margin-right: 0; }
  .mobile-page-title { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-left: auto; }
  .page-title { display: none; }

  .container { padding: 16px; margin-top: 4px; }

  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-2 { grid-template-columns: 1fr; gap: 10px; }
  .grid-3 { grid-template-columns: 1fr; gap: 10px; }

  .card { padding: 16px; border-radius: var(--radius); }
  .stat-value { font-size: 20px; }
  .stat-value-hero { font-size: 28px; }
  .stat-sub { font-size: 10px; }

  table { font-size: 12px; }
  thead th { padding: 8px 10px; font-size: 10px; }
  td { padding: 8px 10px; }
  td.mono { font-size: 11px; }

  /* Hide secondary columns on mobile, show mobile-only content */
  .mobile-hide { display: none !important; }
  .desktop-hide { display: inline !important; }
  .mobile-only { display: block !important; }

  /* Table horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Flex containers allow wrapping */
  .flex-between { flex-wrap: wrap; gap: 8px; }

  /* DB Inspector mobile */
  .dbview-layout { flex-direction: column !important; }
  .dbview-sidebar { min-width: 0 !important; }
  #table-list { max-height: 120px; overflow-y: auto; }

  /* More dropdown hidden on mobile — use bottom popup instead */
  .more-dropdown { display: none !important; }
  .mobile-more-btn { display: none !important; }

  /* Property page mobile */
  /* Side-by-side panels (loan, floor plan, deco): stack vertically */
  #prop-panel .prop-tab [style*="display:flex"] { flex-wrap: wrap !important; }
  #prop-panel [style*="flex:1"][style*="min-width"] { flex: 1 0 100% !important; }
  #prop-panel [style*="min-width"] { min-width: 0 !important; }
  /* Inline grids to single column */
  #prop-panel [style*="display:grid"] { grid-template-columns: 1fr !important; gap: 8px !important; }
  /* Chart area: contain canvas, prevent bleed */
  #prop-panel .grid-2 .card { overflow: hidden; }
  #prop-panel canvas { display: block; max-width: 100%; }
  /* Cost Breakdown: donut + legend wrap on mobile */
  /* KPI boxes */
  #prop-panel [style*="border-radius:8px"][style*="padding:10px"] { overflow: hidden; word-break: break-word; }
  #prop-panel .mono { font-size: 14px !important; }
  /* Cost donut smaller on mobile */
  #prop-panel [style*="width:160px"] { width: 120px !important; height: 120px !important; }
  #prop-panel [style*="width:260px"] { width: 100% !important; }
  .prop-tabs { overflow-x: auto !important; -webkit-overflow-scrolling: touch; -webkit-mask-image: linear-gradient(to right, black 75%, transparent 100%); mask-image: linear-gradient(to right, black 75%, transparent 100%); }
  .prop-tabs button { flex-shrink: 0; }
  /* Slider labels: bump from 10px to 12px on mobile */
  #cf-lifetime label { font-size: 12px !important; }
  /* Insurance coverage: 2-col instead of 1-col on mobile */
  .coverage-meta-grid { grid-template-columns: 1fr 1fr !important; }
  #prop-panel input[type="number"] { width: auto !important; max-width: 160px; height: 36px !important; padding: 4px 8px !important; font-size: 14px !important; }
  #prop-panel select { max-width: 140px; }

  /* ===== GLOBAL: Canvas & Chart containment ===== */
  canvas { display: block; max-width: 100%; }
  .card { overflow: hidden; }

  /* ===== GLOBAL: flex:1 + min-width panels → stack vertically ===== */
  [style*="flex:1"][style*="min-width"] { flex: 1 0 100% !important; min-width: 0 !important; }

  /* ===== GLOBAL: Donut + legend layouts → wrap & center ===== */
  [style*="display:flex"][style*="gap:24px"][style*="flex:1"],
  [style*="display:flex"][style*="gap:20px"][style*="flex:1"] {
    flex-wrap: wrap !important; justify-content: center; gap: 12px !important;
  }
  [style*="width:160px"][style*="height:160px"] { width: 120px !important; height: 120px !important; }
  [style*="width:140px"][style*="height:140px"] { width: 110px !important; height: 110px !important; }

  /* ===== GLOBAL: Chart flex containers → fixed height, no flex:1 grow ===== */
  [style*="flex:1"][style*="min-height"] {
    flex: none !important;
    height: 220px !important;
    min-height: 0 !important;
    position: relative;
    overflow: hidden;
  }
  [style*="min-height:280px"] { height: 240px !important; min-height: 0 !important; }

  /* ===== GLOBAL: Modals responsive ===== */
  .modal { max-width: 92vw !important; width: 92vw !important; }

  /* ===== GLOBAL: Filter selects + text inputs → constrain width ===== */
  .flex-between select[style*="width"],
  .card select[style*="width"],
  #holdings-section select[style*="width"] {
    width: auto !important; max-width: 110px; flex-shrink: 1;
  }
  .card input[type="text"][style*="width:"],
  .card input[type="number"][style*="width:"] {
    width: auto !important; max-width: 140px; flex-shrink: 1;
  }

  /* ===== GLOBAL: Inline grid → single column ===== */
  [style*="display:grid"][style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* ===== Home ===== */
  #fire-bar [style*="min-width"] { min-width: 0 !important; }

  /* ===== Retirement ===== */
  .card [style*="min-width:180px"] { min-width: 100% !important; }
  .card [style*="min-width:140px"] { min-width: calc(50% - 8px) !important; }
  .card [style*="min-width:200px"] { min-width: 100% !important; }
  .card [style*="min-width:130px"] { min-width: 100% !important; text-align: left !important; }

  /* ===== Holdings ===== */
  #filter-search { width: 100% !important; max-width: 160px; }

  /* ===== Income / Tax ===== */
  #tax-detail-panel [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  #annual-cards [style*="min-width"] { min-width: 0 !important; flex: 1 0 calc(50% - 6px) !important; }

  /* ===== Insurance ===== */
  .person-card .stat-value { font-size: 16px; }

  /* ===== Life Plan ===== */
  #family-ages [style*="min-width"] { min-width: 0 !important; flex: 1 0 calc(50% - 12px) !important; }

  /* ===== DB Inspector ===== */
  #db-search { width: 100% !important; max-width: 140px; }

  /* ===== Reports ===== */
  .report-sidebar { display: none !important; }
  .report-mobile-select { display: block !important; }
  .report-content { width: 100% !important; }

  .btn { padding: 7px 12px; font-size: 12px; }
  /* min-height:36px now lives on the base .btn-sm rule (line 886) so it
   * applies at all widths. Mobile only adjusts padding/font-size below. */
  .btn-sm { padding: 4px 8px; font-size: 10px; }

  .modal { padding: 22px; border-radius: 14px; }
  .form-row { grid-template-columns: 1fr; }

  .flex-between { flex-wrap: wrap; gap: 8px; }

  .family-pill { font-size: 11px; padding: 3px 10px 3px 6px; }
  .family-pill .age { font-size: 14px; }

  /* Home health indicators */
  [style*="grid-template-columns:repeat(6"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Report layout */
  .report-layout { flex-direction: column; }
  .report-sidebar { width: 100%; }

  /* Properties accordion */
  .acc-header { font-size: 13px; padding: 10px 12px; }

  /* Property tab bar: ensure 44px touch targets */
  .prop-tabs .btn-sm { min-height: 44px; padding: 8px 12px; font-size: 11px; }
  /* Property loan KPI grid: 2x2 on mobile instead of 4x1 */
  .loan-kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Range sliders + selects: larger touch targets */
  input[type="range"] { height: 36px; }
  select, input[type="text"], input[type="number"], input[type="date"] { min-height: 44px; }

  /* P2-1: Appreciation slider wider on mobile */
  #p-slider-appr { width: 100px !important; }

  /* P2-6: Landing user card padding */
  .user-card { padding: 24px 28px !important; min-width: 120px !important; }

  /* P2-10: Cashflow chart taller on mobile */
  .cf-chart-box { height: 240px !important; }

  /* Toast above bottom nav */
  #toast-container { bottom: 84px; right: 16px; left: 16px; max-width: calc(100vw - 32px); }
}

/* ── Table ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--row-divider-strong);
  white-space: nowrap;
  background: var(--surface2);
}
thead th:first-child { border-radius: var(--radius-xs) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-xs) 0 0; }
thead th.right { text-align: right; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable::after { content: ' ⇅'; font-size: 9px; color: var(--text-muted); opacity: 0.4; }
thead th.sortable:hover { color: var(--text); }
thead th.sortable.sort-asc::after { content: ' ▲'; opacity: 0.8; color: var(--accent); }
thead th.sortable.sort-desc::after { content: ' ▼'; opacity: 0.8; color: var(--accent); }

tbody tr {
  border-bottom: 0.5px solid var(--row-divider);
  transition: background 0.15s var(--ease-apple);
}
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child { border-bottom: none; }

td {
  padding: 10px 14px;
  vertical-align: middle;
}
td.right { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: "SF Mono", "Fira Code", monospace; font-size: 12px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-tw   { background: #141e40; color: #6c8ef5; }
.badge-us   { background: #1e142e; color: #a855f7; }
.badge-etf  { background: #2d2310; color: #fbbf24; }
.badge-crypto { background: #2a1010; color: #f87171; }
.badge-cash { background: #1a3a2e; color: #34d399; }
.badge-fund { background: #1f3a3f; color: #22d3ee; }
.badge-gold { background: #302a0e; color: #fde68a; }
/* Inline tag for "Premium add-on" features (BYOK, Sheets, etc.) shown next
   to a card title so the user understands the feature gating without a
   separate upsell card. Uses .badge sizing + Premium-purple palette. */
.badge-premium {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: #1e142e;
  color: #a855f7;
  vertical-align: middle;
  margin-left: 6px;
}

/* ── ROI colors ── */
.pos { color: var(--green); }
.neg { color: var(--red); }
.neu { color: var(--text-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s var(--ease-apple);
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary {
  background: linear-gradient(180deg, #7d9af7 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 1px 3px rgba(108,142,245,0.25);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #8ea6f9 0%, #5a7de8 100%);
  box-shadow: 0 2px 12px rgba(108,142,245,0.35);
  transform: translateY(-0.5px);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(108,142,245,0.2); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 0.5px solid var(--border);
}
.btn-outline:hover { background: var(--surface2); border-color: var(--border-hover); }

.btn-danger { background: rgba(248,113,113,0.15); color: var(--red); border: 0.5px solid rgba(248,113,113,0.2); }

/* Inline-text button — looks like a link but is semantically a <button>
 * (so screen readers + keyboards treat it as an action, not navigation).
 * Without this rule, `class="btn btn-link"` falls through to the
 * browser-default <button> background (pale grey pill on light theme,
 * dark pill on dark) which paired with .text-muted gave an unreadable
 * grey-on-grey button. Use anywhere a "▸ Show more / ▾ Hide" disclosure
 * trigger is needed inside text flow. */
.btn-link {
  background: transparent;
  border: none;
  text-decoration: none;
}
.btn-link:hover { background: transparent; text-decoration: underline; color: var(--accent); }
.btn-danger:hover { background: rgba(248,113,113,0.25); border-color: rgba(248,113,113,0.4); }

/* min-height: 36px is the tap-target floor — promoted from mobile-only
 * (was @media max-width:600px) to apply at all widths so tablets +
 * touch laptops also get the 36px hit area. Desktop dense layouts keep
 * their thin appearance via padding+font-size; the floor only kicks in
 * when the rendered button would otherwise be < 36px. */
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: var(--radius-xs); min-height: 36px; }

/* Segmented toggle (e.g. Theme picker) */
.theme-opt {
  background: transparent;
  color: var(--text-secondary);
  border: 0.5px solid transparent;
  font-weight: 500;
}
.theme-opt:hover { color: var(--text); }
.theme-opt[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

/* ── Focus styles (accessibility) ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:focus-visible { outline-offset: 1px; }
.nav-links a:focus-visible { outline-offset: 0; border-radius: var(--radius-xs); }
.bottom-nav a:focus-visible { outline-offset: -2px; }

/* Screen reader only */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.sr-only:focus { position: fixed; left: 0; top: 0; width: auto; height: auto; clip: auto; overflow: visible; z-index: 9999; padding: 8px 16px; background: var(--accent); color: #fff; border-radius: 0 0 8px 0; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  /* iOS Safari compositing hint — see .bottom-nav for full rationale. */
  transform: translateZ(0);
  will-change: transform;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 0.5px solid var(--overlay-medium);
  border-radius: 16px;
  padding: 28px;
  width: 480px;
  max-width: 95vw;
  /* dvh accounts for browser chrome + virtual keyboard on iOS 16.4+; vh is
     fallback for older Safari. With keyboard up, dvh shrinks so the modal
     stays scrollable instead of overflowing under the keyboard. */
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.2px;
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-hint { margin-top: 4px; line-height: 1.4; }

/* Symbol autocomplete dropdown — sits below the input inside the modal. */
.symbol-search-wrap { position: relative; }
.symbol-suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--overlay-medium);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 280px; overflow-y: auto; z-index: 100;
  padding: 4px;
}
.symbol-suggest-item {
  padding: 8px 10px; border-radius: var(--radius-xs); cursor: pointer;
  transition: background 0.1s var(--ease-apple);
}
.symbol-suggest-item:hover, .symbol-suggest-item.active {
  background: var(--surface2);
}
.symbol-suggest-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px;
}
.symbol-suggest-sym { font-weight: 600; color: var(--text); }
.symbol-suggest-meta { white-space: nowrap; }
.symbol-suggest-name {
  margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.symbol-suggest-empty { padding: 10px 12px; }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--overlay-medium);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,142,245,0.15);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 0.6; }
select option { background: var(--surface2); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row > .form-group { min-width: 0; }
.form-group select, .form-group input { width: 100%; box-sizing: border-box; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.loan-kpi-grid { grid-template-columns: repeat(4, 1fr); }
.prop-tabs button { flex-shrink: 0; min-width: 72px; }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  background: var(--surface);
  border: 0.5px solid var(--overlay-medium);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  animation: slide-in 0.25s var(--ease-apple);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes slide-in {
  from { transform: translateX(100%) scale(0.95); opacity: 0; }
  to   { transform: translateX(0) scale(1);       opacity: 1; }
}

/* ── Allocation chart ── */
.allocation-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin: 10px 0;
}

.alloc-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.alloc-item { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.alloc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Report viewer ── */
/* Property Regular tab: align monthly/yearly table columns */
#prop-tab-0 table th:nth-child(1), #prop-tab-0 table td:nth-child(1) { width: 30%; }
#prop-tab-0 table th:nth-child(2), #prop-tab-0 table td:nth-child(2) { width: 18%; }
#prop-tab-0 table th:nth-child(3), #prop-tab-0 table td:nth-child(3) { width: 22%; }
#prop-tab-0 table th:nth-child(4), #prop-tab-0 table td:nth-child(4) { width: 22%; }

.report-sidebar { width: 220px; flex-shrink: 0; }
.report-layout { display: flex; gap: 16px; align-items: flex-start; }
.report-content { flex: 1; min-width: 0; }
.report-list { display: flex; flex-direction: column; gap: 4px; }

.report-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 0.5px solid transparent;
  font-size: 13px;
  transition: all 0.2s var(--ease-apple);
}
.report-item:hover { background: var(--surface2); }
.report-item.active { background: var(--accent-dim); border-color: rgba(108,142,245,0.3); }
.report-item .report-status { font-size: 11px; margin-top: 2px; }

/* Markdown render */
.md-body h1 { font-size: 20px; margin: 20px 0 10px; }
.md-body h2 { font-size: 17px; margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 0.5px solid var(--border); }
.md-body h3 { font-size: 14px; margin: 14px 0 6px; color: var(--text-muted); }
.md-body p  { margin-bottom: 10px; line-height: 1.7; }
.md-body ul, .md-body ol { padding-left: 20px; margin-bottom: 10px; }
.md-body li { margin-bottom: 4px; }
.md-body table { margin: 12px 0; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.md-body th { background: var(--surface2); white-space: nowrap; }
.md-body td { white-space: nowrap; }
.md-body code { background: var(--surface2); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.md-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-muted); }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination .btn { min-width: 36px; justify-content: center; border-radius: var(--radius-sm); }

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--overlay-medium);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility classes ──
 * Phase A of style-src CSP tightening (2026-04-27): migrate the high-frequency
 * inline `style="..."` attrs into named utilities so we can drop 'unsafe-inline'
 * from style-src down the line. New utilities use literal-px naming for sizes
 * (`.fs-11`, `.w-140`, `.h-200`) and Tailwind 4-step for margins (`.mb-2` =
 * 8px, .mb-3 = 12px, .mb-4 = 16px). One-offs and compound styles are migrated
 * in later phases. */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.alert-warning {
  /* Theme-aware via CSS vars below. Was hardcoded dark-yellow rgba —
     too dim against light theme's white surface. */
  background: var(--alert-warning-bg);
  border: 0.5px solid var(--alert-warning-border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

/* Read-only inputs need a visual affordance — browser default leaves
   them looking identical to editable, so users tap, type, get nothing,
   and get confused. Faded background + not-allowed cursor makes the
   non-editability obvious. Applies to any <input readonly>; the
   tax-params modal and any future read-only display benefit. */
input[readonly] {
  background: var(--surface2);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.85;
}
input[readonly]:focus {
  outline: none;
  border-color: var(--border);  /* don't show edit-focus ring */
}

.mono { font-family: "SF Mono", "Fira Code", monospace; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-1 { flex: 1; }
.flex-half { flex: 0.5; }

.fs-9  { font-size: 9px; }
.fs-10 { font-size: 10px; }
.fs-11 { font-size: 11px; }
/* A11y contrast bump (locked 2026-05-09 from review): WCAG AA requires
 * 4.5:1 for "normal" text; <12px counts as normal. --text-muted is at
 * the borderline of AA on both themes so any layout drift can push it
 * sub-AA. When tiny size is paired with .text-muted, promote the color
 * one step to --text-secondary which clears AA comfortably on both
 * themes. Body text shouldn't be 9px regardless; new code should
 * prefer .fs-11 or larger. */
.fs-9.text-muted,
.fs-10.text-muted,
.fs-11.text-muted { color: var(--text-secondary); }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.fs-14 { font-size: 14px; }
.fs-22 { font-size: 22px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.m-0  { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-14 { margin-top: 14px; }
.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }

.p-10 { padding: 10px; }
.p-14 { padding: 14px; }
.p-16 { padding: 16px; }

.w-full { width: 100%; }
.w-120 { width: 120px; }
.w-140 { width: 140px; }
.h-200 { height: 200px; }
.maxw-320 { max-width: 320px; }

.cursor-p { cursor: pointer; }

/* Phase D (2026-04-27): visibility toggle. Replaces ~38 inline
 * style="display:none" attrs and ~47 JS el.style.display='none'/''
 * assignments. !important so it wins over any residual inline display.
 * Pair with classList.add/remove/toggle('hide', cond). */
.hide { display: none !important; }

/* Phase E classes that replace dynamic template-literal `style="${...}"`
 * sites. These are state-based (color/highlight per condition) — for
 * continuous values we use CSSOM (.style.setProperty) post-insertion. */
.cf-tpS { font-size: 11px; }
/* Tax Law section header — collapsible, always rendered (no jarring
   insert/remove on edit-toggle). Auto-opens in edit mode. */
.cf-tax-law-summary {
  font-weight: 600;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.cf-tax-law-summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.18s var(--ease-apple);
}
.cf-tax-law[open] > .cf-tax-law-summary::before { transform: rotate(90deg); }
.cf-tax-law-summary::-webkit-details-marker { display: none; }
.cf-tax-law-summary::marker { display: none; }

/* Loan-tab full amortization schedule. Collapsed by default since 360
   rows is too dense for the default tab view. .cf-amort-wrap caps height
   so the table scrolls within the container instead of pushing the
   prepayment calculator off the page. */
.cf-amort-summary { padding: 8px 0; border-top: 1px solid var(--border); }
.cf-amort-summary:hover { background: var(--row-hover); }
.cf-amort-summary::-webkit-details-marker { display: none; }
.cf-amort-summary::marker { display: none; }
.cf-amort-details[open] > .cf-amort-summary > span:first-child { color: var(--accent); }
/* overflow-x:auto + -webkit-overflow-scrolling:touch matches the canonical
 * .table-wrap pattern so the amortization table is horizontally scrollable
 * on narrow widths AND the iOS rubber-band scroll feels native. Pre-fix
 * the wrap declared only overflow-y, browsers computed overflow-x as auto
 * anyway but rendered no scrollbar / no fade hint — at 375px the BALANCE
 * column was off-screen and unreachable. */
.cf-amort-wrap { max-height: 480px; overflow-x: auto; overflow-y: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius-xs); }
.cf-amort-wrap table { width: 100%; }
.cf-amort-wrap thead th {
  position: sticky; top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.cf-amort-wrap td { padding: 4px 8px; border-bottom: 1px dashed var(--row-divider); }
.cf-win { color: var(--green); font-weight: 700; }
.cf-totals-win { font-size: 14px; color: var(--green); font-weight: 700; }
.cf-totals-mt { font-size: 14px; color: var(--text-muted); }
.cf-refund-pos { color: var(--green); }
.cf-refund-neg { color: var(--red); }
.cf-refund-hero { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.cf-refund-hero-pos { color: var(--green); }
.cf-refund-hero-neg { color: var(--red); }
.cf-bonus-row { background: rgba(245,166,35,0.05); }
.cf-bonus-row-past { background: rgba(245,166,35,0.05); opacity: 0.55; }
.rec-action { font-weight: 600; }
.rec-action-buy  { color: var(--green); }
.rec-action-sell { color: var(--red); }
.rec-action-hold { color: var(--text); }
.rec-conf-high   { color: var(--green); }
.rec-conf-medium { color: var(--yellow); }
.rec-conf-low    { color: var(--red); }
.pill-status { padding: 2px 10px; border-radius: 999px; font-size: 10px; font-weight: 600; }
.pill-status-pending  { background: rgba(234,179,8,0.15);  color: #eab308; }
.pill-status-accepted { background: rgba(34,197,94,0.15);  color: #22c55e; }
.pill-status-revoked  { background: var(--surface);        color: var(--text-muted); }
.pill-status-rejected { background: var(--surface);        color: var(--text-muted); }
.report-status-completed { color: #22c55e; }
.report-status-running   { color: #f59e0b; }
.report-status-pending   { color: #6c8ef5; }
.report-status-failed    { color: #ef4444; }
.bar-fill { height: 100%; background: var(--accent); transition: width .3s; }
.bar-fill-warn { background: var(--red); }
/* Property row in holdings table — color matches ALLOC_COLORS.property in api.js. */
.holdings-property-row { background: rgba(249,115,22,0.06); border-left: 3px solid #f97316; }
/* Recurring patterns extracted from inline_residual.css for readability. */
.btn-tiny { padding: 2px 8px; font-size: 10px; }
.donut-wrap { width: 160px; height: 160px; flex-shrink: 0; position: relative; }
/* Awkward middle range (3-up grid still active but each card narrows): scale
 * the donut + legend gap down so the legend has room to breathe. Below 900
 * the grid collapses to 1-col and the full 160px donut fits comfortably. */
@media (min-width: 901px) and (max-width: 1100px) {
  .grid-3 .donut-wrap { width: 120px; height: 120px; }
  .grid-3 .gap-20 { gap: 12px; }
}
.section-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
/* Expense-row badges. Source order matters: post-retire's border-left
 * MUST come after the W variant so it wins when both classes apply
 * (matches the original JS string-concat behavior). */
.expense-row-w { border-left: 3px solid #f59e0b; background: rgba(245,158,11,0.05); }
.expense-row-post-retire { border-left: 3px solid #a855f7; background: rgba(168,85,247,0.05); }
.expense-row-no-retire { opacity: 0.45; }
/* Section header row separating monthly recurring from annual bills
 * in the cashflow expense table (locked 2026-05-11). Subtle bg shift
 * + bold label; subtotal renders right-aligned in the Annual column
 * so it lines up with the per-row Annual numbers below. */
.expense-section-header td { background: var(--surface2); padding-top: 8px; padding-bottom: 8px; }
.expense-section-header td:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.expense-section-header td:last-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.js-error-card { padding: 24px; color: var(--red); }
.js-error-title { font-weight: 700; margin-bottom: 8px; }
.js-error-msg { font-size: 13px; }
.js-error-src { font-size: 11px; margin-top: 4px; }
.chart-empty-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 13px; pointer-events: none; z-index: 1; }

/* Phase B additions (2026-04-27): compound utilities for the next slice
 * of inline-style migrations. */
.mb-1 { margin-bottom: 4px; }
.mt-1 { margin-top: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.text-center { text-align: center; }
.text-yellow { color: var(--yellow); }
.flex-col { display: flex; flex-direction: column; }
.flex-grow-200 { flex: 1; min-width: 200px; }
.flex-grow-min { flex: 1; min-width: 0; }
.flex-160 { flex: 0 0 160px; }
.flex-wrap-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Phase C additions (2026-04-27): non-Tailwind-step margins (literal px),
 * a couple more sizes, semantic colors, and a handful of compound classes
 * for repeating per-page layouts. */
.mb-2px  { margin-bottom: 2px; }
.mb-6px  { margin-bottom: 6px; }
.mb-10px { margin-bottom: 10px; }
.mb-14px { margin-bottom: 14px; }
.mt-6px  { margin-top: 6px; }
.mt-10px { margin-top: 10px; }
.ml-4px  { margin-left: 4px; }
.py-3px  { padding: 3px 0; }
.fs-15 { font-size: 15px; }
.fs-18 { font-size: 18px; }
.text-red       { color: var(--red); }
.text-secondary { color: var(--text-secondary); }
.items-center { align-items: center; }
.list-none    { list-style: none; }
.gap-12 { gap: 12px; }
.gap-20 { gap: 20px; }
.p-12 { padding: 12px; }
.maxw-600 { max-width: 600px; }
.w-160 { width: 160px; }
.h-160 { height: 160px; }
.h-280 { height: 280px; }

/* Compound page-flavor classes — used in multiple templates so they earn
 * a name. One-off layouts stay inline (Phase D will surface them via
 * scoped <style> blocks if needed). */
.tile-center {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.chart-container {
  flex: 1;
  min-height: 220px;
  position: relative;
  overflow: hidden;
}
.flex-toolbar-end {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  justify-content: flex-end;
}
.row-tile {
  padding: 12px 14px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.tab-card-bottom {
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Family pills ── */
.family-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 0.5px solid var(--row-divider-strong);
  border-radius: 20px;
  padding: 5px 14px 5px 10px;
  font-size: 12px;
  transition: border-color 0.2s var(--ease-apple);
}
.family-pill:hover { border-color: var(--border-hover); }
.family-pill .age {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

/* ── Accessibility: Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Phase E follow-up: dedupe of inline_residual.css 2x duplicates. */
.chart-280 { position: relative; height: 280px; }
.items-end { align-items: flex-end; }
.text-green { color: var(--green); }
.flex-row-24-start { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.empty-state { text-align: center; padding: 40px 0; color: var(--text-muted); }
.mt-18px { margin-top: 18px; }
.flex-110 { flex: 0 0 110px; }
.flex-100 { flex: 0 0 100px; }
.flex-90 { flex: 0 0 90px; }
.float-right { float: right; }
.flex-row-16-mb { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.flex-row-16-mb-2 { display: flex; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.flex-grow-240 { flex: 1; min-width: 240px; }
.tile-soft { background: var(--surface2); border-radius: 8px; padding: 12px; font-size: 13px; }
.flex-sb { display: flex; justify-content: space-between; }
.help-text { font-size: 13px; margin-top: 6px; line-height: 1.55; }
.flex-grow-220 { flex: 1; min-width: 220px; }
.col-span-2 { grid-column: span 2; }
.gap-4 { gap: 4px; }

/* ── Settings page: sticky sub-nav + section grouping ── */
.settings-subnav {
  position: sticky;
  top: calc(52px + env(safe-area-inset-top, 0px));
  z-index: 10;
  display: flex;
  gap: 4px;
  padding: 10px 0;
  margin: -4px 0 16px;
  background: var(--bg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 0.5px solid var(--border);
  scrollbar-width: thin;
}
.settings-subnav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  transition: background 0.15s var(--ease-apple), color 0.15s var(--ease-apple);
}
.settings-subnav a:hover { background: var(--overlay-soft); color: var(--text); }
.settings-subnav a.active { background: var(--accent-dim); color: var(--text); }
.settings-section {
  scroll-margin-top: calc(52px + 60px + env(safe-area-inset-top, 0px));
  margin-bottom: 32px;
}
.settings-h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
  margin: 0 0 12px;
  padding-top: 4px;
}
