:root {
  /* Apple Graphite (Classic Dark) */
  --bg: #0b0f17;
  --bg-elev: #131924;
  --card: #18202e;
  --border: rgba(255, 255, 255, 0.09);
  --tx: #f5f7fa;
  --muted: #9ba6b8;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --up: #30d158;
  --up-bg: rgba(48, 209, 88, 0.14);
  --dn: #ff453a;
  --dn-bg: rgba(255, 69, 58, 0.14);
  --warn: #ffd60a;
  --sidebar-w: 244px;
}

.hero-kpi, .advisor-card {
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  font-variant-numeric: tabular-nums;
}
.hero-kpi:hover, .advisor-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}
@media (prefers-reduced-motion: reduce) {
  .hero-kpi, .advisor-card { transition: none; }
  .hero-kpi:hover, .advisor-card:hover { transform: none; }
}

body.light {
  /* Apple Daylight (Classic Light) */
  --bg: #f5f5f7;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --tx: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.10);
  --up: #15803d;
  --up-bg: rgba(21, 128, 61, 0.10);
  --dn: #dc2626;
  --dn-bg: rgba(220, 38, 38, 0.10);
}
body.theme-midnight {
  /* Slate Midnight (Institutional Navy) */
  --bg: #0a101d;
  --bg-elev: #111a2e;
  --card: #16223a;
  --border: rgba(148, 163, 184, 0.14);
  --tx: #e6edf7;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --up: #34d399;
  --dn: #fb7185;
}
body.theme-paper {
  /* Warm Paper (Editorial Light) */
  --bg: #faf7f2;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --border: rgba(28, 25, 23, 0.10);
  --tx: #1c1917;
  --muted: #57534e;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.10);
  --up: #15803d;
  --up-bg: rgba(21, 128, 61, 0.10);
  --dn: #b91c1c;
  --dn-bg: rgba(185, 28, 28, 0.10);
}
body.theme-oled {
  /* OLED Pitch Black */
  --bg: #000000;
  --bg-elev: #0b0d12;
  --card: #11151d;
  --border: rgba(255, 255, 255, 0.12);
  --tx: #f8fafc;
  --muted: #9ca3af;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --up: #22c55e;
  --dn: #ef4444;
}
body.light.theme-aqua {
  /* Aqua (Fresh Light): cool white surfaces, teal-blue accent */
  --bg: #eef6f8;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --border: rgba(8, 72, 92, 0.11);
  --tx: #0f2a33;
  --muted: #557079;
  --accent: #0891b2;
  --accent-soft: rgba(8, 145, 178, 0.11);
  --up: #0f8a5f;
  --up-bg: rgba(15, 138, 95, 0.10);
  --dn: #d9354a;
  --dn-bg: rgba(217, 53, 74, 0.10);
}
body.theme-ocean {
  /* Ocean Dark (Deep Teal) */
  --bg: #071a1f;
  --bg-elev: #0c252c;
  --card: #10303a;
  --border: rgba(125, 211, 222, 0.13);
  --tx: #e6f6f8;
  --muted: #8fb3ba;
  --accent: #22c3d6;
  --accent-soft: rgba(34, 195, 214, 0.16);
  --up: #34d399;
  --dn: #fb7185;
}
.typeahead-wrap { position: relative; display: inline-block; }
.typeahead-drop {
  position: absolute; top: 100%; left: 0; margin-top: 4px; z-index: 110;
  width: 310px; max-height: 320px; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--accent); border-radius: 10px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5); display: none;
}
.typeahead-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; padding: 7px 10px; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--tx); text-align: left; cursor: pointer; font-size: 12px;
}
.typeahead-item:hover { background: var(--accent-soft); }

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--tx);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  user-select: text; -webkit-user-select: text;
}

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; padding: 4px 8px 10px; }
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.nav-grp-title {
  font-size: 10.5px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 14px 8px 5px;
}
.nav-link {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; border: 0; background: transparent; color: var(--tx);
  padding: 7px 9px; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; text-align: left; text-decoration: none;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--accent-soft); }
.nav-link.active { background: var(--accent); color: #fff; }

/* Main column */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Persistent Top Command & Action Bar */
.top-ribbon {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  justify-content: space-between;
  backdrop-filter: blur(8px);
}
.ribbon-left, .ribbon-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.kpi-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 9px; padding: 4px 10px; font-size: 12px; font-weight: 700;
  text-decoration: none; color: var(--tx); cursor: pointer;
}
.kpi-pill:hover { border-color: var(--accent); }
.exit-link {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(16, 185, 129, 0.16));
  border-color: rgba(96, 165, 250, 0.45);
  color: #93c5fd;
}
body.light .exit-link { color: #1d4ed8; }

.tool-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border: 1px solid var(--border); color: var(--tx);
  border-radius: 8px; padding: 5px 9px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.tool-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.tool-btn:disabled { opacity: 0.38; cursor: not-allowed; }
/* Dropdown lists: native option popups ignore the select's colours on Windows/Chrome,
   so the names rendered white-on-white in dark themes. Give options the theme colours. */
select { color-scheme: light dark; }
select option, select optgroup { background: var(--card); color: var(--tx); }
/* 7D heatmap: greyed days before the position was opened; dashed = model-estimated option price */
.hm7 [data-pre] { color: var(--muted) !important; opacity: 0.75; }
.hm7 .hm7-model { outline: 1px dashed rgba(148,163,184,0.85); outline-offset: -1px; }
.hm7 [data-now] { outline: 2px solid var(--accent); outline-offset: -2px; font-weight: 800; }

.search-box {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px 8px;
}
.search-box input {
  background: transparent; border: 0; outline: 0; color: var(--tx);
  font-size: 12px; width: 170px;
}
.kbd {
  font-size: 10px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 4px;
}

/* Content Area */
.content { padding: 14px 18px 40px; max-width: 1520px; width: 100%; }
.page-hdr {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.page-hdr h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.meta-badge { font-size: 11.5px; color: var(--muted); }

/* Cards & Tables (Semantic HTML DOM for native Ctrl+F & Ctrl+C) */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
}
.card-title {
  font-size: 13.5px; font-weight: 800; margin: 0 0 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.tbl-wrap { overflow-x: auto; }
table.dt {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
table.dt th {
  text-align: left; font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.03em;
  padding: 6px 6px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.dt td {
  padding: 6px 6px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
}
table.dt tr:last-child td { border-bottom: none; }
table.dt tr:hover td { background: rgba(255, 255, 255, 0.025); }
table.dt tr.total-row td {
  font-weight: 800; border-top: 2px solid var(--border);
  background: rgba(59, 130, 246, 0.07);
}
table.dt th.n, table.dt td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.dt td.wrap { white-space: normal; min-width: 180px; }

.up { color: var(--up); font-weight: 700; }
.dn { color: var(--dn); font-weight: 700; }
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 700; border: 1px solid var(--border);
  background: var(--bg-elev);
}
.badge.long { background: var(--up-bg); color: var(--up); border-color: rgba(16, 185, 129, 0.3); }
.badge.short { background: var(--dn-bg); color: var(--dn); border-color: rgba(244, 63, 94, 0.3); }
.badge.accent { background: var(--accent-soft); color: #93c5fd; border-color: rgba(96, 165, 250, 0.35); }

/* 7D Heatmap boxes */
.hm7 { display: inline-flex; gap: 3px; align-items: center; }
.hm7-box {
  width: 11px; height: 14px; border-radius: 2px; display: inline-block;
}
.hm7-up { background: #10b981; }
.hm7-dn { background: #f43f5e; }

/* Search highlight & filtering */
mark.find-hit { background: #fde047; color: #111827; padding: 0 2px; border-radius: 2px; }
tr.search-hidden, .search-card-hidden { display: none !important; }

/* Metrics & Sentiment Grid */
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.grid-heatmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); gap: 8px; }
.hm-tile {
  border-radius: 10px; padding: 9px 10px; border: 1px solid var(--border);
  font-size: 12px;
}
.hm-tile.up-bg { background: rgba(16, 185, 129, 0.16); border-color: rgba(16, 185, 129, 0.35); }
.hm-tile.dn-bg { background: rgba(244, 63, 94, 0.16); border-color: rgba(244, 63, 94, 0.35); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.chip-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 90;
  background: #1e293b; color: #f8fafc; border: 1px solid var(--accent);
  border-radius: 10px; padding: 8px 14px; font-size: 12.5px; font-weight: 600;
  display: none; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

/* Contextual Help Pills, Chart Toolbars & Modals */
.q-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; font-size: 10.5px; font-weight: 800;
  background: var(--accent-soft); color: #93c5fd; border: 1px solid rgba(96, 165, 250, 0.4);
  cursor: help; position: relative;
}
.q-help:hover::after, .q-help:focus::after {
  content: attr(data-qhelp);
  position: absolute; left: 20px; top: -4px; z-index: 120;
  min-width: 220px; max-width: 300px; white-space: normal;
  background: #0f172a; color: #f8fafc; border: 1px solid var(--accent);
  border-radius: 8px; padding: 8px 10px; font-size: 11.5px; font-weight: 500;
  line-height: 1.4; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5); pointer-events: none;
}
.chart-tools { display: inline-flex; gap: 4px; align-items: center; }
.chart-tools .tool-btn { padding: 3px 7px; font-size: 11px; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2, 6, 23, 0.78); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 14px;
}
.modal-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}
.eagle-subtabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px;
  border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.eagle-tab {
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--muted);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.eagle-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* PDF / Print mode */
@media print {
  body { background: #fff !important; color: #000 !important; }
  .sidebar, .top-ribbon, .no-print, .toast { display: none !important; }
  .main-col, .content { max-width: 100% !important; width: 100% !important; padding: 0 !important; margin: 0 !important; }
  .card { border: 1px solid #cbd5e1 !important; background: #fff !important; break-inside: avoid; box-shadow: none !important; }
  table.dt th { color: #334155 !important; border-bottom: 1px solid #94a3b8 !important; }
  table.dt td { border-bottom: 1px solid #e2e8f0 !important; white-space: normal !important; }
  .up { color: #047857 !important; }
  .dn { color: #be123c !important; }
}

/* Options chain: header row stays visible while the table scrolls (2026-11-30) */
.chain-sticky thead th { position: sticky; top: 0; z-index: 3; background: var(--bg-elev, #111827); box-shadow: 0 1px 0 var(--border); }
/* Options chain: expiry / strike-span bar frozen while the page scrolls; compact rows so
   30 strikes fit one screen (user 2026-11-30). --eagle-pin-h = height of the pinned Eagle header. */
.chain-ctrl { position: sticky; top: var(--eagle-pin-h, 0px); z-index: 6; background: var(--card, var(--bg-elev, #111827)); padding: 6px 0; }
.chain-ctrl .chip-btn { padding: 2px 8px; font-size: 11px; }
.chain-sticky th { font-size: 10.5px; padding: 3px 6px; }
.chain-sticky td { font-size: 11px; padding: 2px 6px; line-height: 1.25; }
.chain-sticky td .badge { font-size: 9.5px; padding: 0 4px; }
.chain-read summary::-webkit-details-marker { color: var(--muted); }
