:root {
  --bg: #f7f3ea;
  --paper: #fffdf8;
  --ink: #3f2a1f;
  --muted: #6d6055;
  --line: #e8dcc8;
  --accent: #c87412;
  --accent-dark: #a75f0b;
  --navy: #193453;
  --mint: #e3efcf;
  --sand: #f8eacb;
  --soft: #f9f4ea;
  --good: #2f6f43;
  --warn: #8d5a19;
  --bad: #8b3030;
  --shadow: 0 12px 30px rgba(46, 28, 15, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(1100px 520px at 8% -12%, #fff9ee 10%, transparent 68%), var(--bg);
  line-height: 1.5;
}

#stage-content { display: none; }
#pin-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg,#030712,#0b1020);
  padding: 18px;
  z-index: 99;
}
#pin-card {
  width: min(440px,96vw);
  background: #111827;
  border: 1px solid #374151;
  border-radius: 14px;
  padding: 20px;
}
#pin-card h1 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  color: #f8fafc;
}
#pin-card p {
  margin: .25rem 0 .8rem;
  color: #cbd5e1;
}
#pin-card .row { display: flex; gap: 8px; }
#pin-card input {
  flex: 1;
  background: #0b1020;
  color: #fff;
  border: 1px solid #475569;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  letter-spacing: .25em;
}
#pin-card button {
  background: #2563eb;
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
#pin-msg {
  min-height: 1.2em;
  font-size: .9rem;
  color: #fca5a5;
  margin-top: 8px;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; }

.container { width: min(1160px, 94%); margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 800;
}

.brand img.logo { height: 38px; width: auto; border-radius: 8px; }
.brand img.mark { width: 28px; height: 28px; border-radius: 7px; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy small { color: var(--muted); font-weight: 600; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 760;
  border: 1px solid transparent;
  cursor: pointer;
}

.nav-link {
  color: #5e4d3f;
  background: rgba(255,255,255,.82);
  border-color: #ebdfcd;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-dark); }

.btn-ghost {
  background: rgba(255,255,255,.86);
  color: #5f4f40;
  border-color: #e8dcc6;
}

.btn-soft {
  background: #fff4dc;
  color: #7b511f;
  border-color: #ecd1a6;
}

.hero { padding: 44px 0 28px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1.18fr .92fr;
  gap: 30px;
  align-items: start;
}

.eyebrow,
.kicker {
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #8c6536;
  font-size: .78rem;
  font-weight: 800;
}

.hero h1,
.page-head h1 {
  margin: 10px 0 0;
  font-size: clamp(2rem, 5vw, 3.9rem);
  line-height: 1.05;
  letter-spacing: -.01em;
  text-wrap: balance;
}

.hero-sub,
.page-head .sub,
.section-sub {
  margin-top: 14px;
  color: var(--muted);
  max-width: 72ch;
  font-size: 1.03rem;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

.card,
.panel,
.stub-card,
.calc-card,
.summary-card,
.info-card {
  border: 1px solid #eadfcd;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.card,
.panel,
.stub-card,
.calc-card,
.summary-card,
.info-card { padding: 18px; }

.hero-card { background: linear-gradient(180deg, #fff, #fbf5ea); }
.hero-card ul,
.info-card ul,
.stub-card ul { margin: 10px 0 0; padding-left: 18px; color: #5f5145; }

.section { padding: 20px 0 48px; }
.section-head { margin-bottom: 18px; }
.section-head h2 {
  margin: 8px 0 0;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -.01em;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

.tile {
  border: 1px solid #eadfca;
  border-radius: 16px;
  background: #fff;
  padding: 16px;
}

.tile h3, .card h3, .panel h3, .calc-card h2, .summary-card h2 { margin: 0; }
.tile p, .card p, .panel p, .info-card p, .stub-card p { color: var(--muted); }

.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.badge {
  border: 1px solid #e4d7bf;
  background: #fff4dc;
  color: #7e5a2b;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.page-head { padding: 34px 0 18px; }
.page-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  padding-bottom: 48px;
}

.calc-card {
  background: #fffdf9;
}

.field-grid,
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full { grid-column: 1 / -1; }

label {
  font-size: .84rem;
  font-weight: 750;
  color: #5f4f41;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d7cab2;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

input[type="range"] {
  padding: 0;
  border: 0;
  background: transparent;
}

.field-note,
.helper,
.microcopy {
  color: #7d7064;
  font-size: .78rem;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px;
  gap: 10px;
  align-items: center;
}

.summary-pills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-pill {
  border: 1px solid #eadcc6;
  border-radius: 14px;
  background: #fffcf6;
  padding: 14px;
}

.summary-pill .label {
  color: #7f7265;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 800;
}

.summary-pill .value {
  margin-top: 6px;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
}

.gap-guided-layout {
  align-items: start;
}

.guided-input-column {
  display: grid;
  gap: 18px;
}

.sticky-summary {
  position: sticky;
  top: 96px;
  align-self: start;
}

.guided-progress-wrap {
  border-color: #ecd6b5;
  background: linear-gradient(180deg, #fffaf0, #fffdf8);
}

.guided-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.guided-step {
  border: 1px solid #eadfcd;
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.guided-step-num {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: #f3ead8;
  color: #68461d;
  font-weight: 800;
  font-size: .8rem;
  margin-bottom: 6px;
}

.guided-step-title {
  font-weight: 800;
  font-size: .84rem;
  line-height: 1.2;
}

.guided-step-copy {
  margin-top: 4px;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.25;
}

.guided-step.is-active {
  border-color: #d7b680;
  background: #fff5e5;
  box-shadow: inset 0 0 0 1px rgba(200, 116, 18, .08);
}

.guided-step.is-complete .guided-step-num {
  background: #dcefd7;
  color: #2d6a39;
}

.guided-stage-summary {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .88rem;
}

.guided-key-section {
  border-color: #ecd6b5;
  background: #fffaf0;
}

.guided-intro-copy {
  margin: 0 0 12px;
  color: var(--muted);
}

.guided-key-grid {
  margin-bottom: 14px;
}

.guided-card {
  border: 1px solid #eadfcd;
  border-radius: 12px;
  background: #fffdf9;
  margin-bottom: 12px;
  overflow: hidden;
}

.guided-card summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 13px;
  background: #fffaf1;
  border-bottom: 1px solid transparent;
}

.guided-card summary::-webkit-details-marker {
  display: none;
}

.guided-card[open] summary {
  border-bottom-color: #eadfcd;
}

.guided-card-step {
  display: inline-flex;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: #f3ead8;
  color: #68461d;
  font-weight: 800;
  font-size: .82rem;
}

.guided-card-title {
  font-weight: 800;
  font-size: .95rem;
}

.guided-card-body {
  background: #fffdf9;
  padding: 12px;
}

.guided-action-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.guided-mini-card h3 {
  margin-top: 0;
}

.guided-jump {
  margin-top: 10px;
}

.flash-outline {
  animation: flashOutline 1s ease;
  box-shadow: 0 0 0 2px rgba(227,129,28,.4), 0 0 0 6px rgba(227,129,28,.18);
}

@keyframes flashOutline {
  from { box-shadow: 0 0 0 2px rgba(227,129,28,.52), 0 0 0 8px rgba(227,129,28,.24); }
  to { box-shadow: 0 0 0 0 rgba(227,129,28,0), 0 0 0 0 rgba(227,129,28,0); }
}

.flag-list {
  margin: 0;
  padding-left: 18px;
  color: #5f5145;
}

.flag-list li + li { margin-top: 6px; }
.flag-good { color: var(--good); }
.flag-warn { color: var(--warn); }
.flag-bad { color: var(--bad); }

.chart-stack {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.chart-row {
  display: grid;
  gap: 6px;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: .86rem;
  color: #5f5145;
  font-weight: 700;
}

.bar-shell {
  height: 16px;
  border-radius: 999px;
  background: #f0e6d7;
  overflow: hidden;
  display: flex;
}

.bar-segment { height: 100%; }
.bar-essential { background: #d8a459; }
.bar-basic { background: #f1c98f; }
.bar-optional { background: #f5ddba; }
.bar-stable { background: #84c89b; }
.bar-variable { background: #5f96e8; }
.bar-loss { background: #efc0c0; }
.bar-target { background: #d8a459; }

.stub-banner {
  margin-top: 14px;
  border: 1px dashed #ddb97d;
  background: #fff8ea;
  border-radius: 14px;
  padding: 12px 14px;
  color: #6a522f;
}

.stub-status {
  margin-top: 12px;
  border-radius: 12px;
  padding: 11px 13px;
  border: 1px solid #e7dbc4;
  background: #fffdf8;
  color: #5f5145;
  min-height: 48px;
}

.payload-preview {
  margin-top: 12px;
  background: #1f2937;
  color: #e5edf8;
  border-radius: 14px;
  padding: 12px;
  overflow: auto;
  font-size: .82rem;
  line-height: 1.45;
}

.footer {
  padding: 28px 0 44px;
  color: #6d6055;
  font-size: .94rem;
}

.footer-card {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

code.inline {
  background: #f3ead8;
  padding: 2px 6px;
  border-radius: 6px;
}

.notice {
  border: 1px solid #e7dbc4;
  border-radius: 14px;
  background: #fffdf8;
  padding: 14px;
}
.notice.info { background: #fffaf0; }
.notice.success { background: #eef8f1; border-color: #c8e2d0; }
.notice.warning { background: #fff5ef; border-color: #efcfba; }

.checkbox-list {
  display: grid;
  gap: 10px;
}
.checkbox-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.checkbox-list input[type="checkbox"] {
  width: auto;
  margin-top: 4px;
}
.checkbox-helper { display: block; }

.public-capture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.list-tight {
  margin: 10px 0 0;
  padding-left: 18px;
}
.list-tight li + li { margin-top: 6px; }

.disclosure-list {
  margin: 0;
  padding-left: 18px;
}
.disclosure-list li + li { margin-top: 10px; }

@media (max-width: 980px) {
  .hero-grid,
  .page-grid,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .field-grid,
  .result-grid,
  .summary-pills,
  .guided-progress {
    grid-template-columns: 1fr;
  }

  .sticky-summary {
    position: static;
    top: auto;
  }
}

@media (max-width: 700px) {
  .topbar-inner,
  .nav-links {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero { padding-top: 28px; }
  .hero-actions,
  .nav-links { width: 100%; }
  .btn,
  .nav-link { width: 100%; }
  #pin-card .row { flex-direction: column; }
  #pin-card button { width: 100%; }
}
