/* Control de Horas — estilos sin dependencias ni compilación */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #dde3ec;
  --text: #17202e;
  --muted: #5d6b80;
  --primary: #1d4ed8;
  --primary-strong: #1e40af;
  --primary-soft: #e3ebfd;
  --ok: #15803d;
  --ok-soft: #dcf5e4;
  --warn: #a15c07;
  --warn-soft: #fdf0d5;
  --danger: #c0262d;
  --danger-soft: #fde2e2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c;
    --surface: #171e29;
    --surface-2: #1e2734;
    --border: #2b3646;
    --text: #e6ebf2;
    --muted: #9aa8bb;
    --primary: #6b98ff;
    --primary-strong: #8fb0ff;
    --primary-soft: #1c2b4d;
    --ok: #4ade80;
    --ok-soft: #12321f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0c;
    --danger: #f87171;
    --danger-soft: #3d1517;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }

/* ---------- Barra superior del panel ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1000;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 16px; min-height: 56px;
}
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 14px;
}
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.user-menu { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.user-menu form { margin: 0; }

@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; gap: 6px 12px; padding-top: 8px; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  .user-menu { margin-left: auto; }
  .user-menu .user-name { display: none; }
}

.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: .75rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 14px 16px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.stat .value { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.stat .hint { font-size: .8rem; color: var(--muted); }
.stat.ok .value { color: var(--ok); }
.stat.danger .value { color: var(--danger); }
.stat.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.stat.primary .label, .stat.primary .hint { color: rgba(255, 255, 255, .82); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 4px 10px; font-size: .85rem; border-radius: 7px; }
.btn-link { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 500; cursor: pointer; font: inherit; }
.btn-link:hover { text-decoration: underline; background: none; }
.btn-link.danger { color: var(--danger); }
form.inline { display: inline; margin: 0; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.full { grid-column: 1 / -1; }
@media (max-width: 560px) { .field.span-2 { grid-column: 1 / -1; } }
label, .label { font-weight: 600; font-size: .88rem; }
.help { font-size: .8rem; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.is-invalid { border-color: var(--danger) !important; }
.error-text { color: var(--danger); font-size: .82rem; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.checks {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px;
  max-height: 320px; overflow: auto; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.toolbar .field { min-width: 150px; flex: 1 1 150px; max-width: 260px; }
.toolbar .field.grow { max-width: none; flex: 2 1 220px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
td.acciones { white-space: nowrap; text-align: right; }
td.acciones > * + * { margin-left: 10px; }
.tabla-compacta th, .tabla-compacta td { padding: 7px 9px; font-size: .88rem; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- Etiquetas y avisos ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }

.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--primary-soft); color: var(--primary); }
.alert ul { margin: 4px 0 0; padding-left: 20px; }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }

.credencial {
  background: var(--surface); border: 2px dashed var(--primary); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}
.credencial code { font-size: 1.2rem; font-weight: 700; letter-spacing: .06em; background: var(--primary-soft); padding: 2px 8px; border-radius: 6px; }

.pagination { display: flex; gap: 4px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { color: var(--muted); opacity: .6; }

/* ---------- Mapa ---------- */
.mapa { height: 420px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 0; }
.mapa.alto { height: 480px; }
@media (max-width: 560px) { .mapa, .mapa.alto { height: 320px; } }
.mapa-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.mapa-tools input { flex: 1 1 220px; }
.resultados { list-style: none; margin: 0 0 10px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); max-height: 220px; overflow: auto; }
.resultados li { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: .9rem; }
.resultados li:last-child { border-bottom: 0; }
.resultados li:hover { background: var(--surface-2); }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; font-size: 1.2rem; margin-bottom: 18px; }
.auth-card .btn { width: 100%; padding: 11px; }

/* ---------- Portal del funcionario (celular) ---------- */
.portal { max-width: 520px; margin: 0 auto; padding: 14px 16px 96px; }
.portal-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.portal-top .hola { font-size: .85rem; color: var(--muted); }
.portal-top .nombre { font-weight: 700; font-size: 1.05rem; }
.estado-jornada { text-align: center; padding: 22px 16px; }
.estado-jornada .estado { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
.estado-jornada.activa .estado { color: var(--ok); }
.estado-jornada .reloj { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.estado-jornada .detalle { color: var(--muted); }
.btn-marcar {
  width: 100%; padding: 18px; font-size: 1.15rem; border-radius: 14px; margin-top: 16px; border: 0;
  background: var(--primary); color: #fff; font-weight: 700; cursor: pointer;
}
.btn-marcar.salida { background: var(--danger); }
.btn-marcar:disabled { opacity: .45; cursor: not-allowed; }
.ubicacion { display: flex; gap: 12px; align-items: flex-start; }
.ubicacion .punto { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); margin-top: 6px; flex: none; }
.ubicacion.dentro .punto { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.ubicacion.fuera .punto { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.ubicacion.buscando .punto { animation: latido 1.2s infinite; background: var(--primary); }
@keyframes latido { 50% { opacity: .25; } }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.lista li:last-child { border-bottom: 0; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border);
  display: flex; justify-content: center; z-index: 1000; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a, .tabbar button {
  flex: 1; max-width: 170px; text-align: center; padding: 10px 6px 12px; color: var(--muted); font-size: .78rem; font-weight: 600;
  background: none; border: 0; font-family: inherit; cursor: pointer;
}
.tabbar .ico { display: block; font-size: 1.25rem; line-height: 1.2; }
.tabbar a.active { color: var(--primary); }
.tabbar a:hover { text-decoration: none; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: 86px; max-width: 488px; margin: 0 auto; z-index: 1100;
  padding: 14px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.ok { background: var(--ok); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

.resumen-cuenta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.resumen-cuenta .stat .value { font-size: 1.2rem; }
.resumen-cuenta .total { grid-column: 1 / -1; }
.resumen-cuenta .total .value { font-size: 1.7rem; }

/* ---------- Impresión ---------- */
@media print {
  .topbar, .no-print, .tabbar, .form-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #999; break-inside: avoid; }
  .container { padding: 0; }
}
