:root {
  --papel: #FAF8F5;
  --papel-2: #F2EADD;
  --ambar: #FFB100;
  --ambar-suave: #FFF1CC;
  --carbon: #1B1512;
  --gris: #6B625C;
  --linea: #E4DACB;
  --verde: #1F7A4D;
  --verde-suave: #E2F2E8;
  --rojo: #B3261E;
  --azul: #1D5FA8;
  --azul-suave: #E3EDF8;
  --radio: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--papel); color: var(--carbon); }
body { font: 16px/1.45 "Public Sans", system-ui, sans-serif; padding-bottom: calc(76px + env(safe-area-inset-bottom)); -webkit-text-size-adjust: 100%; }
h1, h2, h3, .marca { font-family: Archivo, system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.top { position: sticky; top: 0; z-index: 500; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--carbon); color: var(--papel); }
.marca { font-weight: 800; letter-spacing: .06em; font-size: 18px; }
.marca span { color: var(--ambar); font-weight: 600; letter-spacing: 0; text-transform: lowercase; margin-left: 4px; }
.top-der { display: flex; align-items: center; gap: 10px; font-size: 14px; opacity: .9; }
.icono { background: none; border: 0; color: inherit; font-size: 22px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }

main { padding: 14px 16px 24px; max-width: 720px; margin: 0 auto; }
.titulo { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 6px 0 12px; }
.titulo h1 { font-size: 24px; margin: 0; }
.titulo small { color: var(--gris); }
h2 { font-size: 17px; margin: 22px 0 10px; }
.vacio { padding: 26px 16px; text-align: center; color: var(--gris); background: var(--papel-2); border-radius: var(--radio); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 600; display: flex; background: #fff;
  border-top: 1px solid var(--linea); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 9px 2px 8px; text-decoration: none; font-size: 12px; color: var(--gris); position: relative; }
.tabs a b { display: block; font-size: 20px; line-height: 1.1; font-weight: 400; }
.tabs a.activo { color: var(--carbon); font-weight: 700; }
.tabs a.activo::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--ambar); border-radius: 0 0 3px 3px; }
.burbuja { position: absolute; top: 4px; right: calc(50% - 22px); background: var(--rojo); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; line-height: 18px; }

.card { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px; margin-bottom: 12px; }
.card.en_camino { border-left: 5px solid var(--azul); }
.card.vence { border-left: 5px solid var(--ambar); }
.cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cab h3 { margin: 0; font-size: 18px; }
.cab .nro { color: var(--gris); font-weight: 600; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; justify-content: flex-end; }
.chip { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--papel-2); white-space: nowrap; }
.chip.reparto { background: var(--ambar-suave); }
.chip.viacargo { background: #DDF1EC; color: #0F6B57; }
.chip.oca, .chip.oca_grande { background: #EEE; }
.chip.ml { background: #FFF159; color: #2D3277; }
.chip.et-imprimir { background: var(--azul-suave); color: var(--azul); }
.chip.et-impresa { background: var(--verde-suave); color: var(--verde); }
.chip.et-factura, .chip.et-esperando { background: #FBE3E1; color: var(--rojo); }
.aviso.atrasado { background: #FBE3E1; color: var(--rojo); }
.btn.bloque { margin: 0 0 10px; }
.acciones a.btn, .btn.bloque { display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; color: var(--carbon); }
.ayuda { color: var(--gris); margin: -4px 0 10px; font-size: 15px; }
.chip.en_camino { background: var(--azul-suave); color: var(--azul); }
.chip.entregado, .chip.despachado { background: var(--verde-suave); color: var(--verde); }
.dir { margin: 8px 0 4px; font-weight: 600; }
.dir small { display: block; font-weight: 400; color: var(--gris); }
.prods { margin: 8px 0; padding: 0; list-style: none; font-size: 15px; }
.prods li { padding: 3px 0; border-top: 1px dashed var(--linea); }
.prods li:first-child { border-top: 0; }
.prods .sku { color: var(--gris); font-size: 12px; }
.aviso { background: var(--ambar-suave); border-radius: 10px; padding: 8px 10px; margin: 8px 0; font-size: 14px; }
.aviso.nota-marcos { background: var(--carbon); color: var(--papel); }
.aviso.nota-marcos b { color: var(--ambar); }
.aviso.cliente { background: var(--papel-2); }

.contacto { display: flex; gap: 8px; margin: 10px 0 4px; }
.contacto a { flex: 1; text-align: center; text-decoration: none; padding: 10px 6px; border-radius: 10px; border: 1px solid var(--linea); font-weight: 600; font-size: 14px; background: var(--papel); }
.contacto a.wa { background: #E7F7EC; border-color: #BFE6CB; color: #136B34; }

.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn { border: 0; border-radius: 12px; padding: 13px 12px; font-weight: 700; cursor: pointer; background: var(--papel-2); min-height: 48px; }
.btn.prim { background: var(--ambar); color: var(--carbon); grid-column: 1 / -1; font-size: 17px; }
.btn.ok { background: var(--verde); color: #fff; grid-column: 1 / -1; font-size: 17px; }
.btn.osc { background: var(--carbon); color: var(--papel); }
.btn.chico { padding: 8px 12px; min-height: 0; font-size: 14px; }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; padding: 0; color: var(--gris); text-decoration: underline; cursor: pointer; font-size: 14px; }

#mapa { height: 55vh; min-height: 300px; border-radius: var(--radio); border: 1px solid var(--linea); z-index: 1; }
.pin { background: var(--ambar); color: var(--carbon); border: 2px solid var(--carbon); border-radius: 50%; width: 28px; height: 28px;
  display: grid; place-items: center; font: 700 13px Archivo, sans-serif; }
.pin.dep { background: var(--carbon); color: var(--ambar); }
.pin.vc { background: #0F6B57; color: #fff; }
.ruta { list-style: none; padding: 0; margin: 12px 0; counter-reset: r; }
.ruta li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--linea); }
.ruta li .n { flex: 0 0 28px; }
.ruta li small { color: var(--gris); display: block; }

.nota { background: #fff; border: 1px solid var(--linea); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; max-width: 88%; }
.nota.mia { margin-left: auto; background: var(--ambar-suave); border-color: #F5D98A; }
.nota .meta { font-size: 12px; color: var(--gris); margin-top: 4px; }
.nota .ped { font-weight: 700; font-size: 13px; }
.redactar { display: flex; gap: 8px; margin: 12px 0; }
.redactar textarea { flex: 1; min-height: 48px; border: 1px solid var(--linea); border-radius: 12px; padding: 10px; background: #fff; resize: vertical; }

.ev { padding: 8px 0; border-bottom: 1px solid var(--linea); font-size: 14px; }
.ev .meta { color: var(--gris); font-size: 12px; }

dialog { border: 0; border-radius: 18px 18px 0 0; padding: 0; width: 100%; max-width: 720px; margin: auto auto 0; background: var(--papel); }
dialog::backdrop { background: rgba(27, 21, 18, .55); }
#hoja-form { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
#hoja-form h3 { margin: 0 0 6px; font-size: 20px; }
#hoja-form p { margin: 6px 0 12px; color: var(--gris); }
#hoja-form label { display: block; font-weight: 600; margin: 12px 0 6px; }
#hoja-form input, #hoja-form textarea, #hoja-form select { width: 100%; padding: 12px; border: 1px solid var(--linea); border-radius: 12px; background: #fff; font-size: 17px; }
#hoja-form .guia { font: 700 24px/1.2 Archivo, monospace; letter-spacing: .08em; text-align: center; }
.botonera { display: flex; gap: 8px; margin-top: 16px; }
.botonera .btn { flex: 1; }
.rapidas { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.rapidas button { border: 1px solid var(--linea); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.foto-prev { max-width: 100%; max-height: 180px; border-radius: 10px; display: block; margin: 10px auto 0; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 900; text-align: center; pointer-events: none; }
#toast span { display: inline-block; background: var(--carbon); color: var(--papel); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast span.error { background: var(--rojo); color: #fff; }

.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login h1 { font-size: 30px; margin-bottom: 4px; }
.login input { width: 100%; text-align: center; font: 700 30px Archivo, sans-serif; letter-spacing: .4em; padding: 14px; border: 1px solid var(--linea); border-radius: 14px; margin: 18px 0 12px; background: #fff; }
.login .btn { width: 100%; }

.fila { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
select.ruta-sel { padding: 8px; border-radius: 10px; border: 1px solid var(--linea); background: #fff; }
.cargando { text-align: center; color: var(--gris); padding: 30px; }

.caja { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1px solid var(--linea); border-radius: 12px; padding: 12px; margin-bottom: 8px; cursor: pointer; }
.caja input { width: 26px; height: 26px; flex: none; accent-color: var(--verde); margin: 2px 0 0; }
.caja-txt { flex: 1; min-width: 0; }
.caja-cod { font-size: 20px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.caja-prod { font-size: 14px; color: var(--gris); margin-top: 2px; }
.caja.lista { opacity: .55; }
.caja.lista .caja-cod { text-decoration: line-through; }
.exc { background: #fff; border: 1px solid var(--linea); border-left: 4px solid var(--ambar); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 15px; overflow-wrap: anywhere; }
.exc.urgente { border-left-color: var(--rojo); background: #FBE3E1; }
.exc-acc { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.exc-acc a.btn { color: var(--carbon); text-decoration: none; }
.sucursal-fila { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card h3 { overflow-wrap: anywhere; }
