/* =====================================================================
   MESA DE CONTROL · Grupo Garcha
   Sistema de diseño: industrial, ejecutivo, legible en piso de almacén.
   ===================================================================== */
:root {
  --brand: #FFD100;
  --brand-600: #F0C400;
  --brand-ink: #7A5F00;
  --brand-soft: rgba(255, 209, 0, .16);
  --on-brand: #0A0E13;

  --ink: #0A0E13;
  --steel-950: #0E141B;
  --steel-900: #131A23;
  --steel-800: #1B242F;
  --steel-700: #263241;
  --steel-600: #3A4959;
  --steel-400: #7C8B9C;
  --steel-300: #A8B4C0;
  --steel-200: #D3DAE1;
  --steel-100: #E9EDF1;
  --steel-50: #F4F6F8;

  --tx: #131A23;
  --tx-soft: #4E5C6B;
  --tx-mute: #6B7A8B;
  --line: #E1E6EB;
  --surface: #FFFFFF;
  --page: #F4F6F8;

  /* Estados (siempre con icono + texto, nunca solo color) */
  --ok: #0ca30c;
  --ok-ink: #006300;
  --ok-soft: #e3f5e3;
  --warn: #fab219;
  --warn-ink: #7a5200;
  --warn-soft: #fff4d9;
  --serious: #ec835a;
  --crit: #d03b3b;
  --crit-ink: #a42727;
  --crit-soft: #fbe6e6;
  --info-soft: #e8f1fc;
  --info-ink: #1c5cab;

  /* Gráficas */
  --serie-1: #2a78d6;
  --serie-1-claro: #86b6ef;
  --grid: #e1e0d9;
  --eje: #c3c2b7;
  --muted-chart: #898781;

  --r: 4px;
  --r-lg: 6px;
  --sh-sm: 0 1px 2px rgba(10, 14, 19, .06), 0 2px 8px rgba(10, 14, 19, .04);
  --sh-md: 0 4px 12px rgba(10, 14, 19, .08), 0 12px 32px rgba(10, 14, 19, .06);
  --sh-lg: 0 12px 28px rgba(10, 14, 19, .14), 0 32px 64px rgba(10, 14, 19, .12);
  --f-display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --f-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --lateral: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.45;
  color: var(--tx);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--info-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.oculto { display: none !important; }
.mono { font-family: var(--f-mono); font-size: .92em; letter-spacing: .02em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mute { color: var(--tx-mute); }
.soft { color: var(--tx-soft); }
.chico { font-size: 12px; }
.fuerte { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ico svg { width: 18px; height: 18px; vertical-align: middle; }

/* ============================ ESTRUCTURA ============================ */
.app { display: grid; grid-template-columns: var(--lateral) 1fr; min-height: 100vh; }
.lateral {
  background: var(--steel-950);
  color: #EBF0F5;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid #000;
  z-index: 40;
}
.lateral .marca { padding: 20px 20px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.lateral .marca img { height: 34px; width: auto; display: block; }
.lateral .marca .producto {
  font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: .12em;
  margin-top: 12px; color: #fff; display: flex; align-items: center; gap: 8px;
}
.lateral .marca .producto::before { content: ''; width: 4px; height: 18px; background: var(--brand); display: inline-block; }
.lateral nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.lateral .grupo { font-family: var(--f-display); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: #6f7e8f; padding: 11px 12px 4px; }
.lateral nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 12px; border-radius: var(--r);
  color: #C9D3DD; font-weight: 500; font-size: 14px; line-height: 1.25;
  border-left: 3px solid transparent;
}
.lateral nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.lateral nav a.activo { background: rgba(255, 209, 0, .1); color: #fff; border-left-color: var(--brand); }
.lateral nav a.activo svg { color: var(--brand); }
.lateral nav a svg { width: 18px; height: 18px; flex: none; color: #8796a7; }
.lateral nav a .insignia { margin-left: auto; background: var(--brand); color: var(--on-brand); font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; min-width: 20px; text-align: center; }
.num.negativo, .negativo { color: var(--crit-ink); font-weight: 700; }
.cliente-reabasto.critico { border-left: 4px solid var(--crit); }
.cliente-reabasto.reabastecer { border-left: 4px solid var(--warn); }
.cliente-reabasto.ok { border-left: 4px solid var(--ok); }
.cliente-reabasto.en_camino { border-left: 4px solid var(--serie-1); }
.cliente-reabasto.pedido { border-left: 4px solid var(--warn); }
.avance { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.avance .pista { flex: 1; height: 8px; border-radius: 4px; background: var(--steel-100); overflow: hidden; }
.avance .pista i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.avance span { white-space: nowrap; }
.lateral .pie { padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: #8796a7; }
.lateral .pie strong { color: #EBF0F5; display: block; font-size: 13px; font-weight: 600; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.barra {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.barra h1 { font-family: var(--f-display); font-size: 24px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra .empresa { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--tx-soft); }
.barra .empresa select { max-width: 260px; }
.barra .empresa .nombre { font-weight: 600; color: var(--tx); max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra .btn-menu { display: none; }
.lateral .pie .btn { color: #C9D3DD; }
.lateral .pie .btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
#vista { padding: 24px; max-width: 1480px; width: 100%; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: fixed; left: 0; top: 0; width: var(--lateral); transform: translateX(-100%); transition: transform .2s var(--ease); }
  .app.menu-abierto .lateral { transform: none; box-shadow: var(--sh-lg); }
  .app.menu-abierto::after { content: ''; position: fixed; inset: 0; background: rgba(10, 14, 19, .45); z-index: 35; }
  .barra .btn-menu { display: inline-flex; }
  .barra { padding: 0 14px; }
  .barra .empresa .etiqueta { display: none; }
  #vista { padding: 16px; }
}
@media (max-width: 600px) {
  .barra h1 { font-size: 20px; }
  .barra .empresa .nombre { max-width: 130px; }
}

/* ============================ COMPONENTES ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r);
  border: 1px solid var(--steel-200); background: #fff; color: var(--tx);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease);
  text-decoration: none !important;
}
.btn:hover { background: var(--steel-50); border-color: var(--steel-300); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn.primario { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primario:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn.oscuro { background: var(--steel-900); border-color: var(--steel-900); color: #fff; }
.btn.oscuro:hover { background: var(--steel-700); }
.btn.peligro { color: var(--crit-ink); border-color: #f0c4c4; }
.btn.peligro:hover { background: var(--crit-soft); }
.btn.fantasma { border-color: transparent; background: transparent; }
.btn.fantasma:hover { background: var(--steel-100); }
.btn.chico { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.grande { height: 52px; padding: 0 24px; font-size: 16px; }
.btn.icono { width: 38px; padding: 0; }
.btn.chico.icono { width: 30px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
  height: 38px; padding: 0 11px; border: 1px solid var(--steel-200); border-radius: var(--r);
  background: #fff; min-width: 0; width: 100%;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--steel-600); box-shadow: 0 0 0 3px var(--brand-soft); }
select { padding-right: 28px; }
label.campo { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--tx-soft); }
label.campo .ayuda { font-weight: 400; color: var(--tx-mute); font-size: 12px; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
label.check input { width: 17px; height: 17px; accent-color: var(--steel-900); }
.form { display: grid; gap: 14px; }
.form.dos { grid-template-columns: 1fr 1fr; }
.form .completo { grid-column: 1 / -1; }
@media (max-width: 600px) { .form.dos { grid-template-columns: 1fr; } }

.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.tarjeta > .cab { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tarjeta > .cab h2, .tarjeta > .cab h3 { font-family: var(--f-display); font-size: 18px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; flex: 1; }
.tarjeta > .cab .sub { width: 100%; font-size: 12px; color: var(--tx-mute); margin-top: -6px; }
.tarjeta > .cuerpo { padding: 18px; }
.tarjeta > .cuerpo.sin-pad { padding: 0; }

.rejilla { display: grid; gap: 18px; }
.rejilla.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rejilla.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rejilla.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rejilla.k21 { grid-template-columns: 2fr 1fr; }
.rejilla.k12 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1200px) { .rejilla.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .rejilla.k3, .rejilla.k2, .rejilla.k21, .rejilla.k12 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .rejilla.k4 { grid-template-columns: 1fr; } }
.pila { display: flex; flex-direction: column; gap: 18px; }

.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 18px; }
.filtros > * { flex: 0 0 auto; }
.filtros label.campo { min-width: 150px; }
.filtros .crece { flex: 1 1 220px; }
.filtros > .aviso-caja { flex: 1 1 320px; }
.filtros .der { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Indicadores (stat tiles) */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .etq { font-size: 13px; color: var(--tx-soft); font-weight: 500; }
.kpi .val { font-size: 28px; font-weight: 650; letter-spacing: -.01em; line-height: 1.15; color: var(--tx); }
.kpi .val.heroe { font-size: 48px; }
.kpi .delta { font-size: 12.5px; color: var(--tx-mute); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi .delta .sube-mal { color: var(--crit-ink); font-weight: 600; }
.kpi .delta .baja-bien { color: var(--ok-ink); font-weight: 600; }
.kpi.acento { border-top: 3px solid var(--brand); }

/* Chips de estado: icono + texto */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--steel-100); color: var(--tx-soft);
}
.chip svg { width: 13px; height: 13px; }
.chip.ok { background: var(--ok-soft); color: var(--ok-ink); }
.chip.ok svg { color: var(--ok); }
.chip.aviso { background: var(--warn-soft); color: var(--warn-ink); }
.chip.aviso svg { color: #c98500; }
.chip.critico { background: var(--crit-soft); color: var(--crit-ink); }
.chip.critico svg { color: var(--crit); }
.chip.info { background: var(--info-soft); color: var(--info-ink); }
.chip.marca { background: var(--brand-soft); color: var(--brand-ink); }
.chip.envuelve { white-space: normal; height: auto; padding: 2px 8px; line-height: 1.3; }

/* Tablas */
.tabla-wrap { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--tx-soft); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--steel-50); white-space: nowrap; position: sticky; top: 0;
}
.tabla th.ordenable { cursor: pointer; user-select: none; }
.tabla th.ordenable:hover { color: var(--tx); }
.tabla th .flecha { opacity: .5; margin-left: 4px; font-size: 10px; }
.tabla td { padding: 9px 12px; border-bottom: 1px solid var(--steel-100); vertical-align: middle; }
.tabla tr.clic { cursor: pointer; }
.tabla tbody tr:hover td { background: #fafbfc; }
.tabla tr.inactivo td { color: var(--tx-mute); }
.tabla tr.cancelada td { color: var(--tx-mute); text-decoration: line-through; }
.tabla tr.cancelada td:last-child, .tabla tr.cancelada td .chip { text-decoration: none; }
.tabla td.der, .tabla th.der { text-align: right; }
.tabla td.cen, .tabla th.cen { text-align: center; }
.tabla tfoot td { font-weight: 700; background: var(--steel-50); border-top: 1px solid var(--line); }
.tabla .acciones { display: flex; gap: 4px; justify-content: flex-end; }
.tabla .sub-fila td { background: #fcfcfb; font-size: 12.5px; color: var(--tx-soft); padding-top: 6px; padding-bottom: 6px; }
.tabla-pie { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13px; color: var(--tx-soft); flex-wrap: wrap; }
.tabla-pie .der { margin-left: auto; display: flex; gap: 6px; }

.vacio { padding: 40px 20px; text-align: center; color: var(--tx-mute); }
.vacio svg { width: 40px; height: 40px; color: var(--steel-300); margin-bottom: 8px; }
.cargando { padding: 40px; display: flex; justify-content: center; }
.cargando::after { content: ''; width: 28px; height: 28px; border: 3px solid var(--steel-200); border-top-color: var(--steel-900); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

.pestanas { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.pestanas a, .pestanas button {
  padding: 10px 14px; font-weight: 600; color: var(--tx-soft); border: 0; background: none; cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14px;
}
.pestanas a:hover, .pestanas button:hover { color: var(--tx); text-decoration: none; }
.pestanas .activa { color: var(--tx); border-bottom-color: var(--brand); }

.aviso-caja { padding: 12px 14px; border-radius: var(--r); background: var(--info-soft); color: var(--info-ink); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.aviso-caja svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.aviso-caja.amarillo { background: var(--warn-soft); color: var(--warn-ink); }
.aviso-caja.rojo { background: var(--crit-soft); color: var(--crit-ink); }
.aviso-caja.verde { background: var(--ok-soft); color: var(--ok-ink); }

/* Modal */
.modal-fondo { position: fixed; inset: 0; background: rgba(10, 14, 19, .55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--r-lg); box-shadow: var(--sh-lg); width: 100%; max-width: 560px; display: flex; flex-direction: column; max-height: 88vh; }
.modal.ancho { max-width: 860px; }
.modal .m-cab { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal .m-cab h2 { font-family: var(--f-display); font-size: 20px; text-transform: uppercase; letter-spacing: .03em; flex: 1; }
.modal .m-cuerpo { padding: 20px; overflow-y: auto; }
.modal .m-pie { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* Avisos flotantes */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--steel-900); color: #fff; padding: 12px 16px; border-radius: var(--r); box-shadow: var(--sh-md); display: flex; gap: 10px; align-items: flex-start; font-size: 14px; animation: entra .2s var(--ease); border-left: 4px solid var(--ok); }
.toast.error { border-left-color: var(--crit); }
.toast.aviso { border-left-color: var(--warn); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
@keyframes entra { from { transform: translateY(8px); opacity: 0; } }

/* Fotografía y ficha técnica de artículos */
.miniatura {
  width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--r); background: #fff;
  display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 2px; cursor: zoom-in;
}
.miniatura img { width: 100%; height: 100%; object-fit: contain; }
.miniatura.vacia { background: var(--steel-50); color: var(--steel-300); cursor: default; border-style: dashed; }
.miniatura svg { width: 18px; height: 18px; }
.enlace-ficha { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.enlace-ficha svg { width: 14px; height: 14px; color: var(--crit); }
.slots-archivo { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.slot-archivo { border: 2px dashed var(--steel-200); border-radius: var(--r-lg); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--steel-50); transition: border-color .15s, background .15s; }
.slot-archivo.arrastrando { border-color: var(--brand); background: #fffbe6; }
.slot-archivo .vista {
  height: 160px; background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; overflow: hidden; text-align: center; color: var(--tx-mute); font-size: 12.5px; padding: 6px;
}
.slot-archivo .vista a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.slot-archivo .vista img { max-width: 100%; max-height: 100%; object-fit: contain; }
.slot-archivo .vista svg { width: 38px; height: 38px; color: var(--steel-300); display: block; margin: 0 auto 6px; }
.slot-archivo .vista .pdf { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--tx); font-weight: 600; overflow-wrap: anywhere; padding: 0 8px; }
.slot-archivo .vista .pdf svg { color: var(--crit); }
.slot-archivo .botones { display: flex; gap: 8px; flex-wrap: wrap; }
.ficha-articulo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.ficha-articulo .foto-grande { background: #fff; border: 1px solid var(--line); border-radius: var(--r); min-height: 260px; display: flex; align-items: center; justify-content: center; padding: 10px; text-align: center; }
.ficha-articulo .foto-grande img { max-width: 100%; max-height: 420px; object-fit: contain; }
.ficha-articulo .foto-grande svg { width: 48px; height: 48px; color: var(--steel-300); }
@media (max-width: 700px) { .slots-archivo, .ficha-articulo { grid-template-columns: 1fr; } }

/* Aviso de actualización pendiente */
.aviso-version {
  position: sticky; top: 0; z-index: 95; display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 18px; background: var(--warn-soft); color: var(--warn-ink); border-bottom: 1px solid #f0d9a0; font-size: 13.5px;
}
.aviso-version svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* ============================ LOGIN ============================ */
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
  background: var(--steel-950);
}
.login .lado {
  position: relative; overflow: hidden; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; color: #EBF0F5;
  background: linear-gradient(160deg, #131A23 0%, #0A0E13 100%);
}
.login .lado::before {
  content: ''; position: absolute; inset: 0; opacity: .07;
  background-image: repeating-linear-gradient(45deg, var(--brand) 0 2px, transparent 2px 22px);
}
.login .lado > * { position: relative; }
.login .lado img { height: 52px; width: auto; }
.login .lado h1 { font-family: var(--f-display); font-size: 64px; font-weight: 700; letter-spacing: .04em; line-height: .95; text-transform: uppercase; margin: 28px 0 14px; }
.login .lado h1 span { color: var(--brand); display: block; }
.login .lado p { font-size: 16px; color: #9BAAB9; max-width: 460px; }
.login .lado ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; color: #C9D3DD; }
.login .lado li { display: flex; gap: 10px; align-items: center; }
.login .lado li::before { content: ''; width: 8px; height: 8px; background: var(--brand); flex: none; }
.login .forma { background: #fff; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.login form h2 { font-family: var(--f-display); font-size: 30px; text-transform: uppercase; letter-spacing: .03em; }
.login form .btn { height: 46px; font-size: 15px; }
.login .error { color: var(--crit-ink); font-size: 13px; min-height: 18px; }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login .lado { padding: 32px 24px; }
  .login .lado h1 { font-size: 44px; }
  .login .lado ul { display: none; }
}

/* ============================ REGISTRO DE ENTREGA ============================ */
.escaner {
  display: flex; gap: 10px; align-items: stretch; background: var(--steel-950); padding: 14px; border-radius: var(--r-lg); margin-bottom: 18px;
}
.escaner .entrada { flex: 1; position: relative; }
.escaner .entrada svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--brand); pointer-events: none; }
.escaner input { height: 54px; font-size: 18px; padding-left: 48px; border: 2px solid var(--brand); font-weight: 500; }
.escaner .btn { height: 54px; }
.entrega-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .entrega-cols { grid-template-columns: 1fr; } }
.colab-cab { display: flex; gap: 16px; align-items: center; padding: 18px; border-bottom: 1px solid var(--line); }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--steel-900); color: var(--brand); display: flex; align-items: center; justify-content: center; font-family: var(--f-display); font-weight: 700; font-size: 22px; flex: none; }
.colab-cab .nombre { font-size: 19px; font-weight: 700; }
.colab-cab .meta { color: var(--tx-soft); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; }
.colab-cab .cifras { margin-left: auto; text-align: right; font-size: 12px; color: var(--tx-mute); }
.colab-cab .cifras b { display: block; font-size: 17px; color: var(--tx); }
.epp-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; padding: 16px; }
.epp {
  border: 1px solid var(--line); border-radius: var(--r); padding: 11px 12px; display: flex; flex-direction: column; gap: 6px;
  background: #fff; cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s;
}
.epp:hover { border-color: var(--steel-400); box-shadow: var(--sh-sm); }
.epp.en-carrito { border-color: var(--brand); background: #fffdf2; }
.epp .desc { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.epp .det { font-size: 12px; color: var(--tx-mute); }
.epp .pie { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; }
.carrito-linea { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--steel-100); }
.carrito-linea .desc { font-weight: 600; }
.carrito-linea .controles { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.carrito-linea .controles select { width: auto; flex: 0 0 150px; }
.carrito-linea .controles input.just { flex: 1 1 200px; }
.cant { display: inline-flex; align-items: center; border: 1px solid var(--steel-200); border-radius: var(--r); overflow: hidden; }
.cant button { width: 34px; height: 36px; border: 0; background: var(--steel-50); cursor: pointer; font-size: 18px; font-weight: 600; }
.cant input { width: 56px; height: 36px; border: 0; text-align: center; border-radius: 0; padding: 0; }
.firma-caja { border: 2px dashed var(--steel-300); border-radius: var(--r); background: #fff; position: relative; touch-action: none; }
.firma-caja canvas { display: block; width: 100%; height: 170px; cursor: crosshair; }
.firma-caja .guia { position: absolute; left: 16px; right: 16px; bottom: 34px; border-bottom: 1px solid var(--steel-300); pointer-events: none; }
.firma-caja .leyenda { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 12px; color: var(--tx-mute); pointer-events: none; }
.total-entrega { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px; background: var(--steel-50); border-top: 1px solid var(--line); }
.total-entrega b { font-size: 22px; }
.bienvenida { text-align: center; padding: 56px 24px; }
.bienvenida svg { width: 84px; height: 84px; color: var(--steel-300); }
.bienvenida h2 { font-family: var(--f-display); font-size: 28px; text-transform: uppercase; margin: 12px 0 6px; }
.exito { text-align: center; padding: 18px 0 6px; }
.exito .folio { font-family: var(--f-display); font-size: 54px; font-weight: 700; line-height: 1; }
.exito svg.ok { width: 56px; height: 56px; color: var(--ok); }

/* Cámara */
.camara { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 4 / 3; }
.camara video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camara .mira { position: absolute; inset: 18% 22%; border: 3px solid var(--brand); border-radius: 8px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }

/* Gráficas SVG */
.grafica { width: 100%; position: relative; }
.grafica svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafica .tt {
  position: absolute; pointer-events: none; background: var(--steel-950); color: #fff; padding: 7px 10px; border-radius: var(--r);
  font-size: 12.5px; white-space: nowrap; box-shadow: var(--sh-md); transform: translate(-50%, calc(-100% - 10px)); z-index: 5;
}
.grafica .tt b { display: block; font-size: 13.5px; }
.grafica text { font-family: var(--f-body); }
.leyenda-graf { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--tx-soft); margin-top: 8px; }
.leyenda-graf span { display: inline-flex; gap: 6px; align-items: center; }
.leyenda-graf i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

/* Medidor de rendimiento (duración real vs esperada) */
.medidor { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.medidor .pista { flex: 1; height: 8px; border-radius: 4px; background: var(--steel-100); position: relative; overflow: hidden; }
.medidor .relleno { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.medidor .marca100 { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--steel-600); }

/* Mini serie (pronóstico) */
.mini { display: inline-flex; align-items: flex-end; gap: 2px; height: 26px; }
.mini i { width: 7px; background: var(--serie-1); border-radius: 2px 2px 0 0; display: inline-block; min-height: 1px; }
.mini i.proy { background: var(--serie-1-claro); }

/* Markdown del reporte */
.md h2 { font-family: var(--f-display); font-size: 20px; text-transform: uppercase; letter-spacing: .03em; margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--brand); display: inline-block; }
.md h2:first-child { margin-top: 0; }
.md h3 { font-size: 15px; margin: 12px 0 6px; }
.md p { margin: 6px 0; }
.md ul { margin: 6px 0; padding-left: 20px; }
.md li { margin: 4px 0; }

/* ============================ DOCUMENTOS IMPRIMIBLES ============================ */
.hoja { background: #fff; max-width: 920px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--line); box-shadow: var(--sh-sm); }
.hoja .doc-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 3px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.hoja .doc-cab img { height: 40px; width: auto; }
.hoja .doc-cab h1 { font-family: var(--f-display); font-size: 26px; text-transform: uppercase; letter-spacing: .02em; }
.hoja .doc-cab .meta { text-align: right; font-size: 12.5px; color: var(--tx-soft); }
.hoja .doc-cab .meta b { font-size: 20px; color: var(--tx); display: block; }
.hoja h2.sec { font-family: var(--f-display); font-size: 17px; text-transform: uppercase; letter-spacing: .04em; margin: 22px 0 10px; padding-left: 10px; border-left: 4px solid var(--brand); }
.datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 18px; font-size: 13px; }
.datos div span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--tx-mute); }
.datos div b { font-weight: 600; }
.leyenda-nom { font-size: 12px; color: var(--tx-soft); border: 1px solid var(--line); background: var(--steel-50); padding: 10px 12px; border-radius: var(--r); margin-top: 16px; }
.firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 26px; }
.firmas .f { text-align: center; font-size: 12px; color: var(--tx-soft); }
.firmas .f .linea { height: 90px; border-bottom: 1px solid var(--ink); display: flex; align-items: flex-end; justify-content: center; margin-bottom: 6px; }
.firmas .f img { max-height: 86px; }
.firma-mini { height: 34px; width: auto; max-width: 120px; }
.doc-pie { margin-top: 26px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11px; color: var(--tx-mute); display: flex; justify-content: space-between; gap: 10px; }
.barra-doc { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; max-width: 920px; margin: 0 auto 14px; align-items: center; }
.barra-doc .izq { margin-right: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sello-cancelada { border: 3px solid var(--crit); color: var(--crit); font-family: var(--f-display); font-size: 22px; font-weight: 700; padding: 6px 14px; display: inline-block; transform: rotate(-4deg); letter-spacing: .1em; }
.kpis-doc { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpis-doc > div { border: 1px solid var(--line); border-top: 3px solid var(--brand); padding: 10px 12px; border-radius: var(--r); }
.kpis-doc span { display: block; font-size: 11.5px; color: var(--tx-soft); }
.kpis-doc b { font-size: 20px; font-weight: 650; }
.kpis-doc .heroe b { font-size: 26px; }
.kpis-doc small { display: block; color: var(--tx-mute); font-size: 11.5px; }
@media (max-width: 700px) { .hoja { padding: 20px 16px; } .datos, .kpis-doc { grid-template-columns: 1fr 1fr; } }

/* Gafetes (credencial CR80: 85.6 × 54 mm) */
.pliego { display: grid; grid-template-columns: repeat(2, 85.6mm); gap: 4mm 6mm; justify-content: center; background: #fff; padding: 8mm 0; }
.gafete {
  width: 85.6mm; height: 54mm; border: 1px dashed #b9c2cc; border-radius: 3mm; overflow: hidden; display: flex; flex-direction: column;
  background: #fff; break-inside: avoid; page-break-inside: avoid; position: relative;
}
.gafete .g-cab { background: var(--ink); color: #fff; padding: 2mm 3.5mm; display: flex; justify-content: space-between; align-items: center; gap: 2mm; }
.gafete .g-cab .emp { font-family: var(--f-display); font-weight: 700; font-size: 3.4mm; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gafete .g-cab .tipo { font-family: var(--f-display); font-size: 2.6mm; color: var(--brand); letter-spacing: .12em; white-space: nowrap; }
.gafete .g-cuerpo { flex: 1; display: flex; gap: 3mm; padding: 2.5mm 3.5mm 1mm; min-height: 0; }
.gafete .g-datos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .8mm; }
.gafete .g-nombre { font-weight: 700; font-size: 3.6mm; line-height: 1.15; max-height: 8.4mm; overflow: hidden; }
.gafete .g-num { font-family: var(--f-display); font-size: 6mm; font-weight: 700; line-height: 1; margin-top: .6mm; }
.gafete .g-num small { font-family: var(--f-body); font-size: 2.2mm; font-weight: 500; color: var(--tx-mute); display: block; letter-spacing: .05em; text-transform: uppercase; }
.gafete .g-meta { font-size: 2.5mm; color: var(--tx-soft); line-height: 1.3; }
.gafete .g-qr { width: 23mm; height: 23mm; flex: none; }
.gafete .g-qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.gafete .g-barras { padding: 0 3.5mm 1.2mm; text-align: center; }
.gafete .g-barras img { height: 7.5mm; width: 100%; object-fit: fill; image-rendering: pixelated; }
.gafete .g-barras .cod { font-family: var(--f-mono); font-size: 2.3mm; letter-spacing: .12em; }
.gafete .g-pie { height: 1.6mm; background: var(--brand); }
.gafete.solo-qr .g-qr { width: 30mm; height: 30mm; }
.gafete.solo-barras .g-qr { display: none; }
.gafete.solo-barras .g-barras img { height: 11mm; }
.pliego.etiquetas { grid-template-columns: repeat(3, 63mm); gap: 3mm; }
.etiqueta { width: 63mm; height: 32mm; border: 1px dashed #b9c2cc; border-radius: 2mm; display: flex; gap: 2.5mm; padding: 2.5mm; align-items: center; break-inside: avoid; page-break-inside: avoid; background: #fff; }
.etiqueta .e-qr { width: 25mm; height: 25mm; flex: none; }
.etiqueta .e-qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.etiqueta .e-datos { min-width: 0; font-size: 2.7mm; line-height: 1.25; }
.etiqueta .e-datos b { display: block; font-size: 3.2mm; }
.etiqueta .e-datos .grande { font-family: var(--f-display); font-size: 5mm; font-weight: 700; display: block; }
.etiqueta.articulo { flex-direction: column; align-items: stretch; gap: 1mm; }
.etiqueta.articulo img { height: 11mm; width: 100%; object-fit: fill; image-rendering: pixelated; }

@media print {
  @page { size: letter; margin: 10mm; }
  body { background: #fff; font-size: 12px; }
  .app { display: block; }
  .lateral, .barra, .no-print, .toasts, .barra-doc { display: none !important; }
  #vista { padding: 0; max-width: none; }
  .hoja { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .tarjeta { box-shadow: none; break-inside: avoid; }
  .pliego { padding: 0; }
  .gafete, .etiqueta { border-color: #ccd3da; }
  .tabla th { position: static; }
  .salto { break-before: page; }
  a { color: inherit; }
}
.pedidos-cliente { padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fffbea; }
.pedido-fila { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 6px 0; }
.pedido-fila .btn { margin-left: auto; }

/* Enviar pedido a… (directorio, correo y WhatsApp) */
.directorio { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); }
.contacto { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--steel-100); }
.contacto:last-child { border-bottom: 0; }
.contacto .datos-contacto { flex: 1; min-width: 0; }
.contacto .datos-contacto .chip { margin-left: 6px; }
.contacto .acciones-contacto { display: flex; gap: 6px; flex: none; }
.btn.whatsapp { background: #25D366; border-color: #25D366; color: #0A0E13; }
.btn.whatsapp:hover { background: #1ebe5a; border-color: #1ebe5a; }
.captura-envio { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.envios-pedido { margin-top: 14px; }
.adjunto-pdf { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: var(--r); }
.adjunto-pdf .ayuda-pdf { grid-column: 1 / -1; }
.aviso-caja a { color: inherit; font-weight: 600; }
@media (max-width: 600px) { .contacto { flex-wrap: wrap; } .captura-envio { grid-template-columns: 1fr; } }

/* ---------- Autorización de órdenes de compra ---------- */
.pasos-aut { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.pasos-aut li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; font-size: 13px; }
.pasos-aut .punto { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--steel-100); color: var(--tx-soft); }
.pasos-aut .punto svg { width: 15px; height: 15px; }
.pasos-aut li.autorizado { border-color: var(--ok); background: var(--ok-soft); }
.pasos-aut li.autorizado .punto { background: var(--ok); color: #fff; }
.pasos-aut li.pendiente { border-color: var(--warn); background: var(--warn-soft); }
.pasos-aut li.pendiente .punto { background: var(--warn); color: var(--on-brand); }
.pasos-aut li.en_espera { opacity: .75; }
.orden-aut { margin-bottom: 16px; }
.orden-aut .cab-orden { display: flex; justify-content: space-between; gap: 16px; padding: 16px 18px 10px; flex-wrap: wrap; }
.orden-aut .cab-orden .titulo { font-size: 16px; }
.orden-aut .monto { text-align: right; font-size: 20px; font-weight: 700; }
.orden-aut .acciones-orden { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 14px 18px; margin-top: 12px; border-top: 1px solid var(--line); }
.orden-aut .acciones-orden > span { margin-right: auto; }
.nivel-aut .cab-nivel { display: flex; align-items: center; gap: 12px; padding: 14px 18px 8px; }
.nivel-aut .num-nivel { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--brand); color: var(--on-brand); }
.nivel-aut.apagado { opacity: .6; }
.nivel-aut.apagado .num-nivel { background: var(--steel-100); color: var(--tx-soft); }
.casillas { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.casillas label.check { font-weight: 400; }

/* ---------- Requisiciones ---------- */
.req-caja { margin: 14px 16px 0; padding: 10px 14px; border: 1px solid var(--brand); border-left-width: 4px; border-radius: var(--r); background: #fffdf2; display: grid; gap: 10px; }
.req-caja .cab-req { display: flex; gap: 10px; align-items: center; }
.req-caja .cab-req > div { flex: 1; }
.req-caja .cab-req > svg { width: 20px; height: 20px; flex: none; }
.req-caja ul { margin: 6px 0 0; padding-left: 30px; font-size: 13px; }
.bloques-req { display: grid; gap: 12px; }
.bloque-colab { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: #fff; }
.bloque-colab .cab-colab { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.matriz-chica { display: flex; flex-wrap: wrap; gap: 8px; }
.epp-chico { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.epp-chico:hover { border-color: var(--steel-400, #9aa7b4); }
.epp-chico.en-carrito { border-color: var(--brand); background: #fffdf2; box-shadow: inset 0 0 0 1px var(--brand); }
.lineas-req { display: grid; gap: 6px; margin-top: 10px; }
.linea-req { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-top: 1px dashed var(--line); }
.linea-req .desc { flex: 1 1 220px; font-weight: 600; font-size: 13.5px; }
.linea-req select { width: auto; }
.linea-req input[type="text"] { flex: 1 1 220px; }
.hoja.ancha { max-width: 980px; }
.req-tabla tr.inicio-colab td { border-top: 2px solid var(--line); }
.req-tabla .firma-celda { min-width: 150px; }

/* ---------- Lotes y caducidades ---------- */
.lote-linea { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.lote-linea input[type="text"] { width: 120px; }
.lote-linea input[type="date"] { width: 150px; }
.linea-lote { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.linea-lote svg { width: 15px; height: 15px; color: var(--tx-mute); flex: none; }
.linea-lote select { width: auto; max-width: 100%; font-size: 12.5px; }
.renglon-ajuste { display: grid; gap: 6px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
tr.fila-vencida td { background: var(--crit-soft); }
.tarjeta.kpi.alerta-roja { border-color: var(--crit); background: var(--crit-soft); }

@media print {
  .req-tabla .firma-celda { border-bottom: 1px solid #999; }
  .pasos-aut li { break-inside: avoid; }
}

/* ---------- Alerta de punto de reorden ---------- */
a.alerta-reorden { display: block; color: inherit; text-decoration: none; margin-bottom: 18px; }
a.alerta-reorden:hover .aviso-caja { filter: brightness(.98); text-decoration: underline; }

/* Nombre de la versión (general o la del negocio) bajo el logo */
.lateral .marca .edicion { color: #C9D3DD; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin-top: 4px; }
