/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #FFFFFF;
  --bg-soft: #F6F9F6;
  --text: #17201A;
  --text-soft: #57635C;
  --border: #E1E8E2;
  --border-strong: #C7D3C9;

  --accent: #14532D;
  --accent-dark: #0E3D21;
  --accent-light: #1F7A42;
  --accent-soft: #EAF3EC;

  --scenario-b: #1D4ED8;
  --scenario-b-soft: #EAF0FE;

  --danger: #B91C1C;
  --danger-soft: #FDECEC;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 40, 25, .06), 0 10px 28px -16px rgba(20, 40, 25, .22);

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Manrope", var(--sans);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { font-family: var(--display); text-wrap: balance; line-height: 1.15; letter-spacing: -0.02em; }
ul, ol { list-style: none; padding: 0; }
table { border-collapse: collapse; width: 100%; }
input { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--accent-dark); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* =============================================================
   3. Utilities
   ============================================================= */
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--accent); color: #fff;
  z-index: 9999; border-radius: 8px; font-weight: 600;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

.container {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: 1.25rem;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* =============================================================
   4. Typography
   ============================================================= */
.h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
.h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: .5rem; }
.eyebrow {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent);
}
.lede { color: var(--text-soft); font-size: 1.05rem; max-width: 62ch; }

/* =============================================================
   5. Components
   ============================================================= */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.3rem; border-radius: 999px; font-weight: 600; font-size: .95rem;
  transition: transform .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); }
.btn-ghost { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-small { padding: .5rem 1rem; font-size: .85rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) {
  .site-header { background: #fff; }
}
.site-header-inner { display: flex; align-items: center; justify-content: space-between; padding-block: .85rem; }
.logo { display: flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.header-links { display: flex; align-items: center; gap: 1.25rem; font-size: .9rem; color: var(--text-soft); }
.header-links a:hover { color: var(--accent); }

/* Hero */
.hero { padding-block: 2.25rem 1.5rem; }
.disclaimer-banner {
  display: flex; gap: .6rem; align-items: flex-start;
  background: var(--accent-soft); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: .85rem 1rem; margin-top: 1.1rem;
  color: var(--accent-dark); font-size: .9rem; line-height: 1.5;
}
.disclaimer-banner svg { flex-shrink: 0; margin-top: .1rem; }

/* Tool card */
.tool-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
@media (min-width: 720px) { .tool-card { padding: 2rem; } }

.scenario-block { padding: 0; }
.scenario-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.scenario-title .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.scenario-block.scenario-b .scenario-title .dot { background: var(--scenario-b); }

.field-grid {
  display: grid; grid-template-columns: 1fr; gap: 1rem;
}
@media (min-width: 540px) { .field-grid { grid-template-columns: 1fr 1fr; } }

.field label {
  display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--text);
}
.field .hint { display: block; font-size: .78rem; color: var(--text-soft); font-weight: 400; margin-top: .3rem; }
.input-wrap {
  position: relative; display: flex; align-items: center;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-soft); transition: border-color .15s var(--ease-out);
}
.input-wrap:focus-within { border-color: var(--accent); background: #fff; }
.input-wrap input {
  width: 100%; padding: .7rem .85rem; background: transparent; border: 0; font-size: 1rem; font-weight: 600;
  -moz-appearance: textfield;
}
.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-wrap .suffix { padding-right: .85rem; color: var(--text-soft); font-weight: 600; font-size: .9rem; }

.compare-toggle-row {
  display: flex; align-items: center; gap: .75rem; margin-block: 1.5rem;
  padding: .85rem 1rem; background: var(--bg-soft); border-radius: var(--radius-sm); border: 1px dashed var(--border-strong);
}
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px;
  transition: background .18s var(--ease-out);
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s var(--ease-out);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track + .thumb { transform: translateX(18px); }
.compare-toggle-row label { font-weight: 600; font-size: .92rem; cursor: pointer; }
.compare-toggle-row .hint { font-size: .8rem; color: var(--text-soft); display: block; }

#panel-b { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px dashed var(--border-strong); }

.form-error {
  margin-top: 1rem; padding: .85rem 1rem; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); font-size: .88rem;
}
.form-error p + p { margin-top: .35rem; }

/* Results */
.results-wrap { margin-top: 1.75rem; }
.stat-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-card {
  background: var(--accent-soft); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 1.1rem 1.15rem;
}
.stat-card .label { font-size: .8rem; font-weight: 600; color: var(--accent-dark); text-transform: uppercase; letter-spacing: .03em; }
.stat-card .value { font-family: var(--display); font-size: 1.55rem; font-weight: 800; margin-top: .3rem; color: var(--text); }

.compare-columns { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin-top: 1.25rem; }
@media (min-width: 720px) { .compare-columns.is-comparing { grid-template-columns: 1fr 1fr; } }
.compare-columns .stat-card.scenario-b { background: var(--scenario-b-soft); }
.compare-columns .stat-card.scenario-b .label { color: var(--scenario-b); }
.compare-col-title { font-weight: 700; font-size: .95rem; margin-bottom: .6rem; display: flex; align-items: center; gap: .5rem; }
.compare-col-title .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.compare-col.b .compare-col-title .dot { background: var(--scenario-b); }
.compare-col .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.compare-col[hidden] { display: none; }

.compare-summary {
  margin-top: 1.25rem; padding: 1rem 1.15rem; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 1rem;
}

/* Chart */
.chart-block { margin-top: 2rem; }
.chart-wrap {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem;
  background: var(--bg-soft); overflow: hidden;
}
.chart-legend { display: flex; gap: 1.25rem; margin-top: .75rem; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-soft); }
.legend-item i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Table */
.table-block { margin-top: 2rem; }
.table-block-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
#table-tabs { display: inline-flex; gap: .4rem; background: var(--bg-soft); padding: .3rem; border-radius: 999px; border: 1px solid var(--border); }
#table-tabs button {
  padding: .4rem .95rem; border-radius: 999px; font-size: .85rem; font-weight: 600; color: var(--text-soft);
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
#table-tabs button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.amort-year {
  border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .6rem; overflow: hidden;
}
.amort-year summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; font-weight: 700; background: var(--bg-soft); gap: 1rem; flex-wrap: wrap;
}
.amort-year summary::-webkit-details-marker { display: none; }
.amort-year summary::after {
  content: "+"; margin-left: auto; order: 3; font-size: 1.2rem; color: var(--accent); font-weight: 700;
}
.amort-year[open] summary::after { content: "\2212"; }
.amort-year-balance { font-weight: 500; color: var(--text-soft); font-size: .85rem; }
.amort-table { font-size: .88rem; }
.amort-table th, .amort-table td { padding: .55rem .8rem; text-align: right; border-top: 1px solid var(--border); }
.amort-table th:first-child, .amort-table td:first-child { text-align: left; }
.amort-table thead th { background: var(--bg); font-weight: 700; text-align: right; }
.amort-table thead th:first-child { text-align: left; }
.amort-table tbody tr:hover { background: var(--bg-soft); }

/* Ad slots */
.ad-slot {
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.ad-slot .adsbygoogle { width: 100%; }
.ad-slot-banner { min-height: 90px; margin-block: 2rem; }
.ad-slot-incontent { min-height: 250px; margin-block: 2rem; }

/* Cookie consent banner */
.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
  background: var(--bg); border-top: 1px solid var(--border-strong);
  padding: 1rem 1.25rem; box-shadow: 0 -8px 30px -14px rgba(20,40,25,.25);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem;
}
/* Higher specificity than ".cookie-banner" so [hidden] (set via JS) actually
   hides it — an author "display: flex" rule otherwise beats the browser's
   own default [hidden] { display: none }, regardless of source order. */
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0; color: var(--text-soft); font-size: .88rem; max-width: 62ch; }
.cookie-banner a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.cookie-banner-actions { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; }
.cookie-banner-actions .btn-text { color: var(--text-soft); font-size: .88rem; font-weight: 600; }
.cookie-banner-actions .btn-text:hover { color: var(--text); }
.cookie-banner .btn-primary { padding: .6rem 1.2rem; }
.ad-corner {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 50;
  width: 220px; min-height: 110px;
  background: var(--bg); border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: .85rem;
  display: flex; flex-direction: column; gap: .4rem;
  transform: translateY(120%); opacity: 0;
  transition: transform .35s var(--ease-out), opacity .35s var(--ease-out);
  pointer-events: none;
}
.ad-corner.is-visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
.ad-corner.is-paused { transform: translateY(120%); opacity: 0; pointer-events: none; }
@media (max-width: 539px) {
  .ad-corner { width: 168px; min-height: 84px; padding: .65rem; right: .75rem; bottom: .75rem; }
}
.ad-corner-top { display: flex; align-items: center; justify-content: space-between; }
.ad-corner-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); }
.ad-corner-close { font-size: 1rem; line-height: 1; padding: .15rem .4rem; color: var(--text-soft); }
.ad-corner-close:hover { color: var(--text); }
.ad-corner-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-size: .85rem; font-weight: 700;
  border: 1px dashed var(--border); border-radius: 8px;
}

/* Steps */
.steps-list { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin-top: 1.75rem; }
@media (min-width: 720px) { .steps-list { grid-template-columns: repeat(3, 1fr); } }
.step-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; background: var(--bg); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; margin-bottom: .8rem;
}
.step-card h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.step-card p { color: var(--text-soft); font-size: .92rem; }

/* Use cases */
.usecases-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 1.75rem; }
@media (min-width: 640px) { .usecases-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .usecases-grid { grid-template-columns: repeat(3, 1fr); } }
.usecase-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.1rem 1.2rem; background: var(--bg-soft);
}
.usecase-card h3 { font-size: .98rem; margin-bottom: .35rem; color: var(--accent-dark); }
.usecase-card p { font-size: .88rem; color: var(--text-soft); }

/* FAQ */
.faq-list { margin-top: 1.75rem; display: flex; flex-direction: column; gap: .6rem; }
.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0; background: var(--bg); overflow: hidden;
}
.faq-item summary {
  cursor: pointer; list-style: none; padding: 1rem 1.2rem; font-weight: 700; font-size: .98rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--accent); font-size: 1.2rem; font-weight: 700; flex-shrink: 0; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p { padding: 0 1.2rem 1.1rem; color: var(--text-soft); font-size: .92rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding-block: 2rem; }
.footer-inner { display: flex; flex-direction: column; gap: .75rem; align-items: flex-start; }
@media (min-width: 640px) { .footer-inner { flex-direction: row; align-items: center; justify-content: space-between; } }
.footer-links { display: flex; gap: 1.25rem; font-size: .85rem; color: var(--text-soft); flex-wrap: wrap; }
.footer-links a:hover { color: var(--accent); }
.footer-note { font-size: .8rem; color: var(--text-soft); max-width: 60ch; }

/* =============================================================
   6. Sections spacing
   ============================================================= */
section { padding-block: 2.5rem; }
section[id] { scroll-margin-top: 88px; }
.section-header { max-width: 68ch; }

/* =============================================================
   7. Effects (kept minimal on purpose)
   ============================================================= */
.faq-item, .amort-year, .btn { transition: border-color .15s var(--ease-out); }

/* =============================================================
   8. JS-off / not-ready states
   ============================================================= */
html:not(.is-ready) .results-wrap,
html:not(.is-ready) .chart-block,
html:not(.is-ready) .table-block { display: none; }
.js-required-note { display: none; }
html:not(.is-ready) .js-required-note { display: block; margin-top: 1.5rem; padding: 1rem; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: .9rem; }

#panel-b[hidden] { display: none; }
#table-tabs[hidden] { display: none; }
.compare-summary[hidden] { display: none; }
.form-error[hidden] { display: none; }

/* =============================================================
   9. Print — the printable amortization table
   ============================================================= */
#print-root { display: none; }
@media print {
  body > * { display: none !important; }
  body > #print-root { display: block !important; }
  #print-root { padding: 0; }
  #print-root h1 { font-size: 1.4rem; margin-bottom: .5rem; }
  #print-root .print-meta { font-size: .85rem; margin-bottom: .5rem; }
  #print-root .print-disclaimer { font-size: .78rem; color: #555; margin-bottom: 1rem; font-style: italic; }
  #print-root table { width: 100%; border-collapse: collapse; font-size: .78rem; }
  #print-root th, #print-root td { border: 1px solid #ccc; padding: .3rem .5rem; text-align: right; }
  #print-root th:first-child, #print-root td:first-child { text-align: left; }
  #print-root thead { display: table-header-group; }
  #print-root tr { page-break-inside: avoid; }
}

/* =============================================================
   10. Responsive breakpoints reference (mobile-first; see components above)
   ============================================================= */
@media (min-width: 1280px) {
  .hero { padding-block: 3rem 2rem; }
}
