:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #17212b;
  --ink-soft: #4a5663;
  --muted: #7a8591;
  --line: #e3e1da;
  --accent: #0f7b5f;
  --accent-ink: #ffffff;
  --accent-soft: #e4f2ec;
  --warn-soft: #fff4dc;
  --warn-ink: #7a5300;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 33, 43, .06), 0 8px 24px rgba(23, 33, 43, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161b;
    --surface: #1a2128;
    --ink: #e9edf0;
    --ink-soft: #b7c0c8;
    --muted: #8a949e;
    --line: #2b343d;
    --accent: #3fbf96;
    --accent-ink: #0b1a14;
    --accent-soft: #17312a;
    --warn-soft: #33290f;
    --warn-ink: #f2cf7c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 750; font-size: 20px; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
}
.brand svg { width: 30px; height: 30px; flex: none; }
.nav { display: flex; gap: 18px; font-size: 15px; }
.nav a { color: var(--ink-soft); text-decoration: none; }
.nav a:hover { color: var(--ink); }

/* Hero */
.hero { padding: 40px 0 8px; }
.eyebrow {
  display: inline-block; font-size: 13px; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent);
}
h1 {
  font-size: clamp(28px, 5vw, 42px); line-height: 1.15; letter-spacing: -.02em;
  margin: 8px 0 12px;
}
.lead { font-size: 19px; color: var(--ink-soft); margin: 0 0 8px; max-width: 640px; }
.updated { font-size: 14px; color: var(--muted); }

h2 { font-size: 26px; line-height: 1.25; letter-spacing: -.01em; margin: 48px 0 12px; }
h3 { font-size: 19px; margin: 28px 0 8px; }

/* Calculator */
.calc {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  margin: 24px 0 8px;
}
@media (max-width: 760px) { .calc { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label, .field .label {
  display: block; font-weight: 650; font-size: 15px; margin-bottom: 6px;
}
.hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 400; }

input[type="number"], input[type="date"], select {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; min-height: 46px;
}
input[type="number"]:focus, input[type="date"]:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
.money { position: relative; }
.money input { padding-right: 38px; font-size: 22px; font-weight: 700; }
.money span {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-weight: 600;
}

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label {
  flex: 1 1 0; min-width: 90px; margin: 0; font-weight: 600; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 8px;
  text-align: center; cursor: pointer; background: var(--bg);
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--accent); }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }

details.more { margin-top: 8px; }
details.more summary { cursor: pointer; font-weight: 650; font-size: 15px; color: var(--accent); }
details.more[open] summary { margin-bottom: 14px; }

/* Result */
.result { position: sticky; top: 16px; align-self: start; }
.result .big-label { font-size: 14px; color: var(--muted); font-weight: 600; }
.result .big {
  font-size: clamp(38px, 7vw, 52px); font-weight: 800; letter-spacing: -.03em;
  line-height: 1.05; margin: 2px 0 4px; font-variant-numeric: tabular-nums;
}
.result .sub { color: var(--ink-soft); font-size: 15px; margin-bottom: 16px; }

.bar {
  display: flex; height: 12px; border-radius: 99px; overflow: hidden;
  background: var(--line); margin: 6px 0 10px;
}
.bar i { display: block; height: 100%; }
.bar .b-neto { background: var(--accent); }
.bar .b-ss { background: #d99a2b; }
.bar .b-irpf { background: #c4553d; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; }
.legend span::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 6px; vertical-align: -1px; background: currentColor;
}
.legend .l-neto::before { background: var(--accent); }
.legend .l-ss::before { background: #d99a2b; }
.legend .l-irpf::before { background: #c4553d; }

.lines { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.lines td { padding: 7px 0; border-top: 1px solid var(--line); }
.lines td:last-child { text-align: right; font-weight: 650; }
.lines tr.total td { font-weight: 800; }
.lines .minus { color: #c4553d; }

.note {
  background: var(--warn-soft); color: var(--warn-ink); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; margin-top: 14px;
}
.note:empty { display: none; }
.tip {
  background: var(--accent-soft); border-radius: 10px; padding: 12px 14px;
  font-size: 15px; margin-top: 14px;
}
.tip:empty { display: none; }

/* Content */
.content p, .content li { color: var(--ink-soft); }
.content strong { color: var(--ink); }
.content ol, .content ul { padding-left: 22px; }
.content li { margin-bottom: 6px; }

.table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; min-width: 520px; }
table.data th, table.data td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg); }
table.data tr:last-child td { border-bottom: 0; }

.faq details {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px;
}
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: 10px 0 0; }

/* Tool grid (home) */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 24px 0; }
.tool {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.tool:hover { transform: translateY(-2px); border-color: var(--accent); }
.tool h3 { margin: 0 0 6px; }
.tool p { margin: 0; color: var(--ink-soft); font-size: 15px; }
.tool.soon { opacity: .6; pointer-events: none; box-shadow: none; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; border-radius: 99px;
  padding: 2px 8px; margin-bottom: 8px; background: var(--accent-soft); color: var(--accent);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 64px; padding: 28px 0 40px;
  font-size: 14px; color: var(--muted);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; }
.site-footer a { color: var(--ink-soft); }

.sources { font-size: 14px; color: var(--muted); }

@media (max-width: 480px) {
  .nav { gap: 12px; font-size: 14px; white-space: nowrap; }
  .brand { font-size: 18px; }
}

/* main que es a la vez .wrap y .hero (páginas legales, 404) */
.wrap.hero { padding-left: 16px; padding-right: 16px; }

/* Evitar que los campos de fecha desborden la tarjeta en móvil */
.calc > *, .row2 > * { min-width: 0; }
input, select { max-width: 100%; min-width: 0; }
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }

.calc > form { align-self: start; }
.lines td:last-child { white-space: nowrap; padding-left: 12px; }

/* Botón compartir */
.share {
  display: block; width: 100%; margin-top: 14px; padding: 12px 16px; min-height: 46px;
  font: inherit; font-weight: 700; font-size: 16px; cursor: pointer;
  color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 10px;
}
.share:hover { filter: brightness(1.05); }
.share:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.share[hidden] { display: none; }
