@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,900&family=Spline+Sans+Mono:wght@400;500;600&family=Spline+Sans:wght@400;500;600;700&display=swap');

:root {
  --ink:            #0d1b2a;
  --paper:          #f4f1ea;
  --card:           #ffffff;
  --handled:        #1b7f5a;
  --handled-soft:   #d6ece0;
  --handled-tint:   rgba(27,127,90,0.06);
  --abandoned:      #c1452b;
  --abandoned-soft: #f6dcd4;
  --abandoned-tint: rgba(193,69,43,0.06);
  --asa:            #d98a1f;
  --asa-soft:       #f7e6c8;
  --asa-tint:       rgba(217,138,31,0.08);
  --ink-tint:       rgba(13,27,42,0.05);
  --acceptable:     #7a9cb8;
  --acceptable-soft:#d8e6f0;
  --line:           #dcd6c9;
  --muted:          #5c6670;
  --sidebar-w:      340px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Spline Sans', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 20% 0%, rgba(27,127,90,0.05), transparent 40%),
    radial-gradient(circle at 90% 100%, rgba(193,69,43,0.05), transparent 45%);
  min-height: 100vh;
}

/* ─── PAGE SHELL ──────────────────────────────────────── */
.page { max-width: 1440px; margin: 0 auto; }

/* ─── HEADER ──────────────────────────────────────────── */
.page-header {
  border-bottom: 2px solid var(--ink);
  padding: 36px 40px 28px;
}
.header-inner { max-width: 860px; }
.kicker {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
h1 {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.04;
  letter-spacing: -.02em;
}
h1 em { font-style: italic; color: var(--handled); }
.sub {
  margin-top: 14px;
  font-size: 16px;
  max-width: 64ch;
  color: #2c3742;
  line-height: 1.6;
}

/* ─── TWO-COLUMN BODY ─────────────────────────────────── */
.page-body {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 160px);
}

/* ─── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.sidebar-inner::-webkit-scrollbar { width: 4px; }
.sidebar-inner::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.sidebar-brand {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

/* ─── SLIDER SECTIONS ─────────────────────────────────── */
.slider-section { margin-bottom: 6px; }

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  border-bottom: 1.5px solid var(--ink);
  padding: 0 0 8px;
  margin-bottom: 14px;
  cursor: pointer;
  gap: 8px;
}
.section-label {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 600;
}
.chevron {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform .25s ease;
}
.section-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

.slider-group-body {
  overflow: hidden;
  transition: max-height .3s ease, opacity .25s ease;
  max-height: 1200px;
  opacity: 1;
}
.slider-group-body.collapsed {
  max-height: 0;
  opacity: 0;
}

.slider-item { margin-bottom: 16px; }
.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 7px;
}
.slider-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.val {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 12px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Slider track & thumb */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 8px;
  background: var(--line);
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--card);
  box-shadow: 0 1px 4px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.08);
}
input[type=range]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--card);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
input[type=range]:focus-visible {
  outline: 2px solid var(--asa);
  outline-offset: 2px;
  border-radius: 8px;
}

.method-note {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.c-handled   { color: var(--handled); }
.c-asa       { color: var(--asa); }
.c-abandoned { color: var(--abandoned); }

/* ─── SIDEBAR SUMMARY STRIP ───────────────────────────── */
.sidebar-summary {
  border-top: 1px solid var(--line);
  padding: 14px 22px 18px;
  background: var(--paper);
  flex-shrink: 0;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
}
.summary-row + .summary-row { border-top: 1px solid var(--line); }
.gap-row {
  border-left: 3px solid var(--asa);
  margin-left: -10px;
  padding-left: 7px;
}
.summary-label {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.summary-val {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -.01em;
  color: var(--ink);
}
.gap-row .summary-val { color: var(--abandoned); }

/* ─── RESULTS PANEL ───────────────────────────────────── */
.results {
  flex: 1;
  min-width: 0;
  padding: 36px 40px 80px;
}

/* ─── STAGE HEADERS ───────────────────────────────────── */
.stage { margin: 44px 0 0; }
.stage:first-child { margin-top: 0; }
.stage-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}
.stage-num {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--card);
  background: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stage-head h3 {
  font-family: 'Fraunces', serif;
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 600;
  letter-spacing: -.01em;
}
.stage-rule {
  height: 1px;
  background: var(--line);
  margin-bottom: 20px;
}
.stage-intro {
  font-size: 15px;
  color: #2c3742;
  max-width: 68ch;
  margin-bottom: 18px;
  line-height: 1.65;
}
.eyebrow-label {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 28px 0 6px;
  font-weight: 600;
}

/* ─── KPI CARDS ───────────────────────────────────────── */
.grid { display: grid; gap: 16px; margin-bottom: 8px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 22px 20px;
  position: relative;
  overflow: hidden;
}
.card.handled   { background: linear-gradient(160deg, var(--card) 60%, var(--handled-tint)); }
.card.asa       { background: linear-gradient(160deg, var(--card) 60%, var(--asa-tint)); }
.card.abandoned { background: linear-gradient(160deg, var(--card) 60%, var(--abandoned-tint)); }

.card.accent-top::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  border-radius: 16px 16px 0 0;
}
.card.handled::before   { background: var(--handled); }
.card.abandoned::before { background: var(--abandoned); }
.card.asa::before       { background: var(--asa); }

.tag {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.big {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: clamp(32px, 3.2vw, 44px);
  line-height: 1;
  letter-spacing: -.02em;
}
.unit {
  font-size: 13px;
  color: var(--muted);
  margin-top: 7px;
  font-weight: 500;
}

/* ─── DEMAND BAR ──────────────────────────────────────── */
.demand-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
}
.demand-card .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.demand-card .head .title {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 600;
}
.demand-card .head .total {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 13px;
  color: var(--muted);
}
.bar {
  display: flex;
  height: 80px;
  border-radius: 14px;
  overflow: hidden;
  margin: 16px 0 14px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.bar .seg {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 20px;
  color: #fff;
  transition: flex-basis .5s cubic-bezier(.2,.7,.2,1);
  min-width: 0;
}
.bar .seg .lab {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  opacity: .9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar .seg .figure {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.seg.handled    { background: var(--handled); }
.seg.abandoned  { background: var(--abandoned); }
.seg.acceptable { background: var(--acceptable); }
.legend {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.legend span { display: flex; align-items: center; gap: 7px; }

/* ─── ERLANG FLOW ─────────────────────────────────────── */
.flow {
  display: flex;
  align-items: stretch;
  margin: 0 0 4px;
}
.flow-step {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  min-width: 0;
}
.flow-step.asa-tint     { background: var(--asa-tint); }
.flow-step.handled-tint { background: var(--handled-tint); }
.flow-step.ink-tint     { background: var(--ink-tint); }

.flow-step .t {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.5;
}
.flow-step .v {
  font-family: 'Fraunces', serif;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
}
.flow-step .d {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 7px;
  line-height: 1.4;
}
.flow-arrow {
  display: grid;
  place-items: center;
  padding: 0 10px;
  color: var(--muted);
  flex-shrink: 0;
}
.flow-arrow svg { width: 28px; height: 28px; }

/* ─── FC-LIGHT (cost compare cards) ──────────────────── */
.fc-light {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
}
.fc-light.danger {
  border-color: var(--abandoned-soft);
  background: linear-gradient(160deg, #fff, var(--abandoned-soft));
}
.fc-light.recommended {
  border-color: var(--asa-soft);
  background: linear-gradient(160deg, #fff, var(--asa-soft));
}
.fc-light .t {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.fc-light .v {
  font-family: 'Fraunces', serif;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
}
.fc-light .d { font-size: 13px; color: #3a4650; margin-top: 10px; }
.fc-light .pop {
  color: var(--abandoned);
  font-weight: 700;
  font-family: 'Spline Sans Mono', monospace;
}
.fc-light .pop-amber {
  color: var(--asa);
  font-weight: 700;
  font-family: 'Spline Sans Mono', monospace;
}

/* ─── COST LAYERS ─────────────────────────────────────── */
.layerbar {
  display: flex;
  height: 50px;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 0 16px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.layerbar .seg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Spline Sans Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  transition: flex-basis .5s cubic-bezier(.2,.7,.2,1);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.seg.l_agent { background: var(--handled); }
.seg.l_mgmt  { background: var(--asa); }
.seg.l_infra { background: var(--abandoned); }

.layer-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.lrow {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 16px 18px;
  position: relative;
}
.lrow::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 4px;
  border-radius: 0 4px 4px 0;
}
.lrow.l_agent::before { background: var(--handled); }
.lrow.l_mgmt::before  { background: var(--asa); }
.lrow.l_infra::before { background: var(--abandoned); }

.lrow .t {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
  padding-left: 10px;
}
.lrow .v {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
  padding-left: 10px;
}
.lrow .d {
  font-size: 11px;
  color: var(--muted);
  margin-top: 7px;
  line-height: 1.45;
  padding-left: 10px;
}
.lrow .pct {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 13px;
  color: var(--muted);
  margin-left: 7px;
}

/* ─── INSIGHT BLOCK ───────────────────────────────────── */
.insight {
  margin-top: 44px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 22px;
  padding: 42px 44px;
  position: relative;
  overflow: hidden;
}
.insight::after {
  content: "";
  position: absolute;
  right: -60px; top: -60px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217,138,31,.35), transparent 70%);
  pointer-events: none;
}
.insight .eyebrow {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  opacity: .65;
  margin-bottom: 14px;
}
.insight h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: clamp(22px, 2.8vw, 32px);
  line-height: 1.2;
  max-width: 28ch;
  letter-spacing: -.01em;
  margin-bottom: 16px;
}
.insight > p {
  font-size: 16px;
  max-width: 64ch;
  opacity: .88;
  line-height: 1.65;
  margin-bottom: 28px;
}
.insight .hl   { color: #f1c277; font-weight: 600; }
.insight .hl-r { color: #f0a08e; font-weight: 600; }

.insight-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  position: relative;
  z-index: 2;
}
.forecast { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fc {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 14px;
  padding: 18px 20px;
}
.fc .t {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  opacity: .6;
  margin-bottom: 9px;
}
.fc .v {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}
.fc .d { font-size: 12.5px; opacity: .78; margin-top: 8px; line-height: 1.45; }

.marginal {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(217,138,31,.3);
  border-radius: 16px;
  padding: 22px 24px;
  min-width: 190px;
  max-width: 230px;
}
.marginal-num {
  font-family: 'Fraunces', serif;
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
  color: #f1c277;
  margin-bottom: 10px;
}
.marginal-txt .h {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  opacity: .7;
  margin-bottom: 6px;
}
.marginal-txt .b { font-size: 13px; opacity: .85; line-height: 1.5; }
.marginal-txt .split {
  font-family: 'Spline Sans Mono', monospace;
  font-size: 11px;
  opacity: .65;
  margin-top: 8px;
  line-height: 1.5;
}

/* ─── FOOTER ──────────────────────────────────────────── */
footer {
  margin-top: 48px;
  font-size: 12.5px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
footer .brand {
  font-family: 'Spline Sans Mono', monospace;
  letter-spacing: .1em;
}

/* ─── ANIMATION ───────────────────────────────────────── */
.pulse { animation: pulse .5s ease; }
@keyframes pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 960px) {
  .page-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-inner { padding: 20px 20px 10px; }
  .sidebar-summary { position: static; }
  .results { padding: 28px 20px 60px; }
  .g3 { grid-template-columns: repeat(2, 1fr); }
  .layer-rows { grid-template-columns: 1fr; }
  .insight-grid { grid-template-columns: 1fr; }
  .marginal { max-width: 100%; }
}
@media (max-width: 640px) {
  .page-header { padding: 24px 20px 20px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .forecast { grid-template-columns: 1fr; }
  .flow { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); padding: 4px 0; }
}
