:root {
  --bg0: #e8eef2;
  --bg1: #f5f8fa;
  --surface: #ffffff;
  --ink: #15202b;
  --soft: #5a6a78;
  --muted: #8a99a6;
  --line: #d5dee6;
  --line-strong: #b7c4d0;
  --accent: #e85d4c;
  --accent-soft: rgba(232, 93, 76, 0.14);
  --teal: #0f766e;
  --teal-soft: rgba(15, 118, 110, 0.12);
  --blue: #3b82f6;
  --violet: #6d5bd0;
  --shadow: 0 18px 50px rgba(21, 32, 43, 0.08);
  --radius: 18px;
  --display: "Syne", system-ui, sans-serif;
  --body: "Figtree", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 16px/1.55 var(--body);
  background: var(--bg0);
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.soft { color: var(--soft); }
.hidden { display: none !important; }

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(232, 93, 76, 0.16), transparent 60%),
    radial-gradient(700px 420px at 88% 8%, rgba(15, 118, 110, 0.14), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 42%, #e3eaef);
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(21, 32, 43, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 32, 43, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}

.top {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 24px 8px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: 18px;
  box-shadow: var(--shadow);
}
.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  letter-spacing: -0.04em;
  line-height: 1;
}
.brand h1 span { color: var(--accent); }
.tag {
  margin: 4px 0 0;
  color: var(--soft);
  font-size: 0.92rem;
}
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ghost, .solid {
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.ghost {
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
}
.solid {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 24px rgba(21, 32, 43, 0.18);
}
.ghost:hover, .solid:hover { transform: translateY(-1px); }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 24px 64px;
  display: grid;
  gap: 18px;
}

.hero-line p {
  margin: 0;
  max-width: 40rem;
  font-size: 1.12rem;
  color: var(--soft);
}

.reveal {
  animation: rise 640ms cubic-bezier(.2,.8,.2,1) both;
}
.reveal:nth-of-type(2) { animation-delay: 60ms; }
.reveal:nth-of-type(3) { animation-delay: 120ms; }
.reveal:nth-of-type(4) { animation-delay: 180ms; }
.reveal:nth-of-type(5) { animation-delay: 240ms; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.panel {
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.workbench {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  align-items: stretch;
}
@media (max-width: 960px) {
  .workbench { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.chart-head h2, .chart-head h3 {
  margin: 0;
  font-family: var(--display);
  letter-spacing: -0.03em;
}
.chart-head h2 { font-size: 1.35rem; }
.chart-head h3 { font-size: 1.05rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.chip:hover { border-color: var(--ink); }
.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, .row span:first-child {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--soft);
}
.row { display: flex; justify-content: space-between; align-items: center; }
.field input[type="text"], .field select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  width: 100%;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.field input[type="text"]:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); }

.toggles { display: grid; gap: 8px; margin-bottom: 14px; }
.toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.toggle:has(input:checked) {
  border-color: rgba(232, 93, 76, 0.45);
  background: var(--accent-soft);
}

.history-block { margin-top: 4px; }
#history {
  width: 100%;
  height: 72px;
  display: block;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fafc, #eef3f7);
  border: 1px solid var(--line);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
.metric {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, #fff, #f7fafc);
}
.metric.accent {
  border-color: rgba(232, 93, 76, 0.35);
  background: linear-gradient(180deg, #fff7f5, #ffeae6);
}
.k {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.v {
  margin-top: 6px;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.chart-block { margin-top: 4px; }
.chart-block.compact { margin-top: 0; }
#pmf, #cdf {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  background: linear-gradient(180deg, #fcfdfe, #f3f7fa);
  border: 1px solid var(--line);
}
.split-charts {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 860px) {
  .split-charts { grid-template-columns: 1fr; }
}

.noul { display: grid; gap: 12px; padding-top: 4px; }
.noul-row { display: grid; gap: 6px; }
.noul-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}
.noul-bar {
  height: 12px;
  border-radius: 999px;
  background: #e8eef3;
  overflow: hidden;
}
.noul-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #14b8a6);
  transition: width 280ms ease;
}

.strip {
  display: grid;
  grid-template-columns: 1.05fr 1.15fr 1fr;
  gap: 18px;
}
@media (max-width: 960px) {
  .strip { grid-template-columns: 1fr; }
}
.crps-big {
  font-size: clamp(2.6rem, 5vw, 3.5rem);
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--ink);
}
.meter {
  margin: 14px 0 10px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7eef3;
}
.meter > i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #ff8a70);
  transition: width 280ms ease;
}

.drivers, .holdouts { display: grid; gap: 8px; }
.driver, .hold {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
}
.driver.active, .hold.lead {
  border-color: rgba(15, 118, 110, 0.35);
  background: var(--teal-soft);
}

.viz {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
}
@media (max-width: 960px) {
  .viz { grid-template-columns: 1fr; }
}
.radar-mount, .scatter-mount {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
}
.radar-mount svg, .scatter-mount svg { width: 100%; max-width: 420px; height: auto; }
.dot { cursor: crosshair; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 0.84rem;
  color: var(--soft);
}
.sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 99px;
  margin-right: 6px;
  vertical-align: middle;
}
.sw.a { background: var(--ink); }
.sw.h { background: var(--blue); }
.sw.b { background: var(--violet); }
.tip { margin-top: 8px; min-height: 1.2em; }

.pill {
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #fff;
  color: var(--soft);
  white-space: nowrap;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
}
th {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
tr.me td {
  background: linear-gradient(90deg, rgba(232, 93, 76, 0.1), transparent);
  font-weight: 700;
}
.bar {
  height: 8px;
  background: #e8eef3;
  border-radius: 999px;
  overflow: hidden;
  min-width: 90px;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ink), #3d4f63);
  border-radius: inherit;
}

.scenario-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.scen {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  transition: transform 160ms ease, border-color 160ms ease;
}
.scen:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.scen.win {
  border-color: rgba(15, 118, 110, 0.4);
  background: linear-gradient(180deg, #f3fbf9, #fff);
}
.scen .id {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.foot-note {
  margin: 16px 0 0;
  color: var(--soft);
  font-size: 0.88rem;
}

.foot {
  max-width: 1180px;
  margin: 0 auto 40px;
  padding: 0 24px;
  display: flex;
  gap: 10px;
  color: var(--soft);
  font-size: 0.88rem;
}
.foot a:hover { color: var(--ink); text-decoration: underline; }

.tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  max-width: 240px;
  box-shadow: 0 12px 30px rgba(21, 32, 43, 0.25);
}

/* ---- layout polish: equal heights, no empty cells ---- */
.mark { background: none; box-shadow: var(--shadow); border-radius: 14px; overflow: hidden; }
.mark svg { display: block; }
.controls { display: flex; flex-direction: column; }
.controls .history-block { margin-top: auto; padding-top: 12px; }
.small { font-size: 0.86rem; margin: 0; }
.push-down { margin-top: auto; padding-top: 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--shadow);
  min-height: 132px;
}
.stat .big {
  font-family: var(--display);
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.stat:nth-child(1) .big { color: var(--accent); }
.stat .lab { font-weight: 600; line-height: 1.3; }
.stat .sub { margin-top: auto; font-size: 0.8rem; color: var(--muted); }

.trio, .duo { display: grid; gap: 18px; }
.trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.duo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { display: flex; flex-direction: column; min-height: 340px; }
.card .chart-head { align-items: center; }
.trio .radar-mount { min-height: 0; flex: 1; }
.trio .radar-mount svg { max-width: 300px; }
.trio .legend { justify-content: center; margin-top: 8px; }

.holdouts { display: grid; gap: 10px; }
.hold { flex-direction: column; gap: 4px; }
.hold span:first-child { font-weight: 600; }

.mk-row { display: grid; gap: 6px; margin-bottom: 14px; }
.mk-row .mk-label { display: flex; justify-content: space-between; font-size: 0.88rem; }
.mk-bar { height: 14px; border-radius: 99px; background: #e8eef3; overflow: hidden; }
.mk-bar > i { display: block; height: 100%; border-radius: inherit; }
.mk-bar.grey > i { background: #8a8f98; }
.mk-bar.blue > i { background: linear-gradient(90deg, #2b6cb0, #4c8fd6); }

.code {
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: #0f1720;
  color: #e6edf3;
  font: 12.5px/1.6 var(--mono);
  overflow-x: auto;
}
.bullets { margin: 0; padding-left: 18px; display: grid; gap: 10px; color: var(--ink); }
.bullets li::marker { color: var(--accent); }

@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trio, .duo { grid-template-columns: 1fr; }
  .scenario-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { min-height: 0; }
}

/* small screens: stack the highlight cards and the trio so nothing is clipped */
@media (max-width: 900px) {
  .trio { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .stats, .duo { grid-template-columns: 1fr; }
  .top, main { padding-left: 16px; padding-right: 16px; }
  .card { min-height: 0; }
}
