/* Despachos · panel de la oficina (la planilla) */
:root {
  --tinta: #0f172a; --texto: #1e293b; --suave: #64748b; --linea: #e2e8f0; --linea-fuerte: #cbd5e1;
  --fondo: #f8fafc; --hoja: #ffffff; --acento: #0f766e; --acento-osc: #115e59; --acento-tenue: #ccfbf1;
  --peligro: #b91c1c; --peligro-tenue: #fee2e2;
  /* Colores de fila (mismo significado que en la planilla, en tono legible) */
  --f-amarillo: #fff59d; --f-celeste: #b2ebf2; --f-verde: #c8e6c9; --f-rojo: #ffcdd2; --f-naranjo: #ffe0b2;
  --m-amarillo: #fdd835; --m-celeste: #00bcd4; --m-verde: #43a047; --m-rojo: #e53935; --m-naranjo: #fb8c00; --m-blanco: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--texto); background: var(--fondo); font-size: 14px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* -------- botones -------- */
.btn { border: 1px solid var(--linea-fuerte); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f5f9; }
.btn.primario { background: var(--acento); border-color: var(--acento); color: #fff; font-weight: 600; }
.btn.primario:hover { background: var(--acento-osc); }
.btn.primario:disabled { opacity: .5; cursor: default; }
.btn.icono { padding: 4px 10px; font-size: 18px; line-height: 1; }
.btn.peligro { color: var(--peligro); border-color: #fca5a5; }
.btn.chico { padding: 4px 9px; font-size: 13px; }

/* -------- acceso -------- */
.acceso { min-height: 100%; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #0f172a, #134e4a); }
.acceso-caja { width: min(420px, 100%); background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px -20px rgb(0 0 0 / 50%); }
.marca { font-weight: 800; font-size: 26px; color: var(--tinta); }
.marca.chica { font-size: 17px; }
.acceso-sub { color: var(--suave); margin: 6px 0 18px; }
.pestanas-acceso { display: flex; gap: 6px; margin-bottom: 16px; }
.pestanas-acceso button { flex: 1; border: 1px solid var(--linea-fuerte); background: #fff; padding: 9px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.pestanas-acceso button.on { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.acceso label, .dialogo label { display: block; font-size: 13px; color: var(--suave); margin-bottom: 10px; }
.acceso input, .dialogo input, .dialogo select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--linea-fuerte); border-radius: 8px; background: #fff; color: var(--texto); }
.acceso .btn.primario { width: 100%; padding: 11px; margin-top: 6px; }
.error-txt { color: var(--peligro); font-weight: 600; min-height: 1.2em; }
.aviso-txt { color: var(--acento-osc); font-weight: 600; min-height: 1.2em; }

/* -------- barra -------- */
.app { display: flex; flex-direction: column; height: 100%; }
.barra { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; background: var(--tinta); color: #fff; flex-wrap: wrap; }
.barra .marca { color: #fff; }
.barra-izq, .barra-der, .mes { display: flex; align-items: center; gap: 8px; }
.empresa { color: #99f6e4; font-weight: 600; }
.conexion { background: #b45309; color: #fff; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.mes strong { min-width: 150px; text-align: center; font-size: 16px; }
.barra .btn { background: rgb(255 255 255 / 8%); border-color: rgb(255 255 255 / 25%); color: #fff; }
.barra .btn:hover { background: rgb(255 255 255 / 16%); }
.barra .btn.primario { background: var(--acento); border-color: var(--acento); }
.barra input, .barra select { padding: 7px 10px; border-radius: 8px; border: 1px solid rgb(255 255 255 / 25%); background: rgb(255 255 255 / 10%); color: #fff; }
.barra input::placeholder { color: #cbd5e1; }
.barra select option { color: var(--texto); }
#buscar { width: 230px; }
.menu { position: relative; }
.menu-lista { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--texto); border: 1px solid var(--linea); border-radius: 10px; box-shadow: 0 12px 30px -10px rgb(0 0 0 / 30%); padding: 6px; min-width: 250px; z-index: 30; }
.menu-lista button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-lista button:hover { background: #f1f5f9; }
.menu-lista hr { border: 0; border-top: 1px solid var(--linea); margin: 4px 0; }

.leyenda { display: flex; gap: 14px; flex-wrap: wrap; padding: 6px 14px; font-size: 12px; color: var(--suave); background: #fff; border-bottom: 1px solid var(--linea); }
.leyenda span { display: inline-flex; align-items: center; gap: 5px; }
.muestra { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--linea-fuerte); display: inline-block; background: var(--m-blanco); }
.btn-color-m.amarillo { background: var(--m-amarillo); } .btn-color-m.celeste { background: var(--m-celeste); }
.btn-color-m.verde { background: var(--m-verde); } .btn-color-m.rojo { background: var(--m-rojo); } .btn-color-m.naranjo { background: var(--m-naranjo); }

/* -------- la hoja -------- */
.hoja-cont { flex: 1; overflow: auto; background: var(--hoja); }
.hoja { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; table-layout: fixed; }
.hoja th { position: sticky; top: 0; z-index: 5; background: #f1f5f9; color: var(--suave); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--linea-fuerte); border-right: 1px solid var(--linea); }
.hoja td { border-bottom: 1px solid var(--linea); border-right: 1px solid var(--linea); padding: 0; vertical-align: top; background: inherit; }
/* Anchos pensados para que todo quepa en una pantalla de 1440 px (la columna Repartidor siempre a la vista) */
.c-sel { width: 30px; } .c-color { width: 34px; } .c-numero { width: 68px; } .c-cliente { width: 160px; } .c-direccion { width: 190px; } .c-contacto { width: 170px; }
.c-productos { width: 185px; } .c-obs { width: 150px; } .c-estado { width: 170px; } .c-guia { width: 60px; } .c-rep { width: 140px; } .c-acc { width: 36px; }

.celda { min-height: 34px; padding: 7px 8px; outline: none; white-space: pre-wrap; word-break: break-word; line-height: 1.35; }
.celda:focus { box-shadow: inset 0 0 0 2px var(--acento); background: #fff; }
.celda.guardando { color: var(--suave); }
.celda.error { box-shadow: inset 0 0 0 2px var(--peligro); }

tr.fila { background: #fff; }
tr.fila.amarillo { background: var(--f-amarillo); }
tr.fila.celeste { background: var(--f-celeste); }
tr.fila.verde { background: var(--f-verde); }
tr.fila.rojo { background: var(--f-rojo); }
tr.fila.naranjo { background: var(--f-naranjo); }
tr.fila:hover td { filter: brightness(.98); }

.btn-color { width: 22px; height: 22px; margin: 6px; border-radius: 6px; border: 1px solid var(--linea-fuerte); cursor: pointer; background: var(--m-blanco); }
tr.amarillo .btn-color { background: var(--m-amarillo); } tr.celeste .btn-color { background: var(--m-celeste); }
tr.verde .btn-color { background: var(--m-verde); } tr.rojo .btn-color { background: var(--m-rojo); } tr.naranjo .btn-color { background: var(--m-naranjo); }

tr.dia td { background: #fef9c3; border-bottom: 1px solid #fde68a; position: sticky; }
.dia-cab { display: flex; align-items: center; gap: 12px; padding: 7px 10px; }
.dia-cab strong { font-size: 15px; color: var(--tinta); text-transform: capitalize; }
.dia-cab .cuenta { color: var(--suave); font-size: 12px; }
.dia-cab .btn { margin-left: auto; }

.estado { padding: 7px 8px; font-size: 12px; font-weight: 700; line-height: 1.35; }
.estado.en_ruta { color: #9d174d; }
.estado.entregado { color: #166534; }
.estado.no_entregado { color: var(--peligro); }
.estado .sub { display: block; font-weight: 500; color: var(--texto); }
select.rep { width: 100%; height: 34px; border: 0; background: transparent; padding: 0 6px; cursor: pointer; }
select.rep:focus { outline: 2px solid var(--acento); }
select.rep.sin { color: var(--suave); }
.btn-borrar { border: 0; background: none; color: var(--suave); cursor: pointer; padding: 8px; font-size: 15px; }
.btn-borrar:hover { color: var(--tinta); background: #e2e8f0; border-radius: 6px; }
.ventana button.peligro { color: var(--peligro); }
.hist-lista { max-height: 55vh; overflow: auto; }
.hist-lista .sub { font-size: 12px; margin-top: 2px; }
.nowrap { white-space: nowrap; }
.vieja { color: #b45309; font-weight: 600; }
.btn-fotos { display: block; margin-top: 3px; border: 0; background: #e0f2fe; color: #075985; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; cursor: pointer; }
.fotos-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; max-height: 65vh; overflow: auto; }
.fotos-lista figure { margin: 0; }
.fotos-lista img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; background: #f1f5f9; cursor: zoom-in; }
.fotos-lista img.grande { position: fixed; inset: 0; width: 100vw; height: 100vh; aspect-ratio: auto; object-fit: contain; background: rgb(15 23 42 / 92%); border-radius: 0; z-index: 100; cursor: zoom-out; }
.fotos-lista figcaption { font-size: 12px; color: var(--suave); display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.copiable { user-select: all; word-break: break-all; }

.vacio { padding: 40px; text-align: center; color: var(--suave); }
/* -------- secciones DESPACHOS / RETIROS -------- */
.secciones { display: flex; gap: 4px; padding: 6px 14px 0; background: #fff; border-bottom: 1px solid var(--linea-fuerte); }
.secciones button { border: 1px solid var(--linea-fuerte); border-bottom: 0; background: #f1f5f9; color: var(--suave); font-weight: 700;
  padding: 8px 18px; border-radius: 10px 10px 0 0; cursor: pointer; font-size: 14px; letter-spacing: .02em; }
.secciones button.on { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.secciones .n { font-weight: 500; opacity: .8; margin-left: 4px; }
/* Columnas de RETIROS (caben en 1440 px) */
.c-nota_venta { width: 92px; } .c-factura { width: 84px; } .c-proveedor { width: 170px; } .c-oc { width: 84px; }
.c-condicion_pago { width: 140px; } .c-obs-retiro { width: 285px; }

/* -------- selección de varios pedidos -------- */
.c-sel input, .marca-sel { width: 16px; height: 16px; margin: 9px 7px; cursor: pointer; accent-color: var(--acento); }
.dia-cab .marca-sel { margin: 0; }
tr.fila.sel td { box-shadow: inset 0 2px 0 var(--acento), inset 0 -2px 0 var(--acento); }
tr.fila.sel td:first-child { box-shadow: inset 4px 0 0 var(--acento), inset 0 2px 0 var(--acento), inset 0 -2px 0 var(--acento); }
.barra-sel { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 9px 14px; background: var(--tinta); color: #fff; }
.barra-sel label { display: flex; align-items: center; gap: 8px; }
.barra-sel select { padding: 6px 8px; border-radius: 8px; border: 0; min-width: 180px; }
.barra-sel .btn:not(.primario) { background: rgb(255 255 255 / 8%); border-color: rgb(255 255 255 / 25%); color: #fff; }
.barra-sel .ocultos { color: #fcd34d; font-size: 12px; }
.barra-sel .ayuda { margin-left: auto; color: #94a3b8; font-size: 12px; }

.pie { padding: 6px 14px; font-size: 12px; color: var(--suave); background: #fff; border-top: 1px solid var(--linea); display: flex; gap: 18px; }

/* -------- selector de color -------- */
.ventana { position: fixed; z-index: 40; background: #fff; border: 1px solid var(--linea); border-radius: 10px; box-shadow: 0 12px 30px -10px rgb(0 0 0 / 35%); padding: 6px; }
.ventana button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer; text-align: left; }
.ventana button:hover { background: #f1f5f9; }

/* -------- diálogos -------- */
.dialogo { border: 0; border-radius: 14px; padding: 22px; width: min(420px, 94vw); box-shadow: 0 30px 60px -20px rgb(0 0 0 / 45%); }
.dialogo.ancho { width: min(760px, 94vw); }
.dialogo::backdrop { background: rgb(15 23 42 / 55%); }
.dialogo h3 { margin: 0 0 8px; }
.dialogo h4 { margin: 18px 0 8px; }
.dialogo .sub { color: var(--suave); margin: 0 0 14px; }
.botones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.fila-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.fila-form input, .fila-form select { flex: 1; min-width: 140px; padding: 8px 10px; border: 1px solid var(--linea-fuerte); border-radius: 8px; }
.grilla-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grilla-form .todo { grid-column: 1 / -1; }
.dias { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.dias label { display: inline-flex; align-items: center; gap: 4px; margin: 0; color: var(--texto); }
.dias input { width: auto; display: inline; margin: 0; }
table.lista { width: 100%; border-collapse: collapse; }
table.lista td, table.lista th { border-bottom: 1px solid var(--linea); padding: 8px 6px; text-align: left; font-size: 13px; }
table.lista .acciones { text-align: right; white-space: nowrap; }
.pin { font-family: Consolas, monospace; font-size: 20px; font-weight: 800; letter-spacing: .15em; background: var(--acento-tenue); padding: 3px 10px; border-radius: 6px; }
.hojas-imp label { display: flex; align-items: center; gap: 8px; color: var(--texto); font-size: 14px; }
.hojas-imp input { width: auto; display: inline; margin: 0; }
.inactivo { color: var(--suave); text-decoration: line-through; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 200%); visibility: hidden; background: var(--tinta); color: #fff; padding: 11px 18px; border-radius: 10px; transition: transform .2s; z-index: 50; max-width: 90vw; }
.toast.ver { transform: translate(-50%, 0); visibility: visible; }
.toast.mal { background: var(--peligro); }
