:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #141a2e;
  --muted: #5a6278;
  --border: #dfe3ee;
  --accent: #2546b3;
  --accent-strong: #1c3790;
  --accent-soft: #e6ecfb;
  --accent-2: #e2774a;
  --warn-soft: #fff4e2;
  --warn: #8a5300;
  --ok: #157f4a;
  --neg: #b42318;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 26, 46, .05), 0 8px 24px rgba(20, 26, 46, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1220; --surface: #151a2b; --surface-2: #1c2236; --text: #e8ebf5; --muted: #9aa3bd;
    --border: #2a3149; --accent: #7d97ff; --accent-strong: #a9baff; --accent-soft: #1d2747; --accent-2: #f19a73;
    --warn-soft: #2e2512; --warn: #f0c46a; --ok: #5fd39a; --neg: #ff8a80; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1220; --surface: #151a2b; --surface-2: #1c2236; --text: #e8ebf5; --muted: #9aa3bd;
  --border: #2a3149; --accent: #7d97ff; --accent-strong: #a9baff; --accent-soft: #1d2747; --accent-2: #f19a73;
  --warn-soft: #2e2512; --warn: #f0c46a; --ok: #5fd39a; --neg: #ff8a80; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.65 var(--font); }
img, svg { max-width: 100%; }
a { color: var(--accent-strong); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.22; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.75rem, 4.6vw, 2.55rem); margin: 0 0 .55rem; }
h2 { font-size: 1.45rem; margin: 2.4rem 0 .8rem; }
h3 { font-size: 1.12rem; margin: 1.6rem 0 .5rem; }
p, ul, ol { margin: 0 0 1rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* Header */
.site-header { background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 13px; border-radius: 999px; font-size: .94rem; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: var(--text); padding: 8px; cursor: pointer; }
@media (max-width: 780px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 62px; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; }
  .nav.open { display: flex; }
  .nav a { border-radius: 10px; }
}

/* Hero */
.hero { padding: 48px 0 12px; position: relative; }
.hero::before { content: ""; position: absolute; inset: 0 -40vw auto; height: 340px; z-index: -1;
  background: radial-gradient(600px 240px at 15% 0%, var(--accent-soft), transparent 70%), radial-gradient(500px 220px at 85% 10%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%); }
.hero p.lead { font-size: 1.14rem; color: var(--muted); max-width: 690px; }
.hero-points { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0; list-style: none; color: var(--muted); font-size: .93rem; }
.hero-points li::before { content: "✓"; color: var(--ok); font-weight: 700; margin-right: 6px; }
.breadcrumb { font-size: .88rem; color: var(--muted); margin: 22px 0 8px; }
.breadcrumb a { color: var(--muted); }
.updated { display: inline-block; font-size: .82rem; font-weight: 600; color: var(--accent-strong); background: var(--accent-soft); border-radius: 999px; padding: 3px 12px; margin-bottom: 12px; }
.intro { max-width: 720px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 26px 0 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, transform .15s, box-shadow .15s; display: block; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h3 { margin: 12px 0 6px; }
.card p { color: var(--muted); font-size: .95rem; margin: 0; }
.card .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 34px 0 0; }

/* Calculator */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin: 22px 0 8px; align-items: start; }
@media (max-width: 880px) { .calc { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.panel h2 { margin: 0 0 14px; font-size: 1.15rem; }
.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 600; font-size: .93rem; margin-bottom: 5px; }
.field .hint { font-size: .83rem; color: var(--muted); margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 440px) { .row2 { grid-template-columns: 1fr; } }
input[type="number"], input[type="date"], select {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 11px; padding: 10px 12px; min-height: 46px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.input-eur, .input-pct, .input-yr { position: relative; }
.input-eur input, .input-pct input, .input-yr input { padding-right: 44px; }
.input-eur::after, .input-pct::after, .input-yr::after { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-eur::after { content: "€"; }
.input-pct::after { content: "%"; }
.input-yr::after { content: "años"; font-size: .85rem; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.seg { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.seg label { flex: 1; text-align: center; margin: 0; font-weight: 500; cursor: pointer; padding: 7px 6px; border-radius: 9px; font-size: .92rem; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--accent-strong); font-weight: 700; }
.seg label:has(input:checked) { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500 !important; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--accent); flex: none; }
details.more { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 4px; }
details.more summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; font-size: .93rem; margin-bottom: 10px; }

.result { position: sticky; top: 78px; }
.big { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #6a3fd1)); color: #fff; border-radius: 14px; padding: 18px 20px; margin-bottom: 14px; }
:root[data-theme="dark"] .big { color: #0e1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .big { color: #0e1220; } }
.big .k { font-size: .9rem; opacity: .92; }
.big .v { font-size: clamp(1.9rem, 6vw, 2.55rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.big .s { font-size: .92rem; opacity: .92; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.kpi .k { font-size: .8rem; color: var(--muted); }
.kpi .v { font-weight: 700; font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.kpi.win { outline: 2px solid var(--ok); }
table.breakdown { width: 100%; border-collapse: collapse; font-size: .95rem; font-variant-numeric: tabular-nums; }
table.breakdown td { padding: 7px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
table.breakdown td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; }
table.breakdown tr.sub td { color: var(--muted); font-size: .9rem; }
table.breakdown tr.total td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--text); }
.neg { color: var(--neg); }
.pos { color: var(--ok); }
.bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin: 6px 0 6px; }
.bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82rem; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.c1 { background: var(--accent); } .c2 { background: var(--accent-2); } .c3 { background: #8a93ad; }
.note { background: var(--warn-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; font-size: .88rem; margin-top: 12px; }
.note strong { color: var(--warn); }
.okbox { background: color-mix(in srgb, var(--ok) 12%, transparent); border-radius: 12px; padding: 10px 12px; font-size: .9rem; margin: 0 0 12px; }
.error { color: var(--neg); font-size: .9rem; margin-top: 8px; }
.scroll { overflow-x: auto; }
table.schedule { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.schedule th, table.schedule td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
table.schedule th:first-child, table.schedule td:first-child { text-align: left; }
table.schedule th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }

/* Content */
.content { max-width: 760px; }
.content table { width: 100%; border-collapse: collapse; margin: 0 0 1.2rem; font-size: .95rem; font-variant-numeric: tabular-nums; }
.content th, .content td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.content th { background: var(--surface-2); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.callout { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 18px; margin: 1.2rem 0; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details[open] summary { margin-bottom: 8px; }
.sources { font-size: .9rem; color: var(--muted); }
.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 1rem 0 2rem; }
.related a { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; text-decoration: none; font-weight: 600; }
.related a:hover { border-color: var(--accent); }

/* Footer */
.site-footer { margin-top: 64px; background: var(--surface); border-top: 1px solid var(--border); padding: 34px 0 16px; font-size: .93rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }
.footer-grid a { display: block; color: var(--muted); text-decoration: none; padding: 3px 0; }
.footer-grid a:hover { color: var(--accent-strong); }
.brand-foot, .foot-title { font-weight: 700; margin-bottom: 6px; }
.copy { padding-top: 20px; font-size: .85rem; }

@media print {
  .site-header, .site-footer, .nav-toggle, .related { display: none; }
  .result { position: static; }
}
