:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --ink: #1b2330;
  --ink-2: #4a5464;
  --muted: #7a8291;
  --line: #e1e4dc;
  --accent: #0f5c4f;
  --accent-2: #e5f0ec;
  --ok: #1d7a46; --ok-bg: #e4f4ea;
  --warn: #8a5a00; --warn-bg: #fdf1d8;
  --bad: #a3271f; --bad-bg: #fbe6e3;
  --info: #22528f; --info-bg: #e5eef9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 40, .05), 0 4px 16px rgba(20, 30, 40, .04);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.55rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; word-break: break-all; }
.center { text-align: center; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
main.wrap { flex: 1; padding-top: 26px; padding-bottom: 40px; }
main.narrow { max-width: 760px; }

/* Encabezado */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 22px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-size: 1.05rem; white-space: nowrap; }
.brand b { color: var(--accent); }
.mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 700; font-size: .8rem; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a { text-decoration: none; color: var(--ink-2); padding: 7px 11px; border-radius: 7px; font-size: .93rem; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.who form { margin: 0; }
.pill { display: inline-block; min-width: 19px; padding: 0 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: .74rem; line-height: 19px; text-align: center; font-weight: 600; }
.subbar { background: #12352f; color: #d7e9e3; }
.subbar .wrap { display: flex; align-items: center; gap: 18px; min-height: 44px; flex-wrap: wrap; }
.subbar .nav a { color: #cfe3dc; }
.subbar .nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.subbar .nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.subbar .linkbtn { color: #ffd9a8; }
.subbar form { margin: 0; }
footer.wrap { display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between; color: var(--muted); font-size: .82rem; padding-top: 18px; padding-bottom: 22px; border-top: 1px solid var(--line); }
footer a { color: var(--muted); }

/* Bloques */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.narrow { max-width: 560px; }
.card > h2:first-child { margin-top: 0; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.stat .n { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .88rem; }
a.stat:hover { border-color: var(--accent); }

/* Avisos */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: #c7e8d3; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #f2dca8; }
.alert.bad { background: var(--bad-bg); color: var(--bad); border-color: #f2c5bf; }
.alert.info { background: var(--info-bg); color: var(--info); border-color: #c6d9f1; }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* Etiquetas de estado */
.b { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.b.ok { background: var(--ok-bg); color: var(--ok); }
.b.warn { background: var(--warn-bg); color: var(--warn); }
.b.bad { background: var(--bad-bg); color: var(--bad); }
.b.info { background: var(--info-bg); color: var(--info); }
.b.muted { background: #eceee9; color: var(--ink-2); }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbf8; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbf8; }
td .actions { flex-wrap: nowrap; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* Formularios */
form { margin: 0; }
label { display: block; font-weight: 600; font-size: .88rem; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=month], input[type=number], input[type=search], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-weight: 400; color: var(--ink);
  background: #fff; border: 1px solid #cfd4cb; border-radius: 8px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=file] { margin-top: 6px; font: inherit; }
.stack > * + * { margin-top: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.fields .full { grid-column: 1 / -1; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--ink); }
.check input { margin-top: 4px; }
.radios { display: flex; gap: 18px; flex-wrap: wrap; }
.radios label { display: flex; gap: 7px; align-items: center; font-weight: 500; color: var(--ink); }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 160px; }

/* Botones */
.btn, button { font: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; font-size: .92rem; white-space: nowrap; }
.btn:hover { background: #0b4a40; }
.btn.sec { background: #fff; color: var(--accent); border-color: #c4d3ce; }
.btn.sec:hover { background: var(--accent-2); }
.btn.danger { background: #fff; color: var(--bad); border-color: #ebc3be; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 5px 10px; font-size: .84rem; }
.linkbtn { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; text-decoration: underline; font-size: .9rem; }

/* Pestañas */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { text-decoration: none; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: .88rem; }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Listas de definición */
dl.data { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 8px 16px; margin: 0; }
dl.data dt { color: var(--muted); font-size: .88rem; }
dl.data dd { margin: 0; white-space: pre-wrap; }

/* Clave mostrada una sola vez */
.secret { display: flex; gap: 8px; align-items: center; }
.secret input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.15rem; letter-spacing: .04em; max-width: 260px; }

/* Consultas */
.thread { border-left: 3px solid var(--line); padding: 4px 0 4px 14px; margin: 12px 0; }
.thread .q { white-space: pre-wrap; }
.thread .a { white-space: pre-wrap; background: var(--accent-2); padding: 8px 12px; border-radius: 8px; margin-top: 8px; }

/* Pantallas de ingreso */
body.bare main.wrap { display: grid; place-items: center; }
.auth { width: 100%; max-width: 420px; margin: 4vh auto; }
.auth h1 { margin-bottom: .2rem; }

/* Constancia imprimible */
.constancia { max-width: 760px; margin: 0 auto; }
.constancia .sello { border: 2px solid var(--accent); border-radius: 10px; padding: 14px 18px; display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.constancia .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.4rem; font-weight: 700; letter-spacing: .08em; color: var(--accent); }

@media (max-width: 640px) {
  .who span { display: none; }
  dl.data { grid-template-columns: 1fr; }
  dl.data dt { margin-top: 6px; }
}

@media print {
  .top, .subbar, footer, .no-print, .alert { display: none !important; }
  body, :root { background: #fff; }
  .card { box-shadow: none; border-color: #999; }
  main.wrap { padding: 0; }
}

.btn.block { width: 100%; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mb { margin-bottom: 16px; }
.mt { margin-top: 16px; }

/* v1.1 · documentos */
.doc-prev { display: block; max-width: 100%; max-height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #fafbf8; }
.inline-form .grow { flex: 3; }
.tipo-card { padding: 14px 16px; }
.tipo-card.off { opacity: .6; }
.tipo-form .check { flex: 0 0 auto; min-width: 0; align-self: center; margin-top: 18px; }
.doc-card h2 { margin-bottom: 2px; }

/* v1.1.1 · Dotación: filtros y gráfico de torta (colores categóricos validados para daltonismo; ver lib/charts.js) */
.btn.ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn.ghost:hover { background: var(--bg); color: var(--ink); }
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 14px; align-items: end; margin: 6px 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.filtros-acc { display: flex; gap: 6px; }
.torta { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 28px; align-items: center; }
.torta-svg { width: 100%; height: auto; display: block; }
.torta-svg path { stroke: var(--surface); stroke-width: 2; stroke-linejoin: round; transition: opacity .15s; }
.torta-svg path:hover { opacity: .78; }
.torta-n { font-size: 30px; font-weight: 700; fill: var(--ink); text-anchor: middle; font-variant-numeric: tabular-nums; }
.torta-u { font-size: 12px; fill: var(--muted); text-anchor: middle; }
.torta-ref { width: 100%; border-collapse: collapse; font-size: .92rem; }
.torta-ref th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.torta-ref td { padding: 7px 8px; border-bottom: 1px solid var(--line); color: var(--ink); }
.torta-ref tfoot td { font-weight: 700; border-bottom: 0; }
.torta-ref .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.torta-ref td:first-child { width: 18px; padding-right: 0; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.pz1 { fill: #2a78d6; } .sw.pz1 { background: #2a78d6; }
.pz2 { fill: #eb6834; } .sw.pz2 { background: #eb6834; }
.pz3 { fill: #1baf7a; } .sw.pz3 { background: #1baf7a; }
.pz4 { fill: #eda100; } .sw.pz4 { background: #eda100; }
.pz5 { fill: #e87ba4; } .sw.pz5 { background: #e87ba4; }
.pz6 { fill: #008300; } .sw.pz6 { background: #008300; }
.pz-otros { fill: #9a9c96; } .sw.pz-otros { background: #9a9c96; }
.pz-sin { fill: #d9dbd5; } .sw.pz-sin { background: #d9dbd5; }
@media (max-width: 640px) { .torta { grid-template-columns: 1fr; } .torta-svg { max-width: 220px; margin: 0 auto; } }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
details > summary { cursor: pointer; color: var(--accent); }

/* v1.2 · Ausencias */
.nowrap { white-space: nowrap; }
.warn-txt { color: #8a5a00; }
.stats.compact { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin-bottom: 10px; }
.stats.compact .stat { box-shadow: none; padding: 10px 12px; }
.stats.compact .stat .n { font-size: 1.5rem; }
.stat.destacado { border-color: var(--accent); background: var(--accent-2); }
.stat.destacado .n { color: var(--accent); }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
label.corto input { max-width: 110px; }
.cal { border-collapse: collapse; font-size: .8rem; width: 100%; }
.cal th, .cal td { padding: 0; text-align: center; min-width: 24px; height: 28px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.cal th { font-weight: 600; color: var(--ink-2); padding: 4px 0; line-height: 1.15; }
.cal th span { display: block; font-size: .68rem; color: var(--muted); font-weight: 500; }
.cal .cal-n { text-align: left; padding: 4px 10px; min-width: 150px; white-space: nowrap; border-left: 0; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.cal .fds { background: #f3f4f0; }
.cal th.hoy, .cal td.hoy { box-shadow: inset 0 0 0 2px var(--ink); }
.cal td.k-vacaciones, .sw.k-vacaciones { background: #2a78d6; color: #fff; font-weight: 700; }
.cal td.k-licencia, .sw.k-licencia { background: #eb6834; color: #fff; font-weight: 700; }
.cal td.k-ausencia, .sw.k-ausencia { background: #1baf7a; color: #fff; font-weight: 700; }
.cal td.pend, .sw.pend { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.55) 0 3px, transparent 3px 7px); }
.sw.pend { background-color: #9a9c96; color: #fff; font-weight: 700; }
.cal-ref .sw { width: 18px; height: 18px; line-height: 18px; text-align: center; font-size: .72rem; margin: 0 4px 0 10px; }
.cal-ref .sw:first-child { margin-left: 0; }
.nav .mas { position: relative; }
.nav .mas summary { list-style: none; cursor: pointer; color: var(--ink-2); padding: 7px 11px; border-radius: 7px; font-size: .93rem; }
.nav .mas summary::-webkit-details-marker { display: none; }
.nav .mas summary::after { content: " ▾"; font-size: .75em; }
.nav .mas summary:hover { background: var(--bg); color: var(--ink); }
.nav .mas summary.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.nav .mas-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; min-width: 160px; z-index: 20; }
