:root {
  --card: #ffffff;
  --card-border: rgba(0, 0, 0, 0.06);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}
.dark {
  --card: #2A2A2D;
  --card-border: rgba(255, 255, 255, 0.08);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

/* Bento */
.bento {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
@media (max-width: 480px) { .bento { padding: 16px; border-radius: 20px; } }
.label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #5f5f64; }
.dark .label { color: #a1a1a6; }
.metric { font-size: clamp(30px, 7vw, 44px); line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0; font-variant-numeric: tabular-nums; }

/* Controles segmentados */
.seg { display: inline-flex; background: rgba(120, 120, 128, .16); border-radius: 14px; padding: 3px; gap: 2px; }
.seg button { padding: 8px 18px; border-radius: 11px; font-weight: 600; font-size: 14px; color: #3c3c43; transition: all .15s; flex: 1; }
.seg button.active { background: var(--card); color: inherit; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.dark .seg button { color: #a1a1a6; }
.dark .seg button.active { color: #fff; background: #48484c; }
.seg-lg { display: grid; grid-template-columns: repeat(2, 1fr); width: 100%; }
.seg-lg button { padding: 12px 8px; font-size: 15px; line-height: 1.2; min-height: 52px; }
@media (min-width: 768px) { .seg-lg { grid-template-columns: repeat(4, 1fr); } .seg-lg button { font-size: 16px; padding: 14px 10px; } }
.seg-lg button b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(120, 120, 128, .25); font-size: 12px; margin-right: 6px; }
.seg-lg button.active b { background: #0071e3; color: #fff; }

.btn-primary { background: #0071e3; color: #fff; font-weight: 600; padding: 0 28px; border-radius: 16px; transition: filter .15s; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { padding: 8px 14px; border-radius: 12px; font-size: 13px; font-weight: 600; background: rgba(120, 120, 128, .16); }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }

.field { width: 100%; border-radius: 14px; border: 1px solid rgba(120,120,128,.4); background: var(--card); padding: 12px 14px; font-size: 16px; font-weight: 500; text-transform: none; letter-spacing: 0; color: inherit; outline: none; }
.field:focus { border-color: #0071e3; box-shadow: 0 0 0 4px rgba(0,113,227,.25); }
dialog.modal { max-height: 92dvh; background: var(--card); color: inherit; border: 1px solid var(--card-border); border-radius: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.35); padding: 24px; width: min(760px, 94vw); max-height: 88vh; overflow-y: auto; margin: auto; }
dialog.modal::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(4px); }
.pill.off { background: rgba(120,120,128,.2); color: #3c3c43; }
.dark .pill.off { color: #d1d1d6; }
.pill.admin { background: #E3F2FD; color: #0D47A1; }
.dark .pill.admin { background: #12304f; color: #90CAF9; }

/* Resultado */
.result { border-radius: 20px; min-height: 220px; display: grid; place-items: center; padding: 24px; border: 2px dashed rgba(120, 120, 128, .3); transition: background .2s; }
.result.ok { background: #E8F5E9; border: 2px solid #66BB6A; color: #1B5E20; animation: glow .9s ease-out; }
.result.denied { background: #FFEBEE; border: 2px solid #EF5350; color: #B71C1C; animation: shake .45s; }
.dark .result.ok { background: #16301c; border-color: #43A047; color: #C8E6C9; }
.dark .result.denied { background: #3b1a1e; border-color: #E53935; color: #FFCDD2; }
.result .name { font-size: clamp(30px, 4vw, 52px); font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.result .status { font-size: 15px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.result .meta { font-size: 22px; font-weight: 500; margin-top: 8px; }
.result .group { display: inline-block; margin-top: 14px; padding: 6px 22px; border-radius: 999px; font-size: 28px; font-weight: 800; background: rgba(0,0,0,.08); }
.dark .result .group { background: rgba(255,255,255,.12); }

@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
@keyframes glow { from { box-shadow: 0 0 0 0 rgba(76, 175, 80, .6); } to { box-shadow: 0 0 0 28px rgba(76, 175, 80, 0); } }

/* Etiqueta 1.7" x 1.7" */
.label-preview { zoom: 1.9; filter: drop-shadow(0 6px 14px rgba(0,0,0,.25)); }
.sticker {
  width: 1.7in; height: 1.7in; box-sizing: border-box; background: #fff; color: #000;
  padding: 6px 8px; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  font-family: Inter, Arial, sans-serif; text-align: center; border-radius: 4px; overflow: hidden;
}
.sticker-img { width: 1.7in; height: 1.7in; background: #fff; border-radius: 4px; overflow: hidden; }
.sticker-img img { width: 100%; height: 100%; display: block; }
.sticker.empty { align-items: center; justify-content: center; color: #aaa; font-size: 10px; }
.sticker .s-name { font-weight: 800; font-size: 12px; line-height: 1.1; max-height: 28px; overflow: hidden; }
.sticker .s-role { font-size: 8px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.sticker .s-group { font-weight: 800; font-size: 11px; border: 1.5px solid #000; border-radius: 4px; padding: 0 8px; }
.sticker img { width: 64px; height: 64px; }
.sticker .s-code { font-size: 7px; font-family: ui-monospace, monospace; }

/* Tabla */
#logBody tr { border-top: 1px solid var(--card-border); }
#logBody td { padding: 8px 12px 8px 0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #E8F5E9; color: #2E7D32; }
.pill.denied { background: #FFEBEE; color: #C62828; }
.dark .pill.ok { background: #16301c; color: #A5D6A7; }
.dark .pill.denied { background: #3b1a1e; color: #EF9A9A; }

/* Responsive: la credencial se reduce en pantallas angostas para no desbordar */
@media (max-width: 480px) { .label-preview { zoom: 1.5; } }
@media (max-width: 360px) { .label-preview { zoom: 1.3; } }

/* Objetivos táctiles de al menos 44 px en pantallas táctiles */
@media (pointer: coarse) {
  .btn-ghost, .btn-primary, .seg button { min-height: 44px; }
  .field, #scanInput { min-height: 48px; }
}
.cam-btn { font-size: 20px; line-height: 1; padding: 0 16px; border-radius: 16px; }

/* Cámara */
.cam-frame { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; max-height: 60dvh; margin: 0 auto; }
.cam-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-aim { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none; }

/* Tabla de registros: columnas con ajuste en móvil */
#logBody td { vertical-align: top; }
@media (max-width: 640px) { #logBody td { font-size: 13px; } }
body { overflow-x: hidden; }

.seg button { white-space: nowrap; }
@media (max-width: 480px) { .seg:not(.seg-lg) button { padding: 8px 12px; } }
.seg-lg button { white-space: normal; }
