/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --text: #1a1d1b;
  --text-muted: #565f5a;
  --border: #dfe3df;
  --accent: #1f6d4c;
  --accent-strong: #14432f;
  --accent-soft: #e4f0ea;
  --danger: #b3452f;
  --focus: #1f6d4c;
  --capital-color: #1f6d4c;
  --interes-color: #b3452f;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 14px;
}

:root[data-theme="dark"] {
  --bg: #12140f;
  --surface: #1b1e18;
  --surface-2: #22261f;
  --text: #eef1ea;
  --text-muted: #a7afa5;
  --border: #333a2f;
  --accent: #4fbf8b;
  --accent-strong: #7fd8ab;
  --accent-soft: #1d3327;
  --danger: #e08a6f;
  --capital-color: #4fbf8b;
  --interes-color: #e08a6f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12140f;
    --surface: #1b1e18;
    --surface-2: #22261f;
    --text: #eef1ea;
    --text-muted: #a7afa5;
    --border: #333a2f;
    --accent: #4fbf8b;
    --accent-strong: #7fd8ab;
    --accent-soft: #1d3327;
    --danger: #e08a6f;
    --capital-color: #4fbf8b;
    --interes-color: #e08a6f;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -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 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; font-weight: 800; }
::selection { background: var(--accent-soft); color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: min(880px, 100% - 2.5rem); margin-inline: auto; }
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--surface); color: var(--text);
  z-index: 9999; border-radius: 8px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding-block: 1rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.05rem; color: var(--accent-strong); }
.theme-toggle {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted);
  transition: background .2s var(--ease-out), color .2s var(--ease-out);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}

.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; }
.footer-inner {
  display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between;
  padding-block: 1.5rem; color: var(--text-muted); font-size: .9rem;
}
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a:hover { color: var(--accent); }

/* =============================================================
   5. Hero + tool card
   ============================================================= */
.hero { padding-block: 2.25rem 1rem; }
.hero h1 { font-size: clamp(1.7rem, 4.4vw, 2.5rem); max-width: 20ch; }
.hero-sub { margin-top: .6rem; color: var(--text-muted); max-width: 58ch; font-size: 1.02rem; }

.tool-card {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 32px -18px rgba(0,0,0,.25);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}
.field-grid-b {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}
.field { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.input-suffix {
  display: flex; align-items: center; gap: .4rem;
  border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem;
  background: var(--surface); transition: border-color .15s var(--ease-out);
}
.input-suffix:focus-within { border-color: var(--accent); }
.input-suffix input {
  border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-weight: 700; font-size: 1.05rem; width: 100%; min-width: 0;
  font-family: var(--mono);
}
.input-suffix input::-webkit-outer-spin-button,
.input-suffix input::-webkit-inner-spin-button { margin: 0; }
.input-suffix span:last-child { color: var(--text-muted); font-weight: 600; font-size: .9rem; }

.compare-toggle-row { margin-top: .9rem; }
.link-btn { color: var(--accent); font-weight: 700; font-size: .92rem; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--accent-strong); }

.btn-calc {
  margin-top: 1.25rem; width: 100%;
  background: var(--accent); color: #fff;
  font-weight: 800; font-size: 1.02rem; padding: .85rem 1.25rem;
  border-radius: 12px; transition: transform .15s var(--ease-out), background .15s var(--ease-out);
}
.btn-calc:hover { background: var(--accent-strong); }
.btn-calc:active { transform: scale(.98); }

/* results */
.results { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.result-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; }
.result-card {
  background: var(--surface-2); border-radius: 12px; padding: 1rem 1.1rem;
  border: 1px solid var(--border);
}
.result-card h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; }
.result-card .value { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; margin-top: .25rem; color: var(--accent-strong); }
.result-card.is-diff .value { color: var(--danger); }
.result-card .sub { color: var(--text-muted); font-size: .82rem; margin-top: .15rem; }

.tabs { display: flex; gap: .5rem; margin-top: 1.25rem; }
.tab {
  padding: .5rem 1rem; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-muted); font-weight: 700; font-size: .88rem;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-wrap { margin-top: 1.5rem; }
.chart-wrap canvas { width: 100%; height: auto; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.chart-legend { display: flex; gap: 1.25rem; margin-top: .6rem; font-size: .85rem; color: var(--text-muted); flex-wrap: wrap; }
.chart-legend li { display: flex; align-items: center; gap: .4rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-capital { background: var(--capital-color); }
.dot-interes { background: var(--interes-color); }

.table-toolbar { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-top: 2rem; flex-wrap: wrap; }
.table-toolbar h2 { font-size: 1.15rem; }
.table-scroll { margin-top: .75rem; overflow-x: auto; overflow-y: visible; border: 1px solid var(--border); border-radius: 12px; }
.amort-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .85rem; min-width: 560px; }
.amort-table th, .amort-table td { padding: .55rem .75rem; text-align: right; white-space: nowrap; }
.amort-table th:first-child, .amort-table td:first-child { text-align: left; }
.amort-table thead th { background: var(--surface-2); position: sticky; top: 0; font-family: var(--sans); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.amort-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.amort-table tbody tr.year-end td { border-bottom: 1px solid var(--border); font-weight: 700; }
.btn-more {
  display: block; width: 100%; padding: .8rem; text-align: center;
  color: var(--accent); font-weight: 700; border-top: 1px solid var(--border);
  background: var(--surface);
}
.btn-more:hover { background: var(--surface-2); }

.privacy-badge { margin-top: 1.5rem; font-size: .85rem; color: var(--text-muted); }
.honesty-note { margin-top: .5rem; font-size: .78rem; color: var(--text-muted); line-height: 1.5; }

/* =============================================================
   6. Ad slots
   ============================================================= */
.ad-slot {
  margin-block: 1.5rem; min-height: 90px;
  border: 1px dashed var(--border); border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-muted); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase;
}

/* =============================================================
   7. Info / SEO section
   ============================================================= */
.info-section { padding-block: 2rem 3rem; color: var(--text); }
.info-section h2 { font-size: 1.3rem; margin-top: 2.25rem; }
.info-section > h2:first-child { margin-top: 0; }
.info-section p { margin-top: .75rem; color: var(--text-muted); max-width: 68ch; }
.formula {
  font-family: var(--mono); font-size: 1.05rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1.1rem;
  color: var(--text); max-width: fit-content;
}
.steps { list-style: none; margin-top: 1.25rem; display: grid; gap: 1.1rem; }
.steps li { display: flex; gap: .8rem; align-items: flex-start; color: var(--text-muted); }
.steps li svg { flex-shrink: 0; color: var(--accent); margin-top: .15rem; }
.steps li strong { color: var(--text); }

.faq-list { margin-top: 1rem; display: grid; gap: .6rem; }
.faq-item {
  border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1.1rem;
  background: var(--surface);
}
.faq-item summary { font-weight: 700; cursor: pointer; list-style: none; position: relative; padding-right: 1.5rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; position: absolute; right: 0; top: 0; color: var(--accent); font-weight: 800; font-size: 1.2rem;
}
.faq-item[open] summary::after { content: "–"; }
.faq-item p { margin-top: .6rem; color: var(--text-muted); }

.more-tools-teaser { margin-top: 2.5rem; font-size: .85rem; color: var(--text-muted); font-style: italic; }

/* legal pages */
.legal-page { padding-block: 2.5rem 4rem; }
.legal-page h1 { font-size: 1.6rem; }
.legal-page h2 { font-size: 1.1rem; margin-top: 1.75rem; }
.legal-page p, .legal-page li { color: var(--text-muted); margin-top: .6rem; max-width: 68ch; }
.legal-page ul { padding-left: 1.2rem; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 720px) {
  .tool-card { padding: 2rem; }
}
@media print {
  .site-header, .site-footer, .hero > *:not(.tool-card), .ad-slot,
  .calc-form, .result-cards, .tabs, .chart-wrap, .privacy-badge, .honesty-note,
  .info-section, .btn-more { display: none !important; }
  .tool-card { border: 0; box-shadow: none; padding: 0; }
  .table-scroll { border: 0; overflow: visible; }
  .amort-table { min-width: 0; font-size: 11px; }
  body { background: #fff; color: #000; }
}
