:root {
  --fondo: #090c13; --panel: #111722; --panel2: #161e2c; --borde: #222c3d; --borde2: #2c3850;
  --texto: #eef2f8; --gris: #93a0b5; --tenue: #6b788d;
  --ac: #6ea8ff; --ac-osc: #08162c; --ok: #3ccf8e; --warn: #f5b942; --mal: #ff6b6b;
  --her: #f5b942; --act: #6ea8ff; --mob: #3ccf8e; --mkt: #e879f9;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Poppins', -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--fondo); color: var(--texto); -webkit-font-smoothing: antialiased; font-size: 14px; }
a { color: var(--ac); }
button, input, select, textarea { font: inherit; color: inherit; }
.hide { display: none !important; }
:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }

/* Barra superior y navegación */
.barra { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 8px 18px; min-height: 58px;
  background: rgba(13,18,28,.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--borde); }
.barra .marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.barra .marca img { height: 28px; }
.barra .marca b { display: block; font-size: 15px; font-weight: 700; line-height: 1.15; }
.barra .marca span { display: block; font-size: 11px; color: var(--gris); letter-spacing: .4px; }
.barra .espacio { flex: 1; }
.quien { text-align: right; font-size: 12px; color: var(--gris); line-height: 1.3; }
.quien b { color: var(--texto); font-weight: 600; display: block; font-size: 13px; }
nav.menu { display: flex; gap: 4px; padding: 8px 18px; border-bottom: 1px solid var(--borde); background: var(--fondo); position: sticky; top: 58px; z-index: 19; overflow-x: auto; }
nav.menu a { color: var(--gris); text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
nav.menu a:hover { color: var(--texto); background: rgba(255,255,255,.04); }
nav.menu a.on { color: var(--ac-osc); background: var(--ac); }
nav.menu a .num { background: var(--mal); color: #fff; border-radius: 10px; font-size: 10.5px; padding: 0 6px; line-height: 17px; }
nav.menu a svg { width: 16px; height: 16px; }

.btn { border: 1px solid var(--borde2); background: var(--panel2); color: var(--texto); padding: 9px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: var(--gris); }
.btn.pri { background: var(--ac); border-color: var(--ac); color: var(--ac-osc); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #05261a; }
.btn.peligro { color: var(--mal); border-color: color-mix(in srgb, var(--mal) 45%, transparent); background: transparent; }
.btn.chico { padding: 6px 10px; font-size: 12px; }
.btn.grande { padding: 14px 18px; font-size: 15px; border-radius: 12px; }
.btn.ancho { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }

/* Acceso */
.acceso-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px;
  background: radial-gradient(900px 420px at 50% -10%, rgba(110,168,255,.16), transparent 70%), var(--fondo); }
.tarjeta { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--borde); border-radius: 18px; padding: 28px 26px; box-shadow: 0 20px 50px rgba(0,0,0,.45); position: relative; overflow: hidden; }
.tarjeta::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--ac), transparent 85%); }
.tarjeta .logo { display: block; width: 170px; margin: 0 auto 14px; }
.tarjeta h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
.tarjeta p.sub { text-align: center; color: var(--gris); font-size: 12.5px; margin: 0 0 20px; }
label.campo { display: block; margin-bottom: 14px; }
label.campo > span { display: block; font-size: 12px; color: var(--gris); margin-bottom: 5px; font-weight: 500; }
input.in, select.in, textarea.in { width: 100%; background: var(--panel2); border: 1px solid var(--borde2); border-radius: 9px; padding: 10px 12px; color: var(--texto); outline: none; font-size: 15px; }
input.in:focus, select.in:focus { border-color: var(--ac); }
.tarjeta .btn.pri { width: 100%; padding: 11px; font-size: 14px; }
.msg { margin: 12px 0 0; font-size: 13px; padding: 9px 12px; border-radius: 9px; }
.msg.err { background: color-mix(in srgb, var(--mal) 14%, transparent); color: #ffb3b3; border: 1px solid color-mix(in srgb, var(--mal) 40%, transparent); }
.msg.ok { background: color-mix(in srgb, var(--ok) 13%, transparent); color: #a8f0cf; border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.msg.info { background: color-mix(in srgb, var(--ac) 12%, transparent); color: #c7dcff; border: 1px solid color-mix(in srgb, var(--ac) 35%, transparent); }
.msg.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: #ffe2a6; border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.nota { color: var(--tenue); font-size: 11.5px; text-align: center; margin-top: 16px; line-height: 1.5; }
.enlace { background: none; border: 0; color: var(--ac); cursor: pointer; font-size: 12.5px; padding: 4px; }

/* Contenido */
main.contenido { max-width: 1100px; margin: 0 auto; padding: 18px 18px 60px; }
.panel { background: var(--panel); border: 1px solid var(--borde); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.panel > h2 { font-size: 16px; margin: 0 0 4px; }
.panel > p.ayuda, p.ayuda { color: var(--gris); font-size: 12.5px; margin: 0 0 12px; line-height: 1.5; }
h3.paso { font-size: 13px; color: var(--gris); font-weight: 600; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .5px; }
h3.paso:first-child { margin-top: 0; }
.fila { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.fila > .crece { flex: 1; min-width: 160px; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--borde); border-left: 3px solid var(--ac); border-radius: 12px; padding: 10px 13px; text-align: left; cursor: default; }
button.tile { cursor: pointer; }
button.tile.on { background: var(--panel2); border-color: var(--gris); }
.tile .v { font-size: 22px; font-weight: 700; }
.tile .l { font-size: 12px; color: var(--gris); }
.tile.warn { border-left-color: var(--warn); } .tile.mal { border-left-color: var(--mal); } .tile.ok { border-left-color: var(--ok); }
.tile.c-her { border-left-color: var(--her); } .tile.c-act { border-left-color: var(--act); } .tile.c-mob { border-left-color: var(--mob); } .tile.c-mkt { border-left-color: var(--mkt); }
.buscador { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--borde2); border-radius: 11px; padding: 2px 8px 2px 12px; }
.buscador:focus-within { border-color: var(--ac); }
.buscador input { flex: 1; border: 0; background: transparent; outline: none; padding: 9px 2px; font-size: 14.5px; min-width: 0; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 1px solid var(--borde2); background: transparent; color: var(--gris); border-radius: 20px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; font-weight: 500; }
.chip.on { background: color-mix(in srgb, var(--ac) 16%, transparent); color: var(--texto); border-color: color-mix(in srgb, var(--ac) 60%, transparent); }

/* Grupos de inventario */
.grupo { background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.grupo > button.cab { width: 100%; background: none; border: 0; text-align: left; padding: 12px 14px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.grupo .ico { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; }
.grupo .ico svg { width: 20px; height: 20px; }
.grupo .cuerpo { flex: 1; min-width: 0; }
.grupo .cuerpo b { display: block; font-size: 14.5px; font-weight: 600; }
.grupo .cuerpo small { color: var(--gris); font-size: 12px; }
.grupo .cuenta { font-size: 20px; font-weight: 700; min-width: 34px; text-align: right; }
.piezas { border-top: 1px solid var(--borde); }
.pieza { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--borde); cursor: pointer; }
.pieza:last-child { border-bottom: 0; }
.pieza:hover { background: rgba(255,255,255,.02); }
.pieza .f { font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 13px; min-width: 88px; }
.pieza .d { flex: 1; min-width: 0; color: var(--gris); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pieza input[type=checkbox], .sel { width: 20px; height: 20px; accent-color: var(--ac); flex: none; }
.c-her .ico, .ico.c-her { background: color-mix(in srgb, var(--her) 14%, transparent); color: var(--her); }
.c-act .ico, .ico.c-act { background: color-mix(in srgb, var(--act) 14%, transparent); color: var(--act); }
.c-mob .ico, .ico.c-mob { background: color-mix(in srgb, var(--mob) 14%, transparent); color: var(--mob); }
.c-mkt .ico, .ico.c-mkt { background: color-mix(in srgb, var(--mkt) 14%, transparent); color: var(--mkt); }

.et { font-size: 10.5px; font-weight: 700; letter-spacing: .4px; padding: 2px 8px; border-radius: 20px; white-space: nowrap; display: inline-block; }
.et.uso { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.et.rep { background: color-mix(in srgb, var(--ac) 16%, transparent); color: var(--ac); }
.et.dan { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.et.alm { background: var(--panel2); color: var(--gris); border: 1px solid var(--borde2); }
.et.ext, .et.baja { background: color-mix(in srgb, var(--mal) 16%, transparent); color: var(--mal); }
.et.pend { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.vacio { text-align: center; color: var(--gris); padding: 40px 10px; }

/* Registro: botones grandes */
.opciones { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.opciones.cats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.op { background: var(--panel2); border: 1px solid var(--borde2); border-radius: 12px; padding: 13px 12px; text-align: left; cursor: pointer; font-weight: 600; font-size: 13.5px; display: flex; gap: 10px; align-items: center; min-height: 52px; }
.op:hover { border-color: var(--gris); }
.op.on { border-color: var(--ac); background: color-mix(in srgb, var(--ac) 14%, var(--panel2)); }
.op .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.op .ico svg { width: 19px; height: 19px; }
.op small { display: block; font-weight: 400; color: var(--gris); font-size: 11px; }
.segmento { display: flex; flex-wrap: wrap; gap: 6px; }
.segmento button { border: 1px solid var(--borde2); background: var(--panel2); border-radius: 9px; padding: 9px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.segmento button.on { border-color: var(--ac); background: color-mix(in srgb, var(--ac) 18%, var(--panel2)); }
.contador { display: inline-flex; align-items: center; border: 1px solid var(--borde2); border-radius: 12px; overflow: hidden; }
.contador button { width: 52px; height: 48px; border: 0; background: var(--panel2); font-size: 24px; cursor: pointer; }
.contador b { min-width: 64px; text-align: center; font-size: 22px; }
.foto-prev { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.foto-prev img { width: 130px; height: 130px; object-fit: cover; border-radius: 10px; border: 1px solid var(--borde2); }
.resultado { text-align: center; padding: 10px 0; }
.resultado .folios { font-family: ui-monospace, Consolas, monospace; font-size: 18px; font-weight: 700; margin: 8px 0 14px; word-break: break-word; }
.acciones { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* Ficha y ventanas */
.modal-fondo { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 50; display: grid; place-items: center; padding: 14px; }
.modal { width: 100%; max-width: 640px; max-height: 94vh; overflow: auto; background: var(--panel); border: 1px solid var(--borde2); border-radius: 16px; padding: 18px; position: relative; }
.modal h2 { margin: 0 0 10px; font-size: 17px; padding-right: 36px; }
.modal .cerrar { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--borde2); background: var(--panel2); cursor: pointer; font-size: 18px; }
.ficha-foto { width: 100%; max-height: 340px; object-fit: contain; background: #000; border-radius: 12px; display: block; margin-bottom: 12px; }
.ficha-folio { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--ac); font-weight: 700; letter-spacing: .5px; }
.datos { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; margin: 12px 0; }
.datos dt { color: var(--gris); } .datos dd { margin: 0; }
.historial { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.historial li { padding: 8px 0; border-bottom: 1px solid var(--borde); }
.historial li b { font-weight: 600; } .historial li small { color: var(--gris); display: block; }
.mini { color: var(--gris); font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; }

/* Escáner */
.escaner { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; }
.escaner video { flex: 1; width: 100%; object-fit: cover; min-height: 0; }
.escaner .mira { position: absolute; left: 50%; top: 42%; width: min(64vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; }
.escaner .mira.lei { border-color: var(--ok); }
.escaner .pie { background: rgba(10,14,22,.96); padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.escaner .estado { color: #fff; font-size: 14px; text-align: center; min-height: 22px; }
.escaner .estado b { font-family: ui-monospace, Consolas, monospace; }

/* Tablas */
.tabla { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
th, td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { color: var(--gris); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
td.n, th.n { text-align: right; }
tr.total td { font-weight: 700; border-top: 2px solid var(--borde2); }
tr.zona td { background: var(--panel2); color: var(--gris); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; }
.casillas { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0 12px; }
.casillas label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.barra-accion { position: sticky; bottom: 0; background: rgba(17,23,34,.97); border: 1px solid var(--borde2); border-radius: 12px; padding: 10px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; box-shadow: 0 -8px 24px rgba(0,0,0,.4); }
.cargando { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; font-size: 14px; }
.cargando div { background: var(--panel); border: 1px solid var(--borde2); border-radius: 12px; padding: 14px 20px; }
.aviso { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; background: #1d2738; border: 1px solid var(--borde2); border-radius: 12px; padding: 11px 16px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: calc(100% - 28px); }
.aviso.err { border-color: var(--mal); color: #ffc9c9; }
footer.pie { text-align: center; color: var(--tenue); font-size: 11.5px; padding: 0 20px 30px; }

/* Etiquetas para imprimir (hoja carta, 3 × 8) */
#impresion { display: none; }
@media print {
  @page { size: letter; margin: 9mm 7mm; }
  body { background: #fff; color: #000; }
  body > *:not(#impresion) { display: none !important; }
  #impresion { display: grid !important; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 32.4mm; gap: 0; }
  .etq { border: 1px dashed #999; padding: 2.5mm; display: flex; gap: 2.5mm; align-items: center; overflow: hidden; break-inside: avoid; font-family: Arial, sans-serif; }
  .etq svg { width: 25mm; height: 25mm; flex: none; }
  .etq .t { min-width: 0; line-height: 1.15; }
  .etq .m { font-size: 6.5pt; letter-spacing: .6pt; white-space: nowrap; font-weight: 700; color: #333; }
  .etq .fo { font-size: 12.5pt; white-space: nowrap; font-weight: 800; font-family: Consolas, monospace; margin: .6mm 0; }
  .etq .no { font-size: 7.5pt; font-weight: 700; }
  .etq .ub { font-size: 7pt; color: #333; }
}

@media (max-width: 700px) {
  .barra { padding: 8px 12px; gap: 10px; min-height: 54px; }
  .barra .marca span, .quien span { display: none; }
  .barra .marca img { height: 24px; }
  nav.menu { position: fixed; top: auto; bottom: 0; left: 0; right: 0; border-top: 1px solid var(--borde); border-bottom: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(13,18,28,.98); justify-content: flex-start; gap: 2px; }
  nav.menu a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 9px; min-width: 64px; position: relative; }
  nav.menu a .num { position: absolute; top: 2px; right: 8px; }
  nav.menu a svg { width: 20px; height: 20px; }
  main.contenido { padding: 14px 12px 96px; }
  .datos { grid-template-columns: 100px 1fr; }
  .modal { padding: 16px 14px; }
  .opciones { grid-template-columns: repeat(2, 1fr); }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .tile { padding: 8px 10px; }
  .tile .v { font-size: 18px; }
  .tile .l { font-size: 11px; line-height: 1.25; }
}
