/* ============================================================
   PREMIUM REDESIGN — v30
   ------------------------------------------------------------
   Prepended at the top so it overrides downstream rules.
   Adds: refined typography, sidebar layout, tagline+H1 pattern,
   premium KPI tiles, hairline cards, dense data tables.
   Keeps: all existing class names so JS doesn't need to change.
   ============================================================ */

:root {
  /* Layered surfaces */
  --canvas: #fafbfc;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f4;

  /* Hairlines — barely-there borders that define cards crisply */
  --hairline: #e5e7eb;
  --hairline-strong: #d1d5db;
  --hairline-soft: #f1f3f5;

  /* Ink scale — pure black for primary, calibrated grays for hierarchy */
  --ink: #0b0f17;
  --ink-2: #1f2937;
  --ink-3: #475569;
  --ink-soft: #94a3b8;

  /* Brand — signature emerald */
  --brand-50:  #ecfdf5;
  --brand-100: #d1fae5;
  --brand-200: #a7f3d0;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;

  /* Semantic */
  --positive: #15803d;
  --negative: #b91c1c;
  --caution:  #d97706;
  --info:     #2563eb;

  /* Premium shadows — subtle, layered */
  --shadow-card:        0 1px 3px rgba(11, 15, 23, 0.04), 0 1px 2px rgba(11, 15, 23, 0.03);
  --shadow-card-hover:  0 4px 12px rgba(11, 15, 23, 0.06), 0 2px 4px rgba(11, 15, 23, 0.04);
  --shadow-pop:         0 8px 32px rgba(11, 15, 23, 0.12), 0 2px 8px rgba(11, 15, 23, 0.06);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-card: 14px;
  --r-tile: 16px;
  --r-hero: 20px;

  /* Override legacy tokens used by older CSS */
  --bg: var(--canvas);
  --bg-elev: var(--surface);
  --bg-soft: var(--surface-2);
  --bg-tint: var(--surface-3);
  --border: var(--hairline);
  --border-soft: var(--hairline-soft);
  --text: var(--ink);
  --text-2: var(--ink-3);
  --text-3: var(--ink-soft);
  --primary: var(--brand-600);
  --primary-hover: var(--brand-700);

  /* Layout */
  --sidebar-w: 256px;
  --header-h: 72px;
}

html, body {
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  /* cv11 removed — it enables slashed/dotted zero in Inter. ss01/ss02 removed
     too since they can also trigger alternate digit forms. Standard zeros only. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   App shell — desktop is sidebar + main; mobile is main + bottom nav.
   ============================================================ */
/* ============================================================
   APP LAYOUT — single source of truth for #app sizing.
   Mobile: flex column. Desktop ≥900px: grid with sidebar.
   Using #app everywhere so specificity is uniform.
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  /* CRITICAL: height (not min-height) so body stays at viewport height and
     main-content scrolls internally. min-height lets #app grow past the
     viewport which kills body-level scroll on mobile (iOS Safari). */
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;         /* contain; main-content is the scroller */
  background: var(--canvas);
}
#app.hidden { display: none; }

/* SIDEBAR — hidden by default on mobile; shown via grid layout on desktop
   (≥900px). All sidebar layout/positioning is in the APP SHELL section. */
.sidebar {
  display: none;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 24px;
  border-bottom: 1px solid var(--hairline-soft);
  margin-bottom: 16px;
}
.sidebar-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: 18px;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}
.sidebar-brand-text {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700; font-size: 18px;
  color: var(--ink); letter-spacing: -0.3px;
}

.sidebar-nav {
  display: flex; flex-direction: column;
  gap: 2px;
  flex: 1;
}
.side-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: transparent; border: 0;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background-color 0.15s, color 0.15s;
}
.side-btn:hover { background: var(--surface-2); color: var(--ink); }
.side-btn.active {
  background: var(--brand-50);
  color: var(--brand-700);
}
.side-btn.active::before {
  content: ''; position: absolute;
  left: -16px; top: 8px; bottom: 8px;
  width: 3px; background: var(--brand-600);
  border-radius: 0 3px 3px 0;
}
.side-icon {
  width: 20px; text-align: center;
  font-size: 16px; color: var(--ink-soft);
}
.side-btn.active .side-icon { color: var(--brand-600); }
.side-label { flex: 1; }
.side-badge {
  background: var(--negative); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--hairline-soft);
}
.sidebar-version {
  font-size: 11px; color: var(--ink-soft);
  text-align: center; letter-spacing: 0.3px;
}

/* ============================================================
   Page header — tagline + display H1 pattern.
   Used by every view via App.pageHeader() helper.
   ============================================================ */
.ph-wrap {
  padding: 28px 24px 24px;
  max-width: 1280px;
  margin: 0 auto;
}
@media (min-width: 900px) {
  .ph-wrap { padding: 36px 40px 28px; }
}
.ph-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.ph-titles { flex: 1; min-width: 0; }
.ph-tagline {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--brand-600);
  margin-bottom: 8px;
}
.ph-tagline::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--brand-600);
  border-radius: 50%;
}
.ph-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 32px;
  letter-spacing: -0.6px;
  color: var(--ink);
  line-height: 1.1;
  margin: 0;
}
@media (min-width: 900px) {
  .ph-title { font-size: 38px; }
}
.ph-actions {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.ph-action-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.ph-action-btn:hover {
  background: var(--surface-2);
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-card);
}
.ph-action-btn.primary {
  background: linear-gradient(180deg, var(--brand-600), var(--brand-700));
  border-color: var(--brand-700);
  color: white;
  box-shadow: 0 1px 3px rgba(5, 150, 105, 0.3);
}
.ph-action-btn.primary:hover {
  background: linear-gradient(180deg, var(--brand-700), var(--brand-700));
}

/* Page content container */
.pc-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 120px;
}
@media (min-width: 900px) {
  .pc-wrap { padding: 0 40px 60px; }
}

/* ============================================================
   KPI tile row — Overview's signature element
   ============================================================ */
/* KPI row: authoritative layout is in the premium section below (~line 2819).
   This block was removed to eliminate a duplicate that confused the cascade. */
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-tile);
  padding: 22px;
  box-shadow: var(--shadow-card);
  position: relative;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.04);
}
.kpi-tile:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}
.kpi-tile-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.kpi-tile-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--brand-50);
  color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.kpi-tile-icon.amber { background: #fef3c7; color: #b45309; }
.kpi-tile-icon.violet { background: #ede9fe; color: #6d28d9; }
.kpi-tile-icon.rose { background: #ffe4e6; color: #be123c; }
.kpi-tile-arrow {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  border: 0;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.kpi-tile-arrow:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.kpi-tile-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.kpi-tile-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 28px;
  color: var(--ink);
  letter-spacing: -0.5px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-tile-sub {
  margin-top: 8px;
  font-size: 12px; color: var(--ink-3);
  font-weight: 500;
}
.kpi-tile-sub.positive { color: var(--positive); font-weight: 600; }
.kpi-tile-sub.negative { color: var(--negative); font-weight: 600; }

/* ============================================================
   Premium card — used for charts, sections, tables
   ============================================================ */
.p-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.p-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--hairline-soft);
}
.p-card-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--ink);
}
.p-card-title-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--brand-50);
  color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.p-card-action {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--brand-700);
  text-transform: uppercase;
  background: transparent; border: 0;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
}
.p-card-action:hover { color: var(--brand-600); }
.p-card-body { padding: 18px 22px 22px; }

/* Two-up card grid for Overview charts */
.card-row-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
/* On desktop (sidebar visible), both cards get equal width.
   Start at 900px — same breakpoint as the sidebar — so the layout
   is always consistent: sidebar+content = 2-col, content uses 2-col cards. */
@media (min-width: 900px) {
  .card-row-2 { grid-template-columns: 1fr 1fr; gap: 20px; }
}

/* ============================================================
   Premium data table — for "Active Instruments" on Overview etc.
   ============================================================ */
.p-table {
  width: 100%;
  border-collapse: collapse;
}
.p-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
}
.p-table thead th.num { text-align: right; }
.p-table tbody td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
}
.p-table tbody tr:last-child td { border-bottom: 0; }
.p-table tbody tr {
  cursor: pointer;
  transition: background-color 0.1s;
}
.p-table tbody tr:hover { background: var(--surface-2); }
.p-table td.num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.p-table .row-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: 10px;
  vertical-align: middle;
  overflow: hidden;
  flex-shrink: 0;
}
.p-table .row-icon img { width: 100%; height: 100%; object-fit: cover; }
.p-table .row-main {
  display: flex; align-items: center;
}
.p-table .row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.p-table .row-name {
  font-weight: 700; color: var(--ink); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-table .row-sub {
  font-size: 11px; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.3px; font-weight: 600;
}
.p-yield-pos { color: var(--brand-700); font-weight: 700; }
.p-yield-zero { color: var(--ink-soft); font-weight: 600; }

/* ============================================================
   Sync banner / Review banner — refined
   ============================================================ */
.sync-banner {
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  color: var(--brand-700);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.sync-banner a { color: var(--brand-700); font-weight: 700; text-decoration: none; }
.recon-banner.warning, .recon-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  margin-bottom: 18px;
}

/* ============================================================
   Refine existing hero/category/charts — soft updates
   ============================================================ */
.net-worth-hero {
  background: linear-gradient(135deg, #0b0f17 0%, #1f2937 100%);
  border-radius: var(--r-hero);
  padding: 36px 28px;
  margin-bottom: 24px;
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
}
.net-worth-hero::after {
  content: ''; position: absolute;
  right: -60px; top: -60px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.22) 0%, transparent 60%);
  pointer-events: none;
}
.nw-label {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.65);
  margin-bottom: 10px;
}
.nw-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 48px;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: white;
}
@media (min-width: 900px) { .nw-amount { font-size: 56px; } }
.nw-change {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 16px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.nw-change.positive { color: #4ade80; background: rgba(74, 222, 128, 0.15); }
.nw-change.negative { color: #fca5a5; background: rgba(252, 165, 165, 0.15); }
.nw-change-pct { font-weight: 700; }
.nw-change-since {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
}

/* Hide old top page-header — replaced by ph-wrap */
.page-header {
  display: none !important;
}

/* Bottom nav refinement — mobile only */
.bottom-nav {
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -1px 8px rgba(0,0,0,0.04);
}
.nav-btn {
  color: var(--ink-soft);
  font-weight: 600;
}
.nav-btn.active { color: var(--brand-700); }
.nav-btn .nav-icon { font-size: 18px; }
.nav-btn.nav-scan {
  position: relative;
}
.nav-btn.nav-scan .nav-icon {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: white;
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}
.nav-badge {
  background: var(--negative);
}

/* Section title used inside content */
.section-title {
  font-size: 12px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--ink);
  padding: 18px 0 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 4px; height: 14px;
  background: var(--brand-600);
  border-radius: 2px;
  margin-right: 10px;
  vertical-align: middle;
}

/* Chart cards — premium polish */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px 16px;
  margin-bottom: 16px;
}
.chart-card-title {
  font-size: 12px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink);
  margin-bottom: 4px;
}
.chart-hint {
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 12px;
}

/* Chart-kind toggle pill */
.chart-kind-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 2px;
}
.chart-kind-btn {
  background: transparent; border: 0;
  padding: 6px 12px;
  font-size: 12px; font-weight: 700;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
  transition: all 0.15s;
}
.chart-kind-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

/* Empty state polish */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-card);
  padding: 48px 28px;
  text-align: center;
  margin: 24px 0;
}
.empty-icon { font-size: 38px; margin-bottom: 16px; opacity: 0.8; }
.empty-title { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.empty-text { font-size: 14px; color: var(--ink-3); max-width: 360px; margin: 0 auto; line-height: 1.5; }

/* ============================================================
   WealthTracker — Light Mode Design System
   Clean, calm, trustworthy, large readable typography
   ============================================================ */

:root {
  /* Colors — light mode only per spec */
  --bg:           #ffffff;
  --bg-soft:      #f7f8fa;
  --bg-tint:      #f0f3f8;
  --card:         #ffffff;
  --card-alt:     #fafbfc;
  --border:       #e3e8ef;
  --border-soft:  #eef1f5;

  --text:         #0f172a;
  --text-2:       #1f2937;
  --text-3:       #94a3b8;

  --primary:      #2563eb;       /* trustworthy blue */
  --primary-soft: #dbeafe;
  --primary-deep: #1d4ed8;

  --green:        #16a34a;
  --green-soft:   #dcfce7;
  --red:          #dc2626;
  --red-soft:     #fee2e2;
  --amber:        #d97706;
  --amber-soft:   #fef3c7;
  --purple:       #7c3aed;
  --purple-soft:  #ede9fe;

  /* Categories */
  --cat-cash:     #16a34a;
  --cat-invest:   #2563eb;
  --cat-retire:   #7c3aed;
  --cat-crypto:   #d97706;
  --cat-debt:     #dc2626;

  /* Spacing scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;

  /* Sizing */
  --radius-sm:  10px;
  --radius:     14px;
  --radius-lg:  20px;
  --nav-height: 76px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { height: 100%; background: var(--bg); }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;          /* base — never below 16px for readability */
  line-height: 1.5;
}

/* #app — mobile-first. The desktop grid layout is defined later in
   the "APP SHELL" section using the same #app selector so specificity
/* App shell base — uses CLASS selector so the desktop @media grid
   override (also using .app) wins by source order.
   NEVER use #app here — ID specificity (0-1-0-0) beats class (0-0-1-0)
   and that's what broke v30-v32 desktop layout. */

/* ---------- Splash ---------- */
#splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: var(--space-3); background: var(--bg);
}
.splash-icon { font-size: 64px; }
.splash-title { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.splash-subtitle { font-size: 16px; color: var(--text-2); }

/* ---------- Bottom nav ---------- */
#nav {
  display: flex; align-items: stretch;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--nav-height) + var(--safe-bottom));
  flex-shrink: 0;
  position: relative; z-index: 10;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer; padding: 8px 0;
  color: var(--text-3); font-size: 12px; font-weight: 600;
  border: none; background: none;
  transition: color 0.2s;
  -webkit-appearance: none; min-height: 44px;
}
.nav-item .nav-icon { font-size: 24px; transition: transform 0.2s; line-height: 1; }
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { transform: scale(1.1); }
.nav-item .nav-badge {
  position: absolute; top: 8px; margin-left: 18px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: white; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Page container ---------- */
#page {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-top: var(--safe-top);
  -webkit-overflow-scrolling: touch;
}

/* ---------- Page header ---------- */
.page-header {
  padding: var(--space-5) var(--space-5) var(--space-3);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
}
.page-title { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; color: var(--text); font-family: var(--font-display); }
.header-action {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-tint); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text); transition: all 0.2s;
}
.header-action:active { background: var(--primary-soft); transform: scale(0.95); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ---------- Net worth hero ---------- */
.net-worth-hero {
  margin: var(--space-3) var(--space-4);
  padding: var(--space-6) var(--space-5);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.nw-label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: var(--space-3);
}
.nw-amount {
  font-size: 56px;          /* OVERSIZED per spec */
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--text);
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.nw-amount.hidden-val { letter-spacing: 6px; font-size: 44px; }
.nw-change {
  margin-top: var(--space-3);
  font-size: 17px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
}
.nw-change.positive { color: var(--green); background: var(--green-soft); }
.nw-change.negative { color: var(--red); background: var(--red-soft); }
.nw-change.neutral { color: var(--text-2); background: var(--bg-tint); }

/* ---------- Category tiles ---------- */
.category-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--space-3); margin: 0 var(--space-4) var(--space-4);
}
.cat-tile {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: var(--space-4);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 165px;
}
.cat-tile-icon { font-size: 48px; margin-bottom: 10px; }
.cat-tile-label {
  font-size: 16px; color: #000; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
  text-align: center;
}
.cat-tile-amount {
  font-size: 30px; font-weight: 800; color: #000;
  font-variant-numeric: tabular-nums; letter-spacing: -0.5px; text-align: center;
}

/* ---------- Section titles ---------- */
.section-title {
  font-size: 20px; font-weight: 700;
  margin: var(--space-5) var(--space-4) var(--space-3);
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text);
}
.section-link {
  font-size: 15px; color: var(--primary); font-weight: 500; cursor: pointer;
}

/* ---------- Account rows ---------- */
.institution-card { margin: 0 var(--space-4) var(--space-4); }
.institution-header {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}
.institution-logo {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: white; flex-shrink: 0;
  overflow: hidden; position: relative;
}
/* When .with-img is present, the <img> sits on top of the fallback. If the
   image 404s (e.g. Clearbit doesn't know the bank), onerror swaps in the
   fallback. If it loads, image hides the fallback. */
.institution-logo.with-img { background: #fafafa; border: 1px solid var(--border, #e5e7eb); }
.institution-logo img {
  width: 100%; height: 100%; object-fit: contain;
  position: absolute; inset: 0; padding: 6px;
  background: transparent;
}
.institution-logo-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px;
  z-index: 0;
}
.institution-logo.with-img:not(.img-failed) .institution-logo-fallback { display: none; }
.institution-logo.with-img.img-failed img { display: none; }

.institution-name {
  flex: 1; font-size: 16px; font-weight: 700; color: var(--text);
  min-width: 0;
  word-break: break-word;
  line-height: 1.3;
}
.institution-total {
  font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.account-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 64px;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
  -webkit-touch-callout: none;
  user-select: none;
}
.cat-tile {
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
  -webkit-touch-callout: none;
  user-select: none;
}
.account-row:first-of-type { border-top: 1px solid var(--border); }
.account-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.account-row:active { background: var(--bg-tint); }
.acct-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.acct-info { flex: 1; min-width: 0; }
.acct-name {
  font-size: 16px; font-weight: 600; color: var(--text);
  /* Wrap to 2 lines if needed, then truncate. No more single-line "..." */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.25;
}
.acct-meta {
  font-size: 13px; color: var(--text-2); margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.acct-balance-wrap { text-align: right; flex-shrink: 0; }
.acct-balance {
  font-size: 18px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -0.3px;
}
.acct-balance.negative { color: var(--red); }
.acct-balance.hidden-val { letter-spacing: 4px; }
.acct-updated { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.dot-cash    { background: var(--cat-cash); }
.dot-invest  { background: var(--cat-invest); }
.dot-retire  { background: var(--cat-retire); }
.dot-crypto  { background: var(--cat-crypto); }
.dot-debt    { background: var(--cat-debt); }
.dot-other   { background: var(--text-3); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 64px var(--space-5);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
}
.empty-icon { font-size: 56px; opacity: 0.6; }
.empty-title { font-size: 20px; font-weight: 700; color: var(--text); }
.empty-text { font-size: 15px; color: var(--text-2); line-height: 1.5; max-width: 280px; }

/* ---------- Search ---------- */
.search-bar {
  margin: 0 var(--space-4) var(--space-3);
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
}
.search-bar input {
  flex: 1; border: none; background: transparent; color: var(--text);
  font-size: 16px; outline: none;
}
.search-bar input::placeholder { color: var(--text-3); }
.search-icon { color: var(--text-3); font-size: 18px; }

/* ---------- Filter chips ---------- */
.filter-chips {
  display: flex; gap: var(--space-2);
  margin: 0 var(--space-4) var(--space-3);
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 8px 16px; border-radius: 20px;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-2);
  transition: all 0.15s;
  min-height: 36px;
  display: inline-flex; align-items: center;
}
.chip.active {
  background: var(--primary); border-color: var(--primary); color: white;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 16px 24px; border-radius: var(--radius);
  border: none; cursor: pointer;
  font-size: 17px; font-weight: 600;
  transition: all 0.15s; width: 100%;
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  min-height: 52px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:active { background: var(--primary-deep); }
.btn-secondary {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--red-soft); color: var(--red);
  border: 1px solid var(--red-soft);
}
.btn-sm { padding: 10px 18px; font-size: 14px; min-height: 40px; border-radius: 10px; width: auto; }
.btn-ghost {
  background: transparent; color: var(--primary); border: 1px solid transparent;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  font-size: 16px; color: #000000;
  margin-bottom: var(--space-2);
  font-weight: 700; display: block;
}
.form-input, select.form-input, textarea.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: #000000;
  font-size: 18px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  font-family: inherit;
}
.form-input:focus, select.form-input:focus { border-color: var(--primary); border-width: 2px; padding: 13px 15px; }
.form-input::placeholder { color: var(--text-3); }
select.form-input { cursor: pointer; }

/* ---------- Auth ---------- */
/* Full-viewport lock — prevents scroll/peek bypass on mobile.
   When this view is visible, nothing below it can be seen or touched. */
.auth-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--space-8) var(--space-5); gap: var(--space-5); text-align: center;
  background: var(--bg);
  overflow: hidden;
  touch-action: none;       /* block scroll/pan gestures */
  overscroll-behavior: contain;
}
/* Auth-screen wrapper id — make it cover the whole viewport too,
   so even if user scrolls before mount, the lock stays put. */
#auth-screen:not(.hidden) {
  position: fixed; inset: 0; z-index: 9999;
  overflow: hidden;
}
/* When auth screen is shown, freeze body scroll */
body:has(#auth-screen:not(.hidden)) {
  overflow: hidden;
  position: fixed; width: 100%;
}
.auth-icon { font-size: 64px; }
.auth-title { font-size: 28px; font-weight: 700; color: var(--text); }
.auth-subtitle { font-size: 16px; color: var(--text-2); line-height: 1.5; max-width: 320px; }
.pin-dots { display: flex; gap: var(--space-3); margin: var(--space-3) 0; }
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--primary); background: transparent;
  transition: background 0.15s;
}
.pin-dot.filled { background: var(--primary); }
.pin-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); width: 280px; }
.pin-key {
  height: 72px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--border);
  font-size: 26px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s; color: var(--text);
}
.pin-key:active { background: var(--primary); color: white; transform: scale(0.92); }
.pin-key.delete { font-size: 22px; }
.pin-key.empty { background: transparent; border: none; cursor: default; }
.pin-error { color: var(--red); font-size: 14px; font-weight: 500; }

/* ---------- Modal ---------- */
#modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: flex-end;
}
#modal-overlay.hidden { display: none; }
#modal-container {
  width: 100%; max-height: 92dvh; overflow-y: auto;
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding-bottom: var(--safe-bottom);
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.3s cubic-bezier(0.32,0.72,0,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle {
  width: 36px; height: 5px; background: var(--border);
  border-radius: 3px; margin: var(--space-3) auto;
}
.modal-header {
  padding: 0 var(--space-5) var(--space-4);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 22px; font-weight: 700; color: var(--text); font-family: var(--font-display); }
.modal-close {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-soft); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 18px;
}
.modal-body { padding: 0 var(--space-5) var(--space-6); }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed; top: calc(var(--safe-top) + 16px); left: 50%;
  transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: var(--space-2);
  pointer-events: none;
  width: calc(100% - 32px); max-width: 380px;
}
.toast {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-3) var(--space-4);
  font-size: 15px; font-weight: 500; color: var(--text);
  display: flex; align-items: center; gap: var(--space-2);
  animation: toastIn 0.3s ease;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.toast.success { border-color: var(--green); border-left: 4px solid var(--green); }
.toast.error { border-color: var(--red); border-left: 4px solid var(--red); }
.toast.warning { border-color: var(--amber); border-left: 4px solid var(--amber); }
.toast.info { border-color: var(--primary); border-left: 4px solid var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Loading ---------- */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255, 255, 255, 0.92);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: var(--space-3);
}
.loading-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text { font-size: 15px; color: var(--text-2); font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Scanner ---------- */
.scan-options { margin: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.scan-option {
  display: flex; align-items: center; gap: var(--space-4);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: var(--space-4);
  cursor: pointer;
  transition: all 0.15s;
  width: 100%; text-align: left; color: var(--text);
  min-height: 80px;
}
.scan-option:active { background: var(--bg-soft); }
.scan-opt-icon {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; flex-shrink: 0;
}
.scan-opt-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.scan-opt-title { font-size: 17px; font-weight: 700; color: var(--text); }
.scan-opt-desc { font-size: 14px; color: var(--text-2); line-height: 1.4; }

.tip-card {
  margin: var(--space-3) var(--space-4);
  padding: var(--space-4);
  background: var(--primary-soft);
  border-radius: var(--radius);
  border: 1px solid var(--primary-soft);
}
.tip-title { font-size: 14px; font-weight: 700; color: var(--primary-deep); margin-bottom: 6px; }
.tip-text { font-size: 13px; color: var(--primary-deep); line-height: 1.6; opacity: 0.85; }

.ocr-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--primary);
  border-top-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}

/* ---------- Confidence badges ---------- */
.confidence-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 8px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.confidence-badge.high   { background: var(--green-soft); color: var(--green); }
.confidence-badge.medium { background: var(--amber-soft); color: var(--amber); }
.confidence-badge.low    { background: var(--red-soft); color: var(--red); }

/* ---------- Settings ---------- */
.settings-section { margin: 0 var(--space-4) var(--space-5); }
.settings-label {
  font-size: 12px; font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: var(--space-2); padding-left: 4px;
}
.settings-group {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4);
  cursor: pointer; transition: background 0.15s;
  min-height: 60px;
}
.settings-row:not(:last-child) { border-bottom: 1px solid var(--border-soft); }
.settings-row:active { background: var(--bg-tint); }
.settings-row.no-tap { cursor: default; }
.settings-row.no-tap:active { background: transparent; }
.settings-row-left { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; }
.settings-row-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.settings-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-row-title { font-size: 16px; font-weight: 600; color: var(--text); }
.settings-row-sub { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.settings-row-right {
  display: flex; align-items: center; gap: var(--space-2);
  color: var(--text-3); font-size: 16px;
}
.settings-badge {
  padding: 4px 10px; border-radius: 16px;
  font-size: 12px; font-weight: 700;
}
.settings-badge.connected { background: var(--green-soft); color: var(--green); }
.settings-badge.disconnected { background: var(--red-soft); color: var(--red); }

/* ---------- Toggle ---------- */
.toggle {
  width: 52px; height: 32px; border-radius: 16px;
  background: var(--border); position: relative; cursor: pointer;
  transition: background 0.3s; border: none; flex-shrink: 0;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: white; transition: transform 0.3s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.toggle.on::after { transform: translateX(20px); }

/* ---------- Review item ---------- */
.review-item {
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-4);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 4px solid var(--amber);
}
.review-item.high-priority { border-left-color: var(--red); }
.review-reason { font-size: 13px; font-weight: 700; color: var(--amber); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.review-item.high-priority .review-reason { color: var(--red); }
.review-detail { font-size: 15px; color: var(--text); line-height: 1.5; margin-bottom: var(--space-3); }
.review-evidence {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: var(--space-3);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px; overflow-y: auto;
}
.review-actions { display: flex; gap: var(--space-2); }

/* ---------- Reconciliation banner ---------- */
.recon-banner {
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: 500;
}
.recon-banner.success { background: var(--green-soft); color: var(--green); }
.recon-banner.warning { background: var(--amber-soft); color: var(--amber); }
.recon-banner.error   { background: var(--red-soft); color: var(--red); }

/* ---------- Detected accounts list (in scanner) ---------- */
.detected-account {
  margin-bottom: var(--space-3);
  padding: var(--space-4);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; gap: var(--space-3); align-items: flex-start;
}
.detected-account.deselected { opacity: 0.4; }
.detected-account.inferred { border-style: dashed; border-color: var(--purple); background: var(--purple-soft); }
.detected-checkbox {
  width: 24px; height: 24px; flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--primary); cursor: pointer;
}
.detected-info { flex: 1; min-width: 0; }
.detected-row1 {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.detected-name { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detected-meta { font-size: 13px; color: var(--text-2); margin-bottom: var(--space-2); }
.detected-row3 { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.detected-balance {
  font-size: 22px; font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: -0.5px;
  color: var(--text);
}
.detected-balance.negative { color: var(--red); }
.detected-edit {
  padding: 6px 12px; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text-2);
  cursor: pointer;
}

/* ---------- Sync banner ---------- */
.sync-banner {
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-2);
  display: flex; align-items: center; gap: var(--space-2);
}
.sync-banner a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* ---------- Misc ---------- */
::-webkit-scrollbar { width: 0; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none; }
.text-muted { color: var(--text-2); }
.text-sm { font-size: 14px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.bottom-spacer { height: 80px; }
@media (min-width: 900px) { .bottom-spacer { height: 32px; } }

/* ---------- JSON viewer (debug) ---------- */
.json-viewer {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre;
  max-height: 300px;
  overflow-y: auto;
}

/* ============================================================
   COMPONENTS — alignment + additions for views
   ============================================================ */

/* Map nav class names: index.html uses .nav-btn, .bottom-nav, .main-content */
.bottom-nav {
  display: flex; align-items: stretch;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--nav-height) + var(--safe-bottom));
  flex-shrink: 0;
  position: relative; z-index: 10;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer; padding: 8px 4px;
  color: var(--text-3); font-size: 11px; font-weight: 600;
  border: none; background: none;
  transition: color 0.2s;
  min-height: 44px; position: relative;
}
.nav-btn .nav-icon { font-size: 22px; line-height: 1; transition: transform 0.2s; }
.nav-btn .nav-label { font-size: 11px; }
.nav-btn.active { color: var(--primary); }
.nav-btn.active .nav-icon { transform: scale(1.1); }
.nav-btn.nav-scan { color: var(--primary); }
.nav-btn.nav-scan .nav-icon { font-size: 28px; }
.nav-btn .nav-badge {
  position: absolute; top: 8px; right: calc(50% - 22px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: white; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* (hidden handled by #app.hidden at top of file) */
.main-content {
  /* Mobile: fills remaining flex space below bottom nav.
     min-height: 0 is essential — without it flex children won't shrink
     below their content size, which breaks internal scroll on iOS Safari. */
  flex: 1;
  min-height: 0;            /* KEY: allows flex child to shrink + scroll */
  overflow-y: auto;
  overflow-x: hidden;       /* horizontal scroll handled per-table below */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ===== Buttons (additions) ===== */
.btn-large { padding: 18px 24px; font-size: 17px; min-height: 56px; }
.btn-small { padding: 8px 14px; font-size: 13px; min-height: 36px; border-radius: 10px; width: auto; }
.btn-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-2); cursor: pointer;
  padding: 0; min-height: 36px;
}
.btn-icon:active { background: var(--bg-tint); }
.btn-danger { background: var(--red-soft); color: var(--red); border: 1px solid var(--red-soft); }
.btn-danger:active { background: var(--red); color: white; }
.btn-ghost {
  background: transparent; color: var(--primary);
  border: 1px solid transparent;
}
.btn-ghost:active { background: var(--primary-soft); }

/* ===== Modal ===== */
.modal-root {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-root.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  animation: fade-in 0.2s ease;
}
.modal-card {
  position: relative; z-index: 1;
  background: var(--bg); width: 100%;
  max-width: 580px;          /* desktop ceiling — phone screens just fill */
  margin: 0 auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 90vh; overflow-y: auto;
  padding-bottom: var(--safe-bottom);
  animation: slide-up 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
/* On desktop, center the modal vertically and give it full corner radius
   (the bottom-sheet style is iPhone-first; desktop wants a centered card). */
@media (min-width: 600px) {
  .modal-root { align-items: center; }
  .modal-card {
    border-radius: var(--radius-lg);
    max-height: 88vh;
  }
}
.modal-header {
  padding: var(--space-5) var(--space-5) var(--space-3);
  font-size: 24px; font-weight: 800;
  color: #000000;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-soft);
}
.modal-body { padding: var(--space-5); }
.modal-actions {
  display: flex; gap: var(--space-3);
  padding: 0 var(--space-5) var(--space-5);
}
.modal-actions .btn { flex: 1; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: 24px;
  font-size: 15px; font-weight: 500;
  z-index: 2000; max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toast-in 0.25s ease;
}
.toast.hidden { display: none; }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== Loading overlay ===== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.loading-overlay.hidden { display: none; }
.loading-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-6);
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-3); min-width: 200px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-2); font-size: 14px; font-weight: 500; }

/* ===== Scanner empty / upload ===== */
.scanner-empty {
  padding: var(--space-8) var(--space-5);
  text-align: center; max-width: 480px; margin: 0 auto;
}
.scanner-illustration { font-size: 64px; margin-bottom: var(--space-4); }
.scanner-title { font-size: 24px; font-weight: 700; margin-bottom: var(--space-3); color: var(--text); }
.scanner-subtitle { color: var(--text-2); font-size: 15px; margin-bottom: var(--space-5); line-height: 1.5; }
.scanner-actions { margin-bottom: var(--space-6); }
.scanner-tips {
  text-align: left; background: var(--bg-soft);
  border-radius: var(--radius); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.tip-row { display: flex; gap: var(--space-3); font-size: 14px; align-items: flex-start; }
.tip-icon { color: var(--green); font-weight: 700; flex-shrink: 0; }

/* ===== Scan results ===== */
.scan-results { padding: var(--space-3) 0; }
.scan-institution-header {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-soft);
}
.inst-logo {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.inst-info { flex: 1; min-width: 0; }
.inst-name { font-size: 17px; font-weight: 700; color: var(--text); }
.inst-meta { font-size: 12px; color: var(--text-2); }

.alert {
  margin: 0 var(--space-5) var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius);
  display: flex; align-items: flex-start; gap: var(--space-3);
}
.alert-ok { background: var(--green-soft); color: var(--green); }
.alert-warn { background: var(--amber-soft); color: var(--amber); }
.alert-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }
.alert-title { font-weight: 700; margin-bottom: 2px; }
.alert-body { font-size: 13px; opacity: 0.9; }

.scan-section-title {
  font-size: 14px; font-weight: 700; text-transform: uppercase;
  color: var(--text-3); letter-spacing: 0.5px;
  padding: var(--space-4) var(--space-5) var(--space-2);
}
.scan-accounts { padding: 0 var(--space-5); }
.scan-account {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4); margin-bottom: var(--space-3);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.scan-account.is-inferred {
  border-style: dashed; border-color: var(--purple);
  background: linear-gradient(0deg, var(--purple-soft) 0%, var(--card) 60%);
}
.scan-account-check { display: flex; align-items: center; padding-top: 4px; cursor: pointer; }
.scan-account-check input { width: 22px; height: 22px; accent-color: var(--primary); cursor: pointer; }
.scan-account-body { flex: 1; min-width: 0; }
.scan-account-row1 { display: flex; align-items: center; gap: var(--space-3); margin-bottom: 4px; }
.scan-account-name { flex: 1; font-size: 16px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-account-balance {
  font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -0.3px;
  color: var(--text);
}
.scan-account-balance.is-debt { color: var(--red); }
.scan-account-row2 { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.scan-meta {
  font-size: 12px; color: var(--text-2);
  padding: 2px 8px; background: var(--bg-soft); border-radius: 6px;
}
.scan-conf-high { background: var(--green-soft); color: var(--green); }
.scan-conf-med { background: var(--amber-soft); color: var(--amber); }
.scan-conf-low { background: var(--red-soft); color: var(--red); }
.badge-inferred { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--purple-soft); color: var(--purple); font-weight: 700; }
.badge-known { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-deep); font-weight: 700; }
.badge-anomaly { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--red-soft); color: var(--red); font-weight: 700; }

.scan-no-accounts {
  text-align: center; padding: var(--space-6) var(--space-5);
}
.scan-no-accounts-icon { font-size: 48px; margin-bottom: var(--space-3); }
.scan-no-accounts h3 { font-size: 18px; margin-bottom: var(--space-2); color: var(--text); }
.scan-no-accounts p { color: var(--text-2); font-size: 14px; margin-bottom: var(--space-2); }
.muted { color: var(--text-3); }

.json-toggle { padding: var(--space-3) var(--space-5); }
.json-block {
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: var(--space-3); margin-top: var(--space-2);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-2);
  overflow-x: auto; white-space: pre; max-height: 280px; overflow-y: auto;
}

.scan-actions {
  display: flex; gap: var(--space-3);
  padding: var(--space-5);
  position: sticky; bottom: 0;
  background: var(--bg); border-top: 1px solid var(--border-soft);
}
.scan-actions .btn { flex: 1; }

/* ===== Review queue ===== */
.review-list { padding: var(--space-3) 0; }
.review-card {
  margin: 0 var(--space-5) var(--space-3);
  padding: var(--space-4);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--text-3);
}
.review-card.review-high { border-left-color: var(--red); background: linear-gradient(0deg, var(--red-soft) 0%, var(--card) 30%); }
.review-card.review-med { border-left-color: var(--amber); background: linear-gradient(0deg, var(--amber-soft) 0%, var(--card) 30%); }
.review-card.review-low { border-left-color: var(--text-3); }

.review-card-header {
  display: flex; align-items: center; gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.review-icon { font-size: 18px; }
.review-label { font-weight: 700; color: var(--text); flex: 1; }
.review-time { font-size: 12px; color: var(--text-3); }

.review-account {
  background: var(--bg-soft); padding: var(--space-3);
  border-radius: var(--radius-sm); margin: var(--space-2) 0;
}
.review-acct-name { font-weight: 600; color: var(--text); }
.review-acct-meta { font-size: 13px; color: var(--text-2); }

.review-evidence {
  background: var(--bg-tint); padding: var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-2); white-space: pre-wrap; word-break: break-word;
  max-height: 100px; overflow-y: auto;
  margin: var(--space-2) 0;
}
.review-conf { font-size: 12px; color: var(--text-3); margin-bottom: var(--space-3); }
.review-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.empty-state {
  text-align: center; padding: var(--space-8) var(--space-5);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: var(--space-4); color: var(--green); }
.empty-state h3 { font-size: 20px; color: var(--text); margin-bottom: var(--space-2); }

/* ===== Settings ===== */
.settings-section { margin-bottom: var(--space-5); }
.settings-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  color: var(--text-3); letter-spacing: 0.5px;
  padding: var(--space-4) var(--space-5) var(--space-2);
}
.settings-card {
  margin: 0 var(--space-4);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.settings-card .settings-row {
  padding: var(--space-4);
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-soft);
}
.settings-card .settings-row:last-child { border-bottom: none; }
.settings-row-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.settings-row-sub { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.settings-input {
  width: 100%;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px; margin-top: var(--space-2);
  color: var(--text); font-size: 14px; font-family: var(--font-mono);
}
.settings-input:focus { outline: 2px solid var(--primary); }

.settings-toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; gap: var(--space-3); cursor: pointer;
  position: relative;
}
.toggle-input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-visual {
  width: 44px; height: 26px; border-radius: 13px;
  background: var(--border); position: relative;
  transition: background 0.2s; flex-shrink: 0;
}
.toggle-visual::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-input:checked + .toggle-visual { background: var(--primary); }
.toggle-input:checked + .toggle-visual::after { transform: translateX(18px); }

.learned-list { display: flex; flex-direction: column; gap: var(--space-2); }
.learned-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-soft); border-radius: var(--radius-sm);
}
.learned-logo {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; flex-shrink: 0;
}
.learned-info { flex: 1; min-width: 0; }
.learned-name { font-weight: 600; color: var(--text); }
.learned-meta { font-size: 12px; }

.header-count {
  background: var(--red); color: white;
  padding: 2px 10px; border-radius: 12px;
  font-size: 13px; font-weight: 700;
}

/* ===== Form group ===== */
.form-group { margin-bottom: var(--space-4); }
.form-group label {
  display: block; font-size: 14px; font-weight: 600;
  color: var(--text-2); margin-bottom: var(--space-2);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px; color: var(--text);
  font-size: 16px; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: 2px solid var(--primary); border-color: var(--primary);
}

/* ===== Image preview thumbnail (scanner results) ===== */
.scan-image-preview {
  margin: var(--space-4) 0;
}
.scan-image-preview-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600;
  color: var(--text-2); margin-bottom: var(--space-2);
}
.scan-image-thumb {
  display: block; width: 100%; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-2);
  cursor: pointer; overflow: hidden; position: relative;
  max-height: 340px;
}
.scan-image-thumb img {
  display: block; width: 100%; height: auto;
  max-height: 340px; object-fit: contain;
  background: var(--bg);
}
.scan-image-thumb-overlay {
  position: absolute; top: 8px; right: 8px;
  width: 36px; height: 36px;
  background: rgba(0,0,0,0.6); color: #fff;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; pointer-events: none;
}
.scan-image-thumb:active { transform: scale(0.99); }

/* ===== Fullscreen image viewer ===== */
body.img-viewer-active { overflow: hidden; }
.img-viewer-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column;
  touch-action: none; user-select: none;
}
.img-viewer-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.img-viewer-zoom-controls {
  display: flex; align-items: center; gap: 8px;
}
.img-viewer-btn {
  min-width: 44px; height: 44px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff; font-size: 20px; font-weight: 600;
  border-radius: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0 14px;
}
.img-viewer-btn:hover { background: rgba(255,255,255,0.25); }
.img-viewer-btn:active { transform: scale(0.95); }
.img-viewer-btn-text { font-size: 14px; font-weight: 600; }
.img-viewer-zoom-level {
  color: #fff; font-size: 14px; font-weight: 600;
  min-width: 50px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.img-viewer-stage {
  flex: 1; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; position: relative;
}
.img-viewer-stage img {
  max-width: 100%; max-height: 100%;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  will-change: transform;
  -webkit-user-drag: none;
  pointer-events: none;
}
.img-viewer-hint {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(0,0,0,0.6);
  color: rgba(255,255,255,0.8);
  border-radius: 20px; font-size: 12px;
  pointer-events: none;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

/* ===== History rows (edit modal) ===== */
.history-row:active { background: var(--bg-tint); }
.history-row:hover { background: var(--bg-tint); }

/* ============================================================
   Net worth gain/loss header
   ============================================================ */
.nw-change.positive { color: #16a34a; }
.nw-change.negative { color: #dc2626; }
.nw-change.neutral  { color: var(--text-2); }
.nw-change-pct      { margin-left: 6px; font-weight: 500; opacity: 0.85; }
.nw-change-since    { display: block; font-size: 11px; opacity: 0.7; margin-top: 2px; font-weight: 400; }

/* ============================================================
   Dynamic category cards (replaces fixed crypto/cash/invest/retire)
   ============================================================ */
.cat-tile-sub { font-size: 14px; margin-top: 4px; color: #000; font-weight: 600; }
/* Note: .cat-tile-amount is defined above (30px) — no override here */

/* ============================================================
   Chart card with type/institution tabs
   ============================================================ */
.chart-card {
  background: var(--bg-elev); border-radius: 14px;
  padding: 12px 12px 6px; margin: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
/* Hold the chart canvas in a fixed-height container — prevents the
   "chart shifts every render" issue on iPhone and keeps mobile
   layout compact (no excessive scrolling). */
.chart-card canvas {
  display: block;
  width: 100% !important;
  height: 260px !important;
  max-height: 260px;
}
.chart-tabs {
  display: flex; gap: 4px; margin-bottom: 8px;
  background: var(--bg-soft); border-radius: 10px; padding: 3px;
}
.chart-tab {
  flex: 1; padding: 8px 10px; border: 0; background: transparent;
  border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--text-2); cursor: pointer; transition: all 0.15s;
}
.chart-tab.active { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

/* ============================================================
   Sequence badge per account inside institution card
   ============================================================ */
.acct-seq {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  background: var(--bg-soft); color: var(--text-2);
  padding: 1px 6px; border-radius: 8px;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
.institution-count {
  display: block; font-size: 11px; font-weight: 500;
  color: var(--text-2); margin-top: 1px;
}

/* ============================================================
   Performance card in edit modal (ROR, maturity, interest rate)
   ============================================================ */
.perf-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 16px;
  border: 1px solid #bae6fd;
}
.perf-card-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: #0369a1; margin-bottom: 10px;
}
.perf-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; font-size: 14px;
}
.perf-label { color: var(--text-2); }
.perf-value { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.perf-value.pos { color: #16a34a; }
.perf-value.neg { color: #dc2626; }
.perf-value.neu { color: #ea580c; }
.perf-pct { font-size: 12px; font-weight: 500; margin-left: 6px; opacity: 0.85; }
.perf-divider { height: 1px; background: rgba(0,0,0,0.08); margin: 8px 0; }
.perf-hint { font-size: 11px; margin-top: 10px; line-height: 1.4; }

/* ============================================================
   Accounts page — bigger institution dashboards with collapse
   ============================================================ */
.filter-chips-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 8px;
}
.filter-chips-scroll::-webkit-scrollbar { display: none; }
.filter-chips-scroll .chip { flex: 0 0 auto; white-space: nowrap; }
.chip-count {
  display: inline-block;
  background: rgba(0,0,0,0.08);
  padding: 1px 6px; border-radius: 8px;
  font-size: 10px; font-weight: 700;
  margin-left: 4px;
}
.chip.active .chip-count { background: rgba(255,255,255,0.25); }

.inst-dashboard {
  background: var(--bg-elev);
  border-radius: 18px;
  margin: 14px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
}
.inst-dashboard-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 16px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}
.inst-dashboard-header:active { background: #f1f5f9; }
.inst-logo-big {
  width: 62px; height: 62px;
  border-radius: 16px;
  color: white; font-weight: 800; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  position: relative; overflow: hidden;
}
.inst-logo-big.with-img { background: #fafafa; border: 1px solid var(--border, #e5e7eb); }
.inst-logo-big img {
  width: 100%; height: 100%; object-fit: contain;
  position: absolute; inset: 0; padding: 10px;
  background: transparent;
}
.inst-logo-big .institution-logo-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 26px;
}
.inst-logo-big.with-img:not(.img-failed) .institution-logo-fallback { display: none; }
.inst-logo-big.with-img.img-failed img { display: none; }
.inst-meta-block {
  flex: 1; text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.inst-name-big {
  font-weight: 700; font-size: 18px; color: var(--text);
  line-height: 1.2; letter-spacing: 0.2px;
}
.inst-count-big {
  font-size: 12px; color: var(--text-2);
  margin-top: 4px; font-weight: 500;
}
.inst-right-block {
  text-align: right;
  display: flex; flex-direction: column; align-items: flex-end;
  min-width: 100px;
}
.inst-total-big {
  font-weight: 800; font-size: 22px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.2px;
}
.inst-collapse-icon {
  font-size: 12px; color: var(--text-2); margin-top: 6px;
  transition: transform 0.2s;
}
.inst-accounts-list {
  border-top: 1px solid rgba(0,0,0,0.06);
}
.account-row-big {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  cursor: pointer;
}
.account-row-big:last-child { border-bottom: 0; }
.account-row-big:active { background: var(--bg-tint); }
.acct-icon-big {
  width: 40px; height: 40px;
  background: var(--bg-soft);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.acct-info-big {
  flex: 1; min-width: 0;
  text-align: left;
}
.acct-name-big {
  font-weight: 700; font-size: 15px;
  color: #000000;
  line-height: 1.3;
  word-break: break-word;
  white-space: normal;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.acct-seq-big {
  display: inline-block;
  background: #e0f2fe; color: #0369a1;
  padding: 1px 6px; border-radius: 8px;
  font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.acct-meta-big {
  font-size: 12px; color: #000000;
  margin-top: 1px;
  white-space: normal; word-break: break-word;
  font-weight: 500;
}
.acct-balance-big-wrap {
  text-align: right; flex-shrink: 0;
}
.acct-balance-big {
  font-weight: 800; font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: #000000;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.acct-balance-big.negative { color: #dc2626; }
.acct-updated-big {
  font-size: 11px; color: var(--text-2);
  margin-top: 3px;
}

/* Smaller mobile: ensure tap targets stay big */
@media (max-width: 380px) {
  .inst-logo-big { width: 44px; height: 44px; font-size: 18px; }
  .inst-name-big { font-size: 15px; }
  .inst-total-big { font-size: 18px; }
  .acct-icon-big { width: 38px; height: 38px; font-size: 18px; }
  .acct-name-big { font-size: 14px; }
  .acct-balance-big { font-size: 15px; }
}

/* Per-account balance history chart inside edit modal */
.acct-history-chart {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 8px;
  margin-bottom: 16px;
}
.acct-history-chart canvas {
  display: block;
  width: 100% !important;
  height: 180px !important;
  max-height: 180px;
}
.acct-history-chart-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-2); margin-bottom: 8px;
}

/* Friendly empty-state hint for charts that need more data */
.chart-empty-hint {
  padding: 30px 16px; text-align: center;
  color: var(--text-2); font-size: 13px; line-height: 1.5;
}
.chart-empty-hint .icon { font-size: 30px; display: block; margin-bottom: 8px; }

/* ============================================================
   Account detail "page" inside modal — hero, stat tiles, meta card
   ============================================================ */
.acct-detail-hero {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white; padding: 24px 20px;
  border-radius: 16px; margin: 0 0 18px 0;
  text-align: center;
}
.acct-detail-name {
  font-size: 16px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  opacity: 0.9; margin-bottom: 10px;
  color: #ffffff;
}
.acct-detail-balance {
  font-size: 44px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: #ffffff;
}
.acct-detail-change {
  display: inline-block;
  font-size: 16px; font-weight: 700;
  margin-top: 12px;
  padding: 8px 18px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
}
.acct-detail-change.pos { color: #4ade80; }
.acct-detail-change.neg { color: #f87171; }
.acct-detail-change.neu { color: rgba(255,255,255,0.85); }

/* Stat grid below hero */
/* 2×3 grid on mobile (2 columns), 3×2 grid on desktop (3 columns).
   With 6 tiles we want either:
     - Mobile (≤599px): 2 cols × 3 rows
     - Desktop (≥600px in modal context): 3 cols × 2 rows
   The modal is max 580px on desktop so the responsive break is on the
   modal's container, not the viewport. Use auto-fill with min size. */
.acct-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 18px;
}
@media (min-width: 520px) {
  .acct-stat-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}
.acct-stat-tile {
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 14px 12px;
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  text-align: center;
}
.acct-stat-label {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--ink-3, #475569); margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acct-stat-value {
  font-family: 'JetBrains Mono', 'Inter', monospace;
  font-size: 19px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1.15;
  color: #0b0f17;
  word-break: break-word;
}
.acct-stat-value.pos { color: #15803d; }
.acct-stat-value.neg { color: #b91c1c; }
.acct-stat-value.neu { color: #0b0f17; }
.acct-stat-tile.pos .acct-stat-value { color: #15803d; }
.acct-stat-tile.neg .acct-stat-value { color: #b91c1c; }
.acct-stat-sub {
  font-size: 11px; color: var(--ink-3, #475569);
  margin-top: 5px;
  font-weight: 600;
  line-height: 1.35;
}
@media (min-width: 520px) {
  .acct-stat-value { font-size: 22px; }
}

/* Meta card (account details) */
.acct-meta-card {
  background: var(--bg-elev);
  border-radius: 14px;
  padding: 16px 18px; margin-bottom: 18px;
  border: 1px solid var(--border, rgba(0,0,0,0.08));
}
.acct-meta-card-title {
  font-size: 14px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: #000000; margin-bottom: 12px;
}
.acct-meta-row {
  display: flex; justify-content: space-between;
  align-items: baseline;
  padding: 10px 0; font-size: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.acct-meta-row:last-child { border-bottom: 0; }
.acct-meta-key { color: #000000; font-weight: 500; }
.acct-meta-val {
  color: #000000; font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.acct-meta-hint {
  font-size: 13px; margin-top: 12px; line-height: 1.5;
  color: #000000;
}

/* History list with edit/delete affordance */
.acct-history-list {
  background: var(--bg-soft);
  border-radius: 12px; padding: 6px;
  max-height: 280px; overflow-y: auto;
}
.acct-history-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 8px;
  cursor: pointer;
  font-size: 15px; color: #000000;
  font-weight: 500;
}
.acct-history-row:hover, .acct-history-row:active { background: var(--bg-tint); }
.acct-history-date { display: flex; align-items: center; gap: 6px; color: #000000; }
.acct-history-bal {
  font-variant-numeric: tabular-nums;
  font-weight: 800; color: #000000; font-size: 17px;
}
.acct-history-tag {
  font-size: 10px; font-weight: 700; padding: 2px 6px;
  border-radius: 3px; letter-spacing: 0.4px;
}
.acct-history-tag.edited { background: #f3e8ff; color: #7e22ce; }
.acct-history-tag.inferred { background: #ffedd5; color: #c2410c; }

/* Section title inside modal */
.form-section-title {
  font-size: 15px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: #000000;
  margin: 22px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

/* Chart card title */
.chart-card-title {
  font-size: 13px; font-weight: 700;
  color: var(--text); margin-bottom: 4px;
  padding: 2px 4px;
}
.chart-card .chart-hint {
  font-size: 11px; padding: 0 4px 6px;
}

/* Bar/Pie chart toggle in section title */
.chart-kind-toggle {
  display: inline-flex; gap: 4px;
  background: var(--bg-soft); border-radius: 8px; padding: 2px;
  margin-left: auto;
}
.chart-kind-btn {
  border: 0; background: transparent;
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 700;
  color: var(--text-2); cursor: pointer;
  transition: all 0.15s;
}
.chart-kind-btn.active {
  background: var(--bg-elev); color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ============================================================
   Explicit Edit (⋯) button on every account row
   ============================================================ */
.account-row, .account-row-big {
  position: relative;
}
.acct-edit-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 0;
  background: var(--bg-soft, #f1f5f9);
  color: var(--text);
  font-size: 22px; font-weight: 700;
  line-height: 1;
  cursor: pointer;
  margin-left: 8px;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  transition: background 0.15s;
}
.acct-edit-btn:hover, .acct-edit-btn:active {
  background: var(--bg-tint, #e2e8f0);
}

.acct-flag {
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 3px;
  margin-left: 6px; letter-spacing: 0.3px;
}
.acct-flag.inferred { background: #f3e8ff; color: #7e22ce; }
.acct-flag.review { background: #ffedd5; color: #c2410c; }

.dev-tag {
  font-size: 9px; font-weight: 800;
  background: #fbbf24; color: #78350f;
  padding: 1px 5px; border-radius: 3px;
  vertical-align: middle; letter-spacing: 0.5px;
  margin-left: 6px;
}

/* ============================================================
   Category accordion on Dashboard (compact, collapsed-by-default)
   ============================================================ */
.cat-accordion {
  display: flex; flex-direction: column;
  gap: 10px;
  margin: 0 14px 16px;
}
.cat-acc {
  background: var(--bg-elev);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.cat-acc.open { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.cat-acc-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
  -webkit-touch-callout: none;
  user-select: none;
}
.cat-acc-header:active { background: var(--bg-tint); }
.cat-acc-icon {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.cat-acc-info { flex: 1; min-width: 0; }
.cat-acc-name {
  font-size: 16px; font-weight: 800;
  color: #000000;
  letter-spacing: 0.2px;
}
.cat-acc-count {
  font-size: 12px; color: #000000;
  margin-top: 1px; font-weight: 500;
}
.cat-acc-right { text-align: right; display: flex; align-items: center; gap: 10px; }
.cat-acc-total {
  font-size: 17px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #000000;
}
.cat-acc-chevron {
  font-size: 11px; color: #000000;
  width: 12px; text-align: center;
}
.cat-acc-body {
  border-top: 1px solid var(--border, rgba(0,0,0,0.08));
  background: var(--bg-soft);
}
.cat-acc-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
  background: var(--bg-elev);
}
.cat-acc-row:last-child { border-bottom: 0; }
.cat-acc-row:active { background: var(--bg-tint); }
.cat-acc-row-left { flex: 1; min-width: 0; }
.cat-acc-row-name {
  font-size: 14px; font-weight: 700;
  color: #000000;
  word-break: break-word;
  line-height: 1.25;
}
.cat-acc-row-meta {
  font-size: 11px;
  color: #000000;
  margin-top: 1px;
  font-weight: 500;
}
.cat-acc-row-bal {
  font-size: 15px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #000000;
  text-align: right;
  white-space: nowrap;
}
/* Tighten the edit button so it doesn't dominate the row */
.cat-acc-row .acct-edit-btn {
  width: 30px; height: 30px;
  font-size: 18px;
  margin-left: 4px;
}

/* ============================================================
   Expand/collapse toolbar (Accounts page)
   ============================================================ */
.expand-toolbar {
  display: flex; align-items: center;
  padding: 10px 16px;
  gap: 12px;
  margin-bottom: 4px;
}
.expand-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px; font-weight: 700;
  color: #000000;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
}
.expand-btn:active { background: var(--bg-tint); }
.expand-hint {
  font-size: 12px;
  color: #000000;
  font-weight: 500;
}

/* Hide section title that becomes redundant when accordion replaces flat list */
.dashboard-view .section-title:has(+ .cat-accordion) {
  padding: 12px 14px 6px;
  font-size: 13px;
  color: #000000;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================================
   Source-screenshot verification panel inside Edit modal
   ============================================================ */
.verify-card {
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.verify-card-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.verify-card-title {
  font-size: 12px; font-weight: 800; color: #92400e;
  letter-spacing: 0.5px;
}
.verify-card-hint {
  font-size: 12px; color: #92400e; font-weight: 600;
}
.verify-card-imgwrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
  border: 1px solid #fcd34d;
}
.verify-card-img {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  background: #fff;
}
.verify-card-zoom-hint {
  position: absolute;
  bottom: 6px; right: 8px;
  background: rgba(0,0,0,0.7); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
  letter-spacing: 0.3px;
}
.verify-card-note {
  font-size: 12px; color: #78350f;
  margin-top: 8px; line-height: 1.45;
}
.verify-card-note b { color: #78350f; font-weight: 700; }

/* Full-screen lightbox when user taps the screenshot */
.verify-lightbox {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 30px 12px;
  cursor: zoom-out;
  overflow: auto;
  touch-action: pinch-zoom;
}
.verify-lightbox img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.verify-lightbox-close {
  position: fixed;
  top: 14px; right: 14px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: white; border: 0;
  font-size: 20px; font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255,255,255,0.3);
}
.verify-lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* ===========================================================
   PREMIUM FINTECH REDESIGN — v30
   Layered on top of existing styles. Overrides where needed.
   =========================================================== */

/* Premium design tokens */
:root {
  /* Surfaces */
  --canvas: #fafbfc;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f4;

  /* Hairlines */
  --hairline: #e5e7eb;
  --hairline-strong: #d1d5db;

  /* Ink (text) */
  --ink: #0b0f17;
  --ink-muted: #475569;
  --ink-soft: #94a3b8;

  /* Brand emerald */
  --brand-50:  #ecfdf5;
  --brand-100: #d1fae5;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;

  /* Semantic */
  --positive: #15803d;
  --negative: #b91c1c;
  --caution:  #d97706;
  --info:     #2563eb;

  /* Premium shadows */
  --shadow-card:       0 1px 3px rgba(11,15,23,0.04), 0 1px 2px rgba(11,15,23,0.03);
  --shadow-card-hover: 0 4px 12px rgba(11,15,23,0.06), 0 2px 4px rgba(11,15,23,0.04);
  --shadow-sidebar:    0 0 0 1px rgba(11,15,23,0.04);
}

body { background: var(--canvas); }

/* ===========================================================
   APP SHELL — desktop sidebar layout
   Uses #app to match the specificity of the mobile-first #app rule
   above (line ~725). With matching specificity, source order wins,
   so the desktop grid layout properly overrides the mobile flex stack.
   =========================================================== */
@media (min-width: 900px) {
  #app {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: 1fr;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
  }
  /* Hide mobile header on desktop */
  .mobile-header { display: none !important; }
  .sidebar {
    display: flex; flex-direction: column;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--hairline);
    padding: 24px 16px;
    box-shadow: var(--shadow-sidebar);
    z-index: 50;
    grid-column: 1; grid-row: 1;
  }
  .main-content {
    padding: 32px 40px 64px;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
    align-self: start;
    grid-column: 2; grid-row: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    height: 100%;
  }
  .bottom-nav { display: none !important; }
  body { padding-bottom: 0; overflow: hidden; }
}

/* Sidebar pieces */
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 24px;
  font-family: 'Inter', system-ui, sans-serif;
}
.sidebar-logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 18px;
  box-shadow: 0 2px 8px rgba(5,150,105,0.25);
}
.sidebar-logo-name {
  font-size: 19px; font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.3px;
}
.sidebar-nav {
  flex: 1;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-section-label {
  font-size: 11px; font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 16px 12px 6px;
}
/* .sidebar-item* rules removed — HTML uses .side-btn class instead
   (see line ~130). The .sidebar-item block was from an unused redesign
   pass and targeted non-existent DOM classes. */
.sidebar-divider {
  height: 1px; background: var(--hairline);
  margin: 8px 0;
}
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--hairline);
  font-size: 11px;
  color: var(--ink-soft);
}

/* ===========================================================
   PAGE HEADER — tagline + display H1 pattern
   =========================================================== */
.page-tagline {
  font-size: 12px;
  font-weight: 800;
  color: var(--brand-600);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.page-h1 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 36px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.8px;
  line-height: 1.1;
  margin: 0;
}
@media (max-width: 600px) { .page-h1 { font-size: 28px; } }
.page-header-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 28px;
  padding: 16px 16px 0;
}
@media (min-width: 900px) {
  .page-header-row { padding: 0; margin-bottom: 36px; }
}
.page-header-actions { display: flex; gap: 8px; align-items: center; }
.header-pill-btn {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.header-pill-btn:hover { background: var(--surface-2); border-color: var(--hairline-strong); }
.header-pill-btn.primary {
  background: var(--ink); color: white; border-color: var(--ink);
}
.header-pill-btn.primary:hover { background: #1e2937; }

/* ===========================================================
   PREMIUM KPI TILES — 4-across on desktop, 2 on tablet, 1 on phone
   =========================================================== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 0 16px 28px;
}
@media (min-width: 900px) { .kpi-row { grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 0 0 32px; } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow-card-hover); }
.kpi-card-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.kpi-card-icon {
  width: 36px; height: 36px;
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.kpi-card-icon.amber  { background: #fef3c7; color: #b45309; }
.kpi-card-icon.purple { background: #ede9fe; color: #6d28d9; }
.kpi-card-icon.sky    { background: #e0f2fe; color: #0369a1; }
.kpi-card-icon.rose   { background: #fce7f3; color: #be185d; }
.kpi-card-arrow {
  font-size: 16px; color: var(--ink-soft);
  background: transparent; border: 0; cursor: pointer;
  padding: 4px; line-height: 1;
}
.kpi-card-arrow:hover { color: var(--ink); }
.kpi-card-label {
  font-size: 11px; font-weight: 800;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}
.kpi-card-value {
  font-size: 28px; font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.6px;
  line-height: 1.1;
  word-break: break-all;
}
.kpi-card-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 6px;
  font-weight: 600;
}
.kpi-card-sub.positive { color: var(--positive); }
.kpi-card-sub.negative { color: var(--negative); }

/* ===========================================================
   PREMIUM CARD (used by charts, tables, accordion containers)
   =========================================================== */
.p-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  margin: 0 16px 20px;
  overflow: hidden;
}
@media (min-width: 900px) {
  .p-card { margin: 0 0 24px; }
}
.p-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--hairline);
}
.p-card-title {
  font-size: 12px; font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  display: flex; align-items: center; gap: 10px;
}
.p-card-title-icon {
  width: 24px; height: 24px;
  background: var(--brand-50); color: var(--brand-700);
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.p-card-action {
  font-size: 11px; font-weight: 800;
  color: var(--brand-600);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  cursor: pointer;
  background: transparent; border: 0;
}
.p-card-action:hover { color: var(--brand-700); }
.p-card-body { padding: 20px 22px; }

/* Two-column row pattern on desktop (charts side by side) */
.p-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 0 0 24px;
}
@media (max-width: 900px) {
  .p-grid-2 { grid-template-columns: 1fr; margin: 0 16px 20px; gap: 16px; }
  .p-grid-2 > .p-card { margin: 0; }
}

/* ===========================================================
   ACTIVE INSTRUMENTS TABLE
   =========================================================== */
.ai-table { width: 100%; }
.ai-table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 80px 130px;
  gap: 12px;
  padding: 10px 22px;
  background: var(--surface-2);
  font-size: 11px; font-weight: 800;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.ai-table-head > div:last-child { text-align: right; }
.ai-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 80px 130px;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--hairline);
  align-items: center;
  cursor: pointer;
  transition: background 0.12s;
}
.ai-row:hover { background: var(--surface-2); }
.ai-row-instrument {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
.ai-row-icon {
  width: 32px; height: 32px;
  background: var(--surface-3);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: var(--ink-muted);
  flex-shrink: 0;
}
.ai-row-icon img { width: 100%; height: 100%; border-radius: 8px; object-fit: cover; }
.ai-row-text { min-width: 0; }
.ai-row-name {
  font-size: 14px; font-weight: 700;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-row-sub {
  font-size: 11px; font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.ai-row-bank, .ai-row-yield {
  font-size: 13px; font-weight: 600;
  color: var(--ink);
}
.ai-row-yield.positive { color: var(--positive); }
.ai-row-position {
  text-align: right;
  font-size: 15px; font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Compact responsive table on mobile */
@media (max-width: 700px) {
  .ai-table-head { display: none; }
  .ai-row {
    grid-template-columns: 36px 1fr auto;
    grid-template-areas: "icon name pos" "icon sub  sub";
    padding: 12px 16px;
    gap: 10px;
  }
  .ai-row-icon       { grid-area: icon; }
  .ai-row-instrument { display: contents; }
  .ai-row-text       { grid-area: name; }
  .ai-row-name       { grid-area: name; }
  .ai-row-sub        { grid-area: sub; }
  .ai-row-bank, .ai-row-yield { display: none; }
  .ai-row-position   { grid-area: pos; font-size: 14px; }
}

/* ===========================================================
   PREMIUM HERO (Net Liquidity)
   =========================================================== */
.premium-hero {
  background: linear-gradient(135deg, #0b0f17 0%, #1e2937 60%, #064e3b 100%);
  color: white;
  border-radius: 18px;
  padding: 32px 28px;
  margin: 0 16px 28px;
  position: relative;
  overflow: hidden;
}
@media (min-width: 900px) { .premium-hero { margin: 0 0 32px; padding: 36px 36px; } }
.premium-hero::before {
  content: '';
  position: absolute; top: -100px; right: -80px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(16,185,129,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.premium-hero-tagline {
  font-size: 11px; font-weight: 800;
  color: var(--brand-100);
  letter-spacing: 1.5px; text-transform: uppercase;
  margin-bottom: 10px;
}
.premium-hero-label {
  font-size: 14px;
  color: rgba(255,255,255,0.65);
  font-weight: 600;
  margin-bottom: 8px;
}
.premium-hero-value {
  font-size: 52px; font-weight: 800;
  color: white;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.2px;
  line-height: 1.05;
}
@media (max-width: 600px) { .premium-hero-value { font-size: 38px; } }
.premium-hero-meta { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.premium-hero-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 700;
  background: rgba(255,255,255,0.12);
  color: white;
}
.premium-hero-pill.positive { background: rgba(34,197,94,0.18); color: #86efac; }
.premium-hero-pill.negative { background: rgba(248,113,113,0.18); color: #fca5a5; }

/* ===========================================================
   TIME RANGE SELECTOR (1D / 1W / 1M / 3M / 1Y / ALL)
   =========================================================== */
.range-selector {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 3px;
  gap: 0;
}
.range-btn {
  padding: 6px 12px;
  font-size: 12px; font-weight: 700;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.range-btn:hover { color: var(--ink); }
.range-btn.active {
  background: var(--brand-600);
  color: white;
}

/* ===========================================================
   SECTION SPACING — keep mobile padding consistent
   =========================================================== */
.dashboard-body, .accounts-body, .scanner-body, .settings-body, .review-body {
  padding-top: 0;
}

/* Hide the old simple page-header on premium pages — they use page-header-row */
.dashboard-view .page-header,
.accounts-view-premium .page-header { display: none; }

/* Override the legacy section-title to use premium style */
.section-title {
  font-size: 12px; font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding: 0 16px;
  margin: 28px 0 14px;
  display: flex; justify-content: space-between; align-items: center;
}
@media (min-width: 900px) { .section-title { padding: 0; } }
.section-link {
  font-size: 11px; font-weight: 800;
  color: var(--brand-600);
  letter-spacing: 0.6px;
  cursor: pointer;
}
.section-link:hover { color: var(--brand-700); }

/* ============================================================
   PREMIUM FINTECH MAKEOVER — v30
   Inspired by reference design language: tagline + display H1,
   subtle cards with hairlines, dense data tables, premium spacing.
   ============================================================ */

/* Generic premium card — base for charts, instruments table, etc */
.dashboard-view .card {
  background: var(--surface, #fff);
  border: 1px solid var(--hairline, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(11, 15, 23, 0.04), 0 1px 2px rgba(11, 15, 23, 0.03);
  margin-bottom: 20px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.dashboard-view .card:hover {
  box-shadow: 0 4px 12px rgba(11, 15, 23, 0.06), 0 2px 4px rgba(11, 15, 23, 0.04);
}
.dashboard-view .card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--hairline, #e5e7eb);
}
.dashboard-view .card-title-row {
  display: flex; align-items: center; gap: 10px;
}
.dashboard-view .card-title-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--brand-50, #ecfdf5);
  color: var(--brand-700, #047857);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.dashboard-view .card-title {
  font-size: 12px; font-weight: 800;
  letter-spacing: 0.7px; text-transform: uppercase;
  color: #0b0f17;
}
.dashboard-view .card-title-sub {
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dashboard-view .card-title-sub.positive { color: #15803d; }
.dashboard-view .card-title-sub.negative { color: #b91c1c; }
.dashboard-view .card-title-sub.neutral  { color: #475569; }
.dashboard-view .card-title-link {
  background: transparent; border: 0;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--brand-600, #059669);
  cursor: pointer;
  padding: 6px 10px; border-radius: 6px;
  transition: background-color 0.15s;
}
.dashboard-view .card-title-link:hover {
  background: var(--brand-50, #ecfdf5);
}
.dashboard-view .card-body {
  padding: 18px 22px 20px;
}
.dashboard-view .card-body-chart {
  height: 280px;
  padding: 14px 18px 18px;
  position: relative;
}
.dashboard-view .card-body-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Two-column row for Appreciation + Allocation */
.dashboard-view .dash-2col {
  display: grid; gap: 20px;
  grid-template-columns: 1fr;
  margin-bottom: 4px;
}
@media (min-width: 1024px) {
  .dashboard-view .dash-2col {
    grid-template-columns: 1.7fr 1fr;
  }
}

/* Asset Allocation donut */
.dashboard-view .card-body-donut {
  display: flex;
  flex-direction: column;    /* ALWAYS stack: pie on top, legend below */
  align-items: center;
  gap: 16px;
  padding: 18px 22px 20px;
}
/* No side-by-side — always vertical per user request */
.dashboard-view .donut-wrap {
  position: relative;
  width: 100%; height: 200px;
  display: flex; align-items: center; justify-content: center;
}
.dashboard-view .donut-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 200px;
  max-height: 200px;
}
.dashboard-view .donut-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;    /* 2-column legend */
  gap: 4px 12px;
  min-width: 0;
  width: 100%;
}
.dashboard-view .donut-legend-row {
  display: grid;
  grid-template-columns: 10px 1fr;   /* dot | label+value stack */
  align-items: start;
  gap: 7px;
  font-size: 13px;
  transition: all 0.2s ease;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}
.dashboard-view .donut-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 3px;   /* align with first text line */
  flex-shrink: 0;
}
.dashboard-view .donut-legend-text {
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}
.dashboard-view .donut-legend-label {
  color: #1e293b;
  font-weight: 700;
  white-space: normal;
  word-break: break-word;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.4px;
  line-height: 1.3;
  margin-bottom: 2px;
}
/* Value block stacks balance + pct on separate lines */
.dashboard-view .donut-legend-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 12px;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.3;
}
.dashboard-view .donut-legend-pct {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 11px;
  color: #334155;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
/* Hover/click highlight on legend row */
.dashboard-view .donut-legend-row.highlight {
  background: var(--brand-50, #ecfdf5);
  transform: scale(1.02);
}
.dashboard-view .donut-legend-row.highlight .donut-legend-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--brand-700, #047857);
}
.dashboard-view .donut-legend-row.highlight .donut-legend-value {
  font-size: 13px;
  font-weight: 800;
  color: var(--brand-700, #047857);
}
.dashboard-view .donut-legend-row.highlight .donut-legend-pct {
  color: var(--brand-600, #059669);
  font-weight: 700;
}

/* Active Instruments table */
.dashboard-view .card-body-table { padding: 0; }
.dashboard-view .instruments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.dashboard-view .instruments-table thead {
  background: #f7f8fa;
}
.dashboard-view .instruments-table th {
  padding: 12px 22px;
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #64748b;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline, #e5e7eb);
}
.dashboard-view .instruments-table th.col-position,
.dashboard-view .instruments-table td.col-position {
  text-align: right;
}
.dashboard-view .instruments-table th.col-yield,
.dashboard-view .instruments-table td.col-yield {
  text-align: center;
}
.dashboard-view .instruments-row {
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.04);
  transition: background-color 0.12s;
}
.dashboard-view .instruments-row:hover {
  background: #fafbfc;
}
.dashboard-view .instruments-row td {
  padding: 14px 22px;
  border-bottom: 1px solid #f1f5f9;
}
.dashboard-view .instruments-row:last-child td {
  border-bottom: 0;
}
.dashboard-view .instr-cell {
  display: flex; align-items: center; gap: 12px;
}
.dashboard-view .instr-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  flex-shrink: 0;
}
.dashboard-view .instr-text { min-width: 0; }
.dashboard-view .instr-name {
  font-size: 14px; font-weight: 700;
  color: #0b0f17;
  word-break: break-word;
}
.dashboard-view .instr-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #64748b;
  margin-top: 2px;
}
.dashboard-view .col-bank {
  color: #0b0f17;
  font-weight: 500;
  font-size: 13px;
}
.dashboard-view .yield-positive {
  font-weight: 800;
  color: #15803d;
  font-variant-numeric: tabular-nums;
}
.dashboard-view .yield-neutral {
  font-weight: 600;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}
.dashboard-view .position-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 14px;
  color: #0b0f17;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}
.dashboard-view .position-sub {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.6px;
  margin-top: 1px;
}

/* Section divider before category drill-in */
.dashboard-view .dash-section-divider {
  display: flex; align-items: center;
  gap: 12px;
  margin: 28px 14px 14px;
}
.dashboard-view .dash-section-divider::before,
.dashboard-view .dash-section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--hairline, #e5e7eb);
}
.dashboard-view .dash-section-divider span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #94a3b8;
  text-transform: uppercase;
}

/* KPI tile upgrade — slightly more premium */
.kpi-tile {
  padding: 20px 22px !important;
}
.kpi-tile-label {
  color: #64748b !important;
  font-weight: 800 !important;
  font-size: 11px !important;
  letter-spacing: 0.6px !important;
}
.kpi-tile-value {
  font-size: 28px !important;
  font-weight: 800 !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: -0.5px !important;
  color: #0b0f17 !important;
  margin: 8px 0 6px !important;
}
.kpi-tile-sub {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #64748b !important;
}
.kpi-tile-sub.positive { color: #15803d !important; }
.kpi-tile-sub.negative { color: #b91c1c !important; }

/* Larger empty state when no accounts */
.dashboard-view .empty-state-large {
  background: var(--surface, #fff);
  border: 1px solid var(--hairline, #e5e7eb);
  border-radius: 16px;
  padding: 50px 30px;
  text-align: center;
  margin: 20px 14px;
}

/* Hide category cards row + the redundant "Your Accounts" section title block
   from prior layouts in case any other view rebuilds use them. */
.dashboard-view .category-grid { display: none; }

/* Tighten page content gutter on dashboard */
.dashboard-view .pc-wrap {
  padding-left: 14px;
  padding-right: 14px;
}
@media (min-width: 768px) {
  .dashboard-view .pc-wrap {
    padding-left: 22px;
    padding-right: 22px;
  }
}

/* Mobile: stack appreciation curve above donut */
@media (max-width: 640px) {
  .dashboard-view .card-body-chart { height: 220px; }
  .dashboard-view .donut-wrap { height: 160px; }
  .dashboard-view .donut-wrap canvas {
    max-width: 160px; max-height: 160px;
  }
  .dashboard-view .card-header {
    padding: 14px 16px 12px;
  }
  .dashboard-view .card-body { padding: 14px 16px 18px; }
  .dashboard-view .instruments-table th,
  .dashboard-view .instruments-row td {
    padding: 12px 14px;
  }
  /* On mobile, hide the BANK column to keep rows readable */
  .dashboard-view .col-bank { display: none; }
}

/* ===========================================================
   PAGE HEADER STAT PILLS (used by Maturity page)
   =========================================================== */
.ph-stat-pill {
  display: flex; flex-direction: column;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  min-width: 140px;
}
.ph-stat-pill.caution {
  background: #fffbeb;
  border-color: #f59e0b;
}
.ph-stat-pill-label {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--ink-3, #475569);
}
.ph-stat-pill-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px; font-weight: 700;
  color: var(--ink, #0b0f17);
  margin-top: 2px;
}
.ph-stat-pill.caution .ph-stat-pill-value { color: #92400e; }

/* ===========================================================
   CD STRATEGY CENTER — card grid
   =========================================================== */
.cd-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 0 0 24px;
}
@media (min-width: 640px)  { .cd-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .cd-grid { grid-template-columns: 1fr 1fr 1fr; } }

.cd-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
}
.cd-card:hover {
  box-shadow: 0 4px 16px rgba(11,15,23,0.07), 0 1px 4px rgba(11,15,23,0.04);
  border-color: var(--brand-500);
  transform: translateY(-1px);
}
.cd-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cd-card-inst {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--brand-600);
}
.cd-card-badge {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.cd-badge-default { background: var(--brand-50); color: var(--brand-700); }
.cd-badge-warm    { background: #fef3c7; color: #92400e; }
.cd-badge-hot     { background: #fee2e2; color: #991b1b; }
.cd-badge-matured { background: #e0e7ff; color: #3730a3; }

.cd-card-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px; font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.3px;
  margin-bottom: 14px;
}
.cd-card-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 14px;
}
.cd-card-stat {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.cd-card-stat-label {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-3, #475569);
  margin-bottom: 4px;
}
.cd-card-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px; font-weight: 700;
  color: var(--ink);
}
.cd-card-stat-value.pos { color: #15803d; }
.cd-card-stat-value.neg { color: #b91c1c; }
.cd-card-stat-value .pos { color: #15803d; }
.cd-card-stat-value .neg { color: #b91c1c; }
.cd-card-stat-value .muted { color: var(--ink-soft, #94a3b8); }

.cd-card-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0;
  font-size: 12px;
}
.cd-card-row-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-3, #475569);
}
.cd-card-row-val {
  font-size: 13px; font-weight: 700;
  color: var(--ink);
}
.cd-card-row-val.money {
  font-family: 'JetBrains Mono', monospace;
}

.cd-card-progress {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.cd-card-progress-row {
  display: flex; justify-content: space-between;
  margin-bottom: 6px;
}
.cd-card-progress-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-3, #475569);
}
.cd-card-progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.cd-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-600));
  border-radius: 3px;
  transition: width 0.3s;
}

/* ===========================================================
   HALL OF FAME — Ranks page
   =========================================================== */
.rank-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 0 0 24px;
}
@media (min-width: 900px) { .rank-grid { grid-template-columns: 1fr 1fr 1fr; } }

.rank-col {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
}
.rank-col-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--hairline);
}
.rank-col-icon { font-size: 18px; }
.rank-col-title {
  font-size: 12px; font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--ink);
}
.rank-col-body { padding: 8px 8px 12px; }
.rank-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
}
.rank-row:hover { background: var(--surface-2); }
.rank-row + .rank-row { margin-top: 2px; }
.rank-row-info { flex: 1; min-width: 0; }
.rank-row-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}
.rank-row-sub {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--ink-3, #475569);
  margin-top: 2px;
}
.rank-row-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; font-weight: 700;
  color: var(--brand-700);
  white-space: nowrap;
}
.rank-empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 12px; color: var(--ink-3, #475569);
}

.medal {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  flex-shrink: 0;
}
.medal-gold   { background: linear-gradient(135deg, #fde047, #ca8a04); }
.medal-silver { background: linear-gradient(135deg, #e2e8f0, #94a3b8); }
.medal-bronze { background: linear-gradient(135deg, #fdba74, #c2410c); }
.medal-plain {
  background: var(--surface-2);
  color: var(--ink-3, #475569);
  font-size: 12px; font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
}

/* ===========================================================
   Appreciation Curve — empty state fallback
   =========================================================== */
.appreciation-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 280px;
  padding: 32px;
  text-align: center;
}
.appreciation-empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.appreciation-empty-title {
  font-size: 15px; font-weight: 700;
  color: var(--ink, #0b0f17);
  margin-bottom: 6px;
}
.appreciation-empty-text {
  font-size: 13px;
  color: var(--ink-3, #475569);
  max-width: 280px;
  line-height: 1.5;
}

/* ===========================================================
   Type logo (Column O) badge — small glyph for account type
   shown on each row alongside last-4
   =========================================================== */
.acct-type-logo {
  width: 18px; height: 18px;
  border-radius: 4px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
  background: var(--surface-2);
}

/* CD card: institution logo (Column S) as small image inline */
.cd-card-inst-img {
  width: 18px; height: 18px;
  border-radius: 4px;
  object-fit: contain;
  vertical-align: middle;
}

/* ===========================================================
   VIEW TOGGLE BAR — accordion ↔ table switch + subtotal
   =========================================================== */
.view-toggle-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 12px;
  flex-wrap: wrap;
}
.view-toggle-btn {
  padding: 6px 14px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px; font-weight: 600;
  color: var(--ink-3, #475569);
  cursor: pointer;
  transition: all 0.15s;
}
.view-toggle-btn.active {
  background: var(--brand-50, #ecfdf5);
  border-color: var(--brand-500, #10b981);
  color: var(--brand-700, #047857);
  font-weight: 700;
}
.view-subtotal {
  font-size: 13px; font-weight: 700;
  color: var(--ink, #0b0f17);
  font-variant-numeric: tabular-nums;
}

/* ===========================================================
   SORTABLE PORTFOLIO TABLE
   =========================================================== */
.portfolio-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--surface);
  margin: 0 0 16px;
}
.portfolio-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.portfolio-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2, #f7f8fa);
  padding: 12px 14px;
  font-size: 10px; font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-3, #475569);
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  white-space: nowrap;
  user-select: none;
}
.portfolio-table th.sortable { cursor: pointer; }
.portfolio-table th.sortable:hover { color: var(--brand-600); }
.portfolio-table th.col-right,
.portfolio-table td.col-right { text-align: right; }

.portfolio-row {
  cursor: pointer;
  transition: background 0.12s;
}
.portfolio-row:hover { background: var(--surface-2, #f7f8fa); }
.portfolio-row:active { background: var(--surface-3, #eef0f4); }
.portfolio-row td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  vertical-align: middle;
  color: var(--ink, #0b0f17);
}
.portfolio-row:last-child td { border-bottom: 0; }

.port-name {
  font-weight: 700; font-size: 14px;
  color: var(--ink); line-height: 1.3;
}
.port-last4 {
  font-size: 11px; color: var(--ink-3, #475569);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}
.col-inst { font-weight: 600; white-space: nowrap; }
.col-apy { font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.col-balance .money-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.yield-positive { color: var(--brand-600, #059669); }
.muted { color: var(--ink-soft, #94a3b8); }

/* Owner pill */
.owner-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: #e0f2fe; color: #0369a1;
}
.owner-pill.owner-herry    { background: #dcfce7; color: #166534; }
.owner-pill.owner-ethan    { background: #fef3c7; color: #92400e; }
.owner-pill.owner-joint    { background: #e0e7ff; color: #3730a3; }
.owner-pill.owner-self     { background: #f1f5f9; color: #334155; }

/* Type badge */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: var(--surface-2); color: var(--ink-3, #475569);
}

/* Mobile: stack less important columns */
@media (max-width: 768px) {
  .portfolio-table .col-owner,
  .portfolio-table .col-type,
  .portfolio-table .col-apy { display: none; }
}

/* ===========================================================
   MAJOR CATEGORY SUMMARY TABLE — Portfolio Summary on Overview
   =========================================================== */
.mc-table { width: 100%; }
.mc-table thead th {
  font-size: 10px; font-weight: 800;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: #1e3a5f;                   /* dark blue — high contrast */
  padding: 12px 16px;               /* same as td padding */
  border-bottom: 2px solid var(--hairline);
  background: var(--surface-2, #f7f8fa);
  white-space: nowrap;
  user-select: none;
}
/* Ensure right-aligned headers match right-aligned data cells */
.mc-table th.col-right { text-align: right; }
.mc-sortable { cursor: pointer; }
.mc-sortable:hover { color: var(--brand-600); }
.mc-table td {
  padding: 12px 16px;               /* unified with th */
  border-bottom: 1px solid rgba(0,0,0,0.04);
  vertical-align: middle;
  font-size: 14px;
  color: #0f172a;                   /* near-black — high contrast */
}
.mc-table .col-right { text-align: right; }
.mc-cell {
  display: flex; align-items: center; gap: 10px;
}
.mc-icon { font-size: 20px; }
.mc-name {
  font-weight: 700; font-size: 15px;
  color: #0f172a;
}
.mc-count {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: #1e3a5f;                   /* dark blue for numbers */
  font-variant-numeric: tabular-nums;
}
.mc-pct {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: #1e3a5f;                   /* dark blue — was gray */
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.mc-total-row td {
  border-top: 2px solid var(--hairline);
  border-bottom: 0;
  padding: 14px 16px;
  font-weight: 800;
  font-size: 14px;
  background: var(--surface-2, #f7f8fa);
}
.mc-row { cursor: pointer; transition: background 0.12s; }
.mc-row:hover { background: var(--surface-2, #f7f8fa); }

/* Also: ensure money-val has proper font everywhere */
.money-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ===========================================================
   FILTER BAR — dropdown filters replacing chip buttons
   =========================================================== */
.filter-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  flex-wrap: wrap;
}
.search-bar-inline {
  flex: 1 1 220px;
  min-width: 180px;
  position: relative;
  display: flex; align-items: center;
}
.search-bar-inline .search-icon {
  position: absolute; left: 12px;
  font-size: 14px; pointer-events: none;
}
.search-bar-inline input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.search-bar-inline input:focus { border-color: var(--brand-500); }
.search-bar-inline input::placeholder { color: var(--ink-soft); }

.filter-dropdowns {
  gap: 8px;
}
.filter-select {
  padding: 8px 28px 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23475569'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-select:focus { border-color: var(--brand-500); outline: none; }

.filter-export-btn {
  padding: 8px 14px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-size: 13px; font-weight: 700;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.filter-export-btn:hover { background: var(--surface-2); border-color: var(--brand-500); }

/* Sequential numbering column */
.col-seq {
  width: 50px;
  text-align: center;
  padding: 8px 4px !important;
}
.seq-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3, #475569);
  font-variant-numeric: tabular-nums;
}
.seq-total {
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-soft, #94a3b8);
}

/* Mobile: hide less important dropdowns */
@media (max-width: 640px) {
  .filter-dropdowns { flex-wrap: wrap; }
  .filter-select { flex: 1 1 calc(50% - 4px); max-width: none; font-size: 12px; padding: 7px 24px 7px 10px; }
  .filter-export-btn { flex: 0 0 auto; }
}
@media (max-width: 480px) {
  .filter-select { flex: 1 1 100%; }
}

/* ===========================================================
   HALL OF FAME — enhanced rows + mobile stacking
   =========================================================== */
.rank-row-right {
  text-align: right;
  min-width: 0;
  flex-shrink: 0;
}
.rank-row-secondary {
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
}
/* Mobile: force single-column stack so cards don't squeeze */
@media (max-width: 900px) {
  .rank-grid {
    grid-template-columns: 1fr !important;
  }
  .rank-row {
    gap: 8px;
    padding: 8px 10px;
  }
  .rank-row-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }
  .rank-row-value { font-size: 13px; }
  .rank-row-secondary { font-size: 10px; }
}

/* ===========================================================
   LOGO MANAGEMENT in Settings
   =========================================================== */
.logo-mgmt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.logo-mgmt-row:last-child { border-bottom: 0; }
.logo-mgmt-preview {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}
.logo-mgmt-placeholder {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
  color: var(--ink-3);
  flex-shrink: 0;
}
.logo-mgmt-name {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  word-break: break-word;
}
.logo-mgmt-upload-btn {
  padding: 6px 12px;
  border: 1px solid var(--brand-500);
  border-radius: 8px;
  font-size: 12px; font-weight: 700;
  color: var(--brand-600);
  background: var(--brand-50);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.logo-mgmt-upload-btn:hover { background: var(--brand-100); }
.logo-mgmt-reset-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid #fca5a5;
  background: #fef2f2;
  color: #dc2626;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.logo-mgmt-reset-btn:hover { background: #fee2e2; }

/* ===========================================================
   HORIZONTAL TABLE SCROLL — prevent compression on narrow screens.
   The wrapper already has overflow-x: auto. Adding min-width to
   the table itself stops it from compressing below readable width.
   =========================================================== */

/* Portfolio flat table */
.portfolio-table {
  min-width: 680px;   /* never compress below this — scroll instead */
}

/* Major Category Summary (Portfolio Summary on Overview) */
.mc-table {
  min-width: 540px;
}

/* Active Instruments / generic data table inside a card */
.instruments-table,
.dashboard-view .instruments-table {
  min-width: 520px;
}

/* Ensure ALL card-body-table containers scroll horizontally */
.card-body-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ranks table */
.rank-col .rank-col-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===========================================================
   HIGH-CONTRAST TYPOGRAPHY OVERRIDES (Session 7)
   Replace gray (#94a3b8, #475569) with readable dark colors
   on all financial values, KPI tiles, and table data.
   =========================================================== */

/* KPI tile label: dark blue instead of gray */
.kpi-tile-label {
  color: #1e3a5f !important;
}
/* KPI tile sub-value: dark when neutral */
.kpi-tile-sub {
  color: #334155 !important;
}
/* kpi-tile-sub.positive / .negative use their own !important rules — untouched */

/* Portfolio table: ensure value cells are near-black */
.portfolio-table td { color: #0f172a; }
.portfolio-table thead th { color: #1e3a5f; }

/* mc-total-row: dark text */
.mc-total-row td { color: #0f172a !important; }

/* Hall of Fame rank rows */
.rank-row-sub { color: #334155 !important; }

/* Category accordion meta lines */
.cat-acc-row-meta { color: #334155 !important; }

/* CD card secondary text */
.cd-card-inst span { color: #0f172a; font-weight: 700; }

/* Yield positive green — already fine, just reinforce */
.yield-positive { color: #15803d !important; font-weight: 700; }

/* Muted values: slightly less gray than before */
.muted { color: #64748b !important; }

/* seq-total (1/54) — keep softer */
.seq-total { color: #64748b; }

/* View subtotal count */
.view-subtotal { color: #0f172a !important; font-weight: 700; }

/* ===========================================================
   SESSION 8 — LOGO INTEGRATION CSS
   =========================================================== */

/* Shared logo img used by App.logoImgHtml() */
.shared-logo-img {
  border-radius: 6px; object-fit: contain; flex-shrink: 0;
  background: var(--surface-2);
}

/* Portfolio Summary — category logo in mc-cell */
.mc-cat-logo {
  width: 24px; height: 24px;
  border-radius: 5px; object-fit: contain;
  flex-shrink: 0;
}

/* Hall of Fame — rank badge (replaces emoji medals) */
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 15px; font-weight: 900;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Hall of Fame — institution logo in rank row sub-line */
.rank-inst-logo {
  width: 16px; height: 16px;
  border-radius: 3px; object-fit: contain;
  vertical-align: middle;
  margin-right: 4px;
}
.rank-row-sub {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
}

/* Settings — text input for alias entry */
.settings-text-input {
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  min-width: 180px;
  transition: border-color 0.15s;
}
.settings-text-input:focus { border-color: var(--brand-500); }

/* ===========================================================
   SESSION 9 — FILTER / SORT CSS
   =========================================================== */

/* ── Multi-select <details> dropdown ────────────────────────── */
.ms-dropdown {
  position: relative;
  flex: 0 1 auto;
}
.ms-summary {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  user-select: none;
  white-space: nowrap;
  min-width: 130px;
  transition: border-color 0.15s, background 0.15s;
}
.ms-summary::-webkit-details-marker { display: none; }
.ms-summary.ms-active {
  background: var(--brand-50, #ecfdf5);
  border-color: var(--brand-500);
  color: var(--brand-700);
}
.ms-dropdown[open] .ms-summary {
  border-color: var(--brand-500);
  border-radius: 8px 8px 0 0;
}
.ms-arrow {
  margin-left: auto;
  font-size: 10px;
  color: var(--ink-3);
  transition: transform 0.15s;
}
.ms-dropdown[open] .ms-arrow { transform: rotate(180deg); }

.ms-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--brand-500);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}
.ms-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  color: var(--ink);
  transition: background 0.1s;
}
.ms-item:hover { background: var(--surface-2); }
.ms-all-item {
  font-weight: 700;
  border-bottom: 1px solid var(--hairline);
}
/* Hide the native checkbox — use custom indicator */
.ms-item input[type="checkbox"] { display: none; }
/* Custom checkmark box */
.ms-check-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 2px solid var(--hairline-strong, #cbd5e1);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, border-color 0.1s;
}
.ms-item input:checked ~ .ms-check-icon {
  background: var(--brand-600);
  border-color: var(--brand-600);
}
.ms-item input:checked ~ .ms-check-icon::after {
  content: '✓';
  font-size: 11px;
  color: white;
  font-weight: 800;
  line-height: 1;
}

/* ── Reset Filters button ───────────────────────────────────── */
.filter-reset-btn {
  padding: 8px 12px;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  font-size: 12px; font-weight: 700;
  background: #fef2f2;
  color: #b91c1c;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.filter-reset-btn:hover { background: #fee2e2; }

/* ── Sort indicators ────────────────────────────────────────── */
.sort-ind {
  display: inline-block;
  margin-left: 5px;
  font-size: 9px;
  color: #cbd5e1;            /* light gray — inactive */
  letter-spacing: -1px;
  vertical-align: middle;
  line-height: 1;
  transition: color 0.1s;
}
.sort-ind--active {
  color: #0f172a;            /* near-black — active */
  font-size: 10px;
}
/* Active column header gets slightly darker background */
.portfolio-table thead th.sort-active {
  background: #f1f5f9;
  color: #0f172a;
}

/* Mobile: ms-dropdown takes full width */
@media (max-width: 640px) {
  .ms-dropdown { flex: 1 1 calc(50% - 4px); }
  .ms-summary { min-width: 0; }
}
@media (max-width: 480px) {
  .ms-dropdown { flex: 1 1 100%; }
}

/* ===========================================================
   SESSION 10 — CD CARD REDESIGN + BADGES + HALL OF FAME
   =========================================================== */

/* ── CD Card v2 header (big logo left, number right) ────────── */
.cd-card-head-v2 {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.cd-card-inst-v2 {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
.cd-inst-logo-big {
  width: 40px; height: 40px;
  border-radius: 10px;
  object-fit: contain;
  background: #f1f5f9;
  border: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.cd-inst-logo-fallback {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--brand-600);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
  flex-shrink: 0;
}
.cd-card-inst-info {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
.cd-card-inst-name {
  font-size: 13px; font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.cd-card-inst-type {
  font-size: 10px; font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.cd-card-head-right {
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 6px;
  flex-shrink: 0;
  min-width: 0;
}
.cd-card-acct-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 700;
  color: #334155;
  letter-spacing: 0.5px;
  text-align: right;
}

/* CD stats row: 3 columns (APY, Balance, ROI) */
.cd-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

/* ── Sidebar alert badge ─────────────────────────────────────── */
.side-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #dc2626;
  color: white;
  font-size: 10px; font-weight: 800;
  margin-left: auto;
  flex-shrink: 0;
}
.side-badge.hidden { display: none; }

/* Maturity badge — amber color to distinguish from review red */
#side-maturity-badge {
  background: #d97706;
}

/* ── Hall of Fame polish ─────────────────────────────────────── */
/* Rank badges: ensure consistent sizing + font */
.rank-badge {
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 16px; font-weight: 900;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
}
/* Rank 1 = gold, 2 = silver, 3 = bronze */
.rank-row:nth-child(1) .rank-badge { background:#fef3c7; color:#92400e; border: 2px solid #fcd34d; }
.rank-row:nth-child(2) .rank-badge { background:#f1f5f9; color:#374151; border: 2px solid #d1d5db; }
.rank-row:nth-child(3) .rank-badge { background:#fef3c7; color:#92400e; border: 2px solid #fcd34d; opacity:0.8; }
.rank-row:nth-child(4) .rank-badge,
.rank-row:nth-child(5) .rank-badge { background:#f8fafc; color:#64748b; border: 1px solid #e2e8f0; font-size:14px; }

/* Rank rows: card feel, more padding */
.rank-row {
  display: flex; align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  cursor: pointer;
  transition: background 0.12s;
  border-radius: 8px;
}
.rank-row:last-child { border-bottom: 0; }
.rank-row:hover { background: var(--surface-2); }
.rank-row-info { flex: 1; min-width: 0; }
.rank-row-name {
  font-size: 14px; font-weight: 700;
  color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-row-sub {
  font-size: 11px; color: #334155; font-weight: 600;
  margin-top: 2px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 3px;
}
.rank-row-right { text-align: right; flex-shrink: 0; }
.rank-row-value { font-size: 14px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.rank-row-secondary { font-size: 11px; margin-top: 2px; }

/* Hall of fame columns: fill available height nicely */
.rank-col.card { overflow: hidden; }
.rank-col-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
}
.rank-col-icon { font-size: 20px; }
.rank-col-title {
  font-size: 11px; font-weight: 800;
  color: #1e3a5f;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ===========================================================
   INTEREST PAYOUT DASHBOARD
   =========================================================== */

/* KPI Strip */
.payout-kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 900px) {
  .payout-kpi-strip { grid-template-columns: repeat(6, 1fr); }
}
.payout-kpi {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}
.payout-kpi-label {
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.7px;
  color: #1e3a5f; margin-bottom: 6px;
}
.payout-kpi-value {
  font-size: 18px; font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: #0f172a; font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.payout-kpi-next { font-size: 13px; }
.payout-kpi-sub {
  display: block; font-size: 11px; font-weight: 600;
  color: #64748b; margin-top: 2px;
  font-family: inherit;
}

/* Calendar */
.payout-cal-wrap {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
.payout-cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
}
.payout-cal-title {
  font-size: 17px; font-weight: 800; color: #0f172a;
  display: flex; align-items: center; gap: 12px;
}
.payout-cal-month-total {
  font-size: 13px; font-weight: 700;
  color: var(--brand-600);
  background: var(--brand-50);
  padding: 3px 10px; border-radius: 20px;
}
.payout-cal-nav {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.payout-cal-nav:hover { background: var(--surface-2); }
.payout-cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 10px 16px 6px;
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b; text-align: center;
}
.payout-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 4px 12px 16px; gap: 4px;
}
.cal-day {
  min-height: 72px;
  border-radius: 10px;
  padding: 6px 8px;
  position: relative;
  cursor: default;
  transition: background 0.1s;
}
.cal-day-empty { background: transparent; }
.cal-past .cal-day-num { color: #cbd5e1; }
.cal-today { background: #eff6ff; border: 2px solid #3b82f6; }
.cal-today .cal-day-num { color: #1d4ed8; font-weight: 900; }
.cal-has-payout { background: var(--brand-50); cursor: pointer; }
.cal-has-payout:hover { background: #d1fae5; }
.cal-day-num {
  font-size: 12px; font-weight: 700; color: #334155;
  margin-bottom: 4px;
}
.cal-payout-bubble { }
.cal-payout-amt {
  font-size: 11px; font-weight: 800;
  color: var(--brand-700);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.cal-payout-count {
  font-size: 9px; font-weight: 600;
  color: var(--brand-500);
}
.payout-cal-legend {
  padding: 8px 20px 12px;
  font-size: 11px; color: #64748b;
  display: flex; align-items: center; gap: 6px;
}
.cal-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%; display: inline-block;
}

/* Payout table */
.payout-table { min-width: 800px; }
.payout-urgent td { background: #fef2f2 !important; }
.payout-soon td { background: #fefce8 !important; }
.payout-rule-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px; font-weight: 700;
  background: #e0f2fe; color: #0369a1;
  text-transform: uppercase;
}

/* Institution groups */
.payout-group-card {
  margin-bottom: 16px; overflow: hidden;
}
.payout-group-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
}
.payout-group-inst { display: flex; align-items: center; gap: 12px; }
.payout-group-logo {
  width: 40px; height: 40px;
  border-radius: 10px; object-fit: contain;
  background: white; border: 1px solid var(--hairline);
}
.payout-group-logo-fallback {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--brand-600); color: white;
  font-size: 18px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.payout-group-name { font-size: 15px; font-weight: 800; color: #0f172a; }
.payout-group-sub  { font-size: 12px; color: #64748b; margin-top: 2px; }
.payout-group-totals { text-align: right; }
.payout-group-total-label { font-size: 9px; font-weight: 800; color: #1e3a5f; text-transform: uppercase; letter-spacing: 0.5px; }
.payout-group-total-val { font-size: 20px; font-weight: 900; font-family: 'JetBrains Mono', monospace; }
.payout-group-total-sub { font-size: 11px; color: #64748b; }
.payout-group-rows { padding: 4px 0; }
.payout-group-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  align-items: center; gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 13px;
}
.payout-group-row:last-child { border-bottom: 0; }
.payout-group-row-name { font-weight: 700; color: #0f172a; }
.payout-group-row-meta { color: #64748b; font-size: 12px; }
.payout-group-row-next { color: #334155; font-size: 12px; font-weight: 600; }
.payout-group-row-amt {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800; font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Payout modal */
.payout-modal-row {
  border: 1px solid var(--hairline);
  border-radius: 10px; padding: 12px 16px;
  margin-bottom: 10px;
}
.payout-modal-inst { font-size: 14px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.payout-modal-meta { display: flex; gap: 16px; font-size: 12px; color: #64748b; margin-bottom: 6px; }
.payout-modal-amount { font-size: 18px; font-weight: 900; font-family: 'JetBrains Mono', monospace; }

/* Positive color */
.pos { color: #15803d !important; }

/* ===========================================================
   INTEREST DASHBOARD — PREMIUM INSTITUTION GROUP CARDS (pig)
   =========================================================== */

.pig-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}

/* ── Institution Header ─────────────────────────────────── */
.pig-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  color: white;
}
.pig-header-left {
  display: flex; align-items: center; gap: 14px;
}
.pig-logo-wrap {
  width: 52px; height: 52px; flex-shrink: 0;
}
.pig-logo-img {
  width: 52px; height: 52px;
  border-radius: 12px; object-fit: contain;
  background: white; border: 2px solid rgba(255,255,255,0.2);
}
.pig-logo-fallback {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900; color: white;
  border: 2px solid rgba(255,255,255,0.2);
}
.pig-inst-name {
  font-size: 20px; font-weight: 900;
  color: white; letter-spacing: 0.3px;
}
.pig-inst-meta {
  font-size: 12px; color: rgba(255,255,255,0.65);
  margin-top: 3px; font-weight: 600;
}
.pig-header-stats {
  display: flex; gap: 24px; flex-wrap: wrap;
}
.pig-stat { text-align: right; }
.pig-stat-label {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.8px; text-transform: uppercase;
  color: rgba(255,255,255,0.55); margin-bottom: 4px;
}
.pig-stat-val {
  font-size: 17px; font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: white; font-variant-numeric: tabular-nums;
}
.pig-stat-val.yield-positive { color: #6ee7b7 !important; }
.pig-stat-val.pos { color: #6ee7b7 !important; }

/* ── Sort bar ───────────────────────────────────────────── */
.pig-sort-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.pig-sort-label {
  font-size: 11px; font-weight: 700;
  color: #64748b; margin-right: 4px;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.pig-sort-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-size: 11px; font-weight: 700;
  color: #475569; cursor: pointer;
  transition: all 0.12s;
}
.pig-sort-btn.active {
  background: var(--brand-600); color: white;
  border-color: var(--brand-600);
}
.pig-sort-btn:hover:not(.active) { background: var(--surface-2); }

/* ── Account rows ───────────────────────────────────────── */
.pig-accounts { padding: 8px 0; }
.pig-acct {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  transition: background 0.1s;
}
.pig-acct:last-child { border-bottom: 0; }
.pig-acct:hover { background: var(--surface-2); }
.pig-acct-urgent { background: #fef2f2 !important; }
.pig-acct-soon   { background: #fefce8 !important; }

/* Row 1: Identity + balance ───────────────────────────── */
.pig-acct-top {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.pig-acct-identity {
  display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap; min-width: 0;
}
.pig-acct-rank {
  font-size: 11px; font-weight: 800;
  color: white; background: #1e3a5f;
  padding: 2px 7px; border-radius: 20px;
  flex-shrink: 0;
}
.pig-acct-name {
  font-size: 15px; font-weight: 800; color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 240px;
}
.pig-acct-last4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 600; color: #64748b;
  background: var(--surface-2);
  padding: 2px 8px; border-radius: 6px;
  flex-shrink: 0;
}
.pig-acct-type { flex-shrink: 0; }
.pig-acct-balance {
  font-size: 20px; font-weight: 900;
  font-family: 'JetBrains Mono', monospace;
  color: #0f172a; font-variant-numeric: tabular-nums;
  white-space: nowrap; flex-shrink: 0;
}

/* Row 2: Metrics grid ─────────────────────────────────── */
.pig-acct-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 16px;
  margin-bottom: 12px;
}
@media (min-width: 768px) {
  .pig-acct-metrics { grid-template-columns: repeat(6, 1fr); }
}
.pig-metric { }
.pig-metric-label {
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b; margin-bottom: 3px;
}
.pig-metric-val {
  font-size: 13px; font-weight: 700;
  color: #0f172a;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

/* Next payout badge */
.pig-payout-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700;
  background: #dcfce7; color: #166534;
  font-family: inherit;
}
.pig-payout-badge--hot {
  background: #fef3c7; color: #92400e;
}
.pig-next-amt {
  display: block; font-size: 12px;
  font-weight: 700; margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}

/* Row 3: Progress bars ───────────────────────────────── */
.pig-acct-bars {
  display: flex; flex-direction: column; gap: 5px;
}
.pig-bar-item { }
.pig-bar-label {
  font-size: 10px; color: #94a3b8; font-weight: 600;
  margin-bottom: 3px;
}
.pig-bar-label strong { color: #475569; }
.pig-bar-track {
  height: 5px; border-radius: 3px;
  background: #e2e8f0; overflow: hidden;
}
.pig-bar-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.4s ease;
}
.pig-bar-fill--bal  { background: var(--brand-600); }
.pig-bar-fill--earn { background: #f59e0b; }

/* ===========================================================
   LOGO STANDARDIZATION SYSTEM  (v53+ unified sizing)
   3 canonical tiers — used everywhere:
     SM  = 24px  inline rows, badges, rank lists
     MD  = 40px  account rows, CD cards, payout groups
     LG  = 52px  institution headers, page-level cards
   All containers: object-fit:contain, border-radius:8px
   =========================================================== */

/* ── Variables ─────────────────────────────────────────── */
:root {
  --logo-sm:  24px;
  --logo-md:  40px;
  --logo-lg:  52px;
  --logo-radius: 8px;
  --logo-bg:  #f8fafc;
  --logo-border: 1px solid rgba(0,0,0,0.07);
}

/* ── Generic logo container (use logo-sm / logo-md / logo-lg) ── */
.logo-wrap {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--logo-radius);
  background: var(--logo-bg);
  border: var(--logo-border);
  overflow: hidden;
}
.logo-wrap img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.logo-wrap img[src=""],
.logo-wrap img:not([src]) { display: none; }
/* Fallback initial letter */
.logo-wrap-fallback {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-weight: 900; color: white;
  background: var(--brand-600);
  font-family: system-ui, sans-serif;
}
/* Size modifiers */
.logo-sm  { width: var(--logo-sm);  height: var(--logo-sm);  font-size: 10px; }
.logo-md  { width: var(--logo-md);  height: var(--logo-md);  font-size: 16px; }
.logo-lg  { width: var(--logo-lg);  height: var(--logo-lg);  font-size: 20px; border-radius: 12px; }

/* ── Override all existing logo classes to match new standards ── */
/* SM (24px) — rank rows, table inline, type badges */
.rank-inst-logo { width: var(--logo-sm) !important; height: var(--logo-sm) !important; border-radius: var(--logo-radius) !important; object-fit: contain !important; }
.acct-type-logo { width: var(--logo-sm) !important; height: var(--logo-sm) !important; border-radius: 5px !important; object-fit: contain !important; }
.mc-cat-logo    { width: var(--logo-sm) !important; height: var(--logo-sm) !important; border-radius: 5px !important; object-fit: contain !important; }
.cd-card-inst-img { width: var(--logo-sm) !important; height: var(--logo-sm) !important; border-radius: 5px !important; object-fit: contain !important; }

/* MD (40px) — account rows, CD cards, grouped views */
.inst-logo-big,
.payout-group-logo,
.cd-inst-logo-big { width: var(--logo-md) !important; height: var(--logo-md) !important; border-radius: var(--logo-radius) !important; object-fit: contain !important; background: var(--logo-bg) !important; border: var(--logo-border) !important; }
.payout-group-logo-fallback { width: var(--logo-md) !important; height: var(--logo-md) !important; border-radius: var(--logo-radius) !important; font-size: 18px !important; }
.cd-inst-logo-fallback { width: var(--logo-md) !important; height: var(--logo-md) !important; border-radius: var(--logo-radius) !important; font-size: 18px !important; }

/* LG (52px) — institution header cards (By Institution, pig) */
.pig-logo-img     { width: var(--logo-lg) !important; height: var(--logo-lg) !important; border-radius: 12px !important; object-fit: contain !important; background: white !important; }
.pig-logo-fallback { width: var(--logo-lg) !important; height: var(--logo-lg) !important; border-radius: 12px !important; font-size: 22px !important; }

/* Settings logo preview rows */
.logo-mgmt-preview      { width: 40px !important; height: 40px !important; border-radius: var(--logo-radius) !important; object-fit: contain !important; }
.logo-mgmt-placeholder  { width: 40px !important; height: 40px !important; border-radius: var(--logo-radius) !important; }

/* Shared logo img utility */
.shared-logo-img { border-radius: var(--logo-radius) !important; object-fit: contain !important; }

/* ===========================================================
   SCANNER REVIEW — improved card + edit modal
   =========================================================== */
.scan-account-low-conf {
  border-left: 3px solid #f59e0b !important;
  background: #fffbeb;
}
.scan-low-conf-warning {
  font-size: 11px; font-weight: 700;
  color: #92400e; background: #fef3c7;
  padding: 4px 10px; border-radius: 6px;
  margin-bottom: 6px;
}
.scan-inst-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; color: #1e3a5f;
  background: #eff6ff; padding: 2px 8px;
  border-radius: 6px; flex-shrink: 0;
}
.scan-inst-logo {
  width: 16px !important; height: 16px !important;
  border-radius: 3px !important; object-fit: contain !important;
}
.scan-edit-hint {
  font-size: 12px; color: var(--brand-600); font-weight: 600;
  padding: 8px 12px; background: var(--brand-50);
  border-radius: 8px; margin-bottom: 16px;
}
/* Known Accounts suggestion buttons */
.scan-known-suggestions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 6px;
}
.scan-known-btn {
  padding: 5px 12px;
  border: 1px solid var(--brand-300, #6ee7b7);
  border-radius: 7px;
  font-size: 12px; font-weight: 700;
  color: var(--brand-700); background: var(--brand-50);
  cursor: pointer; transition: background 0.12s;
  text-align: left;
}
.scan-known-btn:hover { background: #d1fae5; }

/* ===========================================================
   MOBILE NAVIGATION SYSTEM  (v59+)
   Breakpoints:
     Desktop  ≥ 900px : persistent sidebar, no mobile header
     Mobile   < 900px : slide-out drawer, mobile header, bottom nav
   =========================================================== */

/* ── Mobile Header ──────────────────────────────────────── */
.mobile-header {
  display: none;             /* hidden on desktop */
}
@media (max-width: 899px) {
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    flex-shrink: 0;           /* never collapse */
  }
}

/* Hamburger button */
.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 0; background: transparent;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:hover,
.hamburger-btn:focus-visible { background: var(--surface-2); }
.hamburger-btn:focus-visible { outline: 2px solid var(--brand-600); }
.hamburger-bar {
  display: block;
  width: 22px; height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transform-origin: center;
  transition: transform 0.22s ease, opacity 0.22s ease, width 0.22s ease;
}
/* Animate to X when open */
#app.sidebar-open .hamburger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#app.sidebar-open .hamburger-bar:nth-child(2) { opacity: 0; width: 0; }
#app.sidebar-open .hamburger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Brand mark in mobile header */
.mobile-header-brand {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.mobile-header-logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: 14px;
  flex-shrink: 0;
}
.mobile-header-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700; font-size: 17px;
  color: var(--ink); letter-spacing: -0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mobile-header-right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

/* ── Sidebar Backdrop (overlay behind drawer) ────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  z-index: 149;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.is-visible {
  display: block;
  opacity: 1;
}

/* ── Mobile Sidebar Drawer ───────────────────────────────── */
@media (max-width: 899px) {
  .sidebar {
    display: flex !important;          /* override the mobile display:none */
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 150;
    background: var(--surface);
    border-right: 1px solid var(--hairline);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    padding: 20px 16px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Start offscreen */
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  /* Prevent body scroll when drawer is open */
  body.sidebar-drawer-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
  /* Close button — visible in mobile drawer */
  .sidebar-close-btn {
    display: flex;
    align-self: flex-end;
    align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 1px solid var(--hairline);
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 12px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .sidebar-close-btn:hover { background: var(--surface-3, #f1f5f9); }
  /* Larger touch targets on mobile */
  .side-btn {
    padding: 13px 14px;
    font-size: 15px;
    border-radius: 10px;
  }
  .side-icon { font-size: 18px; }
}

/* ── Desktop: hide close button ─────────────────────────── */
@media (min-width: 900px) {
  .sidebar-close-btn { display: none; }
  .sidebar-backdrop   { display: none !important; }
}

/* ── App grid — account for mobile header row ────────────── */
@media (max-width: 899px) {
  #app {
    display: flex;
    flex-direction: column;
  }
  .main-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Slightly smaller padding on mobile */
    padding: 16px 16px 80px;    /* 80px bottom for bottom nav */
  }
}

/* ── Bottom nav improvements ─────────────────────────────── */
@media (max-width: 899px) {
  .bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    border-top: 1px solid var(--hairline);
    background: var(--surface);
    z-index: 90;
    display: flex;
    align-items: stretch;
    padding: 0;
    /* Safe area for iPhone notch */
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -1px 8px rgba(0,0,0,0.06);
  }
  .nav-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    border: 0; background: transparent;
    cursor: pointer;
    padding: 8px 4px;
    color: var(--ink-soft);
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.12s;
    min-width: 0;
  }
  .nav-btn.active { color: var(--brand-600); }
  .nav-icon { font-size: 20px; line-height: 1; }
  .nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
  /* Scan button accent */
  .nav-btn.nav-scan .nav-icon {
    width: 38px; height: 38px;
    background: var(--brand-600);
    color: white;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(5,150,105,0.35);
  }
}

/* ── Page content: top padding on mobile ────────────────── */
@media (max-width: 899px) {
  /* Remove the top padding that was designed for the no-header layout */
  .ph-wrap { padding: 16px 16px 16px; }
  .ph-title { font-size: 24px !important; }
  .ph-row { margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
}

/* ── Tables: horizontal scroll on mobile ─────────────────── */
@media (max-width: 899px) {
  .portfolio-table-wrap,
  .payout-table,
  .cd-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
  }
  /* Compact table text on mobile */
  .portfolio-table th,
  .portfolio-table td { font-size: 12px; padding: 10px 8px; }
}

/* ── Cards: single column on small mobile ────────────────── */
@media (max-width: 480px) {
  .payout-kpi-strip { grid-template-columns: repeat(2, 1fr) !important; }
  .pig-acct-metrics { grid-template-columns: repeat(2, 1fr) !important; }
  .pig-header { flex-direction: column; gap: 12px; }
  .pig-header-stats { align-self: stretch; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .pig-stat { text-align: left; }
  .pig-header-stats .pig-stat { text-align: left; }
  .cd-card-stats { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ── Calendar: mobile sizing ─────────────────────────────── */
@media (max-width: 899px) {
  .payout-cal-grid { padding: 4px 6px 12px; gap: 2px; }
  .cal-day { min-height: 52px; padding: 4px 5px; border-radius: 7px; }
  .cal-day-num { font-size: 11px; }
  .cal-payout-amt { font-size: 9px; }
  .cal-payout-count { font-size: 8px; }
  .payout-cal-dow { font-size: 9px; padding: 6px 8px 4px; }
  .payout-cal-title { font-size: 14px; flex-wrap: wrap; gap: 6px; }
  .payout-cal-month-total { font-size: 11px; }
}

/* ── Modals: full width on mobile ────────────────────────── */
@media (max-width: 600px) {
  .modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-backdrop { align-items: flex-end !important; }
}

/* ===========================================================
   MOBILE TABLE HORIZONTAL SCROLL  (v61+)
   All tables are wrapped in .table-scroll-wrap which provides
   smooth horizontal scrolling with a right-fade hint on mobile.
   =========================================================== */

/* ── Universal scroll wrapper ────────────────────────────── */
.table-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Scrollbar only shows on hover/scroll (cleaner on desktop) */
  scrollbar-width: thin;
  scrollbar-color: var(--hairline) transparent;
  border-radius: 0 0 12px 12px;
  position: relative;
}
.table-scroll-wrap::-webkit-scrollbar { height: 5px; }
.table-scroll-wrap::-webkit-scrollbar-track { background: transparent; }
.table-scroll-wrap::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 3px; }

/* Right-fade hint — shows when content overflows right */
@media (max-width: 899px) {
  .table-scroll-wrap::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    width: 48px;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.9));
    flex-shrink: 0;
    display: block;
    margin-left: -48px;
    float: right;
  }
}

/* ── Ensure all known tables have a minimum width so they scroll ── */
@media (max-width: 899px) {
  /* Portfolio Summary (Overview) */
  .table-scroll-wrap .instruments-table,
  .table-scroll-wrap .mc-table {
    min-width: 480px;
  }
  /* Portfolio Accounts table */
  .portfolio-table-wrap { overflow-x: auto !important; }
  .portfolio-table-wrap .portfolio-table,
  .portfolio-table { min-width: 620px; }
  /* Payout schedule table */
  .payout-table { min-width: 700px; }
  /* CD Maturity filter bar */
  .cd-filters { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  /* Rank tables */
  .rank-col-rows { overflow-x: auto; }
}

/* ── card-body-table: let the inner scroll wrapper handle overflow ── */
.card-body-table {
  overflow: visible !important;   /* was hidden, was clipping scrollable tables */
}

/* ── Mobile scroll hint label ────────────────────────────── */
.table-scroll-label {
  display: none;
}
@media (max-width: 899px) {
  .table-scroll-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px; font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px 0;
  }
}

/* ── Portfolio table: responsive column hiding ───────────── */
@media (max-width: 899px) {
  /* Keep the most important columns visible; hide the rest */
  /* Users can scroll right to see all columns */
  .portfolio-table th,
  .portfolio-table td {
    font-size: 12px;
    padding: 10px 10px;
    white-space: nowrap;
  }
  .instruments-table th,
  .instruments-table td {
    font-size: 12px;
    padding: 10px 14px;
    white-space: nowrap;
  }
}

/* ===========================================================
   PORTFOLIO TABLE — Mobile Optimization (v62+)
   Compact account names, APY always visible, balanced columns
   =========================================================== */

/* Account name cell: constrain width + allow wrapping */
.portfolio-table .col-name {
  max-width: 240px;
  min-width: 120px;
}
.portfolio-table .port-name {
  font-weight: 700;
  color: #0f172a;
  font-size: 13px;
  line-height: 1.3;
  /* 2-line clamp with ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  white-space: normal;
}
.portfolio-table .port-last4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
  white-space: nowrap;
}

@media (max-width: 899px) {
  /* Mobile: tighter account column */
  .portfolio-table .col-name {
    max-width: 140px;
    min-width: 100px;
    padding-right: 6px;
  }
  .portfolio-table .port-name {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }
  .portfolio-table .port-last4 { font-size: 10px; }

  /* APY VISIBLE on mobile (was hidden) — high priority financial column */
  .portfolio-table .col-apy {
    display: table-cell !important;
    font-weight: 700;
    min-width: 56px;
  }
  /* Owner + Type stay hidden on mobile (lower priority) */
  .portfolio-table .col-owner,
  .portfolio-table .col-type { display: none; }

  /* Institution column: more compact */
  .portfolio-table .col-inst {
    max-width: 90px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Balance always right-aligned, bold */
  .portfolio-table .col-balance {
    white-space: nowrap;
    font-size: 12px;
  }
  /* Sequence number: tiny */
  .portfolio-table .col-seq { font-size: 10px; padding-left: 8px; padding-right: 4px; }
  .seq-total { font-size: 9px; }
}

/* Very small screens: even tighter */
@media (max-width: 480px) {
  .portfolio-table .col-name { max-width: 110px; }
  .portfolio-table .col-inst { max-width: 70px; font-size: 10px; }
  .portfolio-table th, .portfolio-table td { padding: 8px 6px !important; }
}

/* ===========================================================
   AI PORTFOLIO ANALYSIS VIEW  (v62+)
   Professional analytics dashboard with local intelligent fallback
   =========================================================== */

.ai-analysis-wrap {
  display: flex; flex-direction: column; gap: 16px;
}

/* Header bar */
.ai-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 16px 20px;
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
  border-radius: 14px;
  color: white;
  box-shadow: 0 2px 16px rgba(0,0,0,0.1);
}
.ai-header-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.92);
}
.ai-header-title .sparkle { font-size: 16px; }
.ai-execute-btn {
  background: #3b82f6;
  color: white;
  border: 0;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s;
  font-family: inherit;
}
.ai-execute-btn:hover { background: #2563eb; }
.ai-execute-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Section cards */
.ai-section {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.ai-section-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase;
  color: #64748b;
  margin-bottom: 10px;
}
.ai-status-pill {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #dbeafe; color: #1e40af;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
}
.ai-status-pill--verified { background: #d1fae5; color: #065f46; }
.ai-status-pill--positive { background: #d1fae5; color: #065f46; }
.ai-status-pill--neutral  { background: #f3f4f6; color: #374151; }
.ai-status-pill--caution  { background: #fef3c7; color: #92400e; }
.ai-status-pill--risk     { background: #fee2e2; color: #991b1b; }

/* Executive briefing prose */
.ai-briefing {
  font-size: 13px; line-height: 1.65;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}
.ai-briefing strong {
  color: var(--brand-700);
  font-weight: 800;
}

/* KPI grid */
.ai-kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .ai-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .ai-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
.ai-kpi {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.ai-kpi-info { flex: 1; min-width: 0; }
.ai-kpi-label {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}
.ai-kpi-value {
  font-size: 20px; font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

/* Two column section grid (trends + risks) */
.ai-2col {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
@media (min-width: 900px) {
  .ai-2col { grid-template-columns: 1fr 1fr; }
}

/* Insight rows */
.ai-insight-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.ai-insight-row:last-child { border-bottom: 0; padding-bottom: 0; }
.ai-insight-icon {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  background: #f1f5f9;
  font-size: 14px;
}
.ai-insight-icon--positive { background: #d1fae5; color: #065f46; }
.ai-insight-icon--caution  { background: #fef3c7; color: #92400e; }
.ai-insight-icon--risk     { background: #fee2e2; color: #991b1b; }
.ai-insight-content { flex: 1; min-width: 0; }
.ai-insight-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 800;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.ai-insight-text {
  font-size: 12px; line-height: 1.5;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ai-insight-text strong { color: var(--brand-700); font-weight: 800; }

/* Risk factor cards */
.ai-risk-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fafbfc;
}
.ai-risk-card:last-child { margin-bottom: 0; }
.ai-risk-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px; flex-wrap: wrap;
}
.ai-risk-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 800;
  color: #64748b;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.ai-risk-title {
  font-size: 12px; font-weight: 800;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.ai-risk-title strong { color: #b91c1c; }
.ai-risk-mitigate {
  font-size: 12px; line-height: 1.5;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ai-risk-mitigate strong { color: var(--brand-700); font-weight: 800; }

/* Routing console (recommendations) */
.ai-routing-card {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px 20px;
}
.ai-routing-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #15803d;
  margin-bottom: 10px;
}
.ai-routing-text {
  font-size: 13px; line-height: 1.6;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ai-routing-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--hairline);
}
.ai-routing-footer-right {
  color: #15803d;
}

/* Loading state */
.ai-loading-pulse {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  animation: aiPulse 1.4s infinite;
}
@keyframes aiPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

@media (max-width: 600px) {
  .ai-header { padding: 14px 16px; }
  .ai-header-title { font-size: 11px; letter-spacing: 0.8px; }
  .ai-section { padding: 14px 16px; }
  .ai-kpi-value { font-size: 17px; }
  .ai-briefing { font-size: 12px; }
}

/* ── AI Engine Status Strip (v64+) ──────────────────────── */
.ai-engine-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: #475569;
}
.ai-engine-strip-left {
  display: flex; align-items: center; gap: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  min-width: 0;
  flex-wrap: wrap;
}
.ai-engine-strip-right {
  display: flex; align-items: center; gap: 8px;
  color: #64748b;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.ai-engine-strip-right a:hover { text-decoration: none; }
@media (max-width: 600px) {
  .ai-engine-strip { flex-direction: column; align-items: flex-start; gap: 8px; }
  .ai-engine-strip-left, .ai-engine-strip-right { font-size: 10px; }
}

/* ============================================================
   ANALYTICS DASHBOARD (v66+)
   Institutional-grade portfolio analytics view
   ============================================================ */

.analytics-wrap {
  display: flex; flex-direction: column; gap: 16px;
}

/* ── Section tabs (Timeline / Allocation / Performance) ────── */
.analytics-section-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px solid var(--hairline);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.section-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border: 0; background: transparent;
  border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.section-tab:hover { color: #0f172a; }
.section-tab.active {
  background: white;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.section-tab .tab-icon { font-size: 14px; }

/* ── Hero card (top of Timeline) ───────────────────────────── */
.analytics-hero {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 24px 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.analytics-hero-label {
  font-size: 10px; font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 8px;
}
.analytics-hero-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 36px; font-weight: 800;
  color: #0f172a;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.analytics-hero-change {
  margin-top: 10px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}
.analytics-hero-change--green {
  background: #d1fae5; color: #065f46;
}
.analytics-hero-change--red {
  background: #fee2e2; color: #991b1b;
}
.hero-arrow { font-size: 11px; }
.hero-change-period {
  font-family: inherit; font-weight: 600; font-size: 11px;
  opacity: 0.75; margin-left: 6px;
  text-transform: lowercase;
}

/* ── Time range tabs (1M / 3M / 6M / YTD / 1Y / 2Y / ALL) ──── */
.analytics-range-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.analytics-range-tab {
  padding: 8px 16px;
  border: 0; background: transparent;
  border-radius: 7px;
  font-family: inherit; font-size: 12px; font-weight: 800;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.analytics-range-tab:hover { color: #0f172a; }
.analytics-range-tab.active {
  background: var(--brand-600);
  color: white;
}

/* ── Filter chips + selects ─────────────────────────────────── */
.analytics-filters {
  display: flex; flex-wrap: wrap;
  gap: 10px; align-items: center;
}
.analytics-filter-chip {
  padding: 8px 14px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: 8px;
  font-family: inherit; font-size: 12px; font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.analytics-filter-chip:hover { background: var(--surface-2); }
.analytics-filter-chip.active {
  background: #ecfdf5;
  border-color: var(--brand-600);
  color: var(--brand-700);
}
.analytics-filter-group {
  display: flex; align-items: center; gap: 6px;
}
.analytics-filter-group label {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #94a3b8;
}
.analytics-filter-select {
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 7px 10px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  background: var(--surface);
  color: #0f172a;
  cursor: pointer;
  max-width: 180px;
}

/* ── Generic card ───────────────────────────────────────────── */
.analytics-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.analytics-card-header { margin-bottom: 12px; }
.analytics-card-title {
  font-size: 13px; font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.3px;
  display: flex; align-items: center; gap: 8px;
}
.analytics-card-sub {
  font-size: 11px; color: #94a3b8;
  margin-top: 2px;
}

/* ── Line chart ─────────────────────────────────────────────── */
.analytics-card--chart {
  padding: 18px 12px 18px 20px;
}
.analytics-chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}
.analytics-line-chart {
  width: 100%;
  height: 100%;
  display: block;
}
.analytics-hover-overlay {
  cursor: crosshair;
}
.analytics-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.96);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 11px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  white-space: nowrap;
  z-index: 10;
}
.analytics-tooltip .tt-date {
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 2px;
  letter-spacing: 0.3px;
}
.analytics-tooltip .tt-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 800;
}

/* ── Stat grid (Period High / Low / etc.) ──────────────────── */
.analytics-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 700px) {
  .analytics-stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.analytics-stat-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 12px 14px;
}
.analytics-stat-card .stat-label {
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.7px;
  color: #64748b; margin-bottom: 4px;
}
.analytics-stat-card .stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px; font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}
.analytics-stat-card .stat-value.pos { color: #059669; }
.analytics-stat-card .stat-value.neg { color: #dc2626; }

/* ── Allocation donuts grid ─────────────────────────────────── */
.analytics-allocation-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 900px) {
  .analytics-allocation-grid { grid-template-columns: repeat(3, 1fr); }
}
.analytics-donut {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 14px;
}
.analytics-donut-svg {
  width: 180px; height: 180px;
}
.analytics-donut-svg .donut-slice {
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  transform-origin: center;
}
.analytics-donut-svg:hover .donut-slice { opacity: 0.4; }
.analytics-donut-svg .donut-slice:hover {
  opacity: 1; transform: scale(1.03);
}
.analytics-donut-legend {
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 5px;
}
.legend-row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 6px;
  font-size: 11px;
  border-radius: 5px;
  transition: background 0.12s;
}
.legend-row:hover { background: var(--surface-2); }
.legend-swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-label {
  color: #1e293b; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-pct {
  color: #64748b; font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.legend-value {
  color: #0f172a; font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

/* ── KPI grid (Performance section) ─────────────────────────── */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 640px) {
  .analytics-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .analytics-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
.analytics-kpi {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 16px 18px;
}
.analytics-kpi--primary {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-color: #cbd5e1;
}
.kpi-label {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 6px;
}
.kpi-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px; font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
}
.kpi-value.pos { color: #059669; }
.kpi-value.neg { color: #dc2626; }
.kpi-sub {
  font-size: 10px; font-weight: 700;
  color: #94a3b8;
  margin-top: 4px;
  letter-spacing: 0.3px;
}
.kpi-sub.pos { color: #059669; }
.kpi-sub.neg { color: #dc2626; }

/* ── Monthly heatmap ───────────────────────────────────────── */
.analytics-heatmap-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.analytics-heatmap {
  width: 100%;
  min-width: 600px;
  border-collapse: separate;
  border-spacing: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.analytics-heatmap th {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 6px 8px;
  text-align: center;
}
.analytics-heatmap th.hm-corner { text-align: left; }
.analytics-heatmap th.hm-year {
  font-size: 11px;
  color: #0f172a;
  text-align: left;
  padding-right: 12px;
}
.analytics-heatmap td {
  text-align: center;
  padding: 8px 6px;
  border-radius: 5px;
  font-weight: 700;
  min-width: 42px;
  font-variant-numeric: tabular-nums;
  transition: transform 0.12s;
}
.analytics-heatmap td:hover { transform: scale(1.06); }
.analytics-heatmap .hm-ytd-cell {
  font-size: 12px;
  font-weight: 800;
}
.analytics-heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 10px;
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.4px;
  flex-wrap: wrap;
}
.analytics-heatmap-scale {
  display: flex; gap: 2px;
}
.analytics-heatmap-scale span {
  padding: 3px 7px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 800;
}

/* ── Caveat / Roadmap / Placeholder cards ──────────────────── */
.analytics-caveat,
.analytics-roadmap-note {
  display: flex; gap: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  align-items: flex-start;
}
.caveat-icon,
.roadmap-icon {
  font-size: 16px;
  flex-shrink: 0;
  color: #64748b;
}
.caveat-title,
.roadmap-title {
  font-size: 12px; font-weight: 800;
  color: #0f172a;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.caveat-text,
.roadmap-text {
  font-size: 11px; line-height: 1.55;
  color: #475569;
}
.analytics-card--placeholder {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-style: dashed;
}
.placeholder-pill {
  font-size: 9px; font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  letter-spacing: 0.5px;
}
.analytics-placeholder-body {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 4px;
}
.placeholder-icon {
  font-size: 36px;
  opacity: 0.4;
  flex-shrink: 0;
}
.placeholder-text {
  font-size: 12px; line-height: 1.6;
  color: #475569;
}

/* ── Empty states ──────────────────────────────────────────── */
.analytics-empty,
.analytics-empty-mini {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}
.analytics-empty-mini { padding: 20px; font-size: 11px; }
.analytics-empty-state {
  text-align: center;
  padding: 60px 24px;
  background: var(--surface);
  border: 1px dashed var(--hairline);
  border-radius: 12px;
}
.analytics-empty-state .empty-icon {
  font-size: 48px; opacity: 0.4;
  margin-bottom: 12px;
}
.analytics-empty-state .empty-title {
  font-size: 16px; font-weight: 800;
  color: #0f172a; margin-bottom: 6px;
}
.analytics-empty-state .empty-text {
  font-size: 13px; line-height: 1.6;
  color: #64748b;
  max-width: 420px; margin: 0 auto;
}

/* ── Mobile tuning ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .analytics-hero { padding: 18px 20px; }
  .analytics-hero-value { font-size: 26px; }
  .analytics-section-tabs { padding: 3px; }
  .section-tab { padding: 7px 12px; font-size: 11px; }
  .section-tab .tab-icon { display: none; }
  .analytics-range-tabs { padding: 3px; }
  .analytics-range-tab { padding: 6px 10px; font-size: 11px; }
  .analytics-filters { gap: 8px; }
  .analytics-filter-group { flex: 1; min-width: calc(50% - 4px); }
  .analytics-filter-select { width: 100%; max-width: none; }
  .analytics-chart-wrap { height: 200px; }
  .kpi-value { font-size: 18px; }
  .analytics-donut-svg { width: 150px; height: 150px; }
}

/* ============================================================
   AI CHAT INTERFACE (v67+)
   Modern chat UI — "Ask Your Portfolio Anything"
   ============================================================ */

.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 500px;
  max-height: 900px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

/* ── Header strip ──────────────────────────────────────────── */
.chat-header-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.chat-header-left {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.chat-chain-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 800;
  letter-spacing: 0.6px;
  color: #475569;
  background: #f1f5f9;
  padding: 5px 10px;
  border-radius: 5px;
}
.chat-chain-badge--local {
  background: #fef3c7; color: #92400e;
}
.chat-chain-badge a {
  color: var(--brand-700);
  text-decoration: underline;
  font-family: inherit;
}
.chat-data-context {
  font-size: 10px; font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chat-clear-btn {
  font-family: inherit;
  font-size: 11px; font-weight: 700;
  color: #64748b;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-clear-btn:hover:not(:disabled) {
  background: #fee2e2; color: #991b1b; border-color: #fecaca;
}
.chat-clear-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Conversation log ──────────────────────────────────────── */
.chat-log {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px;
  scroll-behavior: smooth;
  background: linear-gradient(to bottom, #fafbfc, var(--surface));
}

/* ── Empty state ───────────────────────────────────────────── */
.chat-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 40px 20px;
  height: 100%;
  min-height: 280px;
}
.chat-empty-icon {
  font-size: 48px;
  color: var(--brand-600);
  margin-bottom: 16px;
  opacity: 0.6;
}
.chat-empty-title {
  font-size: 20px; font-weight: 800;
  color: #0f172a;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}
.chat-empty-text {
  font-size: 13px; line-height: 1.6;
  color: #64748b;
  max-width: 480px;
}

/* ── Message bubbles ───────────────────────────────────────── */
.chat-message {
  display: flex;
  margin-bottom: 18px;
  animation: chatFadeIn 0.25s ease-out;
}
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-message--user {
  justify-content: flex-end;
}
.chat-message--assistant {
  justify-content: flex-start;
  gap: 10px;
}
.chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.chat-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
}
.chat-bubble--user {
  background: var(--brand-600);
  color: white;
  border-bottom-right-radius: 4px;
  font-weight: 500;
  white-space: pre-wrap;
}
.chat-bubble--assistant {
  background: var(--surface);
  color: #1e293b;
  border: 1px solid var(--hairline);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}

/* Markdown content inside assistant bubble */
.chat-body p { margin: 0 0 8px 0; }
.chat-body p:last-child { margin-bottom: 0; }
.chat-body strong { color: #0f172a; font-weight: 800; }
.chat-body em { color: #64748b; font-style: italic; }
.chat-body code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #0f172a;
}
.chat-body ul, .chat-body ol {
  margin: 6px 0 8px 0;
  padding-left: 22px;
}
.chat-body ul li, .chat-body ol li {
  margin-bottom: 4px;
  line-height: 1.5;
}
.chat-body ul:last-child, .chat-body ol:last-child { margin-bottom: 0; }

/* Provider metadata strip below assistant bubbles */
.chat-msg-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.chat-provider-badge {
  padding: 2px 7px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
  text-transform: uppercase;
}
.chat-provider-badge--gemini { background: #dbeafe; color: #1e40af; }
.chat-provider-badge--claude { background: #ede9fe; color: #5b21b6; }
.chat-provider-badge--local  { background: #f3f4f6; color: #374151; }
.chat-usage {
  color: #94a3b8;
  font-size: 9px;
}

/* ── Thinking indicator ────────────────────────────────────── */
.chat-thinking {
  display: flex; align-items: center; gap: 10px;
}
.chat-thinking .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand-600);
  animation: chatPulse 1.4s infinite ease-in-out;
}
.chat-thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking .dot:nth-child(3) { animation-delay: 0.4s; }
.chat-thinking-text {
  font-size: 12px; font-weight: 700;
  color: #64748b;
  margin-left: 6px;
}
@keyframes chatPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

/* ── Suggested prompts ─────────────────────────────────────── */
.chat-suggestions {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--hairline);
  background: var(--surface);
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline) transparent;
}
.chat-suggestions::-webkit-scrollbar { height: 4px; }
.chat-suggestions::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 2px; }
.chat-suggestion {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 12px; font-weight: 600;
  color: #475569;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.chat-suggestion:hover {
  background: #ecfdf5;
  border-color: var(--brand-600);
  color: var(--brand-700);
}

/* ── Input area ────────────────────────────────────────────── */
.chat-input-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 14px 18px;
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface);
  color: #0f172a;
  resize: none;
  max-height: 140px;
  min-height: 42px;
  transition: border 0.15s, box-shadow 0.15s;
  font-weight: 500;
}
.chat-input:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}
.chat-send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 0;
  background: var(--brand-600);
  color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.chat-send-btn:hover:not(:disabled) {
  background: var(--brand-700);
  transform: scale(1.05);
}
.chat-send-btn:active:not(:disabled) { transform: scale(0.95); }
.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chat-send-btn svg {
  transform: translateX(1px);
}

/* ── Disclaimer ────────────────────────────────────────────── */
.chat-disclaimer {
  padding: 8px 18px 12px;
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.4;
  text-align: center;
  background: var(--surface);
  border-top: 1px dashed #f1f5f9;
}

/* ── Mobile tuning ─────────────────────────────────────────── */
@media (max-width: 899px) {
  .chat-wrap {
    height: calc(100vh - 180px);
    border-radius: 10px;
  }
  .chat-log { padding: 16px 12px; }
  .chat-bubble { max-width: 88%; font-size: 13px; padding: 10px 14px; }
  .chat-avatar { width: 28px; height: 28px; font-size: 13px; }
  .chat-input-form { padding: 12px; }
  .chat-input { font-size: 14px; }
  .chat-suggestions { padding: 10px 12px; }
  .chat-empty-title { font-size: 17px; }
  .chat-empty-text { font-size: 12px; }
  .chat-header-strip { padding: 10px 14px; }
  .chat-chain-badge, .chat-data-context { font-size: 9px; }
}
@media (max-width: 480px) {
  .chat-wrap { height: calc(100vh - 160px); }
  .chat-bubble { max-width: 92%; }
}

/* ============================================================
   SECURITY & PRIVACY UI (v71+)
   ============================================================ */

/* ── Lock Now button in sidebar footer ───────────────────────── */
.lock-now-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-family: inherit;
  font-size: 12px; font-weight: 700;
  color: #475569;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.3px;
}
.lock-now-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}
.lock-now-btn .lock-icon { font-size: 13px; }

/* ── Privacy blur (applied to body when tab loses focus) ────── */
body.privacy-blur-active .ph-mainfig,
body.privacy-blur-active .port-balance,
body.privacy-blur-active .net-worth-value,
body.privacy-blur-active .acct-stat-value,
body.privacy-blur-active .pig-stat-value,
body.privacy-blur-active .pig-total-value,
body.privacy-blur-active .analytics-hero-value,
body.privacy-blur-active .kpi-value,
body.privacy-blur-active .stat-value,
body.privacy-blur-active .chat-body,
body.privacy-blur-active .col-balance,
body.privacy-blur-active .port-last4,
body.privacy-blur-active [data-sensitive],
body.privacy-blur-active .ai-briefing,
body.privacy-blur-active .ai-kpi-value,
body.privacy-blur-active .ai-routing-text {
  filter: blur(8px) !important;
  user-select: none !important;
  transition: filter 0.2s ease;
}
body.privacy-blur-active::after {
  content: '🔒 Privacy mode — click anywhere to reveal';
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: white;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 700;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* ── PIN lockout error styling ───────────────────────────────── */
.pin-error {
  color: #dc2626;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* On mobile, place Lock Now above bottom-nav with proper spacing */
@media (max-width: 899px) {
  .lock-now-btn {
    font-size: 13px;
    padding: 12px;
  }
}
