/* v5 Phase 4 — component primitives.
 *
 * Reusable atoms / molecules used by render.js and the panel renderers.
 * Stage 2 ships the global-chrome subset; Stage 3+4 will extend with
 * activity-feed table and chart wrappers.
 */

/* Flash-on-change pulse — applied by `static/js/utils.js::setText` /
 * `setHTML` whenever a rendered cell's value actually changes.  Gives
 * a continuous visual heartbeat so the operator can confirm the
 * dashboard is live, even when the value-level delta is too small to
 * perceive at the displayed precision (e.g. BTC mid drifting by
 * sub-cents).
 *
 * Implementation: brief text-only glow.  An earlier version used a
 * background-color tint, but that painted the full bounding box of
 * each cell (every cell becomes a flashing rectangle that stretches
 * to the column / grid cell width).  We instead animate `text-shadow`
 * (a soft amber halo on the glyphs) plus a tiny `filter: brightness`
 * bump so the existing color semantics (`.up` green, `.down` red,
 * muted grey) stay intact — the glyphs themselves pop briefly without
 * any layout-affecting paint.  Replayed by removing+re-adding the
 * class after a forced reflow in JS. */
@keyframes just-changed-pulse {
  0%   { filter: brightness(1.55); }
  100% { filter: brightness(1);    }
}
.just-changed {
  animation: just-changed-pulse 220ms ease-out;
}

/* ── Brand text ─────────────────────────────────────────────────── */

.brand-hydrum { color: var(--tentative); font-weight: 700; letter-spacing: 0.03em; }
.brand-piece  { color: var(--white);     font-weight: 700; letter-spacing: 0.03em; }
.brand-pipe   { color: var(--tentative); font-weight: 700; padding: 0 2px; }
.brand-day    { color: var(--white);     font-weight: 600; margin-left: 6px; }

/* ── Price chip (asset price + %) ───────────────────────────────── */

.price-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 11px;
}
.price-chip .pc-asset  { color: var(--muted); font-weight: 600; }
.price-chip .pc-value  { color: var(--white); font-weight: 700; }
.price-chip .pc-pct    { font-size: 10px; }

/* ── Connection status pill ─────────────────────────────────────── */

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dim);
}
.conn-dot.ws   { background: var(--up); }
.conn-dot.rest { background: var(--down); }
.conn-dot.warn { background: var(--tentative); }

/* Heartbeat glow — fired by `static/js/ws.js` on every inbound WS
 * message (throttled to one pulse per 500ms in `pingHeartbeat`).
 * Gives the operator a continuous gentle "alive" signal anchored on
 * the connection dot, so they can confirm data is flowing without
 * having to spot a digit changing in some far-away cell.  Subtle:
 * 0.6s ease-out box-shadow expansion that decays to transparent. */
@keyframes conn-dot-heartbeat {
  0%   { box-shadow: 0 0 0 0   rgba(38, 166, 154, 0.65); }
  100% { box-shadow: 0 0 0 7px rgba(38, 166, 154, 0);    }
}
.conn-dot.heartbeat {
  animation: conn-dot-heartbeat 600ms ease-out;
}

/* ── UTC clock ──────────────────────────────────────────────────── */

.utc-clock {
  font-size: 11px;
  color: var(--muted);
  min-width: 80px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Tier bar bits ──────────────────────────────────────────────── */

.tier-hero {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tier-hero-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--tentative);
  text-transform: uppercase;
}
.tier-hero-row { display: flex; align-items: baseline; gap: 8px; }
.tier-hero-pct {
  font-size: 26px;
  font-weight: 800;
  color: var(--up);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.tier-hero-pct.below { color: var(--down); }

.tier-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.03em;
}
.tier-pill.qualified { background: var(--up);   color: #000; }
.tier-pill.below     { background: var(--down); color: #fff; }
.tier-pill.t2        { background: var(--up);   color: #000; }
.tier-pill.t3        { background: var(--tier-blue); color: #fff; }
.tier-pill.t4        { background: var(--tentative); color: #000; }

.tier-gauge-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tier-gauge-track {
  height: 12px;
  background: var(--bg);
  border: var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.tier-gauge-fill {
  height: 100%;
  background: var(--up);
  transition: width 0.3s ease;
}
.tier-gauge-fill.below { background: var(--down); }
.tier-gauge-markers {
  position: relative;
  height: 14px;
}
.tier-gauge-marker {
  position: absolute;
  top: 0;
  width: 1px;
  height: 4px;
  background: var(--tentative);
}
.tier-gauge-marker-label {
  position: absolute;
  top: 5px;
  font-size: var(--fs-xs);
  color: var(--muted);
  transform: translateX(-50%);
  white-space: nowrap;
}

.tier-tiles {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.tier-tile {
  text-align: center;
  padding: 4px 14px;
  border-left: var(--hairline);
}
.tier-tile:first-child { border-left: none; }
.tier-tile-label {
  display: block;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.tier-tile-value {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tier-tile.tile-week .tier-tile-value { color: var(--white); font-size: 14px; }

/* ── Tab navigation ─────────────────────────────────────────────── */

.tab {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--tentative);
  border-bottom-color: var(--tentative);
}

/* ── Inventory warning banner ───────────────────────────────────── */

.warn-banner {
  display: none;
  background: var(--warn-bg);
  color: #fff;
  padding: 6px 14px;
  border-bottom: 1px solid var(--warn-border);
  font-size: 11px;
  font-weight: 600;
}
.warn-banner.visible { display: block; }
.warn-banner::before { content: "⚠ "; color: var(--down); margin-right: 4px; }

/* ── Generic badges (for slug pills, side BUY/SELL, etc.) ───────── */

.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-quoting    { background: var(--up);        color: #000; }
.badge-paused     { background: var(--tentative); color: #000; }
.badge-halted     { background: var(--down);      color: #fff; }
.badge-disconnected,
.badge-unknown    { background: var(--dim);       color: var(--text); }
.badge-possible_halt { background: var(--down);   color: #fff; }
.badge-tentative  { background: var(--tentative); color: #000; }

/* ── Footer pieces ──────────────────────────────────────────────── */

.foot-cell { display: inline-flex; align-items: baseline; gap: 4px; }

/* ── Generic “waiting / placeholder” block in body sections ─────── */

.placeholder {
  padding: 24px 12px;
  text-align: center;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.05em;
}

/* ── Panel head (chart titles + subtitles) ──────────────────────── */

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: var(--hairline);
}
.panel-title {
  color: var(--tentative);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.panel-sub {
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ── Volume & Performance: BALANCE hero row ─────────────────────── */

.vp-balance-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 12px;
}
.vp-balance-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.vp-balance-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--tentative);
  font-variant-numeric: tabular-nums;
}
.vp-balance-meta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.vp-balance-today {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ── Period grid (TODAY / YESTERDAY / WEEK / EXPECTED) ──────────── */

.period-cell {
  text-align: center;
  padding: 8px 10px;
}
.period-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.period-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.period-sub {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── Sub-row stats grid (6 cells) ───────────────────────────────── */

.sub-cell {
  text-align: center;
  padding: 4px 6px;
}
.sub-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.sub-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── Performance toggle ─────────────────────────────────────────── */

.perf-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg);
  border-bottom: var(--hairline);
}
.perf-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-right: 4px;
}
.perf-toggle {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: var(--radius);
}
.perf-toggle:hover  { color: var(--text); border-color: var(--muted); }
.perf-toggle.active {
  color: var(--tentative);
  border-color: var(--tentative);
  background: var(--tentative-soft);
}
.perf-cell {
  text-align: center;
  padding: 4px 6px;
}

/* ── Chart toggle (PnL / Volume / Both on the right side) ──────── */

.chart-toggle-group { display: inline-flex; gap: 4px; }
.chart-toggle {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  cursor: pointer;
  border-radius: var(--radius);
}
.chart-toggle.active {
  color: var(--tentative);
  border-color: var(--tentative);
  background: var(--tentative-soft);
}

/* ── Chart wrappers (Chart.js needs a fixed-height container) ──── */

.chart-panel { padding: 8px 10px 12px; }
.chart-wrap  {
  position: relative;
  width: 100%;
  height: 220px;
}
.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── KV rows (used in Fill Analytics, Risk & Operations, PNL details) */

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 0;
  font-size: var(--fs-sm);
}
.kv-label { color: var(--muted); }
.kv-value {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.kv-section {
  margin-top: 6px;
  padding-top: 4px;
  border-top: var(--hairline);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.kv-row.total {
  border-top: var(--hairline);
  padding-top: 4px;
  margin-top: 4px;
  font-weight: 700;
}
.phase6-tt { font-size: 9px; cursor: help; }

/* ── Risk progress bars ─────────────────────────────────────────── */

.bar-track {
  height: 8px;
  background: var(--bg);
  border: var(--hairline);
  border-radius: var(--radius);
  margin: 2px 0 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--up);
  transition: width 0.3s ease;
}
.bar-fill.warn { background: var(--tentative); }
.bar-fill.crit { background: var(--down); }

/* ── PNL Details columns ────────────────────────────────────────── */

.pd-col { padding: 6px 12px; }
.pd-col-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--tentative);
  text-transform: uppercase;
  margin-bottom: 4px;
  border-bottom: var(--hairline);
  padding-bottom: 2px;
}

/* ── Activity feed table ────────────────────────────────────────── */

.activity-panel {
  max-height: 380px;
  overflow-y: auto;
  padding: 0;
}
.activity-load-more {
  padding: 6px 12px;
  text-align: center;
  font-size: var(--fs-sm);
}
.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.activity-table thead th {
  position: sticky;
  top: 0;
  background: var(--header);
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 8px;
  border-bottom: var(--hairline);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 1;
}
.activity-table tbody td {
  padding: 2px 8px;
  border-bottom: 1px solid var(--border-soft);
  font-variant-numeric: tabular-nums;
}
.activity-table tbody tr:hover { background: var(--highlight); }
.activity-table tbody tr.tentative {
  background: rgba(255, 149, 0, 0.06);
  border-left: 2px solid var(--tentative);
}
.activity-table tbody tr.tentative td:first-child::after {
  content: " (tentative)";
  color: var(--tentative);
  font-size: 9px;
}
.side-BUY  { color: var(--up); }
.side-SELL { color: var(--down); }

/* ── CSV download dropdown ──────────────────────────────────────── */

.csv-dd { position: relative; display: inline-block; }
.csv-trigger {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  cursor: pointer;
  border-radius: var(--radius);
}
.csv-trigger:hover { border-color: var(--muted); }
.csv-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  background: var(--panel);
  border: var(--hairline);
  border-radius: var(--radius);
  min-width: 120px;
  z-index: 30;
}
.csv-menu li {
  padding: 4px 10px;
  font-size: var(--fs-sm);
  cursor: pointer;
  color: var(--text);
}
.csv-menu li:hover { background: var(--highlight); color: var(--tentative); }
.csv-menu.hidden { display: none; }

/* ── Weekly history table ───────────────────────────────────────── */

.weekly-history {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.weekly-history th {
  text-align: right;
  color: var(--muted);
  font-weight: 600;
  padding: 3px 8px;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: var(--hairline);
}
.weekly-history th:first-child { text-align: left; }
.weekly-history td {
  text-align: right;
  padding: 3px 8px;
  border-bottom: 1px solid var(--border-soft);
  font-variant-numeric: tabular-nums;
}
.weekly-history td:first-child { text-align: left; }
.weekly-history tr.current td { background: rgba(255, 149, 0, 0.04); }
.weekly-history tfoot td {
  font-weight: 700;
  color: var(--white);
  border-top: var(--hairline);
  border-bottom: none;
}

/* Stage 3.6: scrollable weekly-history container, ~4 rows visible. */
.weekly-history-panel { padding: 0 12px 8px; }
.weekly-history-scroll {
  max-height: 156px;     /* ~4 data rows + sticky header at 12px line height */
  overflow-y: auto;
  padding: 0;
}
.weekly-history-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

/* REB row CUMUL muting (Stage 3.6 ergonomic fix).  The cumul column
 * shows the running strategy cumul which doesn't change for off-book
 * rebalance fills (F-001) — operators were misreading it as the
 * rebalance's PnL.  Mute it visually + tooltip explains.
 *
 * Stage 3.11: column 10 is Strategy Cumul (was 8 before the F-027
 * decomposition added Trading PnL + Strategy PnL columns).
 */
.activity-table tr[data-category="rebalance"] td:nth-child(10) {
  color: var(--dim);
  font-style: italic;
}

/* ── Activity feed: rich tag badges (Stage 3.5) ────────────── */

.activity-table td.tags-cell {
  white-space: nowrap;
  font-size: 9px;
  padding-right: 4px;
}
.tag {
  display: inline-block;
  padding: 1px 4px;
  margin-right: 2px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.03em;
  vertical-align: middle;
}
.tag-cat-strategy     { background: var(--cat-strategy);     color: #000; }
.tag-cat-intervention { background: var(--cat-intervention); color: #000; }
.tag-cat-rebalance    { background: var(--cat-rebalance);    color: #fff; }
.tag-tentative        { background: var(--tentative);        color: #000; }
.tag-tent-rebal       { background: transparent; color: var(--tentative);
                        border: 1px dashed var(--tentative); }
.tag-camp             { color: #fff; }   /* background applied inline by JS */
.tag-prefix           { color: #000; font-family: var(--font-mono); }
/* Background applied inline by activity.js per stable hash of the
 * 8-char prefix so each deployment gets a distinct colour.  Operators
 * can visually group consecutive fills by deployment without reading
 * the hex. */
.tag-coid             { background: var(--down); color: #fff; }   /* COID_UNRECOVERABLE */
.tag-coid-trunc       { background: var(--bg); color: var(--text);
                        border: 1px solid var(--border);
                        font-family: var(--font-mono); font-size: 9px; }
.tag-coid-trunc.empty { color: var(--muted); font-style: italic; }
.tag-coid-trunc.outlined {
  /* Inline style sets border colour to match the deployment hash;
   * this rule just locks down the layout. */
  background: transparent !important;
}

/* Maker / Taker tag (Stage 3.9). */
.tag-mt        { font-family: var(--font-mono); padding: 1px 4px; }
.tag-mt.tag-maker { background: var(--up);   color: #000; }
.tag-mt.tag-taker { background: var(--tier-blue); color: #fff; }

/* Stage 3.6: unified period bar (replaces three separate period
 * toggles: perf-bar, chart-period-bar, activity-period-group). */
.period-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--bg);
  border-bottom: var(--hairline);
}
.period-toggle {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: var(--radius);
}
.period-toggle:hover { color: var(--text); border-color: var(--muted); }
.period-toggle.active {
  color: var(--tentative);
  border-color: var(--tentative);
  background: var(--tentative-soft);
}
.period-toggle:disabled,
.period-toggle.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Stage 3.9: stick the period bar below the global header so it's
 * always reachable when scrolled into the activity feed.  Header
 * total height varies (warn banner toggles), so we expose a CSS
 * variable that app.js keeps in sync. */
.period-bar {
  position: sticky;
  top: var(--header-bottom, 0px);
  z-index: 15;
}

/* ── Chart period bar (Stage 3.5) ───────────────────────── */

.chart-period-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--bg);
  border-bottom: var(--hairline);
}
.chart-period-toggle {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  cursor: pointer;
  border-radius: var(--radius);
}
.chart-period-toggle.active {
  color: var(--tentative);
  border-color: var(--tentative);
  background: var(--tentative-soft);
}
.chart-view-toggle {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  cursor: pointer;
  border-radius: var(--radius);
}
.chart-view-toggle.active {
  color: var(--tentative);
  border-color: var(--tentative);
  background: var(--tentative-soft);
}

/* ── Campaign selector (Stage 3.5) ──────────────────────── */

.campaign-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.campaign-selector.hidden { display: none; }
.campaign-selector select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 4px;
  border-radius: var(--radius);
}
.campaign-selector .cs-config { color: var(--muted); margin-left: 6px; }

.perf-baseline-tag {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 0.03em;
}

/* ── Lifetime decomposition bar (F-001 + F-027) ────────────── */

.lifetime-decomp { padding: 10px 14px 12px; }
.ld-bar {
  display: flex;
  height: 18px;
  background: var(--bg);
  border: var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}
.ld-seg { height: 100%; transition: width 0.3s ease; min-width: 0; }
.ld-seg.ld-trading   { background: var(--accent-strategy); }
.ld-seg.ld-rebalance { background: var(--accent-rebalance); }
.ld-seg.ld-fees      { background: var(--down); }
.ld-seg.ld-holding   { background: var(--tier-blue); }
.ld-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 6px;
  font-size: var(--fs-sm);
}
.ld-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.ld-swatch {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 1px;
}
.ld-swatch.ld-trading   { background: var(--accent-strategy); }
.ld-swatch.ld-rebalance { background: var(--accent-rebalance); }
.ld-swatch.ld-fees      { background: var(--down); }
.ld-swatch.ld-holding   { background: var(--tier-blue); }

/* F-001 degenerate state: rebalance bar always shown but with diagonal
   stripes since the value is 0. */
.ld-seg.ld-rebalance.degenerate {
  background: repeating-linear-gradient(
    45deg, var(--accent-rebalance) 0 4px,
    var(--bg) 4px 8px);
}

/* ── Click-expand cards (BALANCE / CAPITAL / period delta) ──── */

.clickable {
  cursor: pointer;
  border-bottom: 1px dotted transparent;
}
.clickable:hover { border-bottom-color: var(--muted); }
.clickable .dd { color: var(--muted); margin-left: 2px; font-size: 11px; }

.vp-expand {
  background: #0f1520;
  border-bottom: var(--hairline);
  padding: 10px 16px;
}
.vp-expand.hidden { display: none; }
.vp-expand .ve-title {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--tentative);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 6px;
}
.vp-expand .ve-grid {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  column-gap: 14px;
  row-gap: 2px;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.vp-expand .ve-row-divider { grid-column: 1 / -1; border-top: var(--hairline); margin: 4px 0; }
.vp-expand .ve-close {
  float: right;
  background: transparent;
  color: var(--muted);
  border: none;
  cursor: pointer;
  font-size: 10px;
}
.vp-expand .ve-close:hover { color: var(--text); }

/* Delta items in the BALANCE row (Today / Week / Campaign / Deployment) */
.delta-item { display: inline-flex; align-items: baseline; gap: 4px; margin-right: 10px; }
.delta-item .delta-label { color: var(--muted); }
.delta-item .delta-value { font-weight: 700; cursor: pointer; }

/* ── Alert toasts (Phase 5 surfacing) ─────────────────────── */

.alerts-toasts {
  position: fixed;
  top: 120px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
  max-width: 380px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  border-left: 3px solid var(--muted);
  background: var(--panel);
  color: var(--text);
}
.toast.critical { border-left-color: var(--down);      background: rgba(239, 83, 80, 0.10); }
.toast.warning  { border-left-color: var(--tentative); background: rgba(255, 149, 0, 0.08); }
.toast.info     { border-left-color: var(--tier-blue); background: rgba(41, 98, 255, 0.06); }
.toast .toast-kind {
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 6px;
  color: var(--muted);
}
.toast .toast-close {
  float: right;
  cursor: pointer;
  color: var(--muted);
  margin-left: 8px;
}
.toast .toast-close:hover { color: var(--text); }

/* ── R6 fees_expected — strike-through fees row ────────────── */
.fees-not-expected { text-decoration: line-through; opacity: 0.6; }

/* ── Reclassification chart marker (R13) ────────────────── */
/* Marker dots are drawn via Chart.js scatter dataset; this class is on
   the legend item only. */
.reclass-legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--tentative);
  border: 1px solid var(--text);
  margin-right: 4px;
}

/* ── Stage 4: overview body ───────────────────────────── */

/* Empty / loading placeholder used by overview sections before data
   hydrates.  Centred + muted; sized to fit any panel. */
.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
  font-size: 12px;
  color: var(--muted);
}

/* Portfolio Performance row — inherits .grid-5 + .perf-cell from
   the per-slug page so colour treatment is consistent. */
.portfolio-perf .perf-cell .sub-value {
  font-size: 18px;
  font-weight: 600;
}

/* Volume Qualification — math line above a 5-cell grid. */
.volume-qual { padding: 10px 12px; }
.vq-math {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.vq-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.vq-grid .perf-cell { padding: 6px 8px; }
.vq-grid .sub-value { font-size: 15px; font-weight: 600; }

/* Stage 4.2 — v3-parity Speed Table + status dots + Live Quote
   panel.  The strategies card grid below is kept for back-compat
   but no longer rendered by overview-body.js. */
.speed-table-wrap {
  margin-top: 6px;
  overflow-x: auto;
}
.speed-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.speed-table thead th {
  text-align: left;
  padding: 6px 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: var(--hairline);
}
.speed-table tbody td,
.speed-table tfoot td {
  padding: 6px 8px;
  border-bottom: var(--hairline);
  vertical-align: top;
}
.speed-table tfoot td {
  font-weight: 700;
  border-top: 1px solid var(--text);
  border-bottom: none;
}
.speed-table .speed-sub {
  font-size: 9px;
  margin-top: 1px;
}
.speed-row:hover td { background: rgba(255, 255, 255, 0.02); }
.speed-strategy {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 180px;
}
.speed-strategy .speed-name {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.speed-strategy .speed-name:hover { text-decoration: underline; }
.speed-strategy .speed-sym  { font-size: 9px; }
.speed-strategy .speed-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 3px;
  margin-top: 2px;
}
.speed-inv-bar {
  position: relative;
  height: 6px;
  margin-top: 4px;
  background: var(--bg);
  border: var(--hairline);
  border-radius: 3px;
  overflow: visible;
}
.speed-inv-fill {
  display: block;
  height: 100%;
  background: var(--up);
  border-radius: 3px;
}
.speed-inv-fill.warn { background: var(--tentative); }
.speed-inv-fill.crit { background: var(--down); }
.speed-inv-pct {
  position: absolute;
  right: 0; top: -10px;
  font-size: 9px;
}

/* Status dot (Stage 4.2 quote-refresh freshness signal). */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  background: var(--muted);
  box-shadow: 0 0 4px transparent;
}
.status-dot.qfresh { background: var(--up);        box-shadow: 0 0 4px var(--up); }
.status-dot.qamber { background: var(--tentative); box-shadow: 0 0 4px var(--tentative); }
.status-dot.qstale { background: var(--down);      box-shadow: 0 0 4px var(--down); }
.badge-qfresh { color: var(--up); }
.badge-qamber { color: var(--tentative); }
.badge-qstale { color: var(--down); }

/* T1 / T2 qualification banner above the Volume Qualification math line. */
.vq-status {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
}
.vq-badge {
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.vq-badge.up    { color: var(--up);        }
.vq-badge.amber { color: var(--tentative); }
.vq-badge.down  { color: var(--down);      }

/* Per-slug Live Quote panel. */
.live-quote {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  font-variant-numeric: tabular-nums;
}
.live-quote .lq-cell {
  text-align: center;
  padding: 4px 6px;
}
.live-quote .lq-cell + .lq-cell { border-left: var(--hairline); }
.live-quote .lq-label {
  font-size: 9px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px;
}
.live-quote .lq-value {
  font-size: 13px; font-weight: 700; color: var(--text);
}
.live-quote .lq-sub { font-size: 9px; color: var(--muted); margin-top: 1px; }

/* Per-slug strategies grid (legacy, not currently rendered). */
.per-slug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.ps-card {
  display: block;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.12s;
}
.ps-card:hover { border-color: var(--text); }
.ps-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.ps-card-name { font-weight: 600; }
.ps-card-symbol { font-size: 11px; margin-bottom: 6px; }
.ps-card-row {
  display: flex; justify-content: space-between;
  font-size: 12px; padding: 2px 0;
}
.ps-card-badge {
  font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 3px;
  border: 1px solid var(--border);
}
.badge-up    { color: var(--up);        border-color: var(--up); }
.badge-amber { color: var(--tentative); border-color: var(--tentative); }
.badge-down  { color: var(--down);      border-color: var(--down); }
.badge-muted { color: var(--muted); }

/* Live Activity ticker. */
.activity-ticker { padding: 0; overflow-x: auto; }
.ticker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.ticker-table th, .ticker-table td {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.ticker-table th {
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.ticker-table tr:last-child td { border-bottom: none; }
.ticker-table a { color: var(--text); text-decoration: none; }
.ticker-table a:hover { text-decoration: underline; }

.overview-period-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
}

/* Live Tape v2 — opt-in via ?livetape=1.  Promoted to default fold on
 * Phase 3 when the rest of the workbook redesign lands.  Layout:
 *   panel-head           (title · status · [+ Position] · ↻ Resume live)
 *   livetape-staleness   (3 px ribbon — colour driven by sslq)
 *   livetape-header      (5-token operational status bar)
 *   livetape-canvas      (the actual chart)
 */
.livetape-panel {
  margin-bottom: 8px;
}
.livetape-canvas {
  height: 360px;
  width: 100%;
  position: relative;
}
.livetape-controls {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.livetape-resume {
  color: var(--text);
  text-decoration: none;
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.livetape-resume:hover { text-decoration: underline; }
.livetape-resume.hidden { display: none; }
.livetape-status { margin-left: 8px; font-size: 11px; }

/* Position-pane toggle. */
.livetape-toggle {
  font: inherit;
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.livetape-toggle:hover { color: var(--text); }
.livetape-toggle.active {
  background: rgba(72, 128, 194, 0.18);
  border-color: #4880c2;
  color: #4880c2;
}

/* Quote-staleness ribbon — sits flush against the top of the canvas. */
.livetape-staleness {
  height: 3px;
  width: 100%;
  border-radius: 2px;
  margin: 4px 0 6px 0;
  background: rgba(159, 170, 184, 0.15);
  transition: background-color 0.25s ease;
}
.livetape-staleness.state-ok    { background: #2e7d32; }
.livetape-staleness.state-warn  { background: #f0a030; }
.livetape-staleness.state-crit  { background: #ec6c6c; }
.livetape-staleness.state-muted { background: rgba(159, 170, 184, 0.15); }

/* Header strip — always-on operational status above the chart. */
.livetape-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 4px 2px;
  margin-bottom: 4px;
}
.livetape-header .lt-token-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 9px;
}
.livetape-header .lt-token-sep {
  color: rgba(159, 170, 184, 0.35);
  margin: 0 2px;
}
.livetape-header .lt-token {
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.livetape-header .lt-token.lt-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 6px;
}

/* Token health classes — used across the strip + ribbon. */
.livetape-header .lt-token.state-ok    { color: #6dd58a; border-color: rgba(109, 213, 138, 0.35); }
.livetape-header .lt-token.state-warn  { color: #f0a030; border-color: rgba(240, 160, 48, 0.45); }
.livetape-header .lt-token.state-crit  { color: #ec6c6c; border-color: rgba(236, 108, 108, 0.45); background: rgba(236, 108, 108, 0.08); }
.livetape-header .lt-token.state-muted { color: var(--muted); border-color: var(--border); }

/* Phase 4 — Strategy P&L row + alert bar styling. */
.strategy-pnl-row .sub-sub {
  font-size: 11px;
  margin-top: 2px;
}
.warn-banner.alert-critical {
  background: rgba(180, 30, 30, 0.18);
  border-left: 3px solid #ec6c6c;
  color: #ec6c6c;
  padding: 6px 10px;
  font-size: 12px;
}
.warn-banner.alert-warning {
  background: rgba(180, 130, 30, 0.16);
  border-left: 3px solid #f0a030;
  color: #f0a030;
  padding: 6px 10px;
  font-size: 12px;
}
.dow-history-panel { padding: 8px 10px; }
.dow-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 6px;
}
.dow-cell {
  background: var(--panel, #131820);
  border: 1px solid var(--border, #1f2632);
  border-radius: 4px;
  padding: 6px 8px;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.dow-cell.today  { border-color: #4880c2; box-shadow: 0 0 0 1px rgba(72,128,194,0.35) inset; }
.dow-cell.future { opacity: 0.4; }
.dow-label { font-size: 10px; color: #8a93a0; text-transform: uppercase; letter-spacing: 0.5px; }
.dow-vol   { font-size: 13px; }
.dow-pnl   { font-size: 12px; }
.dow-share { font-size: 10px; }
