/* SoSoDesk v3 — SoSoValue real-time terminal visual system (Carbon Dark default + Paper Light) */

/* =========================================================================
   1. TOKENS
   ========================================================================= */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  --orange-700: #d9431b;
  --orange-600: #ff4f20;
  --orange-500: #ff6f48;
  --orange-400: #ff8438;
  --cta-gradient: linear-gradient(95deg, #FF4F20 0%, #FF8438 100%);
  --gold: #FFD200;

  --bg-canvas: #0a0a0a;
  --bg-surface: #0a0a0a;
  --bg-well: #111111;
  --bg-elevated: #171717;
  --bg-chip: #1f1f1f;
  --bg-control: #171717;
  --bg-control-hover: #262626;
  --bg-modal: #141414;
  --bg-hover: rgba(106, 106, 106, 0.16);
  --bg-active: rgba(255, 79, 32, 0.10);
  --bg-rail-active: rgba(255, 79, 32, 0.20);

  --border: #262626;
  --border-inner: #1c1c1c;
  --border-subtle: #171717;
  --border-strong: #333333;
  --border-search: #575757;
  --border-search-focus: #f5f5f5;

  --ink-primary: #ffffff;
  --ink-body: #e5e5e5;
  --ink-secondary: #a3a3a3;
  --ink-muted: #737373;
  --ink-rail-active: #ffffff;
  --ink-rail-icon-active: #ffffff;
  --logo-fill: #ffffff;

  --accent: #ff4f20;
  --accent-ink: #ff6f48;
  --accent-hover: #d9431b;
  --accent-soft: rgba(255, 79, 32, 0.16);
  --accent-border: rgba(255, 79, 32, 0.42);

  --pos: #18b36b;
  --pos-bg: #1a2c26;
  --pos-border: rgba(24, 179, 107, 0.34);
  --neg: #f24237;
  --neg-bg: #381513;
  --neg-border: rgba(242, 66, 55, 0.36);
  --warn: #ffc133;
  --warn-bg: #33290f;
  --warn-border: rgba(255, 193, 51, 0.34);

  /* Real-time */
  --live: #30d158;
  --live-ring: rgba(48, 209, 88, 0.55);
  --flash-up-bg: rgba(24, 179, 107, 0.24);
  --flash-down-bg: rgba(242, 66, 55, 0.24);
  --ob-bar-bid: rgba(24, 179, 107, 0.15);
  --ob-bar-ask: rgba(242, 66, 55, 0.15);
  --trade-in-buy: rgba(24, 179, 107, 0.18);
  --trade-in-sell: rgba(242, 66, 55, 0.18);

  --step-up-1: rgba(8, 78, 48, 0.4);
  --step-up-2: rgba(9, 94, 57, 0.4);
  --step-up-3: rgba(7, 119, 72, 0.4);
  --step-up-4: rgba(8, 149, 84, 0.4);
  --step-down-1: rgba(122, 39, 26, 0.4);
  --step-down-2: rgba(147, 34, 26, 0.4);
  --step-down-3: rgba(182, 33, 26, 0.4);
  --step-down-4: rgba(218, 46, 33, 0.4);

  --chart-pos: #18b36b;
  --chart-neg: #f24237;
  --chart-line: #ff4f20;
  --chart-grid: #1f1f1f;
  --chart-zero: #474747;
  --chart-axis: #737373;
  --chart-track: #262626;

  --seg-active-bg: #262626;
  --seg-active-ink: #ffffff;
  --switch-off: #474747;
  --scrollbar: #333333;
  --backdrop: rgba(0, 0, 0, 0.72);
  --shadow-modal: 0 24px 56px rgba(0, 0, 0, 0.6);
  --skeleton-a: #141414;
  --skeleton-b: #1f1f1f;

  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --h-telemetry: 36px;
  --h-topbar: 56px;
  --h-footer: 32px;
  --w-rail: 80px;
  --row-h: 32px;
  --screener-min: 312px;
  --micro-h: 276px;

  --font-sans: "Lato", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Space Grotesk", "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
}

[data-theme="light"] {
  color-scheme: light;

  --bg-canvas: #ffffff;
  --bg-surface: #ffffff;
  --bg-well: #fafafa;
  --bg-elevated: #f5f5f5;
  --bg-chip: #f5f5f5;
  --bg-control: #ffffff;
  --bg-control-hover: #f5f5f5;
  --bg-modal: #ffffff;
  --bg-hover: rgba(106, 106, 106, 0.08);
  --bg-active: rgba(255, 79, 32, 0.07);
  --bg-rail-active: #fff3f0;

  --border: #e5e5e5;
  --border-inner: #efefef;
  --border-subtle: #f5f5f5;
  --border-strong: #d4d4d4;
  --border-search: #171717;
  --border-search-focus: #0a0a0a;

  --ink-primary: #0a0a0a;
  --ink-body: #121212;
  --ink-secondary: #525252;
  --ink-muted: #737373;
  --ink-rail-active: #d9431b;
  --ink-rail-icon-active: #ff4f20;
  --logo-fill: #313131;

  --accent: #ff4f20;
  --accent-ink: #d9431b;
  --accent-hover: #d9431b;
  --accent-soft: #fff3f0;
  --accent-border: #ffc4b0;

  --pos: #089554;
  --pos-bg: #edfef4;
  --pos-border: #aceec7;
  --neg: #da2e21;
  --neg-bg: #fff1f2;
  --neg-border: #ffcbc8;
  --warn: #b45309;
  --warn-bg: #fff8e6;
  --warn-border: #fde3a7;

  --live: #089554;
  --live-ring: rgba(8, 149, 84, 0.45);
  --flash-up-bg: rgba(8, 149, 84, 0.14);
  --flash-down-bg: rgba(218, 46, 33, 0.12);
  --ob-bar-bid: rgba(8, 149, 84, 0.10);
  --ob-bar-ask: rgba(218, 46, 33, 0.09);
  --trade-in-buy: rgba(8, 149, 84, 0.12);
  --trade-in-sell: rgba(218, 46, 33, 0.10);

  --step-up-1: #EDFEF4;
  --step-up-2: #DDFBE7;
  --step-up-3: #ACEEC7;
  --step-up-4: rgba(118, 225, 166, 0.8);
  --step-down-1: #FFF1F2;
  --step-down-2: #FFE3E1;
  --step-down-3: #FFCBC8;
  --step-down-4: rgba(254, 164, 156, 0.8);

  --chart-pos: #089554;
  --chart-neg: #da2e21;
  --chart-line: #ff4f20;
  --chart-grid: #f0f0f0;
  --chart-zero: #d4d4d4;
  --chart-axis: #737373;
  --chart-track: #e5e5e5;

  --seg-active-bg: #171717;
  --seg-active-ink: #ffffff;
  --switch-off: #d4d4d4;
  --scrollbar: #d4d4d4;
  --backdrop: rgba(10, 10, 10, 0.45);
  --shadow-modal: 0 24px 56px rgba(10, 10, 10, 0.16);
  --skeleton-a: #f5f5f5;
  --skeleton-b: #e5e5e5;
}

/* =========================================================================
   2. BASE
   ========================================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--ink-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.4;
  font-size: 12.5px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

::selection { background: rgba(255, 79, 32, 0.32); color: var(--ink-primary); }

* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.mono, .num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

button, input, select { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.text-pos { color: var(--pos); font-weight: 700; }
.text-neg { color: var(--neg); font-weight: 700; }
.text-warn { color: var(--warn); font-weight: 700; }
.text-muted { color: var(--ink-muted); }

/* =========================================================================
   3. REAL-TIME PRIMITIVES
   ========================================================================= */

/* 3.1 Stream status dot — state from html[data-stream] */
.ws-dot {
  position: relative;
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--warn);
}
.ws-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--live);
  opacity: 0;
  pointer-events: none;
}
html[data-stream="live"] .ws-dot,
.ws-dot.live-pulse { background: var(--live); }
html[data-stream="live"] .ws-dot::after,
.ws-dot.live-pulse::after { animation: live-pulse 1.6s cubic-bezier(0.2, 0.6, 0.3, 1) infinite; }
html[data-stream="paused"] .ws-dot:not(.live-pulse),
html[data-stream="closed"] .ws-dot:not(.live-pulse) { background: var(--ink-muted); }

@keyframes live-pulse {
  0% { transform: scale(1); opacity: 0.6; }
  75%, 100% { transform: scale(2.8); opacity: 0; }
}

/* 3.2 Tick flash — background + color only: zero layout shift */
.tick-up { animation: tick-up 550ms ease-out; border-radius: var(--radius-xs); }
.tick-down { animation: tick-down 550ms ease-out; border-radius: var(--radius-xs); }
@keyframes tick-up {
  0%, 18% { background-color: var(--flash-up-bg); color: var(--pos); }
  100% { background-color: transparent; }
}
@keyframes tick-down {
  0%, 18% { background-color: var(--flash-down-bg); color: var(--neg); }
  100% { background-color: transparent; }
}

/* 3.3 Refresh spinner */
.btn.spinning { color: var(--accent); border-color: var(--accent-border); }
.btn.spinning svg { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 3.4 Live tag (screener / method table) */
.tag-live { gap: 6px; }
html[data-stream="live"] .tag-live { background: var(--pos-bg); color: var(--pos); }
html[data-stream="connecting"] .tag-live,
html[data-stream="reconnecting"] .tag-live,
html[data-stream="polling"] .tag-live { background: var(--warn-bg); color: var(--warn); }

/* =========================================================================
   4. ZONE 1 — TELEMETRY BAR (36px)
   ========================================================================= */
.telemetry-bar {
  height: var(--h-telemetry);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.telemetry-left, .telemetry-right {
  display: flex;
  align-items: center;
  min-width: 0;
  white-space: nowrap;
}
.telemetry-left {
  gap: 14px;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.telemetry-left::-webkit-scrollbar { display: none; }
.telemetry-right { gap: 2px; flex-shrink: 0; }

.stream-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 22px;
  padding: 0 9px 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
  flex-shrink: 0;
  transition: border-color 200ms ease, background 200ms ease, color 200ms ease;
}
html[data-stream="live"] .stream-pill { border-color: var(--pos-border); background: var(--pos-bg); color: var(--pos); }
html[data-stream="paused"] .stream-pill,
html[data-stream="closed"] .stream-pill { border-color: var(--border); background: transparent; color: var(--ink-secondary); }
.stream-label { font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase; }
.stream-rate {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-secondary);
  padding-left: 7px;
  border-left: 1px solid var(--border-strong);
  min-width: 6ch;
}

.tele-clock { color: var(--ink-primary); font-size: 11.5px; font-weight: 500; flex-shrink: 0; min-width: 12ch; }
.tele-sep { width: 1px; height: 12px; background: var(--border); flex-shrink: 0; }
.tele-item { flex-shrink: 0; }
.tele-item strong {
  color: var(--ink-primary);
  font-weight: 700;
  margin-left: 4px;
  padding: 1px 3px;
  font-variant-numeric: tabular-nums;
}
.tele-item .text-pos { color: var(--pos); }
.tele-item .text-neg { color: var(--neg); }

.tele-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.tele-btn:hover { background: var(--bg-hover); color: var(--ink-primary); border-color: var(--border); }

.stream-toggle .ic-play { display: none; }
html[data-stream="paused"] .stream-toggle .ic-pause,
.stream-toggle[aria-pressed="true"] .ic-pause { display: none; }
html[data-stream="paused"] .stream-toggle .ic-play,
.stream-toggle[aria-pressed="true"] .ic-play { display: inline; }
.stream-toggle[aria-pressed="true"] { color: var(--accent-ink); border-color: var(--accent-border); background: var(--accent-soft); }

.prov-pill { border-color: var(--border); }
.sync-countdown {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-muted);
  padding-left: 7px;
  border-left: 1px solid var(--border);
  min-width: 4ch;
  text-align: right;
}
.sync-countdown.is-syncing { color: var(--accent-ink); }

/* =========================================================================
   5. ZONE 2 — HEADER (56px)
   ========================================================================= */
.topbar {
  height: var(--h-topbar);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  width: var(--w-rail);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--logo-fill);
  border-right: 1px solid var(--border);
  font-family: var(--font-display);
}
.brand-mark { display: grid; place-items: center; color: var(--logo-fill); line-height: 0; }
.brand-text { font-size: 12px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; line-height: 1; }
.brand-accent { color: var(--accent); }

.topbar-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.global-search-wrap { position: relative; display: flex; align-items: center; flex: 0 1 420px; min-width: 0; }
.search-icon { position: absolute; left: 12px; color: var(--ink-muted); pointer-events: none; }
.global-search {
  height: 36px;
  width: 100%;
  padding: 0 12px 0 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-search);
  background: transparent;
  color: var(--ink-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.global-search::placeholder { color: var(--ink-muted); }
.global-search:hover { border-color: var(--ink-secondary); }
.global-search:focus { border-color: var(--border-search-focus); box-shadow: 0 0 0 3px rgba(255, 79, 32, 0.14); }
.global-search:focus-visible { outline: none; }

/* =========================================================================
   6. CONTROLS
   ========================================================================= */
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-pos { background: var(--pos); box-shadow: 0 0 0 2px var(--pos-bg); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 2px var(--warn-bg); }
.dot-neg { background: var(--neg); box-shadow: 0 0 0 2px var(--neg-bg); }
.dot-accent { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-control);
  color: var(--ink-primary);
  white-space: nowrap;
}
.pill-btn { cursor: pointer; transition: border-color 120ms ease, background 120ms ease, color 120ms ease; }
.pill-demo { border-color: var(--accent-border); background: var(--accent-soft); color: var(--accent-ink); }
.pill-btn:hover { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-control);
  color: var(--ink-primary);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 120ms ease, background 130ms ease, border-color 130ms ease, filter 130ms ease, box-shadow 130ms ease, color 130ms ease;
}
.btn:hover { background: var(--bg-control-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }

.btn-primary {
  background: var(--cta-gradient);
  border-color: transparent;
  color: #ffffff;
  font-family: var(--font-display);
  letter-spacing: 0.005em;
}
.btn-primary:hover {
  background: var(--cta-gradient);
  border-color: transparent;
  filter: brightness(1.07);
  box-shadow: 0 6px 18px rgba(255, 79, 32, 0.26);
}
.btn-warn {
  background: var(--warn);
  border-color: transparent;
  color: #0a0a0a;
  font-family: var(--font-display);
}
.btn-warn:hover { background: var(--warn); border-color: transparent; filter: brightness(1.06); }
.btn-icon { width: 32px; height: 32px; padding: 0; color: var(--ink-secondary); }
.btn-icon:hover { color: var(--ink-primary); }
.topbar .btn-primary { height: 32px; padding: 0 14px; }
.btn-sm { height: 24px; padding: 0 9px; font-size: 11px; }
.btn-lg { height: 38px; padding: 0 14px; font-size: 13px; }
.btn-row { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  font-weight: 700;
  background: var(--bg-chip);
  color: var(--ink-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tag-accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag-pos { background: var(--pos-bg); color: var(--pos); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-neg { background: var(--neg-bg); color: var(--neg); }

.src-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--border);
  padding: 0 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.chip-btn { cursor: pointer; transition: border-color 120ms ease, color 120ms ease; }
.chip-btn:hover { border-color: var(--accent-border); color: var(--accent-ink); }

.underline-tabs { display: inline-flex; align-items: center; gap: 18px; }
.u-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 4px 0 5px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms ease, border-color 120ms ease;
}
.u-tab:hover { color: var(--ink-primary); }
.u-tab.active { color: var(--ink-primary); border-bottom-color: var(--accent); }

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-secondary);
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-pill:hover { color: var(--ink-primary); border-color: var(--border-strong); }
.switch { width: 26px; height: 14px; border-radius: 99px; background: var(--switch-off); position: relative; transition: background 140ms ease; }
.switch.on { background: var(--accent); }
.switch::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 140ms ease;
}
.switch.on::after { transform: translateX(12px); }

.seg-group {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.seg-btn {
  height: 24px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
}
.seg-btn:hover { color: var(--ink-primary); }
.seg-btn.active { background: var(--seg-active-bg); color: var(--seg-active-ink); }

.mini-select {
  height: 24px;
  max-width: 150px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-primary);
  background: var(--bg-control);
  cursor: pointer;
}

/* =========================================================================
   7. SHELL & RAIL
   ========================================================================= */
.app-shell { display: flex; flex: 1; min-height: 0; min-width: 0; }

.left-rail {
  width: var(--w-rail);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
}
.rail-stack {
  position: sticky;
  top: var(--h-topbar);
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}
.rail-item {
  width: 100%;
  height: 60px;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  transition: color 120ms ease, background 120ms ease;
}
.rail-item:hover { background: var(--bg-hover); color: var(--ink-primary); }
.rail-item:focus-visible { outline-offset: -2px; }
.rail-icon { width: 20px; height: 20px; display: grid; place-items: center; position: relative; }
.rail-icon svg { width: 18px; height: 18px; stroke-width: 1.8; }
.rail-label { font-size: 11px; font-weight: 700; letter-spacing: 0.01em; line-height: 1; }
.rail-item.active { background: var(--bg-rail-active); color: var(--ink-rail-active); }
.rail-item.active .rail-icon { color: var(--ink-rail-icon-active); }
.rail-badge {
  position: absolute;
  top: -6px;
  right: -12px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px var(--bg-surface);
}

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

.banner {
  padding: 8px 16px;
  border-bottom: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
}
.banner-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* =========================================================================
   8. DESK — flat hairline plane
   ========================================================================= */
.terminal-main,
.terminal-page {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
}
.terminal-page > .panel { flex: 1; }

.panel {
  background: var(--bg-surface);
  padding: 12px 16px;
  min-width: 0;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  margin-bottom: 10px;
  gap: 10px;
}
.wrap-header { flex-wrap: wrap; }
.panel-title-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.panel-title { font-size: 13.5px; font-weight: 700; color: var(--ink-primary); letter-spacing: -0.005em; }
.sub-label { font-size: 11px; color: var(--ink-muted); margin: 12px 0 6px; }

.chart-host { min-width: 0; line-height: 0; }
.chart-host .empty-inline, .chart-host .skeleton { line-height: 1.4; }
.chart-host svg { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart-host svg .ax-mono { font-family: var(--font-mono); }
.mini-gauge-host svg { font-family: var(--font-display); }

/* ---------- Band 1: KPI strip ---------- */
.kpi-strip {
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr);
  gap: 1px;
  background: var(--border);
}
.strip-kpis {
  display: grid;
  /* Weighted tracks give the text-heavy 48h macro event card room without cramping numeric KPIs */
  grid-template-columns: minmax(0, 0.90fr) minmax(0, 0.85fr) minmax(0, 1.35fr) minmax(0, 0.90fr);
  gap: 1px;
  background: var(--border);
}
.strip-cell {
  background: var(--bg-surface);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  min-height: 86px;
}
.strip-cell.alert { background: var(--warn-bg); }
.strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 4px;
  gap: 6px;
  min-width: 0;
}
.strip-head > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-regime-body { display: flex; align-items: center; gap: 14px; }
.mini-gauge-host { width: 106px; flex-shrink: 0; line-height: 0; }
.mini-gauge-host svg { width: 100%; height: auto; display: block; }
.strip-regime-meta { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; }
.mini-factors { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; width: 100%; }
.mini-factor { font-size: 10.5px; color: var(--ink-muted); display: flex; justify-content: space-between; gap: 4px; }
.mini-factor strong { color: var(--ink-primary); font-weight: 700; }
.kpi-val {
  font-size: clamp(15px, 1.32vw, 19px);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink-primary);
  margin: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
/* Long macro event names sit in slot 3; trim scale slightly so full titles fit without ellipsis */
.strip-kpis > .strip-cell:nth-child(3) .kpi-val {
  font-size: clamp(14px, 1.12vw, 17px);
}
.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-secondary);
  gap: 6px;
  min-width: 0;
}
.kpi-foot span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Band 2: primary workspace grid ---------- */
.desk-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  grid-template-columns: minmax(0, 1.38fr) minmax(460px, 1fr);
  grid-template-rows: 1fr auto auto;
  grid-template-areas:
    "screener ticket"
    "etf      ticket"
    "intel    ticket";
}
.area-screener { grid-area: screener; }
.area-etf { grid-area: etf; }
.area-intel { grid-area: intel; }
.area-ticket { grid-area: ticket; }

/* Screener (elastic absorber) */
.panel-screener {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
  container: screener / inline-size;
}
.screener-body {
  position: relative;
  flex: 1 1 auto;
  min-height: var(--screener-min);
  margin: 0 -16px;
}
.screener-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 0 8px;
}
.screener-body > .no-setup-box { margin: 6px 16px 12px; }

table.screener { width: 100%; border-collapse: collapse; }
table.screener th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: var(--row-h);
  text-align: right;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-muted);
  padding: 0 8px;
  background: var(--bg-surface);
  box-shadow: inset 0 1px 0 var(--border), inset 0 -1px 0 var(--border);
  white-space: nowrap;
}
table.screener th:first-child { text-align: center; width: 32px; }
table.screener th:nth-child(2) { text-align: left; }
table.screener th:last-child { text-align: center; }
.th-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  padding: 2px 0;
  font: inherit;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 120ms ease;
}
.th-sort-btn:hover { color: var(--ink-primary); }
.th-sort-btn.active { color: var(--ink-primary); font-weight: 700; }
.th-sort-btn .sort-caret { opacity: 0.35; flex-shrink: 0; transition: transform 140ms ease, opacity 140ms ease, color 140ms ease; }
.th-sort-btn:hover .sort-caret { opacity: 0.75; }
.th-sort-btn.active .sort-caret { opacity: 1; color: var(--accent); }
.th-sort-btn.active.asc .sort-caret { transform: rotate(180deg); }

table.screener td {
  height: var(--row-h);
  padding: 0 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: right;
  font-size: 12.5px;
  color: var(--ink-body);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.screener td:first-child { text-align: center; color: var(--ink-muted); font-size: 11.5px; }
table.screener td:nth-child(2) { text-align: left; }
table.screener td:last-child { text-align: center; }
table.screener tbody tr { cursor: pointer; transition: background 100ms ease; }
table.screener tbody tr:hover { background: var(--bg-hover); }
table.screener tbody tr.selected,
table.screener tbody tr.selected:hover { background: var(--bg-active); }
table.screener tbody tr:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
table.screener tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); color: var(--accent-ink); font-weight: 700; }
table.screener tbody tr:last-child td { border-bottom: none; }
table.screener td.text-pos { color: var(--pos); font-weight: 700; }
table.screener td.text-neg { color: var(--neg); font-weight: 700; }
table.screener td.text-muted { color: var(--ink-muted); }

@container screener (max-width: 720px) {
  table.screener th:nth-child(7), table.screener td:nth-child(7),
  table.screener th:nth-child(8), table.screener td:nth-child(8) { display: none; }
}
@container screener (max-width: 580px) {
  table.screener th,
  table.screener td { padding: 0 5px; }
  table.screener th { font-size: 11px; }
  table.screener td { font-size: 12px; }
  table.screener th:first-child { width: 24px; }
}
@container screener (max-width: 500px) {
  .panel-header { gap: 6px; }
  .underline-tabs { gap: 12px; }
  .u-tab { font-size: 12.5px; }
}

.sym-cell { display: inline-flex; align-items: center; gap: 6px; }
.sym-name { font-weight: 700; color: var(--ink-primary); }
.sym-sub {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--bg-chip);
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.02em;
}
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.score-hi { background: var(--accent-soft); color: var(--accent-ink); }
.score-mid { background: var(--bg-chip); color: var(--ink-primary); }
.score-lo { background: var(--neg-bg); color: var(--neg); }

.no-setup-box {
  background: var(--bg-well);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.no-setup-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--ink-primary); }
.closest-list { display: flex; flex-direction: column; gap: 6px; }
.closest-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: var(--row-h);
  padding: 0 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* ETF chart */
#chart-etf-btc svg { max-height: 232px; margin: 0 auto; }
.chart-legend { display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--ink-secondary); flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.swatch { width: 8px; height: 8px; border-radius: 1px; display: inline-block; }
.swatch-pos { background: var(--chart-pos); }
.swatch-neg { background: var(--chart-neg); }
.swatch-line { width: 14px; height: 2px; border-radius: 2px; background: var(--chart-line); display: inline-block; }

/* Intel split: SSI | Catalysts */
.intel-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  min-width: 0;
}
.panel-ssi { container: ssi / inline-size; }
.panel-ssi .panel-header,
.panel-news .panel-header { flex-wrap: wrap; row-gap: 6px; }

.ssi-heatmap {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: 62px;
  grid-auto-rows: 50px;
  gap: 4px;
}
.heat-tile {
  grid-column: span 2;
  border-radius: var(--radius-md);
  padding: 7px 9px;
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
  text-align: left;
  min-width: 0;
  background: var(--bg-elevated);
  color: inherit;
  transition: background 140ms ease, border-color 140ms ease;
}
.heat-tile:nth-child(1), .heat-tile:nth-child(2) { grid-column: span 3; padding: 9px 11px; }
.heat-tile.pos, .heat-tile.pos[data-step="2"] { background: var(--step-up-2); }
.heat-tile.pos[data-step="1"] { background: var(--step-up-1); }
.heat-tile.pos[data-step="3"] { background: var(--step-up-3); }
.heat-tile.pos[data-step="4"] { background: var(--step-up-4); }
.heat-tile.neg, .heat-tile.neg[data-step="2"] { background: var(--step-down-2); }
.heat-tile.neg[data-step="1"] { background: var(--step-down-1); }
.heat-tile.neg[data-step="3"] { background: var(--step-down-3); }
.heat-tile.neg[data-step="4"] { background: var(--step-down-4); }
.heat-tile:hover { border-color: var(--border-strong); }
.heat-tile.active,
.heat-tile.active:hover { border-color: var(--gold); }
.heat-tile:focus-visible { outline-offset: 2px; }
.heat-name { font-size: 11px; font-weight: 700; color: var(--ink-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heat-pct { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.heat-tile:nth-child(1) .heat-pct, .heat-tile:nth-child(2) .heat-pct { font-size: 16px; font-family: var(--font-display); letter-spacing: -0.01em; }

.ssi-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; }
.ssi-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 46px; align-items: center; gap: 10px; font-size: 11.5px; min-height: 16px; }
.ssi-sym { font-weight: 700; color: var(--ink-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ssi-pct { text-align: right; font-weight: 700; color: var(--ink-secondary); }
.bar-track { height: 4px; background: var(--chart-track); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width 300ms ease; }
.ssi-row:nth-child(1) .bar-fill { background: var(--orange-600) !important; }
.ssi-row:nth-child(2) .bar-fill { background: var(--orange-400) !important; }
.ssi-row:nth-child(n+3) .bar-fill { background: var(--ink-muted) !important; }

@container ssi (max-width: 320px) {
  .heat-tile { padding: 6px 7px; }
  .heat-tile:nth-child(1), .heat-tile:nth-child(2) { padding: 8px 9px; }
  .heat-name { font-size: 10.5px; }
  .heat-pct { font-size: 12px; }
  .heat-tile:nth-child(1) .heat-pct, .heat-tile:nth-child(2) .heat-pct { font-size: 14.5px; }
}

.news-list { display: flex; flex-direction: column; }
.news-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-inner);
  min-width: 0;
}
.news-item:first-child { padding-top: 2px; }
.news-item:last-child { border-bottom: none; padding-bottom: 0; }
.news-headline {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-primary);
  text-decoration: none;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
a.news-headline:hover { color: var(--accent-ink); }
.news-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 10.5px; color: var(--ink-muted); }

/* =========================================================================
   9. TICKET — live execution inspector
   ========================================================================= */
.ticket {
  display: flex;
  flex-direction: column;
  padding: 0;
  container: ticket / inline-size;
}
.tk-block { padding: 12px 16px; border-top: 1px solid var(--border-inner); min-width: 0; }
.tk-block:first-child { border-top: none; }

/* Hero quote */
.tk-hero { display: grid; gap: 10px; padding-top: 14px; }
.tk-hero-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.tk-symbol { font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink-primary); }

.ws-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
html[data-stream="live"] .ws-badge { border-color: var(--pos-border); color: var(--pos); }

.tk-quote-row { align-items: flex-end; flex-wrap: wrap; row-gap: 6px; }
.tk-quote { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tk-live-price {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  padding: 0 4px;
  margin-left: -4px;
  white-space: nowrap;
}
.chg-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  background: var(--bg-chip);
  color: var(--ink-secondary);
  white-space: nowrap;
}
.chg-pill.text-pos { background: var(--pos-bg); color: var(--pos); }
.chg-pill.text-neg { background: var(--neg-bg); color: var(--neg); }

.tk-quote-stats { display: flex; gap: 16px; margin: 0; }
.tk-quote-stats > div { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.tk-quote-stats dt { font-size: 10.5px; color: var(--ink-muted); }
.tk-quote-stats dd { margin: 0; font-size: 12px; font-weight: 500; color: var(--ink-primary); white-space: nowrap; }
.tk-quote-stats dd.text-pos { color: var(--pos); }
.tk-quote-stats dd.text-neg { color: var(--neg); }

.dir-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.dir-btn {
  height: 30px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.dir-btn:hover { color: var(--ink-primary); background: var(--bg-hover); }
.dir-btn:disabled { opacity: 0.38; cursor: not-allowed; background: transparent; color: var(--ink-muted); }
.dir-btn.active-long { background: var(--pos-bg); color: var(--pos); box-shadow: inset 0 0 0 1px var(--pos-border); }
.dir-btn.active-short { background: var(--neg-bg); color: var(--neg); box-shadow: inset 0 0 0 1px var(--neg-border); }

/* Risk controls + sizing */
.tk-sizing { display: grid; gap: 8px; }
.param-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.param-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  background: var(--bg-well);
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  cursor: text;
  transition: border-color 120ms ease, background 120ms ease;
}
.param-box:hover { border-color: var(--border-strong); }
.param-box:focus-within { border-color: var(--accent); }
.param-box.is-invalid { border-color: var(--neg); background: var(--neg-bg); }
.param-box.is-invalid .param-label { color: var(--neg); }
.param-label { font-size: 10.5px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.param-input {
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-primary);
  width: 100%;
  min-width: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.param-input:focus-visible { outline: none; }

.sizing-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.sizing-strip > div { background: var(--bg-well); padding: 7px 10px; min-width: 0; }
.size-cell-label { font-size: 10.5px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.size-cell-val { font-size: 13.5px; font-weight: 700; color: var(--ink-primary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.size-cell-sub { font-size: 10.5px; color: var(--ink-secondary); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Microstructure module (elastic absorber, fixed min height, no tab jump) */
.micro { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; }
.micro-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.micro-stat {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  text-align: right;
}
.micro-body {
  position: relative;
  flex: 1 1 auto;
  min-height: var(--micro-h);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-well);
  overflow: hidden;
}
.micro-pane {
  position: absolute;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  transition: opacity 160ms ease, visibility 0s linear 160ms;
}
.micro-pane-chart { visibility: visible; opacity: 1; transition: opacity 160ms ease; }

.micro[data-active-chart="book"] .micro-pane-chart,
.micro[data-active-chart="trades"] .micro-pane-chart,
.micro:has(.seg-btn.active[data-chart="book"]) .micro-pane-chart,
.micro:has(.seg-btn.active[data-chart="trades"]) .micro-pane-chart { visibility: hidden; opacity: 0; transition: opacity 160ms ease, visibility 0s linear 160ms; }
.micro[data-active-chart="book"] .micro-pane-book,
.micro:has(.seg-btn.active[data-chart="book"]) .micro-pane-book,
.micro[data-active-chart="trades"] .micro-pane-trades,
.micro:has(.seg-btn.active[data-chart="trades"]) .micro-pane-trades { visibility: visible; opacity: 1; transition: opacity 160ms ease; }
.micro:has(.seg-btn.active[data-chart="depth"]) .micro-pane-chart,
.micro:has(.seg-btn.active[data-chart="kline"]) .micro-pane-chart { visibility: visible; opacity: 1; }
.micro:has(.seg-btn.active[data-chart="depth"]) .micro-pane-book,
.micro:has(.seg-btn.active[data-chart="depth"]) .micro-pane-trades,
.micro:has(.seg-btn.active[data-chart="kline"]) .micro-pane-book,
.micro:has(.seg-btn.active[data-chart="kline"]) .micro-pane-trades { visibility: hidden; opacity: 0; }

.chart-fill {
  position: absolute;
  inset: 8px 8px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-fill > svg { width: 100%; height: 100%; }
.chart-fill > .skeleton { width: 100%; height: 100%; }

/* Order book ladder */
.ob-ladder {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 4px 0 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.ob-head, .tt-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  height: 22px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.ob-head span:not(:first-child), .tt-head span:not(:first-child) { text-align: right; }
.ob-side { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.ob-asks { justify-content: flex-end; }
.ob-bids { justify-content: flex-start; }
.ob-row {
  position: relative;
  flex: 1 1 0;
  min-height: 16px;
  max-height: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  padding: 0 12px;
  color: var(--ink-body);
}
.ob-row::before {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 0;
  width: var(--depth-pct, 0%);
  max-width: 100%;
  background: var(--ob-bar-bid);
  transition: width 280ms ease-out;
  pointer-events: none;
}
.ob-row.ask::before { background: var(--ob-bar-ask); }
.ob-row > span { position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ob-row > span:not(:first-child) { text-align: right; }
.ob-row.ask .ob-px { color: var(--neg); font-weight: 600; }
.ob-row.bid .ob-px { color: var(--pos); font-weight: 600; }
.ob-cum { color: var(--ink-secondary); }
.ob-row:hover { background: var(--bg-hover); }
.ob-row.is-fill { box-shadow: inset 2px 0 0 var(--accent); }
.ob-row.is-empty > span { color: var(--ink-muted); font-weight: 400; }

.ob-spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 32px;
  flex-shrink: 0;
  margin: 3px 0;
  padding: 0 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.ob-mid {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-primary);
  padding: 0 4px;
  margin-left: -4px;
}
.ob-spread-bps { font-size: 10.5px; color: var(--ink-secondary); }

/* Live trade tape */
.trades-tape { height: 100%; display: flex; flex-direction: column; padding-top: 4px; }
.tt-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.tt-body > .empty-inline { padding: 12px; }
.tt-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  height: 22px;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-body);
}
.tt-row > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-row > span:not(:first-child) { text-align: right; }
.tt-row.buy .tt-px { color: var(--pos); font-weight: 600; }
.tt-row.sell .tt-px { color: var(--neg); font-weight: 600; }
.tt-time { color: var(--ink-muted); }
.tt-row.is-large .tt-sz { color: var(--ink-primary); font-weight: 700; }
.tt-row.is-large { box-shadow: inset 2px 0 0 var(--border-strong); }
.tt-row:hover { background: var(--bg-hover); }

.trade-row-new { animation: trade-in-buy 700ms ease-out; }
.tt-row.sell.trade-row-new { animation-name: trade-in-sell; }
@keyframes trade-in-buy {
  0% { opacity: 0; transform: translateY(-4px); background-color: var(--trade-in-buy); }
  43% { opacity: 1; transform: none; background-color: var(--trade-in-buy); }
  100% { background-color: transparent; }
}
@keyframes trade-in-sell {
  0% { opacity: 0; transform: translateY(-4px); background-color: var(--trade-in-sell); }
  43% { opacity: 1; transform: none; background-color: var(--trade-in-sell); }
  100% { background-color: transparent; }
}

/* Risk gate */
.gate-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.gate-head-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.quote-age { font-size: 10.5px; color: var(--ink-muted); white-space: nowrap; }
.quote-age.is-stale { color: var(--neg); font-weight: 600; }
.gate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.gate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-well);
  font-size: 11.5px;
  gap: 6px;
  min-width: 0;
  transition: background 200ms ease, border-color 200ms ease;
}
.gate-item.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.gate-item.fail { background: var(--neg-bg); border-color: var(--neg-border); }
.gate-left { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink-primary); min-width: 0; }
.gate-left span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gate-val { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; color: var(--pos); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gate-item.warn .gate-val { color: var(--warn); }
.gate-item.fail .gate-val { color: var(--neg); }

/* Rationale + provenance */
.tk-rationale-block { display: grid; gap: 8px; }
.rationale-box {
  border-left: 2px solid var(--accent);
  padding: 8px 10px;
  background: var(--bg-well);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 11.5px;
  color: var(--ink-secondary);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.prov-row { display: flex; flex-wrap: wrap; gap: 4px; }

.ticket-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; padding-bottom: 14px; }
.ticket-actions .btn-lg:first-child { overflow: hidden; text-overflow: ellipsis; }

@container ticket (max-width: 525px) {
  .gate-item { padding: 0 7px; font-size: 11px; gap: 4px; }
  .gate-left { gap: 5px; }
  .gate-val { font-size: 10px; letter-spacing: -0.02em; }
}
@container ticket (max-width: 495px) {
  .micro-head { flex-wrap: wrap; }
  .micro-stat { flex-basis: 100%; text-align: left; }
}
@container ticket (max-width: 470px) {
  .tk-quote-stats > .qs-optional { display: none; }
  .gate-item { padding: 0 6px; font-size: 10.5px; gap: 3px; }
  .gate-val { font-size: 9.5px; letter-spacing: -0.025em; }
}
@container ticket (max-width: 452px) {
  .sizing-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container ticket (max-width: 435px) {
  .seg-btn { padding: 0 8px; font-size: 11px; }
  .gate-grid { grid-template-columns: minmax(0, 1fr); }
  .tk-live-price { font-size: 24px; }
}
@container ticket (max-width: 340px) {
  .param-row { grid-template-columns: minmax(0, 1fr); }
}

/* =========================================================================
   10. BAND 3 — DELIVERY STRIP
   ========================================================================= */
.delivery-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--border);
  flex: 1 0 auto;
}
.table-scroll { overflow-x: auto; min-width: 0; margin: 0 -16px; padding: 0 16px; }
/* Screener already bleeds via .screener-body; prevent double negative margins when static */
.table-scroll.screener-scroll { margin: 0; padding: 0 8px; }

table.journal { width: 100%; border-collapse: collapse; }
table.journal th {
  height: 30px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-muted);
  padding: 0 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.journal th.r, table.journal td.r { text-align: right; }
table.journal td {
  height: var(--row-h);
  padding: 0 8px;
  font-size: 12px;
  color: var(--ink-body);
  border-bottom: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.journal td[colspan] { white-space: normal; padding-top: 8px; padding-bottom: 8px; }
table.journal td strong { color: var(--ink-primary); }
table.journal td.text-pos { color: var(--pos); font-weight: 700; }
table.journal td.text-neg { color: var(--neg); font-weight: 700; }
table.journal td.text-muted { color: var(--ink-muted); }
table.journal tbody tr:hover { background: var(--bg-hover); }
table.journal tbody tr:last-child td { border-bottom: none; }

.panel-brief { display: flex; flex-direction: column; gap: 12px; }
.panel-brief .panel-header { margin-bottom: 0; }
.brief-stats {
  display: grid;
  /* Balance Regime and Top Setup columns so multi-word regimes and scored symbols fit untruncated */
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 0.70fr) minmax(0, 1.02fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.brief-stat { background: var(--bg-well); padding: 8px 10px; min-width: 0; }
.brief-stat span { display: block; font-size: 10.5px; color: var(--ink-muted); }
.brief-stat strong {
  display: block;
  font-size: 13px;
  margin-top: 2px;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brief-sections { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11px; color: var(--ink-secondary); }
.brief-sections li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.brief-sections li::before { content: ""; width: 5px; height: 5px; border-radius: 1px; background: var(--accent); flex-shrink: 0; }
.brief-actions-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.brief-count { font-size: 11px; color: var(--ink-muted); }
.brief-count strong { color: var(--ink-primary); }

/* =========================================================================
   11. VIEWS 2–4
   ========================================================================= */
.wallet-form { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.text-input {
  flex: 1;
  min-width: 240px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--ink-primary);
  background: var(--bg-surface);
  outline: none;
  transition: border-color 140ms ease;
}
.text-input::placeholder { color: var(--ink-muted); }
.text-input:focus { border-color: var(--border-search-focus); }
.text-input:focus-visible { outline: none; }
.wallet-form .btn { height: 36px; }
.wallet-summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-well);
  margin-bottom: 12px;
}
.wallet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.sub-heading { font-size: 12px; font-weight: 700; color: var(--ink-secondary); margin-bottom: 6px; }
.wallet-list { display: flex; flex-direction: column; }
.wallet-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: var(--row-h);
  padding: 0 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  min-width: 0;
}
.wallet-row > span { overflow-wrap: anywhere; text-align: right; }
.wallet-row:last-child { border-bottom: none; }
.empty-inline { color: var(--ink-muted); font-size: 12px; padding: 8px 2px; }

.method-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 1px;
  background: var(--border);
  flex: 1;
}
.method-span { grid-column: 1 / -1; }
.method-table { width: 100%; border-collapse: collapse; }
.method-table th, .method-table td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  vertical-align: top;
  line-height: 1.5;
}
.method-table thead th { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 8px; }
.method-table tbody tr:last-child th, .method-table tbody tr:last-child td { border-bottom: none; }
.method-table th { color: var(--ink-muted); font-weight: 400; width: 150px; }
.method-table code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-chip);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  color: var(--accent-ink);
  overflow-wrap: anywhere;
}
.method-endpoints { min-width: 760px; }
.method-endpoints td:first-child { white-space: nowrap; width: 128px; }
.method-endpoints thead th { width: auto; }

/* =========================================================================
   12. ZONE 5 — PINNED TICKER TAPE (32px)
   ========================================================================= */
.ticker-footer {
  height: var(--h-footer);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11.5px;
  color: var(--ink-secondary);
  position: sticky;
  bottom: 0;
  z-index: 25;
}
.footer-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-primary);
  padding-right: 14px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.ticker-tape {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  overflow-x: auto;
  white-space: nowrap;
  min-width: 0;
  padding-right: 16px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
}
.ticker-tape::-webkit-scrollbar { display: none; }
.tape-item { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tape-item > span { padding: 0 2px; }
.tape-item strong { color: var(--ink-primary); font-weight: 700; }
.tape-item + .tape-item { padding-left: 18px; border-left: 1px solid var(--border); }
.ticker-disclaimer { font-size: 11px; color: var(--ink-muted); white-space: nowrap; flex-shrink: 0; }

/* =========================================================================
   13. MODALS & SKELETON
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 16px;
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
}
.modal-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal-head h3 { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--ink-primary); letter-spacing: -0.01em; }
.modal-head .btn-icon { width: 28px; height: 28px; border-color: transparent; background: transparent; }
.modal-head .btn-icon:hover { background: var(--bg-hover); border-color: var(--border); }
.modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; color: var(--ink-body); }
.override-block { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-label { font-size: 11.5px; font-weight: 700; color: var(--ink-primary); }
.field-counter { font-size: 10.5px; color: var(--ink-muted); }
.field-counter.is-ok { color: var(--pos); }
.field-help { font-size: 11px; color: var(--ink-muted); }
.settings-status { padding: 9px 11px; border-radius: var(--radius-sm); background: var(--bg-well); border: 1px solid var(--border); font-size: 12px; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.kv-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.kv-box { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-well); border: 1px solid var(--border); min-width: 0; }
.kv-box span { display: block; font-size: 10.5px; color: var(--ink-muted); }
.kv-box strong { font-size: 12.5px; color: var(--ink-primary); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.skeleton {
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =========================================================================
   14. RESPONSIVE — Multi-scale proportion system across desktop & zoom bands
   ========================================================================= */

/* >= 1680: Ultrawide & zoomed-out (1920@100%, 1920@90%/75%, 1440@75%) —
   cap Ticket column width so charts & 8-check gate stay crisply proportioned. */
@media (min-width: 1680px) {
  .desk-grid { grid-template-columns: minmax(0, 1.48fr) minmax(520px, 650px); }
}

@media (max-width: 1640px) {
  .tele-opt { display: none; }
}

/* 1120–1379: Medium desktop & zoomed laptop (1366, 1280, 1440@110%/125%, 1920@150%).
   Keep intel stacked inside the left column beneath ETF so Screener stays naturally
   balanced beside Ticket with zero vertical void. */
@media (max-width: 1379px) {
  :root,
  [data-theme="dark"],
  [data-theme="light"] {
    --micro-h: 256px;
  }
  .kpi-strip { grid-template-columns: 292px minmax(0, 1fr); }
  .strip-cell { padding: 10px 14px; }
  .strip-regime-body { gap: 10px; }
  .mini-gauge-host { width: 98px; }
  .mini-factors { gap: 3px 10px; }

  .desk-grid {
    grid-template-columns: minmax(0, 1.34fr) minmax(420px, 1fr);
    grid-template-rows: 1fr auto auto;
    grid-template-areas:
      "screener ticket"
      "etf      ticket"
      "intel    ticket";
  }

  .panel:not(.ticket) { padding: 12px 14px; }
  .panel.ticket { padding: 0; }
  .screener-body { margin: 0 -14px; }
  .screener-body > .no-setup-box { margin: 6px 14px 12px; }
  .table-scroll:not(.screener-scroll) { margin: 0 -14px; padding: 0 14px; }
  .tk-block { padding: 11px 14px; }

  .telemetry-bar { gap: 12px; padding: 0 10px 0 14px; }
  .telemetry-left { gap: 10px; }
  .tele-btn { padding: 0 7px; }
  .global-search-wrap { flex-basis: 320px; }
  #provenance-label { display: inline-block; max-width: 195px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
}

/* 1120–1279: Narrower zoomed desktop (1152x800, 1440@125%) — tighten rail & micro-h
   so Screener + ETF + 2-col Intel align tightly against Ticket. */
@media (max-width: 1279px) {
  :root,
  [data-theme="dark"],
  [data-theme="light"] {
    --w-rail: 72px;
    --micro-h: 244px;
  }
  .brief-stat { padding: 7px 8px; }
  .brief-stat strong { font-size: 12px; }
  .telemetry-bar { gap: 8px; }
  .telemetry-left { gap: 8px; }
  .tele-btn { padding: 0 6px; }
  .global-search-wrap { flex-basis: 280px; }
  #provenance-label { max-width: 176px; }
  .ticker-disclaimer { font-size: 10.5px; max-width: 310px; overflow: hidden; text-overflow: ellipsis; }
}

/* <= 1239: Switch Band 1 KPIs to spacious 2x2 beside Regime so event titles stay legible */
@media (max-width: 1239px) {
  .kpi-strip { grid-template-columns: 286px minmax(0, 1fr); }
  .strip-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip-kpis .strip-cell { min-height: 74px; padding: 8px 14px; }
  .strip-kpis > .strip-cell:nth-child(3) .kpi-val { font-size: clamp(15px, 1.32vw, 19px); }
  .strip-regime { justify-content: center; gap: 10px; }
  .strip-regime .strip-head { margin-bottom: 2px; }
  .stream-rate { display: none; }
}

/* 1024–1119: Compact 2-column laptop / landscape tablet (1024x768, 1280@125%).
   Stack SSI + Catalysts vertically inside the left column with 2-col SSI constituents
   so both Desk columns land at matched height with zero void and zero cramped tiles. */
@media (max-width: 1119px) {
  :root,
  [data-theme="dark"],
  [data-theme="light"] {
    --w-rail: 68px;
    --screener-min: 304px;
    --micro-h: 244px;
  }
  .desk-grid { grid-template-columns: minmax(0, 1.24fr) minmax(414px, 1fr); }
  .intel-split { grid-template-columns: minmax(0, 1fr); }
  .ssi-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }

  .telemetry-bar { gap: 8px; }
  .telemetry-left { gap: 8px; }
  #theme-label { display: none; }
  .sync-countdown { display: none; }
  #provenance-label { max-width: 168px; }
  .ticker-disclaimer { max-width: 240px; }
}

/* 781–1023: Single-column workspace (900x800, 1440@150%).
   Screener flows to its natural row height (capped at 392px) so filtered or low-count
   tables never produce an empty box; full-width Intel returns to 2-column side-by-side. */
@media (max-width: 1023px) {
  .kpi-strip { grid-template-columns: minmax(0, 1fr); }
  .strip-regime { justify-content: space-between; gap: 4px; }
  .strip-regime-meta { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 20px; }
  .mini-factors { grid-template-columns: repeat(4, auto); justify-content: start; gap: 4px 20px; width: auto; }
  .mini-factor { gap: 6px; }

  .desk-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "screener" "ticket" "etf" "intel";
  }
  .screener-body { flex: 0 0 auto; min-height: 0; height: auto; }
  .screener-scroll { position: static; max-height: 392px; overflow: auto; }
  .micro { flex: 0 0 auto; }
  .micro-body { flex: 0 0 auto; min-height: 272px; }

  .intel-split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ssi-list { grid-template-columns: minmax(0, 1fr); }
  .delivery-grid, .method-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .global-search-wrap { flex-basis: 240px; }
}

/* <= 960: Split telemetry bar into 2 unclipped rows before BTC/ETH clip on medium tablets */
@media (max-width: 960px) {
  .telemetry-bar {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    padding: 6px 12px;
  }
  .telemetry-right { flex-wrap: wrap; row-gap: 4px; margin: 0 -4px; }
  .telemetry-right #provenance-label { max-width: 195px; }
  .stream-rate, .sync-countdown, #theme-label { display: inline; }
}

/* 680–780: Portrait tablet (768x1024) — rail shifts to sticky top nav while keeping
   single-row topbar and 2-col KPI / Intel layouts. */
@media (max-width: 780px) {
  .telemetry-right #provenance-label { max-width: 176px; }

  .topbar { position: static; height: auto; }
  .brand { width: 64px; padding: 8px 0; }
  .topbar-main { padding: 8px 12px; gap: 10px; }
  .global-search-wrap { flex: 1 1 200px; }

  .app-shell { flex-direction: column; width: 100%; }
  .left-rail {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 29;
  }
  .rail-stack { position: static; flex-direction: row; padding: 0; }
  .rail-item { flex: 1 1 0; min-width: 0; height: 50px; }
  .rail-item.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .workspace-col, .terminal-main { width: 100%; max-width: 100vw; }

  .panel:not(.ticket) { padding: 12px; }
  .panel.ticket { padding: 0; }
  .tk-block { padding: 12px; }
  .screener-body { margin: 0 -12px; }
  .table-scroll.screener-scroll { margin: 0; padding: 0 6px; max-height: 360px; }
  .screener-body > .no-setup-box { margin: 6px 12px 12px; }
  .table-scroll:not(.screener-scroll) { margin: 0 -12px; padding: 0 12px; }
  table.screener { min-width: 500px; }
  table.journal { min-width: 540px; }
  .panel-header { flex-wrap: wrap; }

  .wallet-grid, .kv-list { grid-template-columns: minmax(0, 1fr); }
  .text-input { min-width: 0; width: 100%; }
  .method-table th { width: 110px; }

  .ticker-footer { position: static; height: auto; flex-wrap: wrap; padding: 6px 12px; gap: 4px 12px; }
  .ticker-tape { flex: 1 1 0; min-width: 0; }
  .ticker-disclaimer { flex: 1 0 100%; max-width: none; white-space: normal; }
}

/* <= 679: Narrow tablet & landscape phone — wrap topbar and stack Intel */
@media (max-width: 679px) {
  .telemetry-left {
    padding-right: 16px;
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 16px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 16px), transparent 100%);
  }
  .topbar-main { flex-wrap: wrap; gap: 8px; }
  .global-search-wrap { flex: 1 1 100%; }
  .topbar-actions { width: 100%; flex-wrap: wrap; gap: 6px; }
  .topbar-actions .btn-primary { margin-left: auto; }
  .intel-split { grid-template-columns: minmax(0, 1fr); }
}

/* <= 520: Mobile phone (390x844) — single-col KPIs & brief stats, compact controls */
@media (max-width: 520px) {
  .strip-regime-meta { flex-direction: column; align-items: flex-start; gap: 6px; }
  .mini-factors { grid-template-columns: 1fr 1fr; gap: 3px 12px; width: 100%; }
  .mini-factor { gap: 4px; }
  .strip-kpis { grid-template-columns: minmax(0, 1fr); }
  .strip-kpis .strip-cell { min-height: 68px; padding: 9px 12px; }
  .brand { width: 56px; }
  .brand-text { font-size: 11px; }
  .topbar-actions .pill { height: 30px; padding: 0 9px; font-size: 11px; }
  .topbar .btn-icon { width: 30px; height: 30px; }
  .topbar .btn-primary { height: 30px; padding: 0 10px; font-size: 11.5px; }
  .screener-scroll { max-height: 336px; }
  .micro-body { min-height: 240px; }
  .ticket-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ticket-actions > :first-child { grid-column: 1 / -1; }
  .brief-stats { grid-template-columns: minmax(0, 1fr); }
  .mini-gauge-host { width: 92px; }
  .ssi-heatmap { grid-template-rows: 56px; grid-auto-rows: 48px; }
  .wallet-form .btn { flex: 1 1 auto; }
}

/* =========================================================================
   15. REDUCED MOTION — no movement, state colors kept
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .ws-dot::after { display: none; }
  .tick-up { background-color: var(--flash-up-bg); color: var(--pos); }
  .tick-down { background-color: var(--flash-down-bg); color: var(--neg); }
  .tt-row.buy.trade-row-new { background-color: var(--trade-in-buy); }
  .tt-row.sell.trade-row-new { background-color: var(--trade-in-sell); }
  .btn:active { transform: none; }
}
