/* ==========================================================================
   J. Zhang Quant Terminal · Design Language v12 "Stage"
   Stack: Linear (OKLCH 3-var system) × Stripe (tabular numerics, tight tracking)
        × Tremor (KPI cards + sparklines + status states)
        × Koyfin (model-portfolio drift visualization)
        × FactSet (data density on light surfaces)
   Tech: OKLCH color space · View Transitions API · @property count-up
       · @starting-style entrance · CSS anchor positioning · spring easing
   ========================================================================== */

/* Fonts moved to <link> in HTML head with display=swap & preconnect (CSS @import is render-blocking) */

:root {
  /* =========================================================
     Color tokens — OKLCH color space (perceptually uniform)
     Linear-inspired 3-variable system: base, accent, contrast
     ========================================================= */

  /* ===== v15 Editorial Cream palette (The Economist × Pitch × Bloomberg Light) =====
     Warm cream paper, deep ink for body, gold accent, forest green / norwegian red. */

  /* --- Surfaces — warm cream paper hierarchy --- */
  --surface-0: oklch(96.6% 0.012 80);    /* page bg — cream/奥马哈白 #faf7f2 */
  --surface-1: oklch(100% 0 0);          /* card — pure white */
  --surface-2: oklch(94.5% 0.014 78);    /* elevated section — softer cream */
  --surface-3: oklch(91% 0.015 78);      /* hover */
  --surface-4: oklch(86% 0.018 78);      /* active */
  --surface-glass: oklch(100% 0 0 / 0.78);
  --surface-solid: oklch(100% 0 0);
  --surface-tinted: oklch(94.5% 0.014 78);

  /* --- Hairlines — slightly warm to harmonize with cream --- */
  --hairline-1: oklch(20% 0.015 60 / 0.06);
  --hairline-2: oklch(20% 0.015 60 / 0.10);
  --hairline-3: oklch(20% 0.015 60 / 0.14);
  --hairline-4: oklch(20% 0.015 60 / 0.20);

  /* --- Text — deep umber ramp (warm, not cool gray) --- */
  --text-1: oklch(18% 0.020 40);         /* primary — deep umber/brown #1a1410 */
  --text-2: oklch(25% 0.020 45);         /* body */
  --text-3: oklch(40% 0.018 50);         /* secondary */
  --text-4: oklch(52% 0.016 55);         /* tertiary */
  --text-5: oklch(62% 0.014 60);         /* muted */
  --text-6: oklch(72% 0.010 65);         /* disabled */

  /* --- Accent — deep ink blue (Economist headline ink) --- */
  --accent-tint:    oklch(94% 0.020 260);
  --accent-soft:    oklch(75% 0.08 260);
  --accent:         oklch(28% 0.10 258);  /* deep ink — #0b1c40 */
  --accent-strong:  oklch(22% 0.11 258);
  --accent-dim:     oklch(40% 0.09 258);
  --accent-glow:    oklch(28% 0.10 258 / 0.14);

  /* --- Gold — Editorial signature (哑金 muted gold #c8a76a) --- */
  --gold-tint:   oklch(94% 0.045 85);
  --gold-soft:   oklch(82% 0.080 85);
  --gold:        oklch(75% 0.105 85);   /* primary gold */
  --gold-strong: oklch(65% 0.115 80);
  --gold-deep:   oklch(50% 0.105 75);
  --gold-glow:   oklch(75% 0.105 85 / 0.18);

  /* --- Bull — deep forest green (#0f6e3a) — gravitas over Apple-green --- */
  --bull-300: oklch(60% 0.13 150);
  --bull-400: oklch(50% 0.14 148);
  --bull-500: oklch(42% 0.14 148);       /* primary forest green */
  --bull-600: oklch(34% 0.13 148);
  --bull-glow: oklch(42% 0.14 148 / 0.12);
  --bull-tint: oklch(93% 0.04 148);

  /* --- Bear — norwegian rust (#b1342a) — serious not loud --- */
  --bear-300: oklch(58% 0.17 30);
  --bear-400: oklch(50% 0.18 28);
  --bear-500: oklch(45% 0.18 28);        /* rust red */
  --bear-600: oklch(38% 0.18 28);
  --bear-glow: oklch(50% 0.18 28 / 0.12);
  --bear-tint: oklch(93% 0.04 28);

  /* --- Amber (gold variation — used very sparingly) --- */
  --amber-400: var(--gold);
  --amber-500: var(--gold-strong);
  --amber-glow: var(--gold-glow);
  --amber-tint: var(--gold-tint);

  /* --- Tertiary accents (chart palette only) --- */
  --violet-400: oklch(48% 0.13 295);
  --violet-glow: oklch(48% 0.13 295 / 0.10);
  --cyan-400:   oklch(55% 0.11 220);
  --cyan-glow:  oklch(55% 0.11 220 / 0.10);

  /* Aliases */
  --bull: var(--bull-400);
  --bear: var(--bear-400);
  --amber: var(--amber-400);
  --violet: var(--violet-400);
  --cyan: var(--cyan-400);

  /* =========================================================
     Typography
     Stripe: Inter weight 300 + ss01 + letter-spacing -1.4px (display)
     ========================================================= */
  --font-display: 'Inter var', 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  --font-sans: 'Inter var', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'SF Mono', ui-monospace, monospace;
  /* Editorial serif for hero numbers & headlines — Pitch/Klarna/Lazy/Cron pattern.
     Fraunces with opsz + wght axes only (SOFT dropped to save ~80KB). */
  --font-editorial: 'Fraunces', 'GT Super', 'Tiempos Headline', Georgia, 'Times New Roman', serif;

  /* Type scale (Stripe-inspired) */
  --type-xs: 11px;       /* 10.83 actually */
  --type-sm: 12px;       /* meta */
  --type-base: 13px;     /* body */
  --type-md: 14px;       /* card body */
  --type-lg: 15px;
  --type-xl: 18px;       /* h3 */
  --type-2xl: 22px;      /* h2 */
  --type-3xl: 28px;      /* h1 */
  --type-4xl: 36px;      /* big number */
  --type-5xl: 48px;      /* hero */
  --type-6xl: 64px;      /* mega */

  --tracking-tight: -0.022em;     /* Stripe display */
  --tracking-snug: -0.014em;
  --tracking-normal: -0.005em;
  --tracking-wide: 0.01em;
  --tracking-wider: 0.04em;
  --tracking-widest: 0.08em;       /* uppercase labels */

  --leading-none: 1.0;
  --leading-tight: 1.18;
  --leading-snug: 1.32;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* =========================================================
     Spacing scale (Stripe: 2/4/6/8/10/12/14/16/18/20/22/24)
     Strict 4px grid for everything else
     ========================================================= */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-32: 128px;

  /* =========================================================
     Radii
     ========================================================= */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-2xl: 20px;
  --radius-3xl: 28px;
  --radius-full: 9999px;

  /* =========================================================
     Elevation — soft shadows (very subtle on light bg)
     ========================================================= */
  --elevation-0: none;
  --elevation-1: 0 1px 2px rgba(0,0,0,0.04);
  --elevation-2: 0 2px 6px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.04);
  --elevation-3: 0 8px 24px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --elevation-4: 0 16px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  --elevation-5: 0 24px 60px rgba(0,0,0,0.10), 0 8px 20px rgba(0,0,0,0.06);

  --glow-accent: 0 0 0 4px var(--accent-glow);
  --glow-bull: 0 0 0 4px var(--bull-glow);
  --glow-bear: 0 0 0 4px var(--bear-glow);

  /* =========================================================
     Easing & timing (spring-like)
     ========================================================= */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.75, 0);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-emphasized: cubic-bezier(0.16, 1, 0.3, 1);

  --duration-instant: 80ms;
  --duration-fast: 160ms;
  --duration-base: 240ms;
  --duration-slow: 360ms;
  --duration-slower: 520ms;

  /* =========================================================
     Layout
     ========================================================= */
  --layout-status: 28px;
  --layout-top: 60px;
  --layout-tabs: 52px;
  --layout-timeline: 48px;
  --layout-sidebar: 200px;
  --layout-content-max: 1600px;
}

/* Light-first design — no dark mode override */

/* ==========================================================================
   Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
  font-feature-settings: 'ss01', 'cv02', 'cv03', 'cv04', 'cv11';
  font-variation-settings: 'opsz' 14;
}

body {
  font-family: var(--font-sans);
  font-weight: 400;
  background: var(--surface-0);
  color: var(--text-2);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-normal);
  overflow-x: hidden;
  font-synthesis: none;
}

/* Clean white base — no gradient mesh, no noise textures */
body::before, body::after { display: none; }

/* Text helpers — solid colors for numbers, gradients hurt scan-ability */
.text-gradient,
.text-gradient-bull,
.text-gradient-bear,
.text-gradient-amber {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  -webkit-text-fill-color: currentColor;
}
.text-gradient { color: var(--text-1); }
.text-gradient-bull { color: var(--bull-500); }
.text-gradient-bear { color: var(--bear-500); }
.text-gradient-amber { color: var(--amber-500); }

/* Hide old animation rules (kept here for css validity) */
.legacy-hidden {
  background: linear-gradient(135deg, oklch(80% 0.18 75) 0%, oklch(75% 0.20 55) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--accent-strong); }

button {
  font: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  -webkit-appearance: none;
}

input, select, textarea {
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border-radius: var(--radius-full);
  border: 2px solid var(--surface-0);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-6); }

::selection {
  background: var(--accent-glow);
  color: var(--text-1);
}

/* ==========================================================================
   Typography utilities
   ========================================================================== */
.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums slashed-zero; font-feature-settings: 'tnum', 'zero'; }
.tabular { font-variant-numeric: tabular-nums; }

.num, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums slashed-zero;
  letter-spacing: var(--tracking-snug);
  font-feature-settings: 'tnum', 'zero';
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: var(--tracking-tight);
  font-weight: 600;
  color: var(--text-1);
  line-height: var(--leading-tight);
}

/* ==========================================================================
   Layout
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--layout-sidebar) 1fr;
  grid-template-rows: var(--layout-status) var(--layout-top) var(--layout-tabs) var(--layout-timeline) 1fr;
  grid-template-areas:
    "status status"
    "topbar topbar"
    "tabs   tabs"
    "timeline timeline"
    "sidebar main";
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Status bar — minimal top chrome (Linear-dim hierarchy)
   ========================================================================== */
.status-bar {
  grid-area: status;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline-1);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  gap: var(--space-4);
  font-size: var(--type-xs);
  color: var(--text-5);
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  font-weight: 500;
  /* Make status sticky to viewport top — prevents the 28px "leak" gap that appeared
     when the page scrolled and status went off-screen while topbar (sticky at top:28) stayed. */
  position: sticky;
  top: 0;
  z-index: 51;
  height: var(--layout-status);
}
.status-item { display: flex; align-items: center; gap: var(--space-2); }
.status-item .lbl { color: var(--text-5); }
.status-item .val { color: var(--text-2); letter-spacing: var(--tracking-snug); text-transform: none; }
.status-bar .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bull);
  animation: pulseRing 2s var(--ease-out) infinite;
}
.status-bar .pulse.off { background: var(--text-6); box-shadow: none; animation: none; }
.status-spacer { flex: 1; }

@keyframes pulseRing {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.7); opacity: 0.4; }
}

/* ==========================================================================
   Top bar — frosted-glass backdrop, sticky on scroll
   ========================================================================== */
.topbar {
  grid-area: topbar;
  background: var(--surface-0);
  border-bottom: 1px solid var(--hairline-1);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-5);
  position: sticky;
  top: var(--layout-status);
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 600;
  color: var(--text-1);
  font-size: var(--type-md);
  letter-spacing: var(--tracking-snug);
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--text-1);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: var(--type-sm);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.06),
    inset 0 1px 0 oklch(100% 0 0 / 0.3);
  letter-spacing: var(--tracking-tight);
  position: relative;
}
.brand-mark::after { display: none; }
.brand-sub {
  color: var(--text-4);
  font-size: var(--type-xs);
  font-weight: 400;
  padding-left: var(--space-4);
  border-left: 1px solid var(--hairline-2);
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
}

.search-trigger {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  height: 34px;
  flex: 1;
  max-width: 480px;
  margin-left: var(--space-5);
  gap: var(--space-3);
  color: var(--text-4);
  font-size: var(--type-base);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.search-trigger:hover {
  background: var(--surface-3);
  border-color: var(--hairline-3);
  color: var(--text-2);
}
.search-trigger:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-trigger svg { width: 14px; height: 14px; }
.search-trigger .placeholder { flex: 1; }
.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--surface-3);
  border: 1px solid var(--hairline-3);
  color: var(--text-3);
  border-radius: var(--radius-xs);
  padding: 3px 7px;
  font-weight: 500;
  letter-spacing: 0;
}

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 2px; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text-1);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.has-dot::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bear);
  box-shadow: 0 0 6px var(--bear-glow);
  animation: pulseRing 2s infinite;
}

/* Ticker removed — was causing sticky-stack "leak" between topbar and tabs.
   ETF live prices are not core to portfolio comparison story. */
.ticker, .ticker-track, .ticker-item, .ticker-label { display: none !important; }

/* ==========================================================================
   Portfolio Tabs — minimal typography tabs (NOT card-grid).
   Active = bottom 2px accent underline. No per-cell borders. Quiet by design.
   ========================================================================== */
.portfolio-tabs {
  grid-area: tabs;
  background: var(--surface-0);
  border-bottom: 1px solid var(--hairline-1);
  display: flex;
  align-items: stretch;
  position: sticky;
  top: calc(var(--layout-status) + var(--layout-top));
  z-index: 30;
  height: var(--layout-tabs);
  padding: 0 24px;
  gap: 4px;
}
.pt-cell {
  position: relative;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: color 160ms ease-out;
  outline: none;
  min-width: 0;
  color: var(--text-4);
  border: none;
}
.pt-cell:hover { color: var(--text-2); }
.pt-cell:focus-visible { outline: 2px solid var(--accent-glow); outline-offset: -2px; border-radius: 4px; }

.pt-cell-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}
.pt-pid {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-5);
  flex-shrink: 0;
}
.pt-name {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Score as small inline mono suffix, low-key */
.pt-body { display: inline-flex; align-items: baseline; gap: 0; }
.pt-score {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-5);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}
.pt-score-suffix { display: none; }
/* Risk dots hidden in compact tabs — exposed in watchlist below where they belong */
.pt-risk { display: none; }

/* Active: bold name in primary text, bottom accent underline */
.pt-cell.active { color: var(--text-1); }
.pt-cell.active .pt-name { color: var(--text-1); font-weight: 600; }
.pt-cell.active .pt-pid { color: var(--accent); }
.pt-cell.active .pt-score { color: var(--text-2); }
.pt-cell.active::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* Tooltip on hover — quiet, below tab */
.pt-cell-tip {
  display: none;
  position: absolute;
  top: 100%;
  left: 14px;
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--text-1);
  color: white;
  font-size: 11px;
  line-height: 1.45;
  border-radius: 6px;
  box-shadow: 0 4px 16px oklch(20% 0.015 60 / 0.18);
  z-index: 100;
  pointer-events: none;
  letter-spacing: var(--tracking-snug);
  max-width: 340px;
  white-space: normal;
}
.pt-cell:hover .pt-cell-tip { display: block; }

/* ==========================================================================
   Sidebar — section nav (Linear dim hierarchy lets main content lead)
   ========================================================================== */
.sidebar {
  grid-area: sidebar;
  background: var(--surface-2);
  border-right: 1px solid var(--hairline-2);
  padding: var(--space-3) var(--space-2);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: sticky;
  top: calc(var(--layout-status) + var(--layout-top) + var(--layout-tabs) + var(--layout-timeline));
  height: calc(100vh - var(--layout-status) - var(--layout-top) - var(--layout-tabs) - var(--layout-timeline));
}

/* ==========================================================================
   TIME MACHINE — 16Y replay slider (sticky under portfolio tabs)
   ========================================================================== */
.timeline {
  grid-area: timeline;
  background: var(--surface-0);
  border-bottom: 1px solid var(--hairline-2);
  position: sticky;
  top: calc(var(--layout-status) + var(--layout-top) + var(--layout-tabs));
  z-index: 29;
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  gap: 20px;
  padding: 6px 24px;
  height: var(--layout-timeline);
}
.timeline-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.timeline-date {
  font-family: var(--font-editorial);
  font-variation-settings: 'opsz' 36, 'wght' 500;
  font-size: 15px;
  color: var(--text-1);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.timeline-stat {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-5);
  letter-spacing: 0.02em;
}
.timeline-stat .delta-bull { color: var(--bull-500); font-weight: 600; }
.timeline-stat .delta-bear { color: var(--bear-500); font-weight: 600; }
.timeline-slider-wrap {
  position: relative;
  width: 100%;
  height: 36px;
}
.timeline-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  padding: 0 6px;
}
.timeline-mark {
  position: absolute;
  top: 4px;
  width: 1px;
  height: 6px;
  background: var(--hairline-3);
  transform: translateX(-50%);
}
.timeline-mark-label {
  position: absolute;
  top: 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-5);
  letter-spacing: 0.04em;
  transform: translateX(-50%);
  white-space: nowrap;
}
.timeline-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 36px;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
  z-index: 2;
}
.timeline-slider::-webkit-slider-runnable-track {
  height: 4px;
  margin-top: 16px;
  background: linear-gradient(90deg,
    var(--gold) 0%,
    var(--gold) var(--ts-pct, 100%),
    var(--hairline-3) var(--ts-pct, 100%),
    var(--hairline-3) 100%);
  border-radius: 2px;
}
.timeline-slider::-moz-range-track {
  height: 4px;
  margin-top: 16px;
  background: linear-gradient(90deg,
    var(--gold) 0%, var(--gold) var(--ts-pct, 100%),
    var(--hairline-3) var(--ts-pct, 100%), var(--hairline-3) 100%);
  border-radius: 2px;
}
.timeline-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--gold-strong);
  box-shadow: 0 1px 3px oklch(50% 0.105 75 / 0.30), 0 0 0 4px var(--gold-glow);
  cursor: ew-resize;
  margin-top: -8px;
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.timeline-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--gold-strong);
  box-shadow: 0 1px 3px oklch(50% 0.105 75 / 0.30);
  cursor: ew-resize;
}
.timeline-slider:hover::-webkit-slider-thumb,
.timeline-slider:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

/* ==========================================================================
   Mobile bottom tab bar (only on phone) — hidden by default
   ========================================================================== */
.mobile-bottom-tabs { display: none; }

/* ==========================================================================
   Mobile-only: portfolio chip + bottom nav + bottom sheet
   Hidden on desktop, surfaced via @media below.
   ========================================================================== */
.mobile-pf-chip,
.mobile-bottom-nav,
.mobile-sheet,
.mobile-sheet-backdrop { display: none; }

/* Portfolio chip — sits in topbar on mobile */
.mobile-pf-chip {
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 160ms;
  -webkit-tap-highlight-color: transparent;
}
.mobile-pf-chip:active { background: var(--surface-3); }
.mobile-pf-chip svg { width: 14px; height: 14px; opacity: 0.6; }
.mobile-pf-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bull-500);
  flex-shrink: 0;
}
.mobile-pf-chip.dot-cyan .mobile-pf-chip-dot { background: var(--cyan-400); }
.mobile-pf-chip.dot-violet .mobile-pf-chip-dot { background: var(--violet-400); }
.mobile-pf-chip.dot-amber .mobile-pf-chip-dot { background: var(--amber-400); }
.mobile-pf-chip.dot-bear .mobile-pf-chip-dot { background: var(--bear-400); }
.mobile-pf-chip.dot-bull .mobile-pf-chip-dot { background: var(--bull-500); }

/* Bottom nav bar — iOS-style 5 tab pattern */
.mobile-bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: color-mix(in oklch, var(--surface-1) 95%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--hairline-2);
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  align-items: stretch;
  justify-content: space-around;
}
.mbn-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0 8px;
  background: none;
  border: none;
  color: var(--text-5);
  font-size: 10px;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 120ms;
}
.mbn-btn svg { width: 20px; height: 20px; }
.mbn-btn:active { color: var(--text-2); }
.mbn-btn.active { color: var(--accent); font-weight: 600; }
.mbn-btn.active svg { stroke-width: 2.4; }

/* Bottom sheet — slides up from bottom on portfolio chip tap or "更多" tap */
.mobile-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(15% 0.015 60 / 0.45);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
.mobile-sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.mobile-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 101;
  background: var(--surface-1);
  border-radius: 18px 18px 0 0;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 360ms cubic-bezier(0.34, 1.32, 0.64, 1);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 32px oklch(15% 0.015 60 / 0.20);
}
.mobile-sheet.open { transform: translateY(0); }
.mobile-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--hairline-3);
  border-radius: 2px;
  margin: 8px auto 4px;
  flex-shrink: 0;
}
.mobile-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hairline-1);
  flex-shrink: 0;
}
.mobile-sheet-head h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0;
  font-family: var(--font-editorial);
  font-variation-settings: 'opsz' 24, 'wght' 500;
}
.mobile-sheet-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  border: none;
  display: grid;
  place-items: center;
  color: var(--text-3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-sheet-close svg { width: 16px; height: 16px; }
.mobile-sheet-body {
  padding: 12px 16px 32px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ms-pf-item {
  display: grid;
  grid-template-columns: 8px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 160ms;
}
.ms-pf-item:active { background: var(--surface-2); }
.ms-pf-item.active { background: color-mix(in oklch, var(--surface-2) 60%, var(--accent-tint) 40%); }
.ms-pf-item .dot { width: 8px; height: 8px; border-radius: 50%; }
.ms-pf-item .meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ms-pf-item .name { font-size: 15px; font-weight: 600; color: var(--text-1); }
.ms-pf-item .sub { font-size: 11px; color: var(--text-5); }
.ms-pf-item .score { font-family: var(--font-mono); font-size: 14px; color: var(--text-2); font-weight: 600; }
.ms-pf-item .risk-meter-seg { width: 8px; height: 4px; }

/* "更多" menu uses simpler list */
.ms-link-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-radius: 12px;
  color: var(--text-1);
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ms-link-item:active { background: var(--surface-2); }
.ms-link-item svg { width: 20px; height: 20px; color: var(--text-4); flex-shrink: 0; }
.ms-link-item.active { color: var(--accent); }
.ms-link-item.active svg { color: var(--accent); }

/* ==========================================================================
   Mobile / Tablet — full responsive overhaul (PWA-grade)
   3 breakpoints: ≤520 phone, ≤960 tablet, > desktop
   ========================================================================== */
@media (max-width: 960px) {
  /* Lock horizontal on tablet too */
  html, body { overflow-x: hidden; max-width: 100vw; }
  .app, .main { max-width: 100vw; overflow-x: hidden; }

  :root {
    --layout-sidebar: 0px;
    --layout-tabs: 76px;
    --layout-timeline: 50px;
  }
  .sidebar { display: none !important; }
  .bottom-bar { display: none; }
  .main { padding: 20px 16px 80px; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--layout-status) var(--layout-top) var(--layout-tabs) var(--layout-timeline) 1fr;
    grid-template-areas:
      "status"
      "topbar"
      "tabs"
      "timeline"
      "main";
  }
  .timeline { top: calc(var(--layout-status) + var(--layout-top) + var(--layout-tabs)); }

  /* Hero compresses */
  .kpi-stage {
    grid-template-columns: 1fr;
    padding: 24px 20px 20px;
    gap: 20px;
  }
  .kpi-stage-grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
  .kpi-stage-name { font-size: 28px; }
  .kpi-stage .metric-display:first-child .metric-value { font-size: 52px; }
  .metric-value { font-size: 28px; }

  /* Charts shrink */
  .chart, .chart-lg, .chart-2xl, .chart-xl {
    min-height: 240px;
  }

  /* Section heads tighter */
  .page-title-wrap h1 { font-size: 28px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  /* Watchlist 2-col on tablet */
  .watchlist-grid { grid-template-columns: repeat(2, 1fr); }

  /* Risk bento 2-col */
  .risk-bento { grid-template-columns: repeat(2, 1fr); }

  /* Tables: horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dt { min-width: 700px; }

  /* Insight strip stacks */
  .insight-strip { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  /* ==============  PHONE — XUEQIU PATTERN  ============== */
  /* Lock horizontal scrolling — phone is vertical-only */
  html, body { overflow-x: hidden; max-width: 100vw; }
  .app, .main, .topbar, .timeline, .mobile-bottom-nav { max-width: 100vw; overflow-x: hidden; }
  /* Tables that needed horizontal scroll on desktop — let them scroll within their own wrapper, not page */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

  :root {
    --layout-status: 0px;     /* status bar hidden on phone */
    --layout-top: 52px;       /* compact topbar */
    --layout-tabs: 0px;       /* desktop tabs hidden; nav lives in bottom bar */
    --layout-timeline: 44px;  /* slim timeline */
    --layout-sidebar: 0px;
  }
  .status-bar { display: none; }
  .sidebar { display: none !important; }
  .portfolio-tabs { display: none !important; }
  .bottom-bar { display: none; }
  .ticker, .ticker-track, .ticker-item, .ticker-label { display: none !important; }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--layout-top) var(--layout-timeline) 1fr;
    grid-template-areas:
      "topbar"
      "timeline"
      "main";
  }
  .topbar {
    grid-area: topbar;
    padding: 0 12px;
    gap: 8px;
    height: var(--layout-top);
    top: 0;
  }
  /* On phone we drop full company name — keep only brand mark */
  .brand { gap: 0; flex-shrink: 0; }
  .brand-mark { width: 32px; height: 32px; font-size: 11px; }
  .brand > div:nth-child(2) { display: none; }
  .brand-sub { display: none; }

  /* Topbar layout: brand | pf-chip | search-icon | settings */
  .search-trigger {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    flex: 0 0 auto;
    margin: 0;
    justify-content: center;
  }
  .search-trigger .placeholder, .search-trigger kbd { display: none; }
  .topbar-spacer { display: none; }
  .topbar-actions .icon-btn:nth-child(2) { display: none; }  /* hide bell */

  /* Portfolio chip — replaces desktop tabs */
  .mobile-pf-chip {
    display: inline-flex;
    flex: 1;
    max-width: 200px;
    justify-content: space-between;
  }
  .mobile-pf-chip-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
  }

  /* Timeline shrinks to one row */
  .timeline {
    grid-template-columns: 1fr;
    padding: 6px 14px;
    gap: 4px;
    height: var(--layout-timeline);
    top: var(--layout-top);
    z-index: 49;       /* below topbar so the portfolio-chip dropdown can overlap if needed */
  }
  .timeline-meta { flex-direction: row; align-items: center; gap: 10px; min-width: 0; flex-shrink: 0; }
  .timeline-meta .eyebrow { display: none; }   /* save space */
  .timeline-date { font-size: 12px; flex-shrink: 0; }
  .timeline-stat { display: none; }
  .timeline-slider-wrap { height: 24px; flex: 1; }
  .timeline-mark-label { display: none; }      /* too cramped to read on phone */
  .timeline-mark { opacity: 0.5; }

  /* Main content + safe-area bottom (for bottom nav) */
  .main {
    padding: 18px 14px calc(76px + env(safe-area-inset-bottom));
  }

  /* Hero compact */
  .kpi-stage {
    grid-template-columns: 1fr;
    padding: 18px 16px 14px;
    gap: 14px;
  }
  .kpi-stage-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .kpi-stage-name { font-size: 24px; line-height: 1.1; }
  .kpi-stage .metric-display:first-child .metric-value { font-size: 40px; }
  .metric-value { font-size: 22px; }
  .metric-label { font-size: 10px; }

  /* Watchlist single col */
  .watchlist-grid { grid-template-columns: 1fr; gap: 10px; }
  .watchlist-card { padding: 16px; }
  .risk-bento { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .risk-bento-cell { padding: 14px 14px; }
  .risk-bento-value { font-size: 22px; }

  /* Insight strip stacks */
  .insight-strip { grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px; }

  /* Rank strip: 2-col, ensure not cut off by bottom nav */
  .rank-strip { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
  .rank-cell { padding: 12px 14px; min-width: 0; }
  .rank-cell::after { display: none; }    /* hide #1 trophy on phone (cramped) */
  .rank-value { font-size: 20px; }
  .rank-meta { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Section heads + page header */
  .page-title-wrap h1 { font-size: 26px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 20px; padding-bottom: 14px; }
  /* Hide redundant page actions on phone — keyboard/palette/report buttons live in
     "更多" sheet via bottom nav. */
  .page-actions { display: none !important; }

  /* Hero name — break the long Chinese-English mix so it always fits the viewport */
  .kpi-stage-name {
    font-size: 22px !important;
    line-height: 1.18 !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    max-width: 100%;
  }
  /* Synth tag inline doesn't fight for space */
  .kpi-stage-meta .synth-tag, .kpi-stage-meta .parity-tag { margin-left: 4px; vertical-align: middle; }
  /* Page header h1 (e.g. portfolio detail title) — same wrap rule + ensure containers don't clip */
  .page-title-wrap { min-width: 0; width: 100%; padding-right: 4px; box-sizing: border-box; }
  .page-title-wrap h1 {
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    font-size: 22px !important;
    line-height: 1.2 !important;
  }
  .page-header { width: 100%; min-width: 0; }
  .page-subtitle { word-break: break-word; overflow-wrap: anywhere; }

  /* Multi-stat horizontal strips (compare page 6-cell P0-P5 row) — switch to scroll-snap
     to preserve readability while keeping all 6 visible via horizontal swipe */
  .grid.grid-12.mb-6.stagger,
  .grid.grid-6.mb-6.stagger,
  .grid.grid-5.stagger.mb-6,
  #hard-rules-grid {
    display: flex !important;
    grid-template-columns: none !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 10px !important;
    padding-bottom: 8px;
  }
  .grid.grid-12.mb-6.stagger > .stat,
  .grid.grid-6.mb-6.stagger > .stat,
  .grid.grid-5.stagger.mb-6 > .stat,
  #hard-rules-grid > .stat {
    flex: 0 0 auto !important;
    width: 130px !important;
    min-width: 130px;
    scroll-snap-align: start;
    padding: 12px 14px !important;
    box-sizing: border-box;
  }
  .grid.grid-12.mb-6.stagger .stat-value,
  .grid.grid-6.mb-6.stagger .stat-value,
  .grid.grid-5.stagger.mb-6 .stat-value,
  #hard-rules-grid .stat-value {
    font-size: 18px !important;
    white-space: nowrap;
  }
  .grid.grid-12.mb-6.stagger .stat-label,
  .grid.grid-6.mb-6.stagger .stat-label,
  .grid.grid-5.stagger.mb-6 .stat-label,
  #hard-rules-grid .stat-label {
    font-size: 9px !important;
    white-space: nowrap;
  }
  .grid.grid-12.mb-6.stagger .stat-sub,
  .grid.grid-6.mb-6.stagger .stat-sub,
  .grid.grid-5.stagger.mb-6 .stat-sub,
  #hard-rules-grid .stat-sub {
    font-size: 10px !important;
    white-space: nowrap;
  }

  /* Deploy page holding table — kill vertical-per-character wrap by allowing full row width */
  .dt td { white-space: normal !important; }
  .dt td:first-child { white-space: nowrap !important; }
  /* ETF name column: word-break and allow soft wrap */
  .dt td:nth-child(2) {
    min-width: 96px;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  /* Tables: contained horizontal scroll INSIDE wrapper only (not page-wide) */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid var(--hairline-2);
    max-width: 100%;
    box-sizing: border-box;
  }
  .dt { min-width: 580px; font-size: 11px; }
  .dt th, .dt td { padding: 8px 10px; }

  /* Card-narrative + card-targets stack */
  .grid-12 .col-7, .grid-12 .col-5,
  .grid-12 .col-4, .grid-12 .col-6, .grid-12 .col-8 { grid-column: span 12; }
  .card { padding: 16px; }
  .card-narrative, .card-targets { padding: 18px 18px; }
  .card-narrative-head h3 { font-size: 17px; }
  .card-narrative-body { font-size: 13px; }

  /* Force all grid layouts to stack on phone — avoids cramped multi-col with big numbers */
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 {
    grid-template-columns: 1fr !important;
  }
  /* Force rank-strip 2-col on phone (its own selector, not .grid-X) */
  .rank-strip { grid-template-columns: 1fr 1fr !important; }
  /* CAGR/MDD/Sharpe trios inside cards: keep 3-col but allow shrink */
  .stat .grid-3, .card .grid-3, .card .grid-4 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  /* Compare-page stat strip (6 portfolios in row) → horizontal scroll to avoid cramped 6-col */
  #hard-rules-grid, .grid-5.stagger.mb-6 {
    grid-template-columns: repeat(6, minmax(140px, 1fr)) !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
  }
  #hard-rules-grid > *, .grid-5.stagger.mb-6 > * {
    scroll-snap-align: start;
    min-width: 140px;
  }
  /* Big mono numbers inside grids — shrink to prevent overlap */
  .card .text-2xl,
  .card .text-3xl,
  .stat-value {
    font-size: 18px !important;
    letter-spacing: -0.015em;
  }
  .card .text-2xl .text-sm { font-size: 10px !important; }
  .stat .grid-3 > div, .card .grid-3 > div { min-width: 0; overflow: hidden; }

  /* In-line nowrap for big number+unit pairs (prevent the % wrapping under the digits) */
  .card .text-2xl, .card .text-3xl { white-space: nowrap; }

  /* Card heads with long titles wrap nicely */
  .card-head { flex-wrap: wrap; gap: 6px; }
  .card-title { font-size: 12px; }
  .card-sub { font-size: 10px; }

  /* Charts compress + constrain to card width (ECharts can otherwise overflow) */
  .chart, .chart-lg, .chart-2xl, .chart-xl { min-height: 220px; max-width: 100%; overflow: hidden; width: 100% !important; }
  .chart-sm { min-height: 180px; }
  /* Force every ECharts-managed inner div/canvas to clip at parent width */
  .chart, .chart > div, .chart > div > div, .chart > canvas {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Card body — ensure ECharts inside cards doesn't overflow horizontally */
  .card { overflow: hidden; min-width: 0; }
  .card > * { min-width: 0; }
  /* But report modal must still scroll */
  .report-modal { overflow: visible; }
  .report-modal-body { overflow-y: auto; }

  /* Target rows compress */
  .target-row { grid-template-columns: 60px 1fr 64px 70px; gap: 10px; font-size: 11px; }

  /* Show mobile-only elements */
  .mobile-bottom-nav { display: flex; }

  /* Subtle: when sheet open, prevent body scroll */
  body.sheet-open { overflow: hidden; }
}

/* Larger phones / small tablets: 521-720px — also show bottom nav */
@media (min-width: 521px) and (max-width: 720px) {
  .mobile-bottom-nav { display: flex; }
  .main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .mobile-pf-chip { display: none; }     /* on tablet show tabs */
}

/* Safe-area inset for iPhone with notch (PWA mode) */
@supports (padding: env(safe-area-inset-top)) {
  @media (display-mode: standalone), (max-width: 520px) {
    .topbar {
      padding-top: env(safe-area-inset-top);
      height: calc(var(--layout-top) + env(safe-area-inset-top));
    }
    .main {
      padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
  }
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-5);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  font-family: var(--font-mono);
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: var(--type-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  height: 36px;
  margin: 1px var(--space-2);
  gap: var(--space-3);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}
.nav-item .nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item:hover {
  background: var(--surface-3);
  color: var(--text-1);
}
.nav-item.active {
  background: var(--surface-1);
  color: var(--accent);
  box-shadow: var(--elevation-1);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover svg, .nav-item.active svg { opacity: 1; }

/* Keyboard shortcut hint shown on right side of nav-item */
.nav-item[data-tip]::after {
  content: attr(data-tip);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-5);
  opacity: 0;
  transition: opacity var(--duration-fast);
  letter-spacing: 0;
}
.nav-item:hover[data-tip]::after { opacity: 1; }
@keyframes tooltipIn {
  from { opacity: 0; transform: translate(-6px, -50%); }
  to { opacity: 1; transform: translate(0, -50%); }
}

.sidebar-divider {
  height: 1px;
  background: var(--hairline-2);
  margin: var(--space-2) var(--space-3);
}

/* ==========================================================================
   Main content
   ========================================================================== */
.main {
  grid-area: main;
  background: var(--surface-0);
  overflow-y: auto;
  padding: var(--space-8) var(--space-10);
  position: relative;
  scroll-behavior: smooth;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--hairline-2);
  gap: var(--space-6);
}
.page-title-wrap h1 {
  font-size: var(--type-4xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  font-feature-settings: 'ss01';
  color: var(--text-1);
}
.page-subtitle {
  font-size: var(--type-md);
  color: var(--text-4);
  margin-top: var(--space-2);
  letter-spacing: var(--tracking-snug);
  line-height: var(--leading-normal);
}

.page-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 32px;
  border-radius: var(--radius-md);
  font-size: var(--type-sm);
  font-weight: 500;
  border: 1px solid var(--hairline-3);
  background: var(--surface-2);
  color: var(--text-2);
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  letter-spacing: var(--tracking-snug);
}
.btn:hover {
  background: var(--surface-3);
  color: var(--text-1);
  border-color: var(--hairline-4);
  transform: translateY(-1px);
  box-shadow: var(--elevation-2);
}
.btn:active {
  transform: translateY(0);
  box-shadow: var(--elevation-1);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--hairline-2); }
.btn-bull { background: var(--bull); border-color: var(--bull); color: white; }
.btn-bull:hover { background: var(--bull-500); border-color: var(--bull-500); color: white; }
.btn-bear { background: var(--bear); border-color: var(--bear); color: white; }
.btn-bear:hover { background: var(--bear-500); border-color: var(--bear-500); color: white; }
.btn-lg { height: 38px; padding: 0 var(--space-5); font-size: var(--type-md); }
.btn-sm { height: 26px; padding: 0 var(--space-3); font-size: var(--type-xs); }
.btn-icon { width: 32px; padding: 0; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ==========================================================================
   Cards — white surface + hairline border + soft shadow
   ========================================================================== */
.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  position: relative;
  transition: all var(--duration-base) var(--ease-out);
  overflow: hidden;
  min-width: 0;
  box-shadow: var(--elevation-1);
}
.card::before, .card::after { display: none; }

.card-hover { cursor: pointer; }
.card-hover:hover {
  border-color: var(--hairline-3);
  transform: translateY(-2px);
  box-shadow: var(--elevation-3);
}
.card-glow:hover {
  border-color: var(--accent);
  box-shadow: var(--elevation-3), var(--glow-accent);
}
.card-elevated {
  background: var(--surface-1);
  box-shadow: var(--elevation-3);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-xs);
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
}
.card-title svg { width: 14px; height: 14px; color: var(--text-4); }
.card-sub {
  font-size: var(--type-xs);
  color: var(--text-5);
  font-weight: 400;
  letter-spacing: var(--tracking-snug);
}

/* ==========================================================================
   KPI Stat — legacy white card with top accent bar
   ========================================================================== */
.stat {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  position: relative;
  transition: all var(--duration-base) var(--ease-out);
  overflow: hidden;
  min-width: 0;
  box-shadow: var(--elevation-1);
}
.stat::before, .stat::after { display: none; }
.stat-top-glow::before { display: none; }

.stat:hover {
  border-color: var(--hairline-3);
  transform: translateY(-2px);
  box-shadow: var(--elevation-3);
}

.stat.accent { border-top: 2px solid var(--accent); }
.stat.bull { border-top: 2px solid var(--bull); }
.stat.bear { border-top: 2px solid var(--bear); }
.stat.amber { border-top: 2px solid var(--amber); }

.stat-label {
  font-size: 10px;
  color: var(--text-5);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-family: var(--font-mono);
}
.stat-label svg { width: 12px; height: 12px; opacity: 0.7; }

.stat-value {
  font-family: var(--font-display);
  font-size: var(--type-4xl);
  font-weight: 600;
  color: var(--text-1);
  margin-top: var(--space-3);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-none);
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  font-variant-numeric: tabular-nums slashed-zero;
}
/* Solid color numbers — gradients on numbers hurt scan-ability */
.stat-value.gradient { color: var(--text-1); }
.stat-value.gradient-bull { color: var(--bull-500); }
.stat-value.gradient-bear { color: var(--bear-500); }
.stat-value.gradient-amber { color: var(--amber-500); }
.legacy-hidden2 {
  background: linear-gradient(135deg, oklch(82% 0.18 152) 0%, oklch(76% 0.20 142) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-value.gradient-bear {
  background: linear-gradient(135deg, oklch(75% 0.20 18) 0%, oklch(70% 0.22 8) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-value.gradient-amber {
  background: linear-gradient(135deg, oklch(82% 0.18 75) 0%, oklch(75% 0.20 55) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-value .unit {
  font-size: var(--type-md);
  font-weight: 400;
  color: var(--text-4);
  letter-spacing: 0;
}
.stat-value.md { font-size: 28px; }
.stat-value.sm { font-size: 22px; }

.stat-sub {
  font-size: var(--type-xs);
  color: var(--text-5);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  letter-spacing: var(--tracking-snug);
}
.stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  letter-spacing: var(--tracking-snug);
}
.stat-delta.up { color: var(--bull); background: var(--bull-glow); }
.stat-delta.down { color: var(--bear); background: var(--bear-glow); }

/* ==========================================================================
   Grid (with min-width:0 to prevent overflow)
   ========================================================================== */
.grid { display: grid; gap: var(--space-4); }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-12 { grid-template-columns: repeat(12, 1fr); }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }

@media (max-width: 1400px) { .grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1200px) { .grid-4, .grid-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
  .grid-3, .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .col-3, .col-4, .col-6, .col-8 { grid-column: span 12; }
}

.section { margin-bottom: var(--space-10); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
}
.section-head h2 {
  font-size: var(--type-md);
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: var(--tracking-snug);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.section-head h2 svg { width: 14px; height: 14px; color: var(--text-4); }
.section-head .sub {
  font-size: var(--type-xs);
  color: var(--text-5);
  letter-spacing: var(--tracking-snug);
}

/* ==========================================================================
   Tables — Bloomberg-density rows on white surface, hairline dividers
   ========================================================================== */
.table-wrap {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--elevation-1);
  position: relative;
}
.table-wrap::before { display: none; }
table.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-sm);
}
table.dt thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline-2);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
  font-family: var(--font-mono);
}
table.dt thead th.sortable {
  cursor: pointer;
  transition: color var(--duration-fast);
}
table.dt thead th.sortable:hover { color: var(--text-1); }
table.dt thead th .sort-ind { display: inline-block; margin-left: 4px; opacity: 0.4; font-size: 9px; }
table.dt thead th.sorted { color: var(--text-1); }
table.dt thead th.sorted .sort-ind { opacity: 1; color: var(--accent); }

table.dt tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--hairline-1);
  vertical-align: middle;
  color: var(--text-2);
  letter-spacing: var(--tracking-snug);
}
table.dt tbody tr:last-child td { border-bottom: none; }
table.dt tbody tr { transition: background var(--duration-fast) var(--ease-out); }
table.dt tbody tr:hover { background: var(--surface-2); }
table.dt tbody tr.clickable { cursor: pointer; }
table.dt tbody tr.selected { background: var(--surface-3); }
table.dt .num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums slashed-zero;
}
table.dt tfoot td {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--hairline-2);
  background: var(--surface-2);
  font-weight: 600;
}

.spark {
  display: inline-block;
  height: 30px;
  width: 100px;
  vertical-align: middle;
}

/* ==========================================================================
   Tags / Badges
   ========================================================================== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-3);
  border: 1px solid var(--hairline-2);
  font-family: var(--font-mono);
}
.tag-bull { background: var(--bull-tint); color: var(--bull-500); border-color: transparent; }
.tag-bear { background: var(--bear-tint); color: var(--bear-500); border-color: transparent; }
.tag-amber { background: var(--amber-tint); color: var(--amber-500); border-color: transparent; }
.tag-violet { background: #f6ebff; color: #7c2db8; border-color: transparent; }
.tag-cyan { background: #e6f5fc; color: #0a84a8; border-color: transparent; }
.tag-accent { background: var(--accent-tint); color: var(--accent-strong); border-color: transparent; }
.tag-pink { background: #fde9f0; color: #b3367a; border-color: transparent; }

.dot-inline {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-5);
  vertical-align: middle;
  margin-right: 4px;
}
.dot-inline.bull { background: var(--bull); }
.dot-inline.bear { background: var(--bear); }
.dot-inline.amber { background: var(--amber); }
.dot-inline.violet { background: var(--violet); }
.dot-inline.cyan { background: var(--cyan); }

/* ==========================================================================
   Utility classes
   ========================================================================== */
.text-bull { color: var(--bull) !important; }
.text-bear { color: var(--bear) !important; }
.text-amber { color: var(--amber) !important; }
.text-violet { color: var(--violet) !important; }
.text-cyan { color: var(--cyan) !important; }
.text-accent { color: var(--accent) !important; }
.text-1 { color: var(--text-1) !important; }
.text-2 { color: var(--text-2) !important; }
.text-3 { color: var(--text-3) !important; }
.text-4 { color: var(--text-4) !important; }
.text-5 { color: var(--text-5) !important; }

.text-xs { font-size: var(--type-xs); }
.text-sm { font-size: var(--type-sm); }
.text-base { font-size: var(--type-base); }
.text-md { font-size: var(--type-md); }
.text-lg { font-size: var(--type-lg); }
.text-xl { font-size: var(--type-xl); }
.text-2xl { font-size: var(--type-2xl); }
.text-3xl { font-size: var(--type-3xl); }
.text-4xl { font-size: var(--type-4xl); letter-spacing: var(--tracking-tight); }
.text-5xl { font-size: var(--type-5xl); letter-spacing: var(--tracking-tight); line-height: var(--leading-none); }
.text-6xl { font-size: var(--type-6xl); letter-spacing: var(--tracking-tight); line-height: var(--leading-none); }

.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }

.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

.divider {
  height: 1px;
  background: var(--hairline-2);
  margin: var(--space-5) 0;
}

.uppercase { text-transform: uppercase; letter-spacing: var(--tracking-wider); }
.lowercase { text-transform: lowercase; }

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.fade-in { animation: fadeIn var(--duration-base) var(--ease-out); }
.fade-in-up { animation: fadeInUp var(--duration-slow) var(--ease-out); }
.scale-in { animation: scaleIn var(--duration-base) var(--ease-spring); }

.stagger > * {
  opacity: 0;
  animation: fadeInUp var(--duration-slow) var(--ease-emphasized) forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 50ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 150ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 250ms; }
.stagger > *:nth-child(7) { animation-delay: 300ms; }
.stagger > *:nth-child(8) { animation-delay: 350ms; }
.stagger > *:nth-child(9) { animation-delay: 400ms; }
.stagger > *:nth-child(10) { animation-delay: 450ms; }

@keyframes flashBull {
  0% { background: var(--bull-glow); }
  100% { background: transparent; }
}
@keyframes flashBear {
  0% { background: var(--bear-glow); }
  100% { background: transparent; }
}
.flash-bull { animation: flashBull 1.2s var(--ease-out); }
.flash-bear { animation: flashBear 1.2s var(--ease-out); }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel {
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.6s var(--ease-out) infinite;
  border-radius: var(--radius-md);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--hairline-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page { animation: fadeInUp var(--duration-slow) var(--ease-emphasized); }

/* ==========================================================================
   Charts container — prevent overflow + ensure responsive
   ========================================================================== */
.chart {
  width: 100%;
  min-height: 320px;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  contain: layout;
}
.chart > canvas, .chart > div { max-width: 100% !important; }
.chart-xs { min-height: 80px; }
.chart-sm { min-height: 220px; }
.chart-md { min-height: 320px; }
.chart-lg { min-height: 380px; }
.chart-xl { min-height: 500px; }
.chart-2xl { min-height: 600px; }

/* Table wrap overflow protection */
.table-wrap { overflow-x: auto; }
table.dt { min-width: 0; }

/* ==========================================================================
   Banner
   ========================================================================== */
.banner {
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  position: relative;
  overflow: hidden;
}
.banner::before { display: none; }
.banner-body strong, .banner-body p, .banner-body .sub { color: var(--text-1); }
.banner-body strong { font-size: var(--type-md); font-weight: 600; }
.banner-body p { color: var(--text-3); }
.banner-body .sub { color: var(--text-4); font-size: var(--type-xs); }
/* Banners: subtle tinted background, no aggressive borders */
.banner { border-color: transparent !important; }
.banner-bull { background: var(--bull-tint); color: var(--bull-500); }
.banner-bear { background: var(--bear-tint); color: var(--bear-500); }
.banner-amber { background: var(--amber-tint); color: var(--amber-500); }
.banner-info { background: var(--accent-tint); color: var(--accent-strong); }

.banner-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid currentColor;
  flex-shrink: 0;
  position: relative;
}
.banner-icon svg { width: 18px; height: 18px; color: currentColor; }
.banner-body { flex: 1; color: var(--text-1); }
.banner-body strong {
  color: var(--text-1);
  font-weight: 600;
  font-size: var(--type-md);
  letter-spacing: var(--tracking-snug);
}
.banner-body p {
  font-size: var(--type-base);
  line-height: var(--leading-relaxed);
  color: var(--text-2);
  margin-top: var(--space-1);
  letter-spacing: var(--tracking-snug);
}
.banner-body .sub {
  font-size: var(--type-xs);
  color: var(--text-4);
  margin-top: var(--space-2);
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-5);
}
.tab {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-xs);
  font-size: var(--type-sm);
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  font-weight: 500;
  user-select: none;
  letter-spacing: var(--tracking-snug);
}
.tab:hover { color: var(--text-1); }
.tab.active {
  background: var(--surface-4);
  color: var(--text-1);
  box-shadow: var(--elevation-1);
}

/* ==========================================================================
   Checklist
   ========================================================================== */
.checklist { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.check-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  font-size: var(--type-base);
  color: var(--text-2);
  user-select: none;
}
.check-item:hover { border-color: var(--hairline-3); background: var(--surface-2); }
.check-item.done { color: var(--text-5); text-decoration: line-through; }
.check-item.done .check-box { background: var(--bull); border-color: var(--bull); }
.check-item.done .check-box::after { content: '✓'; color: var(--surface-0); font-size: 12px; font-weight: 700; }
.check-item .check-num { font-family: var(--font-mono); color: var(--text-5); font-size: var(--type-xs); width: 20px; }
.check-item .check-box {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--hairline-4);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--duration-fast);
}

/* ==========================================================================
   Modal / Command palette
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out), visibility var(--duration-base);
}
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%) scale(0.97);
  background: var(--surface-1);
  border: 1px solid var(--hairline-3);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  z-index: 1001;
  min-width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all var(--duration-base) var(--ease-spring);
  box-shadow: var(--elevation-5);
}
.modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-3);
}
.modal-title {
  font-size: var(--type-xl);
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: var(--tracking-tight);
  font-feature-settings: 'ss01';
}
.modal-sub {
  font-size: var(--type-sm);
  color: var(--text-4);
  margin-top: var(--space-1);
  letter-spacing: var(--tracking-snug);
}

/* Command palette */
.palette {
  width: 680px;
  max-width: 92vw;
  background: var(--surface-2);
  border: 1px solid var(--hairline-3);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--elevation-5);
}
.palette-input-wrap {
  display: flex;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--hairline-2);
  gap: var(--space-3);
}
.palette-input-wrap svg { width: 16px; height: 16px; color: var(--text-4); }
.palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--type-md);
  color: var(--text-1);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}
.palette-input::placeholder { color: var(--text-5); }
.palette-results {
  max-height: 440px;
  overflow-y: auto;
  padding: var(--space-2);
}
.palette-group {
  padding: var(--space-3) var(--space-3) var(--space-2);
  font-size: 10px;
  color: var(--text-5);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  font-family: var(--font-mono);
}
.palette-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--type-base);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.palette-item:hover, .palette-item.selected {
  background: var(--surface-3);
  color: var(--text-1);
}
.palette-item svg { width: 16px; height: 16px; color: var(--text-4); }
.palette-item .palette-text { flex: 1; letter-spacing: var(--tracking-snug); }
.palette-item .palette-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
  background: var(--surface-4);
  border: 1px solid var(--hairline-3);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  letter-spacing: 0;
}
.palette-empty {
  padding: var(--space-10);
  text-align: center;
  color: var(--text-5);
  font-size: var(--type-sm);
}

/* ==========================================================================
   Form inputs
   ========================================================================== */
.input {
  background: var(--surface-2);
  border: 1px solid var(--hairline-3);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  height: 34px;
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: var(--type-sm);
  width: 100%;
  transition: all var(--duration-fast) var(--ease-out);
  letter-spacing: var(--tracking-snug);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-label {
  font-size: 10px;
  color: var(--text-5);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-bottom: var(--space-1);
  display: block;
  font-family: var(--font-mono);
}

select.input {
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a5acbd' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-10);
  cursor: pointer;
}

/* ==========================================================================
   Hero — generous whitespace, oversized tabular number (Stripe display)
   ========================================================================== */
.hero {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-2xl);
  padding: var(--space-12) var(--space-10);
  margin-bottom: var(--space-8);
  position: relative;
  overflow: hidden;
  box-shadow: var(--elevation-2);
}
.hero::before, .hero::after { display: none; }

.hero-content { position: relative; z-index: 2; }

.hero-big {
  font-family: var(--font-display);
  font-size: var(--type-6xl);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: var(--leading-none);
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  font-variant-numeric: tabular-nums slashed-zero;
  color: var(--text-1);
}
.hero-big.bull { color: var(--bull-500); }
.hero-big.bear { color: var(--bear-500); }
.hero-big .unit {
  font-size: var(--type-xl);
  font-weight: 400;
  color: var(--text-4);
}

/* ==========================================================================
   Empty / Loading
   ========================================================================== */
.empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-5);
}
.empty svg {
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-4);
  opacity: 0.4;
  color: var(--text-3);
}
.empty .title {
  font-size: var(--type-md);
  color: var(--text-2);
  margin-bottom: var(--space-2);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}
.empty .sub {
  font-size: var(--type-sm);
  line-height: var(--leading-relaxed);
  max-width: 380px;
  margin: 0 auto;
  letter-spacing: var(--tracking-snug);
}

/* ==========================================================================
   Calendar P&L
   ========================================================================== */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.cal-head {
  font-size: 10px;
  color: var(--text-5);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
  padding: var(--space-2) 0;
  font-family: var(--font-mono);
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: var(--space-2);
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  border: 1px solid transparent;
}
.cal-cell:hover { background: var(--surface-3); border-color: var(--hairline-2); }
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.empty:hover { background: transparent; }
.cal-cell.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.cal-cell .date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-4);
  letter-spacing: var(--tracking-snug);
}
.cal-cell.today .date { color: var(--accent); font-weight: 600; }
.cal-cell .pnl {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  margin-top: auto;
}
.cal-cell.bull { background: var(--bull-tint); }
.cal-cell.bear { background: var(--bear-tint); }
.cal-cell.bull .pnl { color: var(--bull-500); }
.cal-cell.bear .pnl { color: var(--bear-500); }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast-container {
  position: fixed;
  /* Below sticky tabs so portfolio cell #6 is never occluded */
  top: calc(var(--layout-status) + var(--layout-top) + var(--layout-tabs) + var(--space-4));
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: 60;  /* below modal (1000) but above tabs (30) */
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--hairline-3);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  min-width: 280px;
  max-width: 420px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  box-shadow: var(--elevation-3);
  pointer-events: auto;
  animation: slideInRight var(--duration-base) var(--ease-out);
  font-size: var(--type-sm);
  backdrop-filter: blur(20px);
}
.toast.bull { border-left-color: var(--bull); }
.toast.bear { border-left-color: var(--bear); }
.toast.amber { border-left-color: var(--amber); }
.toast-title {
  color: var(--text-1);
  font-weight: 600;
  margin-bottom: 2px;
  letter-spacing: var(--tracking-snug);
}
.toast-body { color: var(--text-3); letter-spacing: var(--tracking-snug); }
.toast-icon { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.toast.bull .toast-icon { color: var(--bull); }
.toast.bear .toast-icon { color: var(--bear); }

/* ==========================================================================
   Bottom bar
   ========================================================================== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: var(--layout-sidebar);
  right: 0;
  height: 26px;
  background: var(--surface-1);
  border-top: 1px solid var(--hairline-2);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-4);
  font-size: 10px;
  color: var(--text-5);
  font-family: var(--font-mono);
  z-index: 20;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  font-weight: 500;
  backdrop-filter: blur(12px);
}
.bb-item { display: flex; align-items: center; gap: var(--space-1); }
.bb-spacer { flex: 1; }

/* ==========================================================================
   v12 Refined — Hero, Strategy, Risk Bento, Target rows
   (Linear × Stripe × Tremor × Koyfin)
   ========================================================================== */

/* ----- Eyebrow label (uppercase mono accent caption) ----- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.eyebrow-muted { color: var(--text-5); }

/* ----- Benchmark comparison F section ----- */
.bench-section {
  background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-0) 100%);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: 24px 28px 22px;
  margin-bottom: var(--space-6);
  box-shadow: var(--elevation-1);
  position: relative;
  overflow: hidden;
}
.bench-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, oklch(55% 0.22 25), var(--gold), var(--bull-500));
}
.bench-head { margin-bottom: 18px; }
.bench-title {
  font-family: var(--font-editorial);
  font-variation-settings: 'opsz' 36, 'wght' 480;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text-1);
  margin: 4px 0 2px;
}
.bench-sub { font-size: 12px; color: var(--text-4); margin: 0; }

.bench-h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: var(--tracking-snug);
  margin: 18px 0 4px;
}
.bench-h4-sub { font-size: 11px; color: var(--text-4); margin: 0 0 10px; }

.bench-absolute { margin-bottom: 16px; }
.bench-abs-grid { display: flex; flex-direction: column; gap: 1px; background: var(--hairline-1); border: 1px solid var(--hairline-2); border-radius: 8px; overflow: hidden; }
.bench-abs-row {
  display: grid;
  grid-template-columns: 1.6fr repeat(5, 1fr);
  gap: 12px;
  padding: 9px 14px;
  background: var(--surface-1);
  font-size: 12px;
  align-items: center;
}
.bench-abs-row-header {
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-5);
  font-weight: 600;
}
.bench-abs-row-header > span:not(:first-child) { text-align: right; }
.bench-abs-port { font-weight: 500; }
.bench-abs-bench {
  background: color-mix(in oklch, var(--surface-2) 60%, var(--gold-tint) 40%);
  font-weight: 600;
}
.bench-abs-label { color: var(--text-1); }
.bench-abs-val {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.bench-pair-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--hairline-2); border-radius: 8px; }
.bench-pair-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.bench-pair-table thead { background: var(--surface-2); }
.bench-pair-table th {
  padding: 8px 10px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-5);
  font-weight: 600;
  border-bottom: 1px solid var(--hairline-2);
  white-space: nowrap;
}
.bench-pair-table th.num { text-align: right; }
.bench-pair-table td { padding: 7px 10px; border-bottom: 1px solid var(--hairline-1); color: var(--text-2); }
.bench-pair-table td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.bench-pair-table .bench-pid { color: var(--text-1); font-weight: 500; white-space: nowrap; }
.bench-pair-table .bench-bn { color: var(--text-3); white-space: nowrap; }
.bench-pair-table tr:nth-child(3n) { border-bottom: 2px solid var(--hairline-2); }

.bench-scorecard {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.bench-sc-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: 8px;
  padding: 10px 12px;
}
.bench-sc-pid {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 8px;
  letter-spacing: var(--tracking-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bench-sc-rows { display: flex; flex-direction: column; gap: 4px; }
.bench-sc-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-4);
}
.bench-sc-row strong { font-family: var(--font-mono); font-weight: 700; font-size: 12px; }
.text-amber { color: var(--amber-500); }

.bench-footnote {
  background: var(--surface-2);
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-3);
  margin-top: 14px;
}
.bench-footnote strong { color: var(--text-1); }
.bench-footnote ul { padding-left: 18px; margin: 6px 0 8px; }
.bench-footnote li { margin-bottom: 4px; }
.bench-footnote li strong { display: inline; }

@media (max-width: 720px) {
  .bench-scorecard { grid-template-columns: repeat(2, 1fr); }
  .bench-pair-table { font-size: 10px; }
  .bench-pair-table th, .bench-pair-table td { padding: 6px 8px; }
}
@media (max-width: 520px) {
  .bench-section { padding: 18px 14px; }
  .bench-title { font-size: 17px; }
  .bench-abs-row { grid-template-columns: 1.2fr repeat(5, 0.7fr); gap: 6px; padding: 8px 10px; font-size: 10px; }
  .bench-abs-row-header { font-size: 8px; }
}

/* ----- Bootstrap E section: 9D predictive power validation ----- */
.bootstrap-section {
  background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-0) 100%);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: 24px 28px 22px;
  margin-bottom: var(--space-6);
  box-shadow: var(--elevation-1);
  position: relative;
  overflow: hidden;
}
.bootstrap-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--bear-500), var(--accent), var(--bull-500));
}
.bootstrap-head { margin-bottom: 16px; }
.bootstrap-title {
  font-family: var(--font-editorial);
  font-variation-settings: 'opsz' 36, 'wght' 480;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text-1);
  margin: 4px 0 2px;
}
.bootstrap-sub { font-size: 12px; color: var(--text-4); margin: 0; }

.bootstrap-verdict {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  margin: 12px 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.bootstrap-verdict-bull  { background: var(--bull-tint); border-left: 3px solid var(--bull-500); }
.bootstrap-verdict-amber { background: var(--amber-tint); border-left: 3px solid var(--amber-500); }
.bootstrap-verdict-bear  { background: var(--bear-tint); border-left: 3px solid var(--bear-500); }
.bootstrap-verdict-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-1);
  border: 1px solid var(--hairline-3);
  flex-shrink: 0;
}
.bootstrap-verdict-msg { flex: 1; min-width: 200px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.bootstrap-rho {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
}
.bootstrap-rho strong { font-size: 18px; color: var(--text-1); font-weight: 700; }

.bootstrap-rho-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.rho-cell {
  padding: 12px 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rho-label { font-size: 10px; color: var(--text-5); font-family: var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.rho-val {
  font-family: var(--font-editorial);
  font-variation-settings: 'opsz' 36, 'wght' 540;
  font-size: 20px;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  margin: 2px 0;
}
.rho-detail { font-size: 10px; color: var(--text-4); }

.bootstrap-h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: var(--tracking-snug);
  margin: 14px 0 8px;
}

.bootstrap-winners { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.winner-row {
  display: grid;
  grid-template-columns: 180px 1fr 56px 60px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
}
.winner-row:hover { background: var(--surface-2); }
.winner-pid { color: var(--text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.winner-bar-wrap {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.winner-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 3px;
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}
.winner-bar-bull { background: linear-gradient(90deg, var(--bull-400), var(--bull-500)); }
.winner-pct {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-1);
}
.winner-9d {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-5);
  text-align: right;
}

.bootstrap-footnote {
  background: var(--surface-2);
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-3);
  margin-top: 12px;
}
.bootstrap-footnote strong { color: var(--text-1); display: block; margin-bottom: 6px; }
.bootstrap-footnote ul { padding-left: 18px; margin: 0; }
.bootstrap-footnote li { margin-bottom: 6px; }
.bootstrap-footnote li strong { display: inline; margin-bottom: 0; }

@media (max-width: 520px) {
  .bootstrap-section { padding: 18px 14px; }
  .bootstrap-title { font-size: 17px; }
  .bootstrap-rho-grid { grid-template-columns: repeat(2, 1fr); }
  .winner-row { grid-template-columns: 100px 1fr 50px 48px; gap: 8px; }
  .bootstrap-verdict { padding: 12px; }
}

/* ----- Verdict section: V5 expected vs V6 proxy vs P0 same-window ----- */
.verdict-section {
  background: linear-gradient(180deg, var(--surface-1) 0%, var(--surface-0) 100%);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: 24px 28px 22px;
  margin-bottom: var(--space-6);
  box-shadow: var(--elevation-1);
  position: relative;
  overflow: hidden;
}
.verdict-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--accent) 50%, var(--bull-500) 100%);
}
.verdict-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; }
.verdict-title {
  font-family: var(--font-editorial);
  font-variation-settings: 'opsz' 36, 'wght' 480;
  font-size: 20px;
  letter-spacing: -0.02em;
  font-weight: 500;
  color: var(--text-1);
  margin: 0;
}
.verdict-sub { font-size: 12px; color: var(--text-4); margin: 0; }

.verdict-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.verdict-row-benchmark {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.verdict-cell {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  cursor: help;
}
.verdict-cell-expected { border-color: color-mix(in oklch, var(--hairline-2) 50%, var(--amber-400) 50%); }
.verdict-cell-proxy    { border-color: color-mix(in oklch, var(--hairline-2) 60%, var(--gold) 40%); }
.verdict-cell-real     { border-color: color-mix(in oklch, var(--hairline-2) 50%, var(--bull-500) 50%); }
.verdict-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  align-self: flex-start;
}
.tag-expected { background: var(--amber-tint); color: var(--amber-500); border: 1px solid var(--amber-400); }
.tag-proxy    { background: var(--gold-tint); color: var(--gold-deep); border: 1px solid var(--gold-soft); }
.tag-real     { background: var(--bull-tint); color: var(--bull-600); border: 1px solid var(--bull-300); }
.verdict-val {
  font-family: var(--font-editorial);
  font-variation-settings: 'opsz' 60, 'wght' 540;
  font-size: 30px;
  font-weight: 540;
  letter-spacing: -0.03em;
  color: var(--text-1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.verdict-val.text-bull { color: var(--bull-500); }
.verdict-val.text-bear { color: var(--bear-500); }
.verdict-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}
.verdict-detail { font-size: 10px; color: var(--text-5); line-height: 1.4; }

.verdict-mdd-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--hairline-1);
  border-bottom: 1px solid var(--hairline-1);
  margin: 4px 0 12px;
}
.verdict-mdd-cell { display: flex; flex-direction: column; gap: 2px; padding: 0 6px; }
.verdict-mdd-label { font-size: 10px; color: var(--text-5); font-family: var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.verdict-mdd-val { font-family: var(--font-mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.verdict-warning {
  background: var(--amber-tint);
  border-left: 3px solid var(--amber-500);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-2);
  margin: 8px 0 12px;
}
.verdict-warning code {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--surface-1);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--hairline-2);
}

.verdict-footnote {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
  margin: 0;
}
.verdict-footnote ul { padding-left: 18px; margin: 8px 0 0; }
.verdict-footnote li { margin-bottom: 4px; }

@media (max-width: 520px) {
  .verdict-section { padding: 18px 16px; }
  .verdict-grid, .verdict-row-benchmark, .verdict-mdd-row { grid-template-columns: 1fr; gap: 8px; }
  .verdict-val { font-size: 24px; }
  .verdict-title { font-size: 17px; }
}

/* ----- Framework-parity badge (★直接 vs ◊代理) ----- */
.parity-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  cursor: help;
  position: relative;
}
.parity-tag.direct {
  background: var(--bull-tint);
  color: var(--bull-600);
  border: 1px solid var(--bull-300);
}
.parity-tag.proxy {
  background: var(--gold-tint);
  color: var(--gold-deep);
  border: 1px solid var(--gold-soft);
}

/* Tooltip on hover — shows mapping detail */
.parity-tag::before {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-1);
  color: var(--surface-1);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
  text-transform: none;
  white-space: pre;
  line-height: 1.45;
  box-shadow: var(--elevation-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms;
  z-index: 100;
  max-width: 360px;
  min-width: 200px;
}
.parity-tag:hover::before {
  opacity: 1;
}

/* ----- Synth badge (marks合成 fields) ----- */
.synth-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--amber-tint);
  color: var(--amber-500);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 6px;
}
.synth-tag::before { content: '◊'; font-size: 11px; line-height: 1; }

/* ----- KPI Stage — large narrative + 3-4 metric hero block ----- */
.kpi-stage {
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-0) 100%);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-2xl);
  padding: 36px 40px 32px;
  margin-bottom: var(--space-8);
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(440px, 1.35fr);
  gap: 48px;
  align-items: end;
  box-shadow: var(--elevation-1);
}
.kpi-stage-meta { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kpi-stage-name {
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: -0.034em;
  font-weight: 600;
  color: var(--text-1);
  margin: 6px 0 4px;
}
.kpi-stage-philosophy {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-3);
  max-width: 54ch;
  margin: 0;
}
.kpi-stage-rebal {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.kpi-stage-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;
  align-items: end;
}
.kpi-stage-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ----- Metric Display (large hero number + label + target chip) ----- */
.metric-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.metric-value {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 0.96;
  letter-spacing: -0.042em;
  font-weight: 600;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum', 'ss01';
}
.metric-value.text-bull { color: var(--bull-500); }
.metric-value.text-bear { color: var(--bear-500); }
.metric-foot {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.metric-label {
  font-size: 11px;
  color: var(--text-4);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}
.metric-target {
  font-size: 11px;
  color: var(--text-5);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-snug);
}

/* ----- Risk Meter (5-segment pill bar) ----- */
.risk-meter {
  display: flex;
  align-items: center;
  gap: 3px;
}
.risk-meter-seg {
  width: 18px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
}
.risk-meter-seg.on { background: var(--text-1); }
.risk-meter-1 .risk-meter-seg.on { background: var(--bull-400); }
.risk-meter-2 .risk-meter-seg.on { background: var(--bull-500); }
.risk-meter-3 .risk-meter-seg.on { background: var(--amber-400); }
.risk-meter-4 .risk-meter-seg.on { background: var(--amber-500); }
.risk-meter-5 .risk-meter-seg.on { background: var(--bear-400); }

.risk-meter-lg .risk-meter-seg { width: 22px; height: 8px; border-radius: 4px; }
.risk-meter-sm .risk-meter-seg { width: 12px; height: 4px; border-radius: 2px; }

/* ----- Pill (small contextual badges) ----- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
  font-family: var(--font-sans);
  height: 24px;
  white-space: nowrap;
}
.pill svg { width: 11px; height: 11px; opacity: 0.7; }
.pill-ghost {
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  color: var(--text-3);
}
.pill-accent {
  background: var(--accent-tint);
  color: var(--accent-strong);
}
.pill-bull { background: var(--bull-tint); color: var(--bull-600); }
.pill-bear { background: var(--bear-tint); color: var(--bear-500); }
.pill-amber { background: var(--amber-tint); color: var(--amber-500); }

/* ----- Rank Strip (4-cell summary band, top-ranked across all portfolios) ----- */
.rank-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--hairline-2);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-6);
}
.rank-cell {
  background: var(--surface-1);
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.rank-value {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: -0.03em;
  font-weight: 600;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum', 'ss01';
  line-height: 1;
}
.rank-value.text-bull { color: var(--bull-500); }
.rank-value.text-bear { color: var(--bear-500); }
.rank-value small {
  font-size: 14px;
  color: var(--text-5);
  margin-left: 2px;
  font-weight: 500;
}
.rank-meta {
  font-size: 12px;
  color: var(--text-4);
  letter-spacing: var(--tracking-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Strategy Card (long-form narrative + bottom rule for調仓 logic) ----- */
.card-narrative {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  box-shadow: var(--elevation-1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card-narrative-head { display: flex; flex-direction: column; gap: 4px; }
.card-narrative-head h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--text-1);
  margin: 0;
}
.card-narrative-body {
  font-size: 14px;
  line-height: 1.66;
  color: var(--text-2);
  max-width: 60ch;
}
.card-narrative-rule {
  border-top: 1px solid var(--hairline-2);
  padding-top: 16px;
  margin-top: 8px;
}
.card-narrative-rule-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-3);
  margin-top: 6px;
}

/* ----- Target Card (target vs expected bar rows) ----- */
.card-targets {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--elevation-1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.target-row {
  display: grid;
  grid-template-columns: 84px 1fr 78px 88px;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline-1);
}
.target-row:last-child { border-bottom: none; }
.target-label {
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: var(--tracking-snug);
}
.target-bar { width: 100%; }
.target-bar-track {
  display: block;
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.target-bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width var(--duration-slow) var(--ease-out);
}
.target-bar-fill.text-bull { background: var(--bull-400); }
.target-bar-fill.text-bear { background: var(--bear-400); }
.target-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-1);
  text-align: right;
  letter-spacing: var(--tracking-snug);
}
.target-val.text-bull { color: var(--bull-500); }
.target-val.text-bear { color: var(--bear-500); }
.target-val small { font-size: 10px; color: var(--text-5); font-weight: 500; }
.target-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-5);
  letter-spacing: var(--tracking-snug);
  text-align: right;
}

/* ----- Risk Bento (5-cell VaR + Stress grid) ----- */
.risk-bento {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: var(--space-6);
}
.risk-bento-cell {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  box-shadow: var(--elevation-1);
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast);
}
.risk-bento-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--elevation-2);
}
.risk-bento-cell.var-cell {
  background: linear-gradient(180deg, var(--bear-tint) 0%, var(--surface-1) 50%);
}
.risk-bento-cell.stress-cell {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 60%);
}
.risk-bento-value {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: -0.032em;
  font-weight: 600;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum', 'ss01';
  line-height: 1;
}
.risk-bento-value.text-bear { color: var(--bear-500); }
.risk-bento-desc {
  font-size: 11px;
  color: var(--text-4);
  line-height: 1.5;
  letter-spacing: var(--tracking-snug);
}

/* ----- Watchlist Card (Tremor KPI pattern + inline sparkline, clickable) ----- */
.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: var(--space-6);
}
.watchlist-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-xl);
  padding: 18px 18px 16px;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--duration-fast) var(--ease-out);
  min-width: 0;
}
.watchlist-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--elevation-2);
  border-color: var(--hairline-3);
}
.watchlist-card.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-tint) 0%, var(--surface-1) 40%);
  box-shadow: 0 0 0 1px var(--accent), var(--elevation-1);
}
.watchlist-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.watchlist-card-pid {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-5);
}
.watchlist-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: var(--tracking-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.watchlist-card-irr {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.032em;
  color: var(--bull-500);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum', 'ss01';
  line-height: 1;
}
.watchlist-card-irr-label {
  font-size: 11px;
  color: var(--text-4);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}
.watchlist-card-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline-1);
  font-size: 11px;
}
.watchlist-foot-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.watchlist-foot-cell-label {
  font-size: 10px;
  color: var(--text-5);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.watchlist-foot-cell-val {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  font-size: 13px;
  letter-spacing: var(--tracking-snug);
}
.watchlist-foot-cell-val.text-bear { color: var(--bear-500); }

/* Secondary row: V5 期望 (demoted, low-emphasis) */
.watchlist-card-secondary {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--hairline-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  color: var(--text-5);
}
.ws-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--amber-tint);
  color: var(--amber-500);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ws-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ----- Section Head — refined ----- */
.section-head h2.section-head-xl,
.section-head-xl {
  font-size: 20px;
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--text-1);
  margin: 0;
}

/* ----- Markdown Report Modal (inline reports rendering) ----- */
.report-modal {
  background: var(--surface-1);
  border-radius: var(--radius-xl);
  width: min(820px, 92vw);
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--elevation-5);
}
.report-modal-head {
  padding: 20px 28px;
  border-bottom: 1px solid var(--hairline-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.report-modal-head h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--text-1);
  margin: 0;
}
.report-modal-close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  color: var(--text-4);
  cursor: pointer;
  transition: all var(--duration-fast);
}
.report-modal-close:hover { background: var(--surface-3); color: var(--text-1); }
.report-modal-body {
  padding: 24px 32px 32px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
}
.report-modal-body h1 { font-size: 24px; margin: 24px 0 12px; letter-spacing: -0.02em; }
.report-modal-body h1:first-child { margin-top: 0; }
.report-modal-body h2 { font-size: 18px; margin: 24px 0 10px; letter-spacing: -0.018em; color: var(--text-1); }
.report-modal-body h3 { font-size: 15px; margin: 16px 0 8px; color: var(--text-1); font-weight: 600; }
.report-modal-body p { margin: 8px 0 12px; }
.report-modal-body ul, .report-modal-body ol { margin: 8px 0 12px; padding-left: 22px; }
.report-modal-body li { margin: 4px 0; }
.report-modal-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-1);
}
.report-modal-body pre {
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.55;
  margin: 12px 0;
}
.report-modal-body pre code {
  background: none;
  border: none;
  padding: 0;
}
.report-modal-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 16px;
  margin: 12px 0;
  color: var(--text-3);
  font-style: italic;
}
.report-modal-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 12px 0;
}
.report-modal-body th, .report-modal-body td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--hairline-2);
  text-align: left;
}
.report-modal-body th {
  color: var(--text-5);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.report-modal-body a { color: var(--accent); }
.report-modal-body hr { border: none; border-top: 1px solid var(--hairline-2); margin: 20px 0; }
.report-modal-body strong { color: var(--text-1); font-weight: 600; }

/* Responsive — narrow desktop */
@media (max-width: 1320px) {
  .kpi-stage { grid-template-columns: 1fr; gap: 24px; }
  .kpi-stage-grid { grid-template-columns: repeat(2, 1fr); }
  .watchlist-grid { grid-template-columns: repeat(3, 1fr); }
  .risk-bento { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 880px) {
  .portfolio-tabs { grid-template-columns: repeat(3, 1fr); }
  .pt-cell:nth-child(n+4) { border-top: 1px solid var(--hairline-1); }
  .pt-cell:nth-child(3n) { border-right: none; }
}

/* ==========================================================================
   v12 · 2026 cutting-edge layer
   View Transitions · @property count-up · Sparklines · @starting-style
   ========================================================================== */

/* ---- Spring physics easing tokens (override sluggish cubic-bezier) ---- */
:root {
  --ease-spring-soft:  linear(0, 0.31 7.6%, 0.61 15.4%, 0.83 23.6%, 0.95 31.7%, 1.02 40%, 1.04 48.7%, 1.03 57.6%, 1.01 67.5%, 1);
  --ease-spring-firm:  linear(0, 0.48 8.6%, 0.85 17.7%, 1.05 26.9%, 1.08 35.6%, 1.04 45.5%, 1.01 56.4%, 1);
  --ease-out-quint:    cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---- View Transitions (Chrome 117+, Safari 18+) ---- */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 280ms;
  animation-timing-function: var(--ease-out-quint);
}
::view-transition-old(root) { animation-name: fadeSlideOut; }
::view-transition-new(root) { animation-name: fadeSlideIn; }

@keyframes fadeSlideOut {
  to { opacity: 0; transform: translateY(-4px); filter: blur(2px); }
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); filter: blur(2px); }
}

/* ---- @starting-style — entry animations on first render ---- */
.kpi-stage, .rank-cell, .watchlist-card, .risk-bento-cell, .card-narrative, .card-targets, .pt-cell {
  transition: opacity 300ms var(--ease-out-quint),
              transform 320ms var(--ease-out-quint);
}
@starting-style {
  .kpi-stage, .rank-cell, .watchlist-card, .risk-bento-cell, .card-narrative, .card-targets {
    opacity: 0;
    transform: translateY(8px);
  }
  .pt-cell {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ---- @property count-up tokens (for hero metrics) ---- */
@property --num {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}
.count-up {
  counter-reset: c var(--num, 0);
  transition: --num 720ms var(--ease-spring-firm);
}
.count-up::after {
  content: counter(c);
}

/* ---- Sparkline (inline SVG, 60×16) ---- */
.sparkline {
  display: inline-block;
  width: 100%;
  height: 28px;
  margin-top: 8px;
  margin-bottom: 4px;
  overflow: visible;
}
.sparkline path.line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 1px oklch(0% 0 0 / 0.04));
}
.sparkline path.area {
  fill: var(--accent-glow);
  stroke: none;
}
.sparkline.spark-bull path.line { stroke: var(--bull-500); }
.sparkline.spark-bull path.area { fill: var(--bull-glow); }
.sparkline.spark-bear path.line { stroke: var(--bear-500); }
.sparkline.spark-bear path.area { fill: var(--bear-glow); }
.sparkline circle.endpoint {
  fill: oklch(100% 0 0);
  stroke-width: 1.5;
  r: 2.5;
}
.sparkline.spark-bull circle.endpoint { stroke: var(--bull-500); }
.sparkline.spark-bear circle.endpoint { stroke: var(--bear-500); }
.sparkline:not(.spark-bull):not(.spark-bear) circle.endpoint { stroke: var(--accent); }

/* ---- Watchlist card hover: spring physics + magnetic feel ---- */
.watchlist-card {
  transition: transform 360ms var(--ease-spring-soft),
              box-shadow 280ms var(--ease-out-quint),
              border-color 200ms var(--ease-out-quint),
              background 200ms;
  will-change: transform;
}
.watchlist-card:hover {
  transform: translateY(-3px) scale(1.012);
}
.watchlist-card:active {
  transform: translateY(0) scale(0.995);
  transition-duration: 80ms;
}

/* Tab cells get the same spring */
.pt-cell {
  transition: background 200ms var(--ease-out-quint),
              transform 240ms var(--ease-spring-soft);
}
.pt-cell:active { transform: scale(0.985); }

/* Rank cells subtle lift */
.rank-cell {
  transition: background 200ms;
}
.rank-strip:hover .rank-cell {
  background: var(--surface-1);
}
.rank-cell:hover {
  background: var(--surface-2) !important;
}

/* Risk bento — soft float + shimmer on hover */
.risk-bento-cell {
  transition: transform 360ms var(--ease-spring-soft),
              box-shadow 280ms var(--ease-out-quint);
}
.risk-bento-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.06), 0 1px 2px oklch(0% 0 0 / 0.04);
}

/* ---- Insights callout (data-storytelling row above hero) ---- */
.insight-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.insight-cell {
  background: var(--surface-1);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: all 200ms var(--ease-out-quint);
}
.insight-cell::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.insight-cell.bull::before { background: var(--bull-500); }
.insight-cell.bear::before { background: var(--bear-500); }
.insight-cell.amber::before { background: var(--amber-500); }
.insight-cell:hover {
  background: var(--surface-0);
  transform: translateX(2px);
}
.insight-icon {
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--accent-tint);
  color: var(--accent);
  flex-shrink: 0;
}
.insight-cell.bull .insight-icon { background: var(--bull-tint); color: var(--bull-500); }
.insight-cell.bear .insight-icon { background: var(--bear-tint); color: var(--bear-500); }
.insight-cell.amber .insight-icon { background: var(--amber-tint); color: var(--amber-500); }
.insight-icon svg { width: 14px; height: 14px; }
.insight-body { flex: 1; min-width: 0; }
.insight-headline {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: var(--tracking-snug);
  line-height: 1.4;
}
.insight-detail {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 3px;
  line-height: 1.5;
}
.insight-strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ---- Skeleton shimmer (for async-loaded chart areas) ---- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--radius-md);
}

/* ---- @scope: enforce metric numbers always tabular ---- */
.kpi-stage [class*="-value"],
.kpi-stage .metric-value,
.rank-value,
.risk-bento-value,
.watchlist-card-irr,
.pt-score {
  font-variant-numeric: tabular-nums slashed-zero;
  font-feature-settings: 'tnum' 1, 'ss01' 1, 'zero' 1;
}

/* ---- Live price flash (when a value changes) ---- */
@keyframes flashBull {
  0% { background-color: var(--bull-tint); }
  100% { background-color: transparent; }
}
@keyframes flashBear {
  0% { background-color: var(--bear-tint); }
  100% { background-color: transparent; }
}
.flash-bull { animation: flashBull 800ms var(--ease-out-quint); }
.flash-bear { animation: flashBear 800ms var(--ease-out-quint); }

/* ---- Better page-header rhythm ---- */
.page-header .eyebrow,
.page-title-wrap .eyebrow {
  margin-bottom: 4px;
}

/* ---- Container queries: KPI grid adapts per stage width ---- */
.kpi-stage {
  container-type: inline-size;
  container-name: stage;
}
@container stage (max-width: 720px) {
  .kpi-stage-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
}
@container stage (max-width: 480px) {
  .kpi-stage-grid { grid-template-columns: 1fr; gap: 20px; }
}

/* ---- Reduced motion — strip all keyframes ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .ticker-track { animation: none !important; }
}

/* ==========================================================================
   v13 · Even further cutting-edge (cascade-layered for guaranteed priority)
   :has() · @layer · color-mix · text-wrap balance · scroll-timeline
   · anchor positioning · shared-element view transitions · 3D tilt
   ========================================================================== */

/* ==========================================================================
   v14 · "Signature Polish" — final layer pushing toward magazine-grade
   Editorial serif display · noise grain · CAD grid · cinematic intro · live pulse
   ========================================================================== */
@layer v14 {

  /* ---------- Subtle noise grain + CAD grid background ---------- */
  body {
    position: relative;
  }
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.45;
    background-image:
      /* CAD grid: 1px lines every 64px */
      linear-gradient(to right, oklch(0% 0 0 / 0.025) 1px, transparent 1px),
      linear-gradient(to bottom, oklch(0% 0 0 / 0.025) 1px, transparent 1px),
      /* SVG noise grain — base64 fractal */
      url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 64px 64px, 64px 64px, 200px 200px;
  }
  /* Ensure content sits above the texture */
  .app, .bottom-bar, .modal-backdrop, .modal, .toast-container { position: relative; z-index: 1; }

  /* ---------- Editorial serif for hero display numbers ---------- */
  .kpi-stage-name {
    font-family: var(--font-editorial);
    font-weight: 400;
    font-variation-settings: 'opsz' 144, 'wght' 420, 'wght' 460;
    letter-spacing: -0.028em;
    font-size: 44px;
    line-height: 1.04;
  }
  /* The killer hero number — current portfolio's primary IRR */
  .kpi-stage .metric-display:first-child .metric-value {
    font-family: var(--font-editorial);
    font-variation-settings: 'opsz' 144, 'wght' 500, 'wght' 540;
    font-size: 76px;
    letter-spacing: -0.05em;
    line-height: 0.92;
  }
  /* All metric values: tighter editorial vibe */
  .metric-value {
    font-feature-settings: 'tnum' 1, 'lnum' 1, 'ss01' 1;
  }
  /* Big section headings get editorial serif */
  .section-head-xl, .page-title-wrap h1 {
    font-family: var(--font-editorial);
    font-variation-settings: 'opsz' 80, 'wght' 480, 'wght' 480;
    font-weight: 400;
    letter-spacing: -0.026em;
  }
  /* Rank values: editorial serif for that "magazine cover" feel */
  .rank-value {
    font-family: var(--font-editorial);
    font-variation-settings: 'opsz' 96, 'wght' 460, 'wght' 460;
    font-weight: 400;
    font-size: 32px;
  }

  /* ---------- Cinematic intro (once per session via .intro class on body) ---------- */
  body.intro::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: oklch(99% 0.002 250);
    pointer-events: none;
    animation: introVeil 480ms 80ms cubic-bezier(0.65, 0, 0.35, 1) forwards;
  }
  @keyframes introVeil {
    0%   { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
  }

  body.intro .brand-mark {
    animation: brandReveal 500ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  @keyframes brandReveal {
    from { opacity: 0; transform: scale(0.5) rotate(-12deg); filter: blur(8px); }
    to   { opacity: 1; transform: scale(1) rotate(0); filter: blur(0); }
  }
  body.intro .brand > div:nth-child(2),
  body.intro .brand-sub {
    animation: brandTextFade 420ms 160ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  @keyframes brandTextFade {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
  }
  body.intro .portfolio-tabs {
    animation: tabsDropIn 400ms 180ms var(--ease-spring-firm) both;
  }
  @keyframes tabsDropIn {
    from { opacity: 0; transform: translateY(-24px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  body.intro .kpi-stage {
    animation: heroLift 500ms 260ms var(--ease-spring-soft) both;
  }
  @keyframes heroLift {
    from { opacity: 0; transform: translateY(20px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
  }
  body.intro .insight-cell {
    animation: insightFade 380ms calc(360ms + var(--i, 0) * 50ms) cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  body.intro .insight-cell:nth-child(1) { --i: 0; }
  body.intro .insight-cell:nth-child(2) { --i: 1; }
  body.intro .insight-cell:nth-child(3) { --i: 2; }
  body.intro .insight-cell:nth-child(4) { --i: 3; }
  @keyframes insightFade {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  body.intro .watchlist-card {
    animation: cardStagger 380ms calc(440ms + var(--j, 0) * 40ms) var(--ease-spring-soft) both;
  }
  body.intro .watchlist-card:nth-child(1) { --j: 0; }
  body.intro .watchlist-card:nth-child(2) { --j: 1; }
  body.intro .watchlist-card:nth-child(3) { --j: 2; }
  body.intro .watchlist-card:nth-child(4) { --j: 3; }
  body.intro .watchlist-card:nth-child(5) { --j: 4; }
  body.intro .watchlist-card:nth-child(6) { --j: 5; }
  @keyframes cardStagger {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
  }
  body.intro .rank-strip {
    animation: rankFade 380ms 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  @keyframes rankFade {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  /* ---------- Live pulse next to every "now"-time metric ---------- */
  .live-pulse {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bull-500);
    box-shadow: 0 0 0 0 var(--bull-glow);
    animation: livePulse 2.2s var(--ease-out-quint) infinite;
    vertical-align: middle;
    margin-left: 8px;
  }
  @keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 oklch(60% 0.18 150 / 0.55); }
    70%  { box-shadow: 0 0 0 10px oklch(60% 0.18 150 / 0); }
    100% { box-shadow: 0 0 0 0 oklch(60% 0.18 150 / 0); }
  }

  /* ---------- Market session progress bar (under sticky tabs) ---------- */
  .market-session-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg,
      var(--bull-500) 0%,
      var(--bull-500) var(--session-pct, 0%),
      transparent var(--session-pct, 0%));
    pointer-events: none;
    z-index: 2;
  }

  /* ---------- Hero killer-number animation on portfolio switch ---------- */
  .kpi-stage .metric-display .metric-value {
    transition: transform 480ms var(--ease-spring-soft);
  }

  /* ---------- Chart container subtle inner glow on hover ---------- */
  .card:has(.chart):hover {
    border-color: color-mix(in oklch, var(--hairline-3) 60%, var(--accent) 40%);
  }

  /* ---------- Watchlist sparkline upsize: more prominent ---------- */
  .sparkline {
    height: 36px;
  }

  /* ---------- Editorial accents on insight headlines ---------- */
  .insight-headline {
    font-size: 14px;
    line-height: 1.4;
  }
  .insight-headline .insight-strong {
    font-family: var(--font-editorial);
    font-variation-settings: 'opsz' 36, 'wght' 600, 'wght' 460;
    font-weight: 600;
    font-size: 1.05em;
    letter-spacing: -0.01em;
  }

  /* ---------- Status bar latency + IP details ---------- */
  .status-detail {
    color: var(--text-5);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
  }
}

@layer v13 {

  /* ---------- Typography intelligence ---------- */
  h1, h2, h3,
  .kpi-stage-name,
  .section-head-xl,
  .card-narrative-head h3,
  .insight-headline {
    text-wrap: balance;
  }
  .kpi-stage-philosophy,
  .card-narrative-body,
  .card-narrative-rule-body,
  .insight-detail,
  .risk-bento-desc,
  .page-subtitle {
    text-wrap: pretty;
  }
  body { text-spacing-trim: trim-start; }

  /* ---------- Numbers: full set of OpenType features ---------- */
  .num, .mono,
  .metric-value, .rank-value, .risk-bento-value,
  .watchlist-card-irr, .pt-score, .target-val {
    font-feature-settings: 'tnum' 1, 'lnum' 1, 'ss01' 1, 'cv11' 1, 'zero' 1;
    font-variant-numeric: tabular-nums lining-nums slashed-zero;
  }

  /* ---------- #1 Gold trophy badge on every rank-cell ---------- */
  .rank-cell {
    position: relative;
  }
  .rank-cell::after {
    content: '#1';
    position: absolute;
    top: 14px;
    right: 16px;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: oklch(38% 0.13 80);
    background: linear-gradient(135deg, oklch(94% 0.10 85) 0%, oklch(82% 0.16 80) 100%);
    padding: 3px 8px 2px;
    border-radius: 999px;
    border: 1px solid oklch(78% 0.14 80);
    box-shadow:
      0 1px 2px oklch(45% 0.14 80 / 0.20),
      inset 0 1px 0 oklch(100% 0 0 / 0.5);
  }

  /* ---------- :has() parent-state — bull/bear cards auto-decorated ---------- */
  .watchlist-card:has(.text-bear) {
    border-color: color-mix(in oklch, var(--hairline-2) 70%, var(--bear-400) 30%);
  }
  .watchlist-card:has(.text-bull):not(.active) .watchlist-card-irr {
    text-shadow: 0 0 0 transparent;
    transition: text-shadow 300ms;
  }
  .watchlist-card:has(.text-bull):hover .watchlist-card-irr {
    text-shadow: 0 0 16px oklch(60% 0.18 150 / 0.3);
  }
  /* if active portfolio shows green, tag header glows */
  .portfolio-tabs:has(.pt-cell.active) .pt-cell.active::before {
    background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
    height: 2.5px;
  }

  /* ---------- color-mix dynamic surfaces ---------- */
  .pt-cell.active {
    background: color-mix(in oklch, var(--surface-0) 86%, var(--accent) 14%);
  }
  .pt-cell:hover:not(.active) {
    background: color-mix(in oklch, var(--surface-2) 92%, var(--accent) 8%);
  }
  .rank-cell:hover {
    background: color-mix(in oklch, var(--surface-1) 92%, var(--accent) 8%) !important;
  }
  .watchlist-card.active {
    background: linear-gradient(180deg,
      color-mix(in oklch, var(--surface-1) 88%, var(--accent) 12%) 0%,
      var(--surface-1) 40%);
  }

  /* ---------- 3D card tilt — driven by JS-injected --tilt-* custom props ---------- */
  .watchlist-card {
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    --tilt-elev: 0px;
    transform-style: preserve-3d;
    transform:
      perspective(900px)
      translate3d(0, calc(-1 * var(--tilt-elev)), 0)
      rotateX(var(--tilt-x))
      rotateY(var(--tilt-y));
    transition:
      transform 280ms var(--ease-spring-soft),
      box-shadow 200ms,
      border-color 200ms;
    transform-origin: center center;
    will-change: transform;
  }
  .watchlist-card:hover {
    --tilt-elev: 4px;
  }
  /* Inner elements lift on the Z axis (parallax depth) */
  .watchlist-card .watchlist-card-irr,
  .watchlist-card .sparkline {
    transform: translateZ(20px);
    transition: transform 300ms var(--ease-spring-soft);
  }
  .watchlist-card .watchlist-card-name {
    transform: translateZ(12px);
  }

  /* ---------- Chart skeleton via :has() (vanishes when canvas mounts) ---------- */
  .chart {
    position: relative;
  }
  .chart > .skeleton-fill {
    position: absolute;
    inset: 16px;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg,
      var(--surface-2) 0%,
      var(--surface-3) 50%,
      var(--surface-2) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
    pointer-events: none;
  }
  /* When ECharts has mounted (canvas or its internal div appears), hide skeleton */
  .chart:has(canvas) > .skeleton-fill {
    opacity: 0;
    animation-play-state: paused;
    transition: opacity 320ms var(--ease-out-quint);
  }

  /* ---------- Shared-element view transitions ---------- */
  .kpi-stage-name {
    view-transition-name: hero-portfolio-name;
  }
  /* Custom morph timing for the hero name */
  ::view-transition-old(hero-portfolio-name),
  ::view-transition-new(hero-portfolio-name) {
    animation-duration: 420ms;
    animation-timing-function: var(--ease-spring-soft);
  }

  /* ---------- Scroll-driven entrance (Chrome 115+) ---------- */
  @supports (animation-timeline: view()) {
    .watchlist-card,
    .risk-bento-cell,
    .insight-cell,
    .card-narrative,
    .card-targets {
      animation-name: v13ScrollIn;
      animation-fill-mode: both;
      animation-timing-function: linear;
      animation-timeline: view();
      animation-range: entry 0% cover 25%;
    }
    @keyframes v13ScrollIn {
      from { opacity: 0.55; transform: translateY(14px) scale(0.985); }
      to   { opacity: 1;    transform: translateY(0)    scale(1); }
    }
  }

  /* ---------- CSS anchor positioning (Chrome 125+) ---------- */
  @supports (anchor-name: --x) {
    .pt-cell { anchor-name: --pt-cell; }
    .pt-cell-tip {
      position-anchor: --pt-cell;
      position: fixed;
      top: anchor(bottom);
      left: anchor(left);
      right: anchor(right);
      margin-top: 6px;
    }
  }

  /* ---------- Native <dialog>-ready modal foundation (forward-compat) ---------- */
  dialog.report-dialog {
    border: 1px solid var(--hairline-3);
    border-radius: var(--radius-xl);
    padding: 0;
    background: var(--surface-1);
    color: var(--text-1);
    width: min(820px, 92vw);
    max-height: 86vh;
  }
  dialog.report-dialog::backdrop {
    background: oklch(0% 0 0 / 0.42);
    backdrop-filter: blur(8px);
  }

  /* ---------- popover (Chrome 114+) ready ---------- */
  [popover] {
    border: 1px solid var(--hairline-3);
    border-radius: var(--radius-md);
    background: var(--surface-1);
    box-shadow: var(--elevation-3);
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-2);
  }

  /* ---------- ⌘K — AI Ask hint chip in palette ---------- */
  .palette-input-wrap::after {
    content: '★ AI';
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: oklch(45% 0.20 285);
    background: linear-gradient(135deg, oklch(96% 0.04 285) 0%, oklch(90% 0.10 285) 100%);
    border: 1px solid oklch(82% 0.13 285);
  }

  /* ---------- accent-color (native form controls match brand) ---------- */
  :root { accent-color: var(--accent); }

  /* ---------- field-sizing: content (forward-compat) ---------- */
  @supports (field-sizing: content) {
    .palette-input { field-sizing: content; min-width: 320px; }
  }
}
