/* Albaranes en Ruta · el talonario de notas de entrega (tinta azul, cabecera naranja) en botones grandes */
:root {
  --papel: #F6F7FB;
  --hoja: #FFFFFF;
  --tinta: #1E2A78;
  --tinta-suave: #E4E8F7;
  --naranja: #E2552F;
  --naranja-suave: #FCE9E3;
  --texto: #1B1E2B;
  --texto-2: #545A72;
  --raya: #D3D8EA;
  --ok: #1E7A4F;
  --ok-suave: #DFF3E8;
  --aviso: #8A5A00;
  --aviso-suave: #FFF2CC;
  --error: #B42318;
  --error-suave: #FDE4E1;
  --f-titulo: "Archivo", "Arial Narrow", Arial, sans-serif;
  --f-app: "Atkinson Hyperlegible", Verdana, Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papel: #10131F; --hoja: #171B2B; --tinta: #9FB0FF; --tinta-suave: #232A4A; --naranja: #FF7A52; --naranja-suave: #3A2219;
    --texto: #EEF0F8; --texto-2: #A9AEC6; --raya: #2E3552; --ok: #5FD39B; --ok-suave: #173527; --aviso: #F2C14E; --aviso-suave: #3A2F12;
    --error: #FF8A80; --error-suave: #3B1714; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --papel: #10131F; --hoja: #171B2B; --tinta: #9FB0FF; --tinta-suave: #232A4A; --naranja: #FF7A52; --naranja-suave: #3A2219;
  --texto: #EEF0F8; --texto-2: #A9AEC6; --raya: #2E3552; --ok: #5FD39B; --ok-suave: #173527; --aviso: #F2C14E; --aviso-suave: #3A2F12;
  --error: #FF8A80; --error-suave: #3B1714; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--papel); color: var(--texto); font-family: var(--f-app); font-size: 17px; line-height: 1.5; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--naranja); outline-offset: 2px; }

/* La app ocupa la pantalla; en una tablet o un PC se centra como una hoja */
#app { container-type: inline-size; background: var(--hoja); height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 1100px; margin: 0 auto; position: relative; overflow: hidden; }
@media (min-width: 1140px) { #app { border-inline: 1px solid var(--raya); } }

.barra { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 12px; border-bottom: 1px solid var(--raya); min-height: 76px; }
.barra h1 { font-family: var(--f-titulo); font-size: 22px; margin: 0; flex: 1; min-width: 0; color: var(--texto); line-height: 1.15; overflow-wrap: anywhere; }
.barra .sub { display: block; font-family: var(--f-app); font-size: 14px; color: var(--texto-2); font-weight: 400; }
.icono-boton { width: 52px; height: 52px; border-radius: 16px; border: 2px solid var(--raya); background: var(--hoja); display: grid; place-items: center; flex: none; color: var(--texto); }
.cuerpo { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 16px; align-content: start; -webkit-overflow-scrolling: touch; }
.pie { padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 16px); border-top: 1px solid var(--raya); display: grid; gap: 10px; background: var(--hoja); }

.boton { min-height: 64px; border-radius: 18px; border: none; background: var(--tinta); color: var(--hoja); font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 18px; width: 100%; text-align: center; }
.boton.naranja { background: var(--naranja); color: #fff; }
.boton.claro { background: var(--tinta-suave); color: var(--tinta); }
.boton.verde { background: #25D366; color: #0B2E19; }
.boton:disabled { opacity: .4; cursor: not-allowed; }
.enlace { background: none; border: none; color: var(--tinta); font-weight: 700; text-decoration: underline; padding: 8px 0; justify-self: start; min-height: 44px; }

.pasos { display: flex; gap: 6px; }
.pasos i { height: 6px; flex: 1; border-radius: 6px; background: var(--raya); }
.pasos i.hecho { background: var(--tinta); }
.pasos i.ahora { background: var(--naranja); }

.saludo { font-size: 20px; }
.saludo b { font-family: var(--f-titulo); font-size: 28px; display: block; color: var(--tinta); }
.estado { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--ok-suave); color: var(--ok); font-weight: 700; font-size: 15px; justify-self: start; }
.estado.pendiente { background: var(--aviso-suave); color: var(--aviso); }
.estado.mal { background: var(--error-suave); color: var(--error); }
.losas { display: grid; gap: 14px; }
@container (min-width: 700px) { .losas { grid-template-columns: repeat(2, 1fr); } }
.losa { border: none; border-radius: 22px; padding: 22px; text-align: left; display: grid; gap: 8px; min-height: 120px; background: var(--tinta-suave); color: var(--tinta); }
.losa.principal { background: var(--naranja); color: #fff; min-height: 150px; }
.losa b { font-family: var(--f-titulo); font-size: 26px; line-height: 1.1; }
.losa span { font-size: 16px; opacity: .9; }

.lista { display: grid; gap: 10px; }
.fila { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 2px solid var(--raya); border-radius: 18px; background: var(--hoja); text-align: left; width: 100%; min-height: 72px; }
.fila .t { flex: 1; min-width: 0; }
.fila .t b { display: block; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.fila .t span { color: var(--texto-2); font-size: 15px; }
.fila .precio { font-family: var(--f-titulo); font-size: 20px; color: var(--tinta); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila.especial .precio { color: var(--naranja); }
.inicial { min-width: 48px; height: 48px; padding: 0 6px; border-radius: 14px; background: var(--tinta-suave); color: var(--tinta); display: grid; place-items: center; font-family: var(--f-titulo); font-size: 18px; flex: none; }
.buscar { display: flex; align-items: center; gap: 10px; border: 2px solid var(--raya); border-radius: 16px; padding: 0 14px; min-height: 58px; background: var(--hoja); }
.buscar input { border: none; outline: none; background: transparent; flex: 1; min-width: 0; font-size: 18px; }
.titulillo { font-family: var(--f-titulo); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--texto-2); margin: 4px 0 -4px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex: none; border: 2px solid var(--raya); background: var(--hoja); border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 15px; min-height: 44px; }
.chip[aria-pressed="true"] { background: var(--tinta); border-color: var(--tinta); color: var(--hoja); }

.linea { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px 16px; border-radius: 16px; background: var(--tinta-suave); }
.linea b { font-size: 17px; overflow-wrap: anywhere; }
.linea .cant { color: var(--texto-2); font-size: 15px; }
.linea .num { font-family: var(--f-titulo); font-size: 22px; color: var(--tinta); grid-row: span 2; align-self: center; font-variant-numeric: tabular-nums; text-align: right; }
.linea .quitar { grid-column: 1 / -1; justify-self: start; background: none; border: none; color: var(--naranja); font-weight: 700; padding: 6px 0; min-height: 40px; }
.vacio { border: 2px dashed var(--raya); border-radius: 18px; padding: 26px; text-align: center; color: var(--texto-2); }
.dos-col { display: grid; gap: 18px; }
.solo-tablet { display: none; }
@container (min-width: 700px) {
  .dos-col { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .solo-tablet { display: grid; gap: 12px; }
  .solo-movil { display: none !important; }
}

/* Hoja que sube desde abajo */
.velo { position: absolute; inset: 0; background: rgba(15, 20, 50, .45); display: flex; align-items: flex-end; z-index: 20; }
.hoja { background: var(--hoja); width: 100%; border-radius: 28px 28px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 20px); display: grid; gap: 14px; max-height: 92%; overflow-y: auto; }
@container (min-width: 700px) { .velo { align-items: center; justify-content: center; } .hoja { width: 480px; border-radius: 28px; } }
.hoja h2 { font-family: var(--f-titulo); font-size: 22px; margin: 0; overflow-wrap: anywhere; }
.visor { font-family: var(--f-titulo); font-size: 44px; text-align: right; padding: 10px 16px; border-radius: 16px; background: var(--tinta-suave); color: var(--tinta); font-variant-numeric: tabular-nums; }
.visor small { font-family: var(--f-app); font-size: 18px; color: var(--texto-2); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.teclado button { min-height: 62px; border-radius: 16px; border: 2px solid var(--raya); background: var(--hoja); font-size: 26px; font-weight: 700; }
.aviso { padding: 12px 14px; border-radius: 14px; background: var(--aviso-suave); color: var(--aviso); font-size: 15px; }
.aviso.mal { background: var(--error-suave); color: var(--error); }

/* Firma */
.lienzo { position: relative; border: 2px dashed var(--tinta); border-radius: 18px; background: #FFFFFF; height: 260px; touch-action: none; }
@container (min-width: 700px) { .lienzo { height: 340px; } }
.lienzo canvas { width: 100%; height: 100%; display: block; border-radius: 16px; touch-action: none; }
.lienzo .guia { position: absolute; left: 24px; right: 24px; bottom: 56px; border-bottom: 2px solid #D3D8EA; pointer-events: none; }
.lienzo .rotulo { position: absolute; left: 24px; bottom: 26px; color: #545A72; font-size: 14px; pointer-events: none; }
.campo { display: grid; gap: 6px; }
.campo label { font-weight: 700; }
.campo input, .campo textarea { min-height: 58px; border: 2px solid var(--raya); border-radius: 16px; padding: 12px 14px; font-size: 18px; background: var(--hoja); width: 100%; }
.campo textarea { min-height: 90px; resize: vertical; }
.campo small { color: var(--texto-2); }

/* Destinos */
.destino { display: flex; align-items: center; gap: 14px; padding: 16px; border: 2px solid var(--raya); border-radius: 18px; text-align: left; width: 100%; background: var(--hoja); min-height: 76px; }
.destino[aria-pressed="true"] { border-color: var(--tinta); background: var(--tinta-suave); }
.destino .t { flex: 1; min-width: 0; }
.destino .t b { display: block; font-size: 18px; }
.destino .t span { color: var(--texto-2); font-size: 14px; overflow-wrap: anywhere; }
.marca { width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--raya); display: grid; place-items: center; flex: none; background: var(--hoja); }
.destino[aria-pressed="true"] .marca { background: var(--tinta); border-color: var(--tinta); color: var(--hoja); }
.destino.fijo { cursor: default; }

/* Vista previa de la nota de entrega: siempre en papel blanco, como el PDF */
.nota { border: 1px solid var(--raya); border-radius: 12px; padding: 16px; background: #FFFFFF; color: #1B1E2B; display: grid; gap: 10px; font-size: 14px; }
.nota .cab { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.nota .sello { border: 2px solid #1E2A78; color: #1E2A78; padding: 6px 8px; border-radius: 6px; font-size: 12px; line-height: 1.35; }
.nota .tit { color: #E2552F; font-family: var(--f-titulo); font-weight: 800; font-size: 18px; text-align: right; line-height: 1.1; }
.nota .tit span { display: block; color: #1E2A78; font-size: 22px; }
.nota .tit small { display: block; font-family: var(--f-app); font-weight: 400; color: #545A72; font-size: 12px; margin-top: 4px; }
.nota table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.nota th { text-align: left; font-size: 12px; color: #545A72; border-bottom: 1px solid #D3D8EA; padding: 4px 2px; font-weight: 700; }
.nota td { padding: 5px 2px; border-bottom: 1px solid #EEF0F6; vertical-align: top; }
.nota td.n, .nota th.n { white-space: nowrap; text-align: right; padding-left: 10px; }
.nota .firma img { height: 70px; display: block; }
.nota .firma { border-top: 1px dashed #D3D8EA; padding-top: 6px; color: #545A72; }

/* Hecho */
.hecho { display: grid; gap: 14px; justify-items: center; text-align: center; padding-top: 12px; }
.sello-ok { width: 108px; height: 108px; border-radius: 50%; background: var(--ok-suave); color: var(--ok); display: grid; place-items: center; }
.sello-ok.pendiente { background: var(--aviso-suave); color: var(--aviso); }
.hecho h2 { font-family: var(--f-titulo); font-size: 28px; margin: 0; color: var(--texto); text-wrap: balance; }
.comprobado { display: grid; gap: 10px; width: 100%; text-align: left; }
.comprobado div { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 16px; background: var(--ok-suave); color: var(--ok); font-weight: 700; }
.comprobado div.pendiente { background: var(--aviso-suave); color: var(--aviso); }
.comprobado div.mal { background: var(--error-suave); color: var(--error); }
.comprobado svg { flex: none; }
.comprobado p { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.comprobado span { color: var(--texto); font-weight: 400; }
@media (prefers-reduced-motion: no-preference) {
  .velo .hoja { animation: sube .22s ease-out both; }
}
@keyframes sube { from { transform: translateY(40px); opacity: .6; } }
.toast { position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 110px); background: var(--texto); color: var(--hoja); border-radius: 16px; padding: 14px 16px; font-weight: 700; z-index: 30; display: flex; gap: 10px; align-items: center; }

/* Entrada */
.entrada { display: grid; gap: 18px; max-width: 460px; width: 100%; margin: 0 auto; }
.marca-app { display: flex; align-items: center; gap: 14px; }
.marca-app img { width: 64px; height: 64px; border-radius: 16px; }
.marca-app b { font-family: var(--f-titulo); font-size: 28px; color: var(--tinta); line-height: 1.05; }
.datos { display: grid; gap: 8px; margin: 0; }
.datos div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--raya); }
.datos dt { color: var(--texto-2); }
.datos dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
