:root {
  color-scheme: light;
  --paper: #f3f5f8;
  --surface: #ffffff;
  --ink: #142033;
  --ink-2: #46546a;
  --muted: #5b687b;
  --line: #d9dfe7;
  --grid: #e3e8ef;
  --brand: #1c5cab;
  --brand-soft: #e6f0fc;
  --marker: #ffd84d;
  --panel: #13203a;
  --panel-ink: #eaf0f9;
  --panel-muted: #a9b7cc;
  --panel-line: #2b3b58;
  --capital: #2a78d6;
  --interes: #eb6834;
  --gastos: #1baf7a;
  --danger: #b3261e;
  --radius: 12px;
  --font-display: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0d1420;
    --surface: #152033;
    --ink: #e8edf5;
    --ink-2: #b5c0d0;
    --muted: #93a0b3;
    --line: #27354d;
    --grid: #213047;
    --brand: #6da7ec;
    --brand-soft: #1a2a45;
    --panel: #0a111d;
    --panel-line: #243350;
    --capital: #3987e5;
    --interes: #d95926;
    --gastos: #199e70;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; padding-block: 8px; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; text-decoration: none; color: var(--ink); letter-spacing: -0.02em; }
.brand span { background: var(--marker); color: #142033; padding: 0 .22em; margin-right: .06em; border-radius: 3px; }
.site-header nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-header nav a { color: var(--ink-2); text-decoration: none; font-size: .95rem; }
.site-header nav a:hover { color: var(--brand); text-decoration: underline; }

/* Intro */
.intro { padding: 36px 0 8px; }
.intro h1 { font-size: clamp(1.9rem, 4.4vw, 3rem); font-weight: 800; max-width: 22ch; }
.intro p { margin-top: 14px; color: var(--ink-2); max-width: 62ch; font-size: 1.05rem; }

/* Ads */
.ad { margin: 20px auto; text-align: center; }
.ad-label { display: block; font-size: .7rem; color: var(--muted); margin-bottom: 4px; }
.ad-box { min-height: 90px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: .85rem; }
.ad ins.adsbygoogle { display: block; min-height: 90px; }
.ad[hidden] { display: none; }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 20px; }
@media (max-width: 900px) { .calc { grid-template-columns: minmax(0, 1fr); } }

.form-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.field { margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; padding: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.control { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); overflow: hidden; }
.control:focus-within { outline: 3px solid var(--brand); outline-offset: 1px; }
.control .affix { display: grid; place-items: center; padding: 0 12px; color: var(--muted); font-weight: 600; background: transparent; white-space: nowrap; }
.control input, .control select {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 1.1rem; padding: 11px 12px; font-variant-numeric: tabular-nums;
}
.control input:focus, .control select:focus { outline: none; }
.control select { flex: 0 0 auto; border-left: 1px solid var(--line); padding-right: 8px; cursor: pointer; font-size: 1rem; }
.control select option { color: #142033; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: inherit; font-size: .85rem; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--paper); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: block; text-align: center; padding: 9px 8px; font-size: .92rem; cursor: pointer; color: var(--ink-2); border-left: 1px solid var(--line); }
.seg label:first-of-type { border-left: 0; }
.seg input:checked + label { background: var(--brand); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg input:checked + label { color: #0a111d; } }
.seg input:focus-visible + label { outline: 3px solid var(--brand); outline-offset: -3px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row-2 { grid-template-columns: 1fr; } }
details.extra { border-top: 1px dashed var(--line); padding-top: 14px; margin-top: 4px; }
details.extra summary { cursor: pointer; font-weight: 600; padding: 2px 0 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.check input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--brand); }
.aviso { color: var(--danger); font-weight: 500; min-height: 1.4em; margin: 0 0 4px; font-size: .92rem; }

/* Result panel */
.result { background: var(--panel); color: var(--panel-ink); border-radius: 14px; padding: 26px; border: 1px solid var(--panel-line); }
@media (min-width: 901px) { .result { position: sticky; top: 16px; } }
.result .kicker { color: var(--panel-muted); font-size: .95rem; margin: 0 0 8px; }
.big { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.2rem, 6vw, 3.5rem); line-height: 1.05; margin: 0; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.marker { display: inline-block; background: var(--marker); color: #142033; padding: .02em .22em .06em; border-radius: 4px; transform: rotate(-1.2deg); }
.marker.flash { animation: sweep .45s ease-out; }
@keyframes sweep { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.sub { color: var(--panel-muted); margin: 12px 0 0; font-size: .95rem; }
.stats { margin: 22px 0 0; padding: 0; }
.stats > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px dashed var(--panel-line); }
.stats > div[hidden] { display: none; }
.stats dt { color: var(--panel-muted); }
.stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.stats dd.accent { color: #ffd84d; }
.bar { display: flex; gap: 2px; height: 14px; margin-top: 20px; }
.bar span { display: block; min-width: 3px; border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; padding: 0; list-style: none; font-size: .88rem; color: var(--panel-muted); }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--panel-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.compare { margin: 20px 0 0; padding: 12px 14px; border-radius: 8px; background: rgba(255,255,255,.06); font-size: .92rem; color: var(--panel-ink); }
.compare:empty { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn { font: inherit; font-size: .92rem; font-weight: 600; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--panel-line); background: transparent; color: var(--panel-ink); cursor: pointer; }
.btn:hover { border-color: var(--marker); }
.btn:focus-visible { outline-color: var(--marker); }
.toast { color: var(--marker); font-size: .88rem; align-self: center; min-height: 1.2em; }
.empty-msg { color: var(--panel-muted); margin: 0; }

/* Sections */
section.block { margin-top: 48px; }
section.block > h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 700; margin-bottom: 8px; }
section.block > .lead { color: var(--ink-2); max-width: 66ch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* Chart */
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart-wrap .tick { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart-wrap .grid { stroke: var(--grid); stroke-width: 1; }
.chart-wrap .base { stroke: var(--line); stroke-width: 1; }
.seg-capital { fill: var(--capital); }
.seg-interes { fill: var(--interes); }
.seg-gastos { fill: var(--gastos); }
.tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: .85rem; pointer-events: none; box-shadow: 0 4px 16px rgba(10,20,40,.18); white-space: nowrap; z-index: 2; }
.tip[hidden] { display: none; }
.tip strong { display: block; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; list-style: none; margin: 0 0 10px; padding: 0; font-size: .9rem; color: var(--ink-2); }
.chart-legend li { display: flex; align-items: center; gap: 7px; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* Table */
.table-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.table-head .seg { width: min(260px, 100%); }
.table-scroll { max-height: 540px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .93rem; }
th, td { padding: 9px 14px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
thead th { position: sticky; top: 0; background: var(--surface); border-bottom: 2px solid var(--ink); font-weight: 600; z-index: 1; }
tbody td { border-bottom: 1px dashed var(--line); }
tbody tr:hover td { background: var(--brand-soft); }
tbody td:first-child { color: var(--muted); }

/* Content */
.prose { max-width: 70ch; }
.prose h3 { font-size: 1.2rem; margin: 26px 0 8px; font-weight: 700; }
.formula { font-family: var(--font-display); font-size: 1.1rem; background: var(--brand-soft); border-radius: 8px; padding: 12px 16px; display: inline-block; margin: 4px 0 14px; max-width: 100%; overflow-x: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.two .panel h3 { font-size: 1.1rem; margin-bottom: 6px; }
.two .panel p { margin: 0; color: var(--ink-2); }
details.faq { border-bottom: 1px solid var(--line); padding: 14px 0; max-width: 70ch; }
details.faq summary { cursor: pointer; font-weight: 600; font-size: 1.02rem; }
details.faq p { margin: 10px 0 0; color: var(--ink-2); }

footer { margin-top: 64px; border-top: 1px solid var(--line); background: var(--surface); padding: 28px 0 40px; color: var(--ink-2); font-size: .9rem; }
footer .wrap { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
footer p { margin: 0; max-width: 62ch; }
footer nav { display: flex; gap: 18px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .marker.flash { animation: none; }
}

/* ---------- Páginas de guías ---------- */
.article { max-width: 760px; margin: 0 auto; padding: 32px 0 0; }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.article h1 { font-size: clamp(1.9rem, 4.6vw, 2.8rem); font-weight: 800; }
.article .meta { color: var(--muted); font-size: .9rem; margin: 12px 0 22px; }
.article .lede { font-size: 1.12rem; color: var(--ink-2); max-width: 62ch; }
.article h2 { font-size: 1.5rem; font-weight: 700; margin: 42px 0 10px; }
.article h3 { font-size: 1.15rem; font-weight: 700; margin: 26px 0 8px; }
.article p, .article li { max-width: 68ch; }
.article ul, .article ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.article li { margin-bottom: .45em; }
.callout { background: var(--brand-soft); border-left: 4px solid var(--brand); padding: 14px 18px; border-radius: 0 8px 8px 0; margin: 22px 0; }
.callout p { margin: 0 0 .6em; }
.callout p:last-child { margin: 0; }
.cta { display: inline-block; background: var(--brand); color: #fff; text-decoration: none; font-weight: 600; padding: 12px 18px; border-radius: 8px; margin: 6px 0 14px; }
.cta:hover { filter: brightness(1.1); }
@media (prefers-color-scheme: dark) { .cta { color: #0a111d; } }
.article .tbl-wrap { overflow-x: auto; margin: 16px 0 24px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.article table { font-size: .95rem; }
.article thead th { position: static; background: var(--brand-soft); border-bottom: 1px solid var(--line); }
.article th, .article td { white-space: normal; }
.article td.num, .article th.num { text-align: right; }
@media (max-width: 560px) { .article th, .article td { padding: 8px 10px; font-size: .88rem; } }
.article .src { font-size: .85rem; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 16px 0 0; padding: 0; list-style: none; }
.cards a { display: block; height: 100%; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; font-family: var(--font-display); font-size: 1.05rem; line-height: 1.25; }
.cards a:hover { border-color: var(--brand); }
.cards a span { display: block; margin-top: 6px; font-family: var(--font-body); font-weight: 400; font-size: .9rem; color: var(--ink-2); line-height: 1.45; }

/* Portada y herramientas nuevas */
.months { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .months { grid-template-columns: 1fr; } }
.block h3 { margin-top: 6px; }
.site-header nav { flex-wrap: wrap; row-gap: 4px; }
