:root {
  --tinta: #13202b; --suave: #5b6b78; --linea: #d9e0e6; --fondo: #f3f5f7; --papel: #fff;
  --marca: #0f2a3d; --marca2: #1d4a68; --acento: #e8a33d;
  --ok: #1f7a4d; --ok-f: #e3f4ea; --aviso: #9a6200; --aviso-f: #fff3dc; --mal: #b3261e; --mal-f: #fde7e5; --info-f: #e7f0f7;
  --radio: 10px; --sombra: 0 1px 2px rgba(15, 42, 61, .08), 0 2px 8px rgba(15, 42, 61, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--tinta); background: var(--fondo);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; }
p { margin: .3rem 0 .8rem; }
a { color: var(--marca2); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.suave { color: var(--suave); } .chico { font-size: .85rem; }
.oculto { display: none !important; }

/* Estructura */
.barra { background: var(--marca); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; position: sticky; top: 0; z-index: 5; }
.barra .logo { display: flex; align-items: center; gap: .55rem; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.barra .logo img { width: 28px; height: 28px; }
.barra .logo small { font-weight: 400; opacity: .75; }
.barra .quien { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.barra .quien span { opacity: .85; }
.menu { background: var(--marca2); display: flex; gap: .15rem; overflow-x: auto; padding: 0 .5rem; position: sticky; top: 44px; z-index: 4; }
.menu a { color: #dbe7f0; text-decoration: none; padding: .65rem .8rem; white-space: nowrap; font-size: .95rem; border-bottom: 3px solid transparent; }
.menu a.activo { color: #fff; border-bottom-color: var(--acento); font-weight: 600; }
main { max-width: 1150px; margin: 0 auto; padding: 1rem; }
.demo-cinta { background: var(--acento); color: #2b1d00; text-align: center; font-size: .82rem; padding: .25rem; font-weight: 600; }

/* Tarjetas */
.tarjeta { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); padding: 1rem; margin-bottom: 1rem; }
.rejilla { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.cifras { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 1rem; }
.cifra { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: .7rem .8rem; }
.cifra b { display: block; font-size: 1.6rem; }
.cifra span { color: var(--suave); font-size: .85rem; }
.alerta { border-left: 5px solid var(--linea); }
.alerta.mal { border-left-color: var(--mal); } .alerta.aviso { border-left-color: var(--acento); } .alerta.ok { border-left-color: var(--ok); }
.alerta h3 { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.alerta h3 .n { font-size: 1.3rem; }
.lista-corta { list-style: none; margin: 0; padding: 0; }
.lista-corta li { padding: .35rem 0; border-top: 1px solid var(--linea); display: flex; justify-content: space-between; gap: .5rem; font-size: .92rem; }
.lista-corta li:first-child { border-top: 0; }
.lista-corta li a, td.mono, td .mono { white-space: nowrap; }

/* Formularios */
label { display: block; font-size: .88rem; font-weight: 600; margin: .55rem 0 .25rem; }
input, select, textarea { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid #b9c4cd; border-radius: 8px; background: #fff; color: var(--tinta); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #8cc1e6; outline-offset: 1px; }
textarea { min-height: 70px; resize: vertical; }
.fila { display: grid; gap: .2rem 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.opciones { display: flex; gap: .5rem; flex-wrap: wrap; }
.opciones label { margin: 0; font-weight: 500; display: flex; gap: .4rem; align-items: center; border: 1px solid #b9c4cd; border-radius: 8px; padding: .55rem .8rem; cursor: pointer; background: #fff; }
.opciones input { width: auto; }
.opciones label:has(input:checked) { border-color: var(--marca2); background: var(--info-f); font-weight: 700; }
.escaner { display: flex; gap: .4rem; }
.escaner input { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; text-transform: uppercase; }

button, .boton { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: .6rem 1rem; cursor: pointer; background: var(--marca2); color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; justify-content: center; }
button:hover, .boton:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sec, .boton.sec { background: #fff; color: var(--marca2); border-color: #b9c4cd; }
button.peligro { background: var(--mal); }
button.grande { font-size: 1.15rem; padding: .85rem 1.4rem; }
button.chico { padding: .3rem .6rem; font-size: .85rem; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; align-items: center; }
.barra button.sec { padding: .3rem .7rem; font-size: .85rem; }

/* Mensajes */
.msg { border-radius: 8px; padding: .65rem .8rem; margin: .6rem 0; font-size: .95rem; }
.msg.ok { background: var(--ok-f); color: #0f5132; } .msg.mal { background: var(--mal-f); color: #7a1610; } .msg.aviso { background: var(--aviso-f); color: #6b4500; } .msg.info { background: var(--info-f); color: #123b57; }
#aviso { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 50; max-width: 92vw; }
#aviso .msg { box-shadow: 0 4px 16px rgba(0, 0, 0, .18); margin: 0; }

/* Etiquetas de estado */
.estado { display: inline-block; padding: .12rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: #e9edf1; color: #33424e; }
.estado.recibida { background: #eef0ff; color: #3b3f99; } .estado.pesada { background: var(--info-f); color: #123b57; }
.estado.en_casillero { background: var(--ok-f); color: #0f5132; } .estado.en_reclamo { background: var(--aviso-f); color: #6b4500; }
.estado.eliminada { background: #eceff1; color: #6b7780; } .estado.vencida { background: var(--mal-f); color: #7a1610; }

/* Tablas */
.tabla-env { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--linea); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; color: var(--suave); background: #f7f9fa; position: sticky; top: 0; }
tr.clic { cursor: pointer; } tr.clic:hover td { background: #f4f8fb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Pesaje */
.display-peso { background: #0c1a24; color: #9df2b5; border-radius: 12px; padding: 1rem 1.2rem; font-family: ui-monospace, Consolas, monospace; text-align: right; }
.display-peso .valor { font-size: clamp(2.2rem, 7vw, 3.6rem); font-weight: 700; letter-spacing: 1px; }
.display-peso .valor small { font-size: 1.2rem; margin-left: .3rem; }
.display-peso .linea { display: flex; justify-content: space-between; color: #8aa4b4; font-size: .85rem; margin-top: .3rem; }
.display-peso.mov .valor { color: #f5c66b; }
.display-peso.vacio .valor { color: #4f6676; }
.pastilla { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 700; padding: .25rem .6rem; border-radius: 99px; }
.pastilla.ok { background: var(--ok-f); color: #0f5132; } .pastilla.mal { background: var(--mal-f); color: #7a1610; } .pastilla.aviso { background: var(--aviso-f); color: #6b4500; }

/* Casilleros */
.casilleros { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.casillero { background: #fff; border: 1px solid var(--linea); border-radius: 10px; padding: .6rem .7rem; cursor: pointer; text-align: left; color: var(--tinta); font-weight: 400; display: block; }
.casillero b { font-size: 1.1rem; font-family: ui-monospace, Consolas, monospace; }
.casillero.alto { border-color: var(--acento); background: #fffaf0; } .casillero.lleno { border-color: var(--mal); background: #fff6f5; }
.casillero.inactivo { opacity: .5; }
progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 99px; background: #e5eaee; overflow: hidden; }
progress::-webkit-progress-bar { background: #e5eaee; border-radius: 99px; }
progress::-webkit-progress-value { background: var(--ok); border-radius: 99px; }
.alto progress::-webkit-progress-value { background: var(--acento); } .lleno progress::-webkit-progress-value { background: var(--mal); }
progress::-moz-progress-bar { background: var(--ok); }
.pasos { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.paso { border: 2px dashed var(--linea); border-radius: 10px; padding: .8rem; }
.paso.listo { border-style: solid; border-color: var(--ok); background: var(--ok-f); }
.paso .num { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--marca2); color: #fff; font-weight: 700; margin-right: .4rem; }

/* Detalle */
.ficha { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .5rem 1rem; }
.ficha div span { display: block; font-size: .78rem; color: var(--suave); text-transform: uppercase; letter-spacing: .3px; }
.ficha div b { font-weight: 600; }
.bitacora { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--linea); }
.bitacora li { padding: .3rem 0 .6rem .9rem; position: relative; }
.bitacora li::before { content: ""; position: absolute; left: -6px; top: .65rem; width: 10px; height: 10px; border-radius: 50%; background: var(--marca2); }
.bitacora li .t { font-size: .8rem; color: var(--suave); }

/* Rótulo en pantalla */
.vista-rotulo { display: flex; justify-content: center; padding: .6rem; background: #eef1f4; border-radius: 10px; }

/* Login */
.ingreso { max-width: 400px; margin: 7vh auto; }
.ingreso .marca { text-align: center; margin-bottom: 1rem; }
.ingreso .marca img { width: 54px; }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .6rem; }
.teclado button { font-size: 1.35rem; padding: .8rem; background: #fff; color: var(--tinta); border-color: #b9c4cd; }
.pin { letter-spacing: .6rem; font-size: 1.6rem; text-align: center; }

/* Cámara */
.modal { position: fixed; inset: 0; background: rgba(5, 15, 22, .8); z-index: 40; display: grid; place-items: center; padding: 1rem; }
.modal .caja { background: #000; border-radius: 12px; overflow: hidden; width: min(520px, 100%); }
.modal video { width: 100%; display: block; max-height: 65vh; object-fit: cover; }
.modal .pie { background: #fff; padding: .6rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

@media (max-width: 640px) {
  main { padding: .7rem; }
  .barra .logo small, .barra .quien span { display: none; }
  .barra button { white-space: nowrap; }
  .menu { top: 44px; }
  th.opc, td.opc { display: none; }
}

/* ---------- Impresión ---------- */
#impresion { display: none; }
@page rotulo { size: 100mm 60mm; margin: 0; }
@page acta { size: A4; margin: 15mm; }
@media print {
  body { background: #fff; }
  #app, #aviso { display: none !important; }
  #impresion { display: block; }
  .hoja-rotulo { page: rotulo; width: 100mm; height: 60mm; padding: 3mm 4mm; overflow: hidden; break-after: page; display: flex; flex-direction: column; justify-content: space-between; color: #000; font-family: Arial, Helvetica, sans-serif; }
  .hoja-acta { page: acta; color: #000; font-family: Arial, Helvetica, sans-serif; font-size: 10.5pt; }
}
.hoja-rotulo { width: 100mm; height: 60mm; padding: 3mm 4mm; background: #fff; border: 1px solid #999; display: flex; flex-direction: column; justify-content: space-between; color: #000; font-family: Arial, Helvetica, sans-serif; }
.hoja-rotulo .sup { display: flex; justify-content: space-between; gap: 2mm; white-space: nowrap; overflow: hidden; font-size: 7pt; text-transform: uppercase; letter-spacing: .3px; }
.hoja-rotulo .id { font-size: 22pt; font-weight: 800; font-family: Arial, Helvetica, sans-serif; text-align: center; letter-spacing: .5px; line-height: 1; }
.hoja-rotulo .code128 { width: 100%; height: 14mm; display: block; }
.hoja-rotulo .datos { display: grid; grid-template-columns: 1fr 1fr; font-size: 7.5pt; gap: 0 2mm; }
.hoja-rotulo .datos b { font-size: 8.5pt; }
.hoja-rotulo.casillero .id { font-size: 40pt; }
.hoja-rotulo.casillero .code128 { height: 18mm; }
.hoja-acta h1 { font-size: 15pt; } .hoja-acta table { font-size: 9pt; } .hoja-acta th { position: static; background: #eee; color: #000; }
.hoja-acta .firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 20mm; margin-top: 25mm; text-align: center; }
.hoja-acta .firmas div { border-top: 1px solid #000; padding-top: 2mm; }

.hoja-rotulo .sup span { overflow: hidden; text-overflow: ellipsis; }
.hoja-rotulo .datos b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.aviso-pin { background: var(--aviso-f); color: #5a3b00; border-radius: 8px; padding: .55rem .7rem; font-size: .85rem; margin: .8rem 0 .4rem; }
