/* Estilos compartidos. Sin estilos en línea (la política de seguridad los bloquea). */
:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1b2430; --muted: #667085; --line: #e1e5ea;
  --brand: #0f5c8a; --brand-ink: #fff; --ok: #1a7f4b; --warn: #b26a00; --bad: #c0392b;
  --warn-bg: #fff4e0; --bad-bg: #fdecea; --ok-bg: #e6f5ec; --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: #12171d; --panel: #1b222b; --text: #e8edf3; --muted: #93a0b0; --line: #2c3642;
    --brand: #4aa3d8; --brand-ink: #06202f; --ok: #46c084; --warn: #f0b24d; --bad: #ff7a6b;
    --warn-bg: #3a2f17; --bad-bg: #3d1f1c; --ok-bg: #16301f;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 16px; line-height: 1.4; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Administración ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
nav.tabs { display: flex; gap: 4px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
nav.tabs button { border: 0; background: none; padding: 12px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
nav.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
main { padding: 20px; max-width: 1200px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); min-width: 150px; }
textarea { min-width: 280px; }
button.btn { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
button.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.btn.danger { color: var(--bad); border-color: var(--bad); }
button.btn.small { padding: 4px 9px; font-size: 13px; }
button.btn:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--line); color: var(--text); margin: 1px 2px 1px 0; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.strike { text-decoration: line-through; color: var(--muted); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.login { max-width: 360px; margin: 12vh auto; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 20px; max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog h3 { margin-top: 0; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 28px; letter-spacing: .15em; padding: 12px; background: var(--bg); border-radius: 8px; text-align: center; word-break: break-all; }
.secret.small { font-size: 14px; letter-spacing: 0; }
.qr { display: flex; justify-content: center; padding: 12px; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* ---------- Puesto de fichaje (kiosco) ---------- */
body.kiosk {
  --bg: #0e1319; --panel: #18202a; --text: #f1f5f9; --muted: #8fa0b3; --line: #2a3644;
  --brand: #3b9ddb; --ok: #34c17a; --bad: #ff6b5b; --warn: #f0b24d;
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; overflow: hidden;
}
.k-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; color: var(--muted); font-size: 18px; }
.k-head .where strong { color: var(--text); }
.k-clock { font-size: 38px; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.k-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 24px 24px; gap: 18px; }
.k-title { font-size: 26px; color: var(--muted); }
.k-dots { display: flex; gap: 18px; height: 28px; }
.k-dots i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); }
.k-dots i.on { background: var(--brand); border-color: var(--brand); }
.k-msg { min-height: 30px; font-size: 22px; color: var(--bad); text-align: center; }
.keypad { display: grid; grid-template-columns: repeat(3, 104px); gap: 14px; }
.keypad button { height: 88px; font-size: 38px; font-weight: 600; border-radius: 18px; border: 0; background: var(--panel); color: var(--text); cursor: pointer; }
.keypad button:active { background: var(--brand); }
.keypad button.aux { font-size: 22px; color: var(--muted); background: transparent; }
.k-name { font-size: 44px; font-weight: 700; text-align: center; }
.k-status { font-size: 24px; color: var(--muted); text-align: center; }
.k-actions { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; width: 100%; max-width: 820px; }
.k-act { flex: 1 1 300px; min-height: 150px; font-size: 40px; font-weight: 700; border-radius: 22px; border: 0; cursor: pointer; background: var(--panel); color: var(--text); }
.k-act.primary { background: var(--ok); color: #062915; }
.k-act.out { background: var(--bad); color: #2d0905; }
.k-act.pause { background: var(--warn); color: #2d1d00; }
.k-act:active { filter: brightness(1.25); transform: scale(.98); }
.k-link { background: none; border: 0; color: var(--muted); font-size: 22px; padding: 14px 24px; cursor: pointer; }
.k-recent { color: var(--muted); font-size: 18px; text-align: center; }
.k-warn { background: var(--warn-bg, #3a2f17); color: var(--warn); padding: 12px 20px; border-radius: 12px; font-size: 22px; max-width: 760px; text-align: center; }
.k-done .tick { font-size: 130px; color: var(--ok); line-height: 1; }
.k-done .big { font-size: 46px; font-weight: 700; text-align: center; }
.k-pair { max-width: 560px; text-align: center; }
.k-pair input { width: 100%; font-size: 20px; }
.k-scan video { width: min(80vw, 520px); border-radius: 16px; background: #000; }
.k-bar { position: fixed; left: 0; bottom: 0; height: 6px; background: var(--brand); width: 100%; transform-origin: left; }
.k-bar.run { animation: shrink 12s linear forwards; }
@keyframes shrink { to { transform: scaleX(0); } }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
@media (max-height: 640px) {
  .keypad { grid-template-columns: repeat(3, 84px); gap: 10px; }
  .keypad button { height: 66px; font-size: 30px; }
  .k-act { min-height: 110px; font-size: 32px; }
}

/* ---------- Impresión: solo el diálogo abierto (tarjetas QR / PIN) ---------- */
@media print {
  .topbar, nav.tabs, main, #toasts, dialog .row, dialog .muted { display: none !important; }
  body { background: #fff; }
  dialog { position: static; border: 0; box-shadow: none; max-width: none; }
  dialog::backdrop { background: none; }
}

.menu-link { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; }
.menu-link:hover, .menu-link:focus-visible { border-color: var(--text); }

dialog.wide { max-width: 820px; max-height: 92vh; overflow-y: auto; }
dialog.pdf { max-width: 1000px; width: calc(100% - 16px); max-height: 96vh; }
.pdfview { display: block; width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.ficha fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 10px 12px 2px; }
.ficha legend { font-weight: 600; padding: 0 6px; }
.ficha label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.ficha textarea { width: 100%; box-sizing: border-box; margin-bottom: 10px; }

/* ---- perfiles, aprobaciones, cumplimiento y Mi jornada ---- */
.hidden { display: none !important; }
.check { padding: 8px 0; border-bottom: 1px solid var(--line); }
.checkrow { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checkrow input { margin-top: 4px; min-width: 0; }
label.inline { display: inline-flex; flex-direction: row; gap: 6px; align-items: center; margin: 2px 12px 2px 0; }
label.inline input { min-width: 0; }
.doc h4 { margin: 14px 0 4px; }
.doc p { margin: 0 0 6px; }
body.worker main { max-width: 640px; margin: 0 auto; padding: 12px 16px 40px; }
.monthnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monthnav h2 { margin: 0; }
.stats { display: flex; gap: 20px; flex-wrap: wrap; margin: 12px 0; }
.stats .big { font-size: 28px; font-weight: 700; }
.stats .neg { color: var(--bad); }
.stats .pos { color: var(--ok); }
.day { padding: 8px 0; border-bottom: 1px solid var(--line); }
.dayhead { display: flex; justify-content: space-between; gap: 8px; }
.strike { text-decoration: line-through; }

/* ---- cuadrante de turnos ---- */
table.grid th.left { text-align: left; white-space: nowrap; }
.shiftcell { vertical-align: top; min-width: 96px; }
.shift { border: 1px solid rgba(80,180,120,.6); border-radius: 6px; padding: 2px 6px; margin: 2px 0; font-size: .85rem; cursor: pointer; background: rgba(80,180,120,.18); color: inherit; }
.shift.draft { background: rgba(150,150,150,.15); border: 1px dashed rgba(150,150,150,.7); }
.shift.warn { border-color: #e0584a; background: rgba(224,88,74,.22); }
.btn.ghost { background: transparent; border: 1px dashed #aab; opacity: .6; padding: 0 6px; }
.shift .muted { font-size: .7rem; }

.subnav { gap: 6px; margin-bottom: 8px; }
.table-wrap.month .shiftcell { min-width: 44px; padding: 2px; }
.table-wrap.month .shift { font-size: .72rem; padding: 1px 3px; }
.table-wrap.month th { padding: 4px 2px; text-align: center; font-size: .72rem; }
.table-wrap.month th.left { min-width: 150px; text-align: left; position: sticky; left: 0; background: var(--bg, #14181f); }
th.weekend { opacity: .65; }
.plus { border: 1px dashed #889; background: transparent; color: inherit; opacity: .35; border-radius: 4px; cursor: pointer; font-size: .7rem; padding: 0 4px; }
tr.coverage td { text-align: center; }
details.cmp { border: 1px solid rgba(150,150,150,.3); border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
details.cmp summary { cursor: pointer; }
.neg { color: #e0584a; } .pos { color: #4cb07a; }

/* ---- calendario de festivos ---- */
.cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 10px; }
.minimonth table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.minimonth th, .minimonth td { text-align: center; padding: 2px 0; width: 14%; }
.minimonth td.we { opacity: .6; }
.minimonth td.today { outline: 1px solid currentColor; border-radius: 4px; }
.hol { border-radius: 4px; font-weight: 600; }
.hol-national { background: rgba(224,88,74,.35); } .hol-regional { background: rgba(230,160,40,.38); } .hol-local { background: rgba(140,110,230,.4); }
.legend { display: flex; gap: 8px; margin: 8px 0; } .legend span { padding: 2px 10px; font-size: .8rem; }
th.holiday { background: rgba(230,160,40,.18); }

/* ---- indicador de conexión del puesto ---- */
.k-net { font-size: .85rem; padding: 2px 10px; border-radius: 12px; }
.k-net:empty { display: none; }
.k-net.off { background: rgba(224,88,74,.3); } .k-net.warn { background: rgba(230,160,40,.3); cursor: pointer; }

/* ---- calendario de ausencias ---- */
td.abs { text-align: center; font-weight: 700; font-size: .75rem; }
td.abs-vacaciones { background: rgba(80,160,230,.5); } td.abs-enfermedad { background: rgba(224,88,74,.5); } td.abs-permiso_retribuido { background: rgba(80,180,120,.5); }
td.abs-asuntos_propios { background: rgba(140,110,230,.5); } td.abs-dia_libre { background: rgba(150,150,150,.5); } td.abs-festivo_trabajado { background: rgba(230,160,40,.55); }
td.abs-compensacion { background: rgba(230,200,60,.5); } td.abs-otro { background: rgba(120,120,120,.4); } td.abs.pending { opacity: .45; }
input.w9 { width: 9em; } input.w6 { width: 6em; }

pre.codes { font-size: 1.2rem; letter-spacing: .08em; padding: 12px; background: rgba(150,150,150,.15); border-radius: 8px; user-select: all; }

.shiftcell.pickable, th.pickable { cursor: pointer; }
.shiftcell.sel { outline: 2px solid #2b6cb0; outline-offset: -2px; background: rgba(43, 108, 176, .18); }

.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline dotted; cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }
.searchbox { position: relative; display: flex; gap: 6px; align-items: center; }
.searchbox input { min-width: 200px; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; min-width: 320px; max-height: 360px; overflow-y: auto; z-index: 50; margin-top: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.search-item { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; width: 100%; text-align: left; padding: 8px 12px; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; color: inherit; cursor: pointer; }
.search-item:hover, .search-item:focus { background: rgba(127,127,127,.15); }
.search-empty { padding: 10px 12px; }
table.yearcal td { min-width: 26px; text-align: center; font-size: .72rem; padding: 3px 2px; cursor: pointer; }
table.yearcal td.off { background: transparent; cursor: default; }
table.yearcal td.has-shift { background: rgba(43, 108, 176, .28); }
table.yearcal td.has-shift.draft { opacity: .6; }
table.yearcal td.weekend { box-shadow: inset 0 0 0 100px rgba(128, 128, 128, .12); }
table.yearcal td.today { outline: 2px solid #2b6cb0; outline-offset: -2px; }
