:root {
  color-scheme: light;
  --bg: #F1F5F4;
  --surface: #FFFFFF;
  --surface-2: #E9F0EE;
  --paper: #FBFAF5;
  --border: #D7E1DF;
  --border-strong: #C0CECB;
  --ink: #14231F;
  --ink-muted: #586b67;
  --accent: #0B6E5D;
  --accent-strong: #085a4c;
  --accent-soft: #E1EFEA;
  --navy: #1C3D5A;
  --negative: #A93B1B;
  --positive: #0B6E5D;
  --ring: #1C7EF0;
  --shadow: 0 1px 2px rgba(20, 35, 31, .06), 0 8px 24px rgba(20, 35, 31, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B1514;
    --surface: #13201E;
    --surface-2: #1B2A27;
    --paper: #182624;
    --border: #263936;
    --border-strong: #354C48;
    --ink: #E7EEEC;
    --ink-muted: #9EB0AC;
    --accent: #3FB79E;
    --accent-strong: #62CFB8;
    --accent-soft: #143029;
    --navy: #8FB8D9;
    --negative: #E68A66;
    --positive: #3FB79E;
    --ring: #5AA2F5;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B1514;
  --surface: #13201E;
  --surface-2: #1B2A27;
  --paper: #182624;
  --border: #263936;
  --border-strong: #354C48;
  --ink: #E7EEEC;
  --ink-muted: #9EB0AC;
  --accent: #3FB79E;
  --accent-strong: #62CFB8;
  --accent-soft: #143029;
  --navy: #8FB8D9;
  --negative: #E68A66;
  --positive: #3FB79E;
  --ring: #5AA2F5;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 {
  font-family: "Archivo", "IBM Plex Sans", system-ui, sans-serif;
  line-height: 1.2;
  text-wrap: balance;
  color: var(--ink);
  margin: 0;
}
a { color: var(--accent-strong); }
p { margin: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

header.site {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 40;
}
.site-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px; max-width: 1180px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: "Archivo", sans-serif; font-weight: 700; letter-spacing: -.01em; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 16px; flex: none;
}
.brand span.txt { font-size: 15px; }
.brand span.txt small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-muted); font-family: "IBM Plex Sans", sans-serif; letter-spacing: .02em; }
.theme-toggle {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px; flex: none;
}
.theme-toggle:hover { border-color: var(--accent); }

.hero { padding: 34px 0 10px; }
.hero h1 { font-size: clamp(1.7rem, 4.6vw, 2.6rem); font-weight: 700; letter-spacing: -.02em; }
.hero p.lead { margin-top: 12px; max-width: 62ch; color: var(--ink-muted); font-size: 1.02rem; }
.trust-row { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; font-size: .82rem; color: var(--ink-muted); }
.trust-row > span { display: inline-flex; align-items: center; gap: 6px; }
.trust-row > span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 20px 0 40px; }
@media (min-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .rail { position: sticky; top: 74px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.calc-head { padding: 6px; border-bottom: 1px solid var(--border); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); border-radius: 10px; padding: 5px; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: "Archivo", sans-serif; font-weight: 600; font-size: .95rem;
  color: var(--ink-muted); padding: 11px 10px; border-radius: 7px; transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.tab .ic { font-size: 1.05rem; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow); }
.tab:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.calc-body { padding: 22px; }
.panel[hidden] { display: none; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
.field .hint { font-size: .78rem; color: var(--ink-muted); margin-top: 5px; }
.input-shell { position: relative; display: flex; align-items: center; }
.input-shell .prefix {
  position: absolute; left: 12px; font-family: "IBM Plex Mono", monospace; color: var(--ink-muted); font-size: .95rem; pointer-events: none;
}
input[type="number"], input[type="date"], select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 11px 12px; transition: border-color .15s, box-shadow .15s;
}
input[type="number"] { padding-left: 30px; font-family: "IBM Plex Mono", monospace; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  appearance: none; border: 0; cursor: pointer; font-family: "Archivo", sans-serif; font-weight: 600;
  font-size: .95rem; padding: 12px 18px; border-radius: 9px; transition: filter .15s, transform .05s;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); }

.form-error { color: var(--negative); font-size: .84rem; margin-top: 4px; min-height: 1.1em; font-weight: 500; }

.voucher-wrap { margin-top: 22px; }
.voucher {
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0;
  font-family: "IBM Plex Mono", "IBM Plex Sans", monospace;
  position: relative;
  overflow: hidden;
}
.voucher::before, .voucher::after {
  content: ""; position: absolute; left: 0; right: 0; height: 8px;
  background-image: radial-gradient(circle at 6px 8px, transparent 5px, var(--paper) 5.5px);
  background-size: 16px 8px; background-repeat: repeat-x;
}
.voucher::before { top: -1px; transform: scaleY(-1); }
.voucher::after { bottom: -1px; }
.v-head { padding: 20px 20px 14px; border-bottom: 1px dashed var(--border-strong); }
.v-title { font-weight: 600; font-size: 1rem; letter-spacing: .02em; color: var(--ink); }
.v-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .74rem; color: var(--ink-muted); margin-top: 6px; }
.v-body { padding: 16px 20px; }
.v-section-label {
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted);
  margin: 14px 0 6px; font-family: "IBM Plex Sans", sans-serif; font-weight: 600;
}
.v-section-label:first-child { margin-top: 0; }
.v-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-size: .86rem; }
.v-row .lbl { color: var(--ink); }
.v-row .leader { flex: 1; border-bottom: 1px dotted var(--border-strong); transform: translateY(-3px); }
.v-row .val { font-variant-numeric: tabular-nums; font-weight: 500; }
.v-row .val.neg { color: var(--negative); }
.v-row .val.pos { color: var(--positive); }
.v-row.sub .lbl { color: var(--ink-muted); padding-left: 12px; font-size: .8rem; }
.v-total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border-top: 1px dashed var(--border-strong); margin-top: 12px; padding-top: 14px;
}
.v-total .lbl { font-family: "IBM Plex Sans", sans-serif; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-muted); }
.v-total .amount { font-size: clamp(1.6rem, 6vw, 2.15rem); font-weight: 600; color: var(--accent-strong); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.v-foot { padding: 12px 20px 22px; border-top: 1px dashed var(--border-strong); font-size: .7rem; color: var(--ink-muted); line-height: 1.5; }
.v-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.v-actions .btn { flex: 1; min-width: 140px; }

.placeholder-note {
  text-align: center; color: var(--ink-muted); font-size: .9rem; padding: 30px 16px;
  border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2);
}

section.block { padding: 34px 0; border-top: 1px solid var(--border); }
section.block > h2 { font-size: clamp(1.3rem, 3.5vw, 1.7rem); font-weight: 700; letter-spacing: -.01em; }
section.block > p.section-intro { color: var(--ink-muted); margin-top: 8px; max-width: 60ch; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 22px; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.step .num {
  font-family: "IBM Plex Mono", monospace; font-weight: 600; font-size: .8rem; color: var(--accent-strong);
  background: var(--accent-soft); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; margin-bottom: 10px;
}
.step h3 { font-size: 1rem; font-weight: 600; }
.step p { font-size: .88rem; color: var(--ink-muted); margin-top: 5px; }

.glossary { margin-top: 20px; display: grid; gap: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.glossary dt {
  font-family: "Archivo", sans-serif; font-weight: 600; padding: 14px 16px 4px; background: var(--surface); font-size: .95rem;
}
.glossary dd { margin: 0; padding: 0 16px 14px; font-size: .88rem; color: var(--ink-muted); background: var(--surface); }
.glossary dd:not(:last-child) { border-bottom: 1px solid var(--border); }

.faq { margin-top: 20px; display: grid; gap: 10px; }
details.qa {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px 16px;
}
details.qa summary {
  cursor: pointer; font-weight: 600; font-family: "Archivo", sans-serif; font-size: .95rem;
  padding: 12px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
details.qa summary::-webkit-details-marker { display: none; }
details.qa summary::after { content: "+"; color: var(--accent-strong); font-size: 1.2rem; flex: none; }
details.qa[open] summary::after { content: "–"; }
details.qa .a { padding: 0 0 14px; font-size: .9rem; color: var(--ink-muted); }

.legal {
  margin-top: 16px; border: 1px solid var(--accent); border-left-width: 4px; border-radius: 8px;
  background: var(--accent-soft); padding: 16px 18px;
}
.legal strong { color: var(--ink); font-family: "Archivo", sans-serif; display: block; margin-bottom: 4px; font-size: .9rem; }
.legal p { font-size: .85rem; color: var(--ink); }

footer.site { border-top: 1px solid var(--border); padding: 24px 0 30px; color: var(--ink-muted); font-size: .8rem; }
footer.site p { max-width: 70ch; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ----- Navegación entre calculadoras ----- */
.site-nav { display: flex; gap: 4px; flex: 1; justify-content: flex-end; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  white-space: nowrap; text-decoration: none; color: var(--ink-muted); font-size: .86rem; font-weight: 500;
  padding: 7px 10px; border-radius: 7px;
}
.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--accent-strong); background: var(--accent-soft); font-weight: 600; }
a.brand { text-decoration: none; color: var(--ink); flex: none; }
@media (max-width: 860px) {
  .site-inner { flex-wrap: wrap; row-gap: 6px; }
  .site-nav { order: 3; flex-basis: 100%; justify-content: flex-start; margin: 0 -8px; }
  .brand span.txt small { display: none; }
  .theme-toggle { margin-left: auto; }
}

.calc-body h2.calc-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 16px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: none; }
input[type="number"].plain { padding-left: 12px; }

/* ----- Tarjetas de herramientas ----- */
.tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 20px; }
@media (max-width: 620px) { .tools { grid-template-columns: 1fr; } }
a.tool {
  display: block; text-decoration: none; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
a.tool:hover { border-color: var(--accent); transform: translateY(-1px); }
a.tool h3 { font-size: 1.02rem; font-weight: 600; color: var(--accent-strong); }
a.tool p { font-size: .88rem; color: var(--ink-muted); margin-top: 6px; }
a.tool .when { display: inline-block; margin-top: 10px; font-size: .74rem; font-family: "IBM Plex Mono", monospace; color: var(--ink-muted); background: var(--surface-2); padding: 3px 8px; border-radius: 6px; }

.prose p { margin-top: 12px; max-width: 68ch; }
.prose ul { margin: 12px 0 0; padding-left: 20px; max-width: 68ch; }
.prose li { margin-top: 6px; }
.formula {
  margin-top: 14px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; font-family: "IBM Plex Mono", monospace; font-size: .86rem; overflow-x: auto;
}

/* Espacios publicitarios: invisibles mientras estén vacíos */
.ad-slot { margin-top: 24px; min-height: 0; text-align: center; }
.ad-slot:empty { display: none; }

footer.site nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; }
footer.site a { color: var(--ink-muted); }

@media print {
  header.site, footer.site, .card, .hero, section.block, .v-actions, .rail, .ad-slot { display: none !important; }
  body { background: #fff; }
}
/* ----- Tablas de referencia y migas de pan ----- */
.migas { font-size: .8rem; color: var(--ink-muted); margin-bottom: 10px; }
.migas a { color: var(--ink-muted); }
.tabla-wrap { margin-top: 16px; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.tabla { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.tabla th, .tabla td { padding: 10px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.tabla thead th { font-family: "Archivo", sans-serif; font-weight: 600; font-size: .8rem; color: var(--ink-muted); background: var(--surface-2); }
.tabla th:first-child { text-align: left; }
.tabla tbody th { font-weight: 600; }
.tabla tbody tr:last-child th, .tabla tbody tr:last-child td { border-bottom: 0; }
.tabla td:last-child { color: var(--accent-strong); font-weight: 600; }
.prose p.tabla-nota { font-size: .8rem; color: var(--ink-muted); margin-top: 10px; }