:root {
  /* Warm-tinted dark neutrals — every surface leans toward the amber hue (~80) */
  --bg:          oklch(0.176 0.006 80);
  --panel:       oklch(0.198 0.007 80);
  --card:        oklch(0.208 0.0075 80);
  --tile:        oklch(0.238 0.008 80);
  --tile-2:      oklch(0.226 0.008 80);
  --border:      oklch(0.330 0.012 80);
  --border-soft: oklch(0.268 0.010 80);
  --text:        oklch(0.965 0.006 85);
  --text-dim:    oklch(0.745 0.013 82);
  --text-faint:  oklch(0.560 0.012 80);

  --accent:        oklch(0.820 0.135 78);   /* signature warm gold-amber */
  --accent-soft:   oklch(0.305 0.052 78);
  --accent-border: oklch(0.460 0.080 78);

  --pos:        oklch(0.800 0.140 158);     /* healthy green */
  --pos-soft:   oklch(0.300 0.055 158);
  --pos-border: oklch(0.430 0.080 158);
  --neg:        oklch(0.700 0.170 25);      /* profit leak red */
  --neg-soft:   oklch(0.300 0.070 25);
  --neg-border: oklch(0.450 0.100 25);

  --track: oklch(0.300 0.010 80);
  --thumb: oklch(0.975 0.012 85);

  --radius:    16px;
  --radius-sm: 11px;

  --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', sans-serif;
  --sans:         'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --mono:         'Spline Sans Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* 4pt spacing scale, semantic */
  --space-2xs: 4px;  --space-xs: 8px;   --space-sm: 12px; --space-md: 16px;
  --space-lg: 24px;  --space-xl: 32px;  --space-2xl: 48px; --space-3xl: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1, "cv05" 1;
}

body {
  background:
    radial-gradient(1100px 560px at 82% -12%, color-mix(in oklch, var(--accent) 9%, transparent), transparent 62%),
    var(--bg);
  min-height: 100vh;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* page wrapper: caps width so the layout never stretches edge-to-edge */
.page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 22px 28px;
}

/* ---------------- HERO ---------------- */
.hero {
  padding: clamp(40px, 7vw, 76px) 0 clamp(26px, 4vw, 40px);
}
.hero-kicker {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5.4vw, 3.55rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.02;
  max-width: 16ch;
}
.hero-sub {
  margin-top: 18px;
  max-width: 54ch;
  font-size: clamp(1rem, 1.5vw, 1.12rem);
  line-height: 1.55;
  color: var(--text-dim);
}

.app {
  display: grid;
  grid-template-columns: 366px 1fr;
  gap: 20px;
  align-items: start;
  margin-top: clamp(20px, 3vw, 32px);
}

/* ---------------- PANELS / CARDS ---------------- */
.panel, .card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.controls-panel {
  padding: var(--space-lg) var(--space-lg);
  background: var(--panel);
}

.panel-head, .card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: var(--space-md);
}
.card-head { margin-bottom: var(--space-lg); }

.panel-head h1, .panel-head h3, .card-head h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel-hint {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-faint);
  margin-bottom: 14px;
}
.section-gap {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
}

.panel-icon, .card-icon {
  font-size: 14px;
  display: grid;
  place-items: center;
}
.card-icon {
  width: 24px; height: 24px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
}
.card-icon.econ { background: var(--accent-soft); color: var(--accent); }
.card-icon.proj, .card-icon.rec { background: transparent; }

.card-tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
}

/* ---------------- SLIDERS ---------------- */
.slider-list { display: flex; flex-direction: column; gap: 22px; }

.slider-row { display: flex; flex-direction: column; gap: 10px; }

.slider-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.slider-label {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
}
.slider-label small {
  display: block;
  color: var(--text-faint);
  font-weight: 400;
  font-size: 10.5px;
  margin-top: 1px;
}
.slider-readout {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}
.slider-baseline {
  font-size: 11px;
  color: var(--text-faint);
}
.slider-value {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
}
.slider-value.changed { color: var(--accent); }
.slider-value.good { color: var(--pos); }

.slider-goal {
  font-size: 10px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: -3px;
}
.slider-goal::before {
  content: "○";
  font-size: 9px;
  color: var(--text-faint);
}
.slider-goal.met { color: var(--pos); }
.slider-goal.met::before { content: "✓"; color: var(--pos); }

/* custom range track */
.range-wrap { position: relative; height: 18px; display: flex; align-items: center; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--track);
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
/* filled portion via gradient; --fill = %, --fill-color = amber or green */
input[type="range"] {
  --fill-color: var(--accent);
  background: linear-gradient(to right, var(--fill-color) 0%, var(--fill-color) var(--fill, 0%), var(--track) var(--fill, 0%), var(--track) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--thumb);
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.2);
  cursor: grab;
  transition: transform .1s ease;
}
input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--thumb);
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  cursor: grab;
}
/* baseline tick marker */
.baseline-tick {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 10px;
  background: var(--text-faint);
  opacity: .55;
  border-radius: 2px;
  z-index: 1;
  pointer-events: none;
}

/* ---------------- OFFER BLOCK ---------------- */
.offer-block {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}
.offer-head {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.offer-grid { display: flex; flex-direction: column; gap: 10px; }
.offer-field { display: flex; flex-direction: column; gap: 5px; }
.offer-field span {
  font-size: 11px;
  color: var(--text-dim);
}
.offer-field input {
  background: var(--tile);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 10px;
  outline: none;
}
.offer-field input:focus { border-color: var(--accent-border); }

.panel-actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.btn {
  width: 100%;
  background: var(--tile);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { color: var(--text); border-color: var(--accent-border); background: var(--accent-soft); }
.btn-primary {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 16%, transparent); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-faint);
  font-size: 11.5px;
  padding: 6px;
}
.btn-ghost:hover { background: transparent; color: var(--text-dim); border-color: transparent; }

/* ---------------- RESULTS ---------------- */
.results { display: flex; flex-direction: column; gap: 18px; }

.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text-dim);
}
.status-bar.modeling { border-color: var(--accent-border); color: var(--text); }
.status-icon { font-size: 13px; }

.card { padding: 20px; }

/* ---------------- HOW-TO CARD ---------------- */
.card-icon.how { background: var(--accent-soft); }
.howto-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}
.howto-list li { padding-left: 4px; }
.howto-list strong { color: var(--text); font-weight: 600; }
.howto-list em { font-style: normal; color: var(--accent); }
.ink-pos { color: var(--pos); font-weight: 600; }
.ink-acc { color: var(--accent); font-weight: 600; }

/* ---------------- TOAST ---------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--tile);
  border: 1px solid var(--accent-border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.metric {
  background: var(--tile-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 78px;
  transition: background-color .3s ease, border-color .3s ease;
}
.m-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.m-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.05;
  transition: color .3s ease;
}
.m-value.accent { color: var(--accent); }
.m-value.pos { color: var(--pos); }
.m-value.neg { color: var(--neg); }
.m-sub { font-size: 10.5px; color: var(--text-faint); margin-top: -1px; }

.metric.highlight {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.metric.roas-tile {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.metric.profit-tile.is-neg {
  background: var(--neg-soft);
  border-color: var(--neg-border);
}
.metric.profit-tile.is-pos {
  background: color-mix(in oklch, var(--pos) 7%, transparent);
  border-color: color-mix(in oklch, var(--pos) 24%, transparent);
}

/* ---------------- RECOMMENDED PRICE ---------------- */
.rec-card {
  background: linear-gradient(135deg, color-mix(in oklch, var(--accent) 9%, transparent), color-mix(in oklch, var(--accent) 2.5%, transparent));
  border: 1px solid var(--accent-border);
}
.rec-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.rec-desc strong { color: var(--accent); }
.rec-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.rec-price #recPrice {
  font-family: var(--mono);
  font-size: 38px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -1px;
}
.rec-unit { font-size: 14px; color: var(--text-faint); }
.rec-current {
  font-size: 12px;
  color: var(--text-faint);
}
.rec-current strong { color: var(--text-dim); }
.rec-flag { color: var(--accent); }
.rec-flag.ok { color: var(--pos); }

.app-footer {
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  padding: 6px 0 4px;
  line-height: 1.5;
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .hero { padding: 40px 0 24px; }
  .hero h1 { font-size: 28px; }
}
@media (max-width: 520px) {
  .page { padding: 0 14px 20px; }
  .app { gap: 16px; }
  .metric-grid { grid-template-columns: 1fr; }
  .rec-price #recPrice { font-size: 32px; }
  .scn-row { grid-template-columns: 1fr auto; }
  .scn-side, .scn-bar { display: none; }
}

/* ---------------- DIAGNOSIS CARD ---------------- */
.diagnosis-card {
  background: linear-gradient(135deg, color-mix(in oklch, var(--neg) 11%, transparent), color-mix(in oklch, var(--neg) 2.5%, transparent));
  border: 1px solid var(--neg-border);
}
.diagnosis-card.is-healthy {
  background: linear-gradient(135deg, color-mix(in oklch, var(--pos) 11%, transparent), color-mix(in oklch, var(--pos) 2.5%, transparent));
  border-color: color-mix(in oklch, var(--pos) 32%, transparent);
}
.diag-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.diag-eyebrow {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--neg); font-weight: 600;
}
.is-healthy .diag-eyebrow { color: var(--pos); }
.diag-name {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 700; letter-spacing: -0.025em; line-height: 1.05;
}
.diag-bottleneck {
  font-size: 14px; line-height: 1.55; color: var(--text);
  margin-bottom: 18px; max-width: 64ch;
}
.diag-impact { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--tile-2); border: 1px solid var(--border-soft);
  border-radius: 9px; padding: 8px 12px; min-width: 90px;
}
.chip-k { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-faint); }
.chip-v { font-family: var(--mono); font-size: 14px; font-weight: 500; }

/* ---------------- KPI TILES (green when target met, amber when not) ---------------- */
.metric.kpi.is-good {
  background: color-mix(in oklch, var(--pos) 8%, transparent);
  border-color: color-mix(in oklch, var(--pos) 28%, transparent);
}
.metric.kpi.is-good .m-value { color: var(--pos); }
.metric.kpi.is-bad {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.metric.kpi.is-bad .m-value { color: var(--accent); }

/* ---------------- DEEP DIVE / TABS ---------------- */
.deep-dive { padding: 0; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--border-soft); }
.tab {
  flex: 1; background: transparent; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: var(--text-dim); padding: 14px 10px;
  border-bottom: 2px solid transparent; transition: all .15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; padding: 20px; }
.tab-panel.active { display: block; }
.panel-intro { font-size: 12px; line-height: 1.5; color: var(--text-dim); margin-bottom: 16px; }
.panel-intro em { font-style: normal; color: var(--accent); font-weight: 600; }

/* ---------------- SCENARIO TABLE ---------------- */
.scenario-table { display: flex; flex-direction: column; gap: 4px; }
.scn-row {
  display: grid;
  grid-template-columns: 84px 96px 1fr 56px 44px;
  align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 9px;
  background: var(--tile-2); border: 1px solid transparent;
}
.scn-row.top { background: var(--accent-soft); border-color: var(--accent-border); }
.scn-side { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-faint); }
.scn-label { font-size: 12px; font-weight: 500; }
.scn-bar { height: 6px; background: var(--track); border-radius: 999px; overflow: hidden; }
.scn-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.scn-row.top .scn-fill { background: var(--pos); }
.scn-result { font-family: var(--mono); font-size: 13px; text-align: right; }
.scn-lift { font-family: var(--mono); font-size: 12px; color: var(--pos); text-align: right; font-weight: 500; }

/* ---------------- ACTION PLAN ---------------- */
.action-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 16px; }
.action-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); }
.action-name { font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--accent); }
.action-steps { display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; gap: 12px; background: var(--tile-2); border: 1px solid var(--border-soft); border-radius: 10px; padding: 14px; }
.step-n {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
}
.step-body { display: flex; flex-direction: column; gap: 5px; }
.step-what { font-size: 13px; font-weight: 600; color: var(--text); }
.step-line { font-size: 12px; line-height: 1.45; color: var(--text-dim); }
.step-line span {
  display: inline-block; min-width: 56px;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-faint); font-weight: 600;
}
.step-line.out span { color: var(--pos); }

/* ---------------- FORMULA LIST ---------------- */
.formula-list { display: flex; flex-direction: column; gap: 2px; }
.frm-row {
  display: grid; grid-template-columns: 1.1fr 1.6fr auto;
  align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 8px; background: var(--tile-2);
}
.frm-label { font-size: 12px; font-weight: 600; color: var(--text); }
.frm-eq { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.frm-val { font-family: var(--mono); font-size: 13px; text-align: right; color: var(--accent); }
@media (max-width: 600px) {
  .frm-row { grid-template-columns: 1fr auto; }
  .frm-eq { display: none; }
}

/* ---------------- MOTION: one orchestrated load-in ---------------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero, .howto-card, .app {
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero       { animation-delay: 0.02s; }
.howto-card { animation-delay: 0.10s; }
.app        { animation-delay: 0.18s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
