/* speedex v2 — trading terminal (Direction A, web/v2/DESIGN.md). Loaded after /styles.css and /v2/base-overrides.css on v2 pages only.
 * Layout: near-black terminal cockpit — status bar on top; ≥1280px three panes (batch history | results | routine & run).
 * Dials: visual boldness 8 · motion 3 · density 8. Colors only via tokens. */
body.v2 {
  --ink: #07090b;
  --panel: #0b0e11;
  --panel2: #0f1317;
  --line: #1d232a;
  --line2: #2b333c;
  /* A: platform identity is the name/code, not a hue — all platforms share the text tone */
  --gmgn: #d0d7de;
  --okx: #d0d7de;
  --padre: #d0d7de;
  --binance: #d0d7de;
  --fomo: #d0d7de;
  --gmgn-soft: rgba(208, 215, 222, 0.06);
  --okx-soft: rgba(208, 215, 222, 0.06);
  --padre-soft: rgba(208, 215, 222, 0.06);
  --binance-soft: rgba(208, 215, 222, 0.06);
  --fomo-soft: rgba(208, 215, 222, 0.06);
  --gmgn-line: #2b333c;
  --okx-line: #2b333c;
  --padre-line: #2b333c;
  --binance-line: #2b333c;
  --fomo-line: #2b333c;
  --axiom: #d0d7de;
  --axiom-soft: rgba(208, 215, 222, 0.06);
  --axiom-line: #2b333c;
  --warn: #d29922;
  --win: #3fb950;
  --text: #e6edf3;
  --muted: #9aa4ae;
  --faint: #8b949e;
  --accent: #e6edf3;
  --accent-soft: rgba(230, 237, 243, 0.06);
  --v2-chrome: #07090b;
  --v2-chrome-text: #e6edf3;
  --v2-chrome-muted: #9aa4ae;
  --v2-chrome-line: #1d232a;
  --v2-field: #0f1317;
  --v2-field-line: #2b333c;
  --v2-th: #0f1317;
  --v2-hover: #11161b;
  --v2-active: #1d232a;
  --v2-invert-bg: #e6edf3;
  --v2-invert-fg: #07090b;
  --v2-disabled-bg: #11161b;
  --v2-disabled-fg: #4d565f;
  --v2-focus: #e6edf3;
  --v2-ok: #3fb950;
  --v2-bad: #f85149;
  --v2-bad-bg: rgba(248, 81, 73, 0.1);
  --v2-warn: #d29922;
  --v2-warn-bg: rgba(210, 153, 34, 0.1);
  --v2-idle: #6b7580;
  --v2-header-h: 41px;
  --font-display: 'IBM Plex Mono', ui-monospace, Menlo, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', monospace;
  --font-body: 'IBM Plex Mono', ui-monospace, Menlo, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', monospace;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, 'PingFang SC', 'Noto Sans CJK SC', monospace;
  --radius-lg: 0;
  --radius-md: 0;
  --radius-sm: 0;
  background: var(--ink);
  color: var(--text);
  color-scheme: dark;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.v2::before, body.v2::after { display: none; }
body.v2 * { font-style: normal; }
body.v2 h1, body.v2 h2, body.v2 h3, body.v2 h4 { letter-spacing: 0; font-family: var(--font-display); }
body.v2 :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 1px solid var(--v2-focus); outline-offset: 1px; box-shadow: none; }
@media (prefers-reduced-motion: reduce) { body.v2 * { transition: none !important; animation: none !important; } }

/* ── Header: one hairline row, reverse-video active tab ─── */
body.v2 .topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  max-width: none; margin: 0; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none;
  background: var(--v2-chrome); color: var(--v2-chrome-text); border-bottom: 1px solid var(--v2-chrome-line);
  padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  min-height: var(--v2-header-h); gap: 4px 12px;
}
body.v2 .brand h1 { color: var(--v2-chrome-text); font-size: 13px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; }
body.v2 .brand h1::after { content: ' ▌'; color: var(--v2-ok); letter-spacing: 0; }
body.v2 .brand-sub { display: none; }
body.v2 .view-switch { gap: 0; }
body.v2 .view-btn, body.v2 .topbar .view-btn {
  background: transparent; border: 0; border-radius: 0; color: var(--v2-chrome-muted);
  min-height: var(--v2-header-h); padding: 0 10px; font-size: 12px; font-weight: 400; display: inline-flex; align-items: center;
  text-transform: uppercase; letter-spacing: 0.06em;
}
body.v2 .view-btn.active, body.v2 .view-btn[aria-current='page'] { background: var(--v2-invert-bg); color: var(--v2-invert-fg); }
body.v2 .chain-logo { background: transparent; border: 1px solid var(--v2-chrome-line); color: var(--v2-chrome-text); }
body.v2 .chain-logo[aria-pressed='true'] { background: var(--v2-invert-bg); color: var(--v2-invert-fg); border-color: var(--v2-invert-bg); }
body.v2 .topbar .controls select, body.v2 .topbar .controls button {
  background: transparent; color: var(--v2-chrome-text); border: 1px solid var(--v2-chrome-line); border-radius: 0; min-height: 28px; font-size: 12px;
}
body.v2 .topbar .badge { background: transparent; border-color: var(--line2); color: var(--v2-chrome-muted); }

/* ── Page frame ─────────────────────────────────────────── */
body.v2 .wrap { max-width: none; padding: 0 0 48px; }
body.v2 #homeView { display: flex; flex-direction: column; gap: 0; }
body.v2 #homeView > .v2-health { order: 0; }
body.v2 #homeView > .recent-tasks-block { order: 1; }
body.v2 #homeView > .home-latest { order: 2; }
body.v2 #homeView > .inject-panel { order: 3; }
body.v2 #homeView > .routine-trends-block { order: 4; }
body.v2 .block { margin-top: 0; }
body.v2 :is(.block, .inject-panel, .answer) {
  background: var(--panel); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none;
}
body.v2 #homeView > .block, body.v2 .inject-panel { padding: 10px 12px; }
body.v2 .block-head { margin-bottom: 8px; }
body.v2 .block-head h2, body.v2 .inject-panel h2 {
  font-size: 12px; font-weight: 600; line-height: 1.4; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
body.v2 .block-head h2::before, body.v2 .inject-panel h2::before { content: '// '; color: var(--faint); }
body.v2 .eyebrow { letter-spacing: 0.08em; color: var(--faint); text-transform: uppercase; }
body.v2 .inject-panel .lede, body.v2 .block-head p { color: var(--faint); font-size: 12px; max-width: 80ch; }

/* Controls: hairline fields, square buttons, primary = reverse video */
body.v2 :is(input[type='number'], input[type='text'], input[type='password'], select, textarea) {
  background: var(--v2-field); color: var(--text); border: 1px solid var(--v2-field-line); border-radius: 0; font-family: var(--font-mono); font-size: 12px;
}
body.v2 button { border-radius: 0; font-family: var(--font-mono); }
body.v2 button.primary, body.v2 #injectStart { background: var(--v2-invert-bg); border: 1px solid var(--v2-invert-bg); color: var(--v2-invert-fg); font-weight: 600; }
body.v2 button.primary:disabled, body.v2 #injectStart:disabled { background: var(--v2-disabled-bg); border-color: var(--line2); color: var(--v2-disabled-fg); }
body.v2 :is(.chk, .cfg-label) { color: var(--text); }
body.v2 .cfg-hint, body.v2 .cfg-footnote { color: var(--muted); font-size: 12px; }
body.v2 a { color: var(--text); text-decoration-color: var(--line2); }

/* ── Status bar (health data) ───────────────────────────── */
body.v2 .v2-health {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0;
  background: var(--ink); border-bottom: 1px solid var(--line);
}
body.v2 .v2-tile { background: var(--ink); padding: 8px 12px; min-width: 0; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); }
body.v2 .v2-tile:last-child { border-right: 0; }
body.v2 .v2-tile-label { margin: 0; font: 400 12px/1.4 var(--font-mono); color: var(--faint); letter-spacing: 0.08em; text-transform: uppercase; }
body.v2 .v2-big { margin: 0; font: 600 18px/1.25 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); }
body.v2 .v2-big small { font-size: 12px; font-weight: 400; color: var(--faint); }
body.v2 .v2-tile-note { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
body.v2 .v2-status { margin: 0; display: flex; gap: 6px; align-items: baseline; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
body.v2 .v2-tile-health .v2-status { font-size: 16px; text-transform: uppercase; letter-spacing: 0.04em; }
body.v2 .v2-tile-preflight .v2-status { font-weight: 400; }
body.v2 .v2-status-icon { font-weight: 600; flex: none; }
body.v2 .v2-status-ok { color: var(--v2-ok); }
body.v2 .v2-status-bad { color: var(--v2-bad); }
body.v2 .v2-status-warn { color: var(--warn); }
body.v2 .v2-status-idle { color: var(--muted); }
body.v2 .v2-tile-health:has(.v2-status-warn) { background: var(--v2-warn-bg); }
body.v2 .v2-tile-health:has(.v2-status-bad) { background: var(--v2-bad-bg); }
body.v2 .v2-buckets { display: flex; height: 4px; gap: 1px; background: var(--line); margin: 3px 0 1px; }
body.v2 .v2-bucket-ok { background: var(--v2-ok); }
body.v2 .v2-bucket-warn { background: var(--v2-warn); }
body.v2 .v2-bucket-bad { background: var(--v2-bad); }
body.v2 .v2-bucket-idle { background: var(--v2-idle); }
body.v2 .v2-counts { display: flex; flex-wrap: wrap; gap: 0 10px; font-variant-numeric: tabular-nums; }
body.v2 .v2-count-flag { color: var(--v2-bad); font-weight: 600; }
body.v2 .v2-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line2); }
body.v2 .v2-stale { color: var(--warn); }

/* ── Tables: mono, tabular, hairlines ───────────────────── */
body.v2 table { border-collapse: collapse; }
body.v2 th { background: var(--v2-th); color: var(--faint); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
body.v2 :is(th, td) { border-color: var(--line); }
body.v2 td { font-variant-numeric: tabular-nums; }
body.v2 :is(.rounds-table, .hist-table, .ledger-table) td { font-family: var(--font-mono); font-size: 12px; }
body.v2 .metric-best { color: var(--v2-ok); font-weight: 600; }

/* Status chips: square, text + hairline */
body.v2 .oc.confirmed { color: var(--v2-ok); border-color: var(--v2-ok); background: transparent; }
body.v2 .oc.failed, body.v2 .oc.reverted { color: var(--v2-bad); border-color: var(--v2-bad); background: transparent; }
body.v2 .oc.unknown { color: var(--warn); border-color: var(--v2-warn); background: var(--v2-warn-bg); }

/* Preflight cards: flat rows */
body.v2 .pf-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 0; box-shadow: none; }
body.v2 .pf-card.bad { border-color: var(--v2-bad); }
body.v2 .pf-reasons { color: var(--v2-bad); font-size: 12px; }

/* the base stylesheet sizes several <small> labels in em (≈10px); v2 floor is 12px */
body.v2 small { font-size: max(12px, 0.85em); }

/* the page controllers paint platform/outcome colors inline — route them through the v2 tokens */
body.v2 [style*="color: rgb(47, 216, 194)"] { color: var(--gmgn) !important; }
body.v2 [style*="color: rgb(154, 237, 45)"] { color: var(--okx) !important; }
body.v2 [style*="color: rgb(167, 139, 250)"] { color: var(--padre) !important; }
body.v2 [style*="color: rgb(240, 185, 11)"] { color: var(--binance) !important; }
body.v2 [style*="color: rgb(244, 114, 182)"] { color: var(--fomo) !important; }
body.v2 [style*="color: rgb(250, 204, 21)"] { color: var(--axiom) !important; }
body.v2 [style*="color: rgb(52, 211, 153)"] { color: var(--v2-ok) !important; }
body.v2 [style*="color: rgb(248, 113, 113)"] { color: var(--v2-bad) !important; }
body.v2 [style*="--pc: #2fd8c2"] { --pc: var(--gmgn) !important; }
body.v2 [style*="--pc: #9aed2d"] { --pc: var(--okx) !important; }
body.v2 [style*="--pc: #a78bfa"] { --pc: var(--padre) !important; }
body.v2 [style*="--pc: #f0b90b"] { --pc: var(--binance) !important; }
body.v2 [style*="--pc: #f472b6"] { --pc: var(--fomo) !important; }
body.v2 [style*="--pc: #facc15"] { --pc: var(--axiom) !important; }

/* History page panels */
body.v2 .hist-block { margin-top: 0; padding: 10px 12px; }
body.v2 :is(.hist-filters, .plat-chips, .plat-filter) { flex-wrap: wrap; min-width: 0; }

/* ── Cockpit: three panes on wide screens ───────────────── */
@media (min-width: 1280px) {
  body.v2 #homeView {
    display: grid; align-items: start;
    grid-template-columns: minmax(300px, 24%) minmax(0, 1fr) minmax(360px, 28%);
    grid-template-rows: auto auto 1fr;
  }
  body.v2 #homeView > .v2-health { grid-column: 1 / -1; grid-row: 1; }
  body.v2 #homeView > :is(.recent-tasks-block, .inject-panel) {
    grid-row: 2 / span 2; position: sticky; top: var(--v2-header-h);
    max-height: calc(100vh - var(--v2-header-h)); overflow-y: auto; overscroll-behavior: contain; min-height: 0;
  }
  body.v2 #homeView > .recent-tasks-block { grid-column: 1; border-right: 1px solid var(--line); }
  body.v2 #homeView > .inject-panel { grid-column: 3; border-left: 1px solid var(--line); }
  body.v2 #homeView > .home-latest { grid-column: 2; grid-row: 2; }
  body.v2 #homeView > .routine-trends-block { grid-column: 2; grid-row: 3; }
  /* the batch list lives in a narrow rail: label/value rows instead of the base stylesheet's 8-column grid */
  body.v2 .recent-tasks-block .rt-row { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
  body.v2 .recent-tasks-block .rt-row > * { grid-column: auto !important; white-space: normal; min-width: 0; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1055px) {
  body.v2 .v2-health { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.v2 .v2-tile { border-bottom: 1px solid var(--line); }
}
@media (max-width: 671px) {
  body.v2 .v2-health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.v2 .v2-tile-health { grid-column: 1 / -1; }
  body.v2 .topbar { position: static; flex-wrap: wrap; padding-block: 4px; }
  body.v2 .view-btn, body.v2 .topbar .view-btn { min-height: 36px; padding: 0 8px; }
  body.v2 .btn-row, body.v2 .rt-head, body.v2 .run-cockpit-head { flex-wrap: wrap; }
  body.v2 .rt-row { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
  body.v2 .rt-row > * { grid-column: auto !important; white-space: normal; min-width: 0; }
  body.v2 :is(.hist-table, .rounds-table, .run-table, .ledger-table) :is(th, td):first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); }
  body.v2 :is(.hist-table, .rounds-table, .run-table, .ledger-table) th:first-child { background: var(--v2-th); }
}

/* Hover only for fine pointers; pressed state for every button */
@media (hover: hover) and (pointer: fine) {
  body.v2 .view-btn:not(.active):not([aria-current='page']):hover { background: var(--v2-hover); color: var(--v2-chrome-text); }
  body.v2 .topbar .controls button:hover { background: var(--v2-hover); }
  body.v2 button.primary:not(:disabled):hover, body.v2 #injectStart:not(:disabled):hover { background: var(--muted); border-color: var(--muted); }
  body.v2 :is(.rounds-table, .hist-table, .ledger-table) tbody tr:hover { background: var(--v2-hover); }
  body.v2 .v2-link:hover { text-decoration-color: var(--text); }
}
body.v2 button:active:not(:disabled) { background: var(--v2-active); }
body.v2 :is(button.primary, #injectStart):active:not(:disabled) { background: var(--faint); }

/* Latest-result cards: mono digits are wider than the base display face — size medians to the cell, never truncate */
body.v2 .home-latest .hc-side b { font-size: 20px; overflow: visible; text-overflow: clip; letter-spacing: -0.02em; }
/* the base stylesheet's decorative gradient frame sits 1px outside the run panel (left/right: -1px) — A has no ornament */
body.v2 .inject-panel::before { display: none; }

/* Kimi review (direction A, 2026-10-28) */
body.v2 [hidden] { display: none !important; }                       /* layout display rules must not defeat [hidden] (chain view) */
body.v2 .hc-side { overflow: visible; min-width: 0; }                /* medians never clipped */
@media (min-width: 1280px) { body.v2 .home-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }
body.v2 .cfg-field.cfg-actions { min-width: 0; grid-column: 1 / -1; } /* right rail is narrower than the base 340px action row */
body.v2 .cfg-actions .btn-row { flex-wrap: wrap; height: auto; }
body.v2 :is(.hc-side.miss b, .answer .side.miss b) { opacity: 1; color: var(--muted); } /* missing "—" stays readable */
body.v2 .plat-chip:not(.on) { opacity: 1; color: var(--faint); border-style: dashed; }   /* off ≠ dimmed */
body.v2 .home-card { background: var(--panel2); }                    /* no gradients in A */
body.v2 :is(.reveal, .reveal.in-view) { opacity: 1; transform: none; transition: none; } /* no entry motion */

/* Latest test result per chain: numbers and platform names use each platform's brand color (2026-10-29 owner) — A's monochrome rule yields only here; missing values stay grey */
body.v2 {
  --logo-gmgn: #2fd8c2;
  --logo-okx: #9aed2d;
  --logo-padre: #a78bfa;
  --logo-binance: #f0b90b;
  --logo-fomo: #f472b6;
}
body.v2 .home-latest .hc-side.g:not(.miss) :is(b, em) { color: var(--logo-gmgn); }
body.v2 .home-latest .hc-side.o:not(.miss) :is(b, em) { color: var(--logo-okx); }
body.v2 .home-latest .hc-side.p:not(.miss) :is(b, em) { color: var(--logo-padre); }
body.v2 .home-latest .hc-side.b:not(.miss) :is(b, em) { color: var(--logo-binance); }
body.v2 .home-latest .hc-side.f:not(.miss) :is(b, em) { color: var(--logo-fomo); }
body.v2 .home-latest .hc-side b .hc-unit { color: var(--faint); }
/* Recent trends: dots are only batch links; color does not indicate a lead. */
body.v2 .trend-board .tb-dot { border-radius: 0; }
body.v2 .trend-board .tb-dot.neutral { color: var(--muted); }
body.v2 .trend-board td, body.v2 .trend-board th { border-color: var(--line); }
body.v2 .detail-degraded { color: var(--warn); }
