/* VORTEXTICK — Post-LogZone environment.
   Solid black backdrop, neon purple focal targets, high-contrast white data. */
:root {
  --bg: #000000;
  --panel: #0a0a0f;
  --line: #27272a; /* zinc-800 — explicit dark-gray border grid, not near-invisible */
  --border-hc: #a1a1aa; /* zinc-400 — the high-contrast border every interactive input/select must use */
  --neon: #a855f7; /* purple-600-equivalent focal accent */
  --neon-soft: #c084fc;
  --neon-dim: rgba(168, 85, 247, 0.16);
  --neon-glow: 0 0 10px rgba(147, 51, 234, 0.3);
  --neon-active: #9333ea; /* Phase 18's literal purple-600 hex — the heat map's active-selection border */
  --silver: #e4e4e7; /* Phase 23 radiant silver (zinc-200) — divergence breakout accent */
  --white: #ffffff;
  --dim: #ffffff; /* no muted gray anywhere: secondary text is solid white, distinguished by weight/size */
  --profit: #10b981;
  --loss: #ef4444;
  --profit-deep: #047857; /* emerald-700 — a solid win-cell BACKGROUND reads "deep," unlike the lighter --profit used for text elsewhere */
  --loss-deep: #991b1b; /* red-800 — "clean dark ruby" background, same reasoning */
  --warn: #f59e0b;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: manipulation;
}

/* ── header ── */
#topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 1px; font-size: 14px; }
.brand em { color: var(--white); font-style: normal; }
.statuses { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  font-size: 10px; letter-spacing: 0.6px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 3px; padding: 4px 8px; background: var(--panel);
}
.chip b { color: var(--white); }
.chip.btn { position: relative; color: var(--white); border-color: var(--white); cursor: pointer; font-family: var(--mono); }
.chip.btn::before { content: ""; position: absolute; inset: -11px; } /* 44px min tap target without disturbing the status-bar row */
#chip-risk.nominal b { color: var(--profit); }
#chip-risk.lockout b, #chip-risk.toxic b { color: var(--loss); animation: blink 1s infinite; }
#chip-risk.cooldown b, #chip-risk.buffer b { color: var(--warn); }
@keyframes blink { 50% { opacity: 0.35; } }
/* Fixed min-width sized to the longest possible content ("TOXIC 9.9x")
   so a state flip never reflows the chip row — zero layout shift. */
#chip-spread { min-width: 140px; display: inline-block; }
#chip-spread b { font-variant-numeric: tabular-nums; }
#chip-spread.nominal b { color: var(--profit); }
#chip-spread.toxic b { color: var(--loss); animation: blink 1s infinite; }
/* Phase 23 divergence chip: fixed min-width so a Z/confidence flip never
   reflows the chip row (zero layout shift, same discipline as #chip-spread).
   Radiant silver on a |Z|>2 breakout; dim purple during a compression band. */
#chip-div { min-width: 128px; display: inline-block; }
#chip-div b { font-variant-numeric: tabular-nums; color: var(--white); }
#chip-div.breakout { border-color: var(--silver); box-shadow: 0 0 10px rgba(228,228,231,0.45); }
#chip-div.breakout b { color: var(--silver); animation: blink 1s infinite; }
#chip-div.compressed b { color: var(--neon-soft); }

/* Phase 29: multi-strategy brain consensus chip — green LONG / red SHORT. */
#chip-strat { min-width: 150px; display: inline-block; }
#chip-strat b { font-variant-numeric: tabular-nums; color: var(--white); }
#chip-strat.strat-long b { color: #22c55e; }
#chip-strat.strat-short b { color: var(--loss); }

/* Phase 32: strategy-modality toggles (activate / combine / toggle which of
   the breakout / scalping / mean-reversion strategies drive the consensus). */
.strat-toggles { display: inline-flex; gap: 3px; align-items: center; vertical-align: middle; }
.stgl {
  font: inherit; font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 6px; border: 1px solid #333; background: #0a0a0a; color: #666;
  border-radius: 3px; cursor: pointer; line-height: 1.2; transition: color .12s, border-color .12s, box-shadow .12s;
}
.stgl:hover { color: var(--white); border-color: #555; }
.stgl.on { color: var(--white); border-color: var(--neon-active, #7c4dff); box-shadow: inset 0 0 6px rgba(124, 77, 255, 0.45); }

/* ── Phase 20: network resiliency banner + stale badge ──
   Banner: high-visibility, flashing var(--neon-active) — the spec's
   literal #9333EA — visible ONLY while a reconnect attempt is actively
   in flight (set/cleared by app.js's scheduleWSReconnect/ws.onopen).
   Fixed height + opacity/visibility toggle, always in the DOM, so it
   never shifts the session clock HUD or header when it appears/clears. */
#ws-reconnect-banner {
  height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--white);
  background: var(--neon-active); opacity: 0; transition: opacity .2s, height .2s;
}
#ws-reconnect-banner.active { height: 30px; opacity: 1; animation: blink 1s infinite; }

/* Stale badge: white-on-ruby-red, distinct from #chip-latency's subtler
   "STALE Nms" text — only appears once the 3s hard stale threshold trips
   a reconnect. Always in the DOM at its final size (opacity/visibility
   toggle) so sibling topbar chips never reflow when it appears. */
.ws-stale-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.5px; padding: 4px 8px;
  border-radius: 3px; background: var(--loss); color: #fff;
  visibility: hidden; opacity: 0; transition: opacity .2s;
}
.ws-stale-badge.active { visibility: visible; opacity: 1; animation: blink 1s infinite; }

/* ── global session clock HUD (apex of layout) ──
   Three market sessions (Tokyo/London/New York) with hours converted to
   the VIEWER's own browser-detected timezone via Intl.DateTimeFormat
   (web/session-clock.js) — deliberately distinct from #session-badges
   below, which shows each market's live/closed state as an overlay on
   the chart itself. */
#session-clock-hud {
  display: flex; gap: 16px; overflow-x: auto; padding: 8px 14px;
  border-bottom: 1px solid var(--neon); background: var(--panel);
  font-size: 11px; white-space: nowrap; scrollbar-width: none; align-items: center;
}
#session-clock-hud::-webkit-scrollbar { display: none; }
.sch-placeholder { color: var(--white); letter-spacing: 0.5px; }
.sch-tz-note { color: var(--white); font-size: 9px; letter-spacing: 0.5px; padding-right: 6px; border-right: 1px solid var(--line); }
.sch-item { display: flex; align-items: center; gap: 6px; color: var(--white); }
.sch-label { font-weight: 700; letter-spacing: 0.5px; }
.sch-hours { color: var(--white); font-variant-numeric: tabular-nums; }
.sch-closed {
  font-size: 9px; letter-spacing: 0.5px; color: var(--white); border: 1px solid var(--white);
  border-radius: 3px; padding: 2px 6px;
}
/* Radiant green active pulse — a small animated dot, not text, so it reads
   instantly at a glance during fast-paced conditions. */
.sch-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--profit);
  box-shadow: 0 0 6px var(--profit); animation: sch-pulse-anim 1.6s ease-in-out infinite;
}
@keyframes sch-pulse-anim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.3); }
}

/* ── Phase 24: one-click master hub ──
   A single high-contrast activation switch + a two-state status line.
   Green = active (protecting capital), red = paused. */
#master-hub {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 12px; border-top: 1px solid var(--line);
}
#master-switch {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: var(--mono); font-weight: 800; font-size: 12px; letter-spacing: 1px;
  padding: 9px 18px; border-radius: 9999px; color: #000;
  border: 1px solid transparent; transition: background-color .2s, box-shadow .2s;
}
.master-dot { width: 10px; height: 10px; border-radius: 50%; background: #000; }
#master-status { font-size: 12px; letter-spacing: 0.3px; color: var(--white); }
/* Paused (red): muted so it reads "off", but still high-contrast text. */
#master-hub.paused #master-switch { background: var(--loss); box-shadow: 0 0 0 1px var(--loss); }
#master-hub.paused .master-dot { background: #000; }
/* Activating (amber, pulsing): the sequential handshake in progress. */
#master-hub.activating #master-switch { background: var(--warn); }
#master-hub.activating .master-dot { animation: blink .8s infinite; }
/* Active (green, glowing): protecting capital + scanning. */
#master-hub.active #master-switch { background: var(--profit); box-shadow: 0 0 14px rgba(16,185,129,0.5); }
#master-hub.active .master-dot { background: #000; animation: sch-pulse-anim 1.6s ease-in-out infinite; }

/* ── Phase 24: analytics panel ── */
.stat-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 14px; }
.stat-big { border: 1px solid var(--border-hc); border-radius: 6px; padding: 14px 10px; text-align: center; }
.stat-big-val { font-size: 30px; font-weight: 800; color: var(--white); font-variant-numeric: tabular-nums; }
.stat-big-lbl { font-size: 9px; letter-spacing: 1px; color: var(--white); margin-top: 6px; }
.progress-track { height: 16px; border: 1px solid var(--border-hc); border-radius: 9999px; overflow: hidden; background: #000; }
.progress-fill { height: 100%; width: 0%; background: var(--profit); box-shadow: 0 0 10px rgba(16,185,129,0.5); transition: width .4s ease; }
.progress-caption { font-size: 11px; color: var(--white); margin-top: 8px; letter-spacing: 0.3px; }

/* ── Phase 25: account & billing hub ── */
.acct-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.acct-k { color: var(--white); letter-spacing: 0.4px; }
.acct-v { color: var(--neon-soft); font-weight: 700; text-align: right; }
.acct-caps { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.acct-badge { font-size: 9px; letter-spacing: 0.5px; padding: 4px 8px; border-radius: 3px; border: 1px solid var(--border-hc); color: var(--white); }
.acct-badge.on { border-color: var(--profit); color: var(--profit); }
.acct-badge.off { border-color: var(--line); color: var(--white); opacity: 1; }
.acct-note { font-size: 10px; color: var(--white); margin: 8px 0; line-height: 1.5; }
#acct-portal-btn { width: 100%; margin-top: 6px; }
/* Grace / Sim-Only status card — high-contrast, non-alarming. */
.grace-card { border-radius: 6px; padding: 12px 14px; font-size: 11px; line-height: 1.5; letter-spacing: 0.3px; margin-bottom: 12px; }
.grace-card.warn { border: 1px solid var(--warn); background: rgba(245,158,11,0.12); color: var(--warn); }
.grace-card.sim { border: 1px solid var(--border-hc); background: #000; color: var(--white); }

/* ── workspace ── */
#workspace { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#chartwrap { flex: 1; position: relative; min-height: 0; }
#chart { width: 100%; height: 100%; display: block; touch-action: none; }
#chart-toolbar {
  position: absolute; top: 8px; left: 8px; right: 8px; z-index: 3;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.tf-group { display: flex; gap: 2px; pointer-events: auto; }
.tf-group button, .tabrow button {
  background: var(--panel); color: var(--dim); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; padding: 4px 9px; cursor: pointer;
}
.tf-group button.on, .tabrow button.on { color: var(--white); border-color: var(--neon); background: var(--neon-dim); box-shadow: var(--neon-glow); }
#symbol-label { color: var(--white); font-weight: 700; font-size: 12px; }
#price-label { color: var(--white); font-size: 12px; }
#session-badges { position: absolute; bottom: 8px; left: 8px; z-index: 3; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 9px; letter-spacing: 0.5px; padding: 3px 7px;
  background: var(--neon-dim); border: 1px solid var(--neon); color: var(--white); border-radius: 2px;
}

/* ── AI companion rail ── */
#companion {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--line); padding: 8px 12px; font-size: 11px; color: var(--white);
}
button.neon {
  background: var(--neon); color: var(--white); border: 0; font-family: var(--mono);
  font-weight: 700; font-size: 11px; letter-spacing: 0.5px; padding: 9px 14px;
  cursor: pointer; border-radius: 3px; white-space: nowrap;
}
button.neon:active { transform: scale(0.97); }

/* ── dock ── */
#dock { display: flex; border-top: 1px solid var(--line); }
#dock button {
  flex: 1; min-height: 44px; background: var(--bg); color: var(--dim); border: 0; border-right: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px; padding: 15px 0; cursor: pointer;
}
#dock button:last-child { border-right: 0; }
#dock button.on { color: var(--neon); background: var(--neon-dim); }
/* Fixed width regardless of content (e.g. "8ms" vs "142ms") so live updates
   never reflow the button row beside it — the zero-layout-shift guarantee. */
#dock-latency {
  flex: 0 0 56px; min-height: 44px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; border-left: 1px solid var(--line);
}
#dock-latency-val { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--white); font-variant-numeric: tabular-nums; }
.dock-latency-label { font-size: 7px; letter-spacing: 1px; color: var(--dim); }

/* ── panels ── */
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 61; }
.panel {
  position: fixed; z-index: 62; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, 94vw); max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--neon); border-radius: 6px;
  box-shadow: var(--neon-glow); padding: 18px; display: none;
}
.panel.open { display: block; }
.panel h2 { font-size: 13px; letter-spacing: 2px; color: var(--neon); margin-bottom: 14px; }
.panel h3 { font-size: 11px; letter-spacing: 1px; color: var(--dim); margin: 16px 0 8px; }
.panel label { display: flex; flex-direction: column; gap: 4px; font-size: 9px; color: var(--dim); letter-spacing: 1px; margin: 8px 0; }
.panel input, .panel select {
  background: #000; border: 1px solid var(--border-hc); color: var(--white);
  font-family: var(--mono); font-size: 14px; padding: 9px; border-radius: 3px;
}
.panel input:focus, .panel select:focus { outline: none; border-color: var(--neon); box-shadow: var(--neon-glow); }
.panel button { margin-top: 8px; width: 100%; }
.panel button:not(.neon) {
  background: transparent; border: 1px solid var(--line); color: var(--dim);
  font-family: var(--mono); font-size: 10px; padding: 9px; cursor: pointer; border-radius: 3px;
}

/* ── Phase 17: Smart Calibration Guide ──
   Solid black background, brilliant white primary text, bright purple
   accents on computed values only (var(--neon-soft)) — matches the
   high-contrast law already established in Phase 15's --border-hc/
   --neon-glow variables, reused rather than duplicated. */
.cal-toggle-btn {
  display: block; width: auto; margin: 10px 0; background: transparent;
  border: 1px solid var(--neon); color: var(--white); font-family: var(--mono);
  font-size: 10px; letter-spacing: 1.5px; padding: 8px 14px; cursor: pointer; border-radius: 3px;
}
.cal-toggle-btn:hover, .cal-toggle-btn:focus-visible { background: var(--neon-dim); box-shadow: var(--neon-glow); outline: none; }
.calibrate-panel {
  background: #000; border: 1px solid var(--neon); border-radius: 6px;
  box-shadow: var(--neon-glow); padding: 14px; margin-bottom: 14px;
}
.calibrate-panel h4 { color: var(--white); font-size: 11px; letter-spacing: 1.5px; margin-bottom: 12px; }
.calibrate-panel label {
  display: flex; flex-direction: column; gap: 6px; font-size: 10px; color: var(--white);
  letter-spacing: 0.4px; margin: 0 0 10px;
}
.calibrate-panel input {
  background: #000; border: 1px solid var(--border-hc); color: var(--white);
  font-family: var(--mono); font-size: 16px; padding: 10px; border-radius: 3px;
}
.calibrate-panel input:focus { outline: none; border-color: var(--neon); box-shadow: var(--neon-glow); }
.cal-results { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 10px; }
.cal-row { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; font-size: 11px; gap: 10px; }
.cal-k { color: var(--white); letter-spacing: 0.4px; }
.cal-v { color: var(--neon-soft); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-note { font-size: 10px; color: var(--white); margin: 10px 0; line-height: 1.5; }
.calibrate-panel button.neon { margin-top: 4px; }
.calibrate-panel button.neon:disabled { opacity: 1; background: var(--line); color: var(--white); cursor: not-allowed; box-shadow: none; }
.glossary { font-size: 9px; color: var(--white); letter-spacing: 0.2px; line-height: 1.35; margin-top: 2px; }
/* ── AuthForge-style auth card: matches the AuthForge hosted widget look —
   proportional sans-serif, rounded card, no neon border, mixed-case copy. ── */
/* Phase 28: the auth screen is a full-viewport overlay, not the centered modal
   the base .panel provides — a strict 100dvh / overflow:hidden layout so the
   login/register/2FA steps never spawn a layout-breaking scrollbar. The card is
   flex-centered inside it; .authpanel.open (later + equal specificity) beats the
   base .panel.open display:block. */
.authpanel {
  position: fixed; inset: 0; left: 0; top: 0; transform: none;
  width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none;
  overflow: hidden;
  align-items: center; justify-content: center;
  background: var(--bg, #000); border: 0; border-radius: 0; box-shadow: none; padding: 0;
}
.authpanel.open { display: flex; }
.authpanel .authcard { width: min(440px, 92vw); }

/* Minimalist top-left "Back to Home" — hardware-accelerated (translate3d +
   will-change) so the hover nudge is composited, never a layout reflow. */
.auth-home {
  position: absolute; top: 20px; left: 20px; z-index: 2;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 9999px;
  border: 1px solid var(--border-hc, rgba(255,255,255,0.18));
  background: rgba(255,255,255,0.04); color: var(--white);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  text-decoration: none; cursor: pointer;
  transform: translate3d(0,0,0); will-change: transform;
  transition: transform .2s cubic-bezier(.2,.7,.2,1), background-color .2s ease, border-color .2s ease;
}
.auth-home:hover { transform: translate3d(-3px,0,0); background: rgba(255,255,255,0.09); border-color: var(--neon); }
.auth-home svg { width: 14px; height: 14px; }
.authcard {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--ac-card, #131316); border: 1px solid var(--ac-input-border, #3a3a42); border-radius: calc(var(--ac-radius, 12px) + 8px);
  padding: 38px 36px; color: var(--ac-fg, var(--white));
}
.authcard-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 6px; }
.authcard-logo { width: 44px; height: 44px; object-fit: contain; display: block; }
.authcard-logo[hidden] { display: none; }
.authcard-brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; color: var(--ac-fg, var(--white)); }
.authcard .authcard-title { color: var(--white); text-align: center; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 20px; text-transform: none; }
.authcard-hint { text-align: center; font-size: 13px; margin: -8px 0 18px; }
.authcard-divider { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 4px 0 20px; }
.authcard-divider::before, .authcard-divider::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,0.15); }
.authcard label {
  display: block; text-align: left; font-size: 13.5px; font-weight: 600; letter-spacing: 0;
  text-transform: none; color: var(--ac-label, var(--white)); margin: 16px 0 7px; font-family: inherit;
}
.authcard label[hidden] { display: none; }
.authcard input {
  width: 100%; background: var(--ac-input-bg, #0e0e11); border: 1px solid var(--ac-input-border, #3a3a42); border-radius: var(--ac-radius, 12px);
  padding: 12px 14px; font-size: 15px; color: var(--ac-input-text, var(--white)); font-family: inherit; margin-top: 0;
}
.authcard input:focus { outline: none; border-color: var(--neon); box-shadow: var(--neon-glow); }
.authcard .pwrow { position: relative; }
.authcard .pwrow input { padding-right: 42px; }
.authcard .pwrow button {
  position: absolute; right: -2px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--white); cursor: pointer; font-size: 16px; margin: 0;
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
}
/* Scoped as `.authcard button.authcard-submit` (specificity 0,2,1) so it wins
   over the generic `.panel button:not(.neon)` reset (also 0,2,1) by source
   order — the card lives inside a .panel, whose button reset would otherwise
   flatten this into a tiny transparent mono button. */
.authcard button.authcard-submit {
  width: 100%; margin-top: 24px; background: var(--ac-btn, var(--neon)); color: var(--ac-btn-text, var(--white)); border: 1px solid var(--ac-btn, var(--neon));
  border-radius: var(--ac-radius, 12px); padding: 13px 22px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: filter .15s, opacity .15s;
}
.authcard button.authcard-submit:hover { filter: brightness(1.08); }
.authcard-links { text-align: center; margin-top: 4px; font-size: 14px; }
.authcard-links a { color: var(--white); text-decoration: underline; font-weight: 600; display: inline-block; padding: 14px 4px; min-height: 44px; }
.authcard-links p { margin-top: 4px; color: var(--white); }
.authcard .msg { text-align: center; }
.authcard-badge {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 28px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 12.5px; color: rgba(255,255,255,0.7);
}
.authcard-badge b { font-weight: 700; color: var(--ac-fg, var(--white)); }
.authcard-shield { flex-shrink: 0; color: var(--ac-fg, var(--white)); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.tabrow { display: flex; gap: 4px; margin-bottom: 10px; }
.msg { font-size: 11px; margin-top: 10px; color: var(--warn); min-height: 14px; }
.msg.ok { color: var(--profit); }
.dev { color: var(--profit); }
.dim { color: var(--dim); font-size: 10px; }
code { display: block; background: #000; border: 1px dashed var(--neon); color: var(--neon-soft); padding: 10px; margin: 8px 0; font-size: 13px; word-break: break-all; }
.step { display: none; }
.step.on { display: block; }
output { color: var(--white); font-size: 14px; padding: 9px 0; }

/* ── risk cards ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.card { border: 1px solid var(--line); border-radius: 4px; padding: 10px; }
.card .k { font-size: 8px; letter-spacing: 1px; color: var(--dim); }
.card .v { font-size: 16px; margin-top: 4px; }
.card.bad .v { color: var(--loss); }
.card.good .v { color: var(--profit); }

/* ── performance calendar ── */
/* Fixed height regardless of active state — visibility/opacity toggle only,
   never display:none, so the calendar below never shifts when a tilt
   advisory appears or clears. */
.tilt-banner {
  height: 34px; margin-bottom: 8px; border-radius: 3px; border: 1px solid var(--warn);
  background: rgba(245,158,11,0.12); color: var(--warn); font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px; display: flex; align-items: center; justify-content: center;
  visibility: hidden; opacity: 0; transition: opacity .2s;
}
.tilt-banner.active { visibility: visible; opacity: 1; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.stat {
  border: 1px solid var(--line); border-radius: 3px; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.stat-val { font-size: 13px; font-weight: 700; color: var(--white); }
.stat-label { font-size: 7px; letter-spacing: 0.5px; color: var(--dim); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head button { width: auto !important; padding: 4px 12px !important; margin: 0 !important; }
.cal-head span { font-size: 12px; letter-spacing: 2px; color: var(--white); }
#calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 8px; }
.dow { font-size: 8px; color: var(--dim); text-align: center; padding: 2px 0; }
.day {
  aspect-ratio: 1; border: 1px solid var(--line); border-radius: 3px;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 4px; font-size: 8px; color: var(--dim); overflow: hidden;
}
.day .pnl { font-size: 9px; font-weight: 700; color: var(--white); }
.day.profit { background: var(--profit); border-color: var(--profit); color: rgba(255,255,255,0.85); }
.day.loss { background: var(--loss); border-color: var(--loss); color: rgba(255,255,255,0.85); }
.day.empty { border: 0; }
#analytics { display: flex; gap: 3px; align-items: flex-end; height: 70px; margin: 8px 0; }
.bar { flex: 1; background: var(--neon-dim); border-top: 2px solid var(--neon); position: relative; min-height: 2px; }
.bar.neg { border-top-color: var(--loss); }
.bar span { position: absolute; top: -14px; left: 0; right: 0; text-align: center; font-size: 7px; color: var(--dim); }
#guidance { list-style: none; }
#guidance li { font-size: 11px; padding: 8px; border: 1px solid var(--line); border-radius: 3px; margin: 6px 0; color: var(--neon-soft); }

/* ── news ── */
#news-buffer-banner {
  background: var(--loss); color: #fff; font-size: 11px; padding: 9px; border-radius: 3px; margin-bottom: 10px;
}
.news-ev { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 9px 2px; font-size: 11px; }
.news-ev .imp-high { color: var(--loss); }
.news-ev .imp-medium { color: var(--warn); }
.news-ev time { color: var(--dim); font-size: 9px; margin-left: auto; white-space: nowrap; }

/* ── Phase 18: P&L heat map matrix ──
   Block-based grid, one cell per settled trade. High-contrast law:
   solid black backdrop for flat cells, pure white bold typography on
   every color-coded block (win/loss backgrounds are deliberately DEEP
   shades specifically so white text stays legible — see --profit-deep/
   --loss-deep), soft neon purple (--neon-active, the spec's literal
   #9333EA) marking the active/hovered selection. */
.heatmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; margin: 8px 0 4px; }
.hm-cell {
  position: relative; aspect-ratio: 1; border-radius: 3px; display: flex;
  align-items: center; justify-content: center; padding: 2px;
  font-family: var(--mono); font-size: 9px; font-weight: 700; color: var(--white);
  background: #000; border: 1px solid var(--border-hc); /* flat/breakeven default: solid black + zinc-400 border */
  cursor: pointer; text-align: center; line-height: 1.1; overflow: hidden;
}
.hm-cell.win { background: var(--profit-deep); border-color: var(--profit-deep); }
.hm-cell.loss { background: var(--loss-deep); border-color: var(--loss-deep); }
.hm-cell:hover, .hm-cell:focus-visible, .hm-cell.active {
  border-color: var(--neon-active); box-shadow: 0 0 0 2px var(--neon-active); outline: none; z-index: 2;
}
.hm-tooltip {
  position: fixed; z-index: 70; background: #000; border: 1px solid var(--neon-active);
  box-shadow: var(--neon-glow); border-radius: 4px; padding: 10px 12px;
  font-size: 10px; color: var(--white); line-height: 1.6; pointer-events: none;
  white-space: nowrap;
}
.hm-tooltip b { color: var(--white); letter-spacing: 0.5px; }
.hm-tooltip .hm-tt-row { display: flex; justify-content: space-between; gap: 14px; }
.hm-tooltip .hm-tt-k { color: var(--white); }
.hm-tooltip .hm-tt-v { color: var(--neon-soft); font-weight: 700; }

/* ── trades & admin tables ── */
.trade { border-bottom: 1px solid var(--line); padding: 8px 2px; font-size: 11px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.trade .pnl.pos { color: var(--profit); } .trade .pnl.neg { color: var(--loss); } .trade .pnl.warn { color: var(--warn); }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 9px; }
th { text-align: left; color: var(--dim); letter-spacing: 1px; padding: 6px 8px; border-bottom: 1px solid var(--neon); }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.sev-critical { color: var(--loss); } td.sev-warn { color: var(--warn); }

@media (max-width: 620px) {
  .hide-sm { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  #companion { flex-direction: column; align-items: stretch; text-align: center; }
}

/* Live Sim/Live routing toggle (SYSTEM_ADMIN) — the MODE cell control.
   Scoped under #acct-mode so these win over the generic `.panel button` reset. */
#acct-mode .routing-toggle {
  cursor: pointer; font: inherit; font-weight: 700; font-size: 11px; letter-spacing: 0.3px;
  padding: 4px 10px; border-radius: 4px; border: 1px solid var(--line); background: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#acct-mode .routing-toggle.live { color: var(--profit); border-color: var(--profit); background: rgba(34,197,94,0.10); }
#acct-mode .routing-toggle.sim  { color: var(--warn);   border-color: var(--warn);   background: rgba(245,158,11,0.12); }
#acct-mode .routing-toggle:hover { filter: brightness(1.15); }
#acct-mode .sandbox-status { display: block; margin-top: 5px; font-size: 10px; }
/* Breach states: flashing red halt (loss limit) / gold lock (target win). */
#acct-mode .sandbox-status.halt { color: var(--loss); font-weight: 700; animation: vt-halt-blink 1s steps(2, start) infinite; }
#acct-mode .sandbox-status.target-locked { color: #f2c14e; font-weight: 700; }
@keyframes vt-halt-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Toast notifications ── */
.vt-toasts { position: fixed; top: 14px; right: 14px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 28px)); pointer-events: none; }
.vt-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line); border-left-width: 3px; background: var(--card, #14141a); color: var(--fg, #e8e8ea); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-size: 12px; line-height: 1.4; animation: vt-toast-in 0.22s cubic-bezier(.2, .8, .2, 1); }
.vt-toast.leaving { animation: vt-toast-out 0.28s ease forwards; }
.vt-toast.success { border-left-color: var(--profit); }
.vt-toast.error { border-left-color: var(--loss); }
.vt-toast.warning { border-left-color: var(--warn); }
.vt-toast.info { border-left-color: #3b82f6; }
.vt-toast-ic { flex: 0 0 auto; font-weight: 800; font-size: 13px; margin-top: 1px; }
.vt-toast.success .vt-toast-ic { color: var(--profit); }
.vt-toast.error .vt-toast-ic { color: var(--loss); }
.vt-toast.warning .vt-toast-ic { color: var(--warn); }
.vt-toast.info .vt-toast-ic { color: #3b82f6; }
.vt-toast-msg { flex: 1 1 auto; word-break: break-word; }
.vt-toast-x { flex: 0 0 auto; background: none; border: none; color: var(--dim, #9a9aa2); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
.vt-toast-x:hover { color: var(--fg, #fff); }
@keyframes vt-toast-in { from { opacity: 0; transform: translateX(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes vt-toast-out { to { opacity: 0; transform: translateX(16px) scale(.98); } }
@media (max-width: 620px) { .vt-toasts { top: auto; bottom: 14px; left: 14px; right: 14px; max-width: none; } }
@media (prefers-reduced-motion: reduce) { .vt-toast, .vt-toast.leaving { animation: none; } }
