/* Layout: una sola columna pensada para el móvil; el reloj y los botones de fichar mandan,
   y cada día se dibuja como una tira horaria (06–22 h) con los tramos trabajados en cada empresa. */
:root {
  /* Colores tomados de colegiozurbaran.com: turquesa de la barra superior, azul de los destacados y rojo de los avisos. */
  --brand: #09BAA5;
  --logo-bg: #FFFFFF;
  --bg: #EEF1F1;
  --surface: #FFFFFF;
  --ink: #151A1C;
  --muted: #5F6668;
  --line: #D5DADB;
  --track: #E1E5E6;
  --accent: #067F71;
  --emp-p: #14607D;
  --on-emp-p: #FFFFFF;
  --emp-z: #09BAA5;
  --on-emp-z: #04332D;
  --work: #05695D;
  --work-bg: #D7F1EC;
  --pause: #8A5A00;
  --pause-bg: #FBEBC8;
  --miss: #BE2530;
  --miss-bg: #FDE1E3;
  --idle-bg: #E5E8E9;
  --font-body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "Azeret Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #101516; --surface: #181E20; --ink: #E8ECEC; --muted: #9AA4A6; --line: #2B3437;
  --track: #232B2E; --accent: #3FD3C0;
  --emp-p: #2E8FB8; --on-emp-p: #FFFFFF; --emp-z: #2ED3BF; --on-emp-z: #04332D;
  --work: #3FD3C0; --work-bg: #0F3530; --pause: #E5B454; --pause-bg: #3A2D10;
  --miss: #FF7A84; --miss-bg: #451A1E; --idle-bg: #232B2E;
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101516; --surface: #181E20; --ink: #E8ECEC; --muted: #9AA4A6; --line: #2B3437;
  --track: #232B2E; --accent: #3FD3C0;
  --emp-p: #2E8FB8; --on-emp-p: #FFFFFF; --emp-z: #2ED3BF; --on-emp-z: #04332D;
  --work: #3FD3C0; --work-bg: #0F3530; --pause: #E5B454; --pause-bg: #3A2D10;
  --miss: #FF7A84; --miss-bg: #451A1E; --idle-bg: #232B2E;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  padding-inline: 16px;
  border-top: 6px solid var(--brand);
}
.app { max-width: 42rem; margin-inline: auto; padding-block: 18px 48px; display: flex; flex-direction: column; gap: 20px; }
h1, h2, h3, p, ol, ul, fieldset, legend { margin: 0; padding: 0; }
ol, ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; gap: 12px; }
.top .logo { width: 52px; height: 52px; flex: none; object-fit: contain; background: var(--logo-bg); border-radius: 50%; padding: 4px; box-shadow: 0 0 0 1px var(--line); }
.top h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: .01em; flex: 1; min-width: 0; }
.who { font-size: .9rem; min-width: 0; overflow-wrap: anywhere; text-align: right; display: flex; flex-direction: column; }
.who #who { font-weight: 600; }
.dep { color: var(--muted); font-size: .8rem; font-weight: 400; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--track); border-radius: var(--r); }
.tabs button {
  flex: 1 1 0; min-width: 0; border: 0; background: transparent; padding: 10px 6px; border-radius: 7px;
  font-weight: 600; font-size: .95rem; color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); }

.view { display: flex; flex-direction: column; gap: 20px; }

/* Reloj */
.clock { text-align: center; display: flex; flex-direction: column; gap: 2px; padding-block: 8px 0; }
.clock .date { color: var(--muted); font-size: .95rem; }
.clock .date::first-letter { text-transform: uppercase; }
.clock .time {
  font-family: var(--font-data); font-weight: 500; font-variant-numeric: tabular-nums;
  font-size: clamp(3.2rem, 17vw, 5.2rem); line-height: 1.05; letter-spacing: -.03em;
}
.clock .src { color: var(--muted); font-size: .78rem; min-height: 1.2em; }
.clock .time .sec { font-size: .42em; color: var(--muted); letter-spacing: 0; margin-left: .15em; }

/* Estado */
.status { display: flex; align-items: center; justify-content: center; gap: 6px 10px; flex-wrap: wrap; text-align: center; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 9px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--idle-bg); color: var(--muted);
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.trabajando { background: var(--work-bg); color: var(--work); }
.pill.pausa { background: var(--pause-bg); color: var(--pause); }
.pill.falta { background: var(--miss-bg); color: var(--miss); }
.status .txt { font-size: .95rem; }

/* Botones */
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .lbl { font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); text-align: center; }
.btn {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: var(--r);
  padding: 14px 18px; font-weight: 600; font-size: 1rem; cursor: pointer; min-height: 52px;
}
.btn.main { min-height: 68px; font-size: 1.2rem; font-weight: 700; border-color: transparent; }
.btn.emp-p { background: var(--emp-p); color: var(--on-emp-p); }
.btn.emp-z { background: var(--emp-z); color: var(--on-emp-z); }
.btn.salida { background: var(--ink); color: var(--bg); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 0; padding: 9px 14px; font-size: .9rem; }
.btn.tiny { min-height: 0; padding: 4px 10px; font-size: .8rem; border-width: 1px; border-radius: 7px; }
.btn.danger { border-color: var(--miss); color: var(--miss); }

.note { background: var(--pause-bg); color: var(--ink); border-radius: var(--r); padding: 12px 14px; font-size: .92rem; }
.note.info { background: var(--idle-bg); }

/* Bloques */
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h2, .motivo legend { font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.total { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.05rem; }
.empty { color: var(--muted); font-size: .95rem; }

/* Motivo de salida */
.motivo fieldset { display: flex; flex-direction: column; gap: 8px; }
.motivo legend { margin-bottom: 10px; }
.motivo label { display: flex; align-items: center; gap: 12px; border: 1.5px solid var(--line); border-radius: var(--r); padding: 13px 14px; font-weight: 600; cursor: pointer; }
.motivo label:has(input:checked) { border-color: var(--ink); }
.motivo input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }

/* Empresas */
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--muted); margin-right: 6px; }
.sw.P { background: var(--emp-p); }
.sw.Z { background: var(--emp-z); }
.split { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .85rem; color: var(--muted); }
.split b { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }

/* Tira horaria */
.strip { display: flex; flex-direction: column; gap: 4px; }
.bar { position: relative; height: 14px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bar .seg { position: absolute; top: 0; bottom: 0; min-width: 2px; background: var(--muted); }
.bar .seg.P { background: var(--emp-p); }
.bar .seg.Z { background: var(--emp-z); }
.bar .now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); }
.scale { display: flex; justify-content: space-between; font-family: var(--font-data); font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Marcas */
.marks { display: flex; flex-direction: column; }
.marks li { display: grid; grid-template-columns: 3.3rem minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline; padding-block: 8px; border-top: 1px dashed var(--line); font-size: .92rem; }
.marks li:first-child { border-top: 0; padding-top: 0; }
.marks li:last-child { padding-bottom: 0; }
.marks .hh { font-family: var(--font-data); font-weight: 600; font-variant-numeric: tabular-nums; }
.marks .qq { min-width: 0; overflow-wrap: anywhere; }
.marks .borrada .hh, .marks .borrada .qq { text-decoration: line-through; color: var(--muted); }
.marks .nota { grid-column: 2 / -1; font-size: .8rem; color: var(--miss); font-weight: 600; }
.marks .confirm { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .85rem; padding-top: 4px; }

/* Navegación de mes */
.monthnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monthnav .label { font-weight: 700; font-size: 1.05rem; text-align: center; flex: 1; min-width: 0; }
.monthnav .label::first-letter { text-transform: uppercase; }
.monthnav button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 8px; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer; flex: none; }
.monthnav button:disabled { opacity: .35; cursor: default; }

/* Días y personas plegables */
.rows { display: flex; flex-direction: column; }
.rows > li { border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.rows summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline; padding-block: 12px; cursor: pointer; list-style: none; }
.rows summary::-webkit-details-marker { display: none; }
.rows > li:first-child summary { padding-top: 0; }
.rows .d { font-weight: 600; }
.rows .w { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-weight: 600; font-size: .95rem; text-align: right; }
.rows .x { grid-column: 1 / -1; font-size: .84rem; color: var(--muted); display: flex; gap: 4px 10px; flex-wrap: wrap; align-items: center; }
.rows .x .t { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.rows .inside { padding: 0 0 14px 0; display: flex; flex-direction: column; gap: 14px; }
.rows h3 { font-size: .84rem; font-weight: 700; margin-bottom: 6px; }
.rows h3::first-letter { text-transform: uppercase; }

/* Panel */
.counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .counts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.count { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.count b { font-family: var(--font-data); font-size: 1.9rem; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.count span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.count.falta b { color: var(--miss); }
.count.trabajando b { color: var(--work); }
.count.pausa b { color: var(--pause); }

.people { display: flex; flex-direction: column; }
.people li { display: flex; flex-direction: column; gap: 8px; padding-block: 14px; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; padding-top: 0; }
.people li:last-child { padding-bottom: 0; }
.person { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.person img { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.person .name, .staff .name { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.name small { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); }
.person-times { font-size: .86rem; color: var(--muted); display: flex; gap: 4px 14px; flex-wrap: wrap; }
.person-times b { color: var(--ink); font-weight: 600; font-family: var(--font-data); font-variant-numeric: tabular-nums; }

/* Empleados: lista y formulario de alta */
.staff { display: flex; flex-direction: column; }
.staff li { display: flex; align-items: center; gap: 10px; padding-block: 11px; border-top: 1px solid var(--line); }
.staff li:first-child { border-top: 0; padding-top: 0; }
.staff img, .hits img { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.sub { font-size: .95rem; font-weight: 700; }
.hint { font-size: .82rem; color: var(--muted); }
.pend { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.alta { display: flex; flex-direction: column; gap: 14px; padding: 14px; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--bg); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > legend { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field > legend { margin-bottom: 6px; }
.field input[type="text"], .field input[type="search"], .field input[type="email"] {
  font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; padding: 11px 12px; width: 100%; min-width: 0;
}
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chips label { display: flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 8px; font-weight: 600; font-size: .84rem; background: var(--surface); cursor: pointer; min-width: 0; overflow-wrap: anywhere; }
.chips label:has(input:checked) { border-color: var(--accent); }
.chips input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; }
.hits { display: flex; flex-direction: column; gap: 6px; }
.hits button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-weight: 600; }
.chosen { font-weight: 600; }
.err { color: var(--miss); font-size: .88rem; font-weight: 600; }
.form-actions { display: flex; gap: 10px; }
.form-actions .btn { flex: 1; min-height: 48px; padding: 10px 14px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); margin-inline: auto; max-width: 26rem;
  background: var(--ink); color: var(--bg); border-radius: var(--r); padding: 13px 16px; font-weight: 600; text-align: center; z-index: 5;
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(8px); opacity: .4; } to { transform: none; opacity: 1; } }
}

/* ---- Añadidos de la versión definitiva ---- */
[hidden] { display: none !important; }
.screen { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.screen h2.big { font-size: 1.35rem; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); }
.steps { display: flex; flex-direction: column; gap: 10px; counter-reset: paso; }
.steps li { counter-increment: paso; display: grid; grid-template-columns: 2rem 1fr; gap: 10px; align-items: start; }
.steps li::before { content: counter(paso); width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--work-bg); color: var(--work); font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.code-input { font-family: var(--font-data); font-size: 1.6rem; letter-spacing: .12em; text-transform: uppercase; text-align: center; padding: 14px; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); width: 100%; }
.code-show { font-family: var(--font-data); font-size: 2rem; font-weight: 600; letter-spacing: .1em; text-align: center; padding: 14px; border-radius: var(--r); background: var(--work-bg); color: var(--work); user-select: all; }
.field select, .field input[type="tel"], .field input[type="number"], .field input[type="password"] {
  font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; padding: 11px 12px; width: 100%; min-width: 0;
}
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.staff li { flex-wrap: wrap; }
.staff .meta { width: 100%; padding-left: 0; font-size: .8rem; color: var(--muted); display: flex; gap: 4px 12px; flex-wrap: wrap; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--idle-bg); color: var(--muted); vertical-align: 1px; }
.tag.ok { background: var(--work-bg); color: var(--work); }
.tag.warn { background: var(--pause-bg); color: var(--pause); }
.tag.bad { background: var(--miss-bg); color: var(--miss); }
.panel-detalle { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--bg); }
.imp-tabla { width: 100%; border-collapse: collapse; font-size: .84rem; }
.imp-tabla th, .imp-tabla td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.imp-tabla th { color: var(--muted); font-weight: 600; border-top: 0; }
.scroll-x { overflow-x: auto; }
.audit { display: flex; flex-direction: column; }
.audit li { padding-block: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.audit li:first-child { border-top: 0; padding-top: 0; }
.audit .when { font-family: var(--font-data); font-size: .8rem; color: var(--muted); }
.audit .what { font-weight: 600; }
.audit .who { font-size: .84rem; color: var(--muted); text-align: left; display: block; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.filtros select { font: inherit; font-size: .9rem; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); min-width: 0; flex: 1; }
.btn.link { border: 0; background: none; padding: 4px 0; min-height: 0; color: var(--accent); text-decoration: underline; font-size: .9rem; }
.note.bad { background: var(--miss-bg); }
.note.ok { background: var(--work-bg); }
a { color: var(--accent); }
/* Terminal */
.kiosk { max-width: 30rem; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { min-height: 64px; font-size: 1.5rem; font-weight: 600; font-family: var(--font-data); border: 1.5px solid var(--line); background: var(--surface); border-radius: var(--r); cursor: pointer; }
.pin-dots { font-family: var(--font-data); font-size: 2rem; letter-spacing: .3em; text-align: center; min-height: 2.6rem; }
.row-actions.left { justify-content: flex-start; }
.search { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; min-width: 0; }
.marks .nota.muted { color: var(--muted); font-weight: 400; }
.kiosk-hora { font-family: var(--font-data); font-size: clamp(3rem, 14vw, 5rem); font-weight: 500; text-align: center; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kiosk-fecha { text-align: center; color: var(--muted); }
.kiosk-fecha::first-letter { text-transform: uppercase; }
.cuenta-atras { text-align: center; color: var(--muted); font-size: .9rem; }
a.btn { display: inline-block; text-decoration: none; color: var(--ink); text-align: center; }
/* Terminal en tablet: más ancho y teclas más grandes */
@media (min-width: 700px) {
  .kiosk { max-width: 40rem; }
  .kiosk .keypad button { min-height: 84px; font-size: 2rem; }
  .kiosk .code-input { font-size: 2rem; padding: 18px; }
  .kiosk .btn.main { min-height: 80px; font-size: 1.4rem; }
}
