:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --line: #334155;
  --green: #22c55e;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --red: #ef4444;
  --brand: #2563eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
header.topbar .brand { display: flex; align-items: center; gap: 14px; }
.logo-chip { background: #fff; padding: 7px 12px; border-radius: 10px; display: inline-flex; align-items: center; }
.logo-chip img.logo { height: 34px; display: block; }
.brand-sub { font-size: .9rem; color: var(--muted); font-weight: 600; letter-spacing: .2px; }
header.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 18px;
  font-size: .9rem;
}
header.topbar nav a:hover { color: var(--text); }

.wrap { max-width: 1050px; margin: 0 auto; padding: 26px 20px 60px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* Estación de escaneo */
.scan-input {
  width: 100%;
  font-size: 2rem;
  text-align: center;
  padding: 18px 14px;
  border-radius: 12px;
  border: 2px solid var(--panel-2);
  background: #0b1220;
  color: var(--text);
  letter-spacing: 2px;
  outline: none;
}
.scan-input:focus { border-color: var(--brand); }
.hint { text-align: center; color: var(--muted); margin-top: 10px; font-size: .9rem; }

/* Indicador de pistola lectora USB */
.ready { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 12px; font-size: .95rem; font-weight: 600; }
.ready .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); }
.ready.on { color: #4ade80; }
.ready.on .dot { background: var(--green); animation: pulse 1.6s infinite; }
.ready.off { color: var(--amber); }
.ready.off .dot { background: var(--amber); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70%  { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.cam-hint { font-size: .82rem; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--panel-2);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: .95rem;
}
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: var(--brand); border-color: var(--brand); }
.btn.ghost { background: transparent; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.center { justify-content: center; }

/* Feedback */
.feedback {
  margin-top: 18px;
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  background: #0b1220;
  border: 1px solid var(--line);
  min-height: 118px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  transition: background .15s, border-color .15s;
}
.feedback.entrada { background: rgba(34,197,94,.14); border-color: var(--green); }
.feedback.salida  { background: rgba(59,130,246,.14); border-color: var(--blue); }
.feedback.dup     { background: rgba(245,158,11,.14); border-color: var(--amber); }
.feedback.err     { background: rgba(239,68,68,.14); border-color: var(--red); }
.feedback .big { font-size: 1.7rem; font-weight: 800; }
.feedback .name { font-size: 1.25rem; font-weight: 600; }
.feedback .sub { color: var(--muted); font-size: .92rem; }
.feedback .idle { color: var(--muted); font-size: 1.05rem; }

/* Cámara */
#reader { display: none; width: 100%; max-width: 420px; margin: 14px auto 0; border-radius: 12px; overflow: hidden; background: #000; }
#reader video { width: 100% !important; height: auto !important; display: block; border-radius: 12px; }
#reader img { display: none; }  /* oculta el ícono de "info" que mete la librería */

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.stat .num { font-size: 1.9rem; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

/* Tablas */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.tag.entrada { background: rgba(34,197,94,.18); color: #4ade80; }
.tag.salida  { background: rgba(59,130,246,.18); color: #60a5fa; }
.tbl-wrap { max-height: 360px; overflow: auto; }

input.txt {
  width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--panel-2); background: #0b1220; color: var(--text);
}
.muted { color: var(--muted); }
