*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f4f2ee;
  --border: #e4e0d8;
  --text: #1c1a17;
  --text-2: #57524a;
  --text-3: #8a8378;
  --accent: #b0442b;
  --accent-soft: #fdeee9;
  --good: #2f6f4f;
  --good-soft: #e8f3ec;
  --warn: #8a6414;
  --warn-soft: #fbf1dc;
  --bad: #a3342c;
  --bad-soft: #fbeae8;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 268px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --surface: #1c1a17;
    --surface-2: #24211d;
    --border: #35312b;
    --text: #f2efe9;
    --text-2: #b3aaa0;
    --text-3: #837b70;
    --accent: #e8734f;
    --accent-soft: #33201a;
    --good: #6ac08e;
    --good-soft: #172b21;
    --warn: #d6a94a;
    --warn-soft: #2c2418;
    --bad: #e0776b;
    --bad-soft: #2e1d1b;
  }
}

html { scroll-behavior: smooth; scroll-padding-top: 24px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 28px 0 40px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { padding: 0 24px 22px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.brand h1 { font-size: 15px; margin: 0; letter-spacing: -0.01em; }
.brand p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-3); }

.nav { list-style: none; margin: 0; padding: 0 12px; }
.nav li { margin: 1px 0; }
.nav a {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 12px; border-radius: 7px;
  color: var(--text-2); text-decoration: none;
  font-size: 13.5px; line-height: 1.4;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav .num { font-family: var(--mono); font-size: 11px; color: var(--text-3); flex: 0 0 18px; }
.nav a.active .num { color: var(--accent); }
.nav-group { padding: 16px 24px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3); font-weight: 650; }

.main { flex: 1; min-width: 0; padding: 56px 0 120px; }
.wrap { max-width: 780px; margin: 0 auto; padding: 0 40px; }

/* ---------- typography ---------- */
h2 { font-size: 27px; letter-spacing: -0.02em; margin: 0 0 6px; line-height: 1.25; }
h3 { font-size: 17.5px; letter-spacing: -0.01em; margin: 34px 0 10px; }
h4 { font-size: 14.5px; margin: 22px 0 8px; color: var(--text); }
p { margin: 0 0 14px; color: var(--text-2); }
strong { color: var(--text); font-weight: 600; }
a { color: var(--accent); }
ul, ol { color: var(--text-2); padding-left: 20px; margin: 0 0 14px; }
li { margin-bottom: 7px; }
code {
  font-family: var(--mono); font-size: 0.855em;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; color: var(--text);
}

section { margin-bottom: 76px; scroll-margin-top: 24px; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; font-weight: 600;
}
.lede { font-size: 17px; color: var(--text-2); margin-bottom: 26px; line-height: 1.6; }

/* ---------- hero ---------- */
.hero { border-bottom: 1px solid var(--border); padding-bottom: 40px; margin-bottom: 52px; }
.hero h2 { font-size: 38px; line-height: 1.15; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 28px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kpi .v { font-size: 21px; font-weight: 650; letter-spacing: -0.02em; display: block; }
.kpi .l { font-size: 11.5px; color: var(--text-3); margin-top: 2px; display: block; line-height: 1.35; }

/* ---------- cards & callouts ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 20px 22px; margin: 18px 0; }
.card h4 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.note {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 8px 8px 0; padding: 14px 18px; margin: 18px 0;
}
.note.good { border-color: var(--good); background: var(--good-soft); }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note.bad  { border-color: var(--bad);  background: var(--bad-soft); }
.note p { margin: 0; font-size: 14.5px; color: var(--text-2); }
.note p + p { margin-top: 9px; }
.note .tag { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 650; display: block; margin-bottom: 5px; color: var(--accent); }
.note.good .tag { color: var(--good); }
.note.warn .tag { color: var(--warn); }
.note.bad .tag  { color: var(--bad); }

/* ---------- tables ---------- */
.scroller { overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; min-width: 520px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; white-space: nowrap; }
td { color: var(--text-2); }
td strong { color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
.num-cell { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.pill.g { background: var(--good-soft); color: var(--good); }
.pill.w { background: var(--warn-soft); color: var(--warn); }
.pill.b { background: var(--bad-soft); color: var(--bad); }

/* ---------- phases ---------- */
.phase { display: flex; gap: 18px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.phase:last-child { border-bottom: none; }
.phase .marker { flex: 0 0 60px; }
.phase .marker .n { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 650; }
.phase .marker .t { font-size: 11.5px; color: var(--text-3); display: block; margin-top: 1px; }
.phase .body { flex: 1; min-width: 0; }
.phase .body h4 { margin: 0 0 5px; font-size: 15.5px; }
.phase .body p { margin: 0 0 8px; font-size: 14.5px; }
.phase .body ul { font-size: 14px; margin-bottom: 0; }

/* ---------- calculator ---------- */
.calc { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin: 22px 0; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 640px) { .calc-grid { grid-template-columns: 1fr; } }
.field { margin-bottom: 13px; }
.field label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; gap: 10px; }
.field label .val { font-family: var(--mono); color: var(--text); font-weight: 600; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); height: 4px; }
.readout { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 16px; }
.row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; color: var(--text-2); border-bottom: 1px dashed var(--border); }
.row:last-child { border-bottom: none; }
.row .n { font-family: var(--mono); color: var(--text); }
.row.total { margin-top: 6px; padding-top: 11px; border-top: 1.5px solid var(--border); border-bottom: none; font-weight: 650; font-size: 15px; }
.row.total .n { font-size: 16px; }
.verdict { margin-top: 13px; padding: 11px 13px; border-radius: 7px; font-size: 13px; line-height: 1.5; }
.verdict.g { background: var(--good-soft); color: var(--good); }
.verdict.w { background: var(--warn-soft); color: var(--warn); }
.verdict.b { background: var(--bad-soft); color: var(--bad); }

/* ---------- checklist ---------- */
.check { list-style: none; padding: 0; }
.check li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.check li:last-child { border-bottom: none; }
.check li::before { content: ""; flex: 0 0 15px; height: 15px; margin-top: 4px; border: 1.5px solid var(--text-3); border-radius: 3.5px; }

/* ---------- footer / misc ---------- */
.footer { border-top: 1px solid var(--border); padding-top: 24px; font-size: 13px; color: var(--text-3); }
.footer a { color: var(--accent); }

.menu-btn {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 11px; font-size: 15px; cursor: pointer;
}

@media (max-width: 900px) {
  .menu-btn { display: block; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.16);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding-top: 64px; }
  .wrap { padding: 0 22px; }
  .hero h2 { font-size: 29px; }
}
