/* TochoFace CBTa 24 — High-Contrast Dark Mode (legible bajo luz solar directa) */
.sw { position: relative; }
:root {
  --bg: #05070a;
  --surface: #0d131b;
  --surface-2: #151e29;
  --border: #2a3849;
  --text: #ffffff;
  --muted: #a9b9cc;
  --green: #39ff14;
  --green-dark: #0b3d05;
  --sky: #38bdf8;
  --amber: #ffc400;
  --red: #ff3b3b;
  --radius: 16px;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; padding: calc(var(--header-h) + var(--safe-t)) 0 calc(var(--nav-h) + var(--safe-b) + 12px); font-size: 17px; line-height: 1.4; }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
a { color: var(--sky); }
b { font-weight: 800; }
.muted { color: var(--muted); }
.tiny { font-size: .8rem; }
.pad { padding: 1rem; list-style: none; }
.txt-green { color: var(--green); } .txt-amber { color: var(--amber); } .txt-red { color: var(--red); }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.app-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: calc(var(--header-h) + var(--safe-t)); padding: var(--safe-t) 12px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(5, 7, 10, .96); border-bottom: 2px solid var(--border); backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 900; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--green); color: #000; font-weight: 900; font-size: 1.2rem; box-shadow: 0 0 14px rgba(57, 255, 20, .5); }
.brand-mark-xl { width: 76px; height: 76px; border-radius: 22px; font-size: 2.6rem; margin: 0 auto 8px; }
.brand-text small { color: var(--green); font-weight: 800; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.btn-sync { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 999px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; font-size: .78rem; cursor: pointer; }
.btn-sync .sync-badge { min-width: 22px; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); text-align: center; }
.btn-sync.has-pending { border-color: var(--amber); }
.btn-sync.has-pending .sync-badge { background: var(--amber); color: #000; }
.btn-sync.syncing #sync-icon { display: inline-block; animation: spin 1s linear infinite; }
.net-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.net-dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 420px) { .brand-text small { display: none; } .sync-text { font-size: .7rem; } }

/* ---------- Layout ---------- */
.page { max-width: 880px; margin: 0 auto; padding: 14px; display: grid; gap: 14px; }
.card { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; }
.row-gap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.hero { display: grid; gap: 14px; background: linear-gradient(135deg, #0c2a0a 0%, var(--surface) 70%); border-color: #1f5a16; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.eyebrow { margin: 0; color: var(--green); font-weight: 800; text-transform: uppercase; font-size: .8rem; letter-spacing: .08em; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; display: grid; gap: 2px; }
.kpi-n { font-size: 2.2rem; font-weight: 900; line-height: 1; }
.kpi-l { color: var(--muted); font-weight: 700; font-size: .85rem; }
.kpi-green { border-color: var(--green); } .kpi-green .kpi-n { color: var(--green); }
.kpi-amber { border-color: var(--amber); } .kpi-amber .kpi-n { color: var(--amber); }
.kpi-sky { border-color: var(--sky); } .kpi-sky .kpi-n { color: var(--sky); }
.kpi-red { border-color: var(--red); } .kpi-red .kpi-n { color: var(--red); }

.status-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.status-list li { display: flex; gap: 8px; justify-content: space-between; border-bottom: 1px dashed var(--border); padding-bottom: 6px; }
.status-list li span { color: var(--muted); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 2px solid transparent; font-size: 1rem; font-weight: 800; text-decoration: none; cursor: pointer; transition: transform .08s, filter .15s; color: #000; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--green); box-shadow: 0 0 18px rgba(57, 255, 20, .35); }
.btn-success { background: #22c55e; }
.btn-warning { background: var(--amber); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-xl { min-height: 58px; font-size: 1.15rem; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:hover:not(:disabled) { filter: brightness(1.1); }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: .8rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
input, select { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--border); background: #000; color: var(--text); font-size: 1rem; }
input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(57, 255, 20, .25); }
.form-error { color: var(--red); font-weight: 800; margin: 0 0 10px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.filters .field { margin: 0; }
.dialog { border: 2px solid var(--green); border-radius: var(--radius); background: var(--surface); color: var(--text); width: min(92vw, 440px); padding: 18px; }
.dialog::backdrop { background: rgba(0, 0, 0, .8); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; color: var(--muted); font-size: .72rem; text-transform: uppercase; padding: 6px 8px; border-bottom: 2px solid var(--border); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pill { padding: 2px 10px; border-radius: 999px; font-weight: 800; font-size: .75rem; }
.pill-green { background: var(--green); color: #000; } .pill-gray { background: var(--surface-2); color: var(--muted); }
.light { display: inline-block; width: 22px; height: 22px; border-radius: 50%; }
.light-verde { background: var(--green); box-shadow: 0 0 10px var(--green); }
.light-amarillo { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.light-rojo { background: var(--red); box-shadow: 0 0 10px var(--red); }
.light-gris { background: #4b5563; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.plist small { display: block; }

/* ---------- Navegacion inferior ---------- */
.bottom-nav { position: fixed; inset: auto 0 0 0; z-index: 50; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: #000; border-top: 2px solid var(--border); }
.bottom-nav a { flex: 1; display: grid; place-items: center; align-content: center; gap: 0; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 800; }
.bottom-nav a.active { color: var(--green); background: rgba(57, 255, 20, .08); box-shadow: inset 0 3px 0 var(--green); }
.nav-ico { font-size: 1.4rem; line-height: 1.2; }

/* ---------- Login ---------- */
.login-body { padding: 0; display: grid; place-items: center; }
.login-card { width: min(92vw, 400px); padding: 24px; text-align: center; background: var(--surface); border: 2px solid var(--border); border-radius: 24px; }
.login-card h1 span { color: var(--green); }
.login-card form { text-align: left; margin: 16px 0 10px; }

/* ---------- Camara (enrolar / escanear) ---------- */
.cam-wrap { position: relative; width: 100%; max-width: 560px; margin: 0 auto; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; border: 2px solid var(--border); }
.cam-wrap video, .cam-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cam-hint { position: absolute; left: 8px; right: 8px; top: 8px; padding: 8px 12px; border-radius: 12px; background: rgba(0, 0, 0, .75); font-weight: 800; text-align: center; font-size: .95rem; }
.cam-hint.done { background: var(--green); color: #000; }
.cam-card { display: grid; gap: 12px; }
.steps { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.step { flex: 1; min-width: 92px; max-width: 170px; display: grid; justify-items: center; gap: 4px; padding: 8px; border: 2px dashed var(--border); border-radius: 14px; text-align: center; font-size: .78rem; font-weight: 700; color: var(--muted); }
.step.current { border-color: var(--amber); color: var(--text); }
.step.done { border: 2px solid var(--green); color: var(--green); }
.step-thumb { width: 64px; height: 64px; border-radius: 12px; background: #000 center/cover no-repeat; }
.cap-msg { margin: 0; min-height: 1.4em; font-weight: 800; text-align: center; }
.cap-msg.ok { color: var(--green); } .cap-msg.err { color: var(--red); }

/* ---------- Escaner ---------- */
.scan-body { padding-bottom: 0; overflow: hidden; }
.scan-main { padding: 8px 10px calc(70px + var(--safe-b)); display: grid; gap: 8px; justify-items: center; }
.scan-status { width: 100%; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { padding: 5px 12px; border-radius: 999px; background: var(--surface-2); border: 2px solid var(--border); font-weight: 800; font-size: .82rem; }
.chip-green { border-color: var(--green); color: var(--green); }
.chip-red { border-color: var(--red); color: var(--red); }
.chip-muted { color: var(--muted); }
.scan-cam { width: min(100%, calc((100dvh - 210px - var(--safe-b)) * var(--ar, 1.333))); max-width: 720px; }
.start-panel { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 20px; text-align: center; background: rgba(0, 0, 0, .86); font-weight: 800; z-index: 5; }
.cam-controls { position: absolute; right: 8px; top: 8px; display: grid; gap: 8px; z-index: 4; }
.round-btn { width: 50px; height: 50px; border-radius: 50%; border: 2px solid var(--border); background: rgba(0, 0, 0, .7); color: #fff; font-size: 1.4rem; cursor: pointer; }
.round-btn.on { background: var(--amber); color: #000; border-color: var(--amber); }
.manual-quick { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 6; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255, 196, 0, .25); } }

.toast { position: fixed; left: 10px; right: 10px; bottom: calc(68px + var(--safe-b)); z-index: 40; max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 22px; border: 4px solid var(--green); background: #04200a; box-shadow: 0 0 30px rgba(57, 255, 20, .5); }
.toast.late { border-color: var(--amber); background: #2a2000; box-shadow: 0 0 30px rgba(255, 196, 0, .5); }
.toast.pop { animation: pop .28s ease-out; }
@keyframes pop { from { transform: translateY(30px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-photo { width: 84px; height: 84px; border-radius: 18px; object-fit: cover; flex: none; background: #000; }
.ph { display: grid; place-items: center; background: var(--surface-2); color: var(--green); font-weight: 900; font-size: 2rem; }
.toast-info { flex: 1; min-width: 0; }
.toast-name { font-size: 1.35rem; font-weight: 900; line-height: 1.15; }
.toast-sub { color: var(--muted); font-weight: 800; font-size: 1.05rem; }
.toast-badge { padding: 8px 12px; border-radius: 12px; background: var(--green); color: #000; font-weight: 900; font-size: 1rem; }
.toast.late .toast-badge { background: var(--amber); }

.drawer { position: fixed; inset: auto 0 0 0; z-index: 30; height: 78dvh; display: flex; flex-direction: column; background: var(--surface); border-top: 3px solid var(--green); border-radius: 22px 22px 0 0; transform: translateY(calc(100% - 56px - var(--safe-b))); transition: transform .28s ease; padding-bottom: var(--safe-b); }
.drawer.open { transform: translateY(0); }
.drawer-handle { height: 56px; flex: none; display: grid; place-items: center; align-content: center; gap: 4px; cursor: pointer; touch-action: none; font-weight: 800; }
.grip { width: 46px; height: 5px; border-radius: 3px; background: var(--muted); }
.drawer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 12px 12px; gap: 8px; }
.search { flex: none; }
.mlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: grid; align-content: start; gap: 6px; -webkit-overflow-scrolling: touch; }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-radius: 14px; background: var(--surface-2); border: 2px solid transparent; }
.mrow.is-present { border-color: var(--green); background: #07220a; }
.mrow.is-just { border-color: var(--sky); background: #06222f; }
.mwho { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mtxt { min-width: 0; display: grid; }
.mtxt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.mavatar { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex: none; background: #000; font-size: 1.2rem; }
.mswitches { display: flex; gap: 10px; flex: none; }
.sw { display: grid; justify-items: center; gap: 2px; cursor: pointer; font-size: .64rem; font-weight: 800; color: var(--muted); }
.sw input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.sw-track { width: 52px; height: 30px; border-radius: 999px; background: #3a4656; position: relative; transition: background .15s; }
.sw-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sw input:checked + .sw-track { background: var(--green); }
.sw input:checked + .sw-track::after { transform: translateX(22px); }
.sw:nth-child(2) input:checked + .sw-track { background: var(--sky); }
.sw input:focus-visible + .sw-track { outline: 3px solid #fff; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 380px) { .toast-photo { width: 64px; height: 64px; } .toast-name { font-size: 1.1rem; } }
