/* Estilo provisional: se ajusta a la paleta cuando llegue el diseño */
:root {
  --fondo: #f4f5f7; --superficie: #ffffff; --texto: #1f2933; --sutil: #6b7280; --borde: #e3e6ea;
  --primario: #1f2a37; --primario-texto: #ffffff; --ok: #12805c; --error: #c0362c; --aviso: #b7791f;
  --radio: 12px; --sombra: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); color: var(--texto); font-size: 15px; line-height: 1.45; }
body.centrado { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 6px; }
h2 { font-size: 17px; margin: 0 0 14px; }
.sutil { color: var(--sutil); margin: 0 0 18px; }
.marca { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; color: var(--sutil); }
.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 22px; }
.login { width: 100%; max-width: 380px; }

label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 12px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; color: inherit;
  background: #fff; border: 1px solid #cfd4da; border-radius: 9px;
}
input:focus, select:focus { outline: 2px solid #94a3b8; outline-offset: 1px; border-color: #94a3b8; }
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; font: 600 14px inherit;
  font-family: inherit; border-radius: 9px; border: 1px solid var(--borde); background: #fff; color: var(--texto); cursor: pointer; }
.btn:hover { background: #f8f9fa; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primario { background: var(--primario); color: var(--primario-texto); border-color: var(--primario); }
.btn.peligro { color: var(--error); }
.btn.chico { padding: 5px 9px; font-size: 12px; }
.btn.ancho { width: 100%; }
.msg { min-height: 1.2em; margin: 10px 0 0; color: var(--error); font-size: 14px; }
.msg.ok { color: var(--ok); }

/* ---------- Panel ---------- */
.barra { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  background: var(--primario); color: #fff; }
.barra .titulo { font-weight: 700; }
.barra .esp { flex: 1; }
.barra .usuario { font-size: 13px; opacity: .8; }
.barra .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); padding: 6px 12px; }
.contenedor { max-width: 1180px; margin: 0 auto; padding: 20px; }
.pestanas { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.pestanas button { border: 1px solid var(--borde); background: #fff; border-radius: 999px; padding: 8px 16px; font: 600 14px inherit; font-family: inherit; cursor: pointer; }
.pestanas button[aria-selected="true"] { background: var(--primario); color: #fff; border-color: var(--primario); }
.oculto { display: none !important; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--sutil); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat .d { font-size: 13px; color: var(--sutil); }

.rejilla { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .rejilla { grid-template-columns: 1fr; } }
.tipos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 14px; }
.tipo-opcion { position: relative; border: 2px solid var(--borde); border-radius: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; }
.tipo-opcion input { position: absolute; opacity: 0; pointer-events: none; }
.tipo-opcion .muestra { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.tipo-opcion:has(input:checked) { border-color: var(--primario); background: #f8fafc; }
.resultado { margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.resultado.ok { background: #e8f6ef; color: #0d5c42; }
.resultado.error { background: #fdecea; color: #8a241c; }
.resultado.aviso { background: #fdf6e3; color: #7a5310; }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filtros input { flex: 1 1 240px; margin: 0; }
.filtros select { width: auto; margin: 0; }
.tabla-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef0f2; vertical-align: top; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--sutil); background: #fafbfc; }
td.acciones { display: flex; gap: 6px; flex-wrap: wrap; white-space: normal; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip.valida { background: #e8f6ef; color: #0d5c42; }
.chip.usada { background: #e8eefb; color: #23408e; }
.chip.anulada { background: #fdecea; color: #8a241c; }
.chip.error { background: #fdecea; color: #8a241c; }
.chip.tipo { color: #fff; }
.vacio { padding: 28px; text-align: center; color: var(--sutil); }
dialog { border: none; border-radius: var(--radio); padding: 22px; width: min(440px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,23,42,.45); }
.fila-botones { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---------- Escáner ---------- */
body.escaner { background: #0f141a; color: #fff; min-height: 100vh; }
.escaner .barra { background: #0f141a; border-bottom: 1px solid #222a33; }
.escaner main { max-width: 520px; margin: 0 auto; padding: 16px; }
#lector { width: 100%; border-radius: 14px; overflow: hidden; background: #000; min-height: 280px; }
#lector video { border-radius: 14px; }
.contador { display: flex; justify-content: space-between; margin: 12px 2px; color: #9aa5b1; font-size: 14px; }
.aviso-camara { padding: 16px; background: #2a1f12; color: #f6d38b; border-radius: 12px; margin-top: 12px; }
.panel-resultado { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px; text-align: center; color: #fff; }
.panel-resultado.valida { background: #0f7a4f; }
.panel-resultado.invalida { background: #b3261e; }
.panel-resultado.cargando { background: rgba(15,20,26,.92); }
.panel-resultado .estado { font-size: 40px; font-weight: 800; letter-spacing: .02em; }
.panel-resultado .tipo-grande { margin: 18px 0 8px; padding: 14px 28px; border-radius: 16px; font-size: 44px; font-weight: 900; border: 3px solid rgba(255,255,255,.85); }
.panel-resultado .manilla { font-size: 20px; font-weight: 700; }
.panel-resultado .detalle { font-size: 18px; margin-top: 12px; opacity: .95; }
.panel-resultado .sub { font-size: 15px; margin-top: 6px; opacity: .85; }
.panel-resultado .btn { margin-top: 30px; font-size: 18px; padding: 16px 34px; background: #fff; color: #111; border: none; }
