:root {
  --ink: #17201d;
  --muted: #5e6b64;
  --paper: #f7f8f4;
  --card: #fff;
  --line: #dce3dc;
  --field-line: #78877e;
  --green: #176b45;
  --green-dark: #0e4c31;
  --on-green: #fff;
  --mint: #e3f3e9;
  --mint-line: #abd2b9;
  --hero: #edf7ef;
  --danger: #a92626;
  --shadow: 0 12px 30px #1733240d;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #edf4ef;
    --muted: #aebcb3;
    --paper: #111713;
    --card: #1a241d;
    --line: #34433a;
    --field-line: #7c8f83;
    --green: #62ca91;
    --green-dark: #91e6b4;
    --on-green: #0b1a12;
    --mint: #173526;
    --mint-line: #356846;
    --hero: #163022;
    --danger: #ff8c8c;
    --shadow: 0 12px 30px #0005;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.wrap { width: min(100% - 2rem, 1080px); margin: 0 auto; }

a { color: var(--green-dark); text-underline-offset: 0.15em; }
a:hover { color: var(--green); }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 0.5rem; top: -4rem; background: var(--card); color: var(--ink); padding: 0.6rem 1rem; z-index: 10; }
.skip:focus { top: 0.5rem; }

/* cabecera y pie */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.bar { min-height: 4rem; display: flex; align-items: center; justify-content: space-between; gap: 0.25rem 1rem; flex-wrap: wrap; padding: 0.4rem 0; }
.brand { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.04em; text-decoration: none; color: var(--ink); }
.brand span { color: var(--green); }
.brand:hover { color: var(--ink); }
nav ul { display: flex; flex-wrap: wrap; gap: 0 1rem; list-style: none; margin: 0; padding: 0; }
nav a { display: inline-block; padding: 0.55rem 0; text-decoration: none; font-weight: 650; font-size: 0.92rem; color: var(--ink); }
nav a:hover { color: var(--green); text-decoration: underline; }
nav a[aria-current] { color: var(--green-dark); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 0.4em; }
@media (max-width: 720px) { .bar { flex-direction: column; align-items: flex-start; } }

.site-footer { margin-top: 3.5rem; background: #17201d; color: #e7eee9; padding: 2.5rem 0; }
@media (prefers-color-scheme: dark) { .site-footer { background: #0a0e0b; } }
.site-footer .brand { color: #fff; }
.site-footer .brand span { color: #62ca91; }
.site-footer a { color: #d7f0df; }
.footer-grid { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.site-footer p { margin: 0.4rem 0 0; max-width: 34rem; font-size: 0.92rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.site-footer nav a { color: #d7f0df; font-weight: 600; }

/* héroe */
.hero { padding: 2.75rem 0 2.25rem; background: linear-gradient(120deg, var(--hero), var(--paper) 65%); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.1em; color: var(--green-dark); font-weight: 800; font-size: 0.75rem; margin: 0 0 0.55rem; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.03em; }
h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); max-width: 46rem; margin: 0; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 2.5rem 0 0.6rem; }
h3 { font-size: 1.15rem; margin: 1.5rem 0 0.4rem; letter-spacing: -0.02em; }
.lead { font-size: 1.15rem; max-width: 42rem; color: var(--muted); margin: 1rem 0 0; }
.hero .lead a { color: var(--green-dark); }
@media (max-width: 540px) { .hero { padding: 1.75rem 0 1.5rem; } }

/* contenido: columna de lectura a la izquierda, tarjetas a todo el ancho */
.page { padding: 0.5rem 0 1rem; }
.page > :not(.cards, .tool-grid) { max-width: 46rem; }
.page > h2:first-child { margin-top: 2rem; }
.note, .meta { color: var(--muted); font-size: 0.95rem; }
code, .formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95em; }
.formula { background: var(--mint); border: 1px solid var(--mint-line); padding: 0.8rem 1rem; border-radius: 0.75rem; overflow-x: auto; }
.refs { font-size: 0.95rem; color: var(--muted); padding-left: 1.2rem; }

/* herramienta: formulario + resultado */
.tool-grid { display: grid; gap: 1.5rem; align-items: start; margin: 1.5rem 0; }
.hero .tool-grid { margin-bottom: 0; }
@media (min-width: 60rem) { .tool-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.35rem; box-shadow: var(--shadow); }
@media (max-width: 540px) { .card { padding: 1.1rem; } }
form.tool { margin: 0; }
.field { margin-bottom: 1rem; }
label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
input[type=text], select {
  width: 100%;
  min-height: 3rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--field-line);
  border-radius: 9px;
}
input[aria-invalid=true] { border: 2px solid var(--danger); }
.error { color: var(--danger); font-weight: 600; margin: 0.35rem 0 0; }
.error::before { content: "⚠ "; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0.3rem 0 0; }
.with-unit { position: relative; }
.with-unit input { padding-right: 5.5rem; }
.with-unit select.unit { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 4.75rem; min-height: 0; border: 0; border-left: 1px solid var(--line); border-radius: 0 8px 8px 0; background: transparent; padding: 0 0.4rem; }
details.opts { margin: 0.25rem 0 1rem; }
details.opts summary { cursor: pointer; font-weight: 750; color: var(--green-dark); padding: 0.5rem 0; }
button.go {
  width: 100%;
  min-height: 3.1rem;
  font: inherit;
  font-weight: 800;
  color: var(--on-green);
  background: var(--green);
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}
button.go:hover { background: var(--green-dark); }
@media (min-width: 34rem) {
  .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
}

/* resultado */
.result { background: var(--mint); border-color: var(--mint-line); }
.result-label { margin: 0; color: var(--green-dark); font-weight: 800; }
.result-value { font-size: clamp(2.4rem, 7vw, 3.75rem); letter-spacing: -0.05em; line-height: 1.05; font-weight: 700; margin: 0.15rem 0 0.25rem; }
.result-sub { margin: 0 0 0.75rem; color: var(--muted); }
#res-resumen { margin: 0; }
#res-resumen:not(.sr-only) { color: var(--muted); }
#res-detalle p:first-child { margin-top: 0.75rem; }
.range { font-weight: 650; margin-bottom: 0.25rem; }
#res-detalle h3 { font-size: 1.1rem; margin-top: 1.5rem; }
#res-detalle td:last-child { text-align: right; }
#res-detalle thead th:last-child { text-align: right; }

table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1rem; }
th, td { text-align: left; padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--line); }
.result th, .result td { border-bottom-color: var(--mint-line); }
thead th { border-bottom: 2px solid var(--line); }
td { font-variant-numeric: tabular-nums; }

/* tarjetas de enlaces */
.cards { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: 1rem; }
.cards a { display: block; height: 100%; padding: 1.1rem; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--green); }
.cards strong { display: block; margin-bottom: 0.25rem; }
.cards span { color: var(--muted); font-size: 0.92rem; }
@media (min-width: 34rem) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 60rem) { .cards { grid-template-columns: repeat(3, 1fr); } }

.wide-table { overflow-x: auto; }
