:root {
  /* Paleta de la propuesta: morado profundo, magenta y coral. */
  --fondo: #f5f3f9;
  --superficie: #ffffff;
  --superficie-2: #f9f7fc;
  --borde: #e3deec;
  --texto: #1f1a2b;
  --texto-2: #625b70;
  --primario: #4a1489;
  --primario-2: #36106a;
  --primario-suave: #efe8f8;
  --magenta: #9b1466;
  --coral: #ff7a85;
  --foco: #ff7a85;

  --ok: #1f7a46;      --ok-fondo: #e3f3e8;
  --faltan: #9a5b00;  --faltan-fondo: #fdf0d9;
  --sobran: #1f5ea8;  --sobran-fondo: #e3edf9;
  --ausente: #b42318; --ausente-fondo: #fde7e5;
  --extra: #9b1466;   --extra-fondo: #fbe6f0;

  --radio: 10px;
  --sombra: 0 1px 2px rgba(40, 20, 70, .06), 0 2px 8px rgba(40, 20, 70, .05);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texto);
  font-size: 15px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); min-height: 100vh; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primario); }
small, .tenue { color: var(--texto-2); }
.mono { font-family: var(--mono); font-size: .9em; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.barra {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: linear-gradient(100deg, var(--primario) 0%, var(--primario) 62%, #6c1680 82%, var(--magenta) 100%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.marca { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.marca strong { display: block; font-size: .98rem; }
.marca small { color: var(--coral); font-size: .76rem; font-weight: 600; letter-spacing: .02em; }
.logo { width: 30px; height: 30px; flex-shrink: 0; }
.pestanas { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.pestanas::-webkit-scrollbar { display: none; }
.pestanas a {
  color: #e6dbf6; text-decoration: none; white-space: nowrap;
  padding: 8px 12px; border-radius: 8px; font-size: .92rem; font-weight: 500;
}
.pestanas a:hover { background: rgba(255,255,255,.08); color: #fff; }
.pestanas a.activa { background: #fff; color: var(--primario-2); }

.aviso {
  max-width: 1240px; margin: 14px auto 0; padding: 10px 14px;
  background: var(--faltan-fondo); color: #6d4100; border: 1px solid #f1d39f; border-radius: var(--radio);
  font-size: .92rem;
}
.aviso.error { background: var(--ausente-fondo); color: #7d1a12; border-color: #f4c2bd; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 64px; outline: none; }
.encabezado { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
#vista > .tarjeta + .tarjeta, #vista > .rejilla-2 + .tarjeta, #vista > .tarjeta + .rejilla-2,
#vista > .tarjeta + #detalles, #detalles > .tarjeta { margin-top: 16px; }
.encabezado p { margin-top: 4px; color: var(--texto-2); }

/* ---------- Tarjetas y rejillas ---------- */
.tarjeta {
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 18px; box-shadow: var(--sombra);
}
.tarjeta + .tarjeta, .bloque + .bloque { margin-top: 16px; }
.tarjeta > header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rejilla-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.rejilla-2 > .tarjeta + .tarjeta { margin-top: 0; }
.pila > * + * { margin-top: 12px; }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.separador { height: 1px; background: var(--borde); margin: 14px 0; }

/* ---------- Formularios ---------- */
label.campo { display: grid; gap: 5px; font-size: .86rem; font-weight: 600; color: var(--texto-2); }
.campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
input[type=text], input[type=number], select {
  font: inherit; color: var(--texto); width: 100%;
  padding: 8px 10px; border: 1px solid #d3cce0; border-radius: 8px; background: #fff;
  min-height: 38px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .archivo:focus-within {
  outline: 3px solid var(--foco); outline-offset: 1px;
}
input[type=number] { font-variant-numeric: tabular-nums; }
.archivo {
  position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
}
.archivo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

.boton {
  font: inherit; font-weight: 600; font-size: .92rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--primario); background: var(--primario); color: #fff; text-decoration: none;
}
.boton:hover { background: var(--primario-2); }
.boton.secundario { background: #fff; color: var(--primario); }
.boton.secundario:hover { background: var(--primario-suave); }
.boton.peligro { background: #fff; color: var(--ausente); border-color: #e8b4ae; }
.boton.peligro:hover { background: var(--ausente-fondo); }
.boton.chico { min-height: 30px; padding: 4px 10px; font-size: .85rem; }
.boton:disabled { opacity: .5; cursor: not-allowed; }
.boton.grande { min-height: 46px; padding: 10px 22px; font-size: 1rem; }

.opciones-modo { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.opcion {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px; background: var(--superficie-2);
}
.opcion:has(input:checked) { border-color: var(--primario); background: var(--primario-suave); box-shadow: inset 0 0 0 1px var(--primario); }
.opcion input { margin-top: 3px; accent-color: var(--primario); }
.opcion strong { display: block; font-size: .93rem; }
.opcion small { font-size: .82rem; }

/* ---------- Tablas ---------- */
.tabla-envoltura { overflow: auto; border: 1px solid var(--borde); border-radius: 8px; background: #fff; }
.tabla-envoltura.limitada { max-height: 340px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid #eeeaf4; white-space: nowrap; }
td.ajustar { white-space: normal; min-width: 160px; }
th { position: sticky; top: 0; background: var(--superficie-2); font-weight: 650; font-size: .8rem; color: var(--texto-2); text-transform: uppercase; letter-spacing: .03em; z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #faf8fd; }
tr.e-cumple td:first-child, tr.e-faltan td:first-child, tr.e-sobran td:first-child,
tr.e-ausente td:first-child, tr.e-extra td:first-child { box-shadow: inset 4px 0 0 var(--c); }
tr.e-cumple { --c: var(--ok); } tr.e-faltan { --c: var(--faltan); } tr.e-sobran { --c: var(--sobran); }
tr.e-ausente { --c: var(--ausente); } tr.e-extra { --c: var(--extra); }
tr.e-hueco td { color: var(--texto-2); font-style: italic; background: repeating-linear-gradient(-45deg, transparent 0 6px, #f5f2f9 6px 12px); }
tr.e-hueco td:first-child { box-shadow: inset 4px 0 0 #b8b3c4; }
tfoot td { font-weight: 650; background: var(--superficie-2); border-top: 1px solid var(--borde); }
table input { min-height: 32px; padding: 4px 8px; }

.etiqueta {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap;
  background: #ece8f2; color: var(--texto-2);
}
.etiqueta.cumple { background: var(--ok-fondo); color: var(--ok); }
.etiqueta.faltan { background: var(--faltan-fondo); color: var(--faltan); }
.etiqueta.sobran { background: var(--sobran-fondo); color: var(--sobran); }
.etiqueta.ausente { background: var(--ausente-fondo); color: var(--ausente); }
.etiqueta.extra { background: var(--extra-fondo); color: var(--extra); }
.desv-pos { color: var(--sobran); } .desv-neg { color: var(--ausente); }

.leyenda { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Indicadores ---------- */
.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.indicador { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px 16px; box-shadow: var(--sombra); }
.indicador small { display: block; font-size: .8rem; font-weight: 600; }
.indicador b { display: block; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.indicador span { font-size: .8rem; color: var(--texto-2); }
.indicador.bueno b { color: var(--ok); } .indicador.malo b { color: var(--ausente); } .indicador.medio b { color: var(--faltan); }

/* ---------- Foto y franjas ---------- */
.lienzo-foto { position: relative; display: block; width: 100%; max-width: 560px; margin: 0 auto; user-select: none; touch-action: none; }
.lienzo-foto img { display: block; width: 100%; border-radius: 8px; }
/* Nueva auditoría: una tarjeta por foto del lote */
.foto-lote { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; padding: 16px 0; }
.foto-lote + .foto-lote { border-top: 1px solid var(--borde); }
.franja {
  position: absolute; left: 0; right: 0;
  background: rgba(74, 20, 137, .10); border-top: 2px solid rgba(255,255,255,.95); pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(74,20,137,.9);
}
.franja:nth-child(odd of .franja) { background: rgba(255, 122, 133, .12); }
.franja .num {
  position: absolute; left: 6px; top: 4px; background: var(--primario); color: #fff;
  font-size: .78rem; font-weight: 700; border-radius: 6px; padding: 1px 7px;
}
.limite {
  position: absolute; left: 0; right: 0; height: 26px; margin-top: -13px; cursor: ns-resize; touch-action: none;
}
.limite::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 4px; background: var(--foco); box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.limite::after {
  content: ""; position: absolute; right: 8px; top: 3px; width: 34px; height: 20px; border-radius: 10px;
  background: var(--foco) url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='2.5'><path d='M8 9l4-4 4 4M8 15l4 4 4-4'/></svg>") center/14px no-repeat;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.limite:focus-visible { outline: none; }
.limite:focus-visible::before { background: #fff; box-shadow: 0 0 0 2px var(--foco); }

.resultado-foto { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; }
.detalle-bandejas { max-height: 720px; overflow: auto; }
.navegacion-cuerpos { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
/* Pestañas "Envío completo · Cuerpo 1 · Cuerpo 2 …" (Resultado y tablero del cliente) */
.pestanas-envio { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.navegacion-cuerpos .pestanas-envio { margin-bottom: 0; }
.pestanas-envio a {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--borde); background: var(--superficie);
  color: var(--texto); text-decoration: none; font-size: .87rem; font-weight: 600;
}
.pestanas-envio a:hover { border-color: var(--primario); }
.pestanas-envio a.activa { background: var(--primario); border-color: var(--primario); color: #fff; }
.envio-resumen + .envio-resumen { margin-top: 12px; }

/* ---------- Bloques planograma vs. tienda ---------- */
.bloques .vista-bloques { display: none; }
.bloques:not(:has(.selector-bloques)) .vista-bloques[data-inicial] { display: block; }
.dibujo-bloques { margin-top: 14px; }
.dibujo-bloques h3 { font-size: .92rem; margin: 0 0 6px; }
.rejilla-bloques { overflow-x: auto; }
.fila-bloques { display: flex; align-items: stretch; min-width: 560px; }
.fila-bloques + .fila-bloques, .bandeja-bloques + .bandeja-bloques { margin-top: 2px; }
.bandeja-bloques + .bandeja-bloques:has(.fila-plan) { margin-top: 10px; }
.fila-plan .cuerpo-bloques { min-height: 20px; }
.fila-plan .tramo span { font-size: .66rem; padding: 0 4px; }
.num-bandeja small { font-size: .66rem; font-weight: 500; margin-left: 3px; }
.fila-tienda .num-bandeja small { margin-left: 0; }
.num-bandeja { flex: 0 0 58px; display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 650; color: var(--texto-2); }
.cuerpo-bloques { display: flex; gap: 2px; min-height: 30px; padding-right: 2px; border-right: 2px dashed var(--borde); background: #f4f2f7; }
.cuerpo-bloques:last-child { border-right: 0; }
.encabezado-bloques .cuerpo-bloques { min-height: 0; background: none; font-size: .78rem; font-weight: 650; color: var(--texto-2); padding: 0 4px 4px; }
.tramo { border-radius: 4px; display: flex; align-items: center; justify-content: center; overflow: hidden; min-width: 2px; }
.tramo span { font-size: .72rem; font-weight: 650; color: var(--texto); background: rgba(255,255,255,.85); padding: 1px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 4px); }
.leyenda-bloques { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .82rem; }
.item-leyenda { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 2px 6px; border-radius: 6px; border: 1px solid transparent; }
.item-leyenda:hover { border-color: var(--borde); }
.item-leyenda input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.item-leyenda:has(input:checked) { border-color: var(--primario); background: var(--primario-suave); }
.item-leyenda:has(input:focus-visible) { outline: 2px solid var(--foco); outline-offset: 1px; }
.tramo { transition: opacity .15s; }
.item-leyenda i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.bandeja-det + .bandeja-det { margin-top: 12px; }
.bandeja-det h3 { display: flex; justify-content: space-between; padding: 6px 10px; background: var(--superficie-2); border: 1px solid var(--borde); border-radius: 8px 8px 0 0; }
.bandeja-det ol { list-style: none; margin: 0; padding: 0; border: 1px solid var(--borde); border-top: 0; border-radius: 0 0 8px 8px; }
.bandeja-det li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; padding: 6px 10px; border-top: 1px solid #f0edf5; font-size: .87rem; align-items: center; }
.bandeja-det li:first-child { border-top: 0; }
.bandeja-det li .ord { color: var(--texto-2); font-variant-numeric: tabular-nums; }
.bandeja-det li .cant { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bandeja-det li.hueco { background: repeating-linear-gradient(-45deg, #fff, #fff 6px, #f5f2f9 6px, #f5f2f9 12px); color: var(--texto-2); font-style: italic; }
.bandeja-det li.no-sku { color: var(--extra); }
.bandeja-det.con-plan li { grid-template-columns: 24px minmax(0, 1fr) 40px 40px; }
.bandeja-det li .cant.ancho { grid-column: span 2; }
.bandeja-det.con-plan li:not(.cabecera) > span:nth-child(2):last-child { grid-column: span 3; }
.bandeja-det li.cabecera { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--texto-2); padding-top: 4px; padding-bottom: 4px; background: var(--superficie-2); }
.bandeja-det li .cant.esp { color: var(--texto-2); }
.bandeja-det li .cant.real.dif { color: var(--ausente); font-weight: 600; }
.bandeja-det li .cant.real.sobra { color: var(--sobran); font-weight: 600; }
.bandeja-det li .cant.real.extra { color: var(--extra); font-weight: 600; }
.bandeja-det li.falta-plan { background: var(--ausente-fondo); color: var(--texto-2); }
.marcas-item { display: inline-flex; gap: 4px; margin-left: 6px; }

/* ---------- Costo ---------- */
.costo-rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.dato { padding: 10px 12px; background: var(--superficie-2); border-radius: 8px; border: 1px solid #ebe6f2; }
.dato small { display: block; font-size: .78rem; }
.dato b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.dato.destacado { background: var(--primario-suave); border-color: #dccbef; }
.barra-consumo { height: 8px; margin-top: 12px; border-radius: 99px; background: #ebe6f2; overflow: hidden; }
.barra-consumo span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primario), var(--magenta)); }

/* ---------- Historial ---------- */
.lista-historial { display: grid; gap: 12px; }
.item-historial { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.item-historial img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; background: #eee; }
.item-historial .acciones { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.resumen-mini { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--texto-2); margin-top: 4px; }
.resumen-mini b { color: var(--texto); font-variant-numeric: tabular-nums; }
/* Historial y tablero agrupados por envío */
.envio-historial > header { align-items: flex-start; margin-bottom: 0; }
.envio-historial > header .acciones { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cuerpos-envio { margin-top: 12px; border-top: 1px solid var(--borde); padding-top: 10px; }
.cuerpos-envio > summary { cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--primario); }
.cuerpos-envio .lista-historial { margin-top: 10px; gap: 8px; }
.cuerpos-envio .item-historial { grid-template-columns: 64px minmax(0, 1fr) auto; padding: 10px 12px; box-shadow: none; background: var(--superficie-2); margin-top: 0; }
.cuerpos-envio .item-historial img, .cuerpos-envio .item-cliente .sin-foto { width: 64px; height: 64px; }
.cuerpos-envio .item-historial h3 { font-size: .95rem; margin: 0; }
.item-historial.reemplazada { opacity: .7; }

/* ---------- Comparación ---------- */
.comparacion td.mejor { font-weight: 700; color: var(--ok); }

/* ---------- Estados ---------- */
.vacio { text-align: center; padding: 40px 20px; color: var(--texto-2); }
.vacio h2 { color: var(--texto); margin-bottom: 6px; }
.vacio .boton { margin-top: 14px; }
.cargando { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--primario-suave); border-radius: var(--radio); color: var(--primario-2); font-weight: 600; }
.giro { width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(74,20,137,.25); border-top-color: var(--primario); animation: girar 0.8s linear infinite; flex-shrink: 0; }
@keyframes girar { to { transform: rotate(360deg); } }
.mensaje-error { padding: 12px 14px; background: var(--ausente-fondo); color: #7d1a12; border: 1px solid #f4c2bd; border-radius: var(--radio); }
.lista-errores { margin: 8px 0 0; padding-left: 18px; color: #7d1a12; font-size: .87rem; }
.notificacion {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: #241539; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  font-size: .92rem; max-width: calc(100vw - 32px);
}
details > summary { cursor: pointer; font-weight: 600; color: var(--primario); padding: 4px 0; }
details[open] > summary { margin-bottom: 8px; }

/* ---------- Tablero del cliente ---------- */
.en-vivo { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 99px; background: rgba(255,255,255,.12); font-size: .85rem; font-weight: 600; white-space: nowrap; }
.en-vivo .punto { width: 9px; height: 9px; border-radius: 50%; background: #c9bfd8; }
.en-vivo[data-estado="ok"] .punto { background: #4ade80; box-shadow: 0 0 0 0 rgba(74,222,128,.7); animation: latir 1.8s ease-out infinite; }
.en-vivo[data-estado="caido"] .punto { background: #fbbf24; }
@keyframes latir { 70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
.lista-proceso { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.proceso { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px; border-radius: 8px; background: var(--primario-suave); border: 1px solid #dccbef; }
.proceso img, .proceso .sin-foto, .item-cliente .sin-foto { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: #e6deef; display: block; }
.item-cliente .sin-foto { width: 84px; height: 84px; }
.giro.chico { width: 14px; height: 14px; border-width: 2px; }
a.item-cliente { color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
a.item-cliente:hover { border-color: var(--primario); }
a.item-cliente h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item-cliente .ver-mas { color: var(--primario); font-weight: 600; font-size: .88rem; white-space: nowrap; }
.item-cliente.nuevo { border-color: var(--coral); animation: resaltar 2.4s ease-out 3; }
@keyframes resaltar { 0% { box-shadow: 0 0 0 4px rgba(255,122,133,.45); } 100% { box-shadow: var(--sombra); } }
@media (prefers-reduced-motion: reduce) { .en-vivo .punto, .item-cliente.nuevo { animation: none; } }

/* ---------- Celular ---------- */
@media (max-width: 860px) {
  .barra { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 16px 8px; }
  main { padding: 16px 16px 56px; }
  .rejilla-2, .resultado-foto, .foto-lote { grid-template-columns: minmax(0, 1fr); }
  .opciones-modo { grid-template-columns: minmax(0, 1fr); }
  .detalle-bandejas { max-height: none; }
  .item-historial { grid-template-columns: 64px minmax(0, 1fr); }
  .item-historial img { width: 64px; height: 64px; }
  .item-historial .acciones { grid-column: 1 / -1; justify-content: flex-start; }
  .item-cliente .sin-foto { width: 64px; height: 64px; }
  .item-cliente .ver-mas { display: none; }
  .en-vivo { position: absolute; top: 12px; right: 16px; }
  .aviso { margin: 12px 16px 0; }
  h1 { font-size: 1.25rem; }
  .indicador b { font-size: 1.35rem; }
}

/* Niveles (segmento / marca / producto) en Variación de espacio y Ubicación */
.resumen-nivel { cursor: pointer; padding: 10px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
details + details { border-top: 1px solid var(--borde); }
.consolidado + .consolidado { margin-top: 16px; }

/* ---------- Sesión: usuario en la barra y página de inicio de sesión ---------- */
.sesion-usuario { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; font-size: .86rem; }
.en-vivo + .sesion-usuario { margin-left: 0; }
.sesion-usuario .nombre { color: #e6dbf6; font-weight: 600; }
.sesion-usuario .salir {
  font: inherit; font-weight: 600; cursor: pointer; color: #fff; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.28); border-radius: 8px; padding: 5px 12px; min-height: 32px;
}
.sesion-usuario .salir:hover { background: rgba(255,255,255,.22); }
.aviso-sesion { position: sticky; top: 0; z-index: 30; max-width: none; margin: 0; border-radius: 0; text-align: center; }
.aviso-sesion a { color: inherit; font-weight: 700; }

.pagina-login {
  display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(140deg, var(--primario) 0%, var(--primario-2) 55%, #6c1680 85%, var(--magenta) 100%);
}
main.login { width: 100%; max-width: 400px; padding: 0; display: grid; gap: 18px; }
.login-marca { display: flex; align-items: center; gap: 12px; color: #fff; justify-content: center; }
.login-marca .logo { width: 40px; height: 40px; }
.login-marca strong { display: block; font-size: 1.1rem; }
.login-marca small { color: var(--coral); font-weight: 600; font-size: .8rem; }
.login-tarjeta { display: grid; gap: 14px; padding: 26px 24px; box-shadow: 0 12px 40px rgba(20, 5, 45, .35); }
.login-tarjeta .tenue { margin-top: -8px; font-size: .9rem; }
.login-tarjeta .aviso { margin: 0; }
.login-tarjeta .boton { width: 100%; margin-top: 4px; }
input[type=password] {
  font: inherit; color: var(--texto); width: 100%;
  padding: 8px 10px; border: 1px solid #d3cce0; border-radius: 8px; background: #fff; min-height: 38px;
}
.login-tarjeta input { min-height: 44px; font-size: 1rem; }
.campo-clave { position: relative; display: block; }
.campo-clave input { padding-right: 84px; }
.ver-clave {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  font: inherit; font-size: .82rem; font-weight: 600; color: var(--primario); cursor: pointer;
  background: none; border: 0; border-radius: 6px; padding: 6px 8px;
}
.ver-clave:hover { background: var(--primario-suave); }

@media (max-width: 1080px) and (min-width: 861px) {
  .barra { flex-wrap: wrap; gap: 10px 18px; }
  .pestanas { order: 3; flex: 1 1 100%; }
}

@media (max-width: 860px) {
  .sesion-usuario { margin-left: 0; justify-content: flex-end; }
  .en-vivo + .sesion-usuario { padding-right: 0; }
}

/* ---------- Mejoras v2: parantes verticales, edición rápida y pulido visual ---------- */
.lienzo-foto { overflow: hidden; border-radius: 8px; box-shadow: 0 2px 10px rgba(25, 10, 45, .10); }
.mascara-parante {
  position: absolute; top: 0; bottom: 0; z-index: 2; pointer-events: none;
  background: rgba(20, 14, 34, .56); backdrop-filter: grayscale(.75);
}
.parante {
  position: absolute; top: 0; bottom: 0; width: 22px; margin-left: -11px; z-index: 6;
  cursor: ew-resize; touch-action: none;
}
.parante::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 10px; width: 2.5px;
  background: #06b6d4; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.etiqueta-parante {
  position: absolute; top: 50%; transform: translateY(-50%); background: #0891b2; color: #fff;
  font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 5px;
  white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); pointer-events: none;
}
.parante.izq .etiqueta-parante { left: 14px; }
.parante.der .etiqueta-parante { right: 14px; }
.parante:focus-visible { outline: none; }
.parante:focus-visible::before { background: #fff; box-shadow: 0 0 0 2px #06b6d4; }

.franja { transition: background .15s, box-shadow .15s; z-index: 3; }
.limite { z-index: 5; }
.franja.resaltada {
  background: rgba(31, 122, 70, .28) !important;
  box-shadow: inset 0 0 0 2.5px #10b981;
}
.bandeja-det { transition: border-color .15s, box-shadow .15s; border-radius: 8px; }
.bandeja-det:hover { box-shadow: 0 2px 8px rgba(74, 20, 137, .08); }
.bandeja-det h3 { align-items: center; }
.bandeja-det li.con-accion { grid-template-columns: 24px minmax(0, 1fr) auto auto; }
.bandeja-det.con-plan li.con-accion { grid-template-columns: 24px minmax(0, 1fr) 40px 40px auto; }

.modal-fondo {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(24, 16, 40, .52); backdrop-filter: blur(3px);
}
.modal-caja {
  width: 100%; max-width: 520px; padding: 22px 24px;
  box-shadow: 0 16px 44px rgba(20, 10, 40, .28);
}
input[type=search] {
  font: inherit; color: var(--texto); width: 100%;
  padding: 6px 10px; border: 1px solid #d3cce0; border-radius: 8px; background: #fff;
}
