:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1b1d21;
  --muted: #5a606b;
  --line: #dcdee3;
  --soft: #eef0f3;
  --accent: #0b6e4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f2ec;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --bad: #a3242c;
  --bad-bg: #fde8e9;
  --good: #136a3b;
  --focus: #1a5fd0;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131518;
    --panel: #1c1f24;
    --ink: #eceef1;
    --muted: #a6adb8;
    --line: #333841;
    --soft: #252931;
    --accent: #4cc79a;
    --accent-ink: #0d1f18;
    --accent-soft: #19372c;
    --warn: #f3c46b;
    --warn-bg: #3a2e14;
    --bad: #ff9aa0;
    --bad-bg: #3d1d20;
    --good: #7ddba8;
    --focus: #8ab4ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: 1.9rem; margin: 0 0 .4rem; }
h2 { font-size: 1.35rem; margin: 2.2rem 0 .7rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
p { margin: .5rem 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
header.top { padding: 28px 0 8px; }
.lede { color: var(--muted); max-width: 70ch; }
.privacy { font-size: .9rem; color: var(--muted); }
.privacy strong { color: var(--ink); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
}
.panel > h2:first-child { margin-top: 0; }
.step { color: var(--accent); font-weight: 700; margin-right: .3em; }
.hint { font-size: .88rem; color: var(--muted); }

.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid.c4 { grid-template-columns: repeat(4, 1fr); } }
.grid.c4 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 380px) { .grid.c4 { grid-template-columns: 1fr; } }

label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  min-height: 40px;
}
textarea { min-height: 70px; resize: vertical; }
input[type=number] { font-variant-numeric: tabular-nums; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; margin: 0; }

button, .btn {
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  padding: 8px 12px;
  min-height: 40px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link { background: none; border: 0; color: var(--accent); padding: 4px; min-height: 0; text-decoration: underline; }
button.danger { color: var(--bad); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* tables */
.scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: middle; }
thead th { background: var(--soft); font-weight: 600; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

#items input[type=text] { min-width: 170px; }
#items input[type=number] { width: 100px; }
#items select { min-width: 140px; }

#matrix th.item { min-width: 170px; }
#matrix td.cell { min-width: 120px; }
.cell-in { display: flex; align-items: center; gap: 6px; }
.cell-in input[type=checkbox] { width: 20px; height: 20px; margin: 0; flex: none; }
.cell-in input[type=number] { width: 64px; min-height: 34px; padding: 4px 6px; }
.cell-in input[type=number]:disabled { opacity: .35; }
.tierhead { display: grid; gap: 6px; min-width: 150px; }
.tierhead input[type=text] { font-weight: 700; }
.tierhead .mini { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tierhead .mini label, .tierhead label { font-size: .75rem; font-weight: 600; margin: 0 0 2px; color: var(--muted); }
.tierhead input[type=number] { min-height: 34px; padding: 4px 6px; }
.unit { font-size: .78rem; color: var(--muted); }

/* results */
.cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .cards { grid-template-columns: repeat(4, 1fr); } }
.card { border: 1px solid var(--line); border-radius: 9px; padding: 14px; background: var(--panel); }
.card h3 { margin: 0 0 4px; }
.price { font-size: 1.6rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; padding: 2px 0; }
.kv span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.kv.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
details.break { margin-top: 8px; font-size: .84rem; }
details.break summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.break ul { padding-left: 1.1em; margin: 6px 0; }
details.break li { margin: 3px 0; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--ink); margin-left: 4px; vertical-align: middle; }

.formula {
  background: var(--soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.estimate-note { border-left: 4px solid var(--warn); background: var(--warn-bg); padding: 8px 12px; border-radius: 6px; font-size: .9rem; }

#checks { list-style: none; padding: 0; margin: 0; }
#checks li { padding: 8px 10px; border-radius: 7px; margin: 6px 0; font-size: .92rem; }
#checks li.ok { background: var(--accent-soft); }
#checks li.warn { background: var(--warn-bg); }
#checks li.bad { background: var(--bad-bg); }
#checks li b { margin-right: 4px; }

.summary-strip { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px; font-size: .95rem; }
.summary-strip b { font-variant-numeric: tabular-nums; }

/* sponsor sheet */
#sheet {
  background: #fff;
  color: #16181c;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  max-width: 820px;
  margin: 0 auto;
}
#sheet h2.sh-title { margin: 0; font-size: 1.7rem; color: #16181c; }
#sheet .sh-meta { color: #4a505a; margin: 4px 0 12px; }
#sheet .sh-aud { margin: 0 0 12px; }
#sheet .sh-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 10px 0; border-top: 2px solid #16181c; border-bottom: 1px solid #c9ccd2; margin-bottom: 14px; }
#sheet .sh-stats div { font-size: .82rem; color: #4a505a; }
#sheet .sh-stats b { display: block; font-size: 1.15rem; color: #16181c; }
#sheet .sh-tiers { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
#sheet .sh-tier { border: 1px solid #c9ccd2; border-radius: 8px; padding: 10px 12px; break-inside: avoid; }
#sheet .sh-tier h3 { margin: 0; font-size: 1.05rem; color: #16181c; }
#sheet .sh-price { font-size: 1.3rem; font-weight: 800; color: #0b6e4f; margin: 2px 0; }
#sheet .sh-spots { font-size: .8rem; color: #4a505a; }
#sheet .sh-tier ul { padding-left: 1.05em; margin: 6px 0 0; font-size: .86rem; }
#sheet .sh-tier li { margin: 2px 0; }
#sheet .sh-notes { margin-top: 12px; font-size: .9rem; white-space: pre-wrap; }
#sheet .sh-contact { margin-top: 12px; font-weight: 600; }
#sheet .sh-foot { margin-top: 14px; font-size: .72rem; color: #6a707a; }

textarea#out { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem; min-height: 220px; }

/* content */
.content { max-width: 760px; }
.content .scroll { margin: 10px 0; }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 2px; }
ol.how li, ul.plain li { margin: 5px 0; }

footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 22px 0 40px; font-size: .9rem; color: var(--muted); }
footer ul { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

@media print {
  @page { size: letter; margin: 12mm; }
  body { background: #fff; }
  body > *:not(main) { display: none !important; }
  main > *:not(#sheet-wrap) { display: none !important; }
  #sheet-wrap { display: block !important; margin: 0; padding: 0; border: 0; }
  #sheet-wrap > *:not(#sheet) { display: none !important; }
  #sheet { border: 0; padding: 0; max-width: none; font-size: 11pt; }
  .wrap { padding: 0; max-width: none; }
}

#matrix th.item { position: sticky; left: 0; background: var(--panel); z-index: 1; }
#matrix thead th.item { background: var(--soft); z-index: 2; }
@media (max-width: 600px) { #matrix th.item { min-width: 120px; max-width: 140px; font-size: .85rem; } }
