/* Tema provisional (oscuro). Se reemplazará por los tokens del diseño "Nocturne". */
:root {
  --bg: #0b0d12;
  --surface: #141821;
  --surface-2: #1c212d;
  --border: #2a3140;
  --text: #eef1f6;
  --muted: #9aa4b5;
  --accent: #7c9cff;
  --ok: #22c55e;
  --ok-bg: rgba(34, 197, 94, .14);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, .14);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, .14);
  --radius: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

/* ---------- cabecera ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: .78rem; white-space: nowrap; }
@media (max-width: 400px) { .brand small { display: none; } }
.top-right { display: flex; gap: 6px; align-items: center; }
.pill {
  font-size: .75rem; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); white-space: nowrap;
}
.pill::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: currentColor; }
.pill-on { color: var(--ok); }
.pill-off { color: var(--warn); }
.pill-pend { color: var(--accent); }
.pill-pend::before { animation: pulso 1.6s ease-in-out infinite; }
.pill-err { color: var(--danger); }
@keyframes pulso { 50% { opacity: .3; } }

.banner { font-size: .82rem; padding: 9px 12px; border-radius: 12px; margin-bottom: 10px; background: var(--warn-bg); color: #fcd9a0; }
.banner-info { background: rgba(124, 156, 255, .12); color: #c9d5ff; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

main { flex: 1; display: flex; flex-direction: column; gap: 14px; }

/* ---------- reloj ---------- */
.reloj { text-align: center; padding: 14px 0 6px; }
.hora { font: 700 clamp(3rem, 16vw, 4.6rem)/1 var(--mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fecha { color: var(--muted); margin-top: 8px; font-size: .95rem; }

/* ---------- tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.lbl { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.cedula-wrap { position: relative; }
#cedula {
  width: 100%; font: 600 1.7rem var(--mono); letter-spacing: .14em; text-align: center;
  padding: 14px 44px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text); outline: none;
}
#cedula:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 156, 255, .18); }
#cedula::placeholder { color: #4a5263; }
.icon-btn { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); padding: 6px 10px; }
.cedula-wrap .icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

.msg { min-height: 1.2em; margin: 10px 2px 0; font-size: .88rem; }
.msg-error { color: #fca5a5; }
.msg-info { color: var(--muted); }

.empleado { display: flex; gap: 14px; align-items: center; margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: linear-gradient(135deg, #3b4a7a, #7c9cff); }
.emp-nombre { font-weight: 700; font-size: 1.05rem; }
.emp-cargo { color: var(--muted); font-size: .85rem; }
.emp-estado { margin-top: 4px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.emp-estado.ok { color: var(--ok); }
.emp-estado.warn { color: var(--warn); }

.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

/* ---------- botones ---------- */
.btn {
  border: 0; border-radius: 14px; padding: 16px 14px; font-weight: 700; font-size: 1.02rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, opacity .15s ease, background-color .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .28; cursor: not-allowed; }
.btn .ico { font-size: 1.2rem; }
.btn-entrada { background: var(--ok); color: #04210f; }
.btn-salida { background: var(--danger); color: #fff; }
.acciones .btn { min-height: 74px; font-size: 1.08rem; }
.btn-sec { background: var(--surface-2); border: 1px solid var(--border); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-primary { background: var(--accent); color: #0b1230; }
.btn-primary.btn-entrada { background: var(--ok); color: #04210f; }
.btn-primary.btn-salida { background: var(--danger); color: #fff; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 4px; }

/* ---------- confirmación ---------- */
.confirm-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.conf-nombre { font-weight: 700; }
.tag { font: 800 .72rem var(--font); letter-spacing: .08em; padding: 5px 9px; border-radius: 8px; }
.tag-entrada { background: var(--ok-bg); color: var(--ok); }
.tag-salida { background: var(--danger-bg); color: #f87171; }

.foto-zona {
  aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: var(--surface-2);
  border: 1.5px dashed var(--border); display: grid; place-items: center; position: relative;
}
.foto-zona video, .foto-zona img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-zona video.espejo { transform: scaleX(-1); }
.foto-vacia { color: var(--muted); display: grid; gap: 6px; justify-items: center; font-size: .9rem; }
.cam-ico { font-size: 2rem; opacity: .7; }
.foto-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.foto-btns .btn { flex: 1; padding: 12px; font-size: .95rem; }
#btnGirar { flex: 0 0 52px; }
.legal { font-size: .74rem; color: var(--muted); margin: 10px 2px 0; }
.confirm-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 16px; }

/* ---------- comprobante ---------- */
.comprobante { text-align: center; display: grid; gap: 4px; justify-items: center; }
.check { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; font-weight: 800; margin-bottom: 6px; }
.check-entrada { background: var(--ok-bg); color: var(--ok); }
.check-salida { background: var(--danger-bg); color: #f87171; }
.check-pend { background: var(--warn-bg); color: var(--warn); font-size: 1.7rem; }
.comprobante h2 { margin: 0; font-size: 1.25rem; }
.comp-hora { font: 700 2.6rem/1.1 var(--mono); font-variant-numeric: tabular-nums; margin-top: 4px; }
.comp-fecha { color: var(--muted); }
.comp-nombre { font-weight: 600; margin-top: 6px; }
.comp-estado { margin: 10px 0 4px; font-size: .88rem; font-weight: 600; padding: 8px 12px; border-radius: 10px; }
.comp-estado.ok { background: var(--ok-bg); color: var(--ok); }
.comp-estado.pend, .comp-estado.warn { background: var(--warn-bg); color: #fcd34d; }
#compFoto { width: 100%; border-radius: 12px; margin: 8px 0; }
.comprobante .btn { width: 100%; margin-top: 8px; }
.cuenta { color: var(--muted); font-size: .78rem; margin-top: 4px; }

/* ---------- pendientes ---------- */
dialog {
  width: min(520px, calc(100% - 24px)); max-height: 80dvh; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h3 { margin: 0; }
.dlg-txt { color: var(--muted); font-size: .85rem; }
.lista-pend { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.lista-pend li { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.lista-pend .vacio { color: var(--muted); justify-content: center; }
.pend-info { flex: 1; display: grid; }
.pend-info small { color: var(--muted); }
.pend-info .err { color: #fca5a5; }
#btnSyncAhora { width: 100%; }

.pie { text-align: center; color: #4a5263; font-size: .72rem; padding-top: 14px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ---------- activación ---------- */
.card-title { margin: 0 0 6px; font-size: 1.15rem; }
.card-txt { margin: 0 0 16px; color: var(--muted); font-size: .9rem; }
.input-codigo, .input-texto {
  width: 100%; padding: 14px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text); outline: none; font: inherit;
}
.input-codigo { font: 700 1.6rem var(--mono); letter-spacing: .18em; text-align: center; text-transform: uppercase; }
.input-codigo:focus, .input-texto:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 156, 255, .18); }
.lbl-sep { margin-top: 14px; }
.opc { font-weight: 400; }
.btn-bloque { width: 100%; margin-top: 6px; }
#cedula[readonly] { color: var(--muted); }
.recordar { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.recordar input { margin-top: 2px; }
.recordatorio { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: .85rem; color: var(--muted); }
.btn-mini { padding: 8px 12px; font-size: .85rem; border-radius: 10px; flex: none; }
.link-otro { display: block; margin: 10px auto 0; }
.link-guia { color: var(--accent); text-decoration: none; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
