/* Calcula en Claro — "ticket de caja": formularios limpios a la izquierda, resultado impreso como un ticket a la derecha. */
:root {
  --paper: #eef3f1;
  --surface: #ffffff;
  --ink: #10201f;
  --muted: #566866;
  --line: #d3dedb;
  --accent: #0a6b4e;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe7;
  --mark: #ffd23f;
  --mark-ink: #1b1600;
  --warn: #b5470b;
  --tape: #fffdf6;
  --shadow: 0 1px 2px rgba(16,32,31,.06), 0 8px 24px rgba(16,32,31,.07);
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0c1413; --surface: #142120; --ink: #e5eeec; --muted: #94a7a3; --line: #263735;
    --accent: #3cc493; --accent-ink: #062018; --accent-soft: #173a30; --mark: #ffd23f; --mark-ink: #1b1600;
    --warn: #ff9a5c; --tape: #182624; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0c1413; --surface: #142120; --ink: #e5eeec; --muted: #94a7a3; --line: #263735;
  --accent: #3cc493; --accent-ink: #062018; --accent-soft: #173a30; --mark: #ffd23f; --mark-ink: #1b1600;
  --warn: #ff9a5c; --tape: #182624; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.6 var(--f-body);
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}
h1, h2, h3 { font-family: var(--f-display); line-height: 1.12; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0; }

.wrap {
  max-width: 1160px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Cabecera */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 21; background: var(--surface); }
.top .wrap { display: flex; align-items: center; gap: 20px; padding-block: 12px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 800 1.2rem/1 var(--f-display); letter-spacing: -0.02em; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 700 1rem/1 var(--f-mono); }
.logo b { color: var(--accent); font-weight: 800; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .93rem; padding: 6px 10px; border-radius: 8px; }
@media (max-width: 720px) {
  .nav { margin-left: 0; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-bottom: -4px; }
  .nav a { white-space: nowrap; }
  .top .wrap { gap: 8px; padding-block: 10px; }
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }

/* Anuncios */
.ad {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; text-align: center; padding: 8px;
  border: 1.5px dashed var(--line); border-radius: 10px; color: var(--muted);
  font: 500 .72rem/1.3 var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
  background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--line) 35%, transparent) 10px 11px);
}
.ad span { display: block; font-size: .66rem; letter-spacing: .04em; text-transform: none; opacity: .8; }
.ad-leader { min-height: 90px; margin-block: 18px; }
.ad-box { min-height: 250px; }
.ad-inline { min-height: 120px; }

/* Migas */
.crumbs { font-size: .85rem; color: var(--muted); padding-top: 18px; margin-bottom: 8px; }
.crumbs a { color: var(--muted); }

/* Cabecera de calculadora */
.calc-head { display: grid; gap: 10px; padding-block: 10px 22px; max-width: 760px; }
.calc-head p { color: var(--muted); font-size: 1.08rem; }
.eyebrow { font: 600 .74rem/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }

/* Rejilla principal */
.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
@media (max-width: 1080px) { .calc-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .calc-grid > .side { grid-column: 1 / -1; } .side .ad-box { min-height: 120px; } }
@media (max-width: 720px) { .calc-grid { grid-template-columns: minmax(0, 1fr); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.panel h2 { font-size: 1.1rem; }
.field { display: grid; gap: 6px; }
.field label, .field .lab { font-weight: 600; font-size: .92rem; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }
.field small { color: var(--muted); font-size: .8rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
input[type="number"], input[type="date"], input[type="text"], select {
  width: 100%; font: 500 1.05rem/1.2 var(--f-body); color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); outline: none; background: var(--surface); }
input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
select:disabled { opacity: .55; }
.suffix { position: relative; }
.suffix input { padding-right: 44px; }
.suffix i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 .9rem var(--f-mono); color: var(--muted); font-style: normal; pointer-events: none; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: .9rem; cursor: pointer; background: var(--paper); }
.seg input:checked + label { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; font-size: .93rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Ticket de resultado */
.ticket {
  position: relative; background: var(--tape); border: 1px solid var(--line);
  border-radius: var(--r); padding: 24px 22px 20px; box-shadow: var(--shadow);
  font-family: var(--f-mono); display: grid; gap: 4px; overflow: hidden;
}
/* Perforación de ticket: línea de puntos dentro de la caja, sin salirse del borde */
.ticket::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: 9px; height: 0;
  border-top: 2px dotted var(--line);
}
.quick .ticket, .panel .ticket { box-shadow: none; }
.ticket .t-label { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ticket .t-big { font: 800 clamp(2.1rem, 1.6rem + 2vw, 2.9rem)/1.05 var(--f-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ticket output.t-big, .ticket .t-big output { display: block; }
.ticket .t-big mark, .ticket .t-big output { background: var(--mark); color: var(--mark-ink); padding: 0 6px; border-radius: 6px; display: inline-block; max-width: 100%; overflow-wrap: anywhere; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.ticket { grid-template-columns: minmax(0, 1fr); }
.ticket .t-big { min-width: 0; overflow-wrap: anywhere; }
/* Las cifras no se parten: si no caben junto a su concepto, bajan enteras a la línea siguiente */
.ticket dl div { flex-wrap: wrap; }
.ticket dt { min-width: 0; flex: 1 1 8em; }
.ticket dd { flex: 0 0 auto; max-width: 100%; white-space: nowrap; }
.ticket dd.long { white-space: normal; overflow-wrap: anywhere; }
.ticket .t-sub { color: var(--muted); font-size: .85rem; margin-bottom: 10px; }
.ticket dl { margin: 6px 0 0; display: grid; gap: 7px; border-top: 1.5px dashed var(--line); padding-top: 12px; }
.ticket dl div { display: flex; gap: 8px; align-items: baseline; font-size: .9rem; }
.ticket dt { color: var(--muted); }
.ticket dd { margin: 0 0 0 auto; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.ticket dl div::after { content: none; }
.ticket dl .lead { flex: 1; border-bottom: 1.5px dotted var(--line); transform: translateY(-4px); min-width: 12px; }
.ticket dl .total { border-top: 1.5px dashed var(--line); padding-top: 9px; font-size: .98rem; }
.ticket dl .total dt { color: var(--ink); font-weight: 700; }
.ticket .note { font: 400 .78rem/1.45 var(--f-body); color: var(--muted); margin-top: 10px; }
.ticket .warn { color: var(--warn); font: 600 .82rem/1.4 var(--f-body); }
.ticket-actions { display: flex; gap: 8px; margin-top: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.btn { font: 600 .88rem var(--f-body); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }

/* Gráficos */
.chart { margin-top: 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font: 500 .75rem var(--f-body); color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.gauge { position: relative; height: 12px; border-radius: 999px; margin-top: 14px; background: linear-gradient(90deg, #6fb7e8 0 14%, #3cbf7f 14% 40%, #f2b53c 40% 60%, #e66a4a 60% 100%); }
.gauge b { position: absolute; top: -6px; width: 4px; height: 24px; background: var(--ink); border-radius: 2px; transform: translateX(-2px); transition: left .3s; }
.gauge-labels { position: relative; height: 1.2em; font-size: .72rem; color: var(--muted); margin-top: 6px; }
.gauge-labels span { position: absolute; transform: translateX(-50%); }
.gauge-labels span:nth-child(1) { left: 0; transform: none; }
.gauge-labels span:nth-child(2) { left: 14%; }
.gauge-labels span:nth-child(3) { left: 40%; }
.gauge-labels span:nth-child(4) { left: 60%; }
.gauge-labels span:nth-child(5) { left: auto; right: 0; transform: none; }

/* Contenido explicativo */
.content { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; padding-block: 32px 10px; }
@media (max-width: 900px) { .content { grid-template-columns: minmax(0, 1fr); } }
.prose { display: grid; gap: 14px; max-width: 70ch; }
.prose h2 { margin-top: 14px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.prose table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prose th { font-family: var(--f-mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.prose td.n { white-space: nowrap; }
.prose td.n { font-variant-numeric: tabular-nums; font-family: var(--f-mono); }
.table-scroll { overflow-x: auto; }
.formula { font-family: var(--f-mono); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: .9rem; overflow-x: auto; }
.faq { display: grid; gap: 8px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.faq details p { padding-bottom: 12px; color: var(--muted); }
.aside-sticky { position: sticky; top: 90px; display: grid; gap: 16px; align-self: start; }

/* Relacionadas y tarjetas */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px; display: grid; gap: 8px; align-content: start;
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .ex { font: 500 .8rem/1.4 var(--f-mono); color: var(--muted); background: var(--paper); border-radius: 8px; padding: 7px 9px; }
.card .ex b { white-space: nowrap; }
.card { grid-template-rows: auto auto 1fr auto; }
.card .ex { align-self: end; }
.card .ex b { color: var(--accent); }
.card h3 { font-size: 1.05rem; }
.card p { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.section { padding-block: 34px; display: grid; gap: 18px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head p { color: var(--muted); }

/* Portada */
.hero { padding-block: 44px 24px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 40px; align-items: center; }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 28px; } }
.hero h1 { font-size: clamp(2.3rem, 1.5rem + 3.6vw, 4rem); line-height: 1.02; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lede { font-size: 1.15rem; color: var(--muted); max-width: 46ch; margin-top: 16px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 22px; margin-top: 22px; font-size: .88rem; color: var(--muted); }
@media (max-width: 520px) { .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; font-size: .8rem; } .hero-stats b { font-size: 1.15rem; } }
.hero-stats b { display: block; font: 800 1.35rem/1.1 var(--f-display); color: var(--ink); }
.search { margin-top: 24px; position: relative; max-width: 480px; }
.search input { padding-left: 42px; background: var(--surface); }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.quick { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; display: grid; gap: 12px; }
.quick .ticket { box-shadow: none; }
.cat-tag { font: 600 .7rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* Pie */
.foot { border-top: 1px solid var(--line); margin-top: 40px; background: var(--surface); }
.foot .wrap { padding-block: 28px; display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; font-size: .9rem; }
@media (max-width: 720px) { .foot .wrap { grid-template-columns: 1fr; } }
.foot ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--accent); }
.foot p { color: var(--muted); }
.foot h3 { font-size: .8rem; font-family: var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.card[hidden], .cat-section[hidden] { display: none; }
.pend-tag { background: var(--mark); color: var(--mark-ink); border-radius: 4px; padding: 0 6px; font-weight: 600; }
.legal th { width: 32%; }
.foot .pend { color: var(--muted); opacity: .75; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* En móvil, un solo anuncio tras el resultado: se oculta el lateral para no apilar dos huecos seguidos */
@media (max-width: 720px) { .calc-grid > .side { display: none; } }

/* Zonas táctiles de al menos 44 px */
.nav a, .seg label, .btn, .logo, .foot li a { min-height: 44px; display: inline-flex; align-items: center; }
.seg label, .nav a { min-width: 44px; justify-content: center; }
.check { min-height: 44px; }
.foot ul { gap: 0; }
/* Menú móvil: pista de que hay más opciones y espacio para el foco */
@media (max-width: 720px) {
  .nav { padding: 5px; margin-inline: -5px; width: calc(100% + 10px); }
}
html { scroll-padding-top: calc(var(--header-height, 72px) + 12px); }
select { text-overflow: ellipsis; padding-right: 30px; }
.chart { overflow-x: auto; }

/* Sin flechas en los campos numéricos: chocaban con la unidad (€, %, años) */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* Sin anuncios: el formulario y el resultado ocupan todo el ancho, y el texto no deja columna vacía */
.calc-grid:not(:has(> .side .ad)) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.calc-grid > .side:not(:has(.ad)) { display: none; }
.content:not(:has(aside .ad)) { grid-template-columns: minmax(0, 1fr); }
.content:not(:has(aside .ad)) > aside { display: none; }
@media (max-width: 720px) { .calc-grid:not(:has(> .side .ad)) { grid-template-columns: minmax(0, 1fr); } }
.nav a { flex: none; }
