:root {
  --bg: #ffffff; --card: #f8f9fa; --text: #111111; --muted: #5c6370; --line: #dee2e6;
  --brand: #0d6efd; --brand-d: #0a58ca; --on-brand: #ffffff; --soft: #e7f0ff;
  --ok: #0b6e4f; --warn-bg: #fff8e1; --warn-line: #f2d49b; --err: #b42318;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: #333333; line-height: 1.6; font-size: 16px; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-d); }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 10; }

/* Cabecera */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo img { width: 32px; height: 32px; border-radius: 8px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .92rem; font-weight: 600; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--soft); color: var(--brand); }

/* Héroe */
.hero { padding: 32px 0 8px; }
.hero h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); line-height: 1.15; margin: 0 0 10px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 720px; font-size: 1.05rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }

/* Tarjetas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin: 24px 0; }
.tool { display: block; text-decoration: none; color: inherit; transition: transform .12s, border-color .12s; }
.tool:hover { transform: translateY(-2px); border-color: var(--brand); color: inherit; }
.tool h2 { margin: 0 0 6px; font-size: 1.1rem; color: var(--text); }
.tool p { margin: 0; color: var(--muted); font-size: .94rem; }
.tool .ico { font-size: 1.6rem; display: block; margin-bottom: 8px; }
.tool .go { display: inline-block; margin-top: 10px; font-weight: 700; color: var(--brand); font-size: .92rem; }

/* Valores vigentes */
.vals { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 8px 0 0; padding: 0; list-style: none; }
.vals li { background: var(--soft); border-radius: 10px; padding: 12px 14px; }
.vals b { display: block; font-size: 1.25rem; letter-spacing: -.01em; }
.vals span { font-size: .82rem; color: var(--muted); }

/* Formulario */
.calc { margin: 20px 0; }
.calc h2 { margin: 0 0 14px; font-size: 1.15rem; }
.fields { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field .lbl { font-weight: 650; font-size: .92rem; display: flex; flex-direction: column; justify-content: flex-end; flex: 1; gap: 2px; }
.field label small { font-weight: 400; color: var(--muted); font-size: .8rem; line-height: 1.35; }
.field small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
input[type=number], input[type=date], select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1.5px solid var(--line);
  border-radius: 10px; padding: 0 12px; height: 46px;
}
input:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--brand) 30%, transparent); border-color: var(--brand); }
.money { position: relative; }
.money span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; font-size: .9rem; pointer-events: none; }
.money input { padding-left: 36px; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; grid-column: 1 / -1; order: 99; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.field.check label { display: block; font-weight: 600; flex: 1; }
.hidden { display: none !important; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn { font: inherit; font-weight: 700; border-radius: 10px; padding: 12px 22px; border: 0; cursor: pointer; min-height: 46px; }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 2px; }

/* Resultado */
#resultado { margin-top: 18px; }
#resultado:empty { display: none; }
.result { border: 2px solid var(--brand); border-radius: var(--radius); padding: 20px; background: var(--card); }
.result .big-label { color: var(--muted); font-size: .9rem; font-weight: 600; }
.result .big { font-size: clamp(1.9rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; color: var(--brand); line-height: 1.15; }
.rows { margin-top: 12px; border-top: 1px solid var(--line); }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .96rem; }
.row span { color: var(--muted); } .row strong { white-space: nowrap; }
.row.sub span { padding-left: 14px; } .row.total { border-bottom: 0; font-size: 1.05rem; } .row.total span { color: var(--text); font-weight: 700; }
.note { margin: 14px 0 0; font-size: .85rem; color: var(--muted); }
.msg { padding: 12px 14px; border-radius: 10px; font-size: .94rem; }
.msg.error { background: color-mix(in srgb, var(--err) 12%, var(--card)); color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 35%, transparent); }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 12px 14px; font-size: .9rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 10px 0; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 650; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
td.n, th.n { text-align: right; white-space: nowrap; }
td small { display: block; color: var(--muted); font-size: .8rem; }
.tablewrap { overflow-x: auto; }

/* Contenido SEO */
.prose { margin: 28px 0; } .prose h2 { font-size: 1.3rem; margin: 28px 0 8px; letter-spacing: -.01em; }
.prose h3 { font-size: 1.05rem; margin: 18px 0 6px; } .prose p, .prose li { color: color-mix(in srgb, var(--text) 88%, transparent); }
.prose code { background: var(--soft); padding: 2px 6px; border-radius: 6px; font-size: .92em; }
.formula { background: var(--soft); border-left: 4px solid var(--brand); padding: 12px 14px; border-radius: 8px; margin: 10px 0; font-size: .95rem; }
details { border-bottom: 1px solid var(--line); padding: 12px 0; } summary { cursor: pointer; font-weight: 650; }
details p { margin: 8px 0 0; }
.related { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.related a { border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; text-decoration: none; font-weight: 600; font-size: .9rem; background: var(--card); }
.related a:hover { border-color: var(--brand); }
.ads-placeholder { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 90px; margin: 14px 0; padding: 8px; border: 1.5px dashed #c5ccd6; border-radius: 10px; background: #fff; color: #9aa3af; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; }
.share { margin: 14px 0 0; } .share .btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }

/* Pie */
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); background: var(--card); padding: 24px 0; font-size: .88rem; color: var(--muted); }
.site-footer a { color: var(--muted); } .site-footer .links { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }

@media (max-width: 560px) {
  .card { padding: 16px; } .row strong { white-space: normal; text-align: right; }
}
@media print {
  .site-header, .site-footer, .actions, .related, .ads-placeholder, .calc form { display: none !important; }
  body { background: #fff; color: #000; }
}

h1, h2, h3 { color: var(--text); }

/* Alineación de formularios: cada campo ocupa 2 filas (título + caja) de la grilla del padre,
   así los títulos de una misma fila comparten alto y las cajas quedan a la misma línea. */
@supports (grid-template-rows: subgrid) {
  .fields > .field:not(.check) { display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: 6px; }
  .fields > .field:not(.check) > label { justify-content: flex-start; flex: none; }
}
