:root {
  --fondo: #f4f3ef;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --borde: #e4e1d8;
  --texto: #1d211f;
  --suave: #67706b;
  --marca: #1f6f5c;
  --marca-2: #e6f1ed;
  --ok: #217a4b;
  --ok-2: #e3f3e9;
  --alerta: #a5620b;
  --alerta-2: #fbf0dc;
  --mal: #b3261e;
  --mal-2: #fbe7e5;
  --info: #2457a6;
  --info-2: #e5edf9;
  --radio: 12px;
  --sombra: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fondo); color: var(--texto);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- estructura */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.app > *, #nav, .ped > div { min-width: 0; }
.ped .meta { overflow-wrap: anywhere; }
.lateral {
  position: sticky; top: 0; height: 100vh; background: #17211d; color: #dfe7e3;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.marca { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.marca img { width: 34px; height: 34px; }
.marca b { display: block; color: #fff; font-size: 16px; }
.marca span { font-size: 12px; color: #9fb2aa; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  padding: 9px 12px; border-radius: 8px; cursor: pointer; color: #c9d6d0; text-decoration: none;
  transition: background .15s, color .15s;
}
#nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#nav a.activo { background: var(--marca); color: #fff; }
.pie-lateral { margin-top: auto; font-size: 12px; color: #8ea39a; padding: 8px; }
.vista { padding: 24px 32px 60px; width: 100%; outline: none; }

/* ---------- vistas con lista larga (Productos, Clientes): arriba fijo, solo se desliza la lista */
.vista.fija { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding-bottom: 16px; }
.vista.fija > .cabeza, .vista.fija > .buscar-barra { flex: none; }
.vista.fija > .tabla-caja { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.vista.fija thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--borde); }
.buscar-barra .ayuda { align-self: center; }

/* ---------- títulos y barras */
.cabeza { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.cabeza h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.cabeza .sub { color: var(--suave); font-size: 13px; }
.cabeza .acciones { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
h2 { font-size: 15px; margin: 0 0 10px; }
.explica { color: var(--suave); font-size: 13px; margin: -6px 0 14px; max-width: 760px; }

/* ---------- botones */
.btn {
  border: 1px solid var(--borde); background: var(--panel); border-radius: 9px; padding: 8px 14px;
  cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--panel-2); border-color: #cfcabd; }
.btn:active { transform: scale(.98); }
.btn.pri { background: var(--marca); border-color: var(--marca); color: #fff; }
.btn.pri:hover { background: #185a4a; }
.btn.peligro { color: var(--mal); }
.btn.peligro:hover { background: var(--mal-2); border-color: #f0c4bf; }
.btn.chico { padding: 4px 9px; font-size: 13px; border-radius: 7px; }
.btn.fantasma { background: transparent; border-color: transparent; }
.btn.fantasma:hover { background: rgba(0, 0, 0, .04); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- tarjetas */
.grilla { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); min-width: 0; }
.dato .et { color: var(--suave); font-size: 13px; }
.dato .val { font-size: 24px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.dato .mini { color: var(--suave); font-size: 12px; margin-top: 2px; }
.dato.destacado { background: var(--marca); color: #fff; border-color: var(--marca); }
.dato.destacado .et, .dato.destacado .mini { color: #cfe6de; }
.lista-simple { list-style: none; margin: 0; padding: 0; }
.lista-simple li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--borde); }
.lista-simple li:first-child { border-top: 0; }
.lista-simple .num { font-weight: 600; }
.fila-total { font-weight: 700; }
.separa { margin-top: 18px; }

/* ---------- avisos en página */
.cartel { border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cartel.alerta { background: var(--alerta-2); color: #6b3f05; }
.cartel.info { background: var(--info-2); color: #193f78; }
.cartel.ok { background: var(--ok-2); color: #155433; }

/* ---------- etiquetas de estado */
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.chip.Pendiente { background: var(--mal-2); color: var(--mal); }
.chip.En.curso, .chip.curso { background: var(--alerta-2); color: var(--alerta); }
.chip.Terminado { background: var(--ok-2); color: var(--ok); }
.chip.Entregado { background: #ecebe6; color: #5b605c; }
.chip.debe { background: var(--mal-2); color: var(--mal); }
.chip.pagado { background: var(--ok-2); color: var(--ok); }
.chip.gris { background: #ecebe6; color: #5b605c; }

.chip.boton { border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; transition: filter .15s, box-shadow .15s; }
.chip.boton:hover { filter: brightness(.96); box-shadow: 0 0 0 2px rgba(0, 0, 0, .06); }
.panel-nuevo { margin-top: 10px; border-color: var(--marca); background: #fbfdfc; }
.campo input:disabled, .campo select:disabled, .campo textarea:disabled { background: var(--panel-2); color: var(--texto); opacity: 1; cursor: default; border-color: transparent; }

/* ---------- tablas */
.tabla-caja { overflow-x: auto; background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-top: 1px solid var(--borde); vertical-align: middle; }
thead th { border-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); background: var(--panel-2); font-weight: 600; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #fbfaf7; }
td .sub { display: block; color: var(--suave); font-size: 12px; }
.vacio { color: var(--suave); text-align: center; padding: 28px 12px; }

/* ---------- pedidos */
.lista-pedidos { display: grid; gap: 10px; }
.ped {
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, min(460px, 42%)) auto; gap: 24px; align-items: center;
  cursor: pointer; box-shadow: var(--sombra); transition: border-color .15s;
}
.ped:hover { border-color: #cfc9bb; }
.ped .titulo { font-weight: 700; }
.ped .meta { color: var(--suave); font-size: 13px; }
.ped .plata { text-align: right; }
.barra { height: 8px; border-radius: 99px; background: #ecebe6; overflow: hidden; }
.barra > i { display: block; height: 100%; background: var(--marca); border-radius: 99px; transition: width .25s ease-out; }
.barra-texto { font-size: 12px; color: var(--suave); margin-top: 4px; }

.items td { padding: 7px 10px; }
.contador { display: inline-flex; align-items: center; gap: 4px; }
.contador input { width: 64px; text-align: center; padding: 5px 4px; border: 1px solid var(--borde); border-radius: 7px; font-variant-numeric: tabular-nums; }
.contador button { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--borde); background: var(--panel); cursor: pointer; font-weight: 700; }
.contador button:hover { background: var(--panel-2); }
.contador .listo { width: auto; padding: 0 8px; font-size: 12px; color: var(--ok); }
tr.hecho td { background: #f6fbf8; }
tr.hecho .nom { color: var(--ok); }

/* ---------- formularios */
.form { display: grid; gap: 12px; }
.form .fila { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
label.campo { display: grid; gap: 4px; font-size: 13px; color: var(--suave); font-weight: 600; }
.campo input, .campo select, .campo textarea, .entrada {
  width: 100%; padding: 9px 11px; border: 1px solid var(--borde); border-radius: 9px; background: #fff; color: var(--texto); font-weight: 400;
}
.campo textarea { min-height: 64px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .entrada:focus, .contador input:focus {
  outline: 2px solid rgba(31, 111, 92, .35); outline-offset: 0; border-color: var(--marca);
}
.ayuda { font-size: 12px; color: var(--suave); font-weight: 400; }
.opciones { display: flex; gap: 6px; flex-wrap: wrap; }
.opciones button { border: 1px solid var(--borde); background: #fff; padding: 7px 12px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 13px; }
.opciones button.sel { background: var(--marca); color: #fff; border-color: var(--marca); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--texto); font-weight: 400; }
.buscar-barra { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; }
.filtros > .opciones + .opciones { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--borde); }
.opciones button .cuenta { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 99px; background: #ecebe6; color: var(--suave); font-size: 11px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.opciones button.sel .cuenta { background: rgba(255, 255, 255, .22); color: #fff; }
.acciones-tabla { display: flex; gap: 8px; flex-wrap: wrap; }
.entregado-check { align-self: end; padding-bottom: 10px; font-weight: 600; }
.entregado-check input { width: 18px; height: 18px; accent-color: var(--marca); }
.sin-guardar { align-self: center; font-size: 13px; font-weight: 600; color: var(--alerta); margin-right: 4px; }
.buscar-barra .entrada { max-width: 340px; }

/* ---------- buscador (sugerencias) */
.buscador { position: relative; }
.sugerencias {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--borde);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .12); max-height: 320px; overflow-y: auto; padding: 4px;
}
.sugerencias div { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.sugerencias div .sub { color: var(--suave); font-size: 12px; }
.sugerencias div.act, .sugerencias div:hover { background: var(--marca-2); }
.sugerencias .nuevo { color: var(--marca); font-weight: 600; }

/* ---------- modal */
.capa-modal { position: fixed; inset: 0; background: rgba(15, 22, 19, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto; }
.capa-modal[hidden] { display: none; }
.modal { background: var(--panel); border-radius: 16px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: entra .18s ease-out; }
.modal.ancho { max-width: 980px; }
@keyframes entra { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--borde); }
.modal header h3 { margin: 0; font-size: 17px; }
.modal header .cerrar { margin-left: auto; }
.modal .cuerpo { padding: 18px 20px; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--borde); background: var(--panel-2); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.modal footer .izq { margin-right: auto; display: flex; gap: 8px; }

/* ---------- avisos flotantes */
.avisos { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 8px; }
.aviso { background: #17211d; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 380px; animation: entra .18s ease-out; font-size: 14px; }
.aviso.error { background: var(--mal); }

/* ---------- historial */
details.mes { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); margin-bottom: 10px; box-shadow: var(--sombra); }
details.mes > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: grid; grid-template-columns: 1.3fr repeat(4, minmax(0, 1fr)) 24px; gap: 10px; align-items: center; }
details.mes > summary::-webkit-details-marker { display: none; }
details.mes > summary::after { content: "▸"; color: var(--suave); transition: transform .15s; justify-self: end; }
details.mes[open] > summary::after { transform: rotate(90deg); }
details.mes .et { font-size: 12px; color: var(--suave); display: block; }
details.mes .contenido { padding: 0 16px 16px; border-top: 1px solid var(--borde); }
details.mes .contenido h4 { margin: 16px 0 8px; font-size: 14px; }
details.sub-ped { border-top: 1px solid var(--borde); }
details.sub-ped summary { cursor: pointer; padding: 8px 4px; }

/* ---------- celular */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .buscar-barra .entrada { max-width: none; flex: 1 1 200px; }
  .lateral { position: sticky; top: 0; height: auto; z-index: 20; padding: 8px 10px; flex-direction: row; align-items: center; gap: 8px; }
  .marca { padding: 0; }
  .marca div, .pie-lateral { display: none; }
  #nav { flex-direction: row; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  #nav a { white-space: nowrap; padding: 7px 10px; font-size: 14px; }
  .vista { padding: 16px 16px 60px; }
  .vista.fija { height: calc(100dvh - var(--alto-menu, 56px)); padding-bottom: 8px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .ped { grid-template-columns: 1fr; gap: 8px; }
  .ped .plata { text-align: left; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  details.mes > summary { grid-template-columns: 1fr 1fr; }
  .capa-modal { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .modal footer { border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Socios: reparto en el momento y retiros de más (20/11/2026) */
.debe-devolver .num, .socio-debe .dato .val { color: var(--mal); font-weight: 700; }
.socio-debe { border-color: var(--mal-2); }
.lista-simple .sub-fila { font-size: 12.5px; color: var(--suave); padding-top: 0; }

/* Bolsas: Empresa / socios, préstamos y gasto que no alcanza (20/11/2026) */
.empresa-tarjeta { background: linear-gradient(180deg, var(--ok-2), var(--panel) 60%); }
.lista-simple .a-favor .num, .lista-simple .a-favor span:first-child { color: var(--ok); font-weight: 700; }
.como-funciona { margin: 0; padding-left: 18px; font-size: 14px; display: grid; gap: 6px; }
.faltante { display: grid; gap: 10px; }
.faltante-fila { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) 130px; gap: 8px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; }
.faltante-fila .ayuda { display: block; }
.faltante-fila [data-nota] { grid-column: 1 / -1; margin: 0; }
.faltante-fila [data-nota]:empty { display: none; }
@media (max-width: 860px) { .faltante-fila { grid-template-columns: 1fr; } }

/* Tarjeta: compras agrupadas por resumen (20/11/2026) */
tr.grupo-resumen td { background: var(--panel-2); font-weight: 700; font-size: 13px; color: var(--suave); text-transform: uppercase; letter-spacing: .03em; padding-top: 10px; }

/* Filas de productos con buscador propio (21/11/2026) */
.sugerencias.flotante { position: fixed; right: auto; z-index: 75; }
.td-prod { min-width: 240px; }
.celda-prod .celda-prod-pie { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 0; }
.celda-prod .celda-prod-pie:has(> span:empty):has(> button[hidden]) { display: none; }
.celda-prod .celda-prod-pie .sub { margin: 0; }
.btn.enlace { border: 0; background: none; padding: 2px 0; color: var(--marca); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; box-shadow: none; }
.btn.enlace:hover { background: none; filter: brightness(.9); }

/* ---------- entrada con contraseña (solo en internet, 25/11/2026) */
body.con-login .app { display: none; }
.pantalla-login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, #23362f 0%, #17211d 60%); }
.login-caja { width: 100%; max-width: 380px; background: var(--panel); border-radius: 18px; padding: 26px 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); display: grid; gap: 14px; animation: entra .2s ease-out; }
.login-caja h1 { margin: 4px 0 0; font-size: 20px; }
.login-caja .ayuda { margin: -6px 0 0; font-size: 13px; }
.login-marca { display: flex; gap: 10px; align-items: center; }
.login-marca img { width: 40px; height: 40px; }
.login-marca b { display: block; font-size: 17px; }
.login-marca span { font-size: 12px; color: var(--suave); }
.login-caja input { font-size: 16px; padding: 11px 12px; }
.btn.grande { justify-content: center; padding: 12px 16px; font-size: 15px; min-height: 46px; }
.login-error { margin: 0; color: var(--mal); background: var(--mal-2); border-radius: 9px; padding: 9px 12px; font-size: 14px; }

/* ---------- celular: todo cómodo con el dedo (25/11/2026) */
@media (max-width: 860px) {
  body { -webkit-text-size-adjust: 100%; }
  .lateral { padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
  .marca img { width: 30px; height: 30px; }
  #nav a { padding: 10px 12px; min-height: 40px; display: inline-flex; align-items: center; }
  .btn { min-height: 42px; padding: 9px 14px; }
  .btn.chico { min-height: 40px; padding: 7px 12px; font-size: 14px; }
  .btn.fantasma.chico { min-width: 40px; justify-content: center; }
  .btn.enlace { min-height: 32px; }
  .opciones button { min-height: 40px; padding: 8px 14px; font-size: 14px; }
  .campo input, .campo select, .campo textarea, .entrada, .contador input { font-size: 16px; min-height: 44px; } /* 16 px: iOS no hace zoom */
  .cabeza h1 { font-size: 20px; }
  .cabeza .acciones { margin-left: 0; width: 100%; }
  .cabeza .acciones .btn { flex: 1 1 auto; justify-content: center; }
  .dato .val { font-size: 21px; }
  .avisos { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .aviso { max-width: none; }
  .filtros { gap: 6px; }
  .filtros > .opciones + .opciones { margin-left: 0; padding-left: 0; border-left: 0; }
  .buscar-barra > .entrada { flex-basis: 100%; }
  th, td { padding: 9px 10px; }
  .vista.fija > .tabla-caja { -webkit-overflow-scrolling: touch; }
  /* ventanas: pantalla completa, título arriba y botones fijos abajo */
  #capa-modal .modal { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; max-width: none; }
  #capa-modal .modal .cuerpo { flex: 1 1 auto; padding: 16px; }
  #capa-modal .modal header { position: sticky; top: 0; z-index: 5; background: var(--panel); padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
  #capa-modal .modal header h3 { font-size: 16px; line-height: 1.3; }
  #capa-modal .modal header .cerrar { min-width: 44px; min-height: 44px; font-size: 18px; }
  #capa-modal .modal footer { position: sticky; bottom: 0; z-index: 5; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); box-shadow: 0 -6px 16px rgba(0, 0, 0, .06); }
  #capa-modal .modal footer .btn { flex: 1 1 auto; justify-content: center; }
  #capa-modal .modal footer .izq { margin-right: 0; flex: 1 1 100%; order: 3; }
  #capa-modal .modal footer .izq .btn { flex: 1 1 auto; }
  #capa-modal .modal footer .sin-guardar { flex: 1 1 100%; text-align: center; }
  /* carteles chicos (confirmar, motivo, faltante): centrados, no a pantalla completa */
  body > .capa-modal:not(#capa-modal) { padding: 16px; align-items: center; }
  body > .capa-modal:not(#capa-modal) .modal { min-height: 0; border-radius: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; }
  body > .capa-modal:not(#capa-modal) .modal footer { border-radius: 0 0 16px 16px; }
  body > .capa-modal:not(#capa-modal) .modal footer .btn { flex: 1 1 auto; justify-content: center; }
  .contador button { width: 40px; height: 40px; font-size: 18px; }
  .chip.boton { min-height: 40px; padding: 6px 12px; display: inline-flex; align-items: center; font-size: 13px; }
  .contador .listo { padding: 0 12px; }
  details.mes > summary { padding: 12px; }
  .grilla.g4 .dato .val { font-size: 19px; }
}

/* ---------- celular: las filas de productos del pedido pasan a tarjetas apiladas */
@media (max-width: 640px) {
  table.items, table.items tbody, table.items tfoot { display: block; }
  table.items thead { display: none; }
  table.items tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; padding: 14px 12px; border-top: 1px solid var(--borde); position: relative; }
  table.items tbody tr:first-child { border-top: 0; }
  table.items td { display: block; border: 0; padding: 0; min-width: 0; }
  table.items td.td-prod, table.items td.nom { grid-column: 1 / -1; padding-right: 46px; min-width: 0; }
  table.items td.td-col, table.items td.td-hechos { grid-column: 1 / -1; }
  table.items td.td-cant { order: 1; } table.items td.td-precio { order: 2; } table.items td.td-hechos { order: 3; }
  table.items td.td-col { order: 4; }
  table.items tbody td.td-sub { order: 5; grid-column: 1 / -1; text-align: right; padding-bottom: 0; }
  table.items tbody td.td-sub::before { display: inline; margin-right: 8px; }
  table.items td.num { text-align: left; }
  table.items td[data-et]::before { content: attr(data-et); display: block; font-size: 12px; font-weight: 600; color: var(--suave); margin-bottom: 4px; }
  table.items td.td-sub { align-self: end; font-weight: 700; font-size: 16px; padding-bottom: 10px; }
  table.items td.td-quitar { position: absolute; top: 10px; right: 6px; }
  table.items input.entrada { width: 100% !important; text-align: left !important; }
  table.items .contador { display: flex; width: 100%; gap: 6px; }
  table.items .contador input { flex: 1 1 auto; width: auto; }
  table.items td.vacio { grid-column: 1 / -1; }
  table.items tbody tr:has(> td.vacio) { display: block; }
  table.items tfoot tr { display: block; padding: 12px; border-top: 1px solid var(--borde); }
  table.items tfoot td { display: block; border: 0; padding: 0; }
  table.items tfoot td:empty { display: none; }
  table.items tfoot td.num { text-align: right; font-size: 16px; margin-top: 8px; }
  table.items tfoot .acciones-tabla > b { display: none; }
  table.items tfoot td.num::before { content: "Total "; font-weight: 700; }
  .acciones-tabla .btn { flex: 1 1 auto; justify-content: center; }
  .acciones-tabla .ayuda { flex: 1 1 100%; }
  .td-prod { min-width: 0; }
  .tabla-caja:has(table.items) { overflow: visible; }
  .faltante-fila select, .faltante-fila input { width: 100%; }
  .ped { padding: 12px 14px; }
}

/* ---------- celular: el resto de las tablas pasan a renglones apilados (Columna … valor) */
@media (max-width: 640px) {
  table.apilable thead { display: none; }
  table.apilable, table.apilable tbody, table.apilable tfoot, table.apilable tr, table.apilable td { display: block; }
  table.apilable tbody tr, table.apilable tfoot tr { padding: 10px 14px; border-top: 1px solid var(--borde); }
  table.apilable tbody tr:first-child { border-top: 0; }
  table.apilable td { border: 0; padding: 3px 0; text-align: right; white-space: normal; overflow-wrap: anywhere; }
  table.apilable td::after { content: ""; display: block; clear: both; }
  table.apilable td[data-et]::before { content: attr(data-et); float: left; margin-right: 12px; font-size: 12px; font-weight: 600; color: var(--suave); text-transform: uppercase; letter-spacing: .03em; padding-top: 2px; }
  table.apilable td:first-child { text-align: left; font-weight: 600; font-size: 15px; padding-bottom: 4px; }
  table.apilable td:first-child[data-et]::before { display: none; }
  table.apilable td:not([data-et]):not(.ancha):not(:first-child) { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; padding-top: 6px; }
  table.apilable td.ancha { text-align: left; }
  table.apilable td.vacio { text-align: center; }
  table.apilable td:empty { display: none; }
  .vista.fija > .tabla-caja table.apilable thead th { position: static; }
}
