/* ============================================================
   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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 800; font-size: 18px;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}
.sidebar-brand-text {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, 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: 'Inter', -apple-system, 'Helvetica Neue', Arial, 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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { 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; }

/* ================================================================
   INSTRUMENT INGESTION PAGE — inline single-page workflow
   Scoped to .scan-ingestion / .scan-ing-* only.
   ================================================================ */
.scan-ingestion { display: flex; flex-direction: column; gap: 16px; }

.scan-ing-section {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px;
}
.scan-ing-section-title {
  font-size: 10px; font-weight: 800;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}

/* Institution row */
.scan-ing-inst-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.scan-ing-inst-detected {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 0;
}
.scan-ing-arrow {
  color: var(--ink-3); font-size: 18px; flex-shrink: 0;
}
.scan-ing-detected-val {
  font-size: 13px; font-weight: 700; color: var(--ink-1);
}
.scan-ing-conf { font-size: 10px; font-weight: 600; }

/* Labels */
.scan-ing-label {
  font-size: 9px; font-weight: 800; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 4px;
}

/* Shared select style */
.scan-ing-select {
  width: 100%;
  font-family: inherit; font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-1);
}

/* Account rows */
.scan-ing-acct-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
}
.scan-ing-acct-row:last-child { border-bottom: none; }

.scan-ing-acct-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 8px;
}

.scan-ing-acct-fields {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
@media (max-width: 479px) {
  .scan-ing-acct-fields { grid-template-columns: 1fr; }
  .scan-ing-inst-row    { flex-direction: column; align-items: stretch; }
  .scan-ing-arrow       { display: none; }
}

.scan-ing-field { display: flex; flex-direction: column; }


/* ===== 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 legacy analytics block removed — canonical in performance dashboard section */
.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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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;
}

/* ============================================================
   By Category accordion — canonical styles moved to mc-table
   canonical block above (search: cat-accordion). This stub
   kept so search tools can find the component location.
   ============================================================ */

/* ============================================================
   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) — removed; section-title not used with accordion */

/* ============================================================
   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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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 intentionally unset — each table (instruments / mc-table)
     sets its own via scoped rules. No inherited base to override. */
}
.dashboard-view .instruments-table thead {
  background: #f7f8fa;
}
.dashboard-view .instruments-table:not(.mc-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 set per-table: instruments-table (non-mc) gets larger padding */
  border-bottom: 1px solid #f1f5f9;
}
.dashboard-view .instruments-table:not(.mc-table) .instruments-row td {
  padding: 14px 22px;
}
.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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 24px 0 12px;
}
.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:not(.mc-table) th,
  .dashboard-view .instruments-table:not(.mc-table) .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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 18px; font-weight: 700;
  color: var(--ink, #0b0f17);
  margin-top: 2px;
}
.ph-stat-pill.caution .ph-stat-pill-value { color: #92400e; }

/* ===========================================================
   CD MATURITY PAGE — bespoke two-row page header
   Scoped to .cd-ph-wrap so no other page is affected.
   =========================================================== */
.cd-ph-wrap {
  padding: 28px 24px 20px;
  max-width: 1280px;
  margin: 0 auto;
}
@media (min-width: 900px) {
  .cd-ph-wrap { padding: 36px 40px 24px; }
}
.cd-ph-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}
.cd-ph-row:first-child {
  margin-bottom: 6px;
}
/* Left side (tagline / h1) must not shrink into the pill */
.cd-ph-row .ph-tagline,
.cd-ph-row .ph-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
}
/* Pills stay right-aligned and never shrink */
.cd-ph-row .ph-stat-pill {
  flex-shrink: 0;
}
/* On very narrow screens stack each row vertically */
@media (max-width: 479px) {
  .cd-ph-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .cd-ph-row .ph-stat-pill {
    align-self: stretch;
  }
}

/* ===========================================================
   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; }

/* Row 2 left: account type label */
.cd-card-type-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-3, #64748b);
}

.cd-card-number {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

.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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

/* ===========================================================
   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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  margin-top: 2px;
}
.col-inst { font-weight: 600; white-space: nowrap; }
.col-apy { font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif; font-weight: 700; }
.col-balance .money-val {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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; }
}

/* ===========================================================


/* Also: ensure money-val has proper font everywhere */
.money-val {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ===========================================================
   PORTFOLIO SUMMARY TABLE — mc-table
   Single canonical block. All font sizes match the Overview
   page body system exactly. No overrides needed elsewhere.
   Class .mc-table is ONLY used on the Portfolio Summary table;
   the By Category accordion uses .cat-acc-* classes (below).
   =========================================================== */

/* ── Table shell ── */
.mc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

/* ── Column headers: 10px / 700 / ALL-CAPS — matches system spec ── */
.mc-table thead th {
  padding: 9px 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: #64748b;
  text-align: left;
  background: var(--surface-2, #f7f8fa);
  border-bottom: 1px solid var(--hairline, #e2e8f0);
  white-space: nowrap;
  user-select: none;
}
.mc-table th.col-right,
.mc-table td.col-right { text-align: right; }
.mc-sortable { cursor: pointer; }
.mc-sortable:hover { color: var(--brand-600, #059669); }

/* ── Body cells: 13px / 500 — matches system spec ── */
.mc-table td {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
  vertical-align: middle;
  border-bottom: 1px solid var(--hairline-soft, rgba(0,0,0,0.05));
  line-height: 1.4;
}
.mc-table tbody tr:last-child td { border-bottom: 0; }

/* ── Row interaction ── */
.mc-row { cursor: pointer; transition: background 0.12s; }
.mc-row:hover { background: var(--surface-2, #f7f8fa); }

/* ── Cell layout: icon + name ── */
.mc-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mc-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Category name: 13px / 700 — bold body ── */
.mc-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  word-break: break-word; overflow-wrap: break-word;
}

/* ── Count (number of accounts): 13px / 600 / tabular ── */
.mc-count {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1e3a5f;
}

/* ── Percentage: 12px / 600 / tabular ── */
.mc-pct {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #475569;
}

/* ── Balance / money value (col-right): 13px / 600 / tabular ── */
.mc-table .col-right {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1e3a5f;
}

/* ── Total row: 13px / 800 — same size, max weight ── */
.mc-total-row td {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  border-top: 1px solid var(--hairline, #e2e8f0);
  border-bottom: 0;
  background: var(--surface-2, #f7f8fa);
}

/* ── Section header rows ── */
.mc-section-header td {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 6px 14px;
  background: transparent;
  border-bottom: 0;
}

/* ── Mobile: tighten padding only, keep all font sizes identical ── */
@media (max-width: 639px) {
  .mc-table thead th,
  .mc-table td,
  .mc-total-row td { padding-left: 10px; padding-right: 10px; }
}

/* ===========================================================
   BY CATEGORY ACCORDION — cat-acc-* canonical block
   Separate component from mc-table. 2-col card grid desktop,
   1-col stacked mobile. Typography anchored to system tokens.
   This is the ONLY place cat-acc-* styles should be defined.
   =========================================================== */

/* ── Section wrapper: card-grid layout ── */
.cat-accordion {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0 0 16px;
}

/* ── Individual category card ── */
.cat-acc {
  background: #ffffff;
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  transition: box-shadow 0.15s;
}
.cat-acc.open {
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* ── Card header row (always visible) ── */
.cat-acc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0.04);
}
.cat-acc-header:hover { background: var(--surface-2, #f7f8fa); }
.cat-acc-header:active { background: var(--surface-2, #f7f8fa); }

/* ── Category icon badge ── */
.cat-acc-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--surface-2, #f7f8fa);
  border: 1px solid var(--hairline, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

/* ── Name + count column ── */
.cat-acc-info { flex: 1; min-width: 0; }

/* Category name: 13px / 700 — bold body, matches system spec */
.cat-acc-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0;
  word-break: break-word; overflow-wrap: break-word;
}

/* Account count: 11px / 500 — caption/meta spec */
.cat-acc-count {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  margin-top: 1px;
}

/* ── Right side: total + chevron ── */
.cat-acc-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Category total: 13px / 700 / tabular — numeric cell spec */
.cat-acc-total {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1e3a5f;
  white-space: nowrap;
}

/* Chevron: caption size */
.cat-acc-chevron {
  font-size: 10px;
  color: #94a3b8;
  width: 10px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Expanded body: account rows ── */
.cat-acc-body {
  border-top: 1px solid var(--hairline, #e2e8f0);
  background: var(--surface-2, #f7f8fa);
}

/* ── Account row inside expanded card ── */
.cat-acc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--hairline, #e2e8f0);
  cursor: pointer;
  background: #ffffff;
  -webkit-tap-highlight-color: rgba(0,0,0,0.04);
}
.cat-acc-row:last-child { border-bottom: 0; }
.cat-acc-row:hover { background: var(--surface-2, #f7f8fa); }
.cat-acc-row:active { background: var(--surface-2, #f7f8fa); }

/* ── Account row left: name + meta ── */
.cat-acc-row-left { flex: 1; min-width: 0; }

/* Account name: 13px / 600 — body bold spec */
.cat-acc-row-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
  word-break: break-word; overflow-wrap: break-word;
}

/* Institution + last4: 11px / 500 — caption/meta spec */
.cat-acc-row-meta {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Account balance: 13px / 700 / tabular — numeric cell spec */
.cat-acc-row-bal {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1e3a5f;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Edit button inside account row */
.cat-acc-row .acct-edit-btn {
  width: 28px;
  height: 28px;
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Mobile: single-column stacked, full-width cards ── */
@media (max-width: 799px) {
  .cat-accordion {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0 0 12px;
  }
}

/* ── Tablet (800–1099px): 2-col, slightly reduced padding ── */
@media (min-width: 800px) and (max-width: 1099px) {
  .cat-acc-header { padding: 11px 12px; }
  .cat-acc-row    { padding: 8px 12px; }
}

/* ===========================================================
   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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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) */


/* Active Instruments / generic data table inside a card */
.instruments-table:not(.mc-table),
.dashboard-view .instruments-table:not(.mc-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 */


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

/* cat-acc-row-meta color set in canonical block */

/* 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 */


/* 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;
  flex: 1;
  overflow: hidden;
}
.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;
  flex: 1;
  overflow: hidden;
}
.cd-card-inst-name {
  font-size: 13px; font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cd-card-inst-type {
  font-size: 10px; font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cd-card-head-right {
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 6px;
  flex-shrink: 0;
}
.cd-card-acct-num {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 12px; font-weight: 700;
  color: #334155;
  letter-spacing: 0.5px;
  text-align: right;
  white-space: nowrap;
}

/* 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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif; }
.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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif; }
.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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif; }

/* 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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

/* 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
   =========================================================== */

/* ── Logo Sizing System (v87: 1.5x larger for prominence) ──── */
:root {
  --logo-xs:  24px;   /* inline badges, small indicators */
  --logo-sm:  36px;   /* default cards, table cells */
  --logo-md:  54px;   /* 1.5x larger — performance cards, prominent display */
  --logo-lg:  72px;   /* hero sections, full-width features */
  --logo-radius: 10px;
  --logo-bg:  #f8fafc;
  --logo-border: 1px solid var(--hairline, #e2e8f0);
}

/* ── 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; }


/* 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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 800; font-size: 14px;
  flex-shrink: 0;
}
.mobile-header-title {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, 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) */

  /* 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:not(.mc-table) th,
  .instruments-table:not(.mc-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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}
.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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}
.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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 10px;
}
.legend-value {
  color: #0f172a; font-weight: 800;
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  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;
  }
}

/* ============================================================
   GLOBAL UI OVERHAUL  (v73+)
   ============================================================ */

/* ── 1. GLOBAL THEME TOKENS ─────────────────────────────────── */
:root {
  /* Typography scale */
  --font-heading-xl: 700 28px/1.2 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-heading-lg: 700 22px/1.25 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-heading-md: 700 17px/1.3 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-heading-sm: 700 14px/1.4 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-body:       500 14px/1.55 'Inter', system-ui, sans-serif;
  --font-body-sm:    500 12px/1.55 'Inter', system-ui, sans-serif;
  --font-label:      700 10px/1.4 'Inter', system-ui, sans-serif;
  --font-mono: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;

  /* Surface layers */
  --surface-3: #e8ecf0;
  /* Animation speeds */
  --transition-fast: 0.12s ease;
  --transition-base: 0.22s ease;
}

/* ── 2. FLOATING HAMBURGER — fixed, always visible ───────────── */
@media (max-width: 899px) {
  /* Extract hamburger from header flow → fixed overlay */
  .hamburger-btn {
    position: fixed !important;
    top: 10px;
    left: 12px;
    z-index: 9998;           /* above sidebar backdrop (149) + sidebar (150) */
    width: 44px; height: 44px;
    background: white;
    border: 1px solid var(--hairline);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 5px; padding: 0;
  }
  .hamburger-btn:hover,
  .hamburger-btn:focus-visible {
    background: var(--brand-600);
    border-color: var(--brand-600);
  }
  .hamburger-btn:hover .hamburger-bar,
  .hamburger-btn:focus-visible .hamburger-bar { background: white; }
  .hamburger-bar {
    width: 20px; height: 2px;
    background: #0f172a;
    border-radius: 2px;
  }

  /* Hamburger review badge */
  .hamburger-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 18px; height: 18px;
    padding: 0 4px;
    background: #dc2626;
    color: white;
    font-size: 10px; font-weight: 800;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid white;
    font-family: var(--font-mono);
  }
  .hamburger-badge.hidden { display: none; }

  /* Mobile header: leave room for fixed hamburger (left side) */
  .mobile-header {
    padding-left: 64px;      /* keep text from overlapping the fixed button */
    padding-right: 12px;
  }

  /* Mobile lock button */
  .mobile-lock-btn {
    width: 36px; height: 36px;
    border: 0; background: transparent;
    font-size: 18px;
    cursor: pointer;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-lock-btn:hover { background: var(--surface-2); }
}

/* ── 3. REMOVE BOTTOM NAV COMPLETELY ────────────────────────── */
.bottom-nav { display: none !important; }
/* Remove the 80px bottom padding that compensated for the bottom nav */
@media (max-width: 899px) {
  .main-content { padding-bottom: 24px !important; }
}

/* ── 4. SINGLE-COLUMN CARDS on mobile (strict 1-up) ─────────── */
@media (max-width: 899px) {
  /* Dashboard + general card grids */
  .card-row,
  .card-row-2,
  .dash-kpi-row,
  .kpi-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
  .card-row > *,
  .card-row-2 > * {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
  }

  /* Analytics: all grids to single column */
  .analytics-kpi-grid,
  .analytics-stat-grid,
  .analytics-2col {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .analytics-allocation-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Payouts KPI strip */
  .payout-kpi-strip {
    grid-template-columns: 1fr 1fr !important;
  }

  /* All cards: ensure they don't overflow viewport */
  .card, .settings-card, .analytics-card,
  .analytics-kpi, .analytics-stat-card {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 480px) {
  .payout-kpi-strip { grid-template-columns: 1fr !important; }
}

/* ── 5. STICKY TABLE HEADERS + FIRST COLUMN ─────────────────── */
.table-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
/* Sticky header row */
.table-scroll-wrap table thead th,
.portfolio-table-wrap table thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--hairline);
}
/* Sticky first column (account name, institution, etc.) */
.table-scroll-wrap table th:first-child,
.table-scroll-wrap table td:first-child,
.portfolio-table-wrap table th:first-child,
.portfolio-table-wrap table td:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface);
  box-shadow: 2px 0 4px rgba(0,0,0,0.05);
}
/* Ensure top-left corner is always on top */
.table-scroll-wrap table thead th:first-child,
.portfolio-table-wrap table thead th:first-child {
  z-index: 7;
}

/* ── 6. CALENDAR — fix Saturday column ──────────────────────── */
.payout-cal-dow,
.payout-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  width: 100%;
  box-sizing: border-box;
}
.payout-cal-dow { gap: 1px; }
.payout-cal-grid { gap: 2px; }
.cal-day {
  min-width: 0 !important;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
/* Give calendar a horizontal scroll container on very narrow screens */
@media (max-width: 480px) {
  .payout-cal-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .payout-cal-dow,
  .payout-cal-grid {
    min-width: 320px;
  }
}

/* ── 7. CD DASHBOARD — mobile card sizing ────────────────────── */
@media (max-width: 899px) {
  /* CD maturity tracker cards stack vertically */
  .cd-card-row,
  .cd-cards-wrap {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
  /* Prevent individual CD cards from overflowing */
  .cd-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .cd-card-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── 8. INTEREST SCHEDULE → mobile cards ──────────────────────  */
@media (max-width: 899px) {
  /* Hide the schedule table header on mobile */
  .payout-schedule-table-header { display: none !important; }
  /* Make schedule rows render as cards */
  .payout-schedule-card-row {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  }
  .payout-schedule-card-row:last-child { margin-bottom: 0; }
  /* Hide table, show card version */
  .payout-schedule-table { display: none !important; }
  .payout-schedule-cards { display: block !important; }
}
@media (min-width: 900px) {
  /* On desktop show table, hide card version */
  .payout-schedule-table { display: table !important; }
  .payout-schedule-cards { display: none !important; }
}

/* ── 9. PORTFOLIO / GLOBAL ACCOUNTS — mobile card layout ──────── */
@media (max-width: 899px) {
  /* Hide table on mobile */
  .portfolio-table-mobile-hide { display: none !important; }
  /* Show card list on mobile */
  .portfolio-mobile-cards { display: block !important; }
  /* Account card */
  .portfolio-acct-card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    cursor: pointer;
    transition: box-shadow 0.15s;
  }
  .portfolio-acct-card:hover,
  .portfolio-acct-card:active { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
  .portfolio-acct-card-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 10px;
  }
  .portfolio-acct-card-name {
    flex: 1; min-width: 0;
    font-weight: 700; font-size: 14px; color: #0f172a;
    word-break: break-word; overflow-wrap: break-word;
  }
  .portfolio-acct-card-inst {
    font-size: 11px; color: #64748b; font-weight: 600;
    margin-top: 2px;
    word-break: break-word;
  }
  .portfolio-acct-card-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .portfolio-acct-card-metric { text-align: left; }
  .portfolio-acct-card-metric-label {
    font-size: 9px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.6px;
    color: #94a3b8; margin-bottom: 2px;
  }
  .portfolio-acct-card-metric-value {
    font-family: var(--font-mono);
    font-size: 13px; font-weight: 800;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
  }
  .portfolio-acct-card-metric-value.yield-positive { color: #059669; }
  .portfolio-acct-card-metric-value.muted { color: #94a3b8; }
}
@media (min-width: 900px) {
  .portfolio-mobile-cards { display: none !important; }
  .portfolio-table-mobile-hide { display: block !important; }
}

/* ── 10. AI CHAT — mobile-first overhaul ──────────────────────── */
@media (max-width: 899px) {
  /* Fill the viewport precisely, accounting for fixed hamburger header */
  .chat-wrap {
    height: calc(100dvh - 130px) !important;
    max-height: none !important;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    margin: 0 -16px;        /* bleed to screen edges */
    display: flex !important;
    flex-direction: column !important;
  }
  /* Log fills middle space, scrolls internally */
  .chat-log {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
    padding: 14px 12px !important;
  }
  /* Input form: never shrinks, always visible at bottom */
  .chat-input-form {
    flex-shrink: 0 !important;
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 10px 12px env(safe-area-inset-bottom, 10px) !important;
    border-top: 1px solid var(--hairline);
  }
  .chat-input {
    font-size: 16px !important;  /* prevent iOS zoom on focus */
    min-height: 42px !important;
  }
  .chat-send-btn {
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0 !important;
  }
  /* Suggestions: compact horizontal scroll */
  .chat-suggestions {
    flex-shrink: 0 !important;
    padding: 8px 12px !important;
  }
  /* Disclaimer: compact */
  .chat-disclaimer {
    flex-shrink: 0 !important;
    font-size: 9px !important;
    padding: 4px 12px 6px !important;
  }
  /* Bubbles: wider on mobile */
  .chat-bubble { max-width: 90% !important; }
}

/* ── 11. DONUT CHART INTERACTIVITY ─────────────────────────────── */
/* Sort bar above each donut */
.donut-sort-bar {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.donut-sort-label {
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: #94a3b8;
}
.donut-sort-btn {
  font-family: inherit;
  font-size: 10px; font-weight: 700;
  padding: 4px 10px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface);
  color: #475569;
  cursor: pointer;
  transition: all 0.12s;
  letter-spacing: 0.3px;
}
.donut-sort-btn.active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: white;
}

/* Slice interaction states */
.analytics-donut-svg .donut-slice {
  cursor: pointer;
  transform-origin: 90px 90px;   /* center of the 180x180 viewBox */
  transition: transform 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}
.analytics-donut-svg .donut-slice--dimmed {
  opacity: 0.25 !important;
  filter: none !important;
  transform: none !important;
}
.analytics-donut-svg .donut-slice--selected {
  transform: scale(1.1) !important;
  opacity: 1 !important;
  filter: saturate(1.5) brightness(1.08) !important;
}
/* Override the hover-all-dim when selection is active */
.analytics-donut-svg.has-selection:hover .donut-slice { opacity: 1; }

/* Legend row states */
.analytics-donut-legend .legend-row {
  cursor: pointer;
  transition: opacity 0.15s, background 0.12s;
  border-radius: 6px;
  padding: 5px 6px;
}
.analytics-donut-legend .legend-row--faded { opacity: 0.35; }
.analytics-donut-legend .legend-row--selected {
  background: #f0fdf4;
  outline: 1px solid var(--brand-600);
}
.analytics-donut-legend .legend-row--selected .legend-label {
  font-weight: 800; color: #0f172a;
}

/* ── 12. GENERAL SPACING FIX for fixed hamburger overlap ────────── */
@media (max-width: 899px) {
  /* Add top padding to the main content so content doesn't hide behind the
     fixed hamburger button on pages that scroll from the top */
  .main-content {
    padding-top: 70px !important;
  }
  /* But keep the page header's tagline from having double-padding */
  .ph-wrap { padding-top: 0 !important; }
}

/* ============================================================
   CONTINUATION FIXES (v73+)
   ============================================================ */

/* ── AI Chat: exact viewport height accounting for fixed header ── */
@media (max-width: 899px) {
  .chat-view .chat-wrap,
  .main-content.chat-view .chat-wrap {
    /* 56px header + 70px padding-top from main-content = 126px overhead  */
    height: calc(100dvh - 126px) !important;
    margin: 0 -16px !important;        /* bleed to edges */
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }
}

/* ── Grouped accounts: ensure cards don't overflow on mobile ─── */
@media (max-width: 899px) {
  .inst-dashboard {
    border-radius: 12px !important;
    overflow: hidden !important;
    margin-bottom: 10px !important;
  }
  .account-row-big {
    padding: 12px 14px !important;
  }
  .acct-balance-big {
    font-size: 15px !important;
  }
  .acct-name-big {
    font-size: 13px !important;
    white-space: normal !important;
    word-break: break-word !important;
  }
}

/* ── Portfolio mobile cards: initial display state ───────────── */
.portfolio-mobile-cards {
  display: none;    /* desktop default; media query in earlier block shows on mobile */
}
@media (max-width: 899px) {
  .portfolio-mobile-cards { display: block !important; }
}

/* ── Interest schedule: initial display state ────────────────── */
.payout-schedule-cards {
  display: none;    /* desktop default */
}
@media (max-width: 899px) {
  .payout-schedule-cards { display: block !important; }
  .payout-schedule-table { display: none !important; }
}
@media (min-width: 900px) {
  .payout-schedule-table { display: block !important; }
}

/* ── Fix main-content padding so page headers clear the hamburger ── */
@media (max-width: 899px) {
  /* The ph-wrap already resets to 0 padding-top above; ensure heading text
     isn't hidden behind the fixed hamburger button (44px + 10px margin = 54px)  */
  .ph-wrap {
    padding-top: 8px !important;
  }
  /* Page title sizing on mobile */
  .ph-title {
    font-size: 22px !important;
    line-height: 1.2 !important;
  }
  .ph-tagline {
    font-size: 10px !important;
  }
}

/* ── CD Dashboard: fix oversized summary cards on mobile ────── */
@media (max-width: 899px) {
  .cd-summary-grid,
  .maturity-summary {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }
  .cd-summary-card,
  .maturity-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 14px 16px !important;
  }
  /* CD ladder / timeline */
  .cd-ladder,
  .cd-timeline {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* ── Donut chart: mobile sizing ─────────────────────────────── */
@media (max-width: 480px) {
  .analytics-donut {
    flex-direction: column !important;
    align-items: center !important;
  }
  .analytics-donut-legend {
    width: 100% !important;
    max-width: 340px !important;
  }
}

/* ── Table sticky cells: ensure background matches surface ──── */
@media (prefers-color-scheme: dark) {
  /* Ensures sticky cells don't become transparent in dark OS mode */
  .table-scroll-wrap table:not(.mc-table) thead th,
  .table-scroll-wrap table:not(.mc-table) td:first-child,
  .table-scroll-wrap table:not(.mc-table) th:first-child {
    background: var(--surface) !important;
  }
}

/* ── Payout card touch target ──────────────────────────────── */
.payout-schedule-card-row {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  transition: background 0.12s;
}
.payout-schedule-card-row:active {
  background: var(--surface-2) !important;
}

/* ── Portfolio card touch target ───────────────────────────── */
.portfolio-acct-card {
  -webkit-tap-highlight-color: transparent;
}

/* ── Hamburger animation: X state when drawer open ─────────── */
@media (max-width: 899px) {
  #app.sidebar-open .hamburger-btn {
    background: var(--brand-600) !important;
    border-color: var(--brand-600) !important;
    box-shadow: 0 2px 12px rgba(5,150,105,0.4) !important;
  }
  #app.sidebar-open .hamburger-bar { background: white !important; }
  #app.sidebar-open .hamburger-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg) !important;
  }
  #app.sidebar-open .hamburger-bar:nth-child(2) {
    opacity: 0 !important; width: 0 !important;
  }
  #app.sidebar-open .hamburger-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg) !important;
  }

  /* Sidebar: push below the fixed hamburger button when open */
  .sidebar.is-open {
    padding-top: 68px !important;     /* clear the fixed hamburger */
  }
}

/* ── Prevent sidebar-close-btn from overlapping hamburger ────── */
@media (max-width: 899px) {
  .sidebar-close-btn {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
  }
}

/* ── FINAL: AI Chat definitive mobile height (overrides all previous) ── */
@media (max-width: 899px) {
  .chat-wrap {
    /* mobile header = 56px, main-content padding-top = 70px → total overhead 126px
       Extra 10px breathing room at bottom                                       */
    height: calc(100dvh - 136px) !important;
    max-height: none !important;
    min-height: 300px !important;
    margin-left: -16px !important;
    margin-right: -16px !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  .chat-log {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .chat-input-form {
    flex-shrink: 0 !important;
    border-top: 1px solid var(--hairline) !important;
    background: var(--surface) !important;
    /* iOS safe-area inset so input clears the home indicator */
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 10px) !important;
  }
  .chat-suggestions { flex-shrink: 0 !important; }
  .chat-disclaimer  { flex-shrink: 0 !important; }
}

/* =================================================================
   GLOBAL DESIGN SYSTEM v75
   One source of truth for typography, spacing, card sizing,
   and numeric rendering across every page.
   Applied via CSS variables + global selectors so all views
   inherit automatically — no per-page overrides needed.
   ================================================================= */

/* ── 1. DESIGN TOKEN LAYER ───────────────────────────────────── */
:root {

  /* --- Typography scale (mobile-first, unitless multiples of 13px base) --- */
  --fs-2xs:  9px;    /* badges, micro labels                    */
  --fs-xs:  10px;    /* secondary metadata, timestamps          */
  --fs-sm:  11px;    /* captions, supplemental info             */
  --fs-base: 13px;   /* primary card content, table cells       */
  --fs-md:  14px;    /* emphasized content, list items          */
  --fs-lg:  15px;    /* card titles, section subtitles          */
  --fs-xl:  17px;    /* section headings                        */
  --fs-2xl: 20px;    /* sub-page headings                       */
  --fs-3xl: 24px;    /* page headings (mobile)                  */
  --fs-hero: 30px;   /* net worth hero, large KPIs              */

  /* --- Font weights --- */
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-black:    800;

  /* --- Line heights --- */
  --lh-tight:   1.2;
  --lh-snug:    1.35;
  --lh-base:    1.5;
  --lh-relaxed: 1.65;

  /* --- NUMERIC FONT (single stack, consistent zero rendering) ---
     Inter is loaded via Google Fonts in index.html.
     All financial numbers — balances, APYs, percentages,
     account numbers, timestamps — must use this stack so
     zero "0" renders identically on every OS/browser.
     DO NOT use ui-monospace (resolves differently per OS). */
  --font-numeric: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;

  /* --- Card system --- */
  --card-radius:     12px;
  --card-radius-lg:  14px;
  --card-radius-sm:  8px;
  --card-px:         18px;   /* horizontal padding */
  --card-py:         16px;   /* vertical padding   */
  --card-gap:        12px;   /* gap between cards  */
  --card-shadow:     0 1px 6px rgba(0,0,0,0.05);
  --card-border:     1px solid var(--hairline);

  /* --- Spacing rhythm --- */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
}

/* Mobile: tighter card padding */
@media (max-width: 899px) {
  :root {
    --card-px:  16px;
    --card-py:  14px;
    --card-gap: 10px;
    --fs-3xl:   22px;
    --fs-hero:  26px;
  }
}
@media (max-width: 480px) {
  :root {
    --card-px:  14px;
    --card-py:  12px;
    --card-gap:  8px;
  }
}


/* ── 2. GLOBAL NUMERIC FONT ENFORCEMENT ──────────────────────── */
/*
  All elements that display financial numbers MUST use --font-numeric.
  This prevents mixed zero styles (dotted vs open vs slashed) between pages.
  The selectors below cover every known number-display class across all views.
*/

/* Hero / KPI values */
.ph-mainfig,
.net-worth-value,
.analytics-hero-value,
.analytics-kpi-value,
.kpi-value,
.stat-value,

/* Institution & account totals */
.inst-total-big,
.acct-balance-big,
.pig-total-value,
.pig-stat-value,

/* Table money cells */
.col-balance,
.col-apy,
.money-val,
.port-balance,
.yield-positive,
.yield-negative,

/* Card metric values */
.portfolio-acct-card-metric-value,
.analytics-stat-card .stat-value,
.ai-kpi-value,
.acct-stat-value,
.cd-card-value,
.payout-kpi-value,

/* Chart / heatmap numbers */
.analytics-heatmap td,
.analytics-heatmap .hm-ytd-cell,
.chat-body code,

/* Inline formatted numbers (applied globally) */
[data-numeric],
.money {
  font-family: var(--font-numeric) !important;
  font-variant-numeric: tabular-nums !important;
  -webkit-font-feature-settings: "tnum" 1;
          font-feature-settings: "tnum" 1;
}

/* Override the conflicting --font-mono variable to match --font-numeric */
:root {
  --font-mono: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}


/* ── 3. UNIVERSAL CARD SYSTEM ────────────────────────────────── */
/*
  Every card in the app must use the same border-radius,
  padding, shadow, and gap values. Apply globally via class.
  All existing card classes are aliased here.
*/

/* Shared visual treatment */
.card,
.settings-card,
.analytics-card,
.analytics-kpi,
.analytics-stat-card,
.analytics-routing-card,
.cd-card,
.pig-card,
.payout-schedule-card-row,
.portfolio-acct-card,
.inst-dashboard,
.acct-stat-tile,
.ai-section,
.ai-kpi,
.chat-bubble--assistant,
.donut-card {
  border-radius: var(--card-radius) !important;
  border: var(--card-border) !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
}

/* Cards that need full padding reset */
.card,
.settings-card,
.analytics-card,
.analytics-kpi,
.ai-section,
.ai-kpi {
  padding: var(--card-py) var(--card-px) !important;
}

/* Gap between stacked cards */
.analytics-wrap,
.settings-section-cards,
.cd-cards-wrap,
.analytics-allocation-grid {
  gap: var(--card-gap) !important;
}


/* ── 4. TYPOGRAPHY HIERARCHY ─────────────────────────────────── */

/* Page headings */
.ph-title {
  font-size: var(--fs-3xl) !important;
  font-weight: var(--fw-black) !important;
  line-height: var(--lh-tight) !important;
  letter-spacing: -0.4px !important;
}
.ph-tagline {
  font-size: var(--fs-xs) !important;
  font-weight: var(--fw-bold) !important;
}

/* Section titles */
.settings-section-title,
.analytics-card-title,
.ai-section-label {
  font-size: var(--fs-base) !important;
  font-weight: var(--fw-black) !important;
}

/* Body / card content */
.settings-row-title,
.settings-row-sub,
.legend-label,
.legend-pct,
.legend-value {
  font-size: var(--fs-base) !important;
}
.settings-row-sub {
  font-weight: var(--fw-regular) !important;
  font-size: var(--fs-sm) !important;
}

/* Table cells */
.portfolio-table th {
  font-size: var(--fs-2xs) !important;
  font-weight: var(--fw-black) !important;
  letter-spacing: 0.6px !important;
}
.portfolio-table td {
  font-size: var(--fs-base) !important;
}


/* ── 5. GLOBAL ACCOUNTS — font size reduction ─────────────────── */
/*
  Target: institution name + balance match visual weight of count label.
  Before: inst-name 18px bold, inst-total 22px black.
  After:  inst-name 15px bold, inst-total 16px black.
  This aligns with inst-count-big (12px) in the same card.
*/
.inst-name-big {
  font-size: var(--fs-lg) !important;    /* 15px (was 18px) */
  font-weight: var(--fw-bold) !important;
  letter-spacing: 0 !important;
}
.inst-total-big {
  font-family: var(--font-numeric) !important;
  font-size: var(--fs-md) !important;    /* 14px (was 22px) */
  font-weight: var(--fw-black) !important;
  letter-spacing: -0.3px !important;
}
.inst-count-big {
  font-size: var(--fs-sm) !important;    /* 11px stays */
  font-weight: var(--fw-medium) !important;
}
.acct-name-big {
  font-size: var(--fs-md) !important;    /* 14px (was 15px) */
}
.acct-balance-big {
  font-family: var(--font-numeric) !important;
  font-size: var(--fs-md) !important;    /* 14px (was 16px) */
  font-weight: var(--fw-black) !important;
}
.acct-meta-big {
  font-size: var(--fs-sm) !important;    /* 11px (was 12px) */
}

/* Mobile: slightly looser for readability */
@media (max-width: 899px) {
  .inst-name-big  { font-size: var(--fs-md)  !important; }
  .inst-total-big { font-size: var(--fs-lg)  !important; }
  .acct-balance-big { font-size: var(--fs-base) !important; }
}


/* ── 6. OVERVIEW PAGE — Portfolio Summary + By Category styles now in mc-table canonical block (line ~4048) ─ */


/* Portfolio summary section totals */


/* Dashboard KPI strip: hero net worth number */
.ph-mainfig {
  font-family: var(--font-numeric) !important;
  font-size: var(--fs-hero) !important;
  font-weight: var(--fw-black) !important;
  letter-spacing: -1px !important;
}
/* Dashboard KPI cards */
.dash-kpi-val,
.kpi-value {
  font-family: var(--font-numeric) !important;
  font-size: var(--fs-2xl) !important;   /* 20px (compact) */
  font-weight: var(--fw-black) !important;
}
.dash-kpi-label,
.kpi-label {
  font-size: var(--fs-xs) !important;
  font-weight: var(--fw-black) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.7px !important;
}


/* ── 7. INTEREST DASHBOARD — schedule visibility fix ─────────── */
/*
  The payout-schedule-table class controls show/hide between
  the desktop table and mobile card list.
  Ensure neither collapses unexpectedly.
*/
.payout-schedule-table {
  display: block !important;   /* always a block container */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 899px) {
  .payout-schedule-table {
    display: none !important;  /* hidden on mobile — show cards instead */
  }
  .payout-schedule-cards {
    display: block !important;
  }
}
@media (min-width: 900px) {
  .payout-schedule-cards {
    display: none !important;
  }
}

/* ── 8. COMPACT CONTENT DENSITY ──────────────────────────────── */
/* Reduce excess vertical whitespace on mobile */
@media (max-width: 899px) {
  .card-body, .settings-row {
    padding: var(--card-py) var(--card-px) !important;
  }
  .settings-row + .settings-row {
    border-top: 1px solid var(--hairline);
  }
  /* Account rows inside institution groups */
  .account-row-big {
    padding: 10px var(--card-px) !important;
  }
  /* CD / payout cards */
  .cd-card {
    padding: var(--card-py) var(--card-px) !important;
  }
  /* Schedule mobile cards */
  .payout-schedule-card-row {
    padding: 12px var(--card-px) !important;
    margin-bottom: var(--card-gap) !important;
  }
  /* Portfolio mobile acct cards */
  .portfolio-acct-card {
    padding: 12px var(--card-px) !important;
    margin-bottom: var(--card-gap) !important;
  }
}

/* ── 9. CHART / TABLE NUMERIC FONT ─────────────────────────────── */
/* Ensure chart Y-axis labels, table amounts all use numeric font */
.analytics-line-chart text,
.analytics-heatmap td,
.analytics-heatmap .hm-ytd-cell,
.portfolio-table .col-balance,
.portfolio-table .col-apy,
.payout-table td.col-right {
  font-family: var(--font-numeric) !important;
  font-variant-numeric: tabular-nums !important;
}

/* ╔═══════════════════════════════════════════════════════════╗
   ║  GLOBAL MOBILE-FIRST DESIGN SYSTEM  v75                  ║
   ║  Single source of truth — overrides all previous rules.  ║
   ║  Do NOT add conflicting rules above this block.           ║
   ╚═══════════════════════════════════════════════════════════╝ */

/* ─────────────────────────────────────────────────────────────
   SECTION 1 · DESIGN TOKENS
   ───────────────────────────────────────────────────────────── */
:root {
  /* ── Numeric font — enforced globally for ALL financial values ── */
  /* A single font family with consistent zero shape (no dotted/slashed
     inconsistencies). Applied via [data-num] attribute or .num class
     AND via the element-level rules in Section 4 below.               */
  --num: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;

  /* ── Typography scale (used by Section 2 helper classes) ── */
  --fs-h1:    22px;   /* page headers         */
  --fs-h2:    17px;   /* section titles       */
  --fs-h3:    14px;   /* card titles          */
  --fs-h4:    13px;   /* sub-labels           */
  --fs-body:  13px;   /* default card content */
  --fs-small: 11px;   /* captions, metadata   */
  --fs-label:  9px;   /* ALL-CAPS labels      */
  --fw-black:  800;
  --fw-bold:   700;
  --fw-semi:   600;
  --fw-med:    500;
  --lh-tight:  1.2;
  --lh-base:   1.5;
  --lh-loose:  1.65;

  /* ── Numeric size tokens ── */
  --num-xxl:  28px;   /* hero metrics (net worth on Overview) */
  --num-xl:   22px;   /* KPI card values                     */
  --num-lg:   18px;   /* grouped account totals              */
  --num-md:   15px;   /* row-level balances                  */
  --num-sm:   13px;   /* table cells, card metrics           */
  --num-xs:   11px;   /* compact stats, percentages          */

  /* ── Card system ── */
  --card-radius:   12px;
  --card-p:        14px 16px;    /* standard card padding */
  --card-p-sm:     10px 12px;    /* compact card padding  */
  --card-gap:      10px;         /* vertical gap between cards */
  --card-shadow:   0 1px 5px rgba(0,0,0,0.06);
  --card-border:   1px solid var(--hairline);

  /* ── Spacing rhythm (8-pt grid) ── */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
}

/* Mobile: tighten the scale */
@media (max-width: 899px) {
  :root {
    --fs-h1:    19px;
    --fs-h2:    15px;
    --fs-h3:    13px;
    --fs-body:  13px;
    --num-xxl:  24px;
    --num-xl:   19px;
    --num-lg:   16px;
    --num-md:   14px;
    --card-p:   12px 14px;
    --card-gap:  8px;
    --sp-5: 16px;
    --sp-6: 20px;
    --sp-8: 24px;
  }
}

/* ─────────────────────────────────────────────────────────────
   SECTION 2 · TYPOGRAPHY HELPER CLASSES
   Apply these classes directly in HTML/JS templates.
   ───────────────────────────────────────────────────────────── */

/* Headings */
.t-h1 { font-size: var(--fs-h1); font-weight: var(--fw-black); line-height: var(--lh-tight); color: #0f172a; }
.t-h2 { font-size: var(--fs-h2); font-weight: var(--fw-bold);  line-height: var(--lh-tight); color: #0f172a; }
.t-h3 { font-size: var(--fs-h3); font-weight: var(--fw-bold);  line-height: var(--lh-tight); color: #0f172a; }
.t-h4 { font-size: var(--fs-h4); font-weight: var(--fw-bold);  line-height: var(--lh-base);  color: #1e293b; }

/* Body text */
.t-body  { font-size: var(--fs-body);  font-weight: var(--fw-med);  line-height: var(--lh-base);  color: #334155; }
.t-small { font-size: var(--fs-small); font-weight: var(--fw-med);  line-height: var(--lh-base);  color: #475569; }
.t-label { font-size: var(--fs-label); font-weight: var(--fw-bold); line-height: var(--lh-base);  color: #64748b; letter-spacing: 0.7px; text-transform: uppercase; }

/* Numeric helpers — always mono font */
.num-xxl { font-family: var(--num); font-size: var(--num-xxl); font-weight: var(--fw-black); font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.num-xl  { font-family: var(--num); font-size: var(--num-xl);  font-weight: var(--fw-black); font-variant-numeric: tabular-nums; }
.num-lg  { font-family: var(--num); font-size: var(--num-lg);  font-weight: var(--fw-black); font-variant-numeric: tabular-nums; }
.num-md  { font-family: var(--num); font-size: var(--num-md);  font-weight: var(--fw-bold);  font-variant-numeric: tabular-nums; }
.num-sm  { font-family: var(--num); font-size: var(--num-sm);  font-weight: var(--fw-semi);  font-variant-numeric: tabular-nums; }
.num-xs  { font-family: var(--num); font-size: var(--num-xs);  font-weight: var(--fw-semi);  font-variant-numeric: tabular-nums; }

/* ─────────────────────────────────────────────────────────────
   SECTION 3 · UNIVERSAL CARD SYSTEM
   Every card in the app must either use .wt-card directly
   or have equivalent rules applied via the element selectors below.
   ───────────────────────────────────────────────────────────── */

/* The canonical card class — use this for all new components */
.wt-card {
  background: var(--surface);
  border: var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-p);
  box-shadow: var(--card-shadow);
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.wt-card + .wt-card { margin-top: var(--card-gap); }

/* Apply card rules universally to existing card selectors */
.card,
.settings-card,
.analytics-card,
.analytics-kpi,
.analytics-stat-card,
.analytics-routing-card,
.ai-kpi,
.ai-section,
.ai-risk-card,
.payout-schedule-card-row,
.portfolio-acct-card,
.cd-card,
.pig-card,
.acct-stat-tile,
.inst-dashboard,
.acct-detail-card {
  border-radius: var(--card-radius) !important;
  box-shadow: var(--card-shadow) !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

/* Consistent internal padding across all card types */
.card,
.analytics-card,
.analytics-kpi { padding: var(--card-p) !important; }

.ai-kpi,
.ai-risk-card,
.payout-schedule-card-row,
.portfolio-acct-card { padding: 12px 14px !important; }

/* Card list rhythm — gap between stacked cards */
.analytics-kpi-grid,
.analytics-stat-grid,
.analytics-allocation-grid,
.ai-kpi-grid {
  gap: var(--card-gap) !important;
}

/* Mobile: all card grids → single column */
@media (max-width: 899px) {
  .analytics-kpi-grid,
  .analytics-stat-grid,
  .analytics-2col,
  .analytics-allocation-grid,
  .ai-kpi-grid,
  .ai-2col,
  .card-row,
  .card-row-2 {
    grid-template-columns: 1fr !important;
    display: grid !important;
    gap: var(--card-gap) !important;
  }
  /* Prevent any card from exceeding viewport on mobile */
  .card, .wt-card, .analytics-card, .analytics-kpi,
  .ai-kpi, .ai-section, .payout-schedule-card-row,
  .portfolio-acct-card, .cd-card, .pig-card {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   SECTION 4 · GLOBAL NUMERIC FONT ENFORCEMENT
   Applies the mono font to every element that displays a number.
   No exceptions — this prevents mixed rendering across pages.
   ───────────────────────────────────────────────────────────── */

/* Dollar amounts — catch all common patterns */
.money-val,
.port-balance,
.acct-balance-big,
.inst-total-big,
.net-worth-value,
.ph-mainfig,
.pig-stat-value,
.pig-total-value,
.kpi-value,
.stat-value,
.analytics-hero-value,
.ai-kpi-value,
.acct-stat-value,
.cd-card-value,
.payout-kpi-val,
.payout-kpi-pct,
.legend-value,
.legend-pct,
/* Table cells that contain numbers */
.col-balance,
.col-apy,
.col-right,
/* Portfolio card metrics */
.portfolio-acct-card-metric-value,
/* Chat numbers */
.chat-body strong,
/* Settings usage grid */
.settings-usage-num {
  font-family: var(--num) !important;
  font-variant-numeric: tabular-nums !important;
}

/* Percentage and APY values */
.yield-positive,
.yield-negative,
.yield-neutral {
  font-family: var(--num) !important;
  font-variant-numeric: tabular-nums !important;
}

/* ─────────────────────────────────────────────────────────────
   SECTION 5 · GLOBAL ACCOUNTS PAGE — font size reduction
   Institution name + balance → match "account count" size
   ───────────────────────────────────────────────────────────── */

/* Institution group header: reduce oversized text */
.inst-name-big {
  font-size: 15px !important;   /* was ~18-20px */
  font-weight: var(--fw-bold) !important;
  line-height: var(--lh-base) !important;
}
.inst-total-big {
  font-family: var(--num) !important;
  font-size: var(--num-md) !important;    /* 15px — matches count text */
  font-weight: var(--fw-black) !important;
}
.inst-count-big {
  font-size: var(--fs-small) !important;  /* 11px */
  font-weight: var(--fw-med) !important;
  color: #64748b !important;
}
/* Account row within an institution group */
.acct-name-big {
  font-size: var(--fs-body) !important;   /* 13px — was 14-15px */
  font-weight: var(--fw-bold) !important;
}
.acct-balance-big {
  font-family: var(--num) !important;
  font-size: var(--num-sm) !important;    /* 13px — matches name */
  font-weight: var(--fw-black) !important;
}
.acct-meta-big {
  font-size: var(--fs-small) !important;  /* 11px */
  color: #64748b !important;
}
/* Stat tiles on grouped view (above institution cards) */
.acct-stat-value {
  font-family: var(--num) !important;
  font-size: var(--num-xl) !important;    /* 22px — was potentially bigger */
  font-weight: var(--fw-black) !important;
}
.acct-stat-label {
  font-size: var(--fs-label) !important;
  font-weight: var(--fw-bold) !important;
}

/* ─────────────────────────────────────────────────────────────
   SECTION 6 · removed — instruments-table overrides consolidated
   into canonical block. cat-accordion has its own block.
   ───────────────────────────────────────────────────────────── */


/* Net worth hero on Overview — use xxl token, not arbitrary px */
.ph-mainfig,
.net-worth-value {
  font-family: var(--num) !important;
  font-size: var(--num-xxl) !important;   /* 28px desktop, 24px mobile via token */
  font-weight: var(--fw-black) !important;
  letter-spacing: -0.5px !important;
  font-variant-numeric: tabular-nums !important;
}

/* ─────────────────────────────────────────────────────────────
   SECTION 7 · UNIFIED CONTENT DENSITY
   Consistent line-height, spacing rhythm across all sections.
   ───────────────────────────────────────────────────────────── */

/* Prevent any section from using oversized line-height */
.card *, .wt-card *, .analytics-card *,
.analytics-kpi *, .ai-section *, .pig-card *,
.payout-schedule-card-row * {
  line-height: inherit;
}

/* KPI label → uniform label style everywhere */
.kpi-label, .ai-kpi-label, .analytics-kpi .kpi-label,
.pig-stat-label, .cd-card-label, .payout-kpi-label {
  font-size: var(--fs-label) !important;
  font-weight: var(--fw-bold) !important;
  letter-spacing: 0.7px !important;
  text-transform: uppercase !important;
  color: #64748b !important;
}

/* KPI values → uniform numeric style */
.kpi-value, .ai-kpi-value, .pig-stat-value,
.payout-kpi-val, .cd-card-value {
  font-family: var(--num) !important;
  font-size: var(--num-xl) !important;     /* 22px / 19px mobile */
  font-weight: var(--fw-black) !important;
  font-variant-numeric: tabular-nums !important;
  line-height: 1.15 !important;
}

/* Sub-labels under KPI values */
.kpi-sub, .ai-kpi-sub, .pig-stat-sub,
.payout-kpi-sub, .cd-card-sub {
  font-size: var(--fs-small) !important;
  font-weight: var(--fw-semi) !important;
  color: #64748b !important;
  line-height: 1.4 !important;
  margin-top: 2px !important;
}

/* Section titles — use h2 token */
.analytics-card-title,
.ai-section .ai-section-label .ai-section-label-text,
.pig-inst-name,
.ph-title {
  font-size: var(--fs-h2) !important;
  font-weight: var(--fw-black) !important;
  line-height: var(--lh-tight) !important;
  color: #0f172a !important;
}

/* ─────────────────────────────────────────────────────────────
   SECTION 8 · MOBILE EDGE MARGINS
   Ensure cards have consistent 16px side margins on mobile.
   ───────────────────────────────────────────────────────────── */
@media (max-width: 899px) {
  /* Main content horizontal padding */
  .main-content {
    padding-left:  16px !important;
    padding-right: 16px !important;
  }
  /* Cards inside main-content fill the column */
  .card, .wt-card, .analytics-card,
  .payout-schedule-card-row, .portfolio-acct-card,
  .inst-dashboard, .analytics-kpi,
  .ai-section, .ai-kpi {
    margin-left:  0 !important;
    margin-right: 0 !important;
    width: 100% !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   SECTION 9 · INTEREST DASHBOARD — schedule fix
   Ensure both table and card views display correctly.
   ───────────────────────────────────────────────────────────── */

/* Desktop: show table, hide cards */
@media (min-width: 900px) {
  .payout-schedule-table  { display: block !important; }
  .payout-schedule-cards  { display: none  !important; }
}
/* Mobile: show cards, hide table */
@media (max-width: 899px) {
  .payout-schedule-table  { display: none  !important; }
  .payout-schedule-cards  { display: block !important; }
}
/* Always make the cards container visible (content filled by JS) */
.payout-schedule-cards {
  width: 100%;
  box-sizing: border-box;
}

/* ─────────────────────────────────────────────────────────────
   SECTION 10 · PAGE HEADER — standardize across all views
   ───────────────────────────────────────────────────────────── */
.ph-title {
  font-size: var(--fs-h1) !important;
  font-weight: var(--fw-black) !important;
  letter-spacing: -0.3px !important;
  color: #0f172a !important;
}
.ph-tagline {
  font-size: var(--fs-label) !important;
  font-weight: var(--fw-bold) !important;
  letter-spacing: 0.8px !important;
  text-transform: uppercase !important;
  color: #10b981 !important;    /* brand green — consistent across all pages */
}

/* ─────────────────────────────────────────────────────────────
   END OF GLOBAL DESIGN SYSTEM
   ─────────────────────────────────────────────────────────────
   Anything below this block must not override the tokens above.
   Add new component styles by using var(--token-name) values.
   ───────────────────────────────────────────────────────────── */

/* ============================================================
   v76 DESIGN SYSTEM UPDATES
   ============================================================ */

/* ── 1. NUMERIC FONT REPLACEMENT — Inter (no slashed zeros) ─── */
:root {
  /* Inter with tabular-nums for all numeric displays. */
  --num: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

/* ── 2. OVERVIEW PAGE TYPOGRAPHY NORMALIZATION ─────────────── */

/* Balance + percent columns — rules consolidated into canonical blocks above */


/* ── 3. CARD WIDTH ALIGNMENT — match table width ────────────── */
/* Cards should share the same horizontal padding as tables so edges align */
.dashboard-view .card,
.dashboard-view .wt-card {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
/* Appreciation curve + allocation donut: full width row */
.card-row-2 {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ── 4. CD DASHBOARD — 2×2 card stats grid ─────────────────── */
.cd-card-stats-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  margin-bottom: 12px !important;
}
/* Smaller maturity date text (longer strings need to fit) */
.cd-card-stat-value--sm {
  font-size: 12px !important;
  font-weight: var(--fw-bold, 700) !important;
  line-height: 1.35 !important;
}
/* Remove the old single-row maturity layout */
.cd-card-row { display: none !important; }

/* CD card column stacking on mobile */
@media (max-width: 899px) {
  .cd-cards-grid,
  .cd-card-wrap,
  .cd-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
}

/* ── 5. HALL OF FAME — card layout ─────────────────────────── */
.rank-col {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.rank-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 12px;
  border-bottom: 2px solid var(--hairline);
  margin-bottom: 12px;
}
.rank-col-icon { font-size: 20px; }
.rank-col-title {
  font-size: 14px !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  letter-spacing: 0.3px !important;
  text-transform: uppercase !important;
}

/* Individual rank card */
.rank-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.rank-card:last-child { margin-bottom: 0; }
.rank-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.rank-card:active { transform: scale(0.99); }

/* Card header row: logo + name + medal */
.rank-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.rank-card-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--surface-2);
  padding: 2px;
}
.rank-card-logo-fallback {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
  flex-shrink: 0;
}
.rank-card-info { flex: 1; min-width: 0; }
.rank-card-name {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  word-break: break-word; overflow-wrap: break-word;
}
.rank-card-inst {
  font-size: 11px !important;
  color: #64748b !important;
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-card-medal {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
}

/* Card values area */
.rank-card-values {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--hairline);
}
.rank-card-primary {
  font-family: var(--num) !important;
  font-size: 18px !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  font-variant-numeric: tabular-nums !important;
}
.rank-card-primary.pos { color: #059669 !important; }
.rank-card-primary.neg { color: #dc2626 !important; }
.rank-card-secondary {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #64748b !important;
}

/* Rank column grid — 3 columns on desktop, 1 on mobile */
.rank-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 899px) {
  .rank-cols {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
}

/* ── 6. INTEREST DASHBOARD — institution text on dark bg ─────── */
/* "By Institution" pig-cards have dark green/brand header backgrounds.
   Institution names must use bright, high-contrast yellow to be legible. */
.pig-inst-header .pig-inst-name,
.pig-header .pig-inst-name,
.pig-card-header .pig-inst-name,
.pig-inst-banner .inst-name,
[class*="pig"] .pig-inst-name {
  color: #fef08a !important;    /* bright yellow — Tailwind yellow-200 */
  font-weight: 800 !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

/* ── 7. OVERVIEW ALLOCATION DONUT — remove empty hint styling ── */
.donut-empty-hint {
  text-align: center;
  padding: 32px 20px;
  color: #94a3b8;
  font-size: 13px;
}

/* ── 8. SCAN MODAL — dropdown styles ───────────────────────── */
.scan-edit-hint {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
  color: #065f46;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.5;
}
#edit-account-preview {
  font-size: 12px;
  color: #475569;
}

/* ── 9. CD CARD — heading alignment (no overlap) ──────────────── */
@media (max-width: 899px) {
  .cd-card-head-v2 {
    flex-direction: column !important;
    gap: 6px !important;
    align-items: flex-start !important;
  }
  .cd-card-head-right {
    align-self: flex-end !important;
  }
}

/* ================================================================
   OVERVIEW — Portfolio Summary + By Category
   Typography is now handled by the canonical mc-table block
   (line ~4048) and the cat-accordion block (line ~2492).
   ================================================================ */


/* ================================================================
   GLOBAL TYPOGRAPHY SYSTEM — Inter only, all pages
   Single authoritative block. Wins all specificity via !important.
   Hierarchy (desktop):
     Page header h1  : Inter 32px / 800
     Section title   : Inter 12px / 800 ALL-CAPS 0.7px
     Card title      : Inter 12px / 800 ALL-CAPS 0.7px
     Sub-header      : Inter 11px / 700 ALL-CAPS 0.5px
     Column header   : Inter 10px / 700 ALL-CAPS 0.6px
     Body / table td : Inter 13px / 500
     Body bold       : Inter 13px / 700
     Caption / meta  : Inter 11px / 500
     KPI value       : Inter 28px / 800 tabular-nums
     KPI label       : Inter 11px / 700 ALL-CAPS
     KPI sub         : Inter 12px / 600
     Numeric cells   : Inter 13px / 700 tabular-nums
   ================================================================ */

/* ── Base: ensure Inter everywhere ── */
*, *::before, *::after {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif !important;
}

/* ── Page headers ── */
.ph-title,
.page-title {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif !important;
  font-size: 28px !important;
  font-weight: 800 !important;
  letter-spacing: -0.3px !important;
  line-height: 1.2 !important;
  color: #0f172a !important;
}
@media (min-width: 900px) {
  .ph-title, .page-title {
    font-size: 32px !important;
  }
}
.ph-tagline {
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.8px !important;
  text-transform: uppercase !important;
  color: #10b981 !important;
}

/* ── Card / section titles (ALL-CAPS label style) ── */
.p-card-title,
.card-title,
.dashboard-view .card-title,
.analytics-card-title,
.chart-card-title,
.cd-ing-section-title,
.scan-ing-section-title {
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: 0.7px !important;
  text-transform: uppercase !important;
  color: #0f172a !important;
}

/* ── Sub-headers / group labels ── */
.p-card-action,
.card-title-link,
.scan-section-title,
.cd-ph-row .ph-tagline,
.scan-ing-label,
.cd-card-stat-label,
.kpi-tile-label,
.dash-kpi-label,
.kpi-label,
.ph-tagline {
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.6px !important;
  text-transform: uppercase !important;
}

/* ── Table column headers ── */


/* ── Table body cells ── */


/* ── Numeric cells (tabular alignment) ── */


/* ── Category / institution name in tables ── */

.p-table .row-sub {
  font-size: 10px !important;
  font-weight: 600 !important;
  color: #64748b !important;
  letter-spacing: 0.3px !important;
}

/* ── Total rows ── */


/* ── KPI tile values (hero metrics) ── */
.kpi-tile-value,
.kpi-value,
.ai-kpi-value,
.dash-kpi-val,
.stat-value,
.analytics-hero-value,
.pig-stat-value,
.pig-total-value,
.acct-stat-value,
.cd-card-value,
.ph-mainfig,
.net-worth-value {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif !important;
  font-size: 28px !important;
  font-weight: 800 !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: -0.5px !important;
  line-height: 1.1 !important;
}

/* ── KPI sub-text ── */
.kpi-tile-sub,
.kpi-sub,
.ai-kpi-sub,
.pig-stat-sub,
.payout-kpi-sub,
.cd-card-sub {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #64748b !important;
  line-height: 1.4 !important;
}

/* ── Asset Allocation legend ── */
.donut-legend-label,
.legend-label {
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.4px !important;
  text-transform: uppercase !important;
  color: #1e293b !important;
}

/* ── CD card stats ── */
.cd-card-stat-label {
  font-size: 9px !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px !important;
  text-transform: uppercase !important;
  color: #64748b !important;
}
.cd-card-stat-value {
  font-size: 14px !important;
  font-weight: 800 !important;
  font-variant-numeric: tabular-nums !important;
  color: #0f172a !important;
}

/* ── Body / content text ── */
.p-card-body,
.card-body,
.scan-account-body,
.scan-account-name,
.modal-body {
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1.5 !important;
  color: #1e293b !important;
}

/* ── Caption / metadata ── */
.inst-meta,
.scan-meta,
.muted,
.card-title-sub,
.ph-stat-pill-label {
  font-size: 11px !important;
  font-weight: 500 !important;
  color: #64748b !important;
}

/* ── Pill / badge text ── */
.ph-stat-pill-value,
.cd-badge-default,
.cd-badge-warm,
.cd-badge-hot,
.cd-badge-matured,
.cd-card-badge {
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: 0.4px !important;
  font-variant-numeric: tabular-nums !important;
}

/* ── Institution names in CD cards ── */
.cd-card-inst span,
.cd-card-inst-name,
.cd-card-type-label {
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: 0.5px !important;
  text-transform: uppercase !important;
}

/* ── Account number display ── */
.cd-card-acct-num,
.cd-card-number {
  font-size: 12px !important;
  font-weight: 700 !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: 0.3px !important;
}

/* ── Code / JSON / OCR preformatted text (keep readable) ── */
pre,
code,
.json-block {
  font-family: ui-monospace, Consolas, 'Courier New', monospace !important;
  font-size: 12px !important;
  font-weight: 400 !important;
}

/* ── Mobile scale-down ── */
@media (max-width: 899px) {
  .kpi-tile-value,
  .kpi-value,
  .ai-kpi-value,
  .dash-kpi-val,
  .ph-mainfig,
  .net-worth-value {
    font-size: 22px !important;
  }
  .ph-title, .page-title {
    font-size: 24px !important;
  }
}

/* ── Verification page: balance input field ── */
.scan-ing-balance {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 9px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  width: 100%;
  background: var(--surface);
  color: var(--ink-1, #0f172a);
}

/* ================================================================
   ACCOUNT ROW — badge styles (layout now in SVX block below)
   ================================================================ */

/* OCR match badge */
.badge-ocr-match {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  background: #dcfce7;
  color: #15803d;
  white-space: nowrap;
}
.badge-ocr-match.scan-conf-med { background: #fef9c3; color: #854d0e; }
.badge-ocr-match.scan-conf-low { background: #fee2e2; color: #991b1b; }

/* ================================================================
   SVX — VERIFICATION PAGE v102
   Split-pane workspace: top = screenshot viewer (fixed, pannable,
   zoomable), bottom = verification workspace (scrollable).
   Independent scrolling. Standard hamburger restored.
   No floating FABs. Actions at bottom only.
   ================================================================ */

/* ── Upload idle ─────────────────────────────────────────────── */
.svx-upload-root {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 90px); padding: 16px; box-sizing: border-box;
}
.svx-upload-zone {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: 360px; width: 100%; padding: 28px 20px;
  border: 2px dashed #cbd5e1; border-radius: 14px; background: #f8fafc; text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.svx-upload-zone.svx-drag-over { border-color: #2563eb; background: #eff6ff; }
.svx-upload-icon  { font-size: 36px; line-height: 1; }
.svx-upload-title { font-size: 16px; font-weight: 800; color: #0f172a; }
.svx-upload-sub   { font-size: 11px; color: #64748b; line-height: 1.4; max-width: 260px; }
.svx-upload-btn   { padding: 9px 20px !important; font-size: 13px !important; cursor: pointer; }
.svx-upload-or    { font-size: 10px; color: #94a3b8; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.svx-upload-tips  { display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; color: #64748b; }

/* ── Split-pane workspace root ───────────────────────────────── */
.svx-workspace {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 70px); /* 70px = main-content top padding (hamburger clearance) */
  overflow: hidden;
  background: #0f172a;
}

/* ══ TOP PANE: Screenshot viewer ════════════════════════════════ */
.svx-top-pane {
  flex: 0 0 44vh;          /* fixed height ~44% viewport */
  min-height: 200px;
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  border-bottom: 2px solid #334155;
  overflow: hidden;
  position: relative;
}

/* Viewer toolbar */
.svx-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  height: 32px;
  box-sizing: border-box;
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.svx-viewer-toolbar::-webkit-scrollbar { display: none; }

.svx-tbtn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; height: 22px; box-sizing: border-box;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: #cbd5e1;
  font-size: 11px; font-weight: 700; font-family: inherit;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background 0.1s;
}
.svx-tbtn:hover { background: rgba(255,255,255,0.18); color: #fff; }
.svx-tbtn--upload { background: rgba(37,99,235,0.65); border-color: rgba(96,165,250,0.5); color: #fff; }
.svx-tbtn--upload:hover { background: rgba(37,99,235,0.9); }
.svx-tbtn--icon { padding: 0; width: 22px; height: 22px; justify-content: center; font-size: 14px; font-weight: 800; }
.svx-tbtn-sep { width: 1px; height: 14px; background: rgba(255,255,255,0.15); flex-shrink: 0; margin: 0 1px; }
.svx-zoom-val { font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; color: #94a3b8; min-width: 30px; text-align: center; }

.svx-inst-pill {
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 1px 6px; border-radius: 4px; white-space: nowrap; flex-shrink: 0;
  max-width: 100px; overflow: hidden; text-overflow: ellipsis;
}
.svx-conf-high { background: rgba(16,185,129,0.25); color: #6ee7b7; }
.svx-conf-med  { background: rgba(251,191,36,0.25);  color: #fde68a; }
.svx-conf-low  { background: rgba(239,68,68,0.25);   color: #fca5a5; }

/* Viewer stage: overflow hidden, image dragged via JS */
.svx-viewer-stage {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
  background: #1e293b;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.svx-viewer-stage:active { cursor: grabbing; }
#svx-img {
  position: absolute;
  top: 0; left: 0;
  max-width: none;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  /* transform applied by JS: translate + scale */
}
.svx-no-img {
  color: #475569; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}

/* ══ BOTTOM PANE: Verification workspace ════════════════════════ */
.svx-bottom-pane {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  padding: 8px 10px 20px;
  box-sizing: border-box;
  /* independent scroll from top pane */
  -webkit-overflow-scrolling: touch;
}

/* ── Duplicate warning ───────────────────────────────────────── */
.svx-dup-warn {
  font-size: 10.5px; font-weight: 600; color: #92400e;
  background: #fef3c7; border: 1px solid #fcd34d;
  border-radius: 6px; padding: 5px 8px; margin-bottom: 6px;
}

/* ── Institution row ─────────────────────────────────────────── */
.svx-inst-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 0 6px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 3px;
}
.svx-lbl {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.5px; color: #94a3b8; white-space: nowrap; flex-shrink: 0;
}
.svx-sel {
  flex: 1; padding: 4px 6px;
  border: 1px solid #e2e8f0; border-radius: 5px;
  font-size: 12px; font-weight: 600; font-family: inherit;
  color: #0f172a; background: #fff; appearance: auto; min-height: 26px;
}
.svx-sel:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.12); }

/* ── Account list header ─────────────────────────────────────── */
.svx-acct-hdr {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid #e2e8f0;
}
.svx-acct-hdr-cb { flex: 0 0 22px; }
.svx-hdr-lbl {
  font-size: 8.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.5px; color: #94a3b8;
}
.svx-hdr-bal { flex: 0 0 80px; text-align: right; }

/* ── Account rows ────────────────────────────────────────────── */
.svx-row {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(226,232,240,0.7);
}
.svx-row:last-child { border-bottom: none; }
.svx-row.is-checked { background: rgba(16,185,129,0.03); }

.svx-row-cb {
  flex: 0 0 22px; display: flex; align-items: flex-start;
  padding-top: 3px; cursor: pointer;
}
.svx-row-cb input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: #10b981; cursor: pointer; flex-shrink: 0;
}
.svx-row-info { flex: 1; min-width: 0; }
.svx-row-name {
  font-size: 11.5px; font-weight: 700; color: #0f172a;
  display: flex; align-items: center; flex-wrap: wrap; gap: 3px; line-height: 1.3;
}
.svx-l4 { font-size: 10px; font-weight: 700; color: #475569; font-variant-numeric: tabular-nums; }

/* ── Balance column + chips ──────────────────────────────────── */
.svx-row-right {
  flex: 0 0 80px;
  display: flex; flex-direction: column; gap: 3px;
}
.svx-bal-in {
  width: 100%; text-align: right; box-sizing: border-box;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; font-family: inherit;
  padding: 4px 5px;
  border: 1px solid #e2e8f0; border-radius: 5px;
  background: #fff; color: #0f172a;
}
.svx-bal-in:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.12); }
.svx-bal-in:disabled { background: #f8fafc; color: #94a3b8; border-color: transparent; }

/* ── Chips: dense responsive grid, fills full row width ─────── */
/* Restructure: chips sit OUTSIDE svx-row-right as a full-width row */
.svx-row {
  flex-wrap: wrap; /* allow chips row to wrap below */
}
.svx-row-right .ocr-bal-chips {
  display: none !important; /* hidden when inside right col */
}
/* Chips rendered as a separate full-width element after .svx-row-right */
/* JS injects chips into .svx-chips-row div appended after the row */
.svx-chips-row {
  width: 100%;
  flex: 0 0 100%;
  padding: 3px 0 4px 28px; /* indent to align under account name */
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 3px;
  border-bottom: 1px solid rgba(226,232,240,0.7);
  margin-bottom: -1px; /* collapse with row border */
}
@media (min-width: 480px) { .svx-chips-row { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); } }
@media (min-width: 700px) { .svx-chips-row { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); } }

/* ── Select-all / count footer ───────────────────────────────── */
.svx-list-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0 0; margin-top: 2px;
  border-top: 1px solid #e2e8f0;
}
.svx-all-lbl {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; color: #475569;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.4px;
}
.svx-all-lbl input[type="checkbox"] { width: 13px; height: 13px; accent-color: #10b981; cursor: pointer; }
.svx-sel-cnt { font-size: 10px; font-weight: 700; color: #64748b; }
.svx-empty { padding: 10px 0; font-size: 11px; color: #94a3b8; text-align: center; }

/* ── Debug toggle ────────────────────────────────────────────── */
.svx-debug { margin-top: 8px; }
.svx-debug-btn {
  font-size: 9.5px; font-weight: 600; color: #64748b;
  background: none; border: none; cursor: pointer; padding: 2px 0; display: block;
}
.svx-debug-btn:hover { color: #0f172a; }

/* ── Actions: bottom of workspace, no float/sticky ───────────── */
.svx-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 14px; padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}
.svx-act-btn {
  min-width: 110px; font-size: 12.5px !important;
  padding: 7px 16px !important; min-height: 36px !important;
}

/* ── Hide legacy overlay elements ───────────────────────────── */
.scan-overlay-screen, .svx-ctrl-bar,
.scan-verify-fab, .scan-verify-backdrop,
.scan-verify-drawer-handle { display: none !important; }

/* ── OCR BALANCE CHIPS — unified, NO transform on any state ─── */
.ocr-bal-chips {
  display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px;
}
.ocr-bal-chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 4px; min-width: 0; box-sizing: border-box;
  font-size: 9.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: #475569; background: #f1f5f9; border: 1px solid #e2e8f0;
  border-radius: 4px; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; line-height: 1.4;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background-color 0.1s, border-color 0.1s, color 0.1s;
  transform: none !important; -webkit-transform: none !important;
}
.ocr-bal-chip:hover  { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; transform: none !important; }
.ocr-bal-chip:active { opacity: 0.85; transform: none !important; }
.ocr-bal-chip:focus  { outline: 2px solid #059669; outline-offset: 1px; transform: none !important; }
.ocr-bal-chip--active,
.ocr-bal-chip[aria-pressed="true"] {
  background: #059669; color: #fff; border-color: #059669; transform: none !important;
}

/* When chips are inside svx-row-right, override to grid (defined above) */

   ACCOUNT PERFORMANCE DASHBOARD — Ranks Page Redesign
   Compact professional finance cards. Bloomberg-style hierarchy.
   2-col grid desktop, 1-col mobile. Smaller vertical footprint.
   ================================================================ */

/* ── Dashboard grid ── */
.account-perf-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

/* ── Performance card shell ── */
/* ============================================================
   ACCOUNT PERFORMANCE CARDS — compact, information-dense
   Card anatomy (top → bottom):
     Header  : logo (40px) + account name + institution
     Balance : Beginning → Current (side-by-side, 1 row)
     Metrics : 4 cells in a row (Net Gain | ROI | Duration | APY)
     Footer  : thin ROI progress bar + percentage
   All font sizes from system tokens; no !important needed.
   ============================================================ */

/* ── Card shell ── */
.perf-card {
  background: #ffffff;
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: box-shadow 0.16s, transform 0.1s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.perf-card:hover  { box-shadow: 0 4px 16px rgba(0,0,0,0.09); transform: translateY(-1px); }
.perf-card:active { transform: scale(0.985); }

/* ── Header: logo + name + institution ── */
.perf-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline, #e2e8f0);
}
/* Logo: 40px — readable but compact */
.perf-card-logo {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
  background: #f8fafc;
  border: 1px solid var(--hairline, #e2e8f0);
  padding: 2px;
}
.perf-card-logo-fallback {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-600, #059669), #047857);
  color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
  flex-shrink: 0;
}
.perf-card-info { flex: 1; min-width: 0; }
.perf-card-name {
  font-size: 13px; font-weight: 700; color: #0f172a;
  word-break: break-word; overflow-wrap: break-word;
}
.perf-card-institution {
  font-size: 10px; font-weight: 600; color: #64748b;
  margin-top: 1px;
  text-transform: uppercase; letter-spacing: 0.3px;
  word-break: break-word;
}

/* ── Balance row: Beginning → Current ── */
.perf-balance-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline, #e2e8f0);
  background: #fafbfc;
  gap: 0;
}
.perf-bal-item { flex: 1; }
.perf-bal-item--right { text-align: right; }
.perf-bal-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 2px;
}
.perf-bal-val {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px; font-weight: 700;
  color: #0f172a; font-variant-numeric: tabular-nums;
}
.perf-bal-arrow {
  font-size: 11px; color: #cbd5e1;
  padding: 0 8px; flex-shrink: 0;
  /* vertically offset to align with values rather than labels */
  margin-top: 10px;
}

/* ── Metrics strip: 4 equal cells ── */
.perf-metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 12px;
  flex: 1;
}
.perf-metrics-row .perf-metric {
  padding: 0 6px;
  border-right: 1px solid var(--hairline, #e2e8f0);
}
.perf-metrics-row .perf-metric:first-child { padding-left: 0; }
.perf-metrics-row .perf-metric:last-child  { border-right: 0; padding-right: 0; }

/* ── Metric cell ── */
.perf-metric { display: flex; flex-direction: column; gap: 2px; }
.perf-metric-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  color: #94a3b8;
}
.perf-metric-value {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 13px; font-weight: 700;
  color: #0f172a; font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.perf-metric-value.positive { color: #059669; }
.perf-metric-value.negative { color: #dc2626; }
.perf-metric-sub {
  font-size: 9px; font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.2px;
}
/* "—" placeholder when data unavailable */
.perf-no-data { color: #cbd5e1 !important; font-weight: 500 !important; }

/* ── ROI bar footer ── */
.perf-card-footer {
  padding: 6px 12px 8px;
  border-top: 1px solid var(--hairline, #e2e8f0);
}
.perf-roi-bar  { display: flex; align-items: center; gap: 8px; }
.perf-roi-track {
  flex: 1; height: 4px;
  background: #e2e8f0; border-radius: 2px; overflow: hidden;
}
.perf-roi-fill {
  height: 100%;
  background: linear-gradient(90deg, #059669, #10b981);
  border-radius: 2px;
  transition: width 0.4s ease-out;
  min-width: 3px;
}
.perf-roi-fill.negative { background: linear-gradient(90deg, #dc2626, #ef4444); }
.perf-roi-pct {
  font-family: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 11px; font-weight: 700;
  color: #0f172a; font-variant-numeric: tabular-nums;
  min-width: 44px; text-align: right; white-space: nowrap;
}
.perf-roi-pct.positive { color: #059669; }
.perf-roi-pct.negative { color: #dc2626; }

/* ── Dashboard grid ── */
.account-perf-dashboard {
  display: grid;
  gap: 10px;
}

/* ── Responsive breakpoints ── */
@media (max-width: 599px) {
  .account-perf-dashboard { grid-template-columns: 1fr; gap: 8px; }
  /* 2×2 metrics on narrow mobile */
  .perf-metrics-row { grid-template-columns: repeat(2, 1fr); gap: 0; }
  .perf-metrics-row .perf-metric { padding: 6px 6px 0; border-right: 0; }
  .perf-metrics-row .perf-metric:nth-child(1),
  .perf-metrics-row .perf-metric:nth-child(2) { padding-top: 0; }
  .perf-metrics-row .perf-metric:nth-child(1),
  .perf-metrics-row .perf-metric:nth-child(3) { padding-left: 0; }
  .perf-metrics-row .perf-metric:nth-child(1),
  .perf-metrics-row .perf-metric:nth-child(2) { border-bottom: 1px solid var(--hairline, #e2e8f0); }
}
@media (min-width: 600px) and (max-width: 1099px) {
  .account-perf-dashboard { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
@media (min-width: 1100px) {
  .account-perf-dashboard { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}

/* ================================================================
   UPDATED RANK-CARD STYLES — 1.5x larger logos
   ================================================================ */
.rank-card-logo,
.rank-card-logo-fallback {
  width: var(--logo-md, 54px) !important;
  height: var(--logo-md, 54px) !important;
}
.rank-card-logo-fallback {
  font-size: 20px !important;
}

/* ================================================================
   CONSISTENT LOGO SIZING ACROSS ALL PAGES
   Apply to Portfolio page and other views for uniformity.
   ================================================================ */
.shared-logo-img,
.inst-logo,
.acct-type-logo,
.mc-cat-logo {
  width: var(--logo-sm, 36px) !important;
  height: var(--logo-sm, 36px) !important;
  border-radius: 8px;
  object-fit: contain;
}

/* Hero/prominent logo contexts use md size */
.logo-prominent,
.inst-logo-featured {
  width: var(--logo-md, 54px) !important;
  height: var(--logo-md, 54px) !important;
  border-radius: 10px;
}



/* ================================================================
   HALL OF FAME — tabs, rank cards, detail strips
   Canonical block. All hof-* rules live here only.
   ================================================================ */

/* ── Tab bar ── */
.hof-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 14px;
  background: var(--surface-2, #f7f8fa);
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 10px;
  padding: 4px;
}
.hof-tab {
  flex: 1;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-align: center;
}
.hof-tab:hover { background: #ffffff; color: #0f172a; }
.hof-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── Rank list container ── */
.hof-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Individual rank card ── */
.hof-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--hairline, #e2e8f0);
  border-bottom: none;
  cursor: pointer;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.hof-card:first-child           { border-radius: 10px 10px 0 0; }
.hof-list > *:last-child        { border-bottom: 1px solid var(--hairline, #e2e8f0); border-radius: 0 0 10px 10px; }
/* When a .hof-card-detail is last — give radius to the detail strip */
.hof-card-detail:last-child     { border-radius: 0 0 10px 10px; }
/* First card gets top radius only if it IS the first child */
.hof-card:first-of-type         { border-top-left-radius: 10px; border-top-right-radius: 10px; }
.hof-card:hover                 { background: var(--surface-2, #f7f8fa); }
.hof-card:active                { background: #f1f5f9; }

/* ── Rank badge ── */
.hof-rank {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  flex-shrink: 0;
}

/* ── Card left: logo + text ── */
.hof-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* ── Institution logo (HoF) ── */
.hof-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
  background: #f8fafc;
  border: 1px solid var(--hairline, #e2e8f0);
  padding: 2px;
}
.hof-logo-fb {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-600, #059669), #047857);
  color: #ffffff;
  font-size: 14px; font-weight: 800;
  padding: 0;
}

/* ── Account name + institution text ── */
.hof-card-info { flex: 1; min-width: 0; }
.hof-card-name {
  font-size: 13px; font-weight: 700; color: #0f172a;
  word-break: break-word; overflow-wrap: break-word;
}
.hof-card-inst {
  font-size: 10px; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.3px;
  margin-top: 1px;
  word-break: break-word;
}

/* ── Primary metric (right side) ── */
.hof-card-right { text-align: right; flex-shrink: 0; }
.hof-primary {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 15px; font-weight: 800;
  color: #0f172a; font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.hof-primary-label {
  font-size: 9px; font-weight: 700;
  color: #94a3b8; text-transform: uppercase; letter-spacing: 0.4px;
  margin-top: 1px;
}

/* ── Detail strip beneath a rank card ── */
.hof-card-detail {
  display: flex;
  gap: 0;
  padding: 7px 12px 7px 86px; /* 86px = rank(28) + gap(10) + logo(36) + gap(10) + 2px */
  background: var(--surface-2, #f7f8fa);
  border: 1px solid var(--hairline, #e2e8f0);
  border-top: 1px solid var(--hairline-soft, rgba(0,0,0,0.05));
  border-bottom: none;
}
.hof-card-detail:last-child { border-bottom: 1px solid var(--hairline, #e2e8f0); }
.hof-detail-item { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.hof-detail-item + .hof-detail-item { border-left: 1px solid var(--hairline, #e2e8f0); padding-left: 10px; }
.hof-dl {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; color: #94a3b8;
}
.hof-dv {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12px; font-weight: 700;
  color: #0f172a; font-variant-numeric: tabular-nums;
}
.hof-dv.positive { color: #059669; }
.hof-dv.negative { color: #dc2626; }

/* ── Empty state ── */
.hof-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px; font-weight: 500;
  color: #94a3b8;
  background: #ffffff;
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 10px;
}

/* ── Positive / negative colour helpers (used inline in HoF) ── */
.hof-card .positive, .hof-primary.positive { color: #059669; }
.hof-card .negative, .hof-primary.negative { color: #dc2626; }

/* ── Mobile: tighten HoF layout ── */
@media (max-width: 599px) {
  .hof-tab { font-size: 10px; padding: 6px 6px; }
  .hof-card { padding: 9px 10px; gap: 8px; }
  .hof-card-detail { padding: 6px 10px 6px 10px; flex-wrap: wrap; gap: 8px; }
  .hof-detail-item + .hof-detail-item { border-left: none; padding-left: 0; }
  .hof-logo { width: 32px; height: 32px; }
  .hof-rank { width: 24px; height: 24px; font-size: 11px; }
  .hof-primary { font-size: 14px; }
}

/* ================================================================
   ACCOUNT PERFORMANCE — sort bar
   ================================================================ */
.perf-sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.perf-sort-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #64748b; white-space: nowrap;
}
.perf-sort-select {
  appearance: none;
  -webkit-appearance: none;
  background: #ffffff 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='%2394a3b8'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 8px;
  padding: 7px 30px 7px 11px;
  font-size: 12px; font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  min-width: 180px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.perf-sort-select:focus {
  outline: 2px solid var(--brand-600, #059669);
  outline-offset: 1px;
}


/* ================================================================
   CARD SEQUENCE INDICATOR — "3 / 57"
   Shown in top-right corner of all performance/CD/portfolio cards.
   ================================================================ */
.card-seq {
  /* Removed absolute positioning — was overlapping balance column on mobile */
  display: inline;
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.4px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
/* Inline sequence badge used in portfolio mobile card inst line */
.card-seq-inline {
  display: inline;
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4px;
}
/* Performance and CD cards keep sequence as top-right chip */
.perf-card { position: relative; }
.cd-card   { position: relative; }
.perf-card .card-seq,
.cd-card   .card-seq {
  position: absolute;
  top: 8px; right: 10px;
  z-index: 1;
}
.portfolio-acct-card { position: relative; }

/* ================================================================
   OCR SNAPSHOT CHIPS — draggable balance snippets in left panel
   ================================================================ */
.ocr-chip-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.ocr-snap-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: #ffffff;
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 8px;
  cursor: grab;
  transition: background 0.1s, box-shadow 0.1s, border-color 0.1s;
  -webkit-user-select: none;
  user-select: none;
}
.ocr-snap-chip:hover {
  background: #f0fdf4;
  border-color: #86efac;
  box-shadow: 0 1px 4px rgba(5,150,105,0.1);
}
.ocr-snap-chip.is-dragging {
  opacity: 0.5;
  cursor: grabbing;
}
.ocr-snap-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ocr-snap-acct {
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}
.ocr-snap-drag-hint {
  font-size: 9px;
  font-weight: 500;
  color: #94a3b8;
  letter-spacing: 0.2px;
}
.ocr-snap-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ocr-snap-bal {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #059669;
  font-variant-numeric: tabular-nums;
}
.ocr-snap-bal--empty { color: #94a3b8; }
.ocr-snap-copy {
  font-size: 9px;
  padding: 2px 7px;
  height: 20px;
}

/* ── Drop-target highlight on account rows ── */
.scan-ing-check-row[data-drop-target="true"].drag-over {
  background: #f0fdf4;
  outline: 2px dashed #059669;
  border-radius: 8px;
}

/* ================================================================
   "USE PREVIOUS BALANCE" button + OCR balance picker
   ================================================================ */
.scan-ing-prev-hint {
  background: #fffbeb;
  border-radius: 5px;
  padding: 3px 6px;
  margin-top: 3px;
}
.ocr-copy-btn--prev {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.ocr-copy-btn--prev:hover {
  background: #fde68a;
}

.scan-ing-ocr-picker-wrap {
  margin-top: 4px;
}
.ocr-bal-picker {
  appearance: none;
  -webkit-appearance: none;
  background: #f8fafc 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='%2394a3b8'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 6px;
  padding: 5px 24px 5px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  width: 100%;
  max-width: 240px;
}
.ocr-bal-picker:focus {
  outline: 2px solid var(--brand-600, #059669);
  outline-offset: 1px;
}


/* ================================================================
   OCR CHIP ASSIGN DROPDOWN — chip → account assignment
   Compact select inside each OCR extraction chip (left panel).
   ================================================================ */
.ocr-chip-assign {
  appearance: none; -webkit-appearance: none;
  background: #f1f5f9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%2394a3b8'/%3E%3C/svg%3E") no-repeat right 6px center;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 3px 20px 3px 7px;
  font-size: 10px; font-weight: 600;
  color: #475569;
  cursor: pointer;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}
.ocr-chip-assign:focus { outline: 2px solid var(--brand-600, #059669); outline-offset: 1px; }

/* Flash animation when a chip assigns a balance to a row */
.drop-flash { animation: drop-flash-kf 0.8s ease-out; }
@keyframes drop-flash-kf {
  0%   { background: #d1fae5; }
  100% { background: transparent; }
}


/* ================================================================
   PROFESSIONAL FINANCE DASHBOARD — wt-* component system
   Empower / Monarch / Kubera visual register.
   All rules scoped to .dashboard-view or stand-alone wt- classes.
   ================================================================ */

/* ── Colour tokens ──────────────────────────────────────────── */
:root {
  --wt-pos:    #059669;
  --wt-pos-bg: #ecfdf5;
  --wt-neg:    #dc2626;
  --wt-neg-bg: #fef2f2;
  --wt-blue:   #2563eb;
  --wt-blue-bg:#eff6ff;
  --wt-gold:   #d97706;
  --wt-gold-bg:#fffbeb;
  --wt-ink:    #0f172a;
  --wt-muted:  #64748b;
  --wt-border: #e2e8f0;
  --wt-surface:#f8fafc;
  --wt-card:   #ffffff;
  --wt-r:      12px;   /* card radius */
  --wt-r-sm:   8px;
}

/* ── Shared colour helpers ──────────────────────────────────── */
.wt-pos  { color: var(--wt-pos) !important; }
.wt-neg  { color: var(--wt-neg) !important; }
.wt-blue { color: var(--wt-blue) !important; }

/* ── Section wrapper ────────────────────────────────────────── */
.wt-section {
  background: var(--wt-card);
  border: 1px solid var(--wt-border);
  border-radius: var(--wt-r);
  padding: 16px;
  margin-bottom: 12px;
}
.wt-section .p-card-title {
  margin-bottom: 12px;
}

/* ================================================================
   HERO — net worth + deltas + three sub-metrics
   ================================================================ */
.wt-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #1e40af 100%);
  border-radius: var(--wt-r);
  padding: 20px 18px 16px;
  margin-bottom: 12px;
  color: #ffffff;
}
.wt-hero-eyebrow {
  font-size: 9px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-bottom: 4px;
}
.wt-hero-nw {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 32px; font-weight: 800;
  color: #ffffff; font-variant-numeric: tabular-nums;
  line-height: 1.1; letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.wt-hero-nw.wt-neg { color: #fca5a5; }
.wt-hero-deltas {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 14px;
}
.wt-delta {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.wt-delta.wt-pos { background: rgba(5,150,105,0.25); color: #6ee7b7; }
.wt-delta.wt-neg { background: rgba(220,38,38,0.25);  color: #fca5a5; }
.wt-delta-sep { color: rgba(255,255,255,0.3); font-size: 11px; }

.wt-hero-row {
  display: flex; align-items: stretch;
  background: rgba(255,255,255,0.07);
  border-radius: var(--wt-r-sm);
  overflow: hidden;
}
.wt-hero-cell {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 10px 6px; gap: 2px;
  text-align: center;
}
.wt-hero-cell-l {
  font-size: 8px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: rgba(255,255,255,0.45);
}
.wt-hero-cell-v {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px; font-weight: 700;
  color: #ffffff; font-variant-numeric: tabular-nums;
}
.wt-hero-cell-v.wt-neg { color: #fca5a5; }
.wt-hero-cell-v.wt-pos { color: #6ee7b7; }
.wt-hero-divider {
  width: 1px; background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}

/* ================================================================
   KPI GRID — 12 metric tiles, 2 → 3 → 4 col responsive
   ================================================================ */
.wt-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
@media (min-width: 600px)  { .wt-kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .wt-kpi-grid { grid-template-columns: repeat(4, 1fr); } }

.wt-kpi-tile {
  background: var(--wt-card);
  border: 1px solid var(--wt-border);
  border-radius: var(--wt-r-sm);
  padding: 12px 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
  transition: box-shadow 0.15s;
}
.wt-kpi-tile:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.07); }
.wt-kpi-l {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--wt-muted);
}
.wt-kpi-v {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 16px; font-weight: 800;
  color: var(--wt-ink); font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.wt-kpi-s {
  font-size: 10px; font-weight: 500;
  color: var(--wt-muted); line-height: 1.3;
}

/* Colour variants — left accent bar */
.wt-kpi-tile--green { border-left: 3px solid var(--wt-pos); }
.wt-kpi-tile--green .wt-kpi-v { color: var(--wt-pos); }
.wt-kpi-tile--red   { border-left: 3px solid var(--wt-neg); }
.wt-kpi-tile--red   .wt-kpi-v { color: var(--wt-neg); }
.wt-kpi-tile--blue  { border-left: 3px solid var(--wt-blue); }
.wt-kpi-tile--blue  .wt-kpi-v { color: var(--wt-blue); }

/* ================================================================
   PORTFOLIO ANALYTICS
   ================================================================ */
.wt-port-stats {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-bottom: 12px;
}
@media (min-width: 600px) { .wt-port-stats { grid-template-columns: repeat(4, 1fr); } }

.wt-port-stat {
  background: var(--wt-surface);
  border: 1px solid var(--wt-border);
  border-radius: var(--wt-r-sm);
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.wt-port-sl {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--wt-muted);
}
.wt-port-sv {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px; font-weight: 700;
  color: var(--wt-ink); font-variant-numeric: tabular-nums;
}

/* Allocation list */
.wt-alloc-list { display: flex; flex-direction: column; gap: 6px; }
.wt-alloc-row {
  display: grid;
  grid-template-columns: 110px 1fr 40px 60px;
  align-items: center; gap: 8px;
}
@media (max-width: 479px) {
  .wt-alloc-row { grid-template-columns: 80px 1fr 36px 54px; }
}
.wt-alloc-cat {
  font-size: 11px; font-weight: 600; color: var(--wt-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wt-alloc-bar-wrap {
  height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden;
}
.wt-alloc-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 3px; transition: width 0.4s ease-out;
  min-width: 2px;
}
.wt-alloc-pct {
  font-size: 11px; font-weight: 700;
  color: var(--wt-muted); text-align: right;
  font-variant-numeric: tabular-nums;
}
.wt-alloc-val {
  font-size: 11px; font-weight: 600;
  color: var(--wt-ink); text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   PERFORMANCE LEADERS
   ================================================================ */
.wt-ldr-grid {
  display: grid; grid-template-columns: 1fr;
  gap: 8px; margin-bottom: 10px;
}
@media (min-width: 600px) { .wt-ldr-grid { grid-template-columns: repeat(3, 1fr); } }

.wt-ldr-card {
  border: 1px solid var(--wt-border); border-radius: var(--wt-r-sm);
  overflow: hidden;
}
.wt-ldr-badge {
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.8px; text-transform: uppercase;
  padding: 4px 10px;
  background: var(--wt-surface); color: var(--wt-muted);
  border-bottom: 1px solid var(--wt-border);
}
.wt-ldr-body {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
}
.wt-ldr-logo {
  width: 32px; height: 32px; border-radius: 7px;
  object-fit: contain; flex-shrink: 0;
  background: var(--wt-surface);
  border: 1px solid var(--wt-border);
  padding: 2px;
}
.wt-ldr-info { flex: 1; min-width: 0; }
.wt-ldr-name {
  font-size: 12px; font-weight: 700; color: var(--wt-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wt-ldr-inst {
  font-size: 9px; font-weight: 600; color: var(--wt-muted);
  text-transform: uppercase; letter-spacing: 0.3px;
  margin-top: 1px;
}
.wt-ldr-metric { text-align: right; flex-shrink: 0; }
.wt-ldr-val {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.wt-ldr-sub {
  font-size: 9px; font-weight: 500; color: var(--wt-muted);
  margin-top: 1px;
}

.wt-lstat-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.wt-lstat {
  background: var(--wt-surface); border: 1px solid var(--wt-border);
  border-radius: var(--wt-r-sm); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.wt-lstat-l {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--wt-muted);
}
.wt-lstat-v {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px; font-weight: 700;
  color: var(--wt-ink); font-variant-numeric: tabular-nums;
}

/* ================================================================
   LIQUIDITY BREAKDOWN
   ================================================================ */
.wt-liq-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 600px) { .wt-liq-grid { grid-template-columns: repeat(4, 1fr); } }

.wt-liq-tile {
  border-radius: var(--wt-r-sm);
  padding: 10px 12px;
  border: 1px solid transparent;
}
.wt-liq-tile--now  { background: #ecfdf5; border-color: #a7f3d0; }
.wt-liq-tile--soon { background: #eff6ff; border-color: #bfdbfe; }
.wt-liq-tile--mid  { background: #fffbeb; border-color: #fde68a; }
.wt-liq-tile--lock { background: #f1f5f9; border-color: #cbd5e1; }

.wt-liq-label {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--wt-muted); margin-bottom: 4px;
}
.wt-liq-val {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 15px; font-weight: 800;
  color: var(--wt-ink); font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.wt-liq-meta {
  font-size: 10px; font-weight: 500;
  color: var(--wt-muted); margin-top: 3px;
}
.wt-liq-tile--now  .wt-liq-val { color: var(--wt-pos); }
.wt-liq-tile--lock .wt-liq-label { color: #94a3b8; }

/* ================================================================
   GOAL TRACKING
   ================================================================ */
.wt-goal-bar-wrap {
  height: 8px; background: #e2e8f0; border-radius: 4px;
  overflow: hidden; position: relative;
  margin-bottom: 4px;
}
.wt-goal-bar {
  height: 100%;
  background: linear-gradient(90deg, #059669, #10b981);
  border-radius: 4px;
  transition: width 0.5s ease-out;
  min-width: 4px;
}
.wt-goal-bar-label {
  position: absolute; right: 6px; top: -1px;
  font-size: 8px; font-weight: 700; color: var(--wt-muted);
}
.wt-goal-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-top: 10px;
}
@media (min-width: 600px) { .wt-goal-grid { grid-template-columns: repeat(4, 1fr); } }
.wt-goal-card {
  background: var(--wt-surface); border: 1px solid var(--wt-border);
  border-radius: var(--wt-r-sm); padding: 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.wt-goal-card-l {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--wt-muted);
}
.wt-goal-card-v {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 16px; font-weight: 800;
  color: var(--wt-ink); font-variant-numeric: tabular-nums;
}
.wt-goal-card-s {
  font-size: 10px; font-weight: 500;
  color: var(--wt-muted); line-height: 1.3;
}

/* Mobile tweaks */
@media (max-width: 479px) {
  .wt-hero-nw { font-size: 26px; }
  .wt-kpi-v   { font-size: 14px; }
  .wt-liq-val { font-size: 13px; }
  .wt-goal-card-v { font-size: 14px; }
}

/* ================================================================
   MC-TABLE MOBILE CANONICAL — overrides all conflicting legacy rules
   Single block, applied after all other mc-table rules.
   ================================================================ */
@media (max-width: 599px) {
  .table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    margin-bottom: 12px;
  }
  .instruments-table.mc-table,
  .mc-table {
    width: 100%;
    min-width: 0;
    font-size: 12px !important;
    border-collapse: collapse;
  }
  .mc-table thead th {
    font-size: 9px !important;
    font-weight: 700 !important;
    padding: 7px 8px !important;
    letter-spacing: 0.5px !important;
    white-space: nowrap;
    font-family: 'Inter', -apple-system, sans-serif !important;
  }
  .mc-table td {
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 8px 8px !important;
    vertical-align: middle;
    font-family: 'Inter', -apple-system, sans-serif !important;
  }
  .mc-table .mc-name {
    font-size: 12px !important;
    font-weight: 700 !important;
    font-family: 'Inter', -apple-system, sans-serif !important;
  }
  .mc-table .mc-count,
  .mc-table .col-right {
    font-size: 12px !important;
    font-variant-numeric: tabular-nums;
    font-family: 'Inter', -apple-system, sans-serif !important;
  }
  .mc-table .mc-icon {
    font-size: 14px !important;
  }
  .mc-table .mc-cat-logo {
    width: 18px !important;
    height: 18px !important;
  }
  .mc-total-row td {
    font-size: 12px !important;
    font-weight: 800 !important;
    padding: 8px 8px !important;
    font-family: 'Inter', -apple-system, sans-serif !important;
  }
}

/* ================================================================
   CD CARD SEQUENCE — inline with account number, separated by " - "
   Replaces absolute-position card-seq which overlapped on mobile.
   ================================================================ */
.cd-card-seq {
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.cd-card-acct-num {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ================================================================
   DAILY JOURNAL — jnl-* component styles
   ================================================================ */
.jnl-compose-card {
  background: #fff; border: 1px solid var(--wt-border,#e2e8f0);
  border-radius: 14px; padding: 20px; margin-bottom: 12px;
}
.jnl-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.jnl-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.jnl-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: #64748b;
}
.jnl-label-hint { font-weight: 500; text-transform: none; letter-spacing: 0; }
.jnl-input, .jnl-select, .jnl-textarea {
  border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 9px 12px; font-size: 13px; font-weight: 500;
  color: #0f172a; background: #fff; width: 100%; box-sizing: border-box;
  font-family: 'Inter', -apple-system, sans-serif;
  transition: border-color 0.15s;
}
.jnl-input:focus, .jnl-select:focus, .jnl-textarea:focus {
  outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.jnl-textarea { resize: vertical; min-height: 160px; line-height: 1.6; }
.jnl-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid #e2e8f0;
}
.jnl-btn {
  padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 700;
  border: 1px solid transparent; cursor: pointer; transition: all 0.15s;
}
.jnl-btn--primary { background: #0f172a; color: #fff; }
.jnl-btn--primary:hover { background: #1e293b; }
.jnl-btn--ghost { background: transparent; color: #64748b; border-color: #e2e8f0; }
.jnl-btn--ghost:hover { background: #f8fafc; }
.jnl-btn--danger { background: transparent; color: #dc2626; border-color: #fecaca; }
.jnl-btn--danger:hover { background: #fef2f2; }

.jnl-mood-filter {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px;
}
.jnl-mood-btn {
  padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700;
  border: 1px solid #e2e8f0; background: #fff; color: #64748b; cursor: pointer;
  transition: all 0.13s;
}
.jnl-mood-btn.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.jnl-mood-btn:hover:not(.active) { background: #f8fafc; }

.jnl-stats {
  font-size: 12px; font-weight: 600; color: #64748b;
  margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.jnl-stats-sep { color: #cbd5e1; }
.jnl-stats b { color: #0f172a; }

.jnl-list { display: flex; flex-direction: column; gap: 12px; }
.jnl-month-group {}
.jnl-month-header {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.7px; color: #94a3b8; padding: 6px 2px;
  margin-bottom: 6px;
}
.jnl-entry-row {
  display: flex; align-items: flex-start; gap: 12px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 14px 16px; cursor: pointer; transition: all 0.14s;
}
.jnl-entry-row:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.07); transform: translateY(-1px); }
.jnl-entry-left { flex: 1; min-width: 0; }
.jnl-entry-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.jnl-entry-date { font-size: 10px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 3px; }
.jnl-entry-title { font-size: 14px; font-weight: 700; color: #0f172a; margin-bottom: 3px; word-break: break-word; }
.jnl-entry-preview { font-size: 12px; font-weight: 500; color: #64748b; line-height: 1.5; margin-bottom: 5px; }
.jnl-entry-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.jnl-tag { font-size: 10px; font-weight: 600; color: #2563eb; background: #eff6ff; border-radius: 4px; padding: 1px 6px; }
.jnl-entry-mood { font-size: 20px; }
.jnl-entry-age { font-size: 10px; color: #94a3b8; font-weight: 600; }

.jnl-empty {
  text-align: center; padding: 48px 16px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
}
.jnl-empty-icon { font-size: 40px; margin-bottom: 10px; }
.jnl-empty-title { font-size: 16px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.jnl-empty-text { font-size: 13px; color: #64748b; line-height: 1.5; }

@media (max-width: 599px) {
  .jnl-field-row { grid-template-columns: 1fr; gap: 0; }
  .jnl-compose-card { padding: 14px; }
  .jnl-actions { flex-direction: column; gap: 10px; align-items: stretch; }
  .jnl-actions > div { display: flex; gap: 8px; }
  .jnl-btn { flex: 1; text-align: center; }
}

/* ================================================================
   ACTIVITY FEED — act-* component styles
   ================================================================ */
.act-section { padding: 14px 16px 6px; }
.act-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
}
.act-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.act-tab {
  padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.3px; border: 1px solid #e2e8f0; background: #fff;
  color: #64748b; cursor: pointer; transition: all 0.13s;
}
.act-tab.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.act-tab:hover:not(.active) { background: #f8fafc; }

.act-feed { display: flex; flex-direction: column; gap: 0; }
.act-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 4px; border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.act-row:last-child { border-bottom: 0; }
.act-row--link { cursor: pointer; border-radius: 6px; }
.act-row--link:hover { background: #f8fafc; }
.act-icon {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.act-body { flex: 1; min-width: 0; }
.act-desc { font-size: 12px; font-weight: 600; color: #0f172a; line-height: 1.4; word-break: break-word; }
.act-meta { font-size: 10px; color: #94a3b8; font-weight: 600; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.3px; }
.act-arrow { color: #cbd5e1; font-size: 16px; font-weight: 300; flex-shrink: 0; align-self: center; }
.act-empty { padding: 20px 4px; font-size: 12px; color: #94a3b8; font-weight: 600; }


/* ================================================================
   FINANCIAL ACTIVITY JOURNAL — jnl-* component system
   Replaces text diary. Reads from snapshot history; no manual input.
   ================================================================ */

/* ── Toolbar: period tabs + institution filter ─────────────────── */
.jnl-toolbar {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.jnl-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2, #f7f8fa);
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 9px;
  padding: 3px;
}
.jnl-tab {
  flex: 1; padding: 6px 10px;
  font-size: 11px; font-weight: 700;
  color: #64748b; background: transparent;
  border: none; border-radius: 6px;
  cursor: pointer; text-align: center;
  transition: background 0.14s, color 0.14s;
}
.jnl-tab.active { background: #ffffff; color: #0f172a; box-shadow: 0 1px 4px rgba(0,0,0,0.09); }
.jnl-tab:hover:not(.active) { background: rgba(255,255,255,0.6); }

.jnl-inst-filter { display: flex; gap: 4px; flex-wrap: wrap; }
.jnl-inst-btn {
  padding: 4px 10px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: #64748b; background: var(--surface-2, #f7f8fa);
  border: 1px solid var(--hairline, #e2e8f0); border-radius: 20px;
  cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.jnl-inst-btn.active { background: #0f172a; color: #ffffff; border-color: #0f172a; }

/* ── Summary bar ───────────────────────────────────────────────── */
.jnl-summary-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 10px;
  background: var(--surface-2, #f7f8fa);
  border: 1px solid var(--hairline, #e2e8f0);
  border-radius: 10px;
}
.jnl-summary-val { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.jnl-summary-meta { font-size: 11px; font-weight: 500; color: #64748b; }

/* ── Date group ────────────────────────────────────────────────── */
.jnl-date-group { margin-bottom: 14px; }
.jnl-date-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0 8px;
}
.jnl-date-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #94a3b8; }
.jnl-day-summary { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Change row ────────────────────────────────────────────────── */
.jnl-change-row {
  display: flex; align-items: center;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--hairline, #e2e8f0);
  border-bottom: none;
  cursor: pointer; transition: background 0.12s;
}
.jnl-date-group > .jnl-change-row:first-of-type { border-radius: 10px 10px 0 0; }
.jnl-date-group > .jnl-change-row:last-of-type  { border-bottom: 1px solid var(--hairline, #e2e8f0); border-radius: 0 0 10px 10px; }
.jnl-date-group > .jnl-change-row:only-of-type  { border-radius: 10px; border-bottom: 1px solid var(--hairline, #e2e8f0); }
.jnl-change-row:hover { background: var(--surface-2, #f7f8fa); }

.jnl-row-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.jnl-row-logo {
  width: 36px; height: 36px; border-radius: 8px;
  object-fit: contain; flex-shrink: 0;
  background: var(--surface-2, #f7f8fa);
  border: 1px solid var(--hairline, #e2e8f0); padding: 2px;
}
.jnl-row-info { flex: 1; min-width: 0; }
.jnl-row-name { font-size: 13px; font-weight: 700; color: #0f172a; }
.jnl-row-meta { font-size: 10px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.3px; margin-top: 1px; }
.jnl-row-balances { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11px; font-variant-numeric: tabular-nums; color: #64748b; }
.jnl-bal-prev { text-decoration: line-through; opacity: 0.7; }
.jnl-arrow { color: #cbd5e1; }
.jnl-bal-curr { font-weight: 600; color: #0f172a; }

.jnl-row-right { text-align: right; flex-shrink: 0; min-width: 80px; }
.jnl-delta { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.jnl-pct   { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; }
.jnl-row-ts { font-size: 9px; font-weight: 500; color: #94a3b8; margin-top: 3px; }

/* Colour helpers */
.jnl-pos { color: #059669; }
.jnl-neg { color: #dc2626; }

/* ── Empty state ───────────────────────────────────────────────── */
.jnl-empty { padding: 32px 20px; text-align: center; }
.jnl-empty-icon { font-size: 36px; margin-bottom: 8px; }
.jnl-empty-title { font-size: 16px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.jnl-empty-text  { font-size: 13px; font-weight: 500; color: #64748b; max-width: 280px; margin: 0 auto; }

/* ── Feed wrapper ─────────────────────────────────────────────── */
.jnl-feed { }

/* Mobile tweaks */
@media (max-width: 479px) {
  .jnl-tab     { font-size: 10px; padding: 5px 6px; }
  .jnl-delta   { font-size: 13px; }
  .jnl-row-logo{ width: 30px; height: 30px; }
}

/* ================================================================
   ROLLING PERFORMANCE WINDOWS — rw-* component system
   (used by buildRollingWindowSection in dashboard.js)
   ================================================================ */

/* ── Rolling Performance section wrapper ── */
.rw-section { margin-bottom: 0; }  /* wt-section already provides margin-bottom:12px */

/* ── Period window tiles — 5-col desktop, 3-col mobile ── */
.rw-window-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
@media (max-width: 599px)  { .rw-window-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; } }

.rw-tile {
  border-radius: 10px;
  padding: 10px 8px 8px;
  border: 1px solid var(--hairline, #e2e8f0);
  background: #f8fafc;
  text-align: center;
}
.rw-tile--pos { border-color: #a7f3d0; background: #ecfdf5; }
.rw-tile--neg { border-color: #fecaca; background: #fef2f2; }
.rw-tile--na  { opacity: 0.5; }

.rw-tile-period {
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: #94a3b8; margin-bottom: 4px;
}
.rw-tile-val {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.rw-tile-sub {
  font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.rw-muted { color: #94a3b8; }
.rw-pos   { color: #059669; }
.rw-neg   { color: #dc2626; }

/* ── "Today's Movers" header ── */
.rw-today-header {
  display: flex; align-items: center;
  padding: 12px 0 8px;
  border-top: 1px solid var(--hairline, #e2e8f0);
  margin-top: 2px;
}
.rw-today-title {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase; color: #64748b;
}

/* ── Movers 2-column card grid (mirrors wt-liq-grid) ── */
.rw-movers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

/* ── Individual mover card ── */
.rw-mover-card {
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--hairline, #e2e8f0);
  background: #f8fafc;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  display: flex; flex-direction: column; gap: 6px;
}
.rw-mover-card:hover  { box-shadow: 0 2px 10px rgba(0,0,0,0.08); transform: translateY(-1px); }
.rw-mover-card:active { transform: scale(0.98); }
.rw-mover-card--pos   { border-color: #a7f3d0; background: #ecfdf5; }
.rw-mover-card--neg   { border-color: #fecaca; background: #fef2f2; }

/* Card header: logo + account name */
.rw-mover-card-head {
  display: flex; align-items: center; gap: 8px;
}
.rw-mover-logo {
  width: 28px; height: 28px; border-radius: 7px;
  object-fit: contain; flex-shrink: 0;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--hairline, #e2e8f0); padding: 2px;
}
.rw-logo-fb {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff; font-size: 12px; font-weight: 800;
}
.rw-mover-card-id   { flex: 1; min-width: 0; }
.rw-mover-card-name {
  font-size: 12px; font-weight: 700; color: #0f172a;
  word-break: break-word; overflow-wrap: break-word;
  line-height: 1.3;
}
.rw-mover-card-sub  {
  font-size: 9px; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.3px; margin-top: 1px;
}

/* Balance row: prev → curr */
.rw-mover-card-balances {
  display: flex; align-items: center; gap: 4px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 10px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.rw-mover-card-prev  { color: #94a3b8; }
.rw-mover-card-arrow { color: #cbd5e1; font-size: 9px; }
.rw-mover-card-curr  { color: #1e3a5f; }

/* Bottom: delta + percent */
.rw-mover-card-bottom {
  display: flex; align-items: baseline;
  justify-content: space-between;
}
.rw-mover-card-delta {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rw-mover-card-pct {
  font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rw-no-movers {
  font-size: 12px; color: #94a3b8;
  padding: 14px 10px; text-align: center;
  grid-column: 1 / -1;
}

/* ── Institution breakdown row (horizontal pill tiles) ── */
.rw-inst-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 8px 0 4px;
}
.rw-inst-tile {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 8px 10px;
  border-radius: 9px; border: 1px solid var(--hairline, #e2e8f0);
  min-width: 76px; text-align: center;
  background: #f8fafc;
}
.rw-inst-logo {
  width: 20px; height: 20px; border-radius: 5px;
  object-fit: contain; background: rgba(255,255,255,0.7);
  border: 1px solid var(--hairline, #e2e8f0); padding: 1px;
}
.rw-inst--pos { border-color: #a7f3d0; background: #ecfdf5; }
.rw-inst--neg { border-color: #fecaca; background: #fef2f2; }
.rw-inst-name  {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.3px; color: #64748b;
}
.rw-inst-delta {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rw-inst-pct   { font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ================================================================
   SCANNER — Image opacity slider
   Sits below the zoom controls in the left image panel.
   ================================================================ */
.scan-verify-opacity-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0 2px;
}
.scan-verify-opacity-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: #94a3b8;
  white-space: nowrap; min-width: 22px;
}
.scan-verify-opacity-slider {
  flex: 1; height: 3px;
  accent-color: var(--brand-600, #059669);
  cursor: pointer;
}
.scan-verify-opacity-val {
  font-size: 9px; font-weight: 700; color: #64748b;
  font-variant-numeric: tabular-nums;
  min-width: 30px; text-align: right;
}


/* ================================================================
   FINANCIAL JOURNAL — Balance Change Log  (jnl-* v2)
   Replaces diary-style CSS. All new classes used by the
   auto-generated change-log view in journal.js.
   ================================================================ */

/* ── Toolbar: period tabs + institution filter ────────────────── */
.jnl-toolbar {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 12px;
}
.jnl-tabs {
  display: flex; gap: 4px;
  background: var(--surface-2,#f7f8fa);
  border: 1px solid var(--hairline,#e2e8f0);
  border-radius: 10px; padding: 3px;
}
.jnl-tab {
  flex: 1; padding: 6px 8px;
  font-size: 11px; font-weight: 700;
  color: #64748b; background: transparent;
  border: none; border-radius: 7px; cursor: pointer;
  transition: background .15s, color .15s; white-space: nowrap; text-align: center;
}
.jnl-tab.active { background: #fff; color: #0f172a; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.jnl-tab:hover:not(.active) { background: #fff; color: #0f172a; }

.jnl-inst-filter {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.jnl-inst-btn {
  padding: 4px 10px;
  font-size: 10px; font-weight: 700;
  color: #64748b; background: #f1f5f9;
  border: 1px solid var(--hairline,#e2e8f0);
  border-radius: 20px; cursor: pointer;
  transition: background .12s, color .12s;
}
.jnl-inst-btn.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.jnl-inst-btn:hover:not(.active) { background: #e2e8f0; }

/* ── Summary bar ──────────────────────────────────────────────── */
.jnl-summary-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 10px;
  background: #f8fafc; border: 1px solid var(--hairline,#e2e8f0);
  border-radius: 10px;
}
.jnl-summary-val {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 18px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.jnl-summary-meta { font-size: 11px; font-weight: 500; color: #64748b; }

/* ── Date group ───────────────────────────────────────────────── */
.jnl-feed { display: flex; flex-direction: column; gap: 10px; }
.jnl-date-group {
  background: #fff; border: 1px solid var(--hairline,#e2e8f0);
  border-radius: 12px; overflow: hidden;
}
.jnl-date-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; gap: 8px;
  background: #f8fafc; border-bottom: 1px solid var(--hairline,#e2e8f0);
}
.jnl-date-label {
  font-size: 11px; font-weight: 700;
  color: #475569; text-transform: uppercase; letter-spacing: .5px;
}
.jnl-day-summary {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Change row ───────────────────────────────────────────────── */
.jnl-change-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline-soft,rgba(0,0,0,.05));
  cursor: pointer; transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.jnl-change-row:last-child { border-bottom: none; }
.jnl-change-row:hover { background: #f8fafc; }
.jnl-change-row:active { background: #f1f5f9; }

.jnl-row-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.jnl-row-logo {
  width: 36px; height: 36px; border-radius: 8px;
  object-fit: contain; flex-shrink: 0;
  background: #f8fafc; border: 1px solid var(--hairline,#e2e8f0);
  padding: 2px;
}
.jnl-row-info { flex: 1; min-width: 0; }
.jnl-row-name {
  font-size: 13px; font-weight: 700; color: #0f172a;
  word-break: break-word; overflow-wrap: break-word;
}
.jnl-row-meta {
  font-size: 10px; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: .3px; margin-top: 1px;
}
.jnl-row-balances {
  display: flex; align-items: center; gap: 5px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums; margin-top: 3px;
}
.jnl-bal-prev { color: #94a3b8; }
.jnl-arrow    { color: #cbd5e1; font-size: 10px; }
.jnl-bal-curr { color: #1e3a5f; }

.jnl-row-right { text-align: right; flex-shrink: 0; min-width: 72px; }
.jnl-delta {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.jnl-pct { font-size: 11px; font-weight: 700; margin-top: 1px; }
.jnl-row-ts { font-size: 9px; font-weight: 500; color: #94a3b8; margin-top: 3px; }

/* ── Colour helpers ───────────────────────────────────────────── */
.jnl-pos { color: #059669; }
.jnl-neg { color: #dc2626; }

/* ── Empty state ──────────────────────────────────────────────── */
.jnl-empty {
  text-align: center; padding: 40px 24px;
  background: #fff; border: 1px solid var(--hairline,#e2e8f0);
  border-radius: 12px;
}
.jnl-empty-icon { font-size: 36px; margin-bottom: 10px; }
.jnl-empty-title { font-size: 15px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.jnl-empty-text  { font-size: 13px; font-weight: 500; color: #64748b; line-height: 1.6; }

/* Mobile */
@media (max-width: 479px) {
  .jnl-tabs { gap: 2px; }
  .jnl-tab  { font-size: 10px; padding: 5px 4px; }
  .jnl-change-row { padding: 9px 12px; gap: 8px; }
  .jnl-row-logo { width: 30px; height: 30px; }
  .jnl-delta { font-size: 13px; }
}

/* ================================================================
   ROLLING PERFORMANCE WINDOWS — rw-* components
   Shown on Dashboard in the wt-section.rw-section block.
   ================================================================ */
.rw-section { margin-bottom: 12px; }

/* Period window grid */
.rw-window-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px; margin-bottom: 14px;
}
@media (max-width: 639px) {
  .rw-window-grid { grid-template-columns: repeat(3, 1fr); }
}

.rw-tile {
  background: #f8fafc;
  border: 1px solid var(--hairline,#e2e8f0);
  border-radius: 8px; padding: 10px 8px;
  text-align: center;
}
.rw-tile--pos { border-left: 3px solid #059669; }
.rw-tile--neg { border-left: 3px solid #dc2626; }
.rw-tile--na  { opacity: .55; }
.rw-tile-period {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: #94a3b8; margin-bottom: 4px;
}
.rw-tile-val {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.rw-tile-sub {
  font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.rw-muted { color: #94a3b8; }
.rw-pos   { color: #059669; }
.rw-neg   { color: #dc2626; }


/* ================================================================
   SCANNER — Opacity Slider for inline image viewer
   ================================================================ */
.scan-opacity-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0 0;
}
.scan-opacity-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: #94a3b8; white-space: nowrap; min-width: 18px;
}
.scan-opacity-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; background: #e2e8f0; border-radius: 2px; outline: none;
  cursor: pointer;
}
.scan-opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #0f172a; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.scan-opacity-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #0f172a; cursor: pointer; border: 2px solid #fff;
}
.scan-opacity-val {
  font-size: 9px; font-weight: 700; color: #64748b;
  min-width: 30px; text-align: right; font-variant-numeric: tabular-nums;
}


/* ================================================================
   OCR BALANCE CANDIDATE CHIPS — fixed size, no transform/zoom
   ================================================================ */
/* ocr-bal-chip rules consolidated in SVX block above */


/* ================================================================
   UNIFIED DASHBOARD CARD SYSTEM — dash-*
   Reference: Liquidity Breakdown tile design.
   Used by: Rolling Performance, Today's Movers, Recent Activity.
   All Overview sections share this single design vocabulary.
   ================================================================ */

/* ── 2-column responsive grid ─────────────────────────────────── */
.dash-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
@media (max-width: 359px) {
  .dash-2col { grid-template-columns: 1fr; }
}

/* ── Base card tile ─────────────────────────────────────────────
   Matches wt-liq-tile: same radius, padding, border approach      */
.dash-card {
  border-radius: var(--wt-r-sm, 8px);
  padding: 10px 12px;
  border: 1px solid var(--wt-border, #e2e8f0);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: box-shadow 0.15s;
}
.dash-card--pos { background: #ecfdf5; border-color: #a7f3d0; }
.dash-card--neg { background: #fef2f2; border-color: #fecaca; }
.dash-card--neu { background: #f8fafc; border-color: #e2e8f0; }
.dash-card--link { cursor: pointer; }
.dash-card--link:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.dash-card--link:active { opacity: 0.88; }

/* ── Shared typography — matches wt-liq-* exactly ─────────────── */
.dash-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 2px;
}
.dash-value {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.dash-sub {
  font-size: 10px;
  font-weight: 500;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}
.dash-pos { color: #059669; }
.dash-neg { color: #dc2626; }

/* ── Card with logo header (movers / account cards) ────────────── */
.dash-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.dash-logo {
  width: 28px; height: 28px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--wt-border, #e2e8f0);
  padding: 2px;
}
.dash-logo-fb {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff; font-size: 12px; font-weight: 800;
  padding: 0;
}
.dash-card-id { flex: 1; min-width: 0; }
.dash-card-name {
  font-size: 11px; font-weight: 700; color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Activity card specifics ────────────────────────────────────── */
.dash-act-icon {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.dash-act-desc {
  font-size: 11px; font-weight: 600;
  color: #0f172a; line-height: 1.4;
  word-break: break-word;
}
.dash-act-arrow {
  font-size: 16px; color: #cbd5e1;
  font-weight: 300; flex-shrink: 0;
}
.dash-empty {
  grid-column: 1 / -1;
  padding: 20px 8px;
  font-size: 12px; font-weight: 600;
  color: #94a3b8; text-align: center;
}

/* ── Section title spacing when used mid-section ───────────────── */
.wt-section .p-card-title + .dash-2col { margin-top: 8px; }


/* ================================================================
   ROI ANALYSIS — analytics.js v103
   Source of truth: Known Accounts sheet. 5 grouping tabs.
   ================================================================ */

/* Group tabs */
.roi-group-tabs {
  display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap;
}
.roi-group-tab {
  padding: 5px 13px;
  border: 1px solid #e2e8f0; border-radius: 20px;
  background: #f8fafc; color: #475569;
  font-size: 11.5px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.roi-group-tab:hover { background: #f1f5f9; color: #0f172a; }
.roi-group-tab.active { background: #0f172a; color: #fff; border-color: #0f172a; }

/* Summary grid — 4 cols mobile, 8 desktop */
.roi-sum-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}
@media (min-width: 540px)  { .roi-sum-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px)  { .roi-sum-grid { grid-template-columns: repeat(8, 1fr); } }

.roi-sum-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 9px; padding: 9px 11px;
}
.roi-sum-card--best  { border-color: #a7f3d0; background: #f0fdf4; }
.roi-sum-card--worst { border-color: #fecaca; background: #fef2f2; }
.roi-sum-lbl {
  font-size: 8.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.5px; color: #94a3b8; margin-bottom: 3px;
}
.roi-sum-val {
  font-size: 14px; font-weight: 800; color: #0f172a; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.roi-sum-val.pos { color: #059669; }
.roi-sum-val.neg { color: #dc2626; }
.roi-sum-sub { font-size: 8.5px; color: #94a3b8; margin-top: 2px; }

/* Table header row */
.roi-table-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; gap: 8px;
}
.roi-table-title {
  font-size: 11px; font-weight: 700; color: #475569;
}
.roi-export-btn {
  padding: 5px 12px; font-size: 11px; font-weight: 700; font-family: inherit;
  border: 1px solid #e2e8f0; border-radius: 6px; background: #f8fafc; color: #334155;
  cursor: pointer; white-space: nowrap; transition: background 0.1s;
}
.roi-export-btn:hover { background: #f1f5f9; border-color: #94a3b8; }

/* Table wrapper */
.roi-table-wrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid #e2e8f0; border-radius: 10px;
}

/* Table */
.roi-table {
  width: 100%; border-collapse: collapse; font-size: 11.5px; min-width: 900px;
}
.roi-table thead { position: sticky; top: 0; z-index: 2; background: #f8fafc; }
.roi-th {
  padding: 7px 9px; font-size: 8.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.4px; color: #64748b; white-space: nowrap;
  border-bottom: 2px solid #e2e8f0; user-select: none;
}
.roi-th--name { text-align: left; }
.roi-th--num  { text-align: right; }
.roi-th.sortable { cursor: pointer; }
.roi-th.sortable:hover { color: #0f172a; background: #f1f5f9; }
.roi-sa { margin-left: 2px; font-size: 9px; }
.roi-sa--off { opacity: 0.3; }

/* Body rows */
.roi-tr { border-bottom: 1px solid #f1f5f9; }
.roi-tr:last-child { border-bottom: none; }
.roi-tr:hover { background: #f8fafc; }
.roi-td {
  padding: 6px 9px; font-size: 11.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: #0f172a; vertical-align: middle;
}
.roi-td--name { text-align: left; }
.roi-td--num  { text-align: right; }
.roi-td.pos { color: #059669; }
.roi-td.neg { color: #dc2626; }
.roi-name { font-weight: 800; display: block; }
.roi-cnt  { font-size: 9px; font-weight: 600; color: #94a3b8; display: block; margin-top: 1px; }
.roi-flag { font-size: 9px; color: #f59e0b; margin-left: 2px; cursor: help; vertical-align: super; }
.roi-na   { color: #cbd5e1; font-weight: 600; }

/* Footer */
.roi-tfoot td {
  border-top: 2px solid #e2e8f0; background: #f8fafc;
  padding: 7px 9px; font-variant-numeric: tabular-nums;
}
.roi-tfoot .roi-td--name { font-size: 9px; letter-spacing: 0.5px; color: #64748b; text-align: left; }
.roi-tfoot .pos { color: #059669; }
.roi-tfoot .neg { color: #dc2626; }
