/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --ink: #18201e;
  --ink-2: #4a5552;
  --muted: #6c7673;
  --line: #e2e0d8;
  --accent: #0e6b5c;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ec;
  --nac: #d1453b;
  --aut: #2f66c9;
  --loc: #d98a0b;
  --isl: #8a4fd0;
  --vac: #17a06a;
  --hl: rgba(14, 107, 92, 0.14);
  --warn-bg: #fff5e0;
  --warn-line: #f1c66b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 28, .05), 0 8px 24px rgba(20, 30, 28, .06);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", var(--sans);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615;
    --surface: #182120;
    --surface-2: #1f2a28;
    --ink: #eef3f1;
    --ink-2: #c3ccc9;
    --muted: #93a09c;
    --line: #2b3735;
    --accent: #4cc3a6;
    --accent-ink: #0b1513;
    --accent-soft: #173a33;
    --nac: #f0675d;
    --aut: #6f9cf0;
    --loc: #f0aa3a;
    --isl: #b48af0;
    --vac: #35c98b;
    --hl: rgba(76, 195, 166, 0.18);
    --warn-bg: #2d2615;
    --warn-line: #7d6420;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

/* =============================================================
   2. Reset & 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.6;
  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; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
p { text-wrap: pretty; }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.6vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem); font-weight: 800; margin-bottom: .6rem; }
h3 { font-size: 1.1rem; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* =============================================================
   3. Utilidades
   ============================================================= */
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.narrow { max-width: 720px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--surface); z-index: 9999; border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.small { font-size: .9rem; }
.muted { color: var(--muted); }
.print-only { display: none; }
[hidden] { display: none !important; }

/* =============================================================
   4. Cabecera y pie
   ============================================================= */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.head-in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; }
.logo { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 800; font-size: 1.3rem; color: var(--ink); text-decoration: none; }
.logo svg { width: 34px; height: 22px; color: var(--accent); }
.site-head nav ul { display: flex; gap: .2rem; list-style: none; padding: 0; overflow-x: auto; scrollbar-width: none; }
.site-head nav a { display: block; padding: .45rem .7rem; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .93rem; white-space: nowrap; }
.site-head nav a:hover, .site-head nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 719px) {
  .head-in { flex-wrap: wrap; padding: .5rem 0; min-height: 0; }
  .site-head { position: static; }
  .site-head nav { width: 100%; }
  .site-head nav ul { margin: 0 -8px; }
}
.site-foot { margin-top: 4rem; padding: 2.5rem 0 3rem; background: var(--surface); border-top: 1px solid var(--line); }
.foot-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; margin-bottom: 1.5rem; }
@media (min-width: 720px) { .foot-grid { grid-template-columns: 2fr 1fr 1fr; } }
.foot-h { font-size: 1rem; margin-bottom: .4rem; }
.site-foot ul { list-style: none; padding: 0; }
.site-foot li { margin: .2rem 0; }

/* =============================================================
   5. Portada y cabeceras de página
   ============================================================= */
.hero { padding: 2.2rem 0 1.5rem; background: radial-gradient(1200px 400px at 80% -10%, var(--accent-soft), transparent 70%); }
.hero h1 { max-width: 16ch; }
.lead { font-size: 1.1rem; color: var(--ink-2); margin: .6rem 0 1rem; max-width: 60ch; }
.page-head { padding: 1.2rem 0 1rem; }
.crumbs { font-size: .88rem; color: var(--muted); padding-top: 1rem; }
.crumbs a { color: var(--muted); }
.quick, .chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.quick a, .chips a { display: inline-block; padding: .38rem .8rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: .92rem; }
.quick a:hover, .chips a:hover { border-color: var(--accent); color: var(--accent); }
.tools-row { list-style: none; padding: 0; display: grid; gap: .7rem; margin-top: 1.4rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .tools-row { grid-template-columns: repeat(3, 1fr); } }
.tools-row a { display: block; padding: .9rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .2s var(--ease-out), border-color .2s; }
.tools-row a:hover { transform: translateY(-2px); border-color: var(--accent); }
.tools-row strong { display: block; font-family: var(--display); font-size: 1.1rem; }
.tools-row span { color: var(--muted); font-size: .92rem; }

/* =============================================================
   6. Buscador
   ============================================================= */
.search { position: relative; max-width: 640px; }
.search input {
  width: 100%; height: 58px; padding: 0 1rem 0 3rem;
  border-radius: 16px; border: 2px solid var(--line); background: var(--surface);
  font-size: 1.1rem; box-shadow: var(--shadow); transition: border-color .2s;
}
.search input:focus { outline: none; border-color: var(--accent); }
.search-ico { position: absolute; left: 1rem; top: 19px; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; list-style: none; padding: .35rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; }
.suggest li { display: flex; flex-direction: column; padding: .55rem .75rem; border-radius: 10px; cursor: pointer; }
.suggest li span { font-size: .85rem; color: var(--muted); }
.suggest li[aria-selected="true"], .suggest li[role=option]:hover { background: var(--accent-soft); }
.suggest li.none { cursor: default; font-size: .93rem; color: var(--ink-2); }
.field .search input { height: 48px; font-size: 1rem; border-radius: 12px; box-shadow: none; padding-left: 2.6rem; }
.field .search-ico { top: 14px; left: .85rem; }

/* =============================================================
   7. Tarjeta de herramienta, botones, leyenda
   ============================================================= */
.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); padding: 1rem; box-shadow: var(--shadow); }
@media (min-width: 720px) { .tool-card { padding: 1.4rem; } }
.card-h { font-size: 1.2rem; margin: .4rem 0 .2rem; }
.tool-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .7rem; margin-bottom: .8rem; }
.year-tabs { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.year-tabs a { padding: .35rem .95rem; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .95rem; }
.year-tabs a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .62rem 1rem; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; font-size: .95rem; transition: transform .15s var(--ease-out), filter .15s; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.big { padding: .85rem 1.3rem; font-size: 1.02rem; width: 100%; }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .88rem; color: var(--ink-2); margin-bottom: .8rem; }
.legend li { display: inline-flex; align-items: center; gap: .4rem; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sw.nac { background: var(--nac); } .sw.aut { background: var(--aut); } .sw.loc { background: var(--loc); }
.sw.isl { background: var(--isl); } .sw.vac { background: transparent; border: 2.5px solid var(--vac); }
.privacy { font-size: .9rem; color: var(--muted); margin: .7rem 0 0; }

/* =============================================================
   8. Calendario
   ============================================================= */
.cal { display: grid; gap: 1rem .9rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .cal { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .cal { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.3rem 1.2rem; } }
.mes h3 { font-size: .98rem; margin-bottom: .35rem; text-transform: capitalize; }
.mes-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mes-grid span { aspect-ratio: 1; display: grid; place-items: center; font-size: .8rem; border-radius: 7px; font-variant-numeric: tabular-nums; }
.dow { color: var(--muted); font-size: .7rem !important; font-weight: 600; aspect-ratio: auto !important; padding-bottom: 2px; }
.d.we { color: var(--muted); background: var(--surface-2); }
.d.nac, .d.aut, .d.loc, .d.isl { color: #fff; font-weight: 700; cursor: help; }
.d.nac { background: var(--nac); } .d.aut { background: var(--aut); } .d.loc { background: var(--loc); } .d.isl { background: var(--isl); }
.d.hl:not(.nac):not(.aut):not(.loc):not(.isl) { background: var(--hl); color: var(--ink); }
.d.hl { box-shadow: inset 0 0 0 2px var(--accent); }
.d.vac { background: var(--vac) !important; color: #fff !important; font-weight: 700; box-shadow: none; }
@media (min-width: 960px) { .mes-grid span { font-size: .84rem; } }

/* =============================================================
   9. Bloques de contenido
   ============================================================= */
.block { margin-top: 2.6rem; }
.prose p, .prose li { max-width: 70ch; }
.prose p + p { margin-top: .7rem; }
.prose ul { padding-left: 1.2rem; margin: .6rem 0; }
.prose h2 { margin-top: 1.6rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.festivos { width: 100%; border-collapse: collapse; font-size: .95rem; }
.festivos th, .festivos td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.festivos th { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.festivos tr:last-child td { border-bottom: 0; }
.lf-date { white-space: nowrap; }
.festivos time::first-letter { text-transform: uppercase; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; color: #fff; }
.badge.nac { background: var(--nac); } .badge.aut { background: var(--aut); } .badge.loc { background: var(--loc); } .badge.isl { background: var(--isl); }
.badge.warn { background: var(--warn-line); color: #3a2c00; }
.sources { margin-top: 1rem; font-size: .9rem; color: var(--ink-2); }
.sources h3 { font-size: .95rem; margin-bottom: .3rem; }
.sources ul { padding-left: 1.1rem; }
.notice { background: var(--accent-soft); border-radius: 12px; padding: .75rem .95rem; margin: .6rem 0 .9rem; font-size: .95rem; }
.notice.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.ops { list-style: none; padding: 0; display: grid; gap: .5rem; }
.op { padding: .7rem .9rem .7rem 1rem; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 12px; }
.op-0 { border-left-color: var(--nac); }
.op-1 { border-left-color: var(--vac); }
.op-2, .op-3 { border-left-color: var(--loc); }
.op[role=button] { cursor: pointer; transition: border-color .15s, background .15s; }
.op[role=button]:hover, .op.sel { background: var(--accent-soft); }
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: .8rem; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1rem 1rem 3.4rem; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 1rem; top: 1rem; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.cards { list-style: none; padding: 0; display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .cards { grid-template-columns: repeat(4, 1fr); } }
.cards li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.cards h3 { margin-bottom: .3rem; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: .5rem; }
.faq summary { cursor: pointer; padding: .85rem 1rem; font-weight: 600; list-style: none; position: relative; padding-right: 2.5rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 1rem; top: .7rem; font-size: 1.3rem; color: var(--accent); }
.faq details[open] summary::after { content: "–"; }
.faq details > div { padding: 0 1rem .95rem; color: var(--ink-2); }
.embed-code { width: 100%; padding: .8rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-family: ui-monospace, Consolas, monospace; font-size: .85rem; resize: vertical; }

/* =============================================================
   10. Formularios: optimizador, plazos, laborables
   ============================================================= */
.opt-form, .plazo-form { margin: .4rem 0 1rem; }
.grid-2 { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label, .opt-form > label { font-weight: 600; font-size: .93rem; }
.field-btn { justify-content: flex-end; }
.opt-row { display: flex; gap: .5rem; }
.opt-row input { width: 6.5rem; flex: none; }
.opt-row select { flex: 1; }
input[type=number], input[type=date], select {
  height: 48px; padding: 0 .8rem; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); min-width: 0;
}
input[type=number]:focus, input[type=date]:focus, select:focus { outline: none; border-color: var(--accent); }
.optimizer { margin-top: 2.6rem; }
.tool-card.optimizer { margin-top: 0; }
.opt-result:empty, .plazo-result:empty, .lab-result:empty { display: none; }
.opt-sum { background: var(--accent-soft); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 1rem 0; }
.big-num { font-family: var(--display); font-weight: 800; font-size: clamp(2rem, 1.5rem + 2vw, 2.8rem); line-height: 1; color: var(--accent); }
.big-num span { font-size: 1.05rem; color: var(--ink); font-family: var(--sans); font-weight: 600; }
.plan { padding-left: 1.3rem; display: grid; gap: .4rem; }
.titular { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin: 1rem 0; padding: .8rem 1rem; border: 1px dashed var(--accent); border-radius: 12px; }
.titular p { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.opt-cal { margin: 1rem 0; }
.opt-status { margin: .2rem 0 .6rem; }
.plazo-fin { background: var(--accent-soft); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 1rem 0; }
.big-date { font-family: var(--display); font-weight: 800; font-size: clamp(1.6rem, 1.2rem + 2vw, 2.4rem); line-height: 1.1; color: var(--accent); margin: .2rem 0 .4rem; }
.big-date::first-letter { text-transform: uppercase; }
.pasos { margin: 1rem 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.pasos summary { cursor: pointer; padding: .75rem 1rem; font-weight: 600; }
.pasos ol { list-style: none; padding: 0 1rem .8rem; max-height: 420px; overflow: auto; }
.pasos li { display: flex; gap: 1rem; padding: .3rem 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.pasos li span:first-child { width: 7.5rem; flex: none; font-variant-numeric: tabular-nums; }
.pasos li.ok span:last-child { color: var(--accent); font-weight: 600; }
.pasos li.no { color: var(--muted); }
.lab-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; margin: 1rem 0; }
@media (min-width: 720px) { .lab-grid { grid-template-columns: repeat(4, 1fr); } }
.lab-grid > div { background: var(--surface-2); border-radius: 12px; padding: .9rem; }
.lab-result h3 { margin: 1rem 0 .4rem; }

/* =============================================================
   11. Huecos de publicidad (vacíos hasta pegar AdSense)
   ============================================================= */
.ad-slot { display: grid; place-items: center; border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: .75rem; letter-spacing: .14em; font-weight: 600; background: repeating-linear-gradient(45deg, transparent 0 10px, var(--surface-2) 10px 20px); }
.ad-leaderboard { min-height: 100px; margin: 1.6rem 0; }
@media (min-width: 720px) { .ad-leaderboard { min-height: 90px; } }
.ad-incontent { min-height: 250px; margin: 2.4rem 0; }
.ad-popup { min-height: 250px; width: min(300px, 100%); margin: .8rem auto; }
.ad-toast { min-height: 100px; }
.corner-toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; width: min(320px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: .6rem; animation: toastIn .4s var(--ease-out); }
.toast-x { position: absolute; right: -10px; top: -10px; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 1.1rem; line-height: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
.ad-dialog { border: 0; border-radius: 18px; padding: 1.2rem; width: min(380px, calc(100% - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); text-align: center; }
.ad-dialog::backdrop { background: rgba(10, 15, 14, .55); }
.dlg-x { position: absolute; right: .6rem; top: .4rem; font-size: 1.5rem; color: var(--muted); }
.dlg-ok { font-weight: 600; color: var(--accent); }
.ad-dialog .btn { width: 100%; }

/* =============================================================
   12. Widget para insertar
   ============================================================= */
body.widget { padding: 12px; background: var(--surface); }
.w-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.w-title { font-size: 1rem; font-family: var(--sans); font-weight: 700; letter-spacing: 0; }
.w-head a { font-size: .85rem; }
.cal-mini { gap: .6rem; }
@media (min-width: 540px) { .cal-mini { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 720px) { .cal-mini { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* =============================================================
   13. Impresión: una hoja A4
   ============================================================= */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  :root { --surface: #fff; --surface-2: #f2f2f2; --ink: #000; --muted: #555; --line: #ccc; }
  body { background: #fff; font-size: 10pt; }
  .site-head, .site-foot, .crumbs, .page-head, .tool-bar, .ad-slot, .block, .privacy, .corner-toast, .ad-dialog, .notice a, .lg-vac { display: none !important; }
  .print-only { display: block; }
  .print-head { font-size: 12pt; margin-bottom: 4mm; }
  .tool-card { border: 0; box-shadow: none; padding: 0; }
  .cal { grid-template-columns: repeat(4, 1fr) !important; gap: 3mm 4mm !important; }
  .mes h3 { font-size: 9pt; margin-bottom: 1mm; }
  .mes-grid span { font-size: 7pt; border-radius: 2px; }
  .d.nac, .d.aut, .d.loc, .d.isl, .sw, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .d.hl, .d.vac { box-shadow: none !important; }
  .print-only .table-wrap { border: 0; margin-top: 4mm; }
  .print-only table.festivos { font-size: 8pt; column-count: 1; }
  .print-only .festivos th, .print-only .festivos td { padding: 1mm 2mm; }
  .notice { font-size: 8pt; padding: 2mm; }
}

/* =============================================================
   14. Movimiento reducido (solo efectos intrusivos)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .corner-toast { animation: none; }
  html { scroll-behavior: auto; }
}
