/* styles.css — Hoja de estilos del sistema (identidad IT&Dom Solutions).
   Variables de marca en :root (turquesa #1ba6ce, naranja #f47c20, carbón #303133).
   Secciones: base, login split-screen, topbar/tabs, tarjetas y tablas, formularios,
   badges/chips, panel analítico, monitoreo/mapa, PWA y media queries responsive. */

:root {
  --ink: #303133;
  --ink-soft: #5c5e61;
  --ink-faint: #8b8d90;
  --canvas: #eef1f2;
  --surface: #ffffff;
  --line: #dde2e4;
  --jade: #1ba6ce;
  --jade-deep: #1587ab;
  --jade-tint: #e2f3f8;
  --amber: #f47c20;
  --amber-tint: #fdeddd;
  --rose: #c0392b;
  --rose-tint: #f7e2df;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(48,49,51,.06), 0 8px 24px rgba(48,49,51,.07);
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, sans-serif;
  --display: "Space Grotesk", var(--sans);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* Logo de la empresa */
.brand-logo { height: 34px; width: auto; display: block; }
.topbar-logo { height: 24px; width: auto; display: block; }

/* Brand mark: a geofence target */
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--jade) 0 4px, transparent 5px),
    radial-gradient(circle at center, transparent 0 9px, var(--jade) 9px 11px, transparent 12px),
    radial-gradient(circle at center, transparent 0 15px, rgba(15,122,95,.4) 15px 16px, transparent 17px);
  display: inline-block;
}
.brand-mark.small { width: 26px; height: 26px; }

/* ---------- LOGIN (split-screen) ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-form-side { display: grid; place-items: center; padding: clamp(20px, 5vw, 48px); background: var(--surface); overflow-y: auto; }
.auth-card { width: 100%; max-width: 400px; animation: authIn .5s ease; }
@keyframes authIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.auth-logo { height: clamp(32px, 6vw, 42px); margin-bottom: clamp(18px, 4vw, 26px); }
.auth-title { font-family: var(--display); font-size: clamp(24px, 5vw, 28px); letter-spacing: -.02em; margin: 0 0 6px; }
.auth-sub { color: var(--ink-soft); font-size: 14.5px; margin: 0 0 clamp(18px, 4vw, 26px); line-height: 1.5; }
.auth-foot { margin-top: clamp(18px, 4vw, 26px); font-size: 12px; color: var(--ink-faint); text-align: center; }

/* En pantallas grandes, el formulario no se estira de más */
@media (min-width: 1400px) { .auth { grid-template-columns: 46% 54%; } }

/* Tablet vertical: el panel de arte se reduce; el formulario manda */
@media (max-width: 1024px) and (min-width: 901px) { .auth { grid-template-columns: 1fr 0.85fr; } }

/* Móvil / tablet chico: una sola columna, sin panel de arte, con acento de marca */
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art-side { display: none; }
  .auth-form-side { border-top: 4px solid var(--jade); }
}
/* Móvil bajo en horizontal: no forzar alto completo */
@media (max-height: 560px) { .auth { min-height: 0; } .auth-form-side { padding: 20px; } }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px; }
.in-icon {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--ink-faint); cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 6px 8px; border-radius: 8px; font-family: var(--sans);
}
.in-icon:hover { color: var(--ink); background: #f2f4f6; }
#email-clear { display: none; }

.form-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -2px 0 2px; }
.link { border: none; background: transparent; color: var(--jade); font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--sans); padding: 0; }
.link:hover { color: var(--jade-deep); text-decoration: underline; }
.btn-block { width: 100%; margin-top: 4px; }
.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; top: 50%; left: 50%;
  margin: -9px 0 0 -9px; border: 2.5px solid rgba(255,255,255,.5); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Panel de arte con identidad IT&Dom */
.auth-art-side { position: relative; overflow: hidden; }
.art-gradient {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 120% at 15% 10%, #f47c20 0%, transparent 45%),
    radial-gradient(120% 120% at 85% 30%, #1ba6ce 0%, transparent 50%),
    radial-gradient(140% 140% at 70% 100%, #7a4bd6 0%, transparent 55%),
    linear-gradient(135deg, #1587ab, #303133);
}
.art-shapes {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 78% 22%, rgba(255,255,255,.18) 0 2px, transparent 3px),
    radial-gradient(circle at 82% 26%, rgba(255,255,255,.14) 0 2px, transparent 3px);
  background-size: 26px 26px; opacity: .5;
  mask-image: radial-gradient(circle at 80% 80%, #000, transparent 60%);
}
.art-content { position: absolute; left: 48px; bottom: 56px; right: 48px; color: #fff; }
.art-content h2 { font-family: var(--display); font-size: 34px; letter-spacing: -.02em; margin: 0 0 10px; }
.art-content p { font-size: 15px; line-height: 1.6; color: rgba(255,255,255,.85); max-width: 380px; }

/* Evita el zoom automático de iOS en inputs (fuente >=16px) */
.auth input { font-size: 16px; }

/* ---------- Campana de notificaciones ---------- */
.bell { position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 10px; cursor: pointer; }
.bell:hover { background: #f4f6f6; }
.bell-count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--rose); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center; font-family: var(--mono);
}
.bell-count.show { display: inline-flex; }

/* Contraseña temporal mostrada al admin */
.temp-pass { font-family: var(--mono); font-size: 20px; font-weight: 600; background: var(--jade-tint); color: var(--jade-deep); padding: 10px 14px; border-radius: 10px; text-align: center; letter-spacing: 1px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
input, select {
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: #fbfcfb; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none; border-color: var(--jade);
  box-shadow: 0 0 0 3px rgba(15,122,95,.15);
}
.form-error { color: var(--rose); font-size: 13px; margin: 2px 0 0; min-height: 16px; }

/* ---------- BUTTONS ---------- */
.btn {
  font-family: var(--sans); font-weight: 600; font-size: 14.5px;
  border: 1px solid transparent; border-radius: 10px; padding: 11px 16px;
  cursor: pointer; transition: transform .05s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--jade); color: #fff; }
.btn-primary:hover { background: var(--jade-deep); }
.btn-primary:disabled { background: var(--ink-faint); cursor: default; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f4f6f4; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* ---------- APP SHELL ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 20px; height: 62px; position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 9px; }
.topbar-brand { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; margin-left: 8px; overflow-x: auto; }
.tab {
  font-weight: 600; font-size: 14px; color: var(--ink-soft);
  padding: 8px 13px; border-radius: 9px; border: none; background: transparent; cursor: pointer; white-space: nowrap;
}
.tab:hover { background: #f2f4f2; color: var(--ink); }
.tab.active { background: var(--jade-tint); color: var(--jade-deep); }
.topbar-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.who-name { font-weight: 600; font-size: 13.5px; }
.who-role { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); text-transform: uppercase; letter-spacing: .04em; }

.content { max-width: 1040px; margin: 0 auto; padding: 26px 20px 60px; }
.view-head { margin: 0 0 20px; }
.view-title { font-family: var(--display); font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
.view-sub { color: var(--ink-soft); font-size: 14px; margin: 0; }

/* ---------- CARDS ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1.4fr 1fr; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.metric-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.metric-value { font-family: var(--mono); font-size: 34px; font-weight: 600; margin-top: 6px; letter-spacing: -.01em; }
.metric.accent .metric-value { color: var(--jade); }
.metric.warn .metric-value { color: var(--amber); }

/* ---------- CHECK-IN HERO ---------- */
.hero {
  background: var(--ink); color: #fff; border-radius: 18px; padding: 26px;
  position: relative; overflow: hidden;
}
.hero-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 78% 30%, #000, transparent 70%);
}
.hero-inner { position: relative; }
.hero-date { font-size: 13px; color: rgba(255,255,255,.6); font-weight: 500; text-transform: capitalize; }
.clock { font-family: var(--mono); font-size: 54px; font-weight: 600; letter-spacing: .01em; line-height: 1; margin: 6px 0 20px; }
.clock small { font-size: 22px; color: rgba(255,255,255,.55); }
.presence { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-presence {
  position: relative; border: none; cursor: pointer;
  font-family: var(--sans); font-weight: 600; font-size: 15px; color: #fff;
  padding: 14px 22px; border-radius: 12px; background: var(--jade);
}
.btn-presence.out { background: transparent; border: 1px solid rgba(255,255,255,.3); }
.btn-presence:disabled { opacity: .55; cursor: default; }
.btn-presence .pulse {
  position: absolute; inset: 0; border-radius: 12px; border: 2px solid var(--jade);
  animation: pulse 1.6s ease-out infinite; opacity: 0;
}
.btn-presence.working .pulse { opacity: 1; }
@keyframes pulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.35); opacity: 0; } }

.geo-status { margin-top: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13.5px; }
.chip {
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 20px; display: inline-flex; align-items: center; gap: 6px;
}
.chip.ok { background: rgba(15,122,95,.22); color: #7ee5c3; }
.chip.bad { background: rgba(180,67,47,.22); color: #f0a494; }
.chip.late { background: rgba(183,121,31,.22); color: #f0cd8a; }
.chip.neutral { background: rgba(255,255,255,.12); color: rgba(255,255,255,.8); }

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); font-weight: 600; }
td.mono, .mono { font-family: var(--mono); }
.badge { font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 6px; font-weight: 500; }
.badge.in { background: var(--jade-tint); color: var(--jade-deep); }
.badge.out { background: #eef0ee; color: var(--ink-soft); }
.badge.yes { background: var(--jade-tint); color: var(--jade-deep); }
.badge.no { background: var(--rose-tint); color: var(--rose); }
.badge.late { background: var(--amber-tint); color: var(--amber); }

.section-title { font-family: var(--display); font-size: 16px; margin: 0 0 14px; }
.row-actions { display: flex; gap: 8px; }
.empty { text-align: center; color: var(--ink-faint); padding: 32px; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; align-items: end; }
.help { font-size: 12.5px; color: var(--ink-faint); margin-top: 4px; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 500; box-shadow: 0 12px 40px rgba(0,0,0,.3);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--rose); }
.toast.ok { background: var(--jade-deep); }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .clock { font-size: 42px; }
  .who-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-presence .pulse { animation: none; }
}

/* ---------- Boton instalar (PWA) ---------- */
.install-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 70;
  font-family: var(--sans); font-weight: 600; font-size: 14px; color: #fff;
  background: var(--jade); border: none; border-radius: 999px;
  padding: 12px 20px 12px 20px; box-shadow: 0 10px 30px rgba(27,166,206,.45); cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  animation: fabIn .4s ease, fabBob 2.4s ease-in-out 1s infinite;
}
.install-fab:hover { background: var(--jade-deep); animation-play-state: paused; }
.install-fab::before { content: "⬇"; font-size: 15px; }
.install-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.25);
  font-size: 11px; line-height: 1;
}
@keyframes fabIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fabBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .install-fab { animation: fabIn .4s ease; } }

/* Pasos e instrucciones */
.steps { margin: 4px 0 0; padding-left: 20px; line-height: 1.9; font-size: 14.5px; color: var(--ink-soft); }
.steps b { color: var(--ink); }

/* Zona de depuración */
.danger-zone { border-left: 4px solid var(--amber); }

/* ---------- Textarea ---------- */
textarea {
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: #fbfcfb; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; width: 100%; resize: vertical; transition: border-color .15s, box-shadow .15s;
}
textarea:focus { outline: none; border-color: var(--jade); box-shadow: 0 0 0 3px rgba(15,122,95,.15); }
.filter { max-width: 200px; }

/* ---------- Gráficas ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .c-val { font-family: var(--mono); font-size: 11px; fill: var(--ink-soft); }
.chart .c-lbl { font-family: var(--mono); font-size: 10px; fill: var(--ink-faint); }
.legend { font-size: 12px; color: var(--ink-soft); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .dot.jade { background: var(--jade); }
.legend .dot.amber { background: var(--amber); margin-left: 10px; }

.rank { display: flex; flex-direction: column; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 20px 1fr 90px 34px; align-items: center; gap: 10px; font-size: 13.5px; }
.rank-pos { font-family: var(--mono); color: var(--ink-faint); font-size: 12px; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.rank-bar { background: #eef0ee; border-radius: 6px; height: 10px; overflow: hidden; }
.rank-fill { display: block; height: 100%; border-radius: 6px; }
.rank-val { font-family: var(--mono); text-align: right; font-weight: 600; }

/* ---------- Highlights ---------- */
.highlight {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; border-left: 4px solid var(--amber);
}
.highlight.warn { border-left-color: var(--rose); }
.hl-title { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.hl-name { font-family: var(--display); font-size: 22px; margin: 6px 0 2px; letter-spacing: -.01em; }
.hl-count { font-size: 13px; color: var(--ink-soft); }
.hl-num { font-family: var(--mono); font-size: 20px; font-weight: 600; color: var(--amber); }
.highlight.warn .hl-num { color: var(--rose); }
.hl-empty { color: var(--ink-faint); font-size: 14px; margin-top: 8px; }

/* ---------- Departamentos ---------- */
.dept-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.dept-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.dept-count { font-family: var(--mono); font-size: 11px; background: var(--jade-tint); color: var(--jade-deep); padding: 2px 7px; border-radius: 10px; margin-left: 4px; }
.note { font-size: 12px; color: var(--ink-faint); margin-top: 3px; font-style: italic; }

/* ---------- Saldo de vacaciones ---------- */
.balance {
  background: var(--ink); color: #fff; border-radius: var(--radius);
  display: flex; flex-direction: column; justify-content: center;
}
.bal-title { font-size: 13px; color: rgba(255,255,255,.6); font-weight: 600; }
.bal-main { margin: 8px 0 6px; }
.bal-num { font-family: var(--mono); font-size: 44px; font-weight: 600; color: #7ee5c3; }
.bal-unit { font-size: 14px; color: rgba(255,255,255,.7); }
.bal-sub { font-size: 13px; color: rgba(255,255,255,.7); }
.badge.head { background: var(--jade-tint); color: var(--jade-deep); font-size: 10px; }

/* ---------- Segmentado Oficina/Campo ---------- */
.seg { display: inline-flex; background: rgba(255,255,255,.1); border-radius: 10px; padding: 3px; margin-bottom: 18px; gap: 3px; }
.seg-btn {
  border: none; background: transparent; color: rgba(255,255,255,.75);
  font-family: var(--sans); font-weight: 600; font-size: 13.5px; padding: 8px 16px; border-radius: 8px; cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--ink); }
.badge.field { background: #e7edf4; color: #2f5496; }

/* ---------- Checkbox ---------- */
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--jade); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(23,35,43,.55); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; background: var(--surface); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-x { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--ink-faint); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }

/* ---------- Responsive reforzado (cualquier dispositivo) ---------- */
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .content { padding: 18px 14px 80px; }
  .view-title { font-size: 21px; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form .btn { width: 100%; }
  .card-pad { padding: 16px; }
  .hero { padding: 20px; }
  .clock { font-size: 40px; }
  .seg { width: 100%; }
  .seg-btn { flex: 1; text-align: center; }
  .presence { flex-direction: column; }
  .btn-presence { width: 100%; }
  .metric-value { font-size: 28px; }
  .modal-foot .btn { flex: 1; }
  .who { display: none; }
  .rank-row { grid-template-columns: 18px 1fr 60px 30px; }
  th, td { padding: 9px 10px; }
}
@media (max-width: 400px) {
  .topbar-brand { display: none; }
  .clock { font-size: 34px; }
}
/* Toque cómodo en móvil */
@media (pointer: coarse) {
  .btn, .tab, .seg-btn { min-height: 42px; }
}

/* Logo aún más pequeño en móvil */
@media (max-width: 620px) {
  .topbar-logo { height: 22px; }
  .brand-logo { height: 30px; }
}
/* Salida temprana */
.badge.early { background: var(--amber-tint); color: var(--amber); }
.btn.danger { color: var(--rose); }
.btn.danger:hover { background: var(--rose-tint); }

/* ---------- Panel analítico ---------- */
.view-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.seg.period { background: #e6eaec; }
.seg.period .seg-btn { color: var(--ink-soft); }
.seg.period .seg-btn.active { background: var(--jade); color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border-top: 3px solid var(--line); }
.kpi.accent { border-top-color: var(--jade); }
.kpi.warn { border-top-color: var(--amber); }
.kpi-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.kpi-value { font-family: var(--mono); font-size: 30px; font-weight: 600; margin: 4px 0 2px; letter-spacing: -.01em; }
.kpi.accent .kpi-value { color: var(--jade); }
.kpi.warn .kpi-value { color: var(--amber); }
.kpi-sub { font-size: 12px; color: var(--ink-faint); }

.insight { margin-top: 14px; background: var(--jade-tint); color: var(--jade-deep); border-radius: 12px; padding: 12px 16px; font-size: 14px; line-height: 1.5; }
.insight b { color: var(--ink); }

.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chart .grid { stroke: #e9edee; stroke-width: 1; }
.chart .c-axis { font-family: var(--mono); font-size: 10px; fill: var(--ink-faint); }
.card.center { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.donut { width: 150px; height: 150px; }
.donut-num { font-family: var(--mono); font-size: 26px; font-weight: 600; fill: var(--ink); }
.donut-lbl { font-size: 9px; fill: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }
.donut-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-soft); }
.donut-legend .dot { margin-right: 5px; }

/* ---------- Login: adaptable a cualquier dispositivo ---------- */
.auth { min-height: 100vh; min-height: 100dvh; }
.auth-form-side { padding: clamp(20px, 5vw, 48px); }
/* Inputs a 16px en móvil para evitar el zoom automático de iOS */
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art-side { display: none; }
  .auth-card { max-width: 420px; }
  .auth-form-side input { font-size: 16px; }
}
@media (max-width: 480px) {
  .auth-title { font-size: 24px; }
  .auth-logo { height: 34px; margin-bottom: 20px; }
  .auth-sub { font-size: 14px; margin-bottom: 20px; }
}
/* Tablets: mantener split pero equilibrado */
@media (min-width: 901px) and (max-width: 1180px) {
  .auth { grid-template-columns: 1.05fr 0.95fr; }
  .art-content { left: 34px; right: 34px; bottom: 44px; }
  .art-content h2 { font-size: 28px; }
}
/* Landscape en móvil: permitir scroll y no forzar 100dvh apretado */
@media (max-height: 560px) and (max-width: 900px) {
  .auth { min-height: auto; }
  .auth-form-side { padding: 24px; }
}

/* ---------- Interruptor (switch) ---------- */
.loc-share-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #cfd6d9; border-radius: 999px; transition: .25s; }
.slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .25s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--jade); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Monitoreo / mapa ---------- */
.mon-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mon-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 12px; font-size: 13px; color: var(--ink-soft); }
.mon-dot { display: inline-flex; align-items: center; gap: 6px; }
.mon-dot i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.mon-badge { color: #fff; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pop { font-family: var(--sans); min-width: 180px; }
.pop b { font-size: 14px; }
.pop-sub { color: var(--ink-faint); font-size: 12px; margin-bottom: 6px; }
.pop-line { font-size: 12.5px; margin-top: 3px; }
#map { z-index: 1; }
.leaflet-container { font-family: var(--sans); }

/* ---------- Campo de archivo (evidencia) ---------- */
.file-drop {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 12px 14px;
  background: #fafbfc; transition: border-color .2s, background .2s;
}
.file-drop:hover { border-color: var(--jade); background: var(--jade-tint); }
.file-drop.has-file { border-style: solid; border-color: var(--jade); background: var(--jade-tint); }
.file-drop.bad { border-color: var(--rose); background: var(--rose-tint); }
.file-cta { font-weight: 600; color: var(--jade-deep); font-size: 14px; white-space: nowrap; }
.file-name { color: var(--ink-soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Política de monitoreo ---------- */
.policy { border-left: 4px solid var(--jade); }
.policy-text { font-size: 13.5px; line-height: 1.7; color: var(--ink-soft); margin: 0; text-align: justify; }
.policy-text b { color: var(--ink); }

/* ---------- Tablas y modales adaptables (móvil) ---------- */
/* Las tablas anchas se desplazan horizontalmente con inercia táctil */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 640px; }
@media (max-width: 620px) {
  /* Celdas que no se aplasten y acciones accesibles al dedo */
  th, td { white-space: nowrap; }
  td.row-actions { white-space: nowrap; }
  .row-actions .btn { padding: 8px 12px; }
  /* Formularios en línea pasan a columna */
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .field, .inline-form .btn, .inline-form select, .inline-form input { width: 100%; }
  /* Modal de edición a pantalla casi completa */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal.card {
    width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh;
    border-radius: 18px 18px 0 0; overflow-y: auto;
  }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  /* Cabecera de vista apilada */
  .view-head-row { flex-direction: column; align-items: stretch; }
  .mon-controls { width: 100%; }
  .mon-controls .filter { flex: 1; }
}
/* Indicador: el propio scroll táctil con inercia es suficiente en móvil */

/* ---------- Botones de comida ---------- */
.presence.lunch { margin-top: 10px; }
.lunch-btn {
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--line);
  font-size: 14px; box-shadow: none;
}
.lunch-btn:hover:not(:disabled) { border-color: var(--amber); background: var(--amber-tint); color: var(--amber); }
.lunch-btn .pulse { display: none; }
@media (max-width: 620px) { .presence.lunch { flex-direction: column; } .presence.lunch .lunch-btn { width: 100%; } }

/* ---------- Animación de bienvenida al iniciar sesión ---------- */
.login-anim {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #1587ab, #303133);
  opacity: 0; transition: opacity .35s ease;
}
.login-anim.show { opacity: 1; }
.login-anim.done { opacity: 0; }
.login-anim-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-anim-content {
  position: relative; z-index: 1; text-align: center; color: #fff;
  transform: translateY(8px) scale(.96); opacity: 0;
  transition: transform .5s cubic-bezier(.2,.8,.2,1) .1s, opacity .5s ease .1s;
}
.login-anim.show .login-anim-content { transform: translateY(0) scale(1); opacity: 1; }
.login-anim-logo {
  height: 46px; width: auto; margin-bottom: 22px;
  background: #fff; padding: 12px 16px; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  animation: la-pop .6s cubic-bezier(.2,1.3,.4,1) both;
}
.login-anim-title { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.login-anim-sub { margin-top: 6px; font-size: 14px; color: rgba(255,255,255,.8); }
@keyframes la-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .login-anim-logo { animation: none; }
  .login-anim-content { transition: opacity .3s ease; transform: none; }
}

/* ---------- Tablas que se vuelven tarjetas en móvil/tablet (.cards-sm) ---------- */
/* Se activa hasta 860px para cubrir teléfonos y tablets pequeñas. No depende de :has(). */
@media (max-width: 860px) {
  /* La propia tabla deja de forzar ancho mínimo, así el contenedor no genera scroll */
  table.cards-sm { min-width: 0 !important; width: 100%; }
  table.cards-sm thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } /* oculta encabezados */
  table.cards-sm, table.cards-sm tbody, table.cards-sm tr, table.cards-sm td { display: block; width: 100%; }
  table.cards-sm tr {
    border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
    margin-bottom: 12px; background: var(--surface); box-shadow: var(--shadow);
  }
  table.cards-sm td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: none; padding: 8px 0; text-align: right;
    white-space: normal; word-break: break-word; overflow-wrap: anywhere; min-width: 0;
  }
  table.cards-sm td + td { border-top: 1px solid #f0f2f3; }
  table.cards-sm td::before {
    content: attr(data-label); font-weight: 600; color: var(--ink-soft);
    font-size: 12.5px; text-align: left; flex: none;
  }
  table.cards-sm td.row-actions { justify-content: flex-end; flex-wrap: wrap; padding-top: 10px; }
  table.cards-sm td.row-actions::before { align-self: center; margin-right: auto; }
  table.cards-sm td.row-actions .btn { flex: 1; min-width: 120px; }
}

/* Indicador "en vivo" (punto que late) */
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; margin: 0 3px -1px 6px; animation: liveblink 1.4s ease-in-out infinite; }
@keyframes liveblink { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(46,204,113,.5); } 50% { opacity: .5; box-shadow: 0 0 0 5px rgba(46,204,113,0); } }

/* ---------- Palomita de confirmación al registrar ---------- */
.check-pop {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; pointer-events: none;
  opacity: 0; transition: opacity .22s ease;
}
.check-pop.show { opacity: 1; }
.check-card {
  background: rgba(48,49,51,.92); color: #fff; border-radius: 20px;
  padding: 26px 30px 20px; text-align: center; backdrop-filter: blur(4px);
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  transform: scale(.86); transition: transform .28s cubic-bezier(.2,1.4,.4,1);
}
.check-pop.show .check-card { transform: scale(1); }
.check-svg { width: 78px; height: 78px; display: block; margin: 0 auto 10px; }
.check-circle {
  fill: none; stroke: #2ecc71; stroke-width: 3;
  stroke-dasharray: 151; stroke-dashoffset: 151;
  animation: check-draw .5s cubic-bezier(.65,0,.45,1) forwards;
}
.check-path {
  fill: none; stroke: #2ecc71; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 48; stroke-dashoffset: 48;
  animation: check-draw .35s cubic-bezier(.65,0,.45,1) .38s forwards;
}
@keyframes check-draw { to { stroke-dashoffset: 0; } }
.check-text { font-family: var(--sans); font-weight: 600; font-size: 14.5px; }

/* Botón marcado: muestra una palomita momentánea */
.btn-presence.done { background: #2ecc71 !important; border-color: #2ecc71 !important; color: #fff !important; }
.btn-presence.done::after { content: " ✓"; font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  .check-circle, .check-path { animation: none; stroke-dashoffset: 0; }
  .check-card { transition: none; transform: none; }
}
