/* shadcn-style purple dark theme. HSL tokens so we can tweak hue in one place. */
:root {
  /* Surfaces */
  --bg: hsl(273, 36%, 5%);             /* near-black with a purple tint */
  --panel: hsl(272, 28%, 9%);          /* cards / panels */
  --panel-2: hsl(271, 24%, 13%);       /* hover / nested panels */
  --line: hsl(270, 20%, 18%);          /* borders */

  /* Foreground */
  --fg: hsl(270, 20%, 96%);            /* primary text */
  --fg-dim: hsl(265, 15%, 65%);        /* muted */

  /* Brand / accents */
  --accent: hsl(263, 75%, 65%);        /* violet-500 — primary accent */
  --accent-2: hsl(280, 80%, 70%);      /* fuchsia-ish secondary */
  --ring: hsl(263, 80%, 55%);          /* focus ring */

  /* Status */
  --ok: hsl(142, 70%, 58%);            /* emerald-400 */
  --warn: hsl(38, 92%, 60%);           /* amber-400 */
  --bad: hsl(0, 75%, 64%);             /* red-400 */

  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Radii (shadcn uses --radius) */
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(ellipse at top, hsla(263, 80%, 25%, 0.18), transparent 50%),
    radial-gradient(ellipse at bottom, hsla(280, 60%, 15%, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--fg);
  font: 13px/1.45 var(--mono);
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: linear-gradient(180deg, hsla(272, 28%, 12%, 0.95), hsla(272, 28%, 8%, 0.95));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  font-weight: 800; letter-spacing: 1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 14px;
}
.refresh-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--fg);
  cursor: pointer;
  padding: 2px 9px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.3px;
}
.refresh-btn:hover { background: hsla(270, 30%, 20%, 0.7); color: var(--accent); border-color: var(--accent); }
.refresh-btn:active { transform: translateY(1px); }
.refresh-btn.on { color: var(--bg); background: var(--accent); border-color: var(--accent); font-weight: 700; }

/* Allow the Signals verdict column (long prose) to wrap; numbers stay aligned. */
.signals-table td:last-child { white-space: normal; max-width: 380px; line-height: 1.35; }
.signals-table tbody tr.active { background: rgba(88,166,255,0.08); }
.signals-table tbody tr.active td:first-child { color: var(--accent); font-weight: 700; }

/* Signals detail panel */
.signal-detail-host { margin-top: 12px; }
.signal-detail {
  background: var(--panel); border: 1px solid var(--accent); border-radius: 5px;
  padding: 14px 16px;
}
.signal-detail-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.signal-detail-head h3 { margin: 0; font-size: 16px; color: var(--accent); letter-spacing: 0.5px; }
.signal-detail-kind {
  color: var(--fg-dim); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 1px 8px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 3px;
}
.signal-detail-tiles { margin: 6px 0 10px; }
.signal-verdict { margin: 6px 0 12px; }
.signal-desc { font-size: 12px; line-height: 1.5; margin-bottom: 8px; }
.signal-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px;
}
@media (max-width: 800px) { .signal-detail-grid { grid-template-columns: 1fr; } }
.signal-detail-meta { color: var(--fg-dim); font-size: 11px; margin-top: 10px; }
.badges { display: flex; gap: 8px; }
.meta { margin-left: auto; display: flex; gap: 16px; color: var(--fg-dim); }

.badge {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--panel-2);
  color: var(--fg-dim);
}
.badge.mode-PAPER { color: #0d1117; background: var(--warn); border-color: var(--warn); }
.badge.mode-READONLY { color: var(--fg); background: var(--panel-2); }
.badge-blocked { color: #0d1117; background: var(--bad); border-color: var(--bad); }
.badge-alert { color: #0d1117; background: var(--bad); border-color: var(--bad); }

/* ═══════════════════════════════════════════════════════════════════
   LEFT NAVIGATION — operator-grade
   JetBrains Mono headers, Lucide line icons, grid-row collapse anim,
   command-bar filter, single accent color, no decorative noise.
   ═══════════════════════════════════════════════════════════════════ */

/* Layout */
#layout { display: flex; height: calc(100vh - 38px - 26px); }

#rail {
  width: 224px;
  flex: 0 0 224px;
  display: flex;
  flex-direction: column;
  background:
    /* faint mesh in upper-left for atmosphere */
    radial-gradient(circle at 0% 0%, hsla(263, 70%, 35%, 0.10), transparent 45%),
    linear-gradient(180deg, hsla(272, 28%, 9%, 1) 0%, hsla(273, 32%, 7%, 1) 100%);
  border-right: 1px solid hsla(270, 20%, 16%, 0.8);
  position: relative;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-feature-settings: "ss01" 1, "cv11" 1, "calt" 1;
}
/* Hairline accent stripe on the rail's right edge */
#rail::after {
  content: "";
  position: absolute;
  top: 0; right: -1px; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg,
    transparent 0%,
    hsla(263, 75%, 55%, 0.25) 15%,
    hsla(263, 75%, 55%, 0.10) 60%,
    transparent 100%);
  pointer-events: none;
}

/* ─── Filter / command bar ───────────────────────────────────────── */
.rail-filter {
  position: relative;
  padding: 12px 12px 10px;
  border-bottom: 1px solid hsla(270, 18%, 18%, 0.5);
  background: hsla(273, 32%, 7%, 0.4);
}
.rail-filter__ic {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px; height: 12px;
  color: hsla(270, 10%, 50%, 1);
  pointer-events: none;
  transition: color 160ms ease;
}
.rail-filter input {
  width: 100%;
  font: inherit;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  padding: 7px 32px 7px 28px;
  color: var(--fg);
  background: hsla(272, 30%, 12%, 0.8);
  border: 1px solid hsla(270, 20%, 22%, 0.7);
  border-radius: 7px;
  outline: none;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.rail-filter input::placeholder {
  color: hsla(270, 8%, 48%, 1);
  letter-spacing: 0.01em;
}
.rail-filter input:focus {
  border-color: hsla(263, 75%, 60%, 0.65);
  background: hsla(272, 35%, 14%, 0.95);
  box-shadow:
    0 0 0 2px hsla(263, 75%, 55%, 0.15),
    inset 0 0 12px hsla(263, 75%, 55%, 0.05);
}
.rail-filter:has(input:focus) .rail-filter__ic { color: var(--accent); }
.rail-filter__kbd {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  font: 10px/1 "JetBrains Mono", monospace;
  padding: 2px 6px;
  border-radius: 4px;
  background: hsla(270, 18%, 18%, 0.9);
  color: hsla(270, 10%, 60%, 1);
  border: 1px solid hsla(270, 18%, 25%, 0.7);
  pointer-events: none;
  letter-spacing: 0;
}
.rail-filter:has(input:focus) .rail-filter__kbd { opacity: 0; }

/* ─── Scrollable section column ──────────────────────────────────── */
.rail-scroll {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: hsla(270, 25%, 30%, 0.35) transparent;
  padding: 6px 0 16px;
}
.rail-scroll::-webkit-scrollbar { width: 6px; }
.rail-scroll::-webkit-scrollbar-thumb {
  background: hsla(270, 25%, 30%, 0.35);
  border-radius: 3px;
}
.rail-scroll::-webkit-scrollbar-thumb:hover {
  background: hsla(263, 60%, 45%, 0.5);
}

/* ─── Section ────────────────────────────────────────────────────── */
.nav-section {
  display: block;
  position: relative;
}
.nav-section + .nav-section { margin-top: 1px; }

.nav-section__head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 12px 9px 14px;
  background: transparent;
  border: 0;
  font: inherit;
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: hsla(270, 10%, 56%, 1);
  cursor: pointer;
  outline: 0;
  user-select: none;
  text-align: left;
  position: relative;
  transition: color 200ms cubic-bezier(0.16, 1, 0.3, 1),
              background 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.nav-section__head:hover {
  color: var(--fg);
  background: hsla(270, 22%, 14%, 0.5);
}
.nav-section__head:focus-visible {
  box-shadow: inset 2px 0 0 var(--accent), inset 0 0 0 1px hsla(263, 75%, 55%, 0.3);
}
.nav-section__ic {
  width: 13px;
  height: 13px;
  color: hsla(270, 12%, 60%, 1);
  flex: 0 0 13px;
  transition: color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.nav-section__label {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.nav-section__count {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0;
  color: hsla(270, 8%, 45%, 1);
  padding: 1px 5px;
  background: hsla(270, 20%, 16%, 0.7);
  border-radius: 3px;
  min-width: 18px;
  text-align: center;
  transition: all 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.nav-section__chev {
  width: 11px;
  height: 11px;
  color: hsla(270, 12%, 55%, 1);
  flex: 0 0 11px;
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
              color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Open state: chevron rotates 90° (points down), label brightens, accent on icon */
.nav-section[data-open="true"] .nav-section__head {
  color: hsla(0, 0%, 92%, 1);
}
.nav-section[data-open="true"] .nav-section__ic {
  color: var(--accent);
}
.nav-section[data-open="true"] .nav-section__count {
  color: hsla(263, 60%, 75%, 1);
  background: hsla(263, 60%, 22%, 0.55);
}
.nav-section[data-open="true"] .nav-section__chev {
  transform: rotate(90deg);
  color: var(--accent);
}

/* Section containing the active view — subtle accent stripe on the left */
.nav-section.has-active::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px;
  background: linear-gradient(180deg,
    hsla(263, 80%, 60%, 0.7),
    hsla(263, 80%, 60%, 0.15));
  border-radius: 2px;
  pointer-events: none;
}

/* ─── Collapsible body using grid-row 0→1 animation ──────────────── */
.nav-section__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
.nav-section[data-open="true"] .nav-section__body {
  grid-template-rows: 1fr;
}
.nav-section__inner {
  min-height: 0;
  overflow: hidden;
  padding: 2px 0 4px;
}

/* ─── Individual nav item ────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  color: hsla(270, 8%, 70%, 1);
  padding: 7px 12px 7px 36px;
  font: inherit;
  font-family: "Geist", "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.005em;
  cursor: pointer;
  position: relative;
  outline: 0;
  transition: color 160ms cubic-bezier(0.16, 1, 0.3, 1),
              background 160ms cubic-bezier(0.16, 1, 0.3, 1),
              border-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.nav::before {
  /* Tiny tick mark on the left, brightens on hover/active */
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 4px;
  height: 1px;
  background: hsla(270, 10%, 35%, 1);
  transform: translateY(-50%);
  transition: background 160ms ease, width 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.nav:hover {
  color: var(--fg);
  background: linear-gradient(90deg,
    hsla(263, 55%, 28%, 0.22),
    hsla(263, 55%, 28%, 0.04));
}
.nav:hover::before {
  background: hsla(263, 75%, 70%, 0.9);
  width: 8px;
}
.nav:focus-visible {
  box-shadow: inset 2px 0 0 var(--accent), inset 0 0 0 1px hsla(263, 75%, 55%, 0.25);
}

.nav.active {
  color: var(--fg);
  border-left-color: var(--accent);
  background: linear-gradient(90deg,
    hsla(263, 75%, 35%, 0.32) 0%,
    hsla(263, 75%, 35%, 0.06) 60%,
    transparent 100%);
  font-weight: 600;
}
.nav.active::before {
  background: var(--accent);
  width: 10px;
  box-shadow: 0 0 6px hsla(263, 90%, 65%, 0.6);
}
.nav.active::after {
  /* Pulsing dot on the right edge of the active item */
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
  box-shadow: 0 0 8px var(--accent), 0 0 16px hsla(263, 90%, 65%, 0.4);
  animation: navActivePulse 2.6s ease-in-out infinite;
}
@keyframes navActivePulse {
  0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
  50%      { opacity: 0.55; transform: translateY(-50%) scale(0.85); }
}

/* Inline trailing bits */
.nav__star {
  margin-left: auto;
  color: hsla(45, 90%, 70%, 0.9);
  font-size: 11px;
  text-shadow: 0 0 6px hsla(45, 90%, 60%, 0.4);
}
.nav__hint {
  margin-left: auto;
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsla(270, 8%, 45%, 1);
  padding: 1px 5px;
  background: hsla(270, 20%, 16%, 0.8);
  border-radius: 3px;
}

/* ─── Filter behavior ────────────────────────────────────────────── */
.nav.nav-filtered-out { display: none; }
.nav-section.section-all-filtered { display: none; }
.nav-filter-hit { color: var(--accent) !important; }

/* When filtering, the count badge shows the current visible count */
.nav-section[data-filter-active] .nav-section__count {
  color: var(--accent);
  background: hsla(263, 60%, 25%, 0.6);
}

/* ─── Foot of the rail — version/mode tag ────────────────────────── */
.rail-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-top: 1px solid hsla(270, 18%, 18%, 0.45);
  background: hsla(273, 32%, 6%, 0.5);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: hsla(270, 8%, 50%, 1);
}
.rail-foot__ic {
  width: 11px; height: 11px;
  color: hsla(263, 75%, 60%, 0.85);
}

/* ─── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .nav-section__body { transition: none; }
  .nav-section__chev { transition: none; }
  .nav, .nav-section__head { transition: none; }
  .nav.active::after { animation: none; }
}

#main { flex: 1; overflow: auto; padding: 16px 18px; }

/* Sections */
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--fg-dim); margin: 0 0 10px; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* Tables */
/* Wrap any table in an overflow-x scroller so wide tables (Top Plays,
   leaderboards, optimizer) don't push the layout or clip cells. */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--fg-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.selectable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Cells that hold long-form text (descriptions, notes, signal lists)
   should wrap rather than truncate horizontally. */
td.struct-cell, th.struct-cell {
  white-space: normal;
  min-width: 140px;
  max-width: 360px;
  word-break: break-word;
}

/* Wrap any table in this to allow horizontal scroll without breaking layout */
.tbl-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: hsla(270, 25%, 30%, 0.4) transparent;
}
.tbl-scroll::-webkit-scrollbar { height: 8px; }
.tbl-scroll::-webkit-scrollbar-thumb { background: hsla(270, 25%, 30%, 0.4); border-radius: 4px; }

/* Status pills */
.pill { padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.pill-ok { color: #0d1117; background: var(--ok); }
.pill-bad { color: #0d1117; background: var(--bad); }
.pill-warn { color: #0d1117; background: var(--warn); }
.pill-mut { color: var(--fg-dim); border: 1px solid var(--line); }

/* Panel / detail */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.panel h3 { margin: 0 0 8px; font-size: 13px; }
.tile, .chart-card, .play-tile, .u-card, .signal-detail, .model-card {
  /* unify rounded radius across cards for the shadcn look */
  border-radius: var(--radius);
}
.tile, .chart-card { box-shadow: 0 1px 2px 0 hsla(263, 50%, 5%, 0.4); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 2px 10px; }
.kv .k { color: var(--fg-dim); }
.kv .v { font-variant-numeric: tabular-nums; }

/* Checklist */
.rule { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.rule .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.dot.passed { background: var(--ok); }
.dot.blocked { background: var(--bad); }
.dot.not_evaluated { background: var(--line); }
.dot.unknown { background: var(--warn); }
.rule .rid { color: var(--fg-dim); }
.rule.is-blocked .rid { color: var(--bad); font-weight: 700; }

/* Utilization bars */
.bar-row { margin: 8px 0; }
.bar-row .bar-label { display: flex; justify-content: space-between; color: var(--fg-dim); margin-bottom: 3px; }
.bar { height: 9px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar > span.hot { background: var(--bad); }

/* Journal */
.journal-entry { border: 1px solid var(--line); border-radius: 5px; margin-bottom: 10px; }
.journal-entry > .head { display: flex; gap: 10px; align-items: center; padding: 7px 10px; background: var(--panel); }
.event-row { display: flex; gap: 10px; padding: 4px 10px; border-top: 1px solid var(--line); color: var(--fg-dim); }
.event-row .et { color: var(--fg); min-width: 130px; }

/* Live gate banner */
.gate-banner { border: 1px solid var(--bad); background: rgba(248,81,73,0.08); border-radius: 5px; padding: 12px 14px; margin-bottom: 14px; }
.gate-banner b { color: var(--bad); }

.loading { color: var(--fg-dim); padding: 20px; }
.empty { color: var(--fg-dim); padding: 16px; border: 1px dashed var(--line); border-radius: 5px; }

/* Status bar */
#statusbar {
  height: 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--fg-dim);
  font-size: 11px;
}
.disclaimer { margin-left: auto; }

/* ---- Backtest / Compare form + stats + charts ---- */
.bt-form {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end;
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  padding: 12px 14px; margin-bottom: 14px;
}
.bt-form label { display: flex; flex-direction: column; gap: 3px; color: var(--fg-dim); font-size: 11px; }
.bt-form input, .bt-form select {
  background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 3px; padding: 4px 7px; font: 12px var(--mono); min-width: 110px;
}
.bt-form .multi-select { min-width: 180px; min-height: 90px; }
.bt-form input:focus, .bt-form select:focus { outline: 1px solid var(--accent); }
.bt-form .run-btn {
  background: linear-gradient(135deg, var(--accent), hsl(263, 75%, 55%));
  color: var(--bg); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 6px 16px; font: 700 12px var(--mono); cursor: pointer;
  letter-spacing: 0.3px;
  box-shadow: 0 0 12px hsla(263, 75%, 50%, 0.3);
  transition: all 120ms ease;
}
.bt-form .run-btn:hover {
  background: linear-gradient(135deg, hsl(263, 85%, 70%), hsl(280, 80%, 65%));
  box-shadow: 0 0 18px hsla(263, 75%, 50%, 0.5);
}
.bt-form .run-btn:disabled { opacity: 0.5; cursor: wait; box-shadow: none; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 9px 12px; }
.tile .label { color: var(--fg-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; }
.tile .value { font-size: 18px; font-variant-numeric: tabular-nums; margin-top: 3px; }
.tile .value.pos { color: var(--ok); }
.tile .value.neg { color: var(--bad); }
.tile .sub { color: var(--fg-dim); font-size: 11px; margin-top: 2px; }

.charts { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; }
.chart-card h3 { margin: 0 0 6px; font-size: 12px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.chart-card canvas { width: 100%; display: block; }
.chart-meta { color: var(--fg-dim); font-size: 11px; margin-top: 6px; }

/* ---- Universe tab ---- */
.u-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 12px;
}
.u-card { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; }
.u-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.u-ticker { font-weight: 700; font-size: 14px; letter-spacing: 0.5px; color: var(--accent); }
.u-name { color: var(--fg); font-size: 12px; }
.u-alloc { color: var(--fg-dim); font-size: 11px; margin-left: auto; }
.u-sector { color: var(--fg-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.u-meta { color: var(--fg-dim); font-size: 11px; margin-bottom: 2px; }
.u-section { margin-top: 7px; }
.u-label { color: var(--fg-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 3px; }
.u-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.u-tag { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 3px; font-size: 10px; color: var(--fg); }
.u-tag.tag-cat { border-color: var(--warn); color: var(--warn); }
.u-slice { display: flex; gap: 8px; font-size: 11px; padding: 1px 0; }
.u-slice-k { color: var(--fg-dim); min-width: 50px; }
.u-slice-v { color: var(--fg); font-variant-numeric: tabular-nums; }

/* ---- Chain table ---- */
.chain-table th, .chain-table td { padding: 3px 6px; font-size: 11px; }
.chain-row.atm { background: rgba(88,166,255,0.08); }
.chain-row.atm td { border-color: var(--accent); }

/* ---- Payoff legs ---- */
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.preset-btn {
  background: var(--panel-2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 3px; padding: 4px 9px; font: 11px var(--mono); cursor: pointer;
}
.preset-btn:hover { background: var(--line); color: var(--accent); border-color: var(--accent); }
.preset-btn.add { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.legs-host { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.leg-row {
  display: flex; gap: 6px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: 3px; padding: 4px 7px;
}
.leg-row select, .leg-row input {
  background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 2px; padding: 2px 5px; font: 12px var(--mono); min-width: 70px;
}
.leg-rm {
  background: transparent; color: var(--bad); border: 0; cursor: pointer;
  font-size: 14px; font-weight: 700; padding: 2px 8px;
}
.help-text { color: var(--fg-dim); font-size: 11px; margin-bottom: 10px; }

/* ---- Models tab ---- */
.model-card .model-stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.model-stat-tile {
  display: inline-flex; gap: 4px; align-items: baseline;
  background: var(--bg); border: 1px solid var(--line); border-radius: 3px;
  padding: 2px 7px; font-size: 11px;
}
.model-stat-k { color: var(--fg-dim); font-size: 10px; }
.model-stat-v { font-variant-numeric: tabular-nums; color: var(--fg); }
.model-stat-tile.pos .model-stat-v { color: var(--ok); }
.model-stat-tile.neg .model-stat-v { color: var(--bad); }
.model-verdict {
  color: var(--fg-dim); font-size: 11px; font-style: italic;
  border-left: 2px solid var(--line); padding: 2px 8px; margin: 4px 0; line-height: 1.35;
}
.model-arch {
  background: var(--bg); border: 1px solid var(--line); border-radius: 3px;
  padding: 6px 8px; font-size: 10.5px; line-height: 1.45; color: var(--fg);
  white-space: pre-wrap; margin: 0;
}
.model-hparams { display: grid; grid-template-columns: 1fr; gap: 1px; }
.model-impl { font-family: var(--mono); font-size: 10.5px; color: var(--fg-dim); }
.model-btn-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.model-btn-out { color: var(--fg-dim); font-size: 11px; font-variant-numeric: tabular-nums; }

/* ---- Top Plays (advisor home) ---- */
.tp-banner {
  background:
    radial-gradient(ellipse at top right, hsla(263, 80%, 40%, 0.18), transparent 60%),
    linear-gradient(135deg, hsla(263, 70%, 25%, 0.35), hsla(280, 60%, 20%, 0.2));
  border: 1px solid hsla(263, 70%, 50%, 0.4);
  border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px;
  box-shadow: 0 0 24px hsla(263, 75%, 30%, 0.15);
}
.tp-title {
  margin: 0 0 4px; font-size: 17px; letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 800;
}
.tp-sub { color: var(--fg-dim); font-size: 11px; }
.tp-form { margin-bottom: 14px; }
.tp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 12px; }
/* Compact mode kicks in when there are many tiles — tighter cards, smaller fonts */
.tp-grid.compact { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.tp-grid.compact .play-tile { padding: 10px 12px; }
.tp-grid.compact .play-ticker { font-size: 16px; }
.tp-grid.compact .play-narrative { font-size: 10.5px; }
.tp-grid.compact .play-pnl-v { font-size: 12px; }
.play-tile {
  background: linear-gradient(180deg, var(--panel), hsla(272, 28%, 7%, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
  min-width: 0;          /* flex shrink fix — without this, content can overflow grid cell */
  word-wrap: break-word;
  overflow-wrap: anywhere;
  transition: transform 120ms ease, border-color 200ms ease, box-shadow 200ms ease;
}
.play-tile > * { min-width: 0; }
.play-tile:hover {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: 0 8px 24px hsla(263, 75%, 20%, 0.4), 0 0 12px hsla(263, 75%, 40%, 0.2);
}
.play-tile.top {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px hsla(263, 75%, 50%, 0.25);
}
.play-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.play-head > * { min-width: 0; }
.play-rank {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 1px 8px; font-size: 11px; color: var(--fg-dim); font-weight: 700;
}
.play-tile.top .play-rank { background: var(--ok); color: var(--bg); border-color: var(--ok); }
.play-ticker { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; color: var(--accent); }
.play-spark {
  width: 110px; max-width: 110px; height: 32px; display: block;
  background: var(--bg); border: 1px solid var(--line); border-radius: 3px;
}
.play-trend { font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 700; }
.play-trend.pos { color: var(--ok); }
.play-trend.neg { color: var(--bad); }
.play-catalyst {
  font-size: 10.5px; color: var(--warn); font-weight: 700;
  background: rgba(210,153,34,0.12); border: 1px solid var(--warn);
  border-radius: 10px; padding: 1px 7px; letter-spacing: 0.2px;
}
.play-score { margin-left: auto; padding: 1px 8px; border-radius: 3px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.play-score.hot { background: var(--ok); color: var(--bg); }
.play-score.warm { background: var(--warn); color: var(--bg); }
.play-score.cool { background: var(--line); color: var(--fg-dim); }
.play-struct {
  color: var(--fg); font-size: 12px; font-weight: 600;
  word-break: break-word; overflow-wrap: anywhere;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
}
.play-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.play-pill {
  background: var(--bg); border: 1px solid var(--line); border-radius: 3px;
  padding: 1px 7px; font-size: 10px; display: inline-flex; gap: 5px;
}
.play-pill-k { color: var(--fg-dim); }
.play-pill-v { color: var(--fg); font-variant-numeric: tabular-nums; }
.play-pop { font-size: 10px; }
.play-pop-bar { position: relative; height: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.play-pop-fill { height: 100%; background: var(--accent); }
.play-pop-fill.ok { background: var(--ok); }
.play-pop-fill.warn { background: var(--warn); }
.play-pop-fill.bad { background: var(--bad); }
.play-pop-pct { position: absolute; right: 7px; top: -1px; font-size: 10px; font-weight: 700; color: var(--fg); }
.play-pnl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.play-pnl-cell { background: var(--bg); border: 1px solid var(--line); border-radius: 3px; padding: 4px 6px; }
.play-pnl-k { color: var(--fg-dim); font-size: 9px; letter-spacing: 0.4px; }
.play-pnl-v { font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 1px; }
.play-pnl-v.pos { color: var(--ok); }
.play-pnl-v.neg { color: var(--bad); }
.play-canvas { width: 100%; display: block; border: 1px solid var(--line); border-radius: 3px; }
.play-narrative {
  font-size: 11px; line-height: 1.4; color: var(--fg-dim);
  border-left: 2px solid var(--accent); padding: 2px 8px; margin: 4px 0;
  font-style: italic;
}
.play-tile.clickable { cursor: pointer; }
.play-tile.clickable:hover { border-color: var(--ok); }
.play-cta {
  color: var(--accent); font-size: 11px; font-weight: 600; text-align: right;
  margin-top: 4px; opacity: 0.7;
}
.play-tile.clickable:hover .play-cta { opacity: 1; }
.play-budget {
  background: var(--bg); border: 1px solid var(--accent);
  border-radius: 4px; padding: 5px 8px; margin-top: 6px;
}
.play-budget .u-label { color: var(--accent); margin-bottom: 4px; }
.play-budget-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.play-budget-cell { font-size: 10px; }
.play-budget-k { color: var(--fg-dim); }
.play-budget-v { color: var(--fg); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 12px; }
.play-budget-warn { color: var(--bad); font-size: 11px; font-style: italic; }
.tp-footer {
  grid-column: 1 / -1; color: var(--fg-dim); font-size: 10.5px; padding: 8px 6px;
  border-top: 1px dashed var(--line); margin-top: 6px;
}
.tp-styles {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 14px; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
}
.tp-styles .u-label { margin-right: 8px; margin-bottom: 0; }
.style-pill {
  background: var(--panel-2); color: var(--fg-dim); border: 1px solid var(--line);
  border-radius: 14px; padding: 4px 12px; font: 11px var(--mono);
  cursor: pointer; letter-spacing: 0.3px;
}
.style-pill:hover { color: var(--fg); border-color: var(--accent); }
.style-pill.active {
  background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 700;
}

/* ---- Optimizer ---- */
.opt-table th, .opt-table td { padding: 4px 9px; font-size: 12px; }
.opt-table .struct-cell { text-align: left; color: var(--accent); font-weight: 600; white-space: nowrap; }
.opt-table td.pos { color: var(--ok); }
.opt-table td.neg { color: var(--bad); }
.opt-table tbody tr:first-child { background: rgba(63,185,80,0.06); }
.opt-table tbody tr:first-child td:first-child { color: var(--ok); font-weight: 700; }
.party-d { color: var(--accent); font-weight: 700; }
.party-r { color: var(--bad); font-weight: 700; }
