/* ═══════════════════════════════════════════════════════════════════════
   Lumin Season 2 — Bloomberg-style terminal (institutional vitrine)
   Ported from C:\dev\Lumin\website\terminal\index.html.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  --black: #000000;
  --bg: #0a0a0a;
  --bg-panel: #0d0d0d;
  --bg-card: #111111;
  --amber: #FF9933;
  --amber-dim: #CC7A29;
  --amber-bright: #FFB347;
  --amber-glow: rgba(255,153,51,0.08);
  --bb-blue: #4488FF;
  --bb-blue-dim: #3366CC;
  --bb-blue-glow: rgba(68,136,255,0.1);
  --green: #00CC66;
  --green-dim: #00AA55;
  --red: #FF4444;
  --red-dim: #CC3333;
  --white: #F0F0F0;
  --grey: #555555;
  --grey-light: #888888;
  --grey-dark: #1a1a1a;
  --border: #222222;
  --border-light: #2a2a2a;
  --mono: 'JetBrains Mono', 'Consolas', 'SF Mono', 'Fira Code', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--mono);
  background: var(--black);
  color: var(--amber);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--bb-blue); text-decoration: none; }
a:hover { color: var(--amber); }

/* ── Top bar ───────────────────────────────────────────────────────── */
.top-bar {
  background: linear-gradient(180deg, #1a2a4a 0%, #0d1a33 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 40px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--bb-blue-dim);
}

.top-bar .brand { display: flex; align-items: center; gap: 14px; }
.top-bar .brand .logo-link {
  text-decoration: none;
  display: inline-block;
  transition: color 0.15s ease;
}
.top-bar .brand .logo-link:hover .logo,
.top-bar .brand .logo-link:focus-visible .logo {
  color: var(--amber-bright);
  text-shadow: 0 0 4px rgba(255,179,71,0.4);
}
.top-bar .brand .logo {
  color: var(--amber);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}
.top-bar .brand .subtitle {
  color: var(--grey-light);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.8px;
}

.top-bar .right-info {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 12px;
  font-weight: 400;
}
.top-bar .right-info .label { color: var(--grey-light); }
.top-bar .right-info .value { color: var(--amber-bright); font-weight: 700; }
.top-bar .right-info .value.up { color: var(--green); }
.top-bar .right-info .value.dn { color: var(--red); }
.top-bar .right-info .value.wht { color: var(--white); }

/* ── Nav bar (tabs + strategy toggle) ─────────────────────────────── */
.nav-bar {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  height: 36px;
  padding: 0 12px;
}
.nav-tabs { display: flex; gap: 2px; }
.nav-btn {
  padding: 7px 22px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--grey-light);
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.5px;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.nav-btn:hover { color: var(--amber); background: rgba(255,153,51,0.05); }
/* Active tab — amber-bright text + light tint + 3px amber underline.
   Subtle but distinct from hover (hover is amber, active is amber-bright
   + thick underline). Distinguishes the tab navigation from the strategy
   toggle which uses solid amber for its active state. Reserve transparent
   3px border-bottom on every nav-btn so toggling .active never shifts text. */
.nav-btn {
  border-bottom: 3px solid transparent;
  box-sizing: border-box;
}
.nav-btn.active {
  color: var(--amber-bright);
  background: rgba(255,153,51,0.10);
  border-bottom-color: var(--amber);
  font-weight: 700;
}
.nav-btn .key {
  color: var(--bb-blue);
  font-size: 10px;
  margin-right: 4px;
}

/* ── Strategy toggle (vitrine names: RETURNS / DRAWDOWN) ─────────────
   STRATEGY label sits OUTSIDE the visual frame so the framed+amber
   RETURNS/DRAWDOWN buttons read clearly as the toggle (vs the label
   being framed which made everything look like one tri-state widget). */
.strategy-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  /* No border, no background — just a flex container for label + button-frame */
}
.strategy-toggle .strat-label {
  font-size: 10px;
  color: var(--grey-light);
  letter-spacing: 1px;
  text-transform: uppercase;
  background: transparent;
  border: none;
  padding: 0;
}
/* Framed sub-container around the actual toggle buttons */
.strat-buttons {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-card);
}
.strat-btn {
  padding: 6px 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--grey-light);
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.6px;
  transition: all 0.15s ease;
  border-right: 1px solid var(--border-light);
}
.strat-btn:last-child { border-right: none; }
.strat-btn:hover { color: var(--amber); background: rgba(255,153,51,0.05); }
.strat-btn.active {
  color: var(--black);
  background: var(--amber);
}

.strat-tagline {
  font-size: 10px;
  color: var(--grey-light);
  font-style: italic;
  margin-left: 12px;
  letter-spacing: 0.3px;
}

/* ── Page container ────────────────────────────────────────────────── */
.page {
  padding: 10px 14px;
  min-height: calc(100vh - 100px);
}

/* ── Panel ─────────────────────────────────────────────────────────── */
.panel {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
  background: var(--bg-card);
}
.panel-hdr {
  background: linear-gradient(180deg, #1a1a1a 0%, #111111 100%);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.5px;
}
.panel-hdr .tag {
  font-size: 10px;
  color: var(--amber);
  background: rgba(255,153,51,0.1);
  padding: 2px 10px;
  border: 1px solid var(--amber-dim);
  border-radius: 3px;
  font-weight: 500;
}
.panel-hdr .tag.up { color: var(--green); border-color: var(--green-dim); background: rgba(0,204,102,0.1); }
.panel-hdr .tag.dn { color: var(--red); border-color: var(--red-dim); background: rgba(255,68,68,0.1); }
.panel-body { padding: 0; background: var(--bg-card); }

/* ── Metric strip ──────────────────────────────────────────────────── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
}
.metrics-row.cols-5 { grid-template-columns: repeat(5, 1fr); }
.metrics-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.metric {
  padding: 12px 14px;
  border-right: 1px solid var(--border);
  text-align: center;
  min-width: 0;
}
.metric:last-child { border-right: none; }
.metric .lbl {
  font-size: 10px;
  color: var(--grey-light);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 500;
}
.metric .val {
  font-size: 22px;
  font-weight: 700;
  color: var(--amber-bright);
  margin: 6px 0 2px;
  white-space: nowrap;
}
.metric .val.up { color: var(--green); }
.metric .val.dn { color: var(--red); }
.metric .val.wht { color: var(--white); }
.metric .sub { font-size: 10px; color: var(--grey-light); font-weight: 500; }

/* ── Pair strip — 3 cells per the selected strategy ───────────────── */
.pair-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
.pair-cell {
  border-right: 1px solid var(--border);
  padding: 12px 14px;
  min-width: 0;
  text-decoration: none;
  display: block;
  color: inherit;
  transition: background 0.15s ease;
}
.pair-cell:hover { background: rgba(255,153,51,0.04); }
.pair-cell:last-child { border-right: none; }

.pair-cell .pair-id {
  font-size: 17px;
  font-weight: 700;
  color: var(--bb-blue);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 0.5px;
}
.pair-cell .pair-line {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
}
.pair-cell .pair-line .k { color: var(--grey-light); font-weight: 400; }
.pair-cell .pair-line .v { color: var(--amber); font-weight: 600; }
.pair-cell .pair-line .v.up { color: var(--green); }
.pair-cell .pair-line .v.dn { color: var(--red); }
.pair-cell .pair-line .v.wht { color: var(--white); }
.pair-cell .halt-badge {
  font-size: 9px;
  font-weight: 700;
  color: var(--white);
  background: var(--red);
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.3px;
}

/* ── Chart canvas — proportional scaling ───────────────────────────── */
.chart-canvas {
  width: 100%;
  background: var(--black);
  padding: 8px;
  overflow: hidden;
}
.chart-canvas svg { width: 100%; height: auto; display: block; }

/* Two charts side-by-side (equity + monthly returns) */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.chart-row .panel { margin-bottom: 0; }
@media (max-width: 1100px) {
  .chart-row { grid-template-columns: 1fr; }
}

/* ── Tables ────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  font-size: 10px;
  color: var(--grey-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--amber-dim);
  font-weight: 600;
  background: var(--bg-card);
}
th.r, td.r { text-align: right; }
th.c, td.c { text-align: center; }
tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #1a1a1a;
  color: var(--amber);
  font-weight: 400;
  vertical-align: top;
}
tbody tr:hover { background: rgba(255,153,51,0.03); }
tbody tr.expandable { cursor: pointer; }
tbody tr.expanded { background: rgba(68,136,255,0.05); }
td.sym { color: var(--white); font-weight: 600; }
td.long, span.long { color: var(--green); font-weight: 600; }
td.short, span.short { color: var(--red); font-weight: 600; }
td.up { color: var(--green); }
td.dn { color: var(--red); }
td.wht { color: var(--white); font-weight: 600; }
td.dim { color: var(--grey); }

/* Action badges — solid fills, matching bensalem.ai/terminal/ .st.* style:
   ENTER  = solid green (black text)   — open new position
   FLIP   = solid amber (black text)   — close + open opposite (single bar)
   FLIP↻  = solid amber-bright          — flip over hard stop
   STOP   = solid red (white text)     — hard stop breach
   SIDELINE = solid blue (white text)  — close-only / risk-off
   HOLD   = grey-dim, no fill          — no action
   REFUSED = solid grey-red             — Wrangler refusal
*/
.action-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  letter-spacing: 0.6px;
  border-radius: 3px;
  display: inline-block;
  text-transform: uppercase;
  white-space: nowrap;
}
.action-badge.enter { color: var(--black); background: var(--green); }
.action-badge.flip { color: var(--black); background: var(--amber); }
.action-badge.flip-over-stop { color: var(--black); background: var(--amber-bright); }
.action-badge.hard-stop { color: var(--white); background: var(--red); }
.action-badge.sideline { color: var(--white); background: var(--bb-blue); }
.action-badge.hold { color: var(--grey-light); background: rgba(136,136,136,0.10); border: 1px solid var(--grey); }
.action-badge.refused { color: var(--white); background: var(--red-dim); }

/* Status dots */
.status-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
}
.status-dot.committed { background: var(--green); }
.status-dot.refused { background: var(--red); }
.status-dot.not-reached { background: var(--grey); }

/* Live pulsing dot (active positions DIR indicator) */
.live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  vertical-align: middle;
  animation: live-pulse 2s infinite;
  box-shadow: 0 0 4px var(--green);
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--green); }
  50% { opacity: 0.45; box-shadow: 0 0 9px var(--green); }
}

/* ── Active positions panel ────────────────────────────────────────── */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}
.position-grid .position-cell {
  background: var(--bg-card);
  padding: 12px 16px;
  min-width: 0;
}
.position-grid .position-cell.empty {
  color: var(--grey);
  text-align: center;
  font-style: italic;
  padding: 24px;
  font-size: 13px;
}
.position-grid .pair-id {
  font-size: 18px;
  font-weight: 700;
  color: var(--bb-blue);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.position-grid .pair-id .side-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 1px;
}
.position-grid .pair-id .side-badge.long { color: var(--white); background: var(--green-dim); }
.position-grid .pair-id .side-badge.short { color: var(--white); background: var(--red-dim); }
.position-grid .line {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
}
.position-grid .line .k { color: var(--grey-light); }
.position-grid .line .v { color: var(--amber); font-weight: 600; }
.position-grid .line .v.up { color: var(--green); }
.position-grid .line .v.dn { color: var(--red); }
.position-grid .line .v.wht { color: var(--white); }

/* ── Cycles per-pair-column table ──────────────────────────────────── */
.cycles-table th.pair-col, .cycles-table td.pair-col {
  text-align: center;
  width: 18%;
}
.cycles-table th.pair-col {
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}
.cycles-table td.pair-col .action-badge { font-size: 10px; }

/* ── Universe pill in the top-bar (extreme right) ──────────────────── */
.universe-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-left: 1px solid var(--border-light);
  padding-left: 18px;
  margin-left: 4px;
}
.universe-pill .label {
  font-size: 10px;
  color: var(--grey-light);
  letter-spacing: 1px;
  font-weight: 500;
}
.universe-pill .value {
  color: var(--amber);
  font-weight: 700;
  letter-spacing: 1.5px;
  font-size: 12px;
}
/* Universe pill — each pair is a clickable link to pair.html with the
   account_id baked from the current strategy. */
.universe-pill a {
  color: var(--amber);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
}
.universe-pill a:hover {
  color: var(--amber-bright);
  text-shadow: 0 0 4px rgba(255,179,71,0.35);
}
.universe-pill a:visited { color: var(--amber); }

/* Symbol cells (Active Positions + Per-Pair Performance) — clickable
   drill-down to pair.html. The anchor inherits the cell's amber color
   so it does not pick up the generic bb-blue a {} rule. Hover: bright
   amber + underline for the affordance. */
td.sym a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
}
td.sym a:hover {
  color: var(--amber-bright);
  text-decoration: underline;
  text-decoration-color: var(--amber);
  text-underline-offset: 2px;
}
td.sym a:visited { color: inherit; }

/* ── Pair detail position card ─────────────────────────────────────── */
.position-card {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px 20px;
}
/* Pair title row — spans all columns. Shows the pair name in big amber
   so the reader always knows which pair they are viewing, plus a small
   strategy chip and a coloured side (LONG / SHORT) badge. */
.position-card .position-pair-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.position-card .position-pair-title .pair-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--amber-bright);
  letter-spacing: 1.2px;
}
.position-card .position-pair-title .pair-strat {
  font-size: 10.5px;
  color: var(--bb-blue);
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 3px 10px;
  border: 1px solid var(--bb-blue-dim);
  border-radius: 3px;
  text-transform: uppercase;
}
.position-card .position-pair-title .pair-side {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 3px 12px;
  border-radius: 3px;
  margin-left: auto;
}
.position-card .position-pair-title .pair-side.up { color: var(--white); background: var(--green-dim); }
.position-card .position-pair-title .pair-side.dn { color: var(--white); background: var(--red-dim); }

.position-card .field { display: flex; flex-direction: column; }
.position-card .field .lbl {
  font-size: 10px;
  color: var(--grey-light);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.position-card .field .val {
  font-size: 18px;
  font-weight: 700;
  color: var(--amber-bright);
  margin-top: 6px;
}
.position-card .field .val.up { color: var(--green); }
.position-card .field .val.dn { color: var(--red); }
.position-card .field .val.wht { color: var(--white); }
/* Sub-line under a value (e.g., "as of 2026-05-17" under Last Close). */
.position-card .field .sub {
  display: block;
  font-size: 10px;
  color: var(--grey-light);
  margin-top: 3px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.position-card .flat {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: var(--grey-light);
  font-size: 14px;
}

/* Trade history — open trade row gets a subtle green tint + LIVE marker
   so the in-flight position visibly stands apart from the closed track
   record. P&L cell on this row shows live MTM PnL (computed dynamically
   from mtm_position_pnl_pct), not the null pnl_pct_at_close. */
#signals-table tbody tr.trade-open {
  background: rgba(0,204,102,0.04);
}
#signals-table tbody tr.trade-open td.sym::after {
  content: "● LIVE";
  margin-left: 8px;
  font-size: 9px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.6px;
  vertical-align: middle;
}
#signals-table tbody tr.trade-open .sub {
  display: block;
  font-size: 9.5px;
  color: var(--grey-light);
  margin-top: 1px;
  font-weight: 500;
}

/* ── Footer ────────────────────────────────────────────────────────── */
.footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 6px 18px;
  font-size: 10px;
  color: var(--grey);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 28px;
}
.footer .last-loaded { color: var(--grey-light); }
/* Footer credit link — subtle by default (grey + dotted underline so the
   author attribution is unobtrusive in the read-only chrome) and amber on
   hover for the standard interactive affordance. Overrides the generic
   a {} bb-blue color. */
.footer .footer-credit {
  color: var(--grey-light);
  text-decoration: none;
  border-bottom: 1px dotted var(--grey);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.footer .footer-credit:hover,
.footer .footer-credit:focus-visible {
  color: var(--amber);
  border-bottom-color: var(--amber);
}
.footer .footer-credit:visited { color: var(--grey-light); }

/* ── Loading / error ───────────────────────────────────────────────── */
.loading { padding: 24px; text-align: center; color: var(--grey-light); font-size: 13px; }
.error {
  padding: 14px;
  margin: 10px 0;
  border: 1px solid var(--red-dim);
  background: rgba(255,68,68,0.08);
  color: var(--red);
  font-size: 12px;
  border-radius: 4px;
}

/* ── Cycle expanded detail row ─────────────────────────────────────── */
.cycle-detail {
  padding: 10px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}
.cycle-detail .detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}
.cycle-detail .detail-cell {
  background: var(--bg-card);
  padding: 10px 12px;
}
.cycle-detail .detail-cell .pair-id {
  font-weight: 700;
  color: var(--bb-blue);
  margin-bottom: 6px;
  font-size: 14px;
}
.cycle-detail .detail-cell .line {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}
.cycle-detail .detail-cell .line .k { color: var(--grey-light); }
.cycle-detail .detail-cell .line .v { color: var(--amber); }
.cycle-detail .detail-cell .line .v.up { color: var(--green); }
.cycle-detail .detail-cell .line .v.dn { color: var(--red); }
.cycle-detail .detail-cell .line .v.wht { color: var(--white); }

/* ── About panel (institutional landing copy) ──────────────────────── */
.about-panel {
  border-color: var(--amber-dim);
  background: linear-gradient(180deg, #1a1208 0%, #0d0905 100%);
}
.about-panel .panel-hdr {
  background: linear-gradient(180deg, #2a1a08 0%, #1a1208 100%);
  border-bottom-color: var(--amber-dim);
}
.about-panel .about-body {
  padding: 14px 18px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 28px;
  font-size: 12.5px;
  line-height: 1.55;
}
.about-panel .about-block { color: var(--amber); }
.about-panel .about-block .lbl {
  font-size: 10px;
  color: var(--grey-light);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
}
.about-panel .about-block .val { color: var(--white); font-weight: 500; }
.about-panel .about-block .val.amber { color: var(--amber-bright); font-weight: 600; }
.about-panel .about-block strong { color: var(--amber-bright); font-weight: 700; }
.about-dismiss {
  background: transparent;
  border: 1px solid var(--amber-dim);
  color: var(--amber);
  width: 22px;
  height: 22px;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  margin-left: 10px;
  transition: all 0.15s ease;
}
.about-dismiss:hover { background: var(--amber); color: var(--black); }
.about-panel.collapsed .panel-body { display: none; }
.about-panel.collapsed .about-dismiss::before { content: "+"; }
.about-panel.collapsed .about-dismiss { content: "+"; }

/* ── Inception pill (static — sleeve start date) ─────────────────── */
/* Same overall shape as cycle-status but amber instead of green, no
   pulsing dot — it's static reference info, not a live indicator. */
.inception-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--amber-dim);
  border-radius: 3px;
  font-size: 10.5px;
  letter-spacing: 0.4px;
  background: rgba(255,153,51,0.06);
  color: var(--amber);
  font-weight: 600;
}
.inception-pill .label {
  color: var(--grey-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 9.5px;
}
.inception-pill .value {
  color: var(--amber-bright);
  font-weight: 700;
  letter-spacing: 0.4px;
}

/* ── Cycle-status pill in top-bar (data-freshness indicator) ─────── */
.cycle-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--green-dim);
  border-radius: 3px;
  font-size: 10.5px;
  letter-spacing: 0.6px;
  background: rgba(0,204,102,0.08);
  color: var(--green);
  font-weight: 600;
}
.cycle-status .label {
  color: var(--grey-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 9.5px;
}
.cycle-status .value { color: var(--white); font-weight: 700; letter-spacing: 0.4px; }
.cycle-status.stale {
  border-color: var(--red-dim);
  background: rgba(255,68,68,0.10);
  color: var(--red);
}
.cycle-status.stale .value { color: var(--amber-bright); }
.cycle-status .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
  animation: live-pulse 2s infinite;
}
.cycle-status.stale .dot {
  background: var(--red);
  box-shadow: 0 0 4px var(--red);
  animation: none;
}

/* ── (via stop) suffix inside FLIP→ badges ────────────────────────── */
.action-badge .via-stop {
  font-style: normal;
  text-transform: lowercase;
  font-weight: 500;
  opacity: 0.85;
  letter-spacing: 0.2px;
  margin-left: 2px;
}

/* ── Per-pair performance table (lifetime per-pair view) ──────────── */
/* Pair symbols are amber to match the rest of the page's pair-styling
   convention (cycles-table headers, universe pill, etc.). Active Positions
   table also gets the amber treatment via the same selector. */
#perpair-table td.sym,
#positions-table td.sym {
  color: var(--amber-bright);
  font-weight: 700;
  letter-spacing: 0.5px;
}
/* TOTAL footer row — explicit padding so cells align with body td (which
   inherits `padding: 6px 12px` from the generic `tbody td` rule but tfoot
   does NOT, hence prior misalignment). All cells (incl. TOTAL sym) inherit
   white from this rule — no per-cell color override. */
.perpair-table tfoot td {
  border-top: 1px solid var(--amber-dim);
  border-bottom: none;
  background: rgba(255,153,51,0.04);
  font-weight: 700;
  color: var(--white);
  padding: 9px 12px;
}
.perpair-table tfoot td.sym {
  /* TOTAL row — same white as the rest of the row, slightly wider letterspacing */
  letter-spacing: 0.8px;
}
/* Open-trade sub-line (the % move on the open position, sits below the $ value
   to contextualise it — e.g. "-$25.6K  −2.22% on sleeve"). */
.perpair-table td .sub {
  display: block;
  font-size: 10px;
  color: var(--grey-light);
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: 0.2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE — RADICAL REDESIGN (≤ 768px)

   Desktop layout (≥ 769px) is preserved intact. On mobile, the
   information-dense tables (Active Positions 13-col, Per-Pair 6-col,
   Trading Days 7-col, Trade History 8-col) transform into vertical card
   stacks via display:block. Each <td>'s data-label attribute supplies
   the column label as a ::before pseudo-element. NO horizontal scroll.

   Top-bar uses flex-wrap so brand + cycle-status share row 1 and
   NAV/Return wrap to row 2. Nav-bar stacks tabs above the strategy
   toggle, both full-width. F1/F2 hints hidden. Metric strips become
   2-col grids. Drill-down detail cells stack vertically (was 3-col).
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ─── Top-bar: 2-row layout with flex-wrap ────────────────────────── */
  .top-bar {
    height: auto;
    padding: 6px 12px;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
  }
  .top-bar .brand {
    flex: 1 1 auto;
    min-width: 0;
  }
  .top-bar .brand .subtitle { display: none; }
  .top-bar .brand .logo { font-size: 15px; letter-spacing: 1.2px; }
  .top-bar .cycle-status,
  .top-bar .inception-pill {
    flex: 0 0 auto;
    padding: 3px 8px;
    font-size: 10px;
  }
  .top-bar .cycle-status .label,
  .top-bar .inception-pill .label { font-size: 9px; }
  .top-bar .cycle-status .value,
  .top-bar .inception-pill .value { font-size: 10.5px; }
  .top-bar .right-info {
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 14px;
    font-size: 11px;
    padding-top: 5px;
    border-top: 1px solid rgba(68,136,255,0.25);
  }
  .top-bar .right-info > span { white-space: nowrap; }
  .top-bar .universe-pill { display: none; }  /* redundant with per-pair section */

  /* ─── Nav-bar: two stacked full-width rows ────────────────────────── */
  .nav-bar {
    flex-direction: column;
    height: auto;
    padding: 0;
    gap: 0;
  }
  .nav-tabs {
    width: 100%;
    border-bottom: 1px solid var(--border);
  }
  .nav-btn {
    flex: 1;
    padding: 12px 0;
    text-align: center;
    justify-content: center;
    border-radius: 0;
    font-size: 12px;
    /* Reserve space for the active-state underline so toggling .active
       does not push content up. */
    border-bottom: 3px solid transparent;
    box-sizing: border-box;
  }
  .nav-btn .key { display: none; }  /* no physical keyboard on mobile */
  /* Mobile active tab — inherits the amber-bright underline treatment
     from desktop. Kept the explicit rule so this @media block can be
     tuned independently if mobile ever needs a different look. */
  .nav-btn.active {
    color: var(--amber-bright);
    background: rgba(255, 153, 51, 0.10);
    border-bottom-color: var(--amber);
    font-weight: 700;
  }
  /* Strategy-toggle is no longer the framed element itself; .strat-buttons
     is. On mobile, give the whole row some breathing padding, keep the
     STRATEGY label tight on the left, let .strat-buttons stretch to fill. */
  .strategy-toggle {
    width: 100%;
    padding: 8px 12px;
    gap: 10px;
    background: transparent;
  }
  .strategy-toggle .strat-label {
    flex: 0 0 auto;
  }
  .strat-buttons {
    flex: 1;
    border-radius: 4px;
  }
  .strat-btn {
    flex: 1;
    padding: 10px 0;
    text-align: center;
    font-size: 12px;
  }

  /* ─── Page padding ────────────────────────────────────────────────── */
  .page { padding: 10px 8px; min-height: auto; }

  /* ─── About panel: single column, tighter ─────────────────────────── */
  .about-panel .about-body {
    grid-template-columns: 1fr;
    padding: 12px 14px;
    gap: 12px;
    font-size: 12px;
  }
  .about-panel .about-block .val { line-height: 1.55; }
  .panel-hdr { font-size: 11px; padding: 6px 12px; }
  .panel-hdr .tag { font-size: 9px; padding: 1px 6px; }

  /* ─── Metric strip: 2-col grid (no horizontal scroll) ─────────────── */
  .metrics-row,
  .metrics-row.cols-4,
  .metrics-row.cols-5,
  .metrics-row.cols-6 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    overflow: visible;
  }
  .metric {
    min-width: 0;
    padding: 10px 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }
  .metric:nth-child(2n) { border-right: none; }
  .metric:nth-last-child(-n+2) { border-bottom: none; }
  .metric .val { font-size: 15px; margin: 4px 0 2px; white-space: normal; }
  .metric .sub { font-size: 9.5px; }
  .metric .lbl { font-size: 9px; letter-spacing: 1px; }

  /* ═════════════════════════════════════════════════════════════════
     TABLES → CARDS — common transformation for the 4 dense tables.
     Each <tr> becomes a self-contained card. Each <td> becomes a row
     with the label (via ::before from data-label) on the left and the
     value on the right.
     ═════════════════════════════════════════════════════════════════ */
  #positions-table, #positions-table thead, #positions-table tbody,
  #positions-table tr, #positions-table td,
  #perpair-table, #perpair-table thead, #perpair-table tbody, #perpair-table tfoot,
  #perpair-table tr, #perpair-table td,
  #cycles-table, #cycles-table thead, #cycles-table tbody,
  #cycles-table tr, #cycles-table td,
  #signals-table, #signals-table thead, #signals-table tbody,
  #signals-table tr, #signals-table td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  #positions-table thead,
  #perpair-table thead,
  #cycles-table thead,
  #signals-table thead { display: none; }

  /* Each row = a card */
  #positions-table tbody tr,
  #perpair-table tbody tr,
  #perpair-table tfoot tr,
  #cycles-table tbody tr.expandable,
  #signals-table tbody tr {
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    padding: 12px 14px;
    margin-bottom: 8px;
  }

  /* Each cell = label-on-left, value-on-right, baseline aligned. flex-wrap
     is enabled so a sub-line (e.g., "1 closed · 1 open" under Trades, or
     "live · vs $X" under live trade PnL) can take its own row below the
     headline value without compressing label/value widths. */
  #positions-table tbody td,
  #perpair-table tbody td,
  #perpair-table tfoot td,
  #cycles-table tbody td,
  #signals-table tbody td {
    padding: 5px 0;
    border: none;
    text-align: left !important;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 4px 12px;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--amber);
  }
  /* Mobile: preserve PnL up/dn coloring (overrides the amber default above).
     Without these, mobile card cells inherit amber and lose the green/red
     PnL signal that desktop carries via td.up / td.dn. */
  #positions-table tbody td.up,
  #perpair-table tbody td.up,
  #perpair-table tfoot td.up,
  #cycles-table tbody td.up,
  #signals-table tbody td.up { color: var(--green); }
  #positions-table tbody td.dn,
  #perpair-table tbody td.dn,
  #perpair-table tfoot td.dn,
  #cycles-table tbody td.dn,
  #signals-table tbody td.dn { color: var(--red); }
  /* Generic sub-line behavior in mobile card cells — takes its own
     full-width row below the headline value. */
  #positions-table tbody td .sub,
  #perpair-table tbody td .sub,
  #perpair-table tfoot td .sub,
  #cycles-table tbody td .sub,
  #signals-table tbody td .sub {
    flex-basis: 100%;
    width: 100%;
    display: block;
    text-align: right;
    color: var(--grey-light);
    font-size: 10px;
    font-weight: 500;
    margin-top: 0;
  }

  /* Generic label rendering — driven by data-label attr */
  td[data-label]::before {
    content: attr(data-label);
    color: var(--grey-light);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    flex: 0 0 auto;
    line-height: 1.55;
  }

  /* First cell in each card = title (symbol / date) — no label, larger, amber */
  #positions-table tbody tr td:first-child,
  #perpair-table tbody tr td:first-child,
  #perpair-table tfoot tr td:first-child,
  #signals-table tbody tr td:first-child {
    font-size: 15px;
    font-weight: 700;
    color: var(--amber-bright) !important;
    padding: 0 0 9px 0;
    margin-bottom: 7px;
    border-bottom: 1px solid var(--border);
    display: block;
  }

  /* Active Positions: FLAT row (colspan>1) renders centered, no label */
  #positions-table tbody td[colspan] {
    text-align: center !important;
    color: var(--grey);
    font-style: italic;
    padding: 8px 0;
    display: block;
  }
  #positions-table tbody td[colspan]::before { content: none; }

  /* Per-Pair: ensure value-side preserves its sub-line ($X closed · $Y open) */
  #perpair-table tbody td .sub,
  #perpair-table tfoot td .sub {
    text-align: right;
    display: block;
    width: 100%;
  }
  /* Lifetime P&L cell flex-wraps so sub-line drops below the headline */
  #perpair-table tbody td:nth-child(3),
  #perpair-table tfoot td:nth-child(3) {
    flex-wrap: wrap;
  }
  #perpair-table tbody td:nth-child(3) > *:not(::before):not(.sub),
  #perpair-table tfoot td:nth-child(3) > *:not(::before):not(.sub) {
    text-align: right;
  }

  /* Per-Pair TOTAL footer: accent border + slight tint */
  #perpair-table tfoot tr {
    border-color: var(--amber-dim);
    background: rgba(255,153,51,0.05);
    margin-top: 10px;
  }
  #perpair-table tfoot tr td:first-child {
    color: var(--white) !important;
    letter-spacing: 1.2px;
  }

  /* ─── Trading Days (cycles.html) cards ───────────────────────────── */
  /* Hide the expand-arrow column on mobile; date row gets ::after indicator */
  #cycles-table tbody tr.expandable td.expand-arrow { display: none; }
  #cycles-table tbody tr.expandable td.sym {
    /* Date becomes the card title with an expand chevron on the right */
    font-size: 15px;
    font-weight: 700;
    color: var(--amber-bright) !important;
    padding: 0 0 9px 0;
    margin-bottom: 7px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  #cycles-table tbody tr.expandable td.sym::after {
    content: "▸";
    color: var(--amber);
    font-size: 13px;
    transition: transform 0.15s ease;
  }
  #cycles-table tbody tr.expandable.expanded td.sym::after { content: "▾"; }

  /* Drill-down row: stack details vertically (was 3-col grid on desktop) */
  #cycles-table tbody tr.cycle-detail-row {
    border: none;
    background: transparent;
    padding: 0;
    margin: -4px 0 10px 0;
  }
  #cycles-table tbody tr.cycle-detail-row > td {
    padding: 0;
    background: transparent;
    border: none;
    display: block;
  }
  .cycle-detail {
    padding: 6px 0 0 0 !important;
    background: transparent !important;
    border-top: none !important;
  }
  .cycle-detail .detail-grid {
    display: flex !important;
    flex-direction: column;
    overflow: visible !important;
    gap: 8px !important;
    background: transparent !important;
  }
  .cycle-detail .detail-cell {
    min-width: 0 !important;
    background: var(--bg-panel) !important;
    padding: 10px 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px;
  }
  .cycle-detail .detail-cell .pair-id {
    font-size: 14px;
    color: var(--amber-bright);
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
  }
  .cycle-detail .detail-cell .line {
    padding: 3px 0;
  }

  /* ─── Recent Activity (stays a table on mobile per CEO).
       Desktop CSS sets `.cycles-table th.pair-col { width: 18% }`. With
       table-layout: fixed that gave 3 × 18% = 54% to pair cols, leaving
       only ~15% (~54px on 360px viewport) for Date / Δ% / NAV After.
       "NAV After" header (~52px at 10px font) + padding overflowed the
       column → text-overflow:ellipsis clipped it to "NAV Aft…".
       Fix: explicit per-column widths via :nth-child (higher specificity
       than `.pair-col` due to the #id), and allow header text to wrap
       to two lines so "Δ% vs prior" / "NAV After" fit cleanly. */
  #recent-cycles-table {
    font-size: 10px;
    table-layout: fixed;
    width: 100%;
  }
  #recent-cycles-table th {
    padding: 4px 2px;
    white-space: normal;       /* allow header wrap (e.g., "NAV / After") */
    line-height: 1.15;
    vertical-align: bottom;
    font-size: 9.5px;
  }
  #recent-cycles-table td {
    padding: 5px 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #recent-cycles-table td.sym { font-size: 10px; }
  /* Balanced widths — pair badges get breathable room, no big gap before NAV.
     Sum = 100%. Tuned for 360-414px viewports. */
  #recent-cycles-table th:nth-child(1),
  #recent-cycles-table td:nth-child(1) { width: 19%; }                    /* Date */
  #recent-cycles-table th:nth-child(2),
  #recent-cycles-table td:nth-child(2),
  #recent-cycles-table th:nth-child(3),
  #recent-cycles-table td:nth-child(3),
  #recent-cycles-table th:nth-child(4),
  #recent-cycles-table td:nth-child(4) {
    width: 16%;                                                           /* BTC / ETH / SOL — aéré */
    padding: 5px 2px;
  }
  #recent-cycles-table th:nth-child(5),
  #recent-cycles-table td:nth-child(5) { width: 14%; }                    /* Δ% vs prior (header wraps) */
  #recent-cycles-table th:nth-child(6),
  #recent-cycles-table td:nth-child(6) { width: 19%; }                    /* NAV After — just enough */
  #recent-cycles-table .action-badge {
    font-size: 8.5px;
    padding: 1px 3px;
    letter-spacing: 0.2px;
  }

  /* ─── Side cell: live-dot + direction text wrapped in one span so they
       stay adjacent on the right side of the card row (otherwise flex
       space-between scatters them apart). */
  #positions-table tbody td .side-value {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
  }
  #positions-table tbody td .side-value .live-dot { margin: 0; }

  /* ─── Pair detail: position-card 2-col, position-grid stacked ─────── */
  .position-card { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px; }
  .position-card .field .val { font-size: 14px; }
  .position-grid { grid-template-columns: 1fr; gap: 1px; }

  /* ─── Footer: stacked, smaller ────────────────────────────────────── */
  .footer {
    flex-direction: column;
    height: auto;
    padding: 6px 10px;
    gap: 2px;
    align-items: flex-start;
    font-size: 9.5px;
  }
}
