/* ─────────────────────────────────────────────────────────────────────────
   EdgeLab · Finance-terminal stylesheet
   Full standalone — no Pico, no reset dependency.
   Design: Linear / Vercel dashboard aesthetic — dark, dense, precise.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Font ────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/inter.woff2") format("woff2");
}

/* ── Design tokens ───────────────────────────────────────────────────────── */

:root,
:root[data-theme="dark"] {
  /* PNL Portfolio palette — dark */
  --bg:          #0b0c0e;
  --surface:     #15171b;
  --elevated:    #1d2026;
  --overlay:     rgba(11, 12, 14, 0.92);

  --border:        #22262d;
  --border-strong: #2d323b;

  --text:        #eef0f2;
  --text-muted:  #8a8f99;
  --text-faint:  #5a5f68;

  --up:          #4ade80;
  --up-2:        #22c55e;
  --up-bg:       rgba(74, 222, 128, 0.10);
  --down:        #f87171;
  --down-bg:     rgba(248, 113, 113, 0.10);
  --accent:      #4ade80;
  --accent-2:    #22c55e;
  --accent-bg:   rgba(74, 222, 128, 0.12);
  --warn:        #fbbf24;
  --blue:        #60a5fa;
  --gold:        #d4af37;

  --shadow-md:   0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 8px 24px rgba(74, 222, 128, 0.20);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-7:  32px;
  --s-8:  48px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-pill: 100px;
}

:root[data-theme="light"] {
  --bg:          #f7f8fa;
  --surface:     #ffffff;
  --elevated:    #ffffff;
  --overlay:     rgba(247, 248, 250, 0.92);

  --border:        #e4e6ea;
  --border-strong: #cbd0d8;

  --text:        #0b0c0e;
  --text-muted:  #5c6370;
  --text-faint:  #9098a3;

  --up:          #16a34a;
  --up-2:        #15803d;
  --up-bg:       rgba(22, 163, 74, 0.10);
  --down:        #dc2626;
  --down-bg:     rgba(220, 38, 38, 0.10);
  --accent:      #16a34a;
  --accent-2:    #15803d;
  --accent-bg:   rgba(22, 163, 74, 0.10);
  --warn:        #d97706;
  --blue:        #2563eb;
  --gold:        #a16207;

  --shadow-md:   0 6px 18px rgba(15, 20, 30, 0.08);
  --shadow-glow: 0 8px 24px rgba(22, 163, 74, 0.18);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */

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

html {
  font-size: 13px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 80ms ease;
}
a:hover { color: var(--accent-2); text-decoration: none; }

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
}

h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }

p { line-height: 1.5; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */

nav.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  background: var(--overlay);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-brand a {
  color: var(--accent);
  text-decoration: none;
}
.topbar-brand a:hover { color: var(--accent-2); }

.topbar-center {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: 1;
  justify-content: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-shrink: 0;
}

.topbar-clock {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.03em;
}

/* ── Topbar ticker search ───────────────────────────────────────────────────── */
.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.topbar-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  width: 280px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 250;
  padding: 4px;
}
.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.search-result:hover, .search-result.active {
  background: var(--elevated);
  color: var(--text);
}
.search-result .search-sym {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  min-width: 48px;
}
.search-result .search-sec {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.search-result .search-strat {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: auto;
}
.topbar-search input {
  height: 28px;
  width: 160px;
  padding: 0 10px;
  font: 400 12px/1 var(--font-mono);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 80ms;
}
.topbar-search input:focus {
  border-color: var(--accent);
}
.topbar-search input::placeholder {
  color: var(--text-faint);
}

/* ── Market phase pill ───────────────────────────────────────────────────── */

.phase {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.phase-session { animation: phase-pulse 2s ease-in-out infinite; }
@keyframes phase-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.75; } }
.phase-pre_open    { background: rgba(251,191,36,0.12);  color: #fbbf24; border-color: rgba(251,191,36,0.25); }
.phase-session     { background: rgba(74,222,128,0.12);  color: var(--up); border-color: rgba(74,222,128,0.25); }
.phase-post_market { background: rgba(251,146,60,0.12);  color: #fb923c; border-color: rgba(251,146,60,0.25); }
.phase-overnight   { background: var(--surface); color: var(--text-muted); border-color: var(--border-strong); }
.phase-closed      { background: var(--surface); color: var(--text-faint);  border-color: var(--border); }

/* ── Stats row (strategy tiles) ──────────────────────────────────────────── */

.stats-row {
  display: flex;
  gap: 6px;
  padding: 6px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.stats-row::-webkit-scrollbar { display: none; }

.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 72px;
  height: auto;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.stat-tile:hover {
  background: var(--elevated);
  border-color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}
.stat-tile.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.stat-tile-abbr {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
}

.stat-tile-count {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-tile-split {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  line-height: 1;
}
.stat-tile-split .up-n   { color: var(--up); }
.stat-tile-split .down-n { color: var(--down); }

.stat-tile { min-height: 64px; }
.stat-tile-count { font-size: 20px; }
.stat-tile-abbr, .stat-tile-split, .stat-tile-pnl { line-height: 1.1; }
.stat-tile-pnl {
  font: 500 11px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.stat-tile-pnl.pct-up   { color: var(--up); }
.stat-tile-pnl.pct-down { color: var(--down); }


/* ── Cards ───────────────────────────────────────────────────────────────── */

article.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-4);
  overflow: hidden;
  transition: border-color 120ms ease, transform 120ms ease;
}
article.card:hover { border-color: var(--border-strong); }

article.card > header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.card-title a {
  color: var(--text);
  transition: color 80ms ease;
}
.card-title a:hover { color: var(--accent); }

.card-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
}

/* Stack side-by-side columns below 1100px */
@media (max-width: 1100px) {
  .card-grid.card-grid-split { grid-template-columns: 1fr; }
  .card-grid.card-grid-split .card-section { border-right: none; border-bottom: 1px solid var(--border); }
  .card-grid.card-grid-split .card-section:last-child { border-bottom: none; }
}

.card-section {
  padding: 0;
  border-right: 1px solid var(--border);
}
.card-section:last-child { border-right: none; }

/* Full-width single-table mode */
.card-section-full {
  border-right: none;
  width: 100%;
}

.card-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--s-2) var(--s-3);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* ── Tables (PNL Portfolio style, dense for scan lists) ─────────────────── */

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

thead th {
  text-align: left;
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th.num { text-align: right; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 100ms ease;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
:root[data-theme="light"] tbody tr:hover { background: rgba(15, 20, 30, 0.03); }

tbody td {
  padding: 6px 10px;
  vertical-align: middle;
  line-height: 1.4;
}
tbody td:first-child, thead th:first-child { padding-left: 14px; }
tbody td:last-child,  thead th:last-child  { padding-right: 14px; }

td.num, th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ── Scrollable table container ──────────────────────────────────────────── */

.table-scroll {
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll::-webkit-scrollbar { width: 4px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

/* PNL-style: utility buttons are mono, transparent, hover→accent border+color */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.03em;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: wait; pointer-events: none; }

/* CTA-style: filled accent, rounded pill */
.btn-primary {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 8px 16px;
  color: #05120a;
  background: var(--accent);
  border-color: var(--accent);
  border-radius: var(--r-pill);
}
.btn-primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #05120a;
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.btn-sm { padding: 4px 10px; font-size: 10px; }

/* ── HTMX loading indicator ──────────────────────────────────────────────── */

.htmx-indicator {
  display: none;
  opacity: 0.7;
}
.htmx-request .htmx-indicator {
  display: inline-block;
}
.htmx-request .btn-label {
  opacity: 0.5;
}

/* ── Action row & result pill ────────────────────────────────────────────── */

.action-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  padding: var(--s-3) 0 var(--s-4);
}

.action-row {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
}

.action-result {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px var(--s-2);
  border-radius: 4px;
  margin-left: 6px;
  line-height: 1;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-result:empty { display: none; }

.action-result-ok       { color: var(--up);         background: var(--up-bg); }
.action-result-error    { color: var(--down);        background: var(--down-bg); }
.action-result-cooldown { color: var(--text-muted);  background: var(--surface); border: 1px solid var(--border); }

/* ── Filter chips ────────────────────────────────────────────────────────── */

.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  align-items: center;
}
.pill-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
.filter-label {
  font: 600 9px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-right: 6px;
  user-select: none;
}
.chip.up.active   { background: var(--up-bg);   border-color: var(--up);   color: var(--up); }
.chip.down.active { background: var(--down-bg); border-color: var(--down); color: var(--down); }
.chip.quality-pass.active     { background: var(--up-bg);   border-color: var(--up);   color: var(--up); }
.chip.quality-near_miss.active{ background: rgba(255,159,10,0.15); border-color: var(--warn); color: var(--warn); }

.chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}
.chip:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}
.chip.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.filter-sep {
  color: var(--border-strong);
  font-size: 14px;
  padding: 0 var(--s-1);
  user-select: none;
}

/* ── Sortable column headers ─────────────────────────────────────────────── */

thead th a {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: color 80ms ease;
}
thead th a:hover { color: var(--text); }
thead th a.sort-active { color: var(--accent); }

.sort-arrow {
  font-size: 9px;
  opacity: 0.8;
}

/* ── Inline elements / chips ─────────────────────────────────────────────── */

.ticker {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  letter-spacing: 0.02em;
}
.ticker:hover { color: var(--accent); }
a.ticker { color: var(--text); }
a.ticker:hover { color: var(--accent); }

.sector {
  display: inline-block;
  background: var(--elevated);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
}

span.side-up, span.side-down, span.side-other {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
}
span.side-up    { color: var(--up);   background: var(--up-bg);   border: 1px solid rgba(74,222,128,0.20); }
span.side-down  { color: var(--down); background: var(--down-bg); border: 1px solid rgba(248,113,113,0.20); }
span.side-other { color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); }

.pct-up   { color: var(--up); }
.pct-down { color: var(--down); }

/* PNL .tside pill style — ONLY for inline labels, not whole rows */
span.side-up, span.side-down, span.side-other {
  display: inline-block;
  font: 700 10px/1 var(--font-mono);
  letter-spacing: 0.1em;
  padding: 3px 7px;
  border-radius: 4px;
}
span.side-up    { background: rgba(74, 222, 128, 0.15); color: var(--up); }
span.side-down  { background: rgba(248, 113, 113, 0.15); color: var(--down); }
span.side-other { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }
:root[data-theme="light"] span.side-up    { background: rgba(22, 163, 74, 0.12); }
:root[data-theme="light"] span.side-down  { background: rgba(220, 38, 38, 0.12); }
:root[data-theme="light"] span.side-other { background: rgba(15, 20, 30, 0.06); }

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--text-muted); }

/* ── Page header ─────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0 10px;
  margin-bottom: 8px;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-header .muted {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.page-header-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.page-header-meta > * { display: inline-flex; align-items: baseline; gap: 4px; }
.page-header-meta > * + *::before {
  content: "·";
  color: var(--text-faint);
  margin-right: 6px;
}

/* ── Back / breadcrumb links ─────────────────────────────────────────────── */

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--s-3);
  margin-top: var(--s-3);
  transition: color 80ms ease;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ── Quote header (ticker detail) ────────────────────────────────────────── */

.quote-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-3);
  padding: var(--s-4) 0 var(--s-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-4);
}

.quote-symbol {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.02em;
}

.quote-price {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.quote-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  font-size: 13px;
  color: var(--text-muted);
}
.quote-meta .sep { color: var(--border-strong); }

/* ── Section labels ──────────────────────────────────────────────────────── */

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--s-2) 0 var(--s-1);
}

/* ── Date group headings ─────────────────────────────────────────────────── */

.date-group {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--s-3) var(--s-3) var(--s-1);
  border-top: 1px solid var(--border);
  margin-top: var(--s-3);
}
.date-group:first-child { border-top: none; margin-top: 0; }

/* ── History divider row ─────────────────────────────────────────────────── */

tr.divider-row td {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--s-2) var(--s-3) var(--s-1);
  border-top: 2px solid var(--border-strong);
}

/* ── Today badge ─────────────────────────────────────────────────────────── */

.badge-today {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--accent-bg);
  border: 1px solid rgba(124,147,255,0.25);
  color: var(--accent);
  vertical-align: middle;
  margin-left: 4px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  padding: var(--s-3) 0;
  font-style: italic;
}
.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-style: normal;
  margin: 16px 0;
}
.empty-state-icon {
  font-size: 40px;
  color: var(--text-faint);
  line-height: 1;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 4px 0 0;
}
.empty-state-body {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.6;
}
.empty-state-body a { color: var(--accent); }
.empty-state-body .mono { font-family: var(--font-mono); color: var(--text); }
.empty-state-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

/* Next-scan banner above the home grid */
.next-scan-banner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  margin: 8px 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.next-scan-banner::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: nextScanPulse 2.4s ease-out infinite;
}
@keyframes nextScanPulse {
  0%   { box-shadow: 0 0 0 0 rgba(99, 209, 255, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(99, 209, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 209, 255, 0); }
}
.next-scan-banner .banner-label {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 10px;
  text-transform: uppercase;
}
.next-scan-banner .banner-time { color: var(--text); font-weight: 600; }
.next-scan-banner .banner-eta { color: var(--warn); font-weight: 500; }
.next-scan-banner .banner-name { color: var(--text-muted); }

/* SSE toast — PNL .toast style */
.sse-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--accent);
  color: #05120a;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  z-index: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sse-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sse-toast-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #05120a;
  animation: phase-pulse 1.2s ease-in-out infinite;
}

/* ── Details/summary accordion ───────────────────────────────────────────── */

details > summary {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: var(--s-2) var(--s-3);
  list-style: none;
  user-select: none;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 80ms ease;
}
details > summary:hover { color: var(--text); }
details > summary::before {
  content: "▶";
  font-size: 8px;
  opacity: 0.6;
}
details[open] > summary::before { content: "▼"; }

/* ── HTMX swap fade-in ───────────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.htmx-added {
  animation: fadeIn 120ms ease forwards;
}

/* ── Catastrophe Explore filter panel ───────────────────────────────────── */

.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--s-4);
  margin-bottom: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-3);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group > label {
  font: 500 11px/1 var(--font-sans);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-group input[type=number],
.filter-group select {
  height: 28px;
  padding: 0 10px;
  font: 500 12px/1 var(--font-sans);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  appearance: none;
  -webkit-appearance: none;
}
.filter-group select { padding-right: 24px; }
.filter-group input[type=number]:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
}
/* chips inside a filter group reuse .chip but need override for radio behavior */
.filter-group .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.filter-group .chip {
  font: 500 11px/1 var(--font-mono);
  padding: 5px 10px;
  height: auto;
  border-radius: 4px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 80ms, color 80ms, border-color 80ms;
}
.filter-group .chip:hover {
  color: var(--text);
  background: var(--surface);
}
.filter-group .chip-active {
  color: var(--accent);
  background: var(--accent-bg);
  border-color: var(--accent-bg);
}
.filter-actions {
  display: flex;
  gap: var(--s-2);
  padding-top: var(--s-1);
}
.explore-count {
  font-size: 12px;
  margin-bottom: var(--s-3);
}

/* Status pills — PNL .tside style */
.status-pill {
  display: inline-block;
  font: 700 10px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  white-space: nowrap;
}
:root[data-theme="light"] .status-pill { background: rgba(15, 20, 30, 0.05); }
.status-pass,
.status-good            { color: var(--up);   background: var(--up-bg); }
.status-near_miss_ev,
.status-near_miss_edge,
.status-near_miss_evl,
.status-warn            { color: var(--warn); background: rgba(251, 191, 36, 0.15); }
.status-dup             { color: var(--text-muted); }
.status-no_chain,
.status-no_strike,
.status-no_delta,
.status-spread,
.status-be_ma200,
.status-dte_greeks,
.status-mute            { color: var(--text-faint); background: transparent; }

/* ── Outcomes strip in card header ──────────────────────────────────────── */

.card-outcomes {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 6px 16px 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Trade tickets — actionable rows below each PASS pick ────────────────── */

tr.ticket-row { background: var(--bg); }
tr.ticket-row td { padding: 0; border-bottom: 1px solid var(--border); }
tr.ticket-row:hover { background: var(--bg); }

.ticket {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--elevated);
  border-left: 2px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

.ticket-order {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  flex-shrink: 0;
}

.ticket-action {
  font-weight: 700;
  color: var(--down);
  padding: 2px 6px;
  background: rgba(248, 113, 113, 0.15);
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.ticket-action-long {
  color: var(--up);
  background: var(--up-bg);
  border-color: rgba(74, 222, 128, 0.20);
}

.ticket-qty   { color: var(--text-muted); font-size: 12px; }
.ticket-meta  { color: var(--text-muted); font-size: 11px; }
.ticket-strike { font-weight: 600; }
.ticket-price  { color: var(--text); font-weight: 600; }

.ticket-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.ticket-stats .stat { display: inline-flex; align-items: center; gap: 4px; }
.ticket-stats .stat-label {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
}

.ticket-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.btn-small {
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: 4px;
}

.ticket-compact {
  padding: 6px 16px;
  gap: 10px;
  background: linear-gradient(to right, rgba(124,147,255,0.06), transparent 30%);
}

.action-result-slot {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .card-grid { grid-template-columns: 1fr; }
  .card-section { border-right: none; border-bottom: 1px solid var(--border); }
  .card-section:last-child { border-bottom: none; }
  nav.topbar { padding: 0 var(--s-3); height: 48px; }
  .topbar-brand { font-size: 13px; }
  .stats-row { flex-wrap: nowrap; padding: var(--s-1) var(--s-3); gap: var(--s-1); }
  .container { padding: 0 var(--s-3) var(--s-6); }
  thead th { font-size: 10px; padding: var(--s-1) var(--s-2); }
  tbody td { font-size: 12px; padding: var(--s-1) var(--s-2); }
  .hide-mobile { display: none !important; }
  .page-header h2 { font-size: 18px; }
  .quote-symbol { font-size: 24px; }
  /* On mobile, hide per-card fine-grained filters — tap into the
     strategy detail page for full filtering. */
  .card-toolbar { display: none; }
  /* Compact strategy-card meta line */
  .card-meta { font-size: 11px; }
}

/* ── Pick-row click affordance ──────────────────────────────────────────── */
tr.pick-row { transition: background 80ms; }
tr.pick-row:hover { background: var(--elevated); cursor: pointer; }
tr.pick-row.htmx-request { opacity: 0.7; }

/* ── Detail drawer ──────────────────────────────────────────────────────── */
tr.detail-row > td {
  padding: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border-strong);
}
.detail-panel {
  position: relative;
  padding: 16px 20px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}
.detail-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 400 16px/1 var(--font-mono);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.detail-close:hover { color: var(--text); border-color: var(--border-strong); }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px 24px;
  font-size: 12px;
}
.detail-section { padding: 0; }
.detail-label {
  font: 600 10px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.detail-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.detail-rows > span {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}
.detail-rows .muted {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 56px;
}
.detail-placeholder { display: none; }

/* ── Outcomes section ─────────────────────────────────────────────────────── */
.outcomes-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.section-title {
  font: 600 18px/1.2 var(--font-sans);
  margin-bottom: 16px;
  color: var(--text);
}
.section-title .muted {
  font: 400 12px/1 var(--font-mono);
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.subsection-title {
  font: 600 11px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 24px 0 8px;
}
.outcomes-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-label {
  font: 600 10px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.stat-card-value {
  font: 600 16px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-card-value.pct-up   { color: var(--up); }
.stat-card-value.pct-down { color: var(--down); }
.stat-card-value .ticker { font-size: 14px; }
.stat-card-value .pct-up,
.stat-card-value .pct-down { font-size: 13px; margin-left: 4px; }

/* Daily mean bar chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 12px 8px;
  overflow-x: auto;
}
.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 18px;
  max-width: 32px;
  flex: 0 1 32px;
}
.bar-wrap {
  height: 100px;
  width: 100%;
  position: relative;
}
.bar-wrap::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.bar {
  width: 80%;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 1px;
  transition: filter 80ms;
}
.bar:hover { filter: brightness(1.2); }
.bar.bar-up   { background: var(--up);   bottom: 50%; }
.bar.bar-down { background: var(--down); top: 50%; }
.bar-label {
  font: 500 9px/1 var(--font-mono);
  color: var(--text-faint);
  white-space: nowrap;
}

/* Sector table */
.sector-table { width: 100%; max-width: 400px; }

/* Top/bottom grid */
.best-worst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 16px;
}
.pick-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.pick-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.pick-list li .muted {
  flex: 1;
  font-size: 10px;
  color: var(--text-faint);
}

/* ── App shell (sidebar + main) ─────────────────────────────────────────── */

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

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-main .container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: var(--s-5) var(--s-6) var(--s-7);
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 var(--s-5);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(74,222,128,0.05), transparent);
}
.sidebar-brand a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sidebar-brand a::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent);
}
.sidebar-brand a { color: var(--accent); }
.sidebar-brand .brand-icon { display: none; font-family: var(--font-mono); font-size: 13px; }

.sidebar-section {
  padding: var(--s-3) var(--s-2);
  border-bottom: 1px solid var(--border);
}

.sidebar-section-title {
  font: 600 9px/1 var(--font-mono);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 var(--s-2) 8px;
}

.sidebar-strategy {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
  transition: background 100ms ease, color 100ms ease;
  min-height: 36px;
}
.sidebar-strategy + .sidebar-strategy { margin-top: 2px; }
.sidebar-strategy:hover {
  background: var(--elevated);
  text-decoration: none;
}
.sidebar-strategy.active {
  background: var(--accent-bg);
  color: var(--text);
}
.sidebar-strategy.active::before {
  content: "";
  position: absolute;
  left: 3px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.sidebar-strategy .nav-icon {
  width: 16px;
  text-align: center;
  color: var(--text-muted);
  flex: 0 0 16px;
  font-family: var(--font-mono);
  font-size: 14px;
}
.sidebar-strategy.active .nav-icon { color: var(--accent); }
.sidebar-strategy .status-pulse {
  width: 8px; height: 8px;
  flex: 0 0 8px;
  margin: 0;
}
.sidebar-strategy-label {
  flex: 1 1 auto;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-strategy-count {
  flex: 0 0 auto;
  font: 600 11px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
}
.sidebar-strategy.active .sidebar-strategy-count {
  color: var(--accent);
  background: rgba(74,222,128,0.12);
  border-color: rgba(74,222,128,0.30);
}

.sidebar-actions { display: flex; flex-direction: column; gap: var(--s-2); }
.sidebar-actions .action-bar,
.sidebar-actions .action-row { display: flex; flex-direction: column; gap: var(--s-2); }
.sidebar-actions .btn { width: 100%; justify-content: center; }

.sidebar-account {
  margin-top: auto;
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: 4px;
  column-gap: var(--s-3);
  font-size: 12px;
}
.sidebar-account-label { color: var(--text-muted); font: 500 10px/1.4 var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase; align-self: center; }
.sidebar-account-value { color: var(--text); font: 500 12px/1.4 var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.sidebar-account-value.pct-up   { color: var(--up); }
.sidebar-account-value.pct-down { color: var(--down); }

/* ── Toggle (collapsed icon-rail) ───────────────────────────────────────── */

.sidebar-toggle {
  position: absolute;
  top: 14px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  z-index: 210;
}
.sidebar-toggle:hover { color: var(--text); }


/* Brand + admin stay pinned; single scroll area in between. */
.sidebar-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.sidebar-body::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.sidebar-strategy-label {
  display: inline-flex; align-items: center; gap: 6px;
}
.sidebar-strategy-label .status-pulse {
  width: 6px; height: 6px; margin: 0;
}
.sidebar-strategy-meta .meta-total { color: var(--text-muted); }

/* Status panel rows — fixed 3-col grid so time / label / ETA align. */
.status-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.status-row {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 18px;
  font: 500 11px/1.3 var(--font-mono);
  color: var(--text);
  border-radius: 6px;
}
.status-row::before {
  content: "";
  position: absolute;
  left: 8px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.status-row.status-row-done::before { background: var(--text-faint); }
.status-row .status-time  { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.status-row .status-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.status-row .status-eta   { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.status-row .status-eta.status-soon { color: var(--warn); font-weight: 600; }
.status-row .status-eta.status-done { color: var(--up); }
.status-row.status-row-done .status-label { color: var(--text-muted); }

.sidebar-admin {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  border-bottom: none;
}
.sidebar-admin > summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 4px;
  padding: var(--s-2) var(--s-3);
  user-select: none;
}
.sidebar-admin > summary::-webkit-details-marker { display: none; }
.sidebar-admin[open] > summary { color: var(--text); }
.sidebar-admin .sidebar-actions { padding: var(--s-2) var(--s-3) var(--s-3); }


body.sidebar-collapsed .sidebar { width: 56px; }
body.sidebar-collapsed .sidebar-brand { padding: 0; justify-content: center; }
body.sidebar-collapsed .sidebar-brand .brand-text { display: none; }
body.sidebar-collapsed .sidebar-brand .brand-icon { display: inline; }
body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-strategy-label,
body.sidebar-collapsed .sidebar-strategy-meta,
body.sidebar-collapsed .sidebar-account,
body.sidebar-collapsed .sidebar-actions .btn-label { display: none; }
body.sidebar-collapsed .sidebar-strategy { grid-template-columns: 1fr; justify-items: center; }

@media (max-width: 1100px) {
  .sidebar { width: 56px; }
  .sidebar-brand { padding: 0; justify-content: center; }
  .sidebar-brand .brand-text { display: none; }
  .sidebar-brand .brand-icon { display: inline; }
  .sidebar-section-title,
  .sidebar-strategy-label,
  .sidebar-strategy-meta,
  .sidebar-account,
  .sidebar-actions .btn-label,
  .sidebar-admin > summary,
  .status-label,
  .status-eta { display: none; }
  .sidebar-strategy { grid-template-columns: 1fr; justify-items: center; }
  .sidebar-toggle { display: none; }
  .status-row { grid-template-columns: 1fr; justify-items: center; }
}

/* ── Card toolbar (segmented) ───────────────────────────────────────────── */

.card-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--border);
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.segmented-label {
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-right: 4px;
}
.segmented-pill {
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 5px;
  background: transparent;
  text-decoration: none;
}
.segmented-pill:hover { background: var(--elevated); color: var(--text); }
.segmented-pill.active {
  background: var(--accent-bg);
  color: var(--accent);
}

/* ── Today grid ─────────────────────────────────────────────────────────── */

#card-section.card-grid-today {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(540px, 1fr));
  gap: var(--s-4);
}
@media (max-width: 1100px) {
  #card-section.card-grid-today { grid-template-columns: 1fr; }
}

.card-view-all {
  display: block;
  padding: 8px var(--s-4);
  border-top: 1px solid var(--border);
  font: 500 11px/1 var(--font-mono);
  color: var(--text-muted);
  text-align: center;
}
.card-view-all:hover { color: var(--accent); background: var(--elevated); text-decoration: none; }

/* ── Strategy detail 2-col layout ───────────────────────────────────────── */

.detail-grid {
  display: block;
  align-items: start;
}

.detail-main { min-width: 0; }
.detail-rail-wrap {
  margin-top: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.detail-rail-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 100ms ease;
}
.detail-rail-summary::-webkit-details-marker { display: none; }
.detail-rail-summary:hover { background: var(--elevated); }
.detail-rail-summary::after {
  content: "+";
  float: right;
  font-size: 18px;
  color: var(--text-muted);
  line-height: 1;
  transition: transform 200ms ease;
}
.detail-rail-wrap[open] .detail-rail-summary::after { transform: rotate(45deg); }
.detail-rail-wrap[open] .detail-rail-summary { border-bottom: 1px solid var(--border); }
.detail-rail-summary .muted { font-weight: 400; }
.detail-rail {
  margin: 0;
  padding: 16px 18px;
  border-top: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-rail .stat-list {
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: 4px;
  column-gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.detail-rail .stat-list-label { font: 500 10px/1.4 var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); align-self: center; }
.detail-rail .stat-list-value { font: 600 13px/1.4 var(--font-mono); color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

.detail-rail .bar-chart-rail .bar-col { width: 14px; }
.detail-rail .bar-chart-rail .bar-label { font-size: 9px; }

.filter-row.sticky-filter {
  position: sticky;
  top: 48px;
  z-index: 50;
  background: var(--bg);
  padding-top: 6px;
  padding-bottom: 6px;
}

/* Sticky elements live inside .app-main; their `top:0` is the flex column. */
.app-main nav.topbar { position: sticky; top: 0; z-index: 200; }

/* ── Sidebar status panel ───────────────────────────────────────────────── */

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.status-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: var(--s-2);
  padding: 4px var(--s-2);
  border-radius: 5px;
  font-size: 11px;
  color: var(--text);
}
.status-row + .status-row { border-top: 1px solid var(--border); padding-top: 6px; }
.status-time {
  font: 600 11px/1 var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.status-label { font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-eta {
  font: 500 10px/1 var(--font-mono);
  color: var(--accent);
  text-align: right;
  white-space: nowrap;
}
.status-eta.status-soon { color: var(--warn); }
.status-done { color: var(--up); }
.status-row-done { opacity: 0.65; }

/* Sidebar Admin (collapsible details) */
.sidebar-admin { padding-bottom: var(--s-3); }
.sidebar-admin > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.sidebar-admin > summary::-webkit-details-marker { display: none; }
.sidebar-admin > summary::before { content: "▸ "; font-size: 9px; color: var(--text-faint); margin-right: 4px; }
.sidebar-admin[open] > summary::before { content: "▾ "; }
.sidebar-admin > summary .muted { color: var(--text-faint); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 9px; }
.sidebar-admin .sidebar-actions { margin-top: var(--s-2); }

body.sidebar-collapsed .sidebar-admin > summary,
body.sidebar-collapsed .status-label,
body.sidebar-collapsed .status-eta { display: none; }
body.sidebar-collapsed .status-row { grid-template-columns: 1fr; justify-items: center; }
/* ── Card header — stacked rows (overrides original single-row flex) ────── */

article.card > header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.card-header-top {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  min-width: 0;
}
.card-header-top .card-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-header-top .card-count {
  flex-shrink: 0;
  font: 600 12px/1 var(--font-mono);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.card-header-top .card-count .pct-up,
.card-header-top .card-count .pct-down { font-weight: 600; }

.card-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  font: 500 10px/1.4 var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.card-status-time { color: var(--text); }
.card-status-sep  { color: var(--text-faint); }
.card-status-eta {
  color: var(--accent);
  margin-left: 2px;
}
.card-status-eta.status-soon { color: var(--warn); }

/* ── Toolbar inside card — keep on one row, allow horizontal scroll ─────── */

.card-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  padding: 6px 0 0;
  border-top: 1px solid var(--border);
  border-bottom: none;
  margin-top: 2px;
}
.card-toolbar .segmented { gap: 2px; }
.card-toolbar .segmented-pill { padding: 3px 6px; font-size: 10px; }
.card-toolbar .segmented-label { font-size: 9px; margin-right: 2px; }

/* ── Status list rows — stack label over time so ETA never collides ─────── */

.status-row {
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  row-gap: 1px;
  padding: 5px var(--s-2);
}
.status-row .status-time {
  grid-column: 1;
  grid-row: 2;
  font-size: 10px;
  color: var(--text-faint);
}
.status-row .status-label {
  grid-column: 1;
  grid-row: 1;
  font-size: 11px;
  color: var(--text);
}
.status-row .status-eta {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 10px;
}

/* Sidebar admin summary alignment */
.sidebar-admin > summary { padding: 0 var(--s-2); }
.sidebar-admin > summary .muted { font-size: 9px; }

/* ── Glossary block ──────────────────────────────────────────────────── */
.glossary {
  margin: 0 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
}
.glossary > summary {
  cursor: pointer;
  padding: 8px 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  user-select: none;
}
.glossary > summary:hover { color: var(--text); }
.glossary[open] > summary { border-bottom: 1px solid var(--border); }
.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  padding: 12px 16px 16px;
}
.glossary-col h4 {
  font: 600 11px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.glossary-col dl { margin: 0; }
.glossary-col dt {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  margin: 6px 0 2px;
}
.glossary-col dd {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

/* External chain link in catastrophe table */
a.ext-link {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-mono);
}
a.ext-link:hover { text-decoration: underline; }

/* Freshness color band on row left edge */
tr.pick-row.fresh-new  { box-shadow: inset 3px 0 0 var(--up); }
tr.pick-row.fresh-warm { box-shadow: inset 3px 0 0 var(--warn); }
tr.pick-row.fresh-cold { box-shadow: inset 3px 0 0 var(--text-faint); }
tr.pick-row.fresh-stale { box-shadow: inset 3px 0 0 var(--text-faint); opacity: 0.85; }

/* ── Diversifier basket builder ─────────────────────────────────────────── */
.diversifier-bar {
  position: sticky;
  top: 100px;
  z-index: 49;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  margin: 8px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font: 500 12px/1 var(--font-sans);
}
.diversifier-bar[data-empty="1"] { opacity: 0.7; }
.diversifier-bar .div-label {
  font-weight: 700;
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.diversifier-bar .div-count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.diversifier-bar .div-money {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.diversifier-bar .div-money strong { font-weight: 600; color: var(--text); }
.diversifier-bar .div-money .up-n { color: var(--up); }
.diversifier-bar .div-money .down-n { color: var(--down); }
.diversifier-bar .div-tally { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; min-width: 0; }
.diversifier-bar .div-tally .sec-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  font: 500 10px/1.6 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.diversifier-bar .div-tally .sec-tag.over {
  background: var(--down-bg);
  color: var(--down);
  border-color: rgba(248,113,113,0.35);
}
.diversifier-bar .div-flag { font: 600 11px/1 var(--font-mono); letter-spacing: 0.02em; }
.diversifier-bar .div-flag.ok { color: var(--up); }
.diversifier-bar .div-flag.warn { color: var(--down); }
.diversifier-bar .btn-sm { padding: 3px 10px; font-size: 10px; border-radius: 999px; }
td.div-col, th.div-col { width: 28px; text-align: center; padding-left: 4px; padding-right: 4px; }
td.div-col input { cursor: pointer; }

.crowd-pill { padding: 1px 6px; border-radius: 8px; font-variant-numeric: tabular-nums; font-weight: 600; }
.crowd-pill.crowd-low  { background: rgba(52,199,89,0.18);  color: var(--up); }
.crowd-pill.crowd-med  { background: rgba(255,159,10,0.18); color: var(--warn); }
.crowd-pill.crowd-high { background: rgba(255,69,58,0.18);  color: var(--down); }

.crowd-cell { min-width: 78px; }
.crowd-bar {
  position: relative;
  display: inline-block;
  width: 62px;
  height: 18px;
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.crowd-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 4px;
}
.crowd-bar.crowd-low  .crowd-bar-fill { background: rgba(52,199,89,0.35); }
.crowd-bar.crowd-med  .crowd-bar-fill { background: rgba(255,159,10,0.35); }
.crowd-bar.crowd-high .crowd-bar-fill { background: rgba(255,69,58,0.35); }
.crowd-bar-val {
  position: relative;
  z-index: 1;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  color: var(--text);
}
.crowd-bar.crowd-low  .crowd-bar-val { color: var(--up); }
.crowd-bar.crowd-med  .crowd-bar-val { color: var(--warn); }
.crowd-bar.crowd-high .crowd-bar-val { color: var(--down); }

/* Picks tickers slightly smaller in dense tables to match new font-size */
.detail-main .ticker { font-size: 13px; }
.detail-main .crowd-cell { min-width: 64px; }
.detail-main .crowd-bar { width: 54px; height: 14px; }
.detail-main .crowd-bar-val { font-size: 10px; line-height: 14px; padding: 0 4px; }

/* Diversifier bar — stack under filter-row */
.diversifier-bar.sticky-diversifier { top: 100px; }
.diversifier-bar { padding: 6px 12px; font-size: 11px; margin: 4px 0; }
.diversifier-bar .div-tally .sec-tag { padding: 1px 6px; font-size: 10px; }

/* ── Theme toggle button ────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
:root[data-theme="dark"] .theme-icon-light { display: none; }
:root[data-theme="light"] .theme-icon-dark { display: none; }

/* ── Light-theme refinements (subtle shadows replace dark borders) ──────── */
:root[data-theme="light"] article.card,
:root[data-theme="light"] .stat-tile,
:root[data-theme="light"] .filter-group,
:root[data-theme="light"] .diversifier-bar {
  box-shadow: 0 1px 2px rgba(15, 20, 30, 0.04);
}
:root[data-theme="light"] .topbar { background: rgba(255, 255, 255, 0.92); }
:root[data-theme="light"] tr.pick-row.fresh-cold { opacity: 1; }
:root[data-theme="light"] tr.pick-row.fresh-stale { opacity: 0.85; }
:root[data-theme="light"] .crowd-bar { background: rgba(11, 12, 14, 0.05); }

/* ── Chart overlay ───────────────────────────────────────────────────── */
#chart-overlay-toggle.is-off { opacity: 0.45; }
#chart-overlay-toggle .chart-icon { font-size: 0.95em; }

.chart-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.chart-overlay[hidden] { display: none; }
.chart-overlay-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}
.chart-overlay-panel {
  position: relative;
  width: min(1100px, 94vw);
  height: min(720px, 86vh);
  background: var(--bg, #0b0c0e);
  border: 1px solid var(--border, #2a2d33);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.chart-overlay-head {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border, #2a2d33);
  background: rgba(255,255,255,0.02);
}
.chart-overlay-sym {
  font-weight: 700; letter-spacing: 0.04em;
  font-size: 0.95rem;
}
.chart-overlay-pos {
  font-size: 0.72rem; opacity: 0.55; font-variant-numeric: tabular-nums;
}
.chart-overlay-nav {
  background: transparent; border: 1px solid var(--border, #2a2d33);
  color: inherit; cursor: pointer;
  width: 1.7em; height: 1.7em; padding: 0;
  border-radius: 4px; line-height: 1; font-size: 0.95rem;
  opacity: 0.75;
}
.chart-overlay-nav:hover:not(:disabled) { opacity: 1; }
.chart-overlay-nav:disabled { opacity: 0.25; cursor: default; }
.chart-overlay-open {
  margin-left: auto;
  font-size: 0.78rem; opacity: 0.75;
  text-decoration: none;
}
.chart-overlay-open:hover { opacity: 1; }
.chart-overlay-close {
  background: transparent; border: 0; color: inherit;
  font-size: 1rem; cursor: pointer; padding: 0 0.35rem;
  opacity: 0.7;
}
.chart-overlay-close:hover { opacity: 1; }
.chart-overlay-frame { flex: 1 1 auto; background: #000; }
.chart-overlay-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

:root[data-theme="light"] .chart-overlay-panel { background: #fff; }
:root[data-theme="light"] .chart-overlay-backdrop { background: rgba(20,22,28,0.45); }

/* ── Catastrophe filter drawer (folded into strategy detail page) ─── */
.filter-drawer { margin: 0.5rem 0 0.75rem; }
.filter-drawer-summary {
  cursor: pointer; list-style: none;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border, #2a2d33);
  border-radius: 6px;
  font-size: 0.85rem; user-select: none;
}
.filter-drawer-summary::-webkit-details-marker { display: none; }
.filter-drawer-summary::marker { content: ""; }
.filter-drawer[open] > .filter-drawer-summary { margin-bottom: 0.5rem; }
.filter-drawer-summary:hover { background: rgba(255,255,255,0.03); }

/* Picks-table inline detail expander: hidden until htmx-swap puts a child in. */
tr.detail-placeholder:empty { display: none; }

/* ── Polish round: card-count badges, sort arrows, focus, help modal ─── */

/* Up/Down counter chips in card header */
.card-count {
  display: inline-flex; align-items: center; gap: 6px;
}
.card-count-total { font-weight: 700; color: var(--text); }
.count-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px;
  border-radius: 999px;
  font: 600 10px/1 var(--font-mono);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
.count-badge.count-up   { color: var(--up);   background: var(--up-bg);   border-color: rgba(74,222,128,0.25); }
.count-badge.count-down { color: var(--down); background: var(--down-bg); border-color: rgba(248,113,113,0.25); }

/* Outcomes strip — flex with bullet separators between metrics */
.card-outcomes {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 4px 10px;
}
.card-outcomes .card-metric { display: inline-flex; align-items: baseline; gap: 4px; }
.card-outcomes .card-metric + .card-metric::before {
  content: "·";
  color: var(--text-faint);
  margin-right: 6px;
}

/* Sort-arrow upgrade — slightly larger, accent when active, no glyph jump */
.sort-arrow {
  display: inline-block;
  min-width: 10px;
  font-size: 10px;
  margin-left: 3px;
  opacity: 0.9;
  transition: color 120ms ease, transform 120ms ease;
}
thead th a.sort-active .sort-arrow { color: var(--accent); }
thead th a:hover .sort-arrow { transform: translateY(-1px); }

/* Up / down inline letter counts in sidebar/header — give them tiny chips
   too so they don't look like floating glyphs */
.sidebar-strategy-meta .up-n,
.sidebar-strategy-meta .down-n {
  font-variant-numeric: tabular-nums;
}

/* Help button (?) sits next to chart/theme toggles in topbar */
#help-toggle .help-icon {
  font: 700 14px/1 var(--font-mono);
}

/* Help overlay shares chart-overlay scaffolding but auto-sized body */
.help-overlay-panel { height: auto; max-height: 86vh; width: min(880px, 94vw); }
.help-overlay-body { padding: var(--s-4); overflow: auto; }
.help-overlay-hint { font-size: 0.78rem; }
.help-overlay-body h4 {
  margin: 0 0 var(--s-2);
  font: 600 11px/1 var(--font-mono);
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint);
}
.help-overlay-body dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.help-overlay-body dt { font: 600 12px/1.4 var(--font-mono); color: var(--text); }
.help-overlay-body dd { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.help-overlay-body .glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s-5);
}
.help-overlay-body .glossary-col + .glossary-col { padding-top: 2px; }

/* Focus ring — universal, only visible for keyboard nav */
*:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.chip:focus-visible,
.segmented-pill:focus-visible,
.btn:focus-visible,
.theme-toggle:focus-visible,
.sidebar-strategy:focus-visible,
.stat-tile:focus-visible { outline-offset: 3px; }

/* Slightly larger tap targets for chips/segmented on mobile */
@media (max-width: 700px) {
  .chip { min-height: 28px; padding: 5px 9px; }
  .segmented-pill { min-height: 26px; padding: 5px 9px; font-size: 11px; }
}

/* Inline ticker chart — daily TV widget with MAs (10/20/50/200) */
.ticker-chart {
  height: clamp(320px, 50vh, 520px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  margin-bottom: var(--s-4);
}
.ticker-chart iframe,
.ticker-chart > div { width: 100%; height: 100%; border: 0; }
.ticker-chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font: 500 12px/1 var(--font-mono);
}

/* Right-aligned action group inside page-header */
.page-header-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.page-header-actions .action-row {
  display: inline-flex;
  gap: 6px;
  margin: 0;
  padding: 0;
}

/* Card toolbar — visual divider between segmented groups (no labels) */
.card-toolbar .segmented + .segmented {
  padding-left: 10px;
  border-left: 1px solid var(--border);
  margin-left: 4px;
}

/* Scanner-health pulse — shown next to "last fire" on each card */
.status-pulse {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
  flex: 0 0 8px;
}
.status-pulse-fresh {
  background: var(--up);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
  animation: pulseFresh 2.4s ease-out infinite;
}
@keyframes pulseFresh {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
.status-pulse-warm  { background: var(--warn); }
.status-pulse-cold  { background: var(--text-muted); opacity: 0.7; }
.status-pulse-stale { background: var(--down); }

/* ─────────────────────────────────────────────────────────────────────────
   BLOOMBERG TERMINAL OVERLAY
   Amber-on-black palette, sharp corners, dense mono data, function-key bar.
   Overrides only the dark theme; light theme keeps its prior palette.
   ───────────────────────────────────────────────────────────────────────── */

:root[data-theme="dark"] {
  --bg:          #000000;
  --surface:     #0a0a0a;
  --elevated:    #141414;
  --overlay:     rgba(0, 0, 0, 0.94);

  --border:        #1f1f1f;
  --border-strong: #2e2e2e;

  --text:        #f0e6cf;
  --text-muted:  #8a7d5a;
  --text-faint:  #4f4a3a;

  --up:          #00ff66;
  --up-2:        #00cc52;
  --up-bg:       rgba(0, 255, 102, 0.10);
  --down:        #ff3838;
  --down-bg:     rgba(255, 56, 56, 0.10);
  --accent:      #ffb000;
  --accent-2:    #ffc845;
  --accent-bg:   rgba(255, 176, 0, 0.10);
  --warn:        #ffd84d;
  --blue:        #4cc9ff;
  --gold:        #ffb000;

  --shadow-md:   0 0 0 1px rgba(255, 176, 0, 0.08);
  --shadow-glow: 0 0 18px rgba(255, 176, 0, 0.18);

  --r-sm: 0px;
  --r-md: 2px;
  --r-lg: 2px;
  --r-pill: 2px;
}

/* Sharper corners everywhere, mono numbers a touch crisper */
:root[data-theme="dark"] {
  font-feature-settings: "tnum" 1, "ss01" 1;
}
:root[data-theme="dark"] body {
  background:
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(255,176,0,0.012) 2px 3px),
    var(--bg);
}
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .pill-group,
:root[data-theme="dark"] .btn,
:root[data-theme="dark"] .phase,
:root[data-theme="dark"] .status-pill,
:root[data-theme="dark"] .badge-today,
:root[data-theme="dark"] .stat-tile,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .filter-panel,
:root[data-theme="dark"] .filter-drawer,
:root[data-theme="dark"] .chart-overlay-panel,
:root[data-theme="dark"] .help-overlay-panel {
  border-radius: 0 !important;
}
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .btn,
:root[data-theme="dark"] .pill-group { border-radius: 2px !important; }

/* Brand → amber */
:root[data-theme="dark"] .brand-text,
:root[data-theme="dark"] .brand-icon,
:root[data-theme="dark"] .sidebar-brand a { color: var(--accent); }
:root[data-theme="dark"] a { color: var(--accent); }
:root[data-theme="dark"] a:hover { color: var(--accent-2); }
:root[data-theme="dark"] .ticker { color: var(--accent); font-family: var(--font-mono); }
:root[data-theme="dark"] .ticker:hover { color: var(--accent-2); text-shadow: 0 0 6px rgba(255,176,0,0.45); }

/* Mono-first numeric data */
:root[data-theme="dark"] table,
:root[data-theme="dark"] .topbar-clock,
:root[data-theme="dark"] .stat-tile-count,
:root[data-theme="dark"] .stat-tile-pnl,
:root[data-theme="dark"] .sidebar-strategy-count,
:root[data-theme="dark"] .card-count,
:root[data-theme="dark"] .page-header-meta { font-family: var(--font-mono); }
:root[data-theme="dark"] tbody td { font-size: 12px; padding: 4px 10px; }
:root[data-theme="dark"] thead th { font-size: 9px; padding: 5px 10px; color: var(--accent); }

/* P&L coloring stays green/red, but mono + tabular */
:root[data-theme="dark"] .pct-up,
:root[data-theme="dark"] .up-n,
:root[data-theme="dark"] .side-up { color: var(--up); }
:root[data-theme="dark"] .pct-down,
:root[data-theme="dark"] .down-n,
:root[data-theme="dark"] .side-down { color: var(--down); }

/* Topbar = command/status strip */
:root[data-theme="dark"] nav.topbar {
  height: 36px;
  background: linear-gradient(180deg, #0a0a0a 0%, #000 100%);
  border-bottom: 1px solid var(--accent);
}
:root[data-theme="dark"] .topbar-search input {
  background: #000;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
}
:root[data-theme="dark"] .topbar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  outline: none;
}
:root[data-theme="dark"] .topbar-clock {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.06em;
}
:root[data-theme="dark"] .phase {
  border-radius: 0;
  font-size: 9px;
  padding: 3px 8px;
}

/* Sidebar */
:root[data-theme="dark"] .sidebar {
  background: #000;
  border-right: 1px solid var(--border-strong);
}
:root[data-theme="dark"] .sidebar-section-title {
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 0.14em;
}
:root[data-theme="dark"] .sidebar-strategy:hover { background: rgba(255,176,0,0.06); }
:root[data-theme="dark"] .sidebar-strategy.active {
  background: rgba(255,176,0,0.10);
  border-left: 2px solid var(--accent);
  color: var(--accent);
}
:root[data-theme="dark"] .sidebar-strategy-count {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  padding: 1px 6px;
  font-size: 10px;
}

/* Tables = data grid */
:root[data-theme="dark"] thead th {
  background: #0a0a0a;
  border-bottom: 1px solid var(--accent);
  text-transform: uppercase;
}
:root[data-theme="dark"] tbody tr {
  border-bottom: 1px solid #141414;
}
:root[data-theme="dark"] tbody tr:hover {
  background: rgba(255,176,0,0.06);
  outline: 1px solid rgba(255,176,0,0.20);
  outline-offset: -1px;
}

/* Flash on update — added by JS to changed rows/cells */
@keyframes bbg-flash-up   { 0% { background: rgba(0,255,102,0.45); } 100% { background: transparent; } }
@keyframes bbg-flash-down { 0% { background: rgba(255,56,56,0.45); } 100% { background: transparent; } }
.bbg-flash-up   { animation: bbg-flash-up 900ms ease-out 1; }
.bbg-flash-down { animation: bbg-flash-down 900ms ease-out 1; }

/* ── Ticker tape strip (just below topbar) ───────────────────────────────── */
.tape {
  display: flex;
  align-items: center;
  height: 22px;
  border-bottom: 1px solid var(--border);
  background: #050505;
  overflow: hidden;
  position: sticky;
  top: 36px;
  z-index: 190;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.tape-track {
  display: inline-flex;
  gap: 28px;
  padding: 0 16px;
  white-space: nowrap;
  animation: tape-scroll 80s linear infinite;
  will-change: transform;
}
.tape:hover .tape-track { animation-play-state: paused; }
@keyframes tape-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.tape-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.tape-sym  { color: var(--accent); font-weight: 600; }
.tape-px   { color: var(--text); }
.tape-chg-up   { color: var(--up); }
.tape-chg-down { color: var(--down); }
.tape-sep  { color: var(--text-faint); }

/* ── Function-key bar (sticky bottom) ────────────────────────────────────── */
.fkey-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  display: flex;
  align-items: stretch;
  gap: 1px;
  background: #000;
  border-top: 1px solid var(--accent);
  z-index: 250;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}
:root[data-theme="light"] .fkey-bar {
  background: var(--surface);
  border-top-color: var(--border-strong);
}
.fkey {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
  background: #0a0a0a;
  color: var(--text-muted);
  text-decoration: none;
  border-right: 1px solid #141414;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-transform: uppercase;
  transition: background 80ms ease, color 80ms ease;
}
.fkey:last-child { border-right: 0; }
:root[data-theme="light"] .fkey { background: #fff; color: var(--text-muted); border-right-color: var(--border); }
.fkey:hover { background: rgba(255,176,0,0.12); color: var(--accent); text-decoration: none; }
.fkey-key  { color: var(--accent); font-weight: 700; }
.fkey-label { color: inherit; }
.fkey.active { background: rgba(255,176,0,0.18); color: var(--accent); }

/* Account for the fkey bar so bottom content isn't hidden behind it */
.app-shell { padding-bottom: 24px; }

/* ── Command palette (Cmd/Ctrl+K) ────────────────────────────────────────── */
.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 9999;
  padding-top: 12vh;
}
.cmdk-overlay[open] { display: flex; }
.cmdk-panel {
  width: min(560px, 92vw);
  background: #050505;
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-glow), 0 30px 80px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
}
:root[data-theme="light"] .cmdk-panel {
  background: var(--surface);
  border-color: var(--border-strong);
}
.cmdk-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  outline: none;
}
.cmdk-input::placeholder { color: var(--text-faint); text-transform: uppercase; }
.cmdk-list { max-height: 50vh; overflow-y: auto; }
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  border-bottom: 1px solid #0c0c0c;
  cursor: pointer;
  text-decoration: none;
}
.cmdk-item:hover, .cmdk-item.active {
  background: rgba(255,176,0,0.12);
  color: var(--accent);
  text-decoration: none;
}
.cmdk-key {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  padding: 1px 5px;
}
.cmdk-cat {
  padding: 4px 14px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: #0a0a0a;
  text-transform: uppercase;
}

/* Filter chips compact */
:root[data-theme="dark"] .filter-row { gap: 6px; }
:root[data-theme="dark"] .pill-group { padding: 2px 4px 2px 8px; }
:root[data-theme="dark"] .chip { height: 22px; padding: 0 10px; font-size: 10px; }
:root[data-theme="dark"] .filter-label { font-size: 8px; }

/* Status pills sharper */
:root[data-theme="dark"] .status-pill { border-radius: 0; font-size: 9px; padding: 2px 6px; }

/* Strategy cards on Today */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .card-grid-today > *,
:root[data-theme="dark"] section.card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #0a0a0a 0%, #050505 100%);
}
:root[data-theme="dark"] .card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
:root[data-theme="dark"] .card-title a { color: var(--accent); }

/* Section dividers like Bloomberg dotted lines */
:root[data-theme="dark"] .page-header { border-bottom: 1px dashed var(--border-strong); padding-bottom: 8px; }

/* Make the topbar-search wider and command-line-feel */
:root[data-theme="dark"] .topbar-search input { width: 240px; }
:root[data-theme="dark"] .topbar-search input::placeholder { color: var(--text-faint); }

/* ── Bloomberg polish v2 — fixes from first user pass ──────────────────── */

/* Sidebar toggle: move INSIDE the sidebar so it can never be clipped by
   the topbar/tape, and give it the amber treatment. */
.sidebar-toggle {
  right: 6px !important;
  top: 10px !important;
  border-radius: 0 !important;
  background: #000 !important;
  border: 1px solid var(--accent) !important;
  color: var(--accent) !important;
  z-index: 250 !important;
}
.sidebar-toggle:hover { background: rgba(255,176,0,0.15) !important; color: var(--accent-2) !important; }

/* Status rows: single flex line, no grid wrap, ellipsis on label */
.status-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 5px 10px 5px 18px !important;
  border-radius: 0 !important;
}
.status-row .status-time  { flex: 0 0 auto; }
.status-row .status-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-row .status-eta   { flex: 0 0 auto; margin-left: auto; }

/* Today card grid: one card per row (user wants single column) */
#card-section.card-grid-today {
  grid-template-columns: 1fr !important;
}

/* Backtest stats rail — always open, no click summary */
.detail-rail-wrap { border-radius: 0 !important; }
.detail-rail-summary {
  pointer-events: none;
  background: #0a0a0a !important;
  color: var(--accent) !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: 11px !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
}
.detail-rail-summary::after { display: none !important; }
.detail-rail-summary::-webkit-details-marker { display: none !important; }

/* Tape: slower scroll, dimmer separators, single-line discipline */
:root[data-theme="dark"] .tape { height: 20px; font-size: 10px; background: #050505; }
:root[data-theme="dark"] .tape-track { animation-duration: 140s; gap: 22px; padding: 0 14px; }
:root[data-theme="dark"] .tape-sym { letter-spacing: 0.04em; }

/* ── Bloomberg polish v3 — search contrast, arrow alignment, mobile ─── */

/* Search input: amber text + clear placeholder so it reads on the dark strip */
.topbar-search input,
:root[data-theme="dark"] .topbar-search input {
  color: var(--accent) !important;
  background: #000 !important;
  border: 1px solid var(--border-strong) !important;
  caret-color: var(--accent) !important;
  font-weight: 600;
}
.topbar-search input::placeholder,
:root[data-theme="dark"] .topbar-search input::placeholder {
  color: rgba(255,176,0,0.55) !important;
  font-weight: 500;
}

/* Up/Down triangle arrows: align to numeric baseline, normalize size */
.pct-up::before, .pct-down::before { content: none; }
.page-header-meta .pct-up,
.page-header-meta .pct-down,
.card-count .pct-up,
.card-count .pct-down,
.tape .tape-chg-up,
.tape .tape-chg-down {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* Inline glyph arrows in chip labels / meta: shrink + nudge */
.chip .arrow,
.page-header-meta,
.card-count {
  font-variant-numeric: tabular-nums;
}
/* Compact the bare ▲▼ glyphs to match digit height */
.page-header-meta { display: inline-flex; align-items: center; gap: 10px; }
.page-header-meta > span { display: inline-flex; align-items: center; gap: 4px; line-height: 1; }
.page-header-meta .pct-up,
.page-header-meta .pct-down { font-size: 12px; }
.page-header-meta .pct-up::first-letter,
.page-header-meta .pct-down::first-letter { font-size: 10px; }

/* Arrows in side chips (▲ calls / ▼ puts) */
.chip { line-height: 1; }
.chip.up, .chip.down { font-variant-numeric: tabular-nums; }

/* ── MOBILE (≤ 720px) — Bloomberg compaction ─────────────────────────── */
@media (max-width: 720px) {
  /* Hide the marquee tape on phones — too noisy at narrow width */
  .tape { display: none; }

  /* Topbar: drop center phase pill (still visible in sidebar), shrink search */
  nav.topbar { gap: 8px; padding: 0 8px; height: 40px; }
  .topbar-center { display: none; }
  .topbar-search input { width: 100%; max-width: 180px; }
  .topbar-search { flex: 1 1 auto; }
  .topbar-right .theme-toggle { width: 32px; }

  /* Sidebar: stay collapsed icon-strip (already 56px via existing rules);
     hide status section to keep it clean */
  .sidebar-section:has(.status-list) { display: none; }

  /* F-key bar: show keys only, hide labels to fit 7 keys on a phone */
  .fkey-label { display: none; }
  .fkey { padding: 0 4px; font-size: 9px; }
  .fkey-key { font-size: 10px; }
  #fkey-clock { font-size: 9px; }

  /* Cards: tighter padding */
  .card { padding: 10px 12px !important; }
  .card-title { font-size: 14px; }
  .container { padding: 0 8px 28px; }

  /* Tables: shrink */
  table { font-size: 11px; }
  tbody td { padding: 4px 6px; }
  thead th { padding: 4px 6px; font-size: 9px; }

  /* Filter chips wrap nicely */
  .filter-row { gap: 4px; }
  .pill-group { padding: 2px 4px 2px 6px; }

  /* Page header stacks */
  .page-header { flex-wrap: wrap; gap: 6px; }
  .page-header h2 { font-size: 18px; }
  .page-header-actions { width: 100%; margin-left: 0; }
}

/* Tiny screens (≤ 480px) — go even tighter */
@media (max-width: 480px) {
  /* Drop a couple of F-keys to stop horizontal overflow */
  #fkey-chart, #fkey-theme, #fkey-clock { display: none; }
}

/* ── Visibility bump v4 — readable density, still terminal-feel ──────── */

html { font-size: 14px !important; }
body { font-size: 14px !important; line-height: 1.5; }

h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 14px; }

/* Tables: legible data, comfortable row height */
table { font-size: 13px !important; }
:root[data-theme="dark"] tbody td { font-size: 13px !important; padding: 6px 10px !important; }
:root[data-theme="dark"] thead th { font-size: 11px !important; padding: 7px 10px !important; letter-spacing: 0.10em; }

/* Sidebar */
.sidebar-section-title,
:root[data-theme="dark"] .sidebar-section-title { font-size: 11px !important; letter-spacing: 0.12em; }
.sidebar-strategy { font-size: 13px; line-height: 1.4; }
.sidebar-strategy-label { font-size: 13px; }
.sidebar-strategy-count,
:root[data-theme="dark"] .sidebar-strategy-count { font-size: 12px !important; padding: 2px 8px !important; }
.status-row { font-size: 12px !important; }
.status-row .status-time { font-size: 12px; }
.status-row .status-eta { font-size: 12px; }

/* Topbar / search */
.topbar-clock,
:root[data-theme="dark"] .topbar-clock { font-size: 13px !important; letter-spacing: 0.04em; }
.topbar-search input,
:root[data-theme="dark"] .topbar-search input { font-size: 13px !important; height: 30px; width: 260px !important; }
.phase,
:root[data-theme="dark"] .phase { font-size: 11px !important; padding: 4px 10px !important; }

/* Tape — still scrolling, but bigger and readable */
.tape,
:root[data-theme="dark"] .tape { height: 26px !important; font-size: 12px !important; }
.tape-track,
:root[data-theme="dark"] .tape-track { gap: 28px !important; }

/* Chips / filter labels */
:root[data-theme="dark"] .chip { height: 26px !important; padding: 0 12px !important; font-size: 12px !important; }
:root[data-theme="dark"] .filter-label { font-size: 10px !important; }
:root[data-theme="dark"] .status-pill { font-size: 11px !important; padding: 3px 8px !important; }

/* Cards */
.card { padding: 14px 16px; }
.card-title { font-size: 16px; }
.card-count { font-size: 13px; }

/* Function-key bar */
.fkey-bar { height: 30px !important; font-size: 11px !important; }
.fkey { font-size: 11px !important; padding: 0 10px !important; }
.fkey-key { font-size: 11px !important; }
.app-shell { padding-bottom: 30px !important; }

/* Backtest stats block */
.detail-rail-summary,
:root[data-theme="dark"] .detail-rail-summary { font-size: 12px !important; padding: 10px 16px !important; }
.detail-rail h3.section-title { font-size: 14px; }
.detail-rail h4.subsection-title { font-size: 12px; }
.stat-list-label, .stat-list-value { font-size: 13px; }

/* Page header */
.page-header h2 { font-size: 22px; }
.page-header-meta { font-size: 13px; }

/* Status pulse a hair larger so it reads as a dot, not a speck */
.status-pulse { width: 10px !important; height: 10px !important; }

/* Mobile: scale a touch but don't go below the new floor */
@media (max-width: 720px) {
  html { font-size: 13.5px !important; }
  body { font-size: 13.5px !important; }
  table { font-size: 12px !important; }
  :root[data-theme="dark"] tbody td { font-size: 12px !important; padding: 5px 7px !important; }
  :root[data-theme="dark"] thead th { font-size: 10px !important; }
  .topbar-search input,
  :root[data-theme="dark"] .topbar-search input { width: 100% !important; max-width: 220px; font-size: 13px !important; }
  .fkey-bar { height: 28px !important; }
  .app-shell { padding-bottom: 28px !important; }
}

/* ── Finviz-style filter panel (v5) ───────────────────────────────────── */

:root[data-theme="dark"] .filter-drawer {
  background: #050505;
  border: 1px solid var(--border);
  margin: 12px 0 14px;
}
:root[data-theme="dark"] .filter-drawer-summary {
  background: linear-gradient(180deg, #0a0a0a, #050505);
  color: var(--accent);
  font-size: 12px !important;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 9px 14px !important;
  border-bottom: 1px solid var(--border);
}
:root[data-theme="dark"] .filter-drawer-summary:hover { background: linear-gradient(180deg, #111, #060606); }

/* Active-filter chip row injected by JS at top of every drawer */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: #060606;
  border-bottom: 1px dashed var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
}
.active-filters:empty { display: none; }
.active-filters .af-label {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  margin-right: 4px;
  align-self: center;
}
.active-filters .af-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 2px 8px;
  background: rgba(255,176,0,0.10);
  border: 1px solid var(--accent);
  color: var(--accent);
  cursor: default;
  white-space: nowrap;
}
.active-filters .af-pill button {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: 700 12px/1 var(--font-mono);
  padding: 2px 4px;
}
.active-filters .af-pill button:hover { color: var(--down); }
.active-filters .af-reset {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  padding: 2px 10px;
  font: 600 10px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  cursor: pointer;
}
.active-filters .af-reset:hover { color: var(--accent); border-color: var(--accent); }

/* Filter panel becomes a true Finviz-density grid */
:root[data-theme="dark"] .filter-panel {
  padding: 0;
  background: #050505;
}
:root[data-theme="dark"] .filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 0;
}
@media (max-width: 1100px) {
  :root[data-theme="dark"] .filter-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 780px) {
  :root[data-theme="dark"] .filter-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  :root[data-theme="dark"] .filter-grid { grid-template-columns: 1fr; }
}

:root[data-theme="dark"] .filter-group {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  background: #050505;
  border-right: 1px solid #101010;
  border-bottom: 1px solid #101010;
  min-height: 56px;
}
/* Zebra rows — count groups per row via :nth-child */
:root[data-theme="dark"] .filter-grid > .filter-group:nth-child(8n+1),
:root[data-theme="dark"] .filter-grid > .filter-group:nth-child(8n+2),
:root[data-theme="dark"] .filter-grid > .filter-group:nth-child(8n+3),
:root[data-theme="dark"] .filter-grid > .filter-group:nth-child(8n+4) {
  background: #080808;
}
:root[data-theme="dark"] .filter-group > label {
  font: 600 10px/1.1 var(--font-mono);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
:root[data-theme="dark"] .filter-group input[type=number],
:root[data-theme="dark"] .filter-group select {
  width: 100%;
  height: 26px;
  background: #000;
  border: 1px solid #1a1a1a;
  color: var(--text);
  font: 500 12px/1 var(--font-mono);
  padding: 0 8px;
  border-radius: 0;
  transition: border-color 80ms, color 80ms;
}
:root[data-theme="dark"] .filter-group input[type=number]:focus,
:root[data-theme="dark"] .filter-group select:focus {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 1px var(--accent);
}
/* dirty = value diverged from default → amber */
:root[data-theme="dark"] .filter-group input[data-dirty="1"],
:root[data-theme="dark"] .filter-group select[data-dirty="1"] {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255,176,0,0.06);
}
:root[data-theme="dark"] .filter-group:has(input[data-dirty="1"]) > label,
:root[data-theme="dark"] .filter-group:has(select[data-dirty="1"]) > label,
:root[data-theme="dark"] .filter-group:has(.chip-active) > label {
  color: var(--accent);
}

/* Chips inside drawer (Setup, Regime, Trend alignment, Status, Put/Call) */
:root[data-theme="dark"] .filter-group .chips {
  display: inline-flex;
  gap: 0;
  border: 1px solid #1a1a1a;
  background: #000;
}
:root[data-theme="dark"] .filter-group .chips .chip {
  height: 26px !important;
  padding: 0 10px !important;
  font: 600 11px/1 var(--font-mono) !important;
  background: transparent;
  border: 0;
  border-right: 1px solid #1a1a1a;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  border-radius: 0 !important;
  transition: background 80ms, color 80ms;
}
:root[data-theme="dark"] .filter-group .chips .chip:last-child { border-right: 0; }
:root[data-theme="dark"] .filter-group .chips .chip:hover { background: rgba(255,176,0,0.08); color: var(--accent); }
:root[data-theme="dark"] .filter-group .chips .chip:has(input:checked),
:root[data-theme="dark"] .filter-group .chip-active {
  background: rgba(255,176,0,0.14);
  color: var(--accent);
}

/* Light-theme variant (kept simple — same density, paler) */
:root[data-theme="light"] .filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}
:root[data-theme="light"] .filter-group {
  background: #fff;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 7px 12px;
}
:root[data-theme="light"] .filter-grid > .filter-group:nth-child(8n+1),
:root[data-theme="light"] .filter-grid > .filter-group:nth-child(8n+2),
:root[data-theme="light"] .filter-grid > .filter-group:nth-child(8n+3),
:root[data-theme="light"] .filter-grid > .filter-group:nth-child(8n+4) {
  background: #fafbfc;
}

/* ── Screener page ────────────────────────────────────────────────────── */

.screener-form { margin-top: 12px; }
.screener-presets {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #0a0a0a;
  border: 1px solid var(--accent);
  border-bottom: 0;
  margin-bottom: 0;
}
.screener-presets .filter-label { font-size: 10px; color: var(--accent); margin-right: 4px; }
.preset-select {
  flex: 1 1 auto;
  height: 30px;
  background: #000;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0.04em;
  padding: 0 10px;
}
.preset-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.screener-tabs {
  display: flex;
  margin: 16px 0 0;
  border-bottom: 1px solid var(--accent);
}
.screener-tab {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 8px 16px;
  font: 600 11px/1 var(--font-mono);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.screener-tab:hover { color: var(--accent); }
.screener-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.screener-pane { padding-top: 12px; }
.screener-pane[hidden] { display: none; }

/* Backtest stat tiles */
.bt-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  margin: 16px 0;
}
@media (max-width: 720px) { .bt-stats { grid-template-columns: repeat(2, 1fr); } }
.bt-tile {
  background: #0a0a0a;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bt-tile-label {
  font: 600 9px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.bt-tile-value {
  font: 600 22px/1 var(--font-mono);
  color: var(--text);
}
.bt-tile-sub {
  font: 500 11px/1.4 var(--font-mono);
  color: var(--text-muted);
}
.bt-extremes {
  display: flex;
  gap: 1px;
  background: var(--border);
  margin-bottom: 12px;
}
.bt-extreme {
  flex: 1;
  background: #0a0a0a;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font: 500 12px/1 var(--font-mono);
}

/* ── Backtest equity curve + extras ──────────────────────────────────── */

.bt-curve {
  margin: 14px 0;
  background: #0a0a0a;
  border: 1px solid var(--border);
  padding: 10px 12px 6px;
}
.bt-curve-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font: 500 11px/1 var(--font-mono);
}
.bt-curve-svg {
  width: 100%;
  height: auto;
  display: block;
}

.bt-reasons {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: #0a0a0a;
  border: 1px solid var(--border);
  margin: 8px 0 12px;
  font: 500 12px/1 var(--font-mono);
}
.bt-reason {
  color: var(--text-muted);
}
.bt-reason strong { color: var(--accent); }

.bt-trades-wrap {
  margin: 12px 0;
  background: #0a0a0a;
  border: 1px solid var(--border);
}
.bt-trades-summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 14px;
  font: 600 11px/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}
.bt-trades-summary::-webkit-details-marker { display: none; }

/* Live toggle / save / delete chip cluster */
.screener-presets .chip {
  cursor: pointer;
}
.screener-presets .chip:has(input:checked) {
  background: rgba(255,176,0,0.18);
  color: var(--accent);
  border-color: var(--accent);
}

/* HTMX loading on backtest */
#bt-loading.htmx-indicator { opacity: 0; transition: opacity 100ms; }
.htmx-request #bt-loading.htmx-indicator { opacity: 1; }

/* ── Single Bloomberg theme — force dark, nuke light overrides ───────── */
:root { color-scheme: dark only; }
/* Hide any stray theme/chart toggle markup that might linger */
#theme-toggle, #chart-overlay-toggle, .theme-icon-light, .theme-icon-dark, .chart-icon { display: none !important; }

/* ── Scanner usage affordances ──────────────────────────────────────────── */
.scanner-hint {
  font: 500 11px/1.4 var(--font-mono);
  color: var(--text-muted);
  padding: 6px 14px;
  background: #060606;
  border: 1px solid var(--border);
  border-top: 0;
  letter-spacing: 0.02em;
}
.scanner-hint strong { color: var(--accent); font-weight: 700; }

.scanner-run {
  font-weight: 700 !important;
  letter-spacing: 0.04em;
}

.scanner-updating {
  display: inline-flex;
  align-items: center;
  font: 700 11px/1 var(--font-mono);
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 120ms ease;
  margin-left: 2px;
}
.scanner-updating.on { opacity: 1; animation: scanner-pulse 0.8s ease-in-out infinite; }
@keyframes scanner-pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

/* Results dim while a query is in flight (set inline by JS) */
#screener-results, #intraday-results, #options-results { transition: opacity 120ms ease; }

/* ── Landing / home page ────────────────────────────────────────────────── */
.home { max-width: 1100px; margin: 0 auto; padding: 0 20px 60px; }

.home-hero {
  text-align: center;
  padding: 56px 0 40px;
  border-bottom: 1px dashed var(--border-strong);
}
.home-logo {
  font: 800 44px/1 var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--text);
}
.home-logo-accent { color: var(--accent); }
.home-tagline {
  margin-top: 10px;
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0.42em;
  color: var(--accent);
}
.home-motto {
  margin: 26px 0 18px;
  font: 800 46px/1.08 var(--font-sans);
  letter-spacing: -0.02em;
  color: var(--text);
}
.home-motto-accent { color: var(--accent); }
.home-sub {
  max-width: 620px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
}
.home-sub strong { color: var(--text); }

.home-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 30px 0 22px;
}
.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font: 700 13px/1 var(--font-mono);
  letter-spacing: 0.06em;
  border: 1px solid var(--border-strong);
  color: var(--text);
  background: var(--surface);
  transition: all 100ms ease;
}
.home-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.home-btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.home-btn-primary:hover {
  background: var(--accent-2);
  color: #000;
  box-shadow: var(--shadow-glow);
}

.home-stat-strip {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  font: 500 12px/1 var(--font-mono);
  color: var(--text-muted);
}
.home-stat-strip strong { color: var(--accent); }
.home-dot { color: var(--text-faint); }

/* The loop */
.home-loop {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 44px 0;
}
.home-step {
  flex: 1;
  padding: 22px;
  background: linear-gradient(180deg, #0a0a0a, #050505);
  border: 1px solid var(--border);
}
.home-step-num { font: 700 12px/1 var(--font-mono); color: var(--accent); letter-spacing: 0.2em; }
.home-step-icon { font-size: 30px; margin: 12px 0 8px; color: var(--accent); }
.home-step-title { font: 800 18px/1 var(--font-sans); letter-spacing: 0.06em; color: var(--text); margin-bottom: 10px; }
.home-step p { font-size: 13px; line-height: 1.55; color: var(--text-muted); }
.home-step em { color: var(--text); font-style: normal; font-weight: 600; }
.home-arrow {
  display: flex; align-items: center; justify-content: center;
  padding: 0 14px; font-size: 22px; color: var(--accent);
}
@media (max-width: 820px) {
  .home-loop { flex-direction: column; gap: 10px; }
  .home-arrow { padding: 4px; transform: rotate(90deg); }
  .home-motto { font-size: 34px; }
  .home-logo { font-size: 34px; }
}

/* Why grid */
.home-why { margin: 44px 0; }
.home-why-title {
  text-align: center;
  font: 700 12px/1 var(--font-mono);
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-bottom: 18px;
}
.home-why-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
@media (max-width: 820px) { .home-why-grid { grid-template-columns: 1fr; } }
.home-why-card {
  background: #0a0a0a;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.home-why-k { font: 700 13px/1.2 var(--font-mono); color: var(--accent); }
.home-why-card span:last-child { font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }

.home-foot { text-align: center; margin-top: 36px; }

/* ── Filled amber buttons: force dark text for contrast (final word) ────── */
.btn-primary,
.btn-primary:hover,
.home-btn-primary,
.home-btn-primary:hover,
.scanner-run,
.scanner-run:hover,
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .scanner-run {
  color: #000 !important;
  font-weight: 700 !important;
}
/* keep the run buttons' amber fill explicit too */
.scanner-run, :root[data-theme="dark"] .scanner-run { background: var(--accent) !important; border-color: var(--accent) !important; }

/* ── Top-nav layout (sidebar removed for simpler UX) ────────────────────── */
.app-main { width: 100%; min-height: 100vh; }
:root[data-theme="dark"] body { /* main is full-width now */ }

:root[data-theme="dark"] nav.topbar {
  height: 46px;
  gap: 18px;
  padding: 0 18px;
}
.topbar-brand {
  font: 800 17px/1 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--text) !important;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-brand-accent { color: var(--accent); }
.topbar-brand:hover { text-decoration: none; }

.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.topnav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 46px;
  padding: 0 14px;
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.topnav-link:hover { color: var(--accent); text-decoration: none; background: rgba(255,176,0,0.06); }
.topnav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(255,176,0,0.08);
}
.topbar-search { margin-left: auto; }

@media (max-width: 760px) {
  .topnav-link .topnav-label, .topnav-link span:last-child { }
  .topnav-link { padding: 0 9px; font-size: 11px; }
  .topbar-brand { font-size: 14px; }
  nav.topbar { gap: 8px; padding: 0 8px; }
}

/* ── Footer F-key bar removed — reclaim the reserved space, hide bar ─────── */
.app-shell, .app-main { padding-bottom: 0 !important; }
.fkey-bar { display: none !important; }

/* ── Backtest running feedback ──────────────────────────────────────────── */
.bt-running {
  padding: 18px 14px;
  font: 600 13px/1.4 var(--font-mono);
  color: var(--accent);
  animation: scanner-pulse 1s ease-in-out infinite;
}
#bt-loading.on, #ibt-loading.on, #obt-loading.on { opacity: 1 !important; }

/* ── Charts grid (screener CHARTS tab) ──────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-top: 10px;
}
.chart-card {
  background: #0a0a0a;
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
}
.chart-card:hover { background: rgba(255,176,0,0.06); text-decoration: none; }
.chart-card-head { display: flex; align-items: baseline; gap: 8px; font: 600 12px/1 var(--font-mono); }
.chart-card-sym { color: var(--accent); font-weight: 700; }
.chart-card-px { color: var(--text); }
.chart-card-head .pct-up, .chart-card-head .pct-down { margin-left: auto; }
.chart-card-svg { width: 100%; height: 54px; display: block; }
.chart-card-foot { display: flex; justify-content: space-between; font: 500 10px/1 var(--font-mono); }

/* ── Sortable column headers ────────────────────────────────────────────── */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent) !important; }
th.sortable.sort-active { color: var(--accent) !important; }
.th-arrow { font-size: 9px; margin-left: 2px; }
