/*
 * Equity Breakout Trading App — institutional trading-terminal design system
 * (Phase 5.1B). docs/architecture/OPERATIONS_DASHBOARD_DESIGN.md,
 * docs/architecture/CNC_MARKET_PREPARATION_DESIGN.md.
 *
 * Canonical tokens (Phase 5.1B spec) defined once on [data-bs-theme="dark"]
 * (this app's actual, hardcoded identity) below; every existing --ops-*
 * token from Phase 4 is now a plain alias onto these, so none of the
 * ~500 lines of component CSS below needed rewriting to adopt the new
 * names. Semantic color rule, applied consistently everywhere: profit/
 * healthy = --ok, pending/attention = --warn, true loss/failure/risk =
 * --danger, STOP/protective-state = --protect (never --danger — a STOP
 * order is downside protection, not a system error), inactive/
 * informational/breakeven = --neutral. Cyan (--accent) is the product's
 * own interactive/brand accent, used sparingly, never a status color.
 */

:root {
  --ops-surface: #ffffff;
  --ops-surface-2: #f7f8f9;
  --ops-line: #e3e6e8;
  --ops-line-strong: #cdd2d6;
  --ops-ink: #10161a;
  --ops-ink-soft: #5c6770;
  --ops-ink-faint: #8a949b;
  --ops-shadow: 0 1px 2px rgba(16, 22, 26, 0.04), 0 4px 14px -8px rgba(16, 22, 26, 0.10);
  --ops-accent: #0c7a8a;
}

[data-bs-theme="dark"] {
  /* Phase 5.1B canonical surface/text tokens. */
  --bg: #0d1117;
  --panel: #161b22;
  --surface-hover: #1c2128;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #b1bac4;
  --accent: #22d3ee;

  /* Phase 5.1B canonical semantic status tokens. */
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --protect: #58a6ff;
  --neutral: #8b949e;

  /* Phase 4's --ops-* names now alias the tokens above -- every existing
     rule referencing them is unaffected by this rename. */
  --ops-surface: var(--panel);
  --ops-surface-2: var(--surface-hover);
  --ops-line: var(--border);
  --ops-line-strong: #3d4653;
  --ops-ink: var(--text-primary);
  --ops-ink-soft: var(--text-secondary);
  --ops-ink-faint: var(--neutral);
  --ops-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 18px -8px rgba(0, 0, 0, 0.55);
  --ops-accent: var(--accent);
  --ops-bg: var(--bg);
}

body {
  font-size: 14px;
  color: var(--ops-ink);
  background: var(--bg);
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Semantic-color text utilities — profit/healthy=--ok, pending=--warn,
   loss/risk=--danger, STOP/protective=--protect (never --danger), a
   sign or label always accompanies the color (never color-only). */
.text-ok       { color: var(--ok); }
.text-warn     { color: var(--warn); }
.text-danger   { color: var(--danger); }
.text-protect  { color: var(--protect); }
.text-neutral  { color: var(--ops-ink-faint); }

/* Bootstrap 5's own `.table > :not(caption) > * > *` rule sets a color on
   every table cell with specificity (0,1,1) -- equal to or higher than a
   single class selector, so .text-ok/.text-danger/etc. above were
   silently losing to it whenever applied directly to a <td> inside any
   .ops-table (discovered live during Module 4's Target/Stop coloring
   verification; Today's Completed's P&L sign coloring had the identical,
   previously-undetected bug). (0,2,1) unambiguously wins regardless of
   stylesheet load order. */
.ops-table td.text-ok       { color: var(--ok); }
.ops-table td.text-warn     { color: var(--warn); }
.ops-table td.text-danger   { color: var(--danger); }
.ops-table td.text-protect  { color: var(--protect); }
.ops-table td.text-neutral  { color: var(--ops-ink-faint); }

.ops-shell {
  max-width: 1360px;
}

/* ═══════════════════════════════════════════════════════════════════════
   Command Rail + Lifecycle Spine + layout grid (Phase 5.1B, Module 1)
   ═══════════════════════════════════════════════════════════════════ */

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

.ncr-rail {
  flex: 0 0 60px;
  width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 0 10px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.ncr-rail-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 18px;
  text-decoration: none;
  flex: 0 0 auto;
}
.ncr-rail-link:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.ncr-rail-link.active {
  background: var(--surface-hover);
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.ncr-rail-spacer {
  flex: 1 1 auto;
}

.ncr-rail-safety {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  width: 100%;
}

.ncr-rail-pip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 20px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  flex: 0 0 auto;
}
.ncr-rail-pip-paper  { background: rgba(34, 211, 238, 0.14); color: var(--accent); }
.ncr-rail-pip-locked { background: rgba(88, 166, 255, 0.14); color: var(--protect); }
.ncr-rail-pip-danger { background: rgba(248, 81, 73, 0.16); color: var(--danger); }
.ncr-rail-pip-ok     { background: rgba(63, 185, 80, 0.14); color: var(--ok); }
.ncr-rail-pip-warn   { background: rgba(210, 153, 34, 0.16); color: var(--warn); }

.ncr-rail-slots {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.ncr-rail-slot-pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex: 0 0 auto;
}
.ncr-rail-slot-pip.filled {
  background: var(--accent);
}

.ncr-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 20px 32px;
}

/* ── Lifecycle Spine — thin visual identity strip ────────────────────── */
.ncr-spine {
  margin-bottom: 12px;
}
.ncr-spine-track {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 4px;
  padding: 8px 12px;
  background: var(--ops-surface);
  border: 1px solid var(--ops-line);
  border-radius: 4px;
}
.ncr-spine-stage {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 6px;
  white-space: nowrap;
}
.ncr-spine-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
}
.ncr-spine-count {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ops-ink);
}
.ncr-spine-arrow {
  color: var(--ops-ink-faint);
  font-size: 12px;
  flex: 0 0 auto;
}
.ncr-spine-stage-terminal .ncr-spine-label {
  color: var(--ops-ink-faint);
}

/* ── Trading Pulse hero ───────────────────────────────────────────────── */
.ncr-pulse-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(5, minmax(88px, 1fr));
  gap: 10px;
  padding: 16px;
  background: var(--ops-surface);
  border: 1px solid var(--ops-line);
  border-radius: 4px;
}
.ncr-pulse-primary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding-right: 14px;
  border-right: 1px solid var(--ops-line);
}
.ncr-pulse-primary-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
}
.ncr-pulse-primary-value {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.ncr-pulse-primary-sub {
  font-size: 11.5px;
  color: var(--ops-ink-soft);
}
.ncr-pulse-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.ncr-pulse-item-divider {
  /* Trading Pulse Accounting Refinement: a quiet left rule marks where
     the realized-accounting sequence (Today Realized -> Day Return ->
     Realized Equity) ends and mark-to-market (Unrealized P&L) begins --
     never the other way around, and never louder than the realized
     figures themselves. */
  padding-left: 12px;
  border-left: 1px solid var(--ops-line);
}
.ncr-pulse-item-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
}
.ncr-pulse-item-value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ncr-pulse-item-sub {
  font-size: 10.5px;
  color: var(--ops-ink-soft);
}
.ncr-pulse-afterhours-note {
  margin-top: 6px;
  padding: 4px 16px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
}

/* ── Capital Allocation Rail — proportional DEPLOYED|RESERVED|FREE bar ── */
.ops-capital-rail-track {
  display: flex;
  width: 100%;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--ops-line);
  margin: 4px 0 8px;
}
.ops-capital-rail-seg {
  height: 100%;
}
.ops-capital-rail-seg-deployed { background: var(--protect); }
.ops-capital-rail-seg-reserved { background: var(--warn); }
.ops-capital-rail-seg-free     { background: var(--ops-line-strong); }
.ops-capital-rail-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 10.5px;
  color: var(--ops-ink-soft);
  margin-bottom: 10px;
}
.ops-capital-rail-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ops-capital-rail-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.ops-capital-rail-note {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.ops-capital-rail-note.is-warning { color: var(--warn); }
.ops-capital-rail-note.is-danger  { color: var(--danger); }

/* ── Health Rail — one banner, never several equal cards ─────────────── */
.ncr-health-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.ncr-health-ok {
  background: rgba(63, 185, 80, 0.10);
  border-color: rgba(63, 185, 80, 0.3);
  color: var(--ok);
}
.ncr-health-problem {
  /* Critical (red) reads visibly louder than the routine OK/amber
     states -- stronger fill + a left accent bar -- so a genuine
     market-data/integrity failure never carries the same quiet visual
     weight as "all systems normal" (Phase 5.4 hierarchy audit, item 4). */
  background: rgba(248, 81, 73, 0.16);
  border-color: rgba(248, 81, 73, 0.45);
  box-shadow: inset 3px 0 0 var(--danger);
  color: var(--danger);
  font-weight: 700;
}
.ncr-health-problem.is-amber {
  background: rgba(210, 153, 34, 0.10);
  border-color: rgba(210, 153, 34, 0.3);
  box-shadow: none;
  color: var(--warn);
  font-weight: 600;
}
.ncr-health-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ── Two-column layout grid: main content + narrow side rail ─────────── */
.ncr-side-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}
.ncr-side-main {
  min-width: 0;
}
.ncr-side-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

@media (max-width: 991.98px) {
  .ncr-side-grid {
    grid-template-columns: 1fr;
  }
  .ncr-pulse-grid {
    grid-template-columns: 1fr 1fr;
  }
  .ncr-pulse-primary {
    grid-column: 1 / -1;
    border-right: none;
    border-bottom: 1px solid var(--ops-line);
    padding-right: 0;
    padding-bottom: 10px;
  }
}

@media (max-width: 575.98px) {
  .ncr-shell {
    flex-direction: column;
  }
  .ncr-rail {
    position: sticky;
    top: 0;
    height: auto;
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    padding: 8px 10px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 20;
  }
  .ncr-rail-spacer {
    display: none;
  }
  .ncr-rail-safety {
    flex-direction: row;
    border-top: none;
    padding-top: 0;
    margin-left: auto;
    width: auto;
  }
  .ncr-rail-slots {
    flex-direction: row;
  }
  .ncr-main {
    padding: 6px 12px 24px;
  }
  .ncr-pulse-grid {
    grid-template-columns: 1fr;
  }
  .ncr-pulse-primary {
    border-bottom: 1px solid var(--ops-line);
  }
  .ncr-pulse-item-divider {
    padding-left: 0;
    padding-top: 8px;
    border-left: none;
    border-top: 1px solid var(--ops-line);
  }
  /* Module 8: Capital/Entry-Capacity/Controls rank ahead of Open
     Positions in the requested mobile priority order -- a CSS Grid
     `order` swap (no DOM/JS change, no effect at >=576px, where the
     two-column side-grid already exists) moves the side-rail (Capital,
     Operator Focus, Manual Actions) before the main Open Positions
     column once the grid has already collapsed to one column. */
  .ncr-side-main { order: 2; }
  .ncr-side-rail { order: 1; }
}

/* ── Header — compact institutional strip, not a page hero ──────────────── */
.ops-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 2px 14px;
  margin-bottom: 4px;
}
.ops-header-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}
.ops-header-logo {
  flex: 0 0 auto;
  display: block;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.ops-header-name {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.ops-header-name-accent {
  color: var(--ok);
}
.ops-header-name-primary {
  color: var(--ops-ink);
}
.ops-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--ops-ink-faint);
  white-space: nowrap;
}
.ops-header-clock {
  font-variant-numeric: tabular-nums;
}

/* ── Cards — minimal border, no default Bootstrap shadow, one subtle shadow */
.ops-card {
  background: var(--ops-surface);
  border: 1px solid var(--ops-line);
  border-radius: 4px;
  box-shadow: var(--ops-shadow);
  margin-bottom: 16px;
}
.ops-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--ops-line);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ops-ink-soft);
}
.ops-card-head.ops-card-head-dominant {
  font-size: 13px;
  color: var(--ops-ink);
}
.ops-card-body-flush { padding: 0; }
.ops-card-body { padding: 12px 14px; }

/* Market Watch is the dominant section — a touch more visual weight than
   every other card, achieved via border color and type size only (never
   a background-color change, which would read as "alert" rather than
   "primary"). */
.ops-card-dominant {
  border-color: var(--ops-line-strong);
}

/* ── Compact tables, aligned numeric columns ─────────────────────────────── */
.ops-table {
  font-size: 12.5px;
  margin-bottom: 0;
  color: var(--ops-ink);
}
.ops-table thead th {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
  border-bottom: 1px solid var(--ops-line);
  background: var(--ops-surface-2);
  padding: 6px 10px;
  white-space: nowrap;
}
.ops-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--ops-line);
  vertical-align: middle;
}
.ops-table tbody tr:last-child td { border-bottom: none; }
.ops-table tbody tr:hover td { background: var(--ops-surface-2); }

/* Phase 5.1B-r3: entered/terminal Trade Flow rows (Order Pending onward)
   read as settled, not actionable -- symbol/state/pills/Target/Stop keep
   full strength (STOP/TARGET semantic color is never diluted), only the
   pre-entry-relevant LTP/Buy/Distance-to-Buy cells dim, since those stop
   mattering once a trade is no longer waiting to cross into Buy. */
.ops-mw-row-settled td[data-label="LTP"],
.ops-mw-row-settled td[data-label="Buy"],
.ops-mw-row-settled td[data-label="Distance to Buy"] {
  color: var(--ops-ink-soft);
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right;
  white-space: nowrap;
}

/* ── Status strip — compact tiles, replacing the default Bootstrap .card
   (heavier border + shadow, more padding than this terminal style wants) */
.ops-stat {
  background: var(--ops-surface);
  border: 1px solid var(--ops-line);
  border-radius: 4px;
  padding: 7px 4px;
  text-align: center;
}
.ops-stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
  margin-bottom: 3px;
}

/* ── Status pills — restrained; color is the ONLY thing that varies ─────── */
.ops-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
.ops-pill-grey    { background: var(--ops-surface-2); color: var(--ops-ink-soft); border-color: var(--ops-line-strong); }
.ops-pill-amber   { background: rgba(230, 160, 20, 0.12); color: #a06600; border-color: rgba(230, 160, 20, 0.35); }
.ops-pill-teal    { background: rgba(12, 122, 138, 0.12); color: var(--ops-accent); border-color: rgba(12, 122, 138, 0.35); }
.ops-pill-green   { background: rgba(27, 138, 77, 0.12); color: #1b8a4d; border-color: rgba(27, 138, 77, 0.35); }
.ops-pill-red     { background: rgba(200, 60, 60, 0.12); color: #c33c3c; border-color: rgba(200, 60, 60, 0.35); }
.ops-pill-blue    { background: rgba(40, 100, 200, 0.12); color: #2864c8; border-color: rgba(40, 100, 200, 0.35); }
.ops-pill-orange  { background: rgba(210, 110, 20, 0.14); color: #b25f10; border-color: rgba(210, 110, 20, 0.4); }
[data-bs-theme="dark"] .ops-pill-amber  { color: #e3ac48; }
[data-bs-theme="dark"] .ops-pill-teal   { background: rgba(34, 211, 238, 0.14); color: var(--ops-accent); border-color: rgba(34, 211, 238, 0.4); }
[data-bs-theme="dark"] .ops-pill-green  { color: var(--ok); }
[data-bs-theme="dark"] .ops-pill-red    { color: var(--danger); }
[data-bs-theme="dark"] .ops-pill-blue   { color: var(--protect); }
[data-bs-theme="dark"] .ops-pill-orange { color: #e39a48; }

/* REAL ORDERS LOCKED OFF — the one safety pill that must never be
   mistaken for "just another disabled/grey state": a distinct cyan-
   accented border (never red/danger — LOCKED OFF is the SAFE state,
   not an alarm) makes it read as a deliberate, visible gate rather
   than an inert default. */
.ops-pill-locked {
  background: var(--ops-surface-2);
  color: var(--ops-ink);
  border-color: var(--ops-accent);
  font-weight: 700;
}

/* Price Zone badge — Item 4's six-label, price-location-only vocabulary
   (app.market_data.live_ticker.classify_price_zone), kept structurally
   separate from the Stage/Execution Status .ops-pill badges: this column
   answers "where is price," never "what's the lifecycle state." §3.5:
   color/opacity changes only on update — never a size/position change. */
.zone-badge.zone-below_stop           { background-color: var(--bs-danger)    !important; }
.zone-badge.zone-between_stop_and_buy { background-color: var(--bs-secondary) !important; }
.zone-badge.zone-near_entry           { background-color: var(--bs-warning)   !important; color: #000 !important; }
.zone-badge.zone-above_buy            { background-color: #0dcaf0 !important; color: #000 !important; }
.zone-badge.zone-near_target          { background-color: #20c997 !important; color: #000 !important; }
.zone-badge.zone-above_target         { background-color: var(--bs-success)   !important; }

.live-indicator .badge {
  transition: background-color 0.3s ease, color 0.3s ease;
}

.tick-flash {
  animation: tick-flash-anim 0.6s ease-out;
}
@keyframes tick-flash-anim {
  from { background-color: rgba(13, 202, 240, 0.25); }
  to { background-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .tick-flash { animation: none; }
}

.cell-stale {
  opacity: 0.5;
}

/* ── System Details — collapsible, de-emphasized, technical-scheduler
   content moved out of the primary reading path per the terminal-style
   upgrade. Bootstrap 5 ships no default <details> chrome worth keeping. */
.ops-details {
  border: 1px solid var(--ops-line);
  border-radius: 4px;
  background: var(--ops-surface);
  box-shadow: var(--ops-shadow);
}
.ops-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ops-ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ops-details > summary::-webkit-details-marker { display: none; }
.ops-details > summary::before {
  content: "\25B8"; /* ▸ */
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--ops-ink-faint);
}
.ops-details[open] > summary::before { transform: rotate(90deg); }
.ops-details > summary:focus-visible { outline: 2px solid var(--ops-accent); outline-offset: 2px; }
.ops-details-body {
  border-top: 1px solid var(--ops-line);
  padding: 12px;
}

/* ── "+ Add Stock" ghost button + its collapsible panel ──────────────────── */
.ops-btn-ghost {
  background: transparent;
  border: 1px solid var(--ops-line-strong);
  border-radius: 4px;
  color: var(--ops-ink-soft);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  cursor: pointer;
}
.ops-btn-ghost:hover { background: var(--ops-surface-2); color: var(--ops-ink); }
.ops-btn-ghost[aria-expanded="true"] { background: var(--ops-surface-2); color: var(--ops-accent); border-color: var(--ops-accent); }
.ops-manual-add-panel {
  padding: 10px 14px;
  border-bottom: 1px solid var(--ops-line);
  background: var(--ops-surface-2);
}

/* ── Today's Scanner — compact pipeline strip, replacing the old six-card grid */
.ops-scanner-pipeline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 4px;
}
.ops-scanner-stage {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 2px 4px;
}
.ops-scanner-stage-final .ops-scanner-value { color: var(--ops-accent); }
.ops-scanner-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--ops-ink);
}
.ops-scanner-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
}
.ops-scanner-arrow {
  color: var(--ops-ink-faint);
  font-size: 13px;
  padding: 0 2px;
}
/* ── Discovery — post-freeze compact one-liner (Module 3) ─────────────── */
.ops-scanner-compact {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
}
.ops-scanner-compact-text {
  font-variant-numeric: tabular-nums;
  color: var(--ops-ink-soft);
}
.ops-scanner-compact-text strong {
  color: var(--ops-ink);
  font-weight: 700;
}

.ops-inline-summary {
  font-size: 11.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ops-inline-summary::before {
  content: "\25B8";
  color: var(--ops-ink-faint);
}
.ops-inline-summary:hover { color: var(--ops-ink); }
.ops-inline-summary:hover::before { color: var(--ops-ink-soft); }
details[open] > .ops-inline-summary::before { transform: rotate(90deg); display: inline-block; }

/* ── Market Watch / Active Orders — per-row expandable detail panel ──────── */
.ops-mw-toggle-col { width: 22px; padding-left: 8px !important; padding-right: 0 !important; }
.ops-row-toggle {
  background: none;
  border: none;
  color: var(--ops-ink-faint);
  cursor: pointer;
  font-size: 10px;
  padding: 2px 4px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.12s ease;
}
.ops-row-toggle:hover { color: var(--ops-ink); }
.ops-row-toggle[aria-expanded="true"] { transform: rotate(90deg); color: var(--ops-accent); }
.ops-detail-row td { background: var(--ops-surface-2); }
.ops-detail-cell { padding: 10px 16px !important; }
.ops-detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 6px;
}
.ops-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ops-detail-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
}
.ops-detail-reason {
  font-size: 12px;
  color: var(--ops-ink-soft);
  margin-bottom: 4px;
}
/* ── Lifecycle mini-rail (Module 4) — WATCH -> CROSS -> ENTRY -> EXIT,
   authoritative-only, detail-panel-only (the main row's State pill
   already gives the current stage at a glance; this gives the full
   progression on demand). Never claims ARMED — CROSS lights up only on
   real cnc.entry_trigger.buy_cross_detected audit evidence. ─────────── */
.ops-mw-lifecycle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.ops-mw-lifecycle-step {
  padding: 2px 7px;
  border-radius: 3px;
  color: var(--ops-ink-faint);
  background: var(--ops-surface);
  border: 1px solid var(--ops-line-strong);
}
.ops-mw-lifecycle-step.reached {
  color: var(--ok);
  border-color: var(--ok);
  background: rgba(63, 185, 80, 0.10);
}
.ops-mw-lifecycle-arrow {
  color: var(--ops-ink-faint);
  font-size: 11px;
}

/* ── Distance to Buy — restrained proximity bar (Module 4) ───────────────── */
/* Phase 5.1B-r4 item 20: table-layout: fixed with explicit per-column
   widths -- auto-layout let a wide combination of live content (a longer
   Distance-to-Buy percentage, a MANUAL/STALE/LAST pill, etc.) push the
   table wider than its .table-responsive wrapper, which (being a plain
   block ancestor chain up to .ncr-main/.ncr-shell) then bled into a rare
   page-level horizontal scrollbar. Fixed layout caps the table at 100%
   of its wrapper regardless of content -- any remaining overflow is
   contained by .table-responsive's own overflow-x: auto (an in-table
   scrollbar), never the whole page. Column percentages sum to 100 (the
   toggle column's ~3% covers its 22px in practice at this table's
   typical rendered width). */
.ops-mw-table {
  table-layout: fixed;
  width: 100%;
}
.ops-mw-table th:nth-child(1), .ops-mw-table td:nth-child(1) { width: 3%; }
.ops-mw-table th:nth-child(2), .ops-mw-table td:nth-child(2) { width: 16%; }
.ops-mw-table th:nth-child(3), .ops-mw-table td:nth-child(3) { width: 10%; }
.ops-mw-table th:nth-child(4), .ops-mw-table td:nth-child(4) { width: 8%; }
.ops-mw-table th:nth-child(5), .ops-mw-table td:nth-child(5) { width: 8%; }
.ops-mw-table th:nth-child(6), .ops-mw-table td:nth-child(6) { width: 28%; }
.ops-mw-table th:nth-child(7), .ops-mw-table td:nth-child(7) { width: 8%; }
.ops-mw-table th:nth-child(8), .ops-mw-table td:nth-child(8) { width: 8%; }
.ops-mw-table th:nth-child(9), .ops-mw-table td:nth-child(9) { width: 11%; }
.ops-mw-table td { overflow: hidden; text-overflow: ellipsis; }
.ops-distance-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ops-distance-bar {
  display: block;
  width: 64px;
  height: 4px;
  border-radius: 2px;
  background: var(--ops-line);
  overflow: hidden;
}
.ops-distance-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

/* Edit Levels — MANUAL-row detail-panel-only editing, never in the main
   row (keeps automatic and manual row heights identical). */
.ops-edit-levels-form {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--ops-line-strong);
}
.manual-level-error {
  align-self: center;
}

/* Remove from Market Watch — inline confirm, never the admin-token modal. */
.ops-remove-confirm {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--ops-line-strong);
}
.ops-remove-error {
  margin-left: 6px;
}

/* Removed Today — collapsed by default, kept out of the active table. */
.ops-removed-today {
  border-top: 1px solid var(--ops-line);
  padding: 8px 14px;
}

/* ── Capital — compact single-row account bar, replacing the six-card grid */
.ops-capital-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 22px;
  padding: 10px 14px;
}
.ops-capital-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.ops-capital-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ops-ink-faint);
}
.ops-capital-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--ops-ink);
}
.ops-info-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--ops-ink-faint);
  cursor: pointer;
  font-size: 13px;
  padding: 2px;
}
.ops-info-btn:hover { color: var(--ops-accent); }
.ops-capital-note {
  padding: 0 14px 10px;
  font-size: 10.5px;
  color: var(--ops-ink-faint);
}

/* ── Open Positions / Risk Desk (Module 5) — each position reads as a risk
   object: Symbol -> P&L -> Risk track -> Entry/LTP, not a flat table. ──── */
.ops-positions {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--ops-line);
}
.ops-position-card {
  background: var(--ops-surface);
  padding: 10px 14px;
  border-left: 3px solid var(--ok);
}
.ops-position-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.ops-position-symbol {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ops-ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ops-position-pnl {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ops-position-sub {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--ops-ink-soft);
  margin-top: 1px;
}
.ops-position-dot { color: var(--ops-ink-faint); }

/* Risk track — STOP ── ENTRY ── LTP ── TARGET, presentation-only, never
   read by anything: the track's own two ends ARE Stop/Target (0%/100%),
   Entry/LTP are markers positioned between (or clamped to an edge). */
.ops-risk-track {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 6px;
}
.ops-risk-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: 0 0 auto;
}
.ops-risk-label-stop { color: var(--protect); }
.ops-risk-label-target { color: var(--ok); }
.ops-risk-bar {
  position: relative;
  flex: 1 1 auto;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--protect), var(--ok));
  opacity: 0.35;
  min-width: 40px;
}
.ops-risk-marker {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--bg);
  background: currentColor;
  transition: left 0.2s ease;
}
.ops-risk-marker-entry {
  /* Phase 5.1B-r4 item 9: neutral/white, deliberately higher-contrast
     than --ops-ink-faint (too close to the gradient track's own tone to
     stay distinguishable from the cyan LTP/LAST marker when the two sit
     close together). */
  color: var(--ops-ink);
  z-index: 1;
}
.ops-risk-marker-ltp {
  color: var(--accent);
  width: 11px;
  height: 11px;
  z-index: 2;
}
@media (prefers-reduced-motion: reduce) {
  .ops-risk-marker { transition: none; }
}
.ops-position-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11.5px;
  color: var(--ops-ink-soft);
}

/* ── Manual Actions — visually secondary (smaller type, softer border) ──── */
.ops-card-secondary .ops-card-head { font-size: 11px; }
.ops-card-secondary .ops-card-body { padding: 8px 14px; font-size: 12.5px; }
.ops-manual-actions-sep {
  width: 1px;
  align-self: stretch;
  background: var(--ops-line);
  margin: 0 2px;
}

/* ── Compact empty state — a single muted line, never an empty table ────── */
.ops-empty-compact {
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--ops-ink-soft);
}

/* ── Responsive — no page-level horizontal overflow at any target width;
   tables scroll inside their own .table-responsive wrapper instead. ────── */
.table-responsive { overflow-x: auto; }
@media (max-width: 480px) {
  .ops-shell { padding-left: 8px !important; padding-right: 8px !important; }
  .ops-header-right { width: 100%; justify-content: space-between; }
  .ops-capital-bar { gap: 4px 14px; }
  .ops-scanner-pipeline { gap: 4px 2px; }
  .ops-scanner-value { font-size: 13px; }
  /* The longer "Equity Breakout Trading App" name gets a small margin of
     safety at narrow widths -- .ops-header-title already gets its own
     full-width row here (via .ops-header-right above), so this is purely
     a comfortable-fit adjustment, never required to avoid overflow. */
  .ops-header-name { font-size: 14px; }
  .ops-header-logo { width: 24px; height: 24px; }
}

/* ── Live Opportunities — compact card presentation at 390px (Module 4) ───
   Same DOM/JS (data-trade-id, data-field, .ops-mw-row, .ops-detail-row,
   the toggle button, Edit Levels/Remove) -- only the CSS display mode
   changes, so every existing interaction (row expansion, SSE field
   updates, Edit Levels, Remove, inactivity collapse) keeps working
   completely unchanged underneath a stacked-card look. Target/Stop are
   intentionally hidden at this width (tap/expand reveals the full
   detail panel, which is unaffected by any of this). No page-level
   horizontal overflow is introduced -- the table simply stops being a
   table visually. */
@media (max-width: 575.98px) {
  .ops-mw-table thead { display: none; }
  .ops-mw-table, .ops-mw-table tbody, .ops-mw-table tr, .ops-mw-table td {
    display: block;
    width: 100%;
  }
  .ops-mw-table tr.ops-mw-row {
    position: relative;
    padding: 8px 10px 8px 30px;
    border-bottom: 1px solid var(--ops-line);
  }
  .ops-mw-table tr.ops-mw-row .ops-mw-toggle-col {
    position: absolute;
    left: 0;
    top: 8px;
    width: auto;
  }
  .ops-mw-table tr.ops-mw-row td {
    padding: 1px 0 !important;
    text-align: left !important;
  }
  .ops-mw-table tr.ops-mw-row td.ops-col-target,
  .ops-mw-table tr.ops-mw-row td.ops-col-stop {
    display: none; /* hidden in the compact card -- still in the expanded detail panel below */
  }
  .ops-mw-table tr.ops-mw-row td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--ops-ink-faint);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
  .ops-mw-table tr.ops-mw-row td[data-label="Symbol"]::before,
  .ops-mw-table tr.ops-mw-row td[data-label="State"]::before {
    content: ""; /* symbol + state read naturally without a label prefix */
  }
  .ops-mw-table .ops-detail-cell { padding: 8px 10px !important; }
}
