:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel-2: #f9fafb; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #1d4ed8; --accent-bg: #eff4ff; --top: #0f172a; --top-text: #cbd5e1;
  --ok-bg: #ecfdf5; --ok: #047857; --err-bg: #fef2f2; --err: #b91c1c; --warn-bg: #fffbeb; --warn: #b45309;
  --chip-bg: #eef2ff; --chip: #3730a3; --sombra: 0 1px 2px rgba(0,0,0,.05), 0 1px 1px rgba(0,0,0,.03);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17; --panel: #131a26; --panel-2: #182131; --text: #e5e7eb; --muted: #94a3b8; --line: #243044;
    --accent: #7aa2ff; --accent-bg: #1a2540; --top: #05080e; --top-text: #94a3b8;
    --ok-bg: #0c2a20; --ok: #6ee7b7; --err-bg: #2c1215; --err: #fca5a5; --warn-bg: #2b2210; --warn: #fcd34d;
    --chip-bg: #1e2748; --chip: #c7d2fe; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── Cabecera ─────────────────────────────────────────── */
header.top { background: var(--top); padding: 0 20px; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; min-height: 52px; }
header.top a { color: var(--top-text); text-decoration: none; }
header.top .marca { color: #fff; font-weight: 650; }
header.top .marca span { color: var(--top-text); font-weight: 400; font-size: 12px; margin-left: 6px; }
header.top .modulo-actual { color: #fff; font-size: 13px; background: #1e293b; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
header.top nav a.otros-modulos { color: #93c5fd; }
header.top nav { display: flex; gap: 2px; flex-wrap: wrap; }
header.top nav a { padding: 15px 10px 13px; border-bottom: 2px solid transparent; }
header.top nav a:hover { color: #fff; }
header.top nav a.activo { color: #fff; border-bottom-color: #60a5fa; }
header.top .yo { margin-left: auto; color: var(--top-text); font-size: 13px; }
main { max-width: 1320px; margin: 0 auto; padding: 18px 20px 120px; }

h1 { font-size: 21px; margin: 0; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.encabezado { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.encabezado p { margin: 3px 0 0; }
.ayuda { color: var(--muted); max-width: 900px; margin: 0 0 14px; }

/* ── Flujo de estados ─────────────────────────────────── */
.flujo { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.flujo .paso { flex: 1 0 88px; display: flex; flex-direction: column; gap: 1px; padding: 9px 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--text); box-shadow: var(--sombra); position: relative; }
.flujo .paso .n { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.flujo .paso .t { font-size: 12px; color: var(--muted); white-space: nowrap; }
.flujo .paso.vacio { opacity: .55; }
.flujo .paso.sel { border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 0 0 1px var(--accent) inset; }
.flujo .paso.ALERTA { border-color: #f59e0b; background: var(--warn-bg); }
.flujo .paso.ALERTA .n { color: var(--warn); }

/* ── Filtros ──────────────────────────────────────────── */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.filtros.sin-borde { background: none; border: 0; padding: 0; margin: 0; }
.filtros label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.filtros input[type=search] { min-width: 260px; flex: 1; }

/* ── Grupos y tablas ──────────────────────────────────── */
details.grupo { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; box-shadow: var(--sombra); overflow: hidden; }
details.grupo > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
details.grupo > summary::-webkit-details-marker { display: none; }
details.grupo > summary::before { content: "▾"; color: var(--muted); width: 10px; }
details.grupo:not([open]) > summary::before { content: "▸"; }
details.grupo:not([open]) > summary { border-bottom: 0; }
details.grupo .titulo { font-weight: 650; }
details.grupo .meta { color: var(--muted); font-size: 13px; }
details.grupo .acciones-grupo { margin-left: auto; display: flex; gap: 6px; }
.tabla-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-2); }
th { font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td.chk, th.chk, label.chk { width: 30px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
tr.alerta td { background: var(--warn-bg); }
.nudo { font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: none; }
.nudo:hover { text-decoration: underline; }
.dias { display: inline-block; margin-left: 4px; font-size: 11px; padding: 0 6px; border-radius: 8px; background: var(--chip-bg); color: var(--muted); }
.dias.d2 { background: var(--warn-bg); color: var(--warn); }
.dias.d3 { background: var(--err-bg); color: var(--err); font-weight: 600; }
.alerta-txt { color: var(--warn); }
.vacio-msg { padding: 30px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--chip-bg); color: var(--chip); white-space: nowrap; }
.chip.ALERTA { background: #fde68a; color: #92400e; font-weight: 600; }
.chip.FACTURADA, .chip.EN_DESPACHO { background: var(--ok-bg); color: var(--ok); }
.chip.PICKEADA { background: #dbeafe; color: #1e40af; }
.chip.NUEVA { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

/* ── Barra de acciones en lote ────────────────────────── */
.barra-lote { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--panel); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(0,0,0,.08); padding: 10px 20px; display: flex; gap: 14px 22px; align-items: end; flex-wrap: wrap; }
.barra-lote[hidden] { display: none; }
.barra-lote .cuenta { align-self: center; font-size: 15px; }
.barra-lote .accion { display: flex; gap: 6px; align-items: end; flex-wrap: wrap; padding-left: 18px; border-left: 1px solid var(--line); }
.barra-lote label { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); gap: 2px; }
.barra-lote label.check { flex-direction: row; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text); padding-bottom: 6px; }

/* ── Controles ────────────────────────────────────────── */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=number], select, textarea {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input.cant { width: 90px; text-align: right; }
button, .boton { padding: 6px 12px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button.sec, .boton.sec { background: var(--panel); color: var(--accent); }
button.mini, .boton.mini { padding: 3px 9px; font-size: 12.5px; }
button.peligro { background: var(--err); border-color: var(--err); }
button.link { background: none; border: 0; color: var(--accent); padding: 0 4px; text-decoration: underline; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--sombra); }
.msg { padding: 9px 12px; border-radius: 8px; margin-bottom: 10px; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.error { background: var(--err-bg); color: var(--err); }
.msg.conflicto { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.acciones { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.acciones form { display: flex; gap: 6px; flex-wrap: wrap; align-items: end; }
.falta { color: var(--err); font-weight: 600; }
.login { max-width: 360px; margin: 60px auto; }
.login label, .form label { display: block; margin: 8px 0 3px; color: var(--muted); }
.login input { width: 100%; }

@media print { header.top, .barra-lote, .filtros, .flujo { display: none; } }
tr.concepto td { color: var(--muted); font-style: italic; }
td.lote { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Entregas (celular del chofer) ───────────────────── */
.entregas { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 12px; }
.entrega { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: var(--sombra); }
.entrega header { display: flex; gap: 10px; align-items: center; }
.entrega .parada { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; }
.entrega .cliente { font-weight: 650; }
.entrega .direccion { margin: 10px 0 4px; font-size: 15px; }
.form-entrega { display: grid; gap: 8px; margin-top: 12px; }
.form-entrega label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.form-entrega input { font-size: 16px; padding: 9px 10px; width: 100%; min-width: 0; }
.form-entrega input[type=file] { padding: 6px 0; font-size: 14px; border: 0; background: none; }
.aviso-sync { font-weight: normal; }
.obs-sola { color: var(--warn); white-space: pre-line; }
.acciones-nota { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
button:disabled { opacity: .5; cursor: not-allowed; }
.form-entrega button { padding: 11px; font-size: 16px; }
.no-entrega { margin-top: 10px; }
.no-entrega summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* ── Filtro por doble clic ───────────────────────────── */
.filtrable { cursor: zoom-in; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
td.filtrable:hover, .titulo.filtrable:hover { text-decoration: underline dotted; text-underline-offset: 3px; }
.filtros-activos { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -4px 0 12px; }
.filtro-chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 6px 4px 11px; border-radius: 16px;
  background: var(--accent-bg); color: var(--text); border: 1px solid var(--accent); }
.filtro-chip a { text-decoration: none; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); }
.filtro-chip a:hover { background: var(--accent); color: #fff; }
.filtros .pista { margin-left: auto; align-self: center; }
.zona-peligro { border-color: var(--err); margin-top: 18px; }
.zona-peligro > summary { cursor: pointer; color: var(--err); font-weight: 600; }
.zona-peligro p { max-width: 760px; }

/* ── Crédito por cliente ─────────────────────────────── */
.credito-cuerpo { display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.credito-nvv { overflow-x: auto; border-right: 1px solid var(--line); }
.credito-decision { padding: 12px 14px; }
.credito-decision input[type=text] { width: 100%; }
@media (max-width: 760px) { .credito-cuerpo { grid-template-columns: 1fr; } .credito-nvv { border-right: 0; border-bottom: 1px solid var(--line); } }
.vigencia { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.vigencia span { color: var(--text); }
.vigencia input, .vigencia-corta input { width: 70px; text-align: right; }
.vigencia-corta { font-size: 12px; color: var(--muted); align-self: center; }
.ok-txt { color: var(--ok); }
td.fecha { white-space: nowrap; }

/* ── Indicadores ─────────────────────────────────────── */
.indicadores .kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .t { color: var(--muted); font-size: 12.5px; }
.kpi .v { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
th.barra-col, td.barra-col { width: 45%; }
td.barra-col { position: relative; }
.barra { display: inline-block; height: 14px; border-radius: 3px; background: var(--accent); opacity: .8; vertical-align: middle; min-width: 2px; }
.barra-txt { margin-left: 8px; font-variant-numeric: tabular-nums; vertical-align: middle; }
form.salir { display: inline; } header.top button.link { color: var(--top-text); text-decoration: none; padding: 0; } header.top button.link:hover { color: #fff; }
.chip.prepago { background: #ede9fe; color: #5b21b6; }
.chip.credito { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.prepago { background: #2e1f5e; color: #ddd6fe; } }
details.excepcion { margin-top: 10px; }
details.excepcion > summary { cursor: pointer; font-size: 13px; color: var(--muted); }
details.excepcion form { display: grid; gap: 6px; margin-top: 8px; }
.badge-aviso { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #f59e0b; color: #111; font-size: 11px; font-weight: 700; text-align: center; }
.aviso { display: grid; gap: 4px; }
.aviso p { margin: 2px 0; }
details.liberar > summary { cursor: pointer; font-size: 12.5px; color: var(--accent); }
details.liberar form { display: grid; gap: 4px; margin-top: 4px; min-width: 220px; }
details.volver-pendiente > summary { cursor: pointer; font-weight: 600; color: var(--accent); }

/* ── Barra de acciones compacta (una línea; menús que abren hacia arriba) ── */
.barra-lote.compacta { flex-wrap: nowrap; align-items: center; gap: 8px; padding: 8px 20px; overflow-x: auto; overflow-y: visible; }
.barra-lote.compacta .cuenta { padding-right: 12px; border-right: 1px solid var(--line); white-space: nowrap; }
.barra-lote.compacta .quitar { margin-left: auto; white-space: nowrap; }
.menu-lote { position: relative; }
.menu-lote > summary { list-style: none; cursor: pointer; user-select: none; }
.menu-lote > summary::-webkit-details-marker { display: none; }
.menu-lote[open] > summary { box-shadow: 0 0 0 2px var(--accent-bg); }
.panel-menu { position: fixed; bottom: 58px; min-width: 220px; max-height: 60vh; overflow-y: auto; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  padding: 8px; display: grid; gap: 6px; }
.panel-menu.ancho { min-width: 280px; }
.panel-menu .titulo-menu { margin: 4px 4px 0; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.panel-menu label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.panel-menu label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.item-menu { background: none; border: 0; color: var(--text); text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.item-menu:hover, .item-menu:focus-visible { background: var(--accent-bg); color: var(--accent); }

/* ── Despacho (ENDOFI) y observaciones (OBDO) ─────────── */
.obs-nvv { background: var(--warn-bg); color: var(--text); border: 1px solid #f59e0b; border-left-width: 4px; border-radius: 8px;
  padding: 9px 12px; margin: 10px 0 14px; white-space: pre-line; }
.obs-nvv .obs-rotulo { display: block; font-size: 11.5px; font-weight: 650; color: var(--warn); text-transform: uppercase; letter-spacing: .03em; }
.obs { color: var(--warn); font-size: 12.5px; margin-top: 2px; white-space: pre-line; }
.obs::before { content: "Obs.: "; font-weight: 650; }
.destino { font-size: 12.5px; margin-top: 2px; }
.destino::before { content: "Despachar a: "; color: var(--muted); }
.panel.despacho-distinto { border-color: var(--ok); }
.entrega .obs { font-size: 14px; margin: 6px 0; padding: 6px 8px; border-radius: 6px; background: var(--warn-bg); }

.form-despacho { display: grid; gap: 6px; margin-top: 8px; }
.form-despacho label.check { display: flex; gap: 6px; align-items: center; }
.form-despacho .sub-opcion { display: flex; gap: 6px; flex-wrap: wrap; padding-left: 22px; }
.form-despacho .sub-opcion select { flex: 1 1 140px; min-width: 0; max-width: 100%; }
/* Listas de vehículos y choferes: no deben estirar paneles ni barras (las opciones van agrupadas por empresa). */
.panel-menu select, .panel-menu input[type=text], .barra-lote .panel-menu select { width: 100%; min-width: 0; max-width: none; }
.barra-lote select { max-width: 230px; }
.panel-menu .sub-menu { margin: 6px 4px 0; font-size: 11px; color: var(--muted); }
td.c-ruta { max-width: 170px; }
input[name="patente"] { text-transform: uppercase; }

/* ── Orden y filtros por columna (static/tabla.js) ───── */
.th-col { display: inline-flex; align-items: center; gap: 2px; }
.th-orden, .th-filtro { background: none; border: 0; padding: 2px 3px; color: inherit; font: inherit; text-transform: inherit;
  letter-spacing: inherit; cursor: pointer; border-radius: 4px; min-height: 0; }
.th-orden:hover, .th-filtro:hover { color: var(--accent); background: var(--accent-bg); }
.th-filtro { opacity: .45; line-height: 0; }
th:hover .th-filtro, th.filtrada .th-filtro { opacity: 1; }
th.filtrada .th-filtro { color: var(--accent); }
th.ordenada .th-orden { color: var(--accent); }
th[data-dir="▲"] .th-orden::after { content: " ▲"; } th[data-dir="▼"] .th-orden::after { content: " ▼"; }
th.n .th-col { justify-content: flex-end; width: 100%; }
.tabla-herramientas { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: -4px 0 10px; }
.tabla-herramientas[hidden], .tabla-herramientas [hidden] { display: none; }
.tabla-herramientas .resumen { color: var(--muted); }
.solo-movil { display: none; }
.panel-filtro { position: fixed; z-index: 40; width: 280px; max-height: 70vh; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 10px; display: grid; gap: 8px;
  top: 120px; left: 50%; }
.panel-filtro .titulo-menu { margin: 0; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.panel-filtro .fila-orden { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.panel-filtro .valores { display: grid; gap: 2px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 7px; padding: 6px; }
.panel-filtro label.check { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.panel-filtro label.check[hidden] { display: none; }
.panel-filtro label.check span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-filtro .rango { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.panel-filtro .rango label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.panel-filtro .rango input { width: 100%; }

/* ══ Celular ═══════════════════════════════════════════════════════════════
   Menú plegable, tablas como tarjetas, controles grandes para el dedo (16px evita el zoom de iOS)
   y la barra de acciones en lote abajo, respetando la zona segura del teléfono. */
.menu-btn, .txt-corto { display: none; }
.filtrable { -webkit-touch-callout: none; }
.cant-grupo { display: inline-flex; gap: 6px; align-items: center; }
@media (max-width: 760px) {
  body { font-size: 15px; }
  header.top { position: sticky; top: 0; z-index: 30; gap: 0; padding: env(safe-area-inset-top) 12px 0; min-height: 52px; }
  header.top .marca { flex: 1; padding: 14px 0; }
  .menu-btn { display: inline-flex; gap: 6px; align-items: center; background: none; border: 1px solid #334155; color: #fff;
    font-size: 20px; line-height: 1; padding: 6px 12px; min-height: 40px; }
  header.top nav, header.top .yo { display: none; }
  header.top.abierto nav { display: flex; flex-direction: column; width: 100%; padding: 4px 0 6px; border-top: 1px solid #1e293b; }
  header.top.abierto nav a { padding: 12px 10px; border-bottom: 0; border-left: 3px solid transparent; font-size: 16px; }
  header.top.abierto nav a.activo { border-left-color: #60a5fa; background: #1e293b; }
  header.top.abierto .yo { display: block; width: 100%; margin: 0; padding: 12px 10px 14px; border-top: 1px solid #1e293b; font-size: 15px; }
  header.top.abierto .yo button.link { font-size: 15px; }
  main { padding: 12px 12px 170px; }
  h1 { font-size: 19px; }
  h2 { font-size: 15.5px; }

  input[type=text], input[type=search], input[type=password], input[type=date], input[type=number], select, textarea {
    font-size: 16px; padding: 9px 10px; min-height: 42px; }
  button, .boton { padding: 9px 14px; min-height: 42px; }
  button.mini, .boton.mini { padding: 6px 10px; min-height: 34px; }
  button.link { min-height: 0; }
  input[type=checkbox] { width: 22px; height: 22px; }
  .acciones, .acciones form { flex-direction: column; align-items: stretch; }
  .acciones input, .acciones select, .acciones button, .acciones .boton { width: 100%; min-width: 0 !important; text-align: center; }
  .acciones a.small { text-align: center; padding: 6px; }
  .kv { grid-template-columns: 96px 1fr; gap: 3px 10px; }
  .kv dd { overflow-wrap: anywhere; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .panel { padding: 12px; overflow-x: auto; }
  .ayuda { font-size: 13.5px; }
  .encabezado > form { width: 100%; }
  .encabezado > form:not(.filtros) > button, .encabezado > .boton { width: 100%; text-align: center; }

  .filtros { padding: 10px; gap: 8px; }
  .filtros input[type=search], .filtros input[type=text] { min-width: 0; width: 100%; flex: 1 1 100%; }
  .filtros label { flex: 1 1 40%; }
  .filtros label select { width: 100%; }
  .filtros .pista { display: none; }
  .filtros.sin-borde { flex-wrap: nowrap; }
  .filtros.sin-borde input[type=search] { flex: 1 1 auto; }
  .flujo { margin: 0 -12px 10px; padding: 0 12px 4px; scrollbar-width: none; }
  .flujo .paso { flex: 0 0 auto; padding: 7px 12px; }
  .flujo .paso .n { font-size: 18px; }
  details.grupo > summary { padding: 10px 12px; gap: 4px 10px; }
  details.grupo .meta { font-size: 12.5px; }
  details.grupo .acciones-grupo { margin-left: 0; width: 100%; flex-wrap: wrap; }
  tbody tr:hover td { background: none; }

  /* Tablas genéricas como tarjetas: «rótulo … valor» por fila */
  table.tarjetas, table.tarjetas tbody { display: block; width: 100%; background: none; }
  table.tarjetas thead { display: none; }
  table.tarjetas tr { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
  details.grupo table.tarjetas tr, .panel table.tarjetas tr, .credito-nvv table.tarjetas tr {
    border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin: 0; }
  table.tarjetas td { display: flex; flex-wrap: wrap; gap: 4px 8px; justify-content: flex-end; align-items: baseline;
    padding: 3px 0; border: 0; text-align: right; }
  table.tarjetas td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; margin-right: auto; }
  table.tarjetas.dos-col tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  table.tarjetas.dos-col td:last-child { grid-column: 1 / -1; }
  table.tarjetas td.vacia, table.tarjetas td.chk::before, table.tarjetas td[colspan]::before { display: none; }
  table.tarjetas td.chk { width: auto; justify-content: flex-start; }
  details.liberar form { min-width: 0; }

  /* Líneas de la NVV (picking): el producto primero y la cantidad grande */
  table.lineas tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  table.lineas td.c-pick { order: 1; grid-column: 1 / -1; align-items: center; padding-top: 6px; }
  table.lineas td.c-ubic { order: -1; grid-column: 1 / -1; }
  table.lineas td.c-prod { order: -2; grid-column: 1 / -1; font-weight: 600; font-size: 15.5px; text-align: left; justify-content: flex-start; }
  table.lineas td.c-prod::before { display: none; }
  table.lineas input.cant { width: 110px; }
  table.lineas button.llenar { min-height: 42px; }
  .guardar-picking { position: sticky; bottom: 0; z-index: 5; margin: 0; padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
  .guardar-picking button { width: 100%; font-size: 16px; }

  /* Bandeja: cada NVV es una tarjeta (NVV y estado arriba, cliente, y los datos en una línea) */
  table.bandeja, table.bandeja tbody { display: block; background: none; }
  table.bandeja thead { display: none; }
  table.bandeja tr { display: flex; flex-wrap: wrap; align-items: baseline; position: relative; gap: 2px 12px;
    padding: 10px 12px 10px 48px; border-bottom: 1px solid var(--line); background: var(--panel); }
  table.bandeja tr.alerta { background: var(--warn-bg); }
  table.bandeja td { padding: 0; border: 0; background: none !important; text-align: left; }
  table.bandeja td.c-chk { position: absolute; left: 12px; top: 10px; width: auto; }
  table.bandeja td.c-nvv { order: 1; flex: 1; display: flex; gap: 8px; align-items: center; }
  table.bandeja td.c-nvv .nudo { font-size: 16px; }
  table.bandeja td.c-estado { order: 2; text-align: right; max-width: 60%; }
  table.bandeja td.c-cli { order: 3; flex: 1 1 100%; font-weight: 550; margin-top: 2px; }
  table.bandeja td.c-cli .small, table.bandeja td.c-cli .destino { font-weight: 400; }
  table.bandeja td.c-fecha, table.bandeja td.c-lin, table.bandeja td.c-uni, table.bandeja td.c-bruto,
  table.bandeja td.c-vend, table.bandeja td.c-ruta { order: 4; font-size: 13px; color: var(--muted); }
  table.bandeja td.c-resp { order: 5; flex: 1 1 100%; font-size: 13px; }
  table.bandeja td.c-lin::after { content: " líneas"; }
  table.bandeja td.c-uni::after { content: " unid."; }
  table.bandeja td.c-bruto::before { content: "$ "; }
  table.bandeja td.c-vend::before { content: "Vend. "; }
  table.bandeja td.c-ruta { order: 5; flex: 1 1 100%; font-size: 13px; color: var(--text); }
  table.bandeja td.c-ruta::before { content: "Despacho: "; color: var(--muted); }
  table.bandeja td.c-resp::before { content: "Picking: "; color: var(--muted); }
  table.bandeja td.vacia { display: none; }

  /* Barra de acciones en lote */
  .txt-largo { display: none; }
  .txt-corto { display: inline; }
  .barra-lote { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); max-height: 60vh; overflow-y: auto; }
  .barra-lote .accion { border-left: 0; padding-left: 0; width: 100%; }
  .barra-lote .accion label { flex: 1 1 40%; }
  /* Compacta en dos filas: cantidad y ✕ arriba; las acciones abajo, del mismo ancho */
  .barra-lote.compacta { flex-wrap: wrap; padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); gap: 4px 6px;
    max-height: none; overflow: visible; }
  .barra-lote.compacta .cuenta { border-right: 0; padding: 0 2px; font-size: 14px; }
  .barra-lote.compacta .quitar { order: 1; font-size: 13px; text-decoration: none; padding: 2px 6px; }
  .barra-lote.compacta::after { content: ""; order: 2; flex-basis: 100%; height: 0; }
  .barra-lote.compacta .menu-lote { order: 3; flex: 1 1 0; min-width: 0; }
  .barra-lote.compacta .menu-lote > summary { display: block; width: 100%; text-align: center; padding: 10px 2px; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; }
  .panel-menu { left: 10px !important; right: 10px; bottom: calc(96px + env(safe-area-inset-bottom)); min-width: 0; max-height: 55vh; }
  .panel-menu.ancho { min-width: 0; }
  .item-menu { padding: 12px; font-size: 16px; }

  /* Orden y filtros: botón propio (no hay títulos en las tarjetas) y panel abajo, a todo el ancho */
  .solo-movil { display: inline-block; }
  .tabla-herramientas { margin: 0 0 10px; }
  .panel-filtro { left: 10px !important; right: 10px; width: auto; top: auto !important; bottom: calc(10px + env(safe-area-inset-bottom)); max-height: 75vh; }
  .panel-filtro .valores { max-height: 40vh; }
  .panel-filtro label.check { font-size: 15px; padding: 4px 0; }

  /* Entregas (chofer) y login */
  .entrega > .boton { display: block; text-align: center; }
  .login { margin: 30px auto; }
}

/* Inicio por módulos (D34) */
.modulos { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.modulo-tarjeta { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--sombra); }
.modulo-tarjeta .modulo-titulo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 650; color: inherit; text-decoration: none; }
.modulo-tarjeta .modulo-icono { font-size: 22px; }
.modulo-tarjeta ul { margin: 6px 0 0; padding-left: 18px; }
.modulo-tarjeta li { padding: 3px 0; }
.modulo-tarjeta.proximamente { opacity: .6; border-style: dashed; }
fieldset.permisos-modulo { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 6px 12px 10px; }
fieldset.permisos-modulo legend { font-weight: 600; padding: 0 4px; }
.permisos-func { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; padding: 3px 0; }
.permisos-func > span { min-width: 150px; }
@media (max-width: 760px) {
  header.top .modulo-actual { margin-right: 8px; }
  header.top .marca span { display: none; }
  .permisos-func > span { width: 100%; }
}

/* Cobranza: semáforo del cliente (docs/ESPEC_COBRANZA.md §3.3) */
.chip.sem-verde { background: var(--ok-bg); color: var(--ok); }
.chip.sem-amarillo { background: var(--warn-bg); color: var(--warn); }
.chip.sem-rojo { background: var(--err-bg); color: var(--err); }
tr.partida-favor td { color: var(--ok); }
#tabla-cartera td:first-child { min-width: 210px; }
#tabla-cartera th, #tabla-cartera td.n { white-space: nowrap; }
