/* =====================================================================
   AfterBellScans - design tokens
   Dark is the default (no attribute); light is toggled by
   data-theme="light" on <html> (see base.html). Every rule below reads
   these variables - a new color goes here, never inline in a rule, so
   both themes stay in sync automatically.
   ===================================================================== */
:root {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #151a21;
  --raised: #1b2029;
  --line: #252b35;
  --line-soft: #1e232c;
  --text: #e6e9ef;
  --muted: #8a93a3;
  --faint: #5f6878;
  --accent: #f2a93b;
  --accent-ink: #1a1204;
  --accent-soft: rgba(242, 169, 59, 0.12);
  --up: #3ecf8e;
  --down: #f0646f;
  --info: #6fa8ff;
  --warn: #e8c15a;
  --link: #8ab8ff;
  --brand: #38bdf8;
  --seg-off: #2a303b;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --raised: #f8f9fb;
  --line: #e2e5ea;
  --line-soft: #eef0f3;
  --text: #151922;
  --muted: #5d6676;
  --faint: #8b93a1;
  --accent: #c27400;
  --accent-ink: #ffffff;
  --accent-soft: rgba(194, 116, 0, 0.1);
  --up: #108a55;
  --down: #cf3442;
  --info: #2459c7;
  --warn: #9a6b00;
  --link: #1f5fc4;
  --brand: #0284c7;
  --seg-off: #e3e6eb;
  --shadow: 0 8px 24px rgba(20, 25, 34, 0.1);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { text-wrap: balance; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 1rem; font-weight: 600; margin: 0; }
a { color: var(--link); }
code { font-family: var(--mono); font-size: 0.85em; background: var(--raised); border: 1px solid var(--line-soft); padding: 0.05em 0.35em; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.error { color: var(--down); }
.pos, .up { color: var(--up); }
.neg, .down { color: var(--down); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.main-column { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.container { max-width: 1440px; width: 100%; margin: 0 auto; padding: 1.4rem 1.75rem 2rem; flex: 1; display: flex; flex-direction: column; gap: 1.25rem; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.1rem 0.5rem 1.1rem; }
.sidebar-brand .wordmark { font-weight: 700; font-size: 1.02rem; color: var(--text); letter-spacing: 0.01em; }
.sidebar-brand .wordmark b { color: var(--brand); font-weight: 700; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}
.sidebar-nav a svg { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-nav a:hover { color: var(--text); background: var(--raised); }
.sidebar-nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.sidebar-group-label { padding: 1rem 0.65rem 0.35rem; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--faint); }
.sidebar-foot { margin-top: auto; padding: 0.8rem 0.65rem 0; border-top: 1px solid var(--line); font-size: 0.78rem; color: var(--muted); line-height: 1.55; }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--up); margin-right: 6px; vertical-align: 1px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.6rem 1.75rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.topbar-spacer { flex: 1; }
.user-menu { position: relative; }
.user-menu-button {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.65rem 0.25rem 0.25rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted);
  font: inherit; font-size: 0.85rem; cursor: pointer;
}
.user-menu-button:hover { color: var(--text); }
.user-avatar {
  display: flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 0.82rem; flex-shrink: 0;
}
.user-menu-caret { font-size: 0.7rem; color: var(--faint); }
.user-menu-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.35rem; box-shadow: var(--shadow);
}
.user-menu-dropdown.open { display: block; }
.user-menu-item {
  display: flex; align-items: center; gap: 0.55rem; width: 100%;
  padding: 0.5rem 0.6rem; border: none; border-radius: 6px; background: none;
  color: var(--text); text-decoration: none; font: inherit; font-size: 0.88rem; text-align: left; cursor: pointer;
}
.user-menu-item:hover { background: var(--raised); }
.theme-toggle-icon { font-size: 0.95rem; line-height: 1; }

.site-footer {
  padding: 0.9rem 1.75rem; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.78rem;
}
.footer-disclaimer { margin: 0; line-height: 1.5; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.25rem; flex-wrap: wrap; }
.page-head .crumb { font-size: 0.78rem; color: var(--faint); margin-bottom: 0.25rem; }
.page-head > :first-child { flex: 1 1 0; min-width: min(100%, 20rem); }
.page-head .page-sub { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.stamp { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); }
.stamp .pill {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); padding: 0.3rem 0.65rem; border-radius: 999px;
  color: var(--text); font-weight: 500;
}
.stamp .pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--up); display: inline-block; }
.back-link { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.back-link:hover { color: var(--accent); }

/* ---------- Summary cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.kpi .lbl { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.kpi .val { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .val small { font-size: 0.82rem; font-weight: 500; color: var(--muted); margin-left: 0.25rem; letter-spacing: 0; }
.kpi .cmp { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.kpi .cmp b { font-weight: 600; color: var(--text); }
.kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi.accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h p { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--muted); }
.card-body { padding: 0.9rem 1rem; }

/* Collapsible card: <details class="card collapsible"><summary class="card-h">
   ... <span class="toggle-hint"> ... </summary> body </details>. Closed by
   default; the header is the click/keyboard target. */
.collapsible > summary { cursor: pointer; list-style: none; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible:not([open]) > summary { border-bottom: 0; }
.collapsible > summary:hover h2 { color: var(--accent); }
.toggle-hint { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.toggle-hint svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.collapsible[open] .toggle-hint svg { transform: rotate(180deg); }
.collapsible[open] .when-closed, .collapsible:not([open]) .when-open { display: none; }
.card-foot { padding: 0.6rem 1rem; border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* ---------- Status banner (Deals / Delivery fetch log) ---------- */
.fetch-status {
  display: flex; gap: 0.55rem; align-items: baseline; flex-wrap: wrap;
  padding: 0.6rem 0.9rem; border-radius: 8px; font-size: 0.85rem;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  border-left: 3px solid var(--faint);
}
.fetch-status strong { color: var(--text); }
.fetch-status-success { border-left-color: var(--up); }
.fetch-status-failed { border-left-color: var(--down); }
.fetch-status-failed strong { color: var(--down); }

/* ---------- Tabs, filters, toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; }
.toolbar .screen-tabs, .toolbar .filters { margin: 0; }
.screen-tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; background: var(--raised); border: 1px solid var(--line); border-radius: 9px; align-self: flex-start; }
.screen-tabs a { color: var(--muted); text-decoration: none; padding: 0.35rem 0.8rem; border-radius: 7px; font-size: 0.84rem; font-weight: 500; }
.screen-tabs a:hover { color: var(--text); }
.screen-tabs a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.screen-tabs a.active::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 0.4rem; vertical-align: 1px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.filters label.lbl { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.filters select, .filters input[type="text"], .filters input[type="date"], .filters button {
  font: inherit; font-size: 0.85rem; padding: 0.4rem 0.65rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.filters input[type="text"] { min-width: 170px; }
.filters select, .filters input[type="date"] { cursor: pointer; }
.filters input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.7; }
.filters button { cursor: pointer; font-weight: 600; background: var(--raised); }
.filters button:hover { border-color: var(--accent); }
.filters .check { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.84rem; color: var(--muted); }
.filters .clear-link { color: var(--muted); text-decoration: none; font-size: 0.84rem; padding: 0.4rem 0.2rem; }
.filters .clear-link:hover { color: var(--accent); }

.seg-ctl { display: inline-flex; background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg-ctl a { padding: 0.3rem 0.65rem; font-size: 0.8rem; font-weight: 500; color: var(--muted); border-radius: 6px; text-decoration: none; }
.seg-ctl a:hover { color: var(--text); }
.seg-ctl a.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }

/* ---------- Stat chips (kept for small inline facts) ---------- */
.stat-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { background: var(--surface); border: 1px solid var(--line); padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* ---------- Data tables ---------- */
table.grid { width: 100%; border-collapse: collapse; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
table.grid th {
  position: sticky; top: 0; z-index: 1;
  background: var(--raised); color: var(--muted);
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  text-align: left; padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid th[title] { cursor: help; text-decoration: underline dotted var(--faint); text-underline-offset: 3px; }
table.grid td { padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.grid th:first-child, table.grid td:first-child { padding-left: 1rem; }
table.grid th:last-child, table.grid td:last-child { padding-right: 1rem; }
table.grid td.wrap { white-space: normal; }
table.grid tbody tr:hover td { background: var(--raised); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid a { color: var(--link); text-decoration: none; }
table.grid a:hover { text-decoration: underline; }
table.grid a.sym { font-family: var(--mono); font-weight: 600; color: var(--text); letter-spacing: 0.01em; }
table.grid a.sym:hover { color: var(--accent); text-decoration: none; }
table.grid .num { text-align: right; }
.sym-plain { font-family: var(--mono); font-weight: 600; margin-right: 0.3rem; }
a.kpi:hover { border-color: var(--accent); }
table.grid td.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; white-space: normal; }
.grid td.positive { color: var(--up); font-weight: 600; }
.grid td.negative { color: var(--down); font-weight: 600; }
.date-cell { color: var(--muted); }
.of { color: var(--faint); }

/* Signed change with an arrow: <span class="chg up">3.3%</span> */
.chg { font-weight: 600; white-space: nowrap; }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.up::before, .chg.down::before { font-size: 0.62em; margin-right: 0.25em; vertical-align: 0.12em; }
.chg.up::before { content: "▲"; }
.chg.down::before { content: "▼"; }

/* Inline bar inside a cell */
.bar-cell { display: inline-flex; align-items: center; gap: 0.6rem; justify-content: flex-end; }
.bar-cell .track { width: 90px; height: 6px; border-radius: 3px; background: var(--seg-off); overflow: hidden; }
.bar-cell .fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* Score meter, one segment per confluence criterion */
.meter { display: inline-flex; align-items: center; gap: 0.5rem; cursor: help; }
.segs { display: inline-flex; gap: 2px; }
.segs i { width: 5px; height: 14px; border-radius: 1.5px; background: var(--seg-off); display: block; }
.segs i.on { background: var(--accent); }
.meter.mid .segs i.on { background: var(--muted); }
.meter b { font-weight: 700; min-width: 1.4em; }
.beta-tag {
  display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.35rem; border-radius: 4px;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; line-height: 1.4; vertical-align: 0.2em;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent);
}
h1 .beta-tag { font-size: 0.65rem; vertical-align: 0.45em; }
.tag-lowvol { font-size: 0.7rem; font-weight: 600; color: var(--warn); margin-left: 0.3rem; }

/* ---------- Badges & status chips ---------- */
.badge, .st {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.55rem; border-radius: 999px; font-size: 0.74rem; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted);
}
.st-prog { background: var(--accent-soft); color: var(--accent); }
.st-held, .stage-Breakout, .stage-BUY, .stage-STRONG-BUY { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.st-stop, .stage-Failed-Base, .stage-Fetch-Error, .stage-SELL, .stage-STRONG-SELL { background: color-mix(in srgb, var(--down) 13%, transparent); color: var(--down); }
.stage-Breakout-Low-Volume, .st-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.stage-Near-Pivot { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.stage-Building-Base { background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); }
.stage-No-Setup, .stage-Illiquid, .stage-No-Data, .stage-Insufficient-Data, .stage-NEUTRAL, .st-muted { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); }
.stage-STRONG-BUY, .stage-STRONG-SELL { font-weight: 700; }
.chip.stage-Breakout, .chip.stage-BUY, .chip.stage-STRONG-BUY, .chip.stage-SELL, .chip.stage-STRONG-SELL,
.chip.stage-Near-Pivot, .chip.stage-Failed-Base, .chip.stage-Breakout-Low-Volume { border-color: transparent; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.65rem 1rem; border-top: 1px solid var(--line); font-size: 0.84rem; }
.pagination a { color: var(--text); text-decoration: none; padding: 0.3rem 0.75rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-weight: 500; }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination a.disabled { color: var(--faint); pointer-events: none; opacity: 0.6; }

/* ---------- Login ---------- */
.login-wrap { flex: 1; display: grid; place-items: center; padding: 2rem 0; }
.login-box { width: 100%; max-width: 360px; padding: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.login-logo { display: flex; justify-content: center; margin-bottom: 0.6rem; }
.login-box h1 { text-align: center; font-size: 1.4rem; }
.login-box h1 b { color: var(--brand); }
.login-tagline { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0.35rem 0 1.5rem; }
.login-box form { display: flex; flex-direction: column; gap: 0.9rem; }
.login-box label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.login-box input { font: inherit; padding: 0.55rem 0.7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.login-box input:focus { border-color: var(--accent); outline: none; }
.login-box button { font: inherit; padding: 0.6rem; border: none; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.login-box .error { text-align: center; font-size: 0.85rem; margin: 0; }

/* ---------- Stock page ---------- */
.chart-card { padding: 0.5rem; }
#chart { width: 100%; height: 520px; }
.stock-name { font-family: var(--font); font-weight: 500; color: var(--muted); }
.range-bar { position: relative; height: 6px; border-radius: 3px; background: var(--seg-off); margin-top: 0.35rem; }
.range-bar i { position: absolute; top: -3px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--accent); }
#spurt-chart { width: 100%; height: 300px; }
.history-scroll { max-height: 480px; overflow-y: auto; }
.history-scroll thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

/* ---------- Prime Corner ---------- */
.stamp .pill i.off { background: var(--faint); }
.auto-refresh { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); cursor: pointer; }
.st-main { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
table.grid td .sub { font-size: 0.72rem; color: var(--faint); font-weight: 400; }

.ladder-col { min-width: 120px; }
.ladder { position: relative; height: 14px; width: 110px; }
.ladder-track { position: absolute; left: 0; right: 0; top: 6px; height: 2px; border-radius: 1px; background: var(--seg-off); }
.ladder-fill { position: absolute; top: 5px; height: 4px; border-radius: 2px; }
.ladder-fill.up { background: var(--up); }
.ladder-fill.down { background: var(--down); }
.ladder-tick { position: absolute; top: 2px; width: 2px; height: 10px; margin-left: -1px; border-radius: 1px; background: var(--muted); }
.ladder-tick.sl { background: var(--down); }
.ladder-tick.tg1.hit { background: var(--up); }
.ladder-dot { position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.ladder-labels { display: flex; justify-content: space-between; width: 110px; font-size: 0.62rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }

.chart-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
@media (max-width: 1000px) { .chart-pair { grid-template-columns: minmax(0, 1fr); } }
.perf-chart { height: 280px; padding: 0.5rem 0.5rem 0; }

/* ---------- F&O Corner ---------- */
.bu { font-size: 0.7rem; padding: 0.12rem 0.45rem; }
.bu-long-buildup { background: color-mix(in srgb, var(--up) 14%, transparent); color: var(--up); }
.bu-short-buildup { background: color-mix(in srgb, var(--down) 13%, transparent); color: var(--down); }
.bu-short-covering { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.bu-long-unwinding { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.oi-pick { display: inline-block; font-family: var(--mono); font-weight: 600; font-size: 0.82rem; margin-right: 0.6rem; cursor: help; }
.oi-pick:first-child { text-decoration: underline; text-underline-offset: 3px; }

.oc-wrap { max-height: 78vh; }
table.oc { font-size: 0.8rem; }
table.oc th, table.oc td { padding: 0.42rem 0.5rem; }
table.oc thead tr.oc-side th { position: static; text-align: center; font-size: 0.72rem; letter-spacing: 0.1em; padding: 0.4rem; }
table.oc thead tr:nth-child(2) th { top: 0; }
.oc-calls { color: var(--down) !important; border-right: 1px solid var(--line); }
.oc-puts { color: var(--up) !important; border-left: 1px solid var(--line); }
table.oc .oc-strike {
  text-align: center; font-family: var(--mono); font-weight: 600; color: var(--text);
  background: var(--raised); border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
table.oc td.itm { background: color-mix(in srgb, var(--accent) 6%, transparent); }
table.oc tbody tr:hover td.itm { background: color-mix(in srgb, var(--accent) 11%, var(--raised)); }
table.oc tr.oc-atm td { border-top: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
table.oc tr.oc-atm .oc-strike { color: var(--accent); }
.atm-tag { font-family: var(--font); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; margin-left: 0.35rem; color: var(--accent); vertical-align: 0.15em; }
table.oc tr.oc-spot td { padding: 0; border-bottom: 0; height: 1.3rem; position: relative; background: none !important; }
table.oc tr.oc-spot td span {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  background: var(--accent); color: var(--accent-ink); font-size: 0.68rem; font-weight: 700;
  padding: 0.1rem 0.55rem; border-radius: 999px; white-space: nowrap;
}
table.oc tr.oc-spot td::before { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 1px); border-top: 2px solid var(--accent); }
.oi-cell { position: relative; display: inline-flex; justify-content: flex-end; min-width: 84px; }
.oi-cell span:last-child { position: relative; }
.oi-bar { position: absolute; top: -0.2rem; bottom: -0.2rem; border-radius: 3px; opacity: 0.22; }
.oi-bar.ce { right: 0; background: var(--down); }
.oi-bar.pe { right: 0; background: var(--up); }

/* ---------- Guide ---------- */
.guide-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.guide-toc { position: sticky; top: 1rem; display: flex; flex-direction: column; padding: 0.7rem 0.5rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.guide-toc-h { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 0 0.55rem 0.4rem; }
.guide-toc-group { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--faint); padding: 0.8rem 0.55rem 0.25rem; }
.guide-toc a { color: var(--muted); text-decoration: none; font-size: 0.84rem; padding: 0.3rem 0.55rem; border-radius: 6px; }
.guide-toc a:hover { color: var(--text); background: var(--raised); }
.guide-toc a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.guide-body { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.guide-sec { scroll-margin-top: 1rem; }
.guide-kicker { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 0.15rem; }
.guide-open { font-size: 0.84rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.prose { font-size: 0.9rem; line-height: 1.6; max-width: 72ch; }
.prose p, .prose ul, .prose ol { margin: 0 0 0.8rem; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li { margin-bottom: 0.35rem; }
.prose h3 { font-size: 0.86rem; font-weight: 600; margin: 1.1rem 0 0.5rem; color: var(--text); }
.prose > :last-child { margin-bottom: 0; }
.guide-steps li::marker { color: var(--accent); font-weight: 700; }
.guide-flow { list-style: none; padding: 0 !important; display: flex; flex-direction: column; gap: 0.6rem; }
.guide-flow li { display: flex; gap: 0.75rem; align-items: flex-start; margin: 0; }
.gf-n { flex-shrink: 0; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.guide-tip { border-left: 3px solid var(--accent); background: var(--raised); padding: 0.65rem 0.85rem; border-radius: 0 8px 8px 0; font-size: 0.86rem; margin: 0.9rem 0 0; }
.guide-table { margin: 0.2rem 0 0.8rem; font-size: 0.84rem; }
.guide-criteria { columns: 2; column-gap: 2rem; }
.guide-criteria li { break-inside: avoid; }
.guide-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.75rem; max-width: none; }
.guide-mini { background: var(--raised); border: 1px solid var(--line-soft); border-radius: 8px; padding: 0.75rem 0.9rem; }
.guide-mini h3 { margin: 0 0 0.35rem; }
.guide-mini p { margin: 0; font-size: 0.85rem; }
.prose:has(.guide-cards), .prose:has(.guide-fig) { max-width: none; }
.guide-fig { margin: 0 0 1rem; }
.guide-fig svg { width: 100%; max-width: 620px; height: auto; display: block; }
.guide-fig figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; max-width: 72ch; }
.guide-fig .f-price { fill: none; stroke: var(--text); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.guide-fig .f-pivot { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; }
.guide-fig .f-low { stroke: var(--down); stroke-width: 1.2; stroke-dasharray: 3 4; }
.guide-fig .f-base { fill: var(--accent-soft); stroke: none; }
.guide-fig .f-dot { fill: var(--accent); }
.guide-fig .f-vol rect { fill: var(--seg-off); }
.guide-fig .f-volspike { fill: var(--accent); }
.guide-fig .f-lbl { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.guide-fig .f-acc { fill: var(--accent); font-weight: 600; }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0.2rem 1.5rem; margin: 0; }
.glossary > div { padding: 0.55rem 0; border-bottom: 1px solid var(--line-soft); }
.glossary dt { font-weight: 600; font-size: 0.88rem; }
.glossary dd { margin: 0.15rem 0 0; font-size: 0.84rem; color: var(--muted); line-height: 1.5; }
.stage-list { margin: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.stage-list > div { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 0.75rem; align-items: baseline; }
.stage-list dt { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.stage-list dd { margin: 0; }
.faq details { border-bottom: 1px solid var(--line-soft); padding: 0.55rem 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq summary:hover { color: var(--accent); }
.faq details p { margin: 0.45rem 0 0.2rem; color: var(--muted); }
@media (max-width: 1000px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr); }
  .guide-toc { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; gap: 0.15rem; }
  .guide-toc-h, .guide-toc-group { display: none; }
}
@media (max-width: 560px) {
  .guide-criteria { columns: 1; }
  .stage-list > div { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .glossary { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 0.5rem 1rem; overflow-x: auto; gap: 0.5rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { padding: 0 0.75rem 0 0; }
  .sidebar-brand .wordmark { display: none; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-nav a { white-space: nowrap; }
  .sidebar-group-label, .sidebar-foot { display: none; }
  .topbar { padding: 0.5rem 1rem; }
  .user-menu-name { display: none; }
  .container { padding: 1rem; }
  .stamp { align-items: flex-start; }
}
@media (prefers-reduced-motion: no-preference) {
  .sidebar-nav a, .screen-tabs a, .seg-ctl a, .pagination a, .filters button { transition: background-color 0.12s, color 0.12s, border-color 0.12s; }
}

.community-link { display: inline-block; padding: 0.5rem 0.95rem; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.community-link:hover { filter: brightness(1.08); text-decoration: none; }
