/* session-flow.css — Session Flow Dashboard
 *
 * Layout, palette and visual primitives match the approved mockup. The dashboard is REST-driven
 * (polls /api/session-flow) so it has no websocket spinner — just a quiet age indicator in the top
 * nav. Bucket chips re-aggregate the whole view; the SPOT column shows the bucket-end SPX value
 * with a per-row arrow + intraday range bar, and the top "spot strip" sparkline shows the day's
 * trajectory with a "now" cursor that slides right as new minutes arrive.
 */

:root {
  --bg: #0d1117;
  --panel: #151b23;
  --grid: #1f2730;
  --grid-soft: #1a2129;
  --text: #d7e2ef;
  --muted: #6e7d92;
  --muted-strong: #91a7bd;
  --bull: #2ecc71;
  --bear: #ff5d5d;
  --accent: #1f6feb;
  --warn: #f5b400;
  --spot: #79b8ff;
  /* Heights of the two pinned header layers (topnav, controls). Measured at runtime by
     session-flow.js and written back as these vars so the sticky offsets below stay exact when
     the controls wrap onto two lines at narrow widths. The values here are first-paint fallbacks. */
  --topnav-h: 44px;
  --controls-h: 52px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 13px;
}

/* ---------- top nav bar (deep link back to option-chain) ---------- */
.topnav {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: #0a0e14;
  border-bottom: 1px solid var(--grid);
  position: sticky; top: var(--oc-topnav-h, 0px); z-index: 30;
}
.topnav a.back {
  color: var(--muted-strong);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background 0.12s;
}
.topnav a.back:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.topnav .title {
  font-size: 14px; font-weight: 800; color: var(--text);
  letter-spacing: 0.03em;
}
.topnav .spacer { flex: 1; }
.topnav .date {
  color: var(--muted); font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.topnav .age {
  color: var(--muted); font-size: 11px; font-weight: 700;
  margin-left: 14px;
}
.topnav .age.stale { color: var(--warn); }

/* ---------- bucket dropdown / controls ---------- */
.controls {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  flex-wrap: wrap;
  /* Pin the bucket/date controls directly under the topnav so the duration can be changed without
     scrolling back to the top. Opaque background + border so data rows never show through. */
  position: sticky; top: calc(var(--oc-topnav-h, 0px) + var(--topnav-h)); z-index: 25;
  background: #0a0e14;
  border-bottom: 1px solid var(--grid);
}
.control-group { display: inline-flex; align-items: center; gap: 8px; }
.control-label {
  font-size: 10px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.bucket-btns {
  display: inline-flex; gap: 2px;
  background: #0f1620;
  border: 1px solid var(--grid);
  border-radius: 5px;
  padding: 2px;
}
.bucket-btns button {
  appearance: none; border: 0;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 800;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}
.bucket-btns button:hover { color: var(--text); }
.bucket-btns button.on { background: var(--accent); color: #fff; }
.bucket-btns button:disabled { opacity: 0.5; cursor: progress; }

.date-input {
  background: #0f1620;
  color: var(--text);
  border: 1px solid var(--grid);
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}

/* ---------- session summary banner ---------- */
main { padding: 18px 24px 32px; max-width: 1280px; }

.summary {
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label {
  font-size: 10px; font-weight: 800;
  color: var(--muted); letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat-value { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-value.bull { color: var(--bull); }
.stat-value.bear { color: var(--bear); }
.stat-value.spot { color: var(--spot); }
.stat-sub { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ---------- spot strip (intra-day price sparkline) ---------- */
.spot-strip {
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 12px 18px;
  margin-bottom: 18px;
}
.spot-strip-head {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 8px;
}
.spot-strip-head .label {
  font-size: 10px; font-weight: 800;
  color: var(--muted); letter-spacing: 0.08em;
  text-transform: uppercase;
}
.spot-strip-head .now { font-size: 18px; font-weight: 800; color: var(--spot); font-variant-numeric: tabular-nums; }
.spot-strip-head .delta { font-size: 12px; font-weight: 800; }
.spot-strip-head .delta.bull { color: var(--bull); }
.spot-strip-head .delta.bear { color: var(--bear); }
svg.sparkline { display: block; width: 100%; height: 56px; }

/* ---------- main flow table ---------- */
table.flow {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: 10px;
  /* Deliberately NO `overflow: hidden` here. Corner-clipping a table needs overflow != visible, but
     that turns the table into a scroll container, which scopes the sticky column headers to the table
     box and breaks their pinning against the viewport. Clipping and viewport-sticky are mutually
     exclusive, so we keep sticky: the outer 1px border stays rounded, and the inner header/cell
     backgrounds are left un-clipped at the four corners (a negligible cosmetic trade-off). */
}
.flow th, .flow td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--grid-soft);
  vertical-align: middle;
}
.flow thead th {
  font-size: 10px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  background: #11161e;
  text-align: right;
  border-bottom: 1px solid var(--grid);
  /* Pin the column labels just below the topnav + controls so it's always clear what each column
     means while scrolling rows. Sticky goes on the th cells (not thead) for cross-browser support;
     the opaque background above keeps rows from bleeding through. */
  position: sticky; top: calc(var(--oc-topnav-h, 0px) + var(--topnav-h) + var(--controls-h)); z-index: 15;
}
.flow thead th:first-child,
.flow thead th.left { text-align: left; }
.flow td { text-align: right; }
.flow td.time {
  text-align: left;
  font-weight: 800; color: var(--text);
  width: 64px;
  position: relative;
}
.flow td.num { font-weight: 800; }
.flow td.num.bull { color: var(--bull); }
.flow td.num.bear { color: var(--bear); }
.flow td.num.zero { color: var(--muted-strong); }
.flow td.notes { text-align: left; padding-left: 18px; color: var(--muted-strong); font-size: 12px; }

/* row tints */
.flow tr.tint-bull        { background: rgba(46, 204, 113, 0.04); }
.flow tr.tint-bull-strong { background: rgba(46, 204, 113, 0.10); }
.flow tr.tint-bear        { background: rgba(255, 93, 93, 0.04); }
.flow tr.tint-bear-strong { background: rgba(255, 93, 93, 0.10); }
.flow tr.tint-bear-peak   { background: rgba(255, 93, 93, 0.16); }
.flow tr.tint-close       { background: #11161e; }

/* ---------- SPOT column: value + arrow + intraday range bar ---------- */
.spot-cell { width: 150px; text-align: right; }
.spot-val {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-weight: 800; font-size: 13px;
  color: var(--spot);
}
.spot-arrow { font-size: 11px; font-weight: 800; margin-right: 2px; }
.spot-arrow.up   { color: var(--bull); }
.spot-arrow.down { color: var(--bear); }
.spot-range {
  position: relative;
  height: 4px;
  background: rgba(110, 125, 146, 0.18);
  border-radius: 2px;
  margin-top: 4px;
}
.spot-range-mark {
  position: absolute; top: -2px; bottom: -2px;
  width: 2px;
  background: var(--spot);
  border-radius: 1px;
}

/* ---------- visual strength bar ---------- */
.bar-cell { width: 260px; padding-right: 18px; }
.bar { position: relative; height: 14px; background: transparent; }
.bar-axis { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #8a94a6; }
.bar-fill { position: absolute; top: 0; bottom: 0; height: 14px; border-radius: 2px; }
.bar-fill.bull { background: var(--bull); }
.bar-fill.bear { background: var(--bear); }

/* ---------- "you are here" live cursor ---------- */
tr.live-row { position: relative; box-shadow: inset 3px 0 0 var(--spot); }
tr.live-row td.time::after {
  content: '● LIVE';
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  font-size: 8px; font-weight: 800;
  color: var(--spot);
  letter-spacing: 0.1em;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.4 } 50% { opacity: 1 } }

/* ---------- badges (label tags on each row) ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge.flat       { background: rgba(110, 125, 146, 0.15); color: var(--muted-strong); }
.badge.open       { background: rgba(31, 111, 235, 0.18);  color: #79b8ff; }
.badge.close      { background: rgba(110, 125, 146, 0.22); color: var(--muted-strong); }
.badge.bull-start { background: rgba(46, 204, 113, 0.22);  color: var(--bull); }
.badge.bull-build { background: rgba(46, 204, 113, 0.14);  color: var(--bull); }
.badge.bear-drift { background: rgba(255, 93, 93, 0.14);   color: var(--bear); }
.badge.bear-flip  { background: rgba(245, 180, 0, 0.18);   color: var(--warn); }
.badge.put-wave   { background: rgba(255, 93, 93, 0.30);   color: #fff; }
.badge.put-mass   { background: rgba(255, 93, 93, 0.40);   color: #fff; }
.badge.peak-bear  { background: rgba(255, 93, 93, 0.55);   color: #fff; }
.note-text { margin-left: 10px; color: var(--muted-strong); font-size: 11.5px; }

/* ---------- empty / error states ---------- */
.empty, .errbox {
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 28px 24px;
  text-align: center;
  color: var(--muted);
}
.errbox { border-color: var(--bear); color: var(--bear); }

.legend {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  max-width: 1100px;
}
.legend code { background: #11161e; padding: 1px 5px; border-radius: 3px; color: var(--muted-strong); }
