:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --surface-3: #eaf1f7;
  --border: #cfdae6;
  --border-strong: #aebdcb;
  --text: #102036;
  --muted: #61738c;
  --blue: #087fca;
  --blue-soft: #dff2ff;
  --green: #079455;
  --green-muted: #4dab7c;
  --green-soft: #dcf8e9;
  --amber: #c87400;
  --amber-soft: #fff1d6;
  --red: #dc3d4a;
  --red-soft: #ffe5e8;
  --shadow: 0 16px 42px rgba(25, 48, 78, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081019;
  --surface: #0e1824;
  --surface-2: #121f2d;
  --surface-3: #182838;
  --border: #27394b;
  --border-strong: #3a5268;
  --text: #eff6fc;
  --muted: #91a7bd;
  --blue: #39b8ff;
  --blue-soft: #102f43;
  --green: #26d985;
  --green-muted: #5fb88a;
  --green-soft: #10382b;
  --amber: #ffb53f;
  --amber-soft: #3d2d12;
  --red: #ff6874;
  --red-soft: #421f27;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

button, input, select { font: inherit; }
button, select { color: inherit; }

.site-header {
  height: 68px;
  padding: 0 clamp(16px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--text);
  color: var(--surface);
  border-radius: 7px;
  font: 600 13px/1 "IBM Plex Mono", monospace;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.header-actions, .snapshot-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.snapshot-meta {
  color: var(--muted);
  font: 500 12px/1 "IBM Plex Mono", monospace;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.ready { background: var(--green); }

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  cursor: pointer;
}

.section-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 4px;
  padding: 8px clamp(16px, 3vw, 42px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.tab-button {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.tab-button.is-active {
  background: var(--surface-3);
  color: var(--text);
}

main { padding: clamp(18px, 3vw, 38px); }
.panel { display: none; max-width: 1560px; margin: 0 auto; }
.panel.is-active { display: block; }

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow, .card-label {
  margin: 0 0 6px;
  color: var(--muted);
  font: 500 11px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 3vw, 36px); letter-spacing: -0.03em; }
h2 { margin-bottom: 0; font-size: 18px; }
.as-of { margin: 0; color: var(--muted); font: 12px "IBM Plex Mono", monospace; }

.barometer-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.72fr);
  gap: 12px;
}

.state-card, .allocation-card, .chart-card, .table-card, .detail-card, .scoring-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.state-card, .allocation-card { padding: 20px; min-height: 146px; }
.state-row { display: flex; align-items: center; gap: 12px; }
.state-row strong { font: 600 34px/1 "IBM Plex Mono", monospace; }
.state-card p, .allocation-card p { margin: 14px 0 0; color: var(--muted); }

.badge, .signal {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font: 500 11px "IBM Plex Mono", monospace;
}

.badge.watch, .signal.watch { color: var(--amber); background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 38%, var(--border)); }
.badge.good, .signal.good { color: var(--green); background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 38%, var(--border)); }
.badge.bad, .signal.bad { color: var(--red); background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 38%, var(--border)); }

.allocation-value { display: flex; align-items: baseline; gap: 8px; }
.allocation-value strong { font: 600 32px/1 "IBM Plex Mono", monospace; }
.allocation-value span { color: var(--muted); }
.allocation-bar { height: 9px; margin-top: 16px; overflow: hidden; background: var(--surface-3); border-radius: 999px; }
.allocation-bar span { display: block; width: 0; height: 100%; background: var(--blue); transition: width 0.35s ease; }

.signal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.signal {
  justify-content: space-between;
  gap: 12px;
  border-radius: 7px;
  background: var(--surface);
}

.signal span { color: var(--muted); }
.signal strong { color: inherit; font-size: 12px; }

.chart-card { padding: 18px; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.legend-line { display: inline-block; width: 18px; height: 3px; margin-right: 5px; vertical-align: middle; }
.legend-line.spy { background: var(--blue); }
.legend-line.vvix { background: var(--amber); }
.chart-host { min-height: 330px; margin-top: 14px; }
.chart-host svg { display: block; width: 100%; height: 330px; overflow: visible; }

.watchlist-heading { align-items: center; }
.search-field, .ticker-select { display: grid; gap: 5px; color: var(--muted); font: 500 10px "IBM Plex Mono", monospace; text-transform: uppercase; }
.search-field input, .ticker-select select {
  height: 39px;
  min-width: 220px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  outline: none;
}

.watchlist-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1.35fr) minmax(360px, 0.65fr);
  gap: 12px;
  align-items: start;
}

.table-card { overflow: hidden; }
.table-scroll { max-height: 690px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 7px;
  background: var(--surface-3);
  color: var(--muted);
  text-align: left;
  font: 600 9.5px "IBM Plex Mono", monospace;
  text-transform: uppercase;
  cursor: pointer;
}
td { padding: 8px 7px; border-top: 1px solid var(--border); white-space: nowrap; }
tr[data-ticker] { cursor: pointer; }
tr[data-ticker]:hover, tr.is-selected { background: var(--blue-soft); }
.numeric { text-align: right; font-family: "IBM Plex Mono", monospace; }
.company-cell strong, .company-cell small { display: block; }
.company-cell small { margin-top: 3px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

.score-pill {
  display: inline-flex;
  justify-content: center;
  min-width: 40px;
  padding: 4px 7px;
  border-radius: 5px;
  font: 600 11px "IBM Plex Mono", monospace;
}
.score-pill.high { color: var(--green); background: var(--green-soft); }
.score-pill.mid { color: var(--amber); background: var(--amber-soft); }
.score-pill.low { color: var(--red); background: var(--red-soft); }

.signal-cell { font-weight: 600; font-size: 11px; }
.signal-cell.signal-hold-add { color: var(--green); background: var(--green-soft); border-radius: 4px; padding: 3px 6px; }
.signal-cell.signal-hold { color: var(--green-muted); }
.signal-cell.signal-watch { color: var(--amber); }
.signal-cell.signal-cash { color: var(--red); }

.detail-card { position: sticky; top: 70px; min-height: 420px; padding: 18px; }
.detail-title { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.detail-title h2 { font-size: 23px; }
.detail-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.detail-score { text-align: right; font: 600 26px "IBM Plex Mono", monospace; }
.detail-score small { display: block; color: var(--muted); font: 10px Inter, sans-serif; text-transform: uppercase; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 16px 0; }
.mini-stat { padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; }
.mini-stat span, .mini-stat strong { display: block; }
.mini-stat span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.mini-stat strong { margin-top: 5px; font: 600 13px "IBM Plex Mono", monospace; }
.price-chart { min-height: 210px; }
.price-chart svg { width: 100%; height: 210px; }
.momentum-copy { margin: 12px 0 0; padding: 12px; background: var(--surface-2); border-left: 3px solid var(--blue); color: var(--muted); font-size: 12px; line-height: 1.55; }

.scoring-shell { padding: 18px; min-height: 560px; }
.scoring-top { display: grid; grid-template-columns: minmax(340px, 0.85fr) minmax(420px, 1.15fr); gap: 18px; }
.radar-panel { min-height: 390px; display: grid; place-items: center; }
.radar-panel svg { width: min(100%, 480px); height: 390px; }
.score-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; align-content: start; }
.summary-box { min-height: 112px; padding: 15px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.summary-box.momentum { grid-column: 1 / -1; }
.summary-box span, .summary-box strong { display: block; }
.summary-box span { color: var(--muted); font: 10px "IBM Plex Mono", monospace; text-transform: uppercase; }
.summary-box strong { margin-top: 9px; font: 600 23px "IBM Plex Mono", monospace; }
.summary-box p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dimension-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.dimension-card { padding: 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.dimension-card span, .dimension-card strong { display: block; }
.dimension-card span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.dimension-card strong { margin-top: 6px; font: 600 20px "IBM Plex Mono", monospace; }

.empty-state { min-height: 300px; display: grid; place-items: center; color: var(--muted); text-align: center; }

footer {
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px clamp(18px, 3vw, 38px) 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px 22px;
  color: var(--muted);
  font: 10px "IBM Plex Mono", monospace;
}

@media (max-width: 980px) {
  .signal-grid { grid-template-columns: repeat(2, 1fr); }
  .watchlist-layout, .scoring-top { grid-template-columns: 1fr; }
  .detail-card { position: static; }
  .dimension-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .site-header { height: auto; min-height: 68px; padding-block: 10px; }
  .brand small, .snapshot-meta span:not(.status-dot) { display: none; }
  .section-tabs { overflow-x: auto; }
  main { padding: 15px 10px 28px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .search-field input, .ticker-select select { width: 100%; min-width: 0; }
  .barometer-summary { grid-template-columns: 1fr; }
  .signal-grid { grid-template-columns: 1fr 1fr; }
  .signal { padding-inline: 8px; }
  .chart-host, .chart-host svg { min-height: 250px; height: 250px; }
  .watchlist-layout { display: block; }
  .table-card { margin-bottom: 12px; }
  .table-scroll { max-height: 500px; }
  table { min-width: 960px; }
  .mini-stats { grid-template-columns: repeat(2, 1fr); }
  .scoring-shell { padding: 10px; }
  .scoring-top { grid-template-columns: 1fr; }
  .radar-panel, .radar-panel svg { min-height: 300px; height: 300px; }
  .score-summary, .dimension-grid { grid-template-columns: 1fr 1fr; }
}
