/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f8f8; --card: #ffffff; --ink: #14201f; --muted: #5b6b69; --line: #dbe3e2;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e3f2f0;
  --warn: #92400e; --ok: #166534;
  --radius: 14px; --shadow: 0 1px 2px rgba(15, 40, 38, .06), 0 8px 24px rgba(15, 40, 38, .06);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1514; --card: #131f1e; --ink: #e6efee; --muted: #93a6a3; --line: #243534; --accent: #2dd4bf; --accent-ink: #062622; --accent-soft: #10302c; --shadow: none; }
}

/* =============================================================
   2. Reset y base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { font-family: var(--sans); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: clip; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--card); color: var(--ink); z-index: 99; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 1rem; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* =============================================================
   3. Cabecera
   ============================================================= */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { padding: 7px 12px; border-radius: 999px; font-size: .92rem; font-weight: 500; color: var(--muted); }
.top nav a:hover { background: var(--accent-soft); color: var(--ink); }
.top nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

/* =============================================================
   4. Hero y herramienta
   ============================================================= */
.hero { padding: 28px 0 16px; }
.hero h1 { font-size: clamp(1.6rem, 3.4vw + .6rem, 2.5rem); }
.sub { color: var(--muted); margin-top: 8px; max-width: 70ch; }

.tool-card { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
.inputs { display: grid; gap: 14px; }
.grp { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.grp legend { font-weight: 700; font-size: .95rem; padding: 0 6px; margin-left: -6px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.months { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin-top: 12px; }
.fld { display: grid; gap: 4px; align-content: start; font-size: .88rem; }
.fld > span { font-weight: 600; }
.fld small { color: var(--muted); font-size: .78rem; line-height: 1.3; }
input[type="text"], input[type="date"], input[type="month"], select {
  width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 1rem;
}
input:focus, select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.chk { display: flex; align-items: center; gap: 10px; font-size: .92rem; padding: 6px 0; cursor: pointer; }
.chk input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 10px; }
.row-actions { display: flex; justify-content: flex-end; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; min-height: 42px; border-radius: 10px; font-weight: 600; font-size: .95rem; border: 1px solid var(--line); background: var(--card); transition: transform .12s, background .12s; }
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: .82rem; color: var(--muted); }

/* Resultado */
.out { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.empty { color: var(--muted); padding: 18px 4px; }
.headline { background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 16px 18px; display: grid; gap: 2px; margin-bottom: 14px; }
.headline span { font-size: .85rem; opacity: .9; font-weight: 500; }
.headline strong { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 700; letter-spacing: -.02em; }
.headline em { font-style: normal; font-size: .85rem; opacity: .9; }
table.res { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.res td, table.res th { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
table.res .sec th { background: var(--accent-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-radius: 6px; border: 0; }
table.res .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.res tr.tot td { font-weight: 700; border-top: 2px solid var(--ink); }
table.res small { display: block; color: var(--muted); font-size: .76rem; font-weight: 400; }
table.res.sub { margin-top: 14px; }
table.res.sub thead th { background: var(--accent-soft); font-size: .8rem; }
.tbl-wrap { overflow-x: auto; }
.notes { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: .84rem; display: grid; gap: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.actions[hidden] { display: none; }

.emp-table { display: grid; gap: 8px; margin-bottom: 12px; }
.emp-head, .emp-row { display: grid; grid-template-columns: 1fr 76px 76px 36px; gap: 8px; align-items: center; }
.emp-head { font-size: .78rem; font-weight: 600; color: var(--muted); }
.ico { width: 36px; height: 36px; border-radius: 8px; font-size: 1.3rem; color: var(--muted); }
.ico:hover { background: var(--accent-soft); color: var(--ink); }

.badge { display: flex; gap: 8px; align-items: flex-start; margin-top: 16px; font-size: .88rem; color: var(--ok); }
.badge svg { flex: none; margin-top: 3px; }
@media (prefers-color-scheme: dark) { .badge { color: #86efac; } }
.limits { margin-top: 6px; font-size: .84rem; color: var(--muted); }
.params { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.params summary { cursor: pointer; font-weight: 600; }
.params .grid { margin-top: 12px; }
.params input::placeholder { color: var(--muted); opacity: .8; }

/* Publicidad (marcadores vacíos) */
.ad-slot { min-height: 90px; margin: 28px 0; border: 1px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }

/* Contenido SEO */
.prose { padding: 8px 0 8px; max-width: 78ch; margin-inline: auto; width: min(78ch, 100% - 32px); }
.prose h2 { font-size: 1.4rem; margin: 24px 0 10px; }
.prose p { margin-bottom: 12px; color: var(--ink); }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin-top: 8px; color: var(--muted); }
.legal { padding: 32px 0; }
.legal h1 { font-size: 2rem; margin-bottom: 16px; }
.more-h { font-size: 1.3rem; margin: 20px 0 12px; }
.more { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 32px; }
.more-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 4px; transition: border-color .15s, transform .15s; }
.more-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.more-card span { color: var(--muted); font-size: .88rem; }
.foot { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: .88rem; }
.foot .wrap { display: grid; gap: 6px; }
.foot a { text-decoration: underline; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* =============================================================
   5. Responsive
   ============================================================= */
@media (min-width: 960px) {
  .tool-card { grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); }
  .out { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
}

/* =============================================================
   6. Impresión: solo el resultado
   ============================================================= */
@media print {
  .top, .hero, .inputs, .actions, .badge, .limits, .params, .ad-slot, .prose, .more, .more-h, .foot, .toast, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .tool-card { display: block; }
  .out { border: 0; box-shadow: none; padding: 0; position: static; max-height: none; }
  .headline { background: #eee; color: #000; }
}

/* Publicidad superior */
.ad-top .ad-slot { margin: 14px 0 0; min-height: 90px; }
table.res.sub { font-size: .82rem; }
table.res.sub td:first-child { min-width: 170px; }
table.res.sub th, table.res.sub td { padding: 6px 5px; }
.foot-contact { font-weight: 600; color: var(--ink); margin-bottom: 4px; }
