/* ============ Design Tokens ============ */
:root {
  --bg: #f7f8f7;
  --surface: #ffffff;
  --text: #17251f;
  --muted: #5b6b63;
  --primary: #0d6b4f;
  --primary-dark: #0a563f;
  --accent: #e8f4ef;
  --border: #e2e7e4;
  --danger: #b4482f;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(23, 37, 31, 0.08), 0 4px 16px rgba(23, 37, 31, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 760px; }
.text-balance { text-wrap: balance; }
.text-pretty { text-wrap: pretty; }

h1, h2, h3 { line-height: 1.25; font-weight: 700; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: 1rem; }
h3 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }

p { margin-bottom: 1rem; }

/* ============ Header ============ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--primary);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 500;
}
.nav-links a:hover { color: var(--primary); }

/* ============ Hero ============ */
.hero {
  background: var(--surface);
  padding: 3rem 0 2.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero-sub {
  max-width: 640px;
  margin: 1rem auto 0;
  color: var(--muted);
  font-size: 1.05rem;
}
.hero-sub strong { color: var(--primary); }

/* ============ Calculator ============ */
.calc-section { padding: 2.5rem 0; }

.calc-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.field { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.35rem; }

.field-row { display: flex; gap: 1rem; }
.field-row .field { flex: 1; }

label { font-size: 0.85rem; font-weight: 600; color: var(--text); }

input, select {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.prepay-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1.25rem 0;
  background: var(--accent);
}

.prepay-fieldset legend {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0 0.5rem;
  color: var(--primary);
}

.btn-primary {
  width: 100%;
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 700;
  color: #ffffff;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--primary-dark); }

/* ============ Results ============ */
.result-hero {
  background: var(--accent);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.result-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.result-big {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 800;
  color: var(--primary);
  margin: 0;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.result-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}

.result-value { font-size: 1.15rem; font-weight: 700; margin: 0; }

.chart-wrap h3 { margin-top: 0; }

#chart { width: 100%; height: auto; }

.legend { display: flex; gap: 1.25rem; margin-top: 0.5rem; font-size: 0.85rem; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 0.4rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-original { background: var(--danger); }
.dot-prepay { background: var(--primary); }

.result-note {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 0.85rem;
}

/* ============ Content ============ */
.content-section { padding: 3rem 0; }
.content-section:nth-of-type(odd) { background: var(--surface); }

.content-section p { color: var(--muted); }
.content-section strong { color: var(--text); }

/* FAQ */
.faq-section details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.faq-section summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.faq-section summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--primary);
  flex-shrink: 0;
}

.faq-section details[open] summary::after { content: "−"; }
.faq-section details p { margin: 0.75rem 0 0; color: var(--muted); }

/* ============ Footer ============ */
.site-footer {
  background: var(--text);
  color: #cfd8d3;
  padding: 2rem 0;
  font-size: 0.85rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-inner p { margin: 0; }

.site-footer nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.site-footer a { color: #ffffff; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ============ Tools hub ============ */
.section-title { text-align: center; margin-bottom: 2rem; }

.tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.tool-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.tool-card svg { color: var(--primary); }
.tool-card h3 { margin: 0; font-size: 1.1rem; }
.tool-card p { color: var(--muted); font-size: 0.925rem; margin: 0; flex: 1; }
.tool-link { color: var(--primary); font-weight: 600; font-size: 0.9rem; }

/* ============ Multi-row tool forms ============ */
.debt-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 0.85rem;
  position: relative;
  background: var(--bg);
}
.debt-row .field { margin-bottom: 0.6rem; }

.remove-debt {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.remove-debt:hover { text-decoration: underline; }

.btn-secondary {
  width: 100%;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--primary);
  background: var(--accent);
  border: 1px dashed var(--primary);
  border-radius: 8px;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--surface); }

/* ============ Comparison layout ============ */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.compare-col h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  text-align: center;
}

.compare-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.compare-col .result-item { margin-bottom: 0.6rem; }

@media (max-width: 480px) {
  .compare-grid { grid-template-columns: 1fr; }
}

/* ============ Static pages ============ */
.page-content { padding: 3rem 0; min-height: 60vh; }
.page-content h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin-bottom: 1.25rem; }
.page-content h2 { font-size: 1.25rem; margin-top: 1.75rem; }
.page-content p, .page-content li { color: var(--muted); }
.page-content ul { padding-left: 1.5rem; margin-bottom: 1rem; }

/* ============ Responsive ============ */
@media (min-width: 640px) {
  .tools-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 860px) {
  .calc-grid { display: grid; grid-template-columns: 420px 1fr; align-items: start; }
  .footer-inner { flex-direction: row; justify-content: space-between; align-items: center; }
  .tools-grid { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 560px) {
  .field-row { flex-direction: column; gap: 0; }
  .nav-links { gap: 1rem; }
  .nav-links li:nth-child(n+3) { display: none; }
}
