/* Albaranes · Aina Elephant — paleta y tipografía de ainaelephant.es */
:root {
  --bg: #f4faf6;
  --surface: #ffffff;
  --surface-2: #f3f9f5;
  --border: rgba(14, 138, 110, 0.16);
  --border-strong: rgba(14, 138, 110, 0.34);
  --text: #0f2620;
  --text-soft: #44615a;
  --muted: #7c948c;
  --green: #28b34c;
  --green-light: #56c271;
  --green-deep: #0e8a6e;
  --grad: linear-gradient(120deg, #56c271 0%, #28b34c 46%, #0e8a6e 100%);
  --amber: #b7791f;
  --amber-bg: #fff6e0;
  --red: #c53030;
  --red-bg: #fdecec;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 44px -28px rgba(14, 70, 56, 0.45);
  --font-head: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --nav-h: 68px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior: none;
  /* Como una app: sin zoom por doble toque, sin seleccionar texto ni menús
     al mantener pulsado. Los campos de texto sí se pueden seleccionar. */
  touch-action: pan-x pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img { -webkit-user-drag: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

.aura {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 40% at 90% -5%, rgba(86, 194, 113, 0.18), transparent 60%),
    radial-gradient(50% 35% at 0% 0%, rgba(14, 138, 110, 0.12), transparent 60%);
}

/* ---------- comunes ---------- */
.vista { min-height: 100dvh; }
.centrada { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.suave { color: var(--text-soft); }
.pequeno-texto { font-size: 0.86rem; }
.error { color: var(--red); font-size: 0.9rem; min-height: 1.3em; }
h1, h2 { font-family: var(--font-head); letter-spacing: -0.01em; }

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 600;
  transition: transform .12s, background .2s;
}
.boton:active { transform: scale(0.98); }
.boton.primario { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 10px 24px -14px rgba(14,138,110,.9); }
.boton.peligro { color: var(--red); border-color: rgba(197,48,48,.4); }
.boton.peligro-lleno { background: var(--red); color: #fff; border-color: transparent; }
.boton.pequeno { min-height: 38px; padding: 0 12px; font-size: 0.88rem; border-radius: 10px; }
.boton.ancho { width: 100%; }
.boton[disabled] { opacity: .55; pointer-events: none; }
.enlace { color: var(--green-deep); font-weight: 600; padding: 12px; text-decoration: underline; text-underline-offset: 3px; }
.icono-boton { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--text-soft); }
.icono-boton:active { background: var(--surface-2); }

label { display: grid; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text-soft); }
input, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: #fff; font-size: 16px; font-weight: 500; color: var(--text);
}
textarea { min-height: 72px; resize: vertical; }
input:focus, textarea:focus { outline: 3px solid rgba(40,179,76,.25); border-color: var(--green-deep); }

/* ---------- entrar ---------- */
.entrar { width: 100%; max-width: 400px; display: grid; gap: 14px; text-align: center; }
.entrar label { text-align: left; }
.logo-grande { width: 170px; margin: 0 auto 4px; }
.entrar h1 { font-size: 1.7rem; }

/* ---------- cabecera y pestañas ---------- */
.cabecera {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px;
  background: rgba(244, 250, 246, 0.88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo-mini { width: 38px; height: 38px; border-radius: 10px; }
.cabecera-titulo { display: grid; line-height: 1.15; flex: 1; }
.cabecera-titulo strong { font-family: var(--font-head); font-size: 1.15rem; }
.cabecera-titulo span { font-size: 0.75rem; color: var(--green-deep); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }

.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: 1fr 1fr;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.pestana { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.pestana.activa { color: var(--green-deep); }
.pestana.activa svg { stroke: var(--green); }

/* ---------- subir ---------- */
.disparador {
  width: 100%;
  display: grid; justify-items: center; gap: 6px;
  padding: 40px 20px 34px;
  border-radius: 26px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 26px 50px -26px rgba(14,138,110,.95);
  transition: transform .12s;
}
.disparador:active { transform: scale(0.985); }
.disparador-icono { width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.5); margin-bottom: 8px; }
.disparador-texto { font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; }
.disparador-sub { opacity: .85; font-size: .92rem; }
#boton-galeria { display: block; margin: 6px auto 0; }
.consejo { margin-top: 18px; font-size: .88rem; color: var(--muted); text-align: center; }

.resumen-dia { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.resumen-dia div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.resumen-dia b { display: block; font-family: var(--font-head); font-size: 1.5rem; color: var(--green-deep); font-variant-numeric: tabular-nums; }
.resumen-dia span { font-size: .75rem; color: var(--text-soft); }

.previa { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 12px; background: var(--surface-2); }
.progreso { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 16px 0 10px; }
.progreso-barra { height: 100%; width: 0; background: var(--grad); transition: width .25s; }
.progreso-barra.indeterminada { width: 40% !important; animation: vaiven 1.1s ease-in-out infinite alternate; }
@keyframes vaiven { from { transform: translateX(-10%); } to { transform: translateX(160%); } }
.estado-subida { text-align: center; font-weight: 600; color: var(--text-soft); }

#paso-revisar { display: grid; gap: 14px; }
.revisar-cabecera { display: flex; gap: 12px; align-items: center; }
.previa-mini { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; }
.ok-titulo { font-weight: 700; color: var(--green-deep); font-size: 1.05rem; }
.campos { display: grid; gap: 12px; }
.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.botonera { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.aviso {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--amber-bg); color: #7a4f0d; font-size: .9rem; font-weight: 500;
  border: 1px solid rgba(183,121,31,.3);
}
.aviso-ia { display: block; line-height: 1.4; }
.aviso-rojo { background: var(--red-bg); color: #8b1f1f; border-color: rgba(197,48,48,.3); }

/* ---------- histórico ---------- */
.cifras { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.cifras div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 6px; text-align: center; }
.cifras b { display: block; font-family: var(--font-head); font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.cifras span { font-size: .7rem; color: var(--text-soft); line-height: 1.2; display: block; }
.cifras .c-porcaducar b { color: var(--amber); }
.cifras .c-caducado b { color: var(--red); }

.buscador { position: relative; margin-bottom: 10px; }
.buscador svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.buscador input { padding-left: 40px; }

.filtros { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.filtro { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .86rem; font-weight: 600; color: var(--text-soft); }
.filtro.activo { background: var(--green-deep); color: #fff; border-color: var(--green-deep); }

.dia { margin: 18px 0 8px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.item {
  width: 100%; text-align: left;
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.item:active { background: var(--surface-2); }
.item img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.item-cuerpo { min-width: 0; }
.item-empresa { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-ruta { font-size: .88rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.item-lado { display: grid; justify-items: end; gap: 4px; }
.vacio { text-align: center; color: var(--muted); padding: 40px 16px; }

.sello { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.sello.vigente { background: rgba(40,179,76,.12); color: var(--green-deep); }
.sello.porcaducar { background: var(--amber-bg); color: var(--amber); }
.sello.caducado { background: var(--red-bg); color: var(--red); }
.sello.qr { background: #e8f1ff; color: #2756a8; }
.dias { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.contador { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.contador div { height: 100%; background: var(--grad); }
.contador.porcaducar div { background: var(--amber); }
.contador.caducado div { background: var(--red); }

/* ---------- ficha ---------- */
.ficha-fondo { position: fixed; inset: 0; z-index: 20; background: rgba(10, 30, 25, .45); display: flex; align-items: flex-end; justify-content: center; animation: aparece .2s; }
.ficha {
  width: min(720px, 100%); max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: sube .25s cubic-bezier(.22,1,.36,1);
}
.ficha-asa { width: 44px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 6px; }
.ficha-cabecera { display: flex; align-items: center; justify-content: space-between; }
.ficha-cabecera h2 { font-size: 1.25rem; }
.ficha-foto { width: 100%; max-height: 40vh; object-fit: contain; background: #fff; border-radius: 14px; border: 1px solid var(--border); margin: 6px 0 12px; cursor: zoom-in; }
.ficha-estado { display: grid; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 12px; font-size: .9rem; }
.ficha-estado-fila { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ficha-acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.ficha-acciones .ancho-total { grid-column: 1 / -1; }
.nota-ia { font-size: .82rem; color: var(--muted); margin-top: -4px; }
@keyframes aparece { from { opacity: 0; } }
@keyframes sube { from { transform: translateY(40px); opacity: .6; } }

.visor { position: fixed; inset: 0; z-index: 30; background: #000; overflow: hidden; touch-action: none; }
.visor-lienzo { position: absolute; inset: 0; display: grid; place-items: center; }
.visor img { max-width: 100%; max-height: 100%; transform-origin: 0 0; will-change: transform; }
.visor-cerrar {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px;
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.18); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.visor-ayuda { position: absolute; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); text-align: center; color: rgba(255,255,255,.75); font-size: .85rem; pointer-events: none; }

.tostada {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 40; max-width: calc(100% - 32px);
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 500; font-size: .92rem;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); animation: aparece .2s;
}

@media (min-width: 560px) {
  .cifras span { font-size: .78rem; }
}

/* ---------- escanear QR / PDF original ---------- */
.disparador.secundario {
  margin-top: 12px; padding: 18px 20px;
  display: flex; align-items: center; gap: 16px; text-align: left;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow);
}
.disparador.secundario svg { color: var(--green-deep); flex: none; }
.disparador.secundario .disparador-texto { font-size: 1.15rem; display: block; }
.disparador.secundario .disparador-sub { display: block; color: var(--text-soft); opacity: 1; font-size: .85rem; }

.mini-pdf {
  width: 56px; height: 56px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px; background: #fdecec; color: #c53030;
  font-family: var(--font-head); font-weight: 700; font-size: .9rem; letter-spacing: .04em;
  border: 1px solid rgba(197,48,48,.25);
}
.mini-pdf.grande { width: 84px; height: 100px; font-size: 1.2rem; border-radius: 12px; }
.previa-pdf { display: grid; place-items: center; padding: 24px 0 8px; }
.original {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; margin: 6px 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  color: var(--text); text-decoration: none;
}
.original:active { background: var(--surface-2); }
.campo-qr { margin-top: 12px; }
.campo-qr input { font-size: 16px; } /* menos de 16 px y el iPhone amplía al escribir */

.escaner { position: fixed; inset: 0; z-index: 35; background: #000; color: #fff; overflow: hidden; }
.escaner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.escaner-marco { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.escaner-marco span {
  width: min(72vw, 72vh); aspect-ratio: 1; border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
  border: 3px solid #56c271;
  animation: latido 1.6s ease-in-out infinite;
}
@keyframes latido { 50% { border-color: #fff; } }
.escaner-texto, .escaner-ayuda { position: absolute; left: 16px; right: 16px; text-align: center; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.escaner-texto { top: calc(28px + env(safe-area-inset-top)); font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; }
.escaner-ayuda { top: calc(64px + env(safe-area-inset-top)); font-size: .92rem; opacity: .9; }
.escaner-zoom {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 6px; border-radius: 99px; background: rgba(0,0,0,.45);
}
.escaner-zoom button { min-width: 48px; height: 40px; border-radius: 99px; color: #fff; font-weight: 700; }
.escaner-zoom button.activo { background: #fff; color: var(--text); }
.escaner-botones {
  position: absolute; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.escaner-botones .boton { background: rgba(255,255,255,.95); color: var(--text); border: 0; }

/* ---------- instalar ---------- */
.instalar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow);
}
.instalar img { width: 44px; height: 44px; border-radius: 11px; flex: none; }
.instalar div { flex: 1; display: grid; line-height: 1.3; }
.instalar b { font-size: .95rem; }
.instalar span { font-size: .82rem; color: var(--text-soft); }

/* Instalada (pantalla completa): sin bordes de navegador, la cabecera respira. */
@media (display-mode: standalone) {
  .cabecera { padding-top: calc(12px + env(safe-area-inset-top)); }
}
