:root {
  --bg: #0c0f14;
  --bg-2: #11161e;
  --surface: #161c26;
  --surface-2: #1d2531;
  --border: #273141;
  --text: #eef2f7;
  --muted: #93a1b5;
  --accent: #ef3e36;
  --accent-2: #ff7a18;
  --grad: linear-gradient(135deg, #ef3e36, #ff7a18);
  --accent-ink: #ffffff;
  --ok: #34d399;
  --ok-bg: #0e2a22;
  --bad: #fb7185;
  --bad-bg: #2c1117;
  --warn: #fbbf24;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: radial-gradient(1000px 560px at 78% -12%, #2a1410 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: 'Sora', sans-serif; letter-spacing: -0.01em; }

#app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px calc(18px + env(safe-area-inset-top)); 
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg), rgba(12,15,20,0.6));
  backdrop-filter: blur(8px);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-family: 'Sora'; font-weight: 700; font-size: 18px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 16px var(--accent); }
.topbar .who { font-size: 13px; color: var(--muted); text-align: right; line-height: 1.3; }
.topbar .who b { color: var(--text); display: block; font-weight: 600; }
.logout { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; }

/* ---------- Layout ---------- */
.screen { flex: 1; padding: 8px 20px 120px; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.screen-title { font-size: 26px; font-weight: 700; margin: 6px 0 18px; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 12px; }

/* ---------- Metrics ---------- */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: relative; overflow: hidden; }
.metric .val { font-family: 'Sora'; font-size: 30px; font-weight: 700; line-height: 1; }
.metric .lab { color: var(--muted); font-size: 13px; margin-top: 8px; }
.metric.accent { border-color: #3a4a1e; background: linear-gradient(160deg, #1a230f, var(--surface)); }
.metric.accent .val { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.metric.warn .val { color: var(--warn); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 14px 18px; font-family: 'Manrope'; font-weight: 700;
  font-size: 15px; cursor: pointer; width: 100%; transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--grad); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.btn-sm { width: auto; padding: 10px 14px; font-size: 14px; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input, select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 14px; font-size: 16px; font-family: 'Manrope'; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ---------- Search & list ---------- */
.search { position: relative; margin-bottom: 8px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; cursor: pointer; transition: border-color .15s; }
.row:hover { border-color: #36465c; }
.row .avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; font-family: 'Sora'; font-weight: 700; color: var(--accent); flex: none; }
.row .info { flex: 1; min-width: 0; }
.row .info .name { font-weight: 600; }
.row .info .sub { color: var(--muted); font-size: 13px; }

/* ---------- Badges ---------- */
.badge { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: #2e2408; color: var(--warn); }
.badge.gray { background: var(--surface-2); color: var(--muted); }

/* ---------- Check-in ---------- */
.checkin-input { display: flex; gap: 10px; margin-bottom: 16px; }
.checkin-input input { font-size: 18px; }
.scan-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #000; aspect-ratio: 4/3; position: relative; display: none; }
.scan-wrap.on { display: block; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18% 18%; border: 3px solid var(--accent); border-radius: 16px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.result { border-radius: var(--radius); padding: 26px 20px; text-align: center; animation: pop .25s ease both; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.result.ok { background: var(--ok-bg); border: 1px solid #195f48; }
.result.bad { background: var(--bad-bg); border: 1px solid #6b2230; }
.result .big { font-family: 'Sora'; font-size: 24px; font-weight: 700; margin: 8px 0; }
.result.ok .big { color: var(--ok); }
.result.bad .big { color: var(--bad); }
.result .icon { font-size: 40px; }
.result .meta { color: var(--muted); font-size: 14px; }

/* ---------- Bottom nav ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: rgba(15, 20, 28, 0.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.nav button { background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; font-size: 11px; font-weight: 600; font-family: 'Manrope'; }
.nav button .ico { font-size: 22px; line-height: 1; }
.nav button.active { color: var(--accent); }

/* ---------- Login ---------- */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; max-width: 420px; margin: 0 auto; width: 100%; }
.login .logo { display: flex; align-items: center; gap: 12px; font-family: 'Sora'; font-weight: 700; font-size: 24px; margin-bottom: 6px; }
.login .logo .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 20px var(--accent); }
.login p.sub { color: var(--muted); margin-bottom: 28px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 60px; }
.toast { position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text); padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); z-index: 50; animation: rise .3s ease; }
.hist { display: flex; flex-direction: column; gap: 8px; }
.hist .h { display: flex; justify-content: space-between; font-size: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.hist .h:last-child { border: none; }
.hist .h .muted { color: var(--muted); }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.kv:last-child { border: none; }
.kv .muted { color: var(--muted); }
.qrbox { font-family: monospace; font-size: 12px; word-break: break-all; color: var(--muted); background: var(--bg-2); padding: 10px; border-radius: 10px; margin-top: 6px; }

/* Selector de modo (check-in) */
.seg-btn { flex: 1; background: none; border: none; color: var(--muted); padding: 9px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: inherit; }
.seg-btn.on { background: var(--grad); color: #fff; }

/* Impresión de carnet: solo se imprime la tarjeta */
@media print {
  body * { visibility: hidden !important; }
  #carnetPrint, #carnetPrint * { visibility: visible !important; }
  #carnetPrint { position: fixed; left: 50%; top: 30px; transform: translateX(-50%); box-shadow: none !important; }
  .no-print { display: none !important; }
}

/* Ver / ocultar la contraseña en el ingreso (v1.15.1) */
label.field span.pass-wrap { display: block; position: relative; margin: 0; font-size: inherit; font-weight: inherit; color: inherit; text-transform: none; letter-spacing: normal; }
label.field span.pass-wrap input { padding-right: 46px !important; }
.pass-ver { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.pass-ver:hover, .pass-ver[aria-pressed="true"] { color: var(--text); }
.pass-ver:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Aviso para dejar el ícono en el celular (v1.16.0) */
.aviso-icono { margin-bottom: 14px; border-color: var(--accent); }

/* Relevo con la nube (1.18.0): aviso de solo lectura */
.ro-banner { margin: 10px 14px 0; padding: 10px 12px; border-radius: 10px; background: rgba(255,159,28,.14); border: 1px solid #ff9f1c; font-size: 13px; line-height: 1.45; }
.ro-banner b { color: #ff9f1c; }
