:root {
  --ink: #14201a;
  --muted: #4a5c52;
  --bg: #f7f5f0;
  --card: #ffffff;
  --accent: #1f6b4a;
  --accent-hover: #175538;
  --line: #d9e0da;
  --warm: #e8f0ea;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 32, 26, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
a { color: var(--accent); }
.wrap { width: min(1080px, calc(100% - 2rem)); margin-inline: auto; }

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(247, 245, 240, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 0; gap: 1rem;
}
.brand {
  font-weight: 760; letter-spacing: -0.02em; text-decoration: none; color: var(--ink); font-size: 1.15rem;
}
.nav { display: flex; align-items: center; gap: 0.85rem; }
.nav a { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.nav a:hover { color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; text-decoration: none; font-weight: 650;
  padding: 0.7rem 1.15rem; border: 1px solid transparent; transition: 0.15s ease;
}
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; background: var(--accent); color: #fff !important; }
.btn-sm:hover { background: var(--accent-hover); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--line); color: var(--ink); background: #fff; }
.btn-ghost:hover { border-color: var(--accent); }
.btn-lg { padding: 0.9rem 1.4rem; font-size: 1.05rem; }

.hero { padding: 3.2rem 0 2.5rem; }
.hero-grid {
  display: grid; gap: 1.75rem;
  grid-template-columns: 1.35fr 0.9fr; align-items: start;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem;
  color: var(--accent); font-weight: 700; margin: 0 0 0.75rem;
}
.hero h1 {
  margin: 0 0 1rem; font-size: clamp(1.9rem, 4vw, 2.75rem);
  line-height: 1.15; letter-spacing: -0.03em;
}
.lede { font-size: 1.08rem; color: var(--muted); margin: 0 0 1.25rem; }

.btn-ghost.btn-sm { background: #fff; color: var(--ink) !important; border-color: var(--line); }
.btn-ghost.btn-sm:hover { border-color: var(--accent); background: var(--warm); }
button.btn { cursor: pointer; font: inherit; font-weight: 650; }
.full { width: 100%; margin: 0.4rem 0 0.6rem; }
.fine { color: var(--muted); font-size: 0.92rem; margin: 0 0 0.6rem; }
h2 { letter-spacing: -0.02em; }

.calc-hero { padding: 2.4rem 0 1.2rem; }
.calc-hero .lede { max-width: 68ch; }
.legal-note {
  background: #fff7e0; border: 1px solid #e9d38c; border-left: 5px solid #c79a1e;
  border-radius: 10px; padding: 0.8rem 1rem; max-width: 72ch; font-size: 0.97rem;
}

.calc { padding: 0.8rem 0 2rem; }
.calc-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.calc-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem 1.3rem; box-shadow: var(--shadow);
}
.calc-card h2 { font-size: 1.15rem; margin: 0.2rem 0 0.8rem; }
.calc-card h2:not(:first-child) { margin-top: 1.4rem; }
.result-card { position: sticky; top: 4.6rem; }
.field-grid { display: grid; gap: 0.75rem 0.9rem; grid-template-columns: 1fr 1fr; }
.field-grid .span-2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
input, select {
  font: inherit; font-size: 1rem; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 9px; padding: 0.55rem 0.65rem; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: 2px solid rgba(31, 107, 74, 0.35); border-color: var(--accent); }
.err { color: #a2321e; font-size: 0.82rem; font-weight: 600; margin: 0; min-height: 0; }
.err:empty { display: none; }
.state-note { margin-top: 0.9rem; background: var(--warm); border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 0.9rem; }
.state-note p { margin: 0 0 0.35rem; }

.lines { display: grid; gap: 0.7rem; }
.line { border: 1px solid var(--line); border-radius: 11px; padding: 0.7rem; background: #fbfcfb; }
.line-top { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.3fr) auto; gap: 0.5rem; align-items: center; }
.l-remove {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; width: 2.2rem; height: 2.2rem;
  font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--muted);
}
.l-remove:hover { color: #a2321e; border-color: #a2321e; }
.line-bottom { display: flex; flex-wrap: wrap; gap: 0.5rem 0.6rem; align-items: flex-end; margin-top: 0.55rem; }
.line-bottom label { flex: 1 1 7.5rem; font-size: 0.8rem; }
.line .rep { display: none; }
.line.is-replace .rep { display: flex; }
.line.is-replace .amt { display: none; }
.charge { margin-left: auto; text-align: right; display: flex; flex-direction: column; min-width: 6.5rem; }
.charge .l-basis { font-size: 0.75rem; color: var(--muted); }
.charge strong { font-size: 1.1rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }

.totals { margin: 0 0 1rem; }
.totals div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.totals .grand { border-bottom: 0; padding-top: 0.7rem; }
.totals .grand dt { color: var(--ink); font-weight: 700; }
.totals .grand dd { font-size: 1.6rem; }
.refund { color: var(--accent); }
.owed { color: #a2321e; }
.deadline { margin: 0 0 0.4rem; }

.next-steps { margin: 0 0 1rem; padding: 0.8rem 0.9rem; border: 1px dashed var(--line); border-radius: var(--radius); font-size: 0.93rem; }
.next-steps p { margin: 0 0 0.45rem; }
.next-steps p:last-child { margin-bottom: 0; }
.next-steps.is-live { border: 1.5px solid var(--accent, #1f6b4a); background: #f3faf5; }
#csv { margin-top: 0.5rem; }
.next-steps .next-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.soft-cta { padding: 0 0 1.6rem; }
.soft-cta-inner p { margin: 0; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; color: var(--muted); }
.soft-cta strong { color: var(--ink); }

.explain, .deadlines, .faq, .disclaimer { padding: 2.2rem 0; }
.explain h2, .deadlines h2, .faq h2, .disclaimer h2 { margin: 0 0 0.9rem; font-size: clamp(1.4rem, 2.5vw, 1.85rem); }
.explain p, .deadlines > .wrap > p { max-width: 75ch; }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem; display: inline-block; font-size: 0.95rem; }
.example-box { background: var(--warm); border-radius: 12px; padding: 0.9rem 1rem; margin: 0.6rem 0 1rem; max-width: 75ch; }
.example-box p { margin: 0; }

.filter { flex-direction: row; align-items: center; gap: 0.6rem; margin: 0.6rem 0 0.8rem; max-width: 22rem; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
#state-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 760px; }
#state-table th, #state-table td { text-align: left; vertical-align: top; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
#state-table thead th { position: sticky; top: 0; background: var(--warm); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
#state-table tbody th { white-space: nowrap; }
#state-table td:nth-child(2) { width: 38%; }
#state-table td:nth-child(3) { width: 30%; }
#state-table td:nth-child(4) { width: 18%; min-width: 10rem; }
.filter { white-space: nowrap; }
#state-table .src { color: var(--muted); font-size: 0.78rem; }
#state-table tbody tr:nth-child(even) { background: #fbfcfb; }
.deadlines .fine { margin-top: 0.8rem; }

.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1rem; margin: 0 0 0.6rem; max-width: 80ch; }
.faq summary { cursor: pointer; font-weight: 650; }
.faq details p { margin: 0.6rem 0 0; color: var(--muted); }

.disclaimer { background: var(--warm); border-block: 1px solid var(--line); }
.disclaimer p { margin: 0; color: var(--muted); max-width: 75ch; }
.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0 2rem; }
.footer-inner p { margin: 0.25rem 0; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Statement: hidden on screen, the only thing printed */
.statement { display: none; }

@media (max-width: 860px) {
  .calc-grid { grid-template-columns: 1fr; }
  .result-card { position: static; }
  .nav a:not(.btn) { display: none; }
}
@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
  .line-top { grid-template-columns: 1fr auto; }
  .line-top .l-desc { grid-column: 1 / -1; grid-row: 2; }
  .calc-card { padding: 1rem; }
  .charge { min-width: 100%; flex-direction: row; justify-content: space-between; align-items: baseline; }
}
@media (max-width: 680px) {
  #state-table { min-width: 0; }
  #state-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #state-table, #state-table tbody, #state-table tr, #state-table th, #state-table td { display: block; width: auto !important; }
  #state-table tr { border-bottom: 1px solid var(--line); padding: 0.4rem 0; }
  #state-table tr[hidden] { display: none; }
  #state-table tbody th { font-size: 1.02rem; padding-bottom: 0.1rem; border: 0; }
  #state-table td { border: 0; padding: 0.25rem 0.75rem; }
  #state-table td::before { content: attr(data-label); display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
}

@media print {
  @page { margin: 0.6in; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-header, main, .site-footer { display: none !important; }
  .statement { display: block; }
  .statement h2 { font-size: 15pt; margin: 0 0 12pt; }
  .statement table { width: 100%; border-collapse: collapse; margin: 0 0 12pt; }
  .statement th, .statement td { text-align: left; padding: 4pt 6pt; border-bottom: 0.5pt solid #999; vertical-align: top; }
  .s-meta th { width: 34%; font-weight: 600; }
  .s-lines thead th { border-bottom: 1pt solid #000; }
  .s-lines .num { text-align: right; white-space: nowrap; }
  .s-lines tfoot th { text-align: right; }
  .s-lines .grand th, .s-lines .grand td { font-weight: 700; border-top: 1pt solid #000; border-bottom: 0; }
  .s-note { font-size: 9.5pt; }
  .sig { display: flex; gap: 2in; margin-top: 36pt; }
  .sig span { border-top: 0.75pt solid #000; padding-top: 3pt; min-width: 2.2in; font-size: 9pt; }
  .s-fine { margin-top: 18pt; font-size: 8.5pt; color: #444; }
  a { color: #000; text-decoration: none; }
  .next-steps, .soft-cta { display: none !important; }
}
