:root {
  --paper: #f8f7f4;
  --sheet: #ffffff;
  --tint: #f2efe9;
  --tint-soft: #f6f4ef;
  --rule: #e6e2da;
  --rule-strong: #cec8bc;
  --ink: #161614;
  --ink-2: #4b4a45;
  --ink-3: #817e76;
  --crimson: #c2332a;
  --crimson-bg: #fdf2f1;
  --amber: #a86400;
  --amber-bg: #fdf7ec;
  --forest: #12734d;
  --forest-bg: #eef7f3;
  --slate: #2c4657;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.serif { font-family: Georgia, "PT Serif", "Times New Roman", serif; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--tint);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink);
}

/* HEADER & NAV */
header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.wrap { max-width: 900px; margin: 0 auto; padding: 0 24px; }
.hdr-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 11px;
}
.brand-group { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hdr-meta {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.step-pill {
  color: var(--ink-2);
  font-weight: 500;
}

.nav-wrap {
  position: relative;
}
nav {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
nav::-webkit-scrollbar { display: none; }
.nav-link {
  display: inline-block;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  padding: 2px 0 11px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color 150ms ease-out, border-color 150ms ease-out;
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

/* MAIN LAYOUT */
main { padding: 40px 0 72px; }

.hero {
  padding-bottom: 32px;
  margin-bottom: 38px;
  border-bottom: 1px solid var(--rule);
}
h1 {
  font-size: 33px;
  line-height: 1.18;
  font-weight: 400;
  letter-spacing: -0.018em;
  color: var(--ink);
  margin-bottom: 14px;
  max-width: 27ch;
}
.lead-copy {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.6;
  max-width: 68ch;
  margin-bottom: 22px;
}

.metric-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 24px 40px;
  padding-top: 6px;
}
.lead-num { font-size: 46px; font-weight: 600; line-height: 1.04; letter-spacing: -0.025em; }
.lead-lbl { font-size: 13px; color: var(--ink-2); margin-top: 6px; max-width: 30ch; }
.sub-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 32px;
  border-left: 1px solid var(--rule-strong);
  padding-left: 28px;
}
.sub-num { font-size: 20px; font-weight: 600; color: var(--ink); line-height: 1.15; }
.sub-lbl { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

/* CONTENT BLOCKS */
.block { margin-bottom: 44px; }
.block:last-child { margin-bottom: 0; }
h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.block-sub {
  font-size: 14px;
  color: var(--ink-2);
  margin-bottom: 16px;
  max-width: 72ch;
}

.plot-sheet {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px 22px;
}
canvas { width: 100%; display: block; }
.chart-note { font-size: 12.5px; color: var(--ink-3); margin-top: 10px; line-height: 1.48; }
.tip {
  position: absolute;
  pointer-events: none;
  display: none;
  z-index: 20;
  background: var(--ink);
  color: #fff;
  padding: 9px 13px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.45;
  max-width: 260px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.ed-list { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.ed-item {
  padding: 18px 20px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.ed-item h3 { font-size: 14.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.ed-item p { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }

.sheet-box {
  padding: 20px 22px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink-2);
}
.sheet-box strong { color: var(--ink); }
.sheet-box h3 { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.sheet-box p + p { margin-top: 10px; }

.tint-box {
  padding: 22px 24px;
  background: var(--tint);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink-2);
}
.tint-box strong { color: var(--ink); }
.tint-box h3 { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 9px; line-height: 1.3; }
.tint-box p + p { margin-top: 10px; }

.clean-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.clean-list li {
  padding-left: 16px;
  position: relative;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.52;
}
.clean-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--ink-3);
}
.clean-list li strong { color: var(--ink); }

/* TABLES (DESKTOP) + STACKED EDITORIAL CARDS (MOBILE) */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13.5px;
}
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  background: var(--tint-soft);
  padding: 11px 16px;
  border-bottom: 1px solid var(--rule-strong);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  vertical-align: top;
  line-height: 1.55;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.strong { color: var(--ink); font-weight: 600; }
.t-right { text-align: right; }

/* STATUS SIGNALS */
.c-red { color: var(--crimson); }
.c-amber { color: var(--amber); }
.c-green { color: var(--forest); }
.c-ink { color: var(--ink); }
.fw-600 { font-weight: 600; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  white-space: nowrap;
}
.tag-red { color: var(--crimson); background: var(--crimson-bg); }
.tag-amber { color: var(--amber); background: var(--amber-bg); }
.tag-green { color: var(--forest); background: var(--forest-bg); }
.tag-neutral { color: var(--ink-2); background: var(--tint); }

/* CALCULATOR CONTROLS */
.controls {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-bottom: 26px;
}
.ctrl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.ctrl-head strong { color: var(--ink); font-size: 14px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: #dedad2;
  border-radius: 999px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* CONTRACT CLAUSES GRID */
.clause-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.clause-card {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px 20px;
}
.clause-card h3 {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.35;
}
.clause-card p {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.54;
}

/* BOTTOM PAGER */
.pager {
  margin-top: 54px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 14px;
}
.pager-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  padding: 14px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  background: var(--sheet);
  color: var(--ink);
  min-width: 220px;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}
.pager-btn:hover { background: var(--tint); border-color: var(--ink); }
.pager-btn.next { text-align: right; margin-left: auto; }
.pager-dir { font-size: 12px; color: var(--ink-3); }
.pager-title { font-size: 14px; font-weight: 600; color: var(--ink); }

/* ==================== MOBILE-FIRST RESPONSIVE (iPhone 375-430px) ==================== */
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 16px; }
  .hdr-top { padding: 13px 0 9px; }
  .brand-sub { display: none; }
  nav { gap: 18px; padding-right: 16px; }
  .nav-link { font-size: 13.5px; padding: 2px 0 10px; }

  main { padding: 26px 0 56px; }
  .hero { padding-bottom: 24px; margin-bottom: 28px; }
  h1 { font-size: 25px; line-height: 1.22; }
  .lead-copy { font-size: 14px; margin-bottom: 18px; }
  .lead-num { font-size: 38px; }
  .sub-metrics {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--rule);
    padding-top: 16px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .sub-num { font-size: 18px; }

  .block { margin-bottom: 34px; }
  h2 { font-size: 16px; }
  .plot-sheet { padding: 14px 14px 16px; }
  .sheet-box, .tint-box, .ed-item, .clause-card { padding: 16px; }
  .grid-2, .ed-list, .controls, .clause-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Transform data tables into clean stacked editorial cards on mobile — ZERO horizontal scroll! */
  .data-table {
    background: transparent;
    border: none;
    border-radius: 0;
    display: block;
  }
  .data-table thead { display: none; }
  .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .data-table tr {
    display: block;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 14px 16px;
  }
  .data-table td {
    display: block;
    padding: 0;
    border: none;
    text-align: left !important;
  }
  .data-table td + td { margin-top: 8px; }
  .data-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-3);
    margin-bottom: 2px;
  }
  .data-table td.m-head {
    font-size: 14.5px;
    color: var(--ink);
    font-weight: 600;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--rule);
  }
  .data-table td.m-head::before { display: none; }

  /* Compact 3-col compare rows on mobile */
  .data-table.compare-tbl td.m-kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding-top: 4px;
  }
  .data-table.compare-tbl td.m-kv::before {
    display: inline;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .pager {
    margin-top: 40px;
    flex-direction: column;
    gap: 10px;
  }
  .pager-btn { min-width: 0; width: 100%; }
  .pager-btn.next { text-align: left; margin-left: 0; }
}

@media print {
  header, .pager { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .pdf-section { page-break-after: always; padding-top: 10px; }
  .pdf-section:last-child { page-break-after: auto; }
}
