/* kavach.dashweb — mobile-first token system.
   Mirrors the project's report-artifact design language: near-neutral paper,
   one teal accent, tabular-nums, 1px-bordered cards. Light/dark via
   prefers-color-scheme, with an explicit [data-theme] override that wins. */

:root {
  --paper:      #f7f7f5;
  --card:       #ffffff;
  --ink:        #1c1d1f;
  --muted:      #6b6f76;
  --faint:      #9aa0a6;
  --line:       #e3e4e6;
  --line-soft:  #eeeef0;
  --accent:     #0e7467;
  --accent-bg:  rgba(14,116,103,0.08);
  --pos:        #1a7f4b;
  --neg:        #c0392b;
  --warn:       #b8791b;
  --warn-bg:    rgba(184,121,27,0.10);
  --live:       #1a7f4b;
  --paper-badge:#6b6f76;
  --radius:     12px;
  --shadow:     0 1px 2px rgba(0,0,0,0.04);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper:#131416; --card:#1c1e21; --ink:#e8e9ea; --muted:#9aa0a6; --faint:#6b6f76;
    --line:#2c2f33; --line-soft:#26282b; --accent:#3fbfae; --accent-bg:rgba(63,191,174,0.12);
    --pos:#4ecb83; --neg:#e5705f; --warn:#e0ad5b; --warn-bg:rgba(224,173,91,0.12);
    --live:#4ecb83; --shadow:0 1px 2px rgba(0,0,0,0.3);
  }
}
:root[data-theme="light"] {
  --paper:#f7f7f5; --card:#ffffff; --ink:#1c1d1f; --muted:#6b6f76; --faint:#9aa0a6;
  --line:#e3e4e6; --line-soft:#eeeef0; --accent:#0e7467; --accent-bg:rgba(14,116,103,0.08);
  --pos:#1a7f4b; --neg:#c0392b; --warn:#b8791b; --warn-bg:rgba(184,121,27,0.10);
  --live:#1a7f4b; --shadow:0 1px 2px rgba(0,0,0,0.04);
}
:root[data-theme="dark"] {
  --paper:#131416; --card:#1c1e21; --ink:#e8e9ea; --muted:#9aa0a6; --faint:#6b6f76;
  --line:#2c2f33; --line-soft:#26282b; --accent:#3fbfae; --accent-bg:rgba(63,191,174,0.12);
  --pos:#4ecb83; --neg:#e5705f; --warn:#e0ad5b; --warn-bg:rgba(224,173,91,0.12);
  --live:#4ecb83; --shadow:0 1px 2px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--sans);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  padding-bottom: 76px; /* room for the sticky bottom nav */
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
a { color: var(--accent); text-decoration: none; }

/* ── layout ─────────────────────────────────────────────────────────────── */
.wrap { max-width: 720px; margin: 0 auto; padding: 12px 14px 24px; }
header.app {
  position: sticky; top: 0; z-index: 20; background: var(--card);
  border-bottom: 1px solid var(--line); padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
header.app .brand { font-weight: 650; letter-spacing: -0.01em; display: flex; gap: 8px; align-items: baseline; }
header.app .brand small { color: var(--muted); font-weight: 500; font-size: 11px; }
header.app .who { color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 4px 8px; font-size: 13px; cursor: pointer; }

h1,h2,h3 { letter-spacing: -0.01em; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 18px 2px 8px; font-weight: 600; }

/* ── cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 10px; }
.grid.cards-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cards-3 { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 560px) { .grid.cards-auto { grid-template-columns: repeat(3, 1fr); } }
.grid.cards-auto { grid-template-columns: repeat(2, 1fr); }

/* /more hub (2026-09-03): the phone bottom-nav's "More" tab — a plain list of
   links to the pages the 4-tab bar has no room for. */
.more-list { display: flex; flex-direction: column; gap: 2px; }
.more-link { color: var(--ink); display: flex; align-items: center; gap: 12px;
  font-size: 15px; padding: 12px 10px; border-radius: 10px; border-bottom: 1px solid var(--line-soft); }
.more-link:last-child { border-bottom: none; }
.more-link .ic { font-size: 18px; line-height: 1; width: 22px; text-align: center; }
.more-link:hover { background: var(--line-soft); }

/* book strip card */
.book {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.book.stale { border-color: var(--warn); }
.book.broken { border-color: var(--neg); }
.book .top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.book .name { font-size: 12px; color: var(--muted); font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.book .pnl { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.book .sub { font-size: 11px; color: var(--faint); }
.book .warn { font-size: 11px; color: var(--warn); font-weight: 600; }

.badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--line); white-space: nowrap; }
.badge.live { color: var(--live); border-color: color-mix(in srgb, var(--live) 40%, transparent); }
.badge.paper { color: var(--paper-badge); }
.badge.off { color: var(--faint); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
/* small text utility (2026-09-03): the live-parameter captions replacing the
   analysis tabs' what-if forms — a step down from body text, same family. */
.small { font-size: 12px; }

/* ── open-trade cards ───────────────────────────────────────────────────── */
.trade { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  background: var(--card); display: flex; flex-direction: column; gap: 8px; }
.trade .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.trade .dir { font-weight: 650; }
.trade .dir.bull { color: var(--pos); }
.trade .dir.bear { color: var(--neg); }
.trade .legs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 13px; }
.trade .legs .k { color: var(--muted); font-size: 11px; display: block; }
.chip { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

/* ── Today: positions by book (2026-09-11) ─────────────────────────────────
   Phone-first: one column of dense cards; the leg table is the only element
   allowed to be wider than the card, inside its own overflow-x wrapper. */
.pos-books { display: flex; flex-direction: column; gap: 14px; }
.pos-book { display: flex; flex-direction: column; gap: 6px; }
.pos-book-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 4px; font-size: 12px; }
.pos-book-label { font-size: 14px; font-weight: 650; color: var(--ink); letter-spacing: -0.01em; }
.pos-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  font-weight: 600; margin-top: 2px; }
.pos-cards { display: grid; gap: 8px; }
@media (min-width: 720px) { .pos-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pos-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
  background: var(--card); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pos-card.is-closed { background: var(--paper); }
.pos-card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pos-card .dir { font-weight: 650; font-size: 14px; }
.pos-card .dir.bull { color: var(--pos); }
.pos-card .dir.bear { color: var(--neg); }
.pos-pnl { font-weight: 650; white-space: nowrap; }
.pos-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; align-items: center; }
.pos-exit { font-weight: 600; color: var(--ink); }
.pos-legs-wrap { overflow-x: auto; }
.pos-legs { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pos-legs th { font-size: 10px; font-weight: 600; color: var(--muted); text-align: right;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 0 3px 2px; }
.pos-legs td { text-align: right; padding: 3px 3px; border-top: 1px solid var(--line-soft); white-space: nowrap; }
.pos-legs th:first-child, .pos-legs td:first-child,
.pos-legs th:nth-child(2), .pos-legs td:nth-child(2) { text-align: left; }
.side { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; letter-spacing: 0.03em; }
.side-sell { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.side-buy { background: color-mix(in srgb, var(--pos) 14%, transparent); color: var(--pos); }
.pos-line { font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline; }
.pos-line .k { color: var(--muted); font-size: 11px; min-width: 64px; }
.pos-id { font-size: 10px; overflow-wrap: anywhere; }
.pos-foot { margin-top: 8px; }

/* ── day plan ───────────────────────────────────────────────────────────── */
.regime { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.regime .chip-lg { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.regime .meta { color: var(--muted); font-size: 13px; }
.ruleset { margin: 6px 0 0; padding: 0; list-style: none; }
.ruleset li { padding: 6px 0 6px 20px; position: relative; border-top: 1px solid var(--line-soft);
  font-size: 14px; }
.ruleset li:first-child { border-top: none; }
.ruleset li::before { content: "›"; position: absolute; left: 4px; color: var(--accent); font-weight: 700; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.plan-head .engine { font-family: var(--mono); font-size: 12px; color: var(--accent);
  background: var(--accent-bg); padding: 2px 7px; border-radius: 6px; }
/* right-hand cluster (index badge + status chip) on the Book C card head */
.plan-head .head-right { display: inline-flex; align-items: center; gap: 6px; flex: none; }
/* neutral/muted status chip (Book C IDLE) — same pill as .chip / .chip.warn */
.chip.muted { background: var(--line-soft); color: var(--muted); }
/* stale-payload chip: the precompute worker has not refreshed this payload */
.chip.chip-stale { background: var(--warn-bg); color: var(--warn); }

/* ── tap-friendly hint popover (2026-09-11) ────────────────────────────────
   A native <details>/<summary> — no JS, works with a tap on a phone (a
   `title` attribute alone never fires on touch) and a click on desktop.
   Used on Chain (strip metrics, IV smile) and Performance (book/sleeve/lots/
   cadence) wherever the operator asked for plain-English clarity on what a
   number or control means. `position:relative` on `.hint` gives the popover
   an anchor without pushing surrounding text — it overlays instead of
   reflowing the card. */
.hint { display: inline-block; position: relative; margin-left: 3px; vertical-align: middle; }
.hint summary { list-style: none; cursor: pointer; width: 15px; height: 15px; line-height: 14px;
  text-align: center; font-size: 11px; border-radius: 50%; border: 1px solid var(--line);
  color: var(--muted); background: var(--card); user-select: none; }
.hint summary::-webkit-details-marker { display: none; }
.hint[open] summary { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.hint-body { position: absolute; z-index: 40; top: 20px; left: 0; width: max-content;
  max-width: min(260px, 78vw); background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; font-weight: 400; line-height: 1.4;
  box-shadow: var(--shadow); }

/* Book B components — a 2×2 grid on desktop (B1 B2 / B3 B4), single column on
   mobile. Grid rows stretch so the two cards in a row stay equal-height. The
   Manager-gates card sits OUTSIDE this grid and stays full-width. */
.bookb-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 10px; }
@media (min-width: 900px) { .bookb-grid { grid-template-columns: repeat(2, 1fr); } }

/* timeline */
/* ── day-plan timeline (redrawn 2026-09-11) ────────────────────────────────
   A vertical list, one row per event, in time order: two events a minute
   apart (09:15 Book A open / 09:16 Book C open) just become two adjacent
   rows instead of two labels fighting for the same few horizontal pixels —
   this can never overlap no matter how dense the day gets, on any screen
   width. `.tl-row.now` is highlighted so "where we are" reads as a live
   marker among the fixed events, not one more row to parse. */
.timeline-list { display: flex; flex-direction: column; }
.timeline-list .tl-row {
  display: grid; grid-template-columns: 50px 14px 1fr; column-gap: 8px;
  align-items: center; padding: 5px 2px; border-radius: 6px;
}
.timeline-list .tl-time { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.timeline-list .tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); justify-self: center; }
.timeline-list .tl-row.square_off .tl-dot { background: var(--neg); }
.timeline-list .tl-row.cap_deadline .tl-dot { background: var(--warn); }
.timeline-list .tl-row.market_open .tl-dot { background: var(--accent); }
.timeline-list .tl-label { font-size: 12px; color: var(--ink); }
.timeline-list .tl-row.now { background: var(--accent-bg); font-weight: 600; }
.timeline-list .tl-row.now .tl-dot { background: var(--ink); width: 10px; height: 10px; }
.timeline-legend { font-size: 11px; color: var(--faint); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }

.warn-banner { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 10px 0; }

/* ── charts ─────────────────────────────────────────────────────────────── */
.chart-box { height: 300px; width: 100%; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 40px 0; text-align: center; }

/* ── Today's trades (Charts tab) — grouped per-book cards ─────────────────── */
.tt-books { display: flex; flex-direction: column; gap: 16px; }
.tt-book { display: flex; flex-direction: column; gap: 8px; }
.tt-book-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.tt-book-label { font-size: 13px; font-weight: 650; color: var(--ink); letter-spacing: -0.01em; }
.tt-nd { font-size: 12px; font-style: italic; }
.tt-empty { font-size: 12px; padding: 2px 2px 4px; }
.tt-cards { display: grid; gap: 10px; }
@media (min-width: 560px) { .tt-cards { grid-template-columns: repeat(2, 1fr); } }
.tt-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  background: var(--card); display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.tt-card .dir { font-weight: 650; }
.tt-card .dir.bull { color: var(--pos); }
.tt-card .dir.bear { color: var(--neg); }
.tt-card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tt-card .legs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 13px; }
.tt-card .legs .k { color: var(--muted); font-size: 11px; display: block; }
.tt-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; align-items: center; }
/* "backtest ↗" — the one link from a recorded row to that date's Inspector
   (Task 8, 2026-09-09: the re-simulated charts that used to sit inside the card
   were removed; the backtest now lives on a page that says it is one). */
.tt-card .insp-link { margin-left: auto; font-size: 11px; font-weight: 600;
  color: var(--muted); text-decoration: none; white-space: nowrap; }
.tt-card .insp-link:hover { color: var(--accent); text-decoration: underline; }
.tt-chart-wrap { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.tt-chart { display: none; }                 /* mobile: no ECharts bundle */
.tt-chart-note { font-size: 11px; }
/* ── Book D (2026-09-11 chart redesign) ───────────────────────────────────
   The three-panel chart renders at EVERY width — the Charts tab loads ECharts
   on phones too, and the operator reads Book D there. Tall on purpose: three
   stacked panels + a legend + a slider. The header strip wraps on a phone. */
.tt-chart.bookd-chart { display: block; height: 620px; width: 100%; }
.chart-box-bookd { height: 620px; width: 100%; }
.bt-chart.bt-chart-d { height: 560px; }
.bd-head { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 8px; font-size: 12px; }
.bd-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.bd-leg { white-space: nowrap; }
.bd-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.bd-tile { display: flex; flex-direction: column; gap: 1px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px; }
.bd-tile .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.bd-tile .v { font-size: 15px; font-weight: 650; }
.bd-tile .sub { font-size: 10px; overflow-wrap: anywhere; }
.bd-note { font-size: 11px; font-style: italic; padding: 0 2px 4px; }
.bd-howto { font-size: 12px; color: var(--muted); margin: 4px 0; }
.bd-howto summary { cursor: pointer; font-weight: 600; }
.bd-howto p { margin: 4px 0; }
.bd-hedges { display: flex; flex-direction: column; gap: 2px; font-size: 12px; margin: 4px 0 6px; }
.bd-hedge { display: flex; flex-wrap: wrap; gap: 6px; }
.bd-fid { font-size: 11px; padding: 3px 8px; margin-left: auto; }
@media (max-width: 420px) {
  .bd-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tt-chart.bookd-chart, .chart-box-bookd { height: 600px; }
}
/* ── the per-book BACKTEST strip (Task 4, 2026-09-10) ──────────────────────
   The record's own charts under a book's live rows. Phone: a horizontal
   scroller (the `.tbl-scroll` pattern — one card at a time, swipe for the
   next), so a 12-trade day does not push the next book off the screen.
   Desktop: a 2-column grid. Unlike `.tt-chart` these boxes DO render on mobile
   (the Charts tab loads ECharts for both). */
.bt-wrap { border-top: 1px dashed var(--line); padding-top: 8px; display: flex;
  flex-direction: column; gap: 8px; }
.bt-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 11px; }
.chip.bt-badge { background: var(--line-soft); color: var(--muted); font-weight: 600;
  letter-spacing: 0.02em; }
/* The live-fill chip carries the SAME colour the JS draws the markPoints in
   (charts.html LIVE_FILL_COLOR) — one visual identity for "this is the broker
   fill, not the backtest". */
.chip.bt-live { background: rgba(142, 36, 170, 0.12); color: #8E24AA; font-weight: 600; }
/* …and the strikes chip is a WARNING, not decoration: it is the card saying it
   could not prove this backtest trade is the live one (2026-09-07). */
.chip.bt-chip { background: var(--warn-bg); color: var(--warn); }
.bt-strip { display: flex; gap: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory; padding-bottom: 4px; }
.bt-card { flex: 0 0 88%; scroll-snap-align: start; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; background: var(--card);
  display: flex; flex-direction: column; gap: 6px; }
.bt-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.bt-title { font-size: 12px; font-weight: 650; color: var(--ink); }
.bt-sub { font-size: 11px; }
.bt-chart { height: 230px; width: 100%; }
/* LIVE per-trade chart under a Book A / C row (2026-09-11) — renders on mobile. */
.lv-card { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; margin: -2px 0 8px; }
.lv-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 11px; }
.chip.lv-badge { background: var(--accent-bg, rgba(14,116,103,0.12)); color: var(--accent); font-weight: 600; }
.lv-chart { height: 220px; width: 100%; }
.lv-note { font-size: 12px; font-style: italic; padding: 2px 2px 8px; }
@media (min-width: 900px) {
  .bt-strip { display: grid; grid-template-columns: repeat(2, 1fr); overflow-x: visible; }
  .bt-card { flex: none; }
  .bt-chart { height: 300px; }
}

/* SENSEX spot chart (Book C group header) — visible on mobile + desktop. */
.tt-sensex { margin: 2px 0 4px; }
.tt-sensex-note { font-size: 12px; font-style: italic; padding: 8px 2px; }
@media (min-width: 900px) {
  .tt-cards { grid-template-columns: 1fr; }  /* full-width so the chart has room */
  .tt-chart { display: block; height: 360px; width: 100%; }
  .tt-chart-note { display: none; }
}
select, .btn { font-family: var(--sans); font-size: 14px; }
select { background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; }

/* ── tables ─────────────────────────────────────────────────────────────── */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── /chain: NIFTY option-chain table (2026-09-03) ─────────────────────────
   Mirrored CE | strike | PE layout (research mock, plan §6): each side reads
   outward from the strike column, so the OI in-cell bar is anchored TOWARD
   the strike it is next to — `.bar` (CE, left of strike) grows leftward from
   the strike-side edge, `.barp` (PE, right of strike) grows rightward from
   its strike-side edge — via the `--w` custom property each cell sets
   inline (`style="--w: NN%"`). */
.chain-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chain-tabs a.chip { cursor: pointer; }
.chain-legend { margin: -2px 0 8px; }
.chain-updated { margin-left: 6px; }
/* Density pass (2026-09-04, operator: "make this more readable, better
   user experience") — tighter than the generic `table.data` rule so a
   ±10-strike chain fits without excess scrolling. `.num` (already on the
   table's class list) supplies tabular-nums. */
table.chain-table th, table.chain-table td { padding: 4px 6px; font-size: 13px; white-space: nowrap; }
/* Header row is NOT sticky: the table lives inside `.tbl-scroll`, its own
   overflow-x container, so `position: sticky; top` measures against THAT
   box, not the page — it never pins during page scroll, and any top offset
   just pushes the header down over the first data rows (found in a real
   render 2026-09-04). A solid background + bottom border is enough for it
   to read as a header. */
table.chain-table thead th {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
/* The strike column is the table's spine: it stays visually anchored while
   CE/PE scroll horizontally underneath it (a true `position: sticky` left/
   right doesn't apply to a MIDDLE column, so this is a solid background +
   a stronger border, not actual horizontal pinning). */
table.chain-table td.strike-col, table.chain-table th.strike-col {
  text-align: center; font-weight: 700; white-space: nowrap;
  background: var(--card); border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
table.chain-table tr.atm td {
  background: var(--accent-bg); font-weight: 600;
  border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
}
table.chain-table tr.atm td.strike-col { background: var(--accent-bg); }
table.chain-table td.itm { background: var(--line-soft); }
table.chain-table tr.atm td.itm { background: var(--accent-bg); }
table.chain-table td.stale { opacity: 0.45; }
table.chain-table td.outline { box-shadow: inset 0 0 0 1px var(--accent); }
.chain-table .bar, .chain-table .barp {
  display: inline-block; padding: 2px 5px; border-radius: 4px; --w: 0%;
}
.chain-table .bar { background: linear-gradient(to left, var(--accent-bg) var(--w), transparent 0); }
.chain-table .barp { background: linear-gradient(to right, var(--accent-bg) var(--w), transparent 0); }
.chip.outline { background: transparent; border: 1px solid var(--accent); color: var(--accent);
  padding: 1px 6px; font-size: 11px; margin: 0 4px; white-space: nowrap; }
/* ATM strike chip — filled (vs. the outline own-leg chips) so it reads as a
   marker, not a position tag. */
.chip.chip-atm { background: var(--accent); color: var(--card); font-size: 11px;
  padding: 1px 6px; margin-right: 4px; white-space: nowrap; }
/* Expiry-clamp chip (2026-09-10): inside 15 min of the expiry close the four
   Greeks are withheld, and this marks the rows it applies to. Warning-toned,
   not alarming — the data is fine, the maths is the part that stops meaning
   anything. */
.chip.chip-exp { background: color-mix(in srgb, var(--neg) 12%, transparent);
  color: var(--neg); font-size: 11px; padding: 1px 6px; margin-right: 4px;
  white-space: nowrap; }
/* Near-tied OI wall: the runner-up strike is within 5% of the top one. */
.chip.chip-approx { background: transparent; color: var(--muted);
  font-size: 11px; padding: 0 3px; }
/* Price-tab buildup chip: LB/SC tinted with the --pos token (bullish OI
   read), SB/LU with --neg (bearish) — same variables as .pos/.neg text. */
.chip.bu-lb, .chip.bu-sc { background: color-mix(in srgb, var(--pos) 15%, transparent); color: var(--pos); }
.chip.bu-sb, .chip.bu-lu { background: color-mix(in srgb, var(--neg) 15%, transparent); color: var(--neg); }
/* Plain value cells (OI, LTP, IV, Greeks, depth, straddle) were inheriting
   the muted body colour and reading as low-contrast grey (found in a real
   render 2026-09-04); .pos/.neg and .muted below both have higher
   specificity and keep overriding this. */
table.chain-table td { color: var(--ink); }
/* Sign-coloured ΔOI/price-change cells (price tab only — never raw OI/LTP). */
table.chain-table td.pos { color: var(--pos); }
table.chain-table td.neg { color: var(--neg); }

/* ── F7 (2026-09-10): signed in-cell bar on the ΔOI-day column ────────────
   Same `--w` mechanism as the OI bars above, but the SIGN picks the
   direction: OI added grows rightward in the --pos token, OI removed grows
   leftward in --neg, so a column of them reads as a build/unwind profile
   without anyone parsing the numbers. Scaled to the largest |ΔOI| in the
   shown window (chain_view: `ce_dbar`/`pe_dbar`), one shared CE/PE scale.
   The span carries the class, never the <td>: a background on the cell
   would paint over the ITM/ATM shading the row already uses. */
.chain-table .dbar {
  display: inline-block; padding: 2px 5px; border-radius: 4px; --w: 0%;
}
.chain-table .dbar.pos {
  background: linear-gradient(to right, color-mix(in srgb, var(--pos) 20%, transparent) var(--w), transparent 0);
}
.chain-table .dbar.neg {
  background: linear-gradient(to left, color-mix(in srgb, var(--neg) 20%, transparent) var(--w), transparent 0);
}

/* ── F3 (2026-09-10): the IV smile sparkline ──────────────────────────────
   An SVG chain.js writes from the embedded numbers (no chart library). The
   current expiry is solid, the other one dashed — one shared y-scale, since
   the reason to draw both is comparing them. `height` is fixed and the
   viewBox is stretched to the card's width, so it stays a 140px strip on a
   phone as well as a desktop. */
.chain-smile-card { margin-bottom: 8px; padding: 6px 10px 2px; }
svg.chain-smile { display: block; width: 100%; height: 140px; }
svg.chain-smile .smile-line { fill: none; stroke-width: 1.5; }
svg.chain-smile .smile-ce { stroke: var(--accent); }
svg.chain-smile .smile-pe { stroke: var(--neg); }
svg.chain-smile .smile-atm { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }

/* ── IV smile: title, legend, axis labels (2026-09-11) ────────────────────
   Operator: "close to three lines or four lines and there is one line at
   the middle ... no naming of those lines ... title is also missing ...
   maybe some kind of scale as well." The legend swatches reuse the exact
   colours/dash the SVG lines are drawn in (smile-ce/smile-pe/smile-atm
   above) so the key and the chart can never drift apart. Axis tick labels
   are plain HTML, not SVG <text> — see chain.js's drawSmile() comment on why
   text inside a non-uniformly stretched viewBox would smear — positioned by
   CSS at the chart's fixed padding, with only their text content rewritten
   each poll. */
.chain-smile-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.chain-smile-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0; }
.chain-smile-legend .lg-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.chain-smile-legend .lg-swatch { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--muted); }
.chain-smile-legend .lg-ce { border-top-color: var(--accent); }
.chain-smile-legend .lg-pe { border-top-color: var(--neg); }
.chain-smile-legend .lg-dashed { border-top-style: dashed; }
.chain-smile-legend .lg-atm { border-top-color: var(--muted); border-top-style: dashed; }
.chain-smile-wrap { position: relative; margin-top: 2px; }
.chain-smile-axis-y, .chain-smile-axis-x { position: absolute; font-size: 9px; color: var(--faint);
  pointer-events: none; white-space: nowrap; }
.chain-smile-axis-y.y-top { top: 2px; left: 4px; }
.chain-smile-axis-y.y-bottom { bottom: 12px; left: 4px; }
.chain-smile-axis-x.x-min { bottom: 0; left: 4px; }
.chain-smile-axis-x.x-max { bottom: 0; right: 4px; }
.chain-smile-atm-label { position: absolute; top: 2px; font-size: 9px; color: var(--muted);
  transform: translateX(-50%); pointer-events: none; white-space: nowrap; }
.chain-smile-atm-label[hidden] { display: none; }

/* ── phase 5 (2026-09-10): strip sparklines, flag chip, wall-break line ───
   `svg.chain-spark` is a fixed 90x24 box (NOT stretched — the viewBox matches
   the CSS size, so a 1px stroke stays 1px and needs no vector-effect). The
   first series of a cell is solid in the accent, the rest are dashed and
   muted; the dot marks the primary series' latest point. Hidden under 560px:
   a phone pays for every pixel above the table, and the HARD rule for this
   page is that the phone must not scroll more than it did before. */
svg.chain-spark { display: block; width: 90px; height: 24px; margin-top: 3px; }
svg.chain-spark .spark-line { fill: none; stroke-width: 1; }
svg.chain-spark .spark-a { stroke: var(--accent); }
svg.chain-spark .spark-b { stroke: var(--muted); }
svg.chain-spark .spark-dot { fill: var(--accent); stroke: none; }
/* Unusual-ΔOI flag: the leg's own OI change this cycle is unlike its own
   recent ones. A marker, not an alarm — the accent, not --neg. */
.chip.chip-flag { background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent); font-size: 11px; padding: 0 4px; margin-left: 4px;
  white-space: nowrap; }
/* The day's wall breaks, newest first, directly under the strip card. */
.chain-events { display: flex; gap: 14px; flex-wrap: wrap; margin: -4px 0 8px; }

/* ── D5 (2026-09-10): per-strike 5-level depth drawer ─────────────────────
   A second <tr> under each depth row, server-rendered `hidden` and toggled
   by chain.js. Nothing here may set `display` on `tr.chain-drawer` itself
   except through the [hidden] rule below — the attribute IS the open/closed
   state, so a stray `display: table-row` would pin every drawer open. */
table.chain-table tr.chain-drawer[hidden] { display: none; }
table.chain-table tr.chain-drawer > td { background: var(--line-soft); padding: 6px 10px; }
.chain-drawer-body { display: flex; gap: 18px; flex-wrap: wrap; }
.chain-drawer-side { min-width: 210px; }
table.chain-ladder { border-collapse: collapse; margin-top: 3px; }
table.chain-ladder td { padding: 1px 8px 1px 0; font-size: 12px; border: 0; white-space: nowrap; }
table.chain-ladder td.bidside { color: var(--pos); }
table.chain-ladder td.askside { color: var(--neg); }
a.chain-drawer-toggle { color: var(--muted); text-decoration: none; margin-right: 4px;
  cursor: pointer; font-weight: 400; }
a.chain-drawer-toggle.open { color: var(--accent); }
/* F6 (phase 5): the drawer's LTP+OI day path. Two independent y-scales in one
   box (see chain.js) — LTP solid in the accent, OI dashed and muted. Rendered
   `hidden` and un-hidden by chain.js only once it has a series, so a strike
   outside the writer's ATM±20 path window leaves the drawer as it was.
   `[hidden]` needs an explicit rule here: the UA stylesheet's `[hidden]` is
   namespaced to HTML and does not reach an SVG element. */
svg.chain-path { display: block; width: 100%; max-width: 220px; height: 44px;
  margin-top: 5px; }
svg.chain-path[hidden] { display: none; }
svg.chain-path .path-ltp { fill: none; stroke: var(--accent); stroke-width: 1; }
svg.chain-path .path-oi { fill: none; stroke: var(--muted); stroke-width: 1;
  stroke-dasharray: 3 2; }

/* ── F4 (2026-09-10): the /chain/replay minute scrubber ──────────────
   The replay page reuses every table rule above unchanged (that is the point:
   the live chain and the replayed one must look like the same chain) and adds
   only the control row. The range input takes the whole width it can get — a
   375-position slider on a phone needs every pixel to be draggable minute by
   minute — and the clock beside it is tabular so the numbers do not jitter as
   they change. */
.replay-scrub { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; }
.replay-scrub input[type="range"] { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); }
.replay-scrub input[type="range"]:disabled { opacity: 0.4; }
#replay-clock { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── D7 (2026-09-10): column priority on narrow screens ───────────────────
   The mirrored price table is 17 columns wide; on a phone that is all
   horizontal scrolling and no reading. Each cell declares its priority in
   the markup (col-p1 = OI/ΔOI day/LTP/IV, always shown; col-p2 = Build/Chg;
   col-p3 = ΔOI %/ΔOI 1st) and the two breakpoints below drop the lower ones.
   `.chain-allcols` (chain.js puts it on #chain-root from the "All cols"
   chip, remembered in localStorage) brings them all back — it wins on
   specificity, so the escape hatch works at every width. */
@media (max-width: 899px) {
  table.chain-table .col-p3 { display: none; }
  .chain-allcols table.chain-table .col-p3 { display: table-cell; }
}
/* The "All cols" chip (2026-09-11) is only rendered on the Price tab (the one
   tab with anything to hide) and does nothing at all up here — every column
   already shows once col-p3 stops being dropped above — so hide the control
   itself rather than leave a button an operator can tap for no visible
   change (memory: "I don't see any visual change when I click on all
   columns"). */
@media (min-width: 900px) {
  [data-chain-allcols] { display: none; }
}
@media (max-width: 559px) {
  /* The smile is a shape, not a measurement — it reads fine at 90px, and on a
     phone every pixel above the table is scroll the viewer pays for. */
  svg.chain-smile { height: 90px; }
  /* Same rule, taken to its conclusion for phase 5: the strip sparklines go
     entirely (they would add a row of 24px boxes to every strip cell), the
     drawer chart shrinks, and the wall-break line keeps only its most recent
     entry — so the phone's scroll length is what it was before this feature. */
  svg.chain-spark { display: none; }
  svg.chain-path { height: 30px; }
  .chain-events .chain-event:nth-child(n+2) { display: none; }
  table.chain-table .col-p2, table.chain-table .col-p3 { display: none; }
  .chain-allcols table.chain-table .col-p2,
  .chain-allcols table.chain-table .col-p3 { display: table-cell; }
}

/* ── bottom nav ─────────────────────────────────────────────────────────── */
nav.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav.bottom a { color: var(--muted); display: flex; flex-direction: column; align-items: center;
  gap: 2px; font-size: 10px; padding: 4px 12px; border-radius: 10px; min-width: 56px; }
nav.bottom a .ic { font-size: 19px; line-height: 1; }
nav.bottom a.active { color: var(--accent); background: var(--accent-bg); }

/* ── desktop shell (Stage 2) ──────────────────────────────────────────────
   Everything below is ADDITIVE: the left rail, the desktop-only analysis
   bodies and the wider canvas are hidden by default (mobile-first, layout
   byte-for-byte the same) and only turned on inside @media (min-width: 900px).
   No existing mobile rule above is modified. */

/* hidden on mobile by default */
nav.rail { display: none; }
.desktop-only { display: none; }
.mobile-note { display: block; }
/* ...but a `charts_always` analysis page (the record Inspector, Task 6
   2026-09-09) renders at EVERY width — it is charts-first and the operator
   reads it on a phone. The `.insp-metrics` grid below collapses for it. */
.charts-always { display: block; container-type: inline-size; }
.charts-always .insp-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ── the record Inspector (Task 6, 2026-09-09) ───────────────────────────── */
/* One SERIES block per recorded sleeve (Book C shows up to four). */
.rec-series { margin-bottom: 24px; }
.rec-title { font-size: 14px; font-weight: 700; margin: 0 0 8px; letter-spacing: 0.02em; }
/* The runner's own notes for the day (Book C's collision note, Book D's
   "booked on expiry date") — a day's caveats belong ABOVE its numbers. */
.note-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.note-chip { font-size: 12px; color: var(--warn); background: var(--warn-bg);
  border-radius: 999px; padding: 4px 10px; }

/* analysis-tab chrome (only ever visible at desktop width) */
.analysis-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; }
.param-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.param-bar .param { font-size: 12px; color: var(--muted); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.param-bar .param b { color: var(--ink); font-weight: 600; }
.chart-box-lg { height: 420px; width: 100%; }
.chart-box-xl { height: 480px; width: 100%; }

/* interactive param form (Trade Inspector) */
.param-form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end;
  margin-bottom: 14px; padding: 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); }
.param-form .pf { display: flex; flex-direction: column; gap: 4px; }
.param-form .pf > span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-weight: 600; }
.param-form .pf input[type=number] { width: 78px; }
.param-form .pf input, .param-form .pf select { font-family: var(--sans); font-size: 13px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px; }
.param-form .pf.check { flex-direction: row; align-items: center; gap: 6px; }
.param-form .pf.check > span { text-transform: none; letter-spacing: 0; font-size: 12px; }

/* headline metric tiles */
.insp-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px;
  margin-bottom: 16px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: var(--shadow); }
.metric .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 600; }
.metric .v { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; }

/* per-trade chart sections */
.trade-section { margin-bottom: 16px; }
.trade-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px; font-size: 13px; }
.trade-head .dir { font-weight: 650; }
.trade-head .pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); }

/* ── Batch 4: multi-book inspectors + Day Review ──────────────────────────── */
/* A · B · C book selector strip (top of each inspector) */
.book-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.book-strip .bk { font-size: 13px; color: var(--muted); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; }
.book-strip .bk:hover { background: var(--line-soft); }
.book-strip .bk.active { color: var(--accent); background: var(--accent-bg);
  border-color: var(--accent); font-weight: 600; }

/* read-only resolved-rules strip (khamakya preset / Book B regime) */
.rules-strip { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline;
  margin-bottom: 14px; padding: 10px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; }
.rules-strip .rk { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-weight: 600; margin-left: 8px; }
.rules-strip .rk:first-child { margin-left: 0; }
.rules-strip .rv { color: var(--ink); font-weight: 600; }

/* fallback / warning banner (regime UNKNOWN, no-archive Day Review) */
.fallback-banner { padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius);
  background: var(--warn-bg, rgba(184,121,27,0.10)); border: 1px solid var(--warn);
  color: var(--warn); font-size: 13px; font-weight: 600; }

/* notes lines */
.insp-notes { margin-bottom: 14px; }
.note-line { font-size: 13px; color: var(--muted); margin: 3px 0; }

/* component segmented control (Book B) */
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.seg-btn { font-family: var(--sans); font-size: 13px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 14px; cursor: pointer; }
.seg-btn:hover { background: var(--line-soft); }
.seg-btn.active { color: var(--accent); background: var(--accent-bg);
  border-color: var(--accent); font-weight: 600; }

/* record-source badges (Day Review) + regime line */
.src-badge { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); }
.src-live { color: var(--accent); background: var(--accent-bg); border-color: var(--accent); }
.src-archive { color: var(--muted); background: var(--line-soft); }
.src-ledger { color: var(--warn); background: var(--warn-bg, rgba(184,121,27,0.10)); border-color: var(--warn); }
.tt-regime { font-size: 12px; margin: 2px 0 6px; }
.skip-row td { color: var(--muted); font-style: italic; }

@media (min-width: 900px) {
  body { padding-bottom: 24px; }               /* no bottom-nav gutter on desktop */

  nav.bottom { display: none; }                /* mobile bottom nav → hidden */

  nav.rail {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; top: 45px; left: 0; bottom: 0; width: 208px; z-index: 15;
    background: var(--card); border-right: 1px solid var(--line);
    padding: 14px 10px; overflow-y: auto;
  }
  nav.rail a { color: var(--muted); display: flex; align-items: center; gap: 10px;
    font-size: 14px; padding: 9px 12px; border-radius: 10px; }
  nav.rail a .ic { font-size: 18px; line-height: 1; width: 20px; text-align: center; }
  nav.rail a.active { color: var(--accent); background: var(--accent-bg); font-weight: 600; }
  nav.rail a:hover { background: var(--line-soft); }
  nav.rail .rail-sec { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--faint); font-weight: 700; margin: 16px 12px 4px; }

  .wrap { margin: 0 auto 0 208px; max-width: 1760px; padding: 22px 40px 32px; }

  .desktop-only { display: block; }            /* analysis body → shown */
  .mobile-note { display: none; }              /* "best viewed on desktop" → hidden */
  .charts-always .insp-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }

  .grid.cards-auto { grid-template-columns: repeat(3, 1fr); }
}

/* ── Batch 4: full-width desktop chart-height bump ─────────────────────────
   On a big screen the wider canvas (1760px) gives charts much more width, so
   give them proportionally more height too. Mobile (≤900px) is untouched. */
@media (min-width: 1500px) {
  .chart-box { height: 340px; }
  .chart-box-lg { height: 470px; }
  .chart-box-xl { height: 540px; }
  .tt-chart { height: 420px; }
}

/* ── login ──────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field input[type=password] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); font-size: 15px; }
.field.check { display: flex; align-items: center; gap: 8px; }
.btn { display: inline-block; width: 100%; text-align: center; background: var(--accent);
  color: #fff; border: none; border-radius: 10px; padding: 11px 14px; font-weight: 600;
  cursor: pointer; font-size: 15px; }
.err { background: var(--warn-bg); color: var(--neg); border: 1px solid var(--neg);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.logout-btn { background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; }

/* ── /performance (2026-09-09): the backtest record, per lot ────────────────
   Mobile-first like everything above: the chips wrap, the lot inputs are
   thumb-sized, and the drill-down table scrolls inside `.tbl-scroll`. Only
   `#perf-charts` is desktop-gated (`.desktop-only`, already defined above). */
/* The BOOK strip (2026-09-10) sits above the sleeve chips: the operator sizes
   and funds a book, so that is the page's unit and a sleeve is the drill-down. */
.books-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.book-card { font: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; min-width: 148px;
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
  background: var(--paper); color: var(--ink); }
.book-card.active { border-color: var(--accent); background: var(--accent-bg); }
.book-card-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.book-card-net { font-size: 17px; font-weight: 700; }
.book-card-sleeves { font-size: 11px; color: var(--muted); }
.coverage-chip { font-size: 10px; font-weight: 600; color: var(--muted);
  background: var(--line-soft); border-radius: 6px; padding: 1px 5px;
  margin-left: 4px; white-space: nowrap; }
.coverage-chip:empty { display: none; }
/* A book's day row says what it is MADE of — one link per sleeve that traded. */
.perf-parts { font-size: 11px; color: var(--muted); margin-left: 6px; }
.perf-parts a { font-weight: 700; }

.perf-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.perf-chip-cell { display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 10px; padding: 5px 8px;
  background: var(--paper); }
/* `display:flex` above out-specifies the UA's `[hidden]` rule, so the chips of
   the books that are NOT selected need this to actually disappear. */
.perf-chip-cell[hidden] { display: none; }
.series-chip { font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 8px; padding: 4px 9px; }
.series-chip.active { border-color: var(--accent); color: var(--accent);
  background: var(--accent-bg); }
/* The PRIMARY selection is the one the tiles, the table, the equity curve and
   the heatmap describe — the other selected chips only join the compare chart,
   so the difference has to be visible at a glance. */
.series-chip.primary { background: var(--accent); color: var(--card);
  border-color: var(--accent); }
.cadence-chip { font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  color: var(--muted); background: var(--line-soft); border-radius: 6px;
  padding: 2px 5px; }
.perf-lots { display: flex; align-items: center; gap: 4px; }
.perf-lots input.lots-input { width: 58px; padding: 5px 6px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  color: var(--ink); }
.perf-cadence-note { color: var(--warn); }
/* The added plain-English sentence (2026-09-11) reads as a second line, not a
   run-on of the technical standing-rule wording it follows. */
.cadence-note-plain { display: block; color: var(--muted); margin-top: 2px; font-weight: 400; }

.perf-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.perf-controls label { display: flex; flex-direction: column; gap: 3px; }
.perf-controls select { padding: 7px 8px; font-size: 13px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink); }
.perf-export { font: inherit; font-size: 13px; cursor: pointer; padding: 7px 12px;
  border: 1px solid var(--accent); color: var(--accent); background: transparent;
  border-radius: 8px; }

.perf-tiles > div { min-width: 0; }
.perf-tiles span[id^="tile-"] { font-size: 16px; font-weight: 700; }

/* Bucket rows are clickable; day rows are not (their only action is the
   Inspector link they carry). */
tr.perf-row { cursor: pointer; }
tr.perf-row.perf-day { cursor: default; background: var(--paper); }
tr.perf-row td.lbl { white-space: nowrap; }
tr.perf-row .tw { color: var(--muted); font-size: 11px; }
tr.perf-row .tw.leaf { opacity: 0.35; }
#perf-root .perf-expand { display: inline-flex; align-items: center; gap: 4px;
  min-width: 24px; min-height: 24px; padding: 0 2px; border: 0;
  background: transparent; color: inherit; font: inherit; cursor: pointer; }
#perf-root .perf-expand:focus-visible, #perf-root .hint summary:focus-visible,
#perf-root #table-levels:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
#perf-root .hint summary { display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; line-height: 1; }
#perf-root .hint-body { top: calc(100% + 5px); }
.source-chip { font-size: 10px; font-weight: 700; color: var(--muted);
  background: var(--line-soft); border-radius: 6px; padding: 1px 5px;
  margin-left: 4px; }

/* Reflow Inspector tiles by available content width, including scaled text. */
.insp-metrics > .metric { min-width: 0; overflow-wrap: anywhere; }
@container (max-width: 700px) {
  .charts-always .insp-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Consistent single-chart session / held-window control. */
.trade-view-controls{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0}
.trade-view-controls button{background:var(--card);color:var(--text);border:1px solid var(--line);border-radius:8px;padding:8px 12px;cursor:pointer}
.trade-view-controls button[aria-pressed="true"]{background:var(--accent-bg,rgba(14,116,103,.18));border-color:var(--accent);color:var(--accent)}
.lv-chart{height:340px;min-width:0}
.lv-card{min-width:0}
@media(min-width:900px){.lv-chart{height:420px}}

.session-calendar-trigger{padding:9px 14px;border:1px solid var(--line);border-radius:9px;background:var(--card);color:var(--text)}
.session-calendar{max-width:min(360px,90vw);padding:20px;background:var(--card,#202326);color:var(--text,#ddd);border:1px solid var(--line);border-radius:14px}
.session-calendar::backdrop{background:#0009}.calendar-head{display:flex;justify-content:space-between;gap:8px}.calendar-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:5px;margin:14px 0;text-align:center}.session-calendar button{min-height:36px;border-radius:7px;background:transparent;color:inherit;border:1px solid var(--line)}.session-calendar button:disabled{opacity:.3}.session-calendar button[aria-pressed=true]{border-color:var(--accent);background:var(--accent-bg)}.session-calendar p{font-size:12px;line-height:1.5}.calendar-head input{min-width:0;color:inherit;background:transparent;border:1px solid var(--line);color-scheme:dark}
#record-freshness{padding:12px;margin:12px 0;border-left:3px solid var(--accent)}
@media(max-width:899px){#perf-charts .chart-box-lg{height:320px}.books-strip{gap:8px}}

.validated-year{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:12px 0}.validated-year strong{grid-column:1/-1}.validated-year button{white-space:pre-line;background:var(--card);border:1px solid var(--line);border-radius:8px;padding:12px;cursor:pointer}.validated-year button:disabled{opacity:.45}.validated-year .pos{background:rgba(70,160,135,.13)}.validated-year .neg{background:rgba(190,90,100,.13)}#validated-basis{overflow-wrap:anywhere;font-size:12px;line-height:1.6}#validated-metrics{padding:16px;margin:14px 0;line-height:1.8}#validated-detail{max-width:min(700px,90vw);background:var(--card);color:var(--text);border:1px solid var(--line);border-radius:12px;padding:24px}#validated-detail-body{max-height:60vh;overflow:auto;margin-bottom:15px}#validated-choices button{max-width:100%;text-align:left}@media(max-width:600px){.validated-year{grid-template-columns:repeat(2,minmax(0,1fr))}}
