/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1d1a16;
  --ink-soft: #57514a;
  --line: #e8e3da;
  --accent: #0e7a5f;
  --accent-deep: #0a5c48;
  --accent-soft: #e3f1ec;
  --warn: #b3541e;
  --cream: #faf8f4;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 26, 22, .05), 0 8px 28px rgba(29, 26, 22, .07);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(1rem, 4vw, 2rem);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
  overflow-x: clip;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
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 { text-wrap: balance; line-height: 1.08; letter-spacing: -0.02em; }
::selection { background: var(--accent); color: var(--cream); }

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

/* =============================================================
   3. Utilities
   ============================================================= */
.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--ink); color: var(--cream);
  z-index: 9999; border-radius: 8px; font-weight: 500;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.7rem, 5.4vw, 3rem);
  max-width: 22ch;
  margin-inline: auto;
}
h2 { font-size: clamp(1.25rem, 3.4vw, 1.75rem); font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .6rem 1.1rem;
  border-radius: 999px;
  font-weight: 600; font-size: .92rem;
  transition: background .25s var(--ease-out), color .25s var(--ease-out), border-color .25s var(--ease-out);
}
.btn-ghost {
  border: 1.5px solid var(--line);
  color: var(--accent-deep);
  background: var(--surface);
}
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn-small { padding: .4rem .85rem; font-size: .85rem; }

.ad-slot {
  max-width: 760px;
  margin: 2.2rem auto;
  min-height: 100px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #b5aea4; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
}

.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.15rem; height: 1.15rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: .7rem; font-weight: 700; line-height: 1;
  opacity: .65; vertical-align: 1px;
}
.info-btn:hover { opacity: 1; }

/* =============================================================
   6. Sections
   ============================================================= */

/* --- Header --- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem var(--gutter);
  max-width: 1100px; margin-inline: auto;
}
.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em;
  color: var(--accent-deep);
}
.brand em { font-style: normal; color: var(--ink); }
.site-nav { display: flex; gap: 1.1rem; font-size: .9rem; font-weight: 500; color: var(--ink-soft); }
.site-nav a:hover { color: var(--accent-deep); }

/* --- Hero --- */
.hero { text-align: center; padding: 1.1rem var(--gutter) 1.4rem; }
.hero-sub {
  color: var(--ink-soft);
  max-width: 52ch;
  margin: .6rem auto 0;
  font-size: clamp(.95rem, 2.5vw, 1.05rem);
}

/* --- Tool card --- */
.tool-wrap { max-width: 1100px; margin-inline: auto; padding-inline: var(--gutter); }
.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: clamp(1.1rem, 3.5vw, 2rem);
}
.noscript-msg {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin-bottom: 1rem;
  font-size: .92rem;
}
.tool-grid { display: grid; gap: 1.6rem; }

.field { margin-bottom: 1.35rem; }
.field:last-child { margin-bottom: 0; }
.field-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  margin-bottom: .35rem;
}
.field-head label { font-weight: 600; font-size: .95rem; }
.field-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--accent-deep);
  white-space: nowrap;
}
.field-hint { font-size: .8rem; color: var(--ink-soft); margin-top: .4rem; }
.field-alt {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .45rem; font-size: .82rem; color: var(--ink-soft);
}
.field-alt input {
  font: inherit; font-variant-numeric: tabular-nums;
  width: 15ch; padding: .3rem .55rem;
  border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
}
.field-alt input:focus-visible { outline-offset: 0; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0 var(--fill, 50%), var(--line) var(--fill, 50%) 100%);
  outline-offset: 6px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(29,26,22,.2);
  cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(29,26,22,.2);
  cursor: grab;
}
input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }

/* --- Results --- */
.tool-results {
  background: linear-gradient(160deg, var(--accent-soft), #f2f8f5 70%);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  align-self: start;
}
.result-label { font-size: .88rem; font-weight: 600; color: var(--accent-deep); }
.result-big {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2rem, 7.5vw, 2.9rem);
  letter-spacing: -0.02em;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
  margin: .1rem 0 .9rem;
}
.result-list { display: grid; gap: .5rem; }
.result-list > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  border-top: 1px solid rgba(14, 122, 95, .18);
  padding-top: .5rem;
}
.result-list dt { font-size: .85rem; color: var(--ink-soft); }
.result-list dd { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result-note {
  font-size: .8rem; color: var(--ink-soft);
  background: var(--surface); border-radius: 10px;
  padding: .6rem .8rem; margin-top: .7rem;
}
.result-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }

/* --- Comparador --- */
.compare {
  margin-top: 1.8rem;
  border-top: 1px solid var(--line);
  padding-top: 1.4rem;
}
.compare-title { font-size: 1.05rem; margin-bottom: .8rem; }
.compare-grid { display: grid; gap: 1.2rem; }
.compare-results {
  display: grid; grid-template-columns: 1fr 1fr; gap: .8rem;
}
.compare-col {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}
.compare-col h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.compare-cuota { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; margin-top: .25rem; }
.compare-int { font-size: .82rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.compare-verdict {
  margin-top: .9rem;
  font-weight: 600; font-size: .95rem;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-radius: 10px; padding: .6rem .9rem;
}
.compare-verdict:empty { display: none; }

/* --- Gráfica --- */
.chart-wrap { margin-top: 2rem; }
.block-title { font-size: 1.05rem; margin-bottom: .6rem; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 1.2rem;
  font-size: .82rem; color: var(--ink-soft); margin-bottom: .6rem;
}
.chart-legend .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: .35rem; vertical-align: -1px;
}
.dot-saldo { background: var(--accent); }
.dot-interes { background: var(--warn); }
#chart { width: 100%; height: 260px; }

/* --- Tabla --- */
.table-wrap { margin-top: 2rem; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.table-head .block-title { margin-bottom: 0; }
.table-scroll { overflow-x: auto; overflow-y: visible; border: 1px solid var(--line); border-radius: var(--radius); }
.amort { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 560px; }
.amort th, .amort td { padding: .5rem .8rem; text-align: right; font-variant-numeric: tabular-nums; }
.amort th:first-child, .amort td:first-child { text-align: left; }
.amort thead th {
  background: var(--bg);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft);
  position: sticky; top: 0;
}
.amort tbody tr:nth-child(even) { background: #fbfaf7; }
.amort tbody tr.year-row td {
  background: var(--accent-soft);
  font-weight: 700; color: var(--accent-deep);
}
.btn-more { margin-top: .8rem; }

/* --- Badges bajo la herramienta --- */
.privacy-badge {
  text-align: center; font-size: .9rem; font-weight: 500;
  margin-top: 1.2rem; color: var(--accent-deep);
}
.honesty-line {
  text-align: center; font-size: .8rem; color: var(--ink-soft);
  max-width: 62ch; margin: .4rem auto 0;
}

/* --- Cómo funciona --- */
.steps { max-width: 1100px; margin: 2.5rem auto 0; padding-inline: var(--gutter); text-align: center; }
.steps h2 { margin-bottom: 1.4rem; }
.steps-grid {
  list-style: none; padding: 0;
  display: grid; gap: 1rem;
  text-align: left;
}
.steps-grid li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
}
.steps-grid svg { color: var(--accent); margin-bottom: .6rem; }
.steps-grid h3 { margin-bottom: .3rem; }
.steps-grid p { font-size: .9rem; color: var(--ink-soft); }

/* --- Texto SEO --- */
.seo-text { max-width: 720px; margin: 3rem auto 0; padding-inline: var(--gutter); }
.seo-text h2 { margin-bottom: 1rem; }
.seo-text p { margin-bottom: 1rem; color: #3d3831; }

/* --- FAQ --- */
.faq { max-width: 720px; margin: 3rem auto 0; padding-inline: var(--gutter); }
.faq h2 { margin-bottom: 1.2rem; }
.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin-bottom: .7rem;
}
.faq summary {
  font-weight: 600; cursor: pointer;
  list-style-position: outside;
}
.faq details[open] summary { color: var(--accent-deep); }
.faq details p { margin-top: .6rem; font-size: .92rem; color: var(--ink-soft); }

/* --- Footer --- */
.site-footer {
  margin-top: 3.5rem;
  border-top: 1px solid var(--line);
  padding: 2rem var(--gutter) 2.4rem;
  text-align: center;
  font-size: .85rem; color: var(--ink-soft);
}
.footer-brand { font-weight: 600; color: var(--ink); }
.footer-disclaimer { max-width: 58ch; margin: .5rem auto; }
.site-footer nav { margin: .6rem 0; }
.site-footer nav a { text-decoration: underline; text-underline-offset: 3px; }
.site-footer nav a:hover { color: var(--accent-deep); }
.footer-copy { margin-top: .4rem; }

/* --- Páginas legales --- */
.legal-page { max-width: 680px; margin: 1.5rem auto 3rem; padding-inline: var(--gutter); }
.legal-page h1 { margin-bottom: 1.2rem; font-size: clamp(1.5rem, 4.5vw, 2.2rem); margin-inline: 0; }
.legal-page h2 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
.legal-page p, .legal-page ul { margin-bottom: .8rem; color: #3d3831; font-size: .95rem; }
.legal-page ul { padding-left: 1.2rem; }
.legal-todo {
  background: #fdf3e7; border: 1px dashed var(--warn);
  border-radius: 10px; padding: .7rem 1rem;
  font-size: .88rem; color: #7c4a1d;
}

/* =============================================================
   7. Effects
   ============================================================= */
.result-big { transition: opacity .18s var(--ease-out); }
.result-big.is-updating { opacity: .55; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 720px) {
  .tool-grid { grid-template-columns: 1.05fr .95fr; gap: 2.2rem; }
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .compare-grid { grid-template-columns: 1fr 1.2fr; align-items: start; }
}
@media (max-width: 539px) {
  .site-nav { display: none; }
  .hero { padding-top: .4rem; }
  .hero-sub { display: none; }   /* la herramienta manda sobre el pliegue en móvil */
}

/* =============================================================
   9. Print — tabla de amortización completa
   ============================================================= */
@media print {
  .site-header, .site-nav, .hero-sub, .ad-slot, .steps, .seo-text, .faq,
  .result-actions, .compare, .chart-wrap, .btn, .privacy-badge, .site-footer nav,
  .field-hint, .field-alt, input[type="range"] { display: none !important; }
  body { background: #fff; }
  .tool-card { border: 0; box-shadow: none; padding: 0; }
  .table-scroll { border: 0; overflow: visible; }
  .amort { min-width: 0; font-size: .75rem; }
}

/* =============================================================
   10. Reduced-motion (solo efectos intrusivos — aquí no hay ninguno)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  /* Las micro-transiciones de esta página no se desactivan (ver gotcha A.2). */
}
