/* Tipografía servida por la misma app (sin Google Fonts). Licencia: fonts/OFL-plus-jakarta-sans.txt */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans.woff2') format('woff2');
}

/* ==========================================================================
   Paleta de marca: AZUL 60% (fondos, estructura) · MAGENTA 30% (acciones, acentos) · BLANCO 10% (texto, detalles)
   ========================================================================== */
:root {
  --azul-950: #050d3a;
  --azul-900: #0a1a6b;
  --azul-850: #0c1c6e;
  --azul-800: #10268f;
  --azul-700: #1537d6;
  --azul-600: #2a4df0;
  --azul-400: #6f8bff;
  --azul-200: #c3cfff;
  --magenta-700: #a50f6b;
  --magenta-600: #c8157e;
  --magenta-500: #e0218a;
  --magenta-400: #e8479b;
  --magenta-200: #f8b8da;
  --violeta: #7b2ff7;
  --blanco: #ffffff;
  --texto: #ffffff;
  --texto-2: rgba(255, 255, 255, 0.78);
  --texto-3: rgba(255, 255, 255, 0.58);
  --superficie: rgba(255, 255, 255, 0.06);
  --superficie-2: rgba(255, 255, 255, 0.1);
  --borde: rgba(255, 255, 255, 0.14);
  --ok: #34d399;
  --alerta: #fbbf24;
  --error: #ff6b8a;
  --degradado: linear-gradient(120deg, var(--magenta-500) 0%, var(--violeta) 48%, var(--azul-700) 100%);
  --degradado-btn: linear-gradient(120deg, var(--magenta-500), #b61fd0);
  --radio: 18px;
  --radio-sm: 12px;
  --sombra: 0 10px 30px rgba(3, 8, 40, 0.45);
  --fuente: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: only dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--fuente);
  color: var(--texto);
  background: var(--azul-950);
  background-image:
    radial-gradient(1200px 600px at 110% -10%, rgba(224, 33, 138, 0.28), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(21, 55, 214, 0.55), transparent 60%),
    linear-gradient(180deg, var(--azul-900), var(--azul-950));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
a { color: var(--magenta-200); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .6em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--texto-3); }
.sub { color: var(--texto-2); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: 76px 1fr; min-height: 100vh; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px; background: rgba(5, 13, 58, 0.72); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 20;
}
.marca { display: flex; gap: 10px; align-items: center; color: var(--texto); text-decoration: none; min-width: 0; }
.marca img { height: 56px; width: auto; max-width: 160px; object-fit: contain; flex: none; }
.marca span { display: flex; flex-direction: column; min-width: 0; }
.marca strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marca small { color: var(--texto-3); font-size: .72rem; }
.topbar-der { display: flex; align-items: center; gap: 10px; }
.chip-demo {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 5px 10px; border-radius: 99px; background: rgba(224, 33, 138, .2); color: var(--magenta-200);
  border: 1px solid rgba(224, 33, 138, .45);
}
.perfil select { max-width: 260px; }
.btn-icono {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--superficie); border: 1px solid var(--borde); color: var(--texto); cursor: pointer;
}
.btn-icono:hover { background: var(--superficie-2); }
.punto-estado { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--texto-3); }
.punto-estado.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .2); }
.punto-estado.error { background: var(--error); }

.menu { position: sticky; top: 76px; height: calc(100vh - 76px); overflow-y: auto; padding: 18px 12px; border-right: 1px solid var(--borde); background: rgba(5, 13, 58, 0.35); }
.menu a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; margin-bottom: 4px; border-radius: 12px;
  color: var(--texto-2); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.menu a svg { width: 20px; height: 20px; flex: none; }
.menu a:hover { background: var(--superficie); color: var(--texto); }
.menu a.activo { background: var(--degradado-btn); color: var(--blanco); box-shadow: 0 6px 18px rgba(224, 33, 138, .35); }
.menu .titulo-menu { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--texto-3); padding: 8px 14px; }
.vista { padding: 28px clamp(16px, 3vw, 40px) 110px; max-width: 1200px; width: 100%; outline: none; overflow-wrap: break-word; }
/* Textos largos sin espacios (correos, números) no deben ensanchar la pantalla. */
.vista b, .vista .sub, .vista h2, .vista h3, .vista .dir, .vista .folio { overflow-wrap: anywhere; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 64px 1fr; }
  .marca img { height: 46px; max-width: 120px; }
  .topbar { padding: 0 12px; }
  .marca small, .chip-demo { display: none; }
  .menu {
    height: auto; top: auto;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--borde);
    background: rgba(5, 13, 58, 0.95); backdrop-filter: blur(14px);
  }
  .menu .titulo-menu, .menu a.solo-escritorio { display: none; }
  .solo-movil { display: revert !important; }
  .perfil-chip.solo-movil { display: inline-flex !important; }
  .solo-escritorio-top { display: none !important; }
  .menu button.solo-movil { display: flex !important; }
  .menu button { flex-direction: column; gap: 3px; font: inherit; font-size: .66rem; font-weight: 600; padding: 7px 6px; margin: 0;
    background: none; border: 0; color: var(--texto-2); border-radius: 12px; align-items: center; cursor: pointer; }
  .menu button svg { width: 20px; height: 20px; }
  /* Modales como hoja inferior, al estilo de una app */
  .modal-fondo { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 24px 24px 0 0; max-height: 92vh; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: subir .2s ease; }
  /* Botones del asistente siempre a mano, sobre la barra inferior. Los márgenes negativos son iguales al relleno
     de la tarjeta en el celular (16 px): con -20 px la barra sobresalía 4 px por cada lado. */
  .acciones-fijas { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 5; margin: 18px -16px -16px; padding: 12px 16px;
    background: rgba(10, 26, 107, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--borde); border-radius: 0 0 var(--radio) var(--radio); }
  .acciones-fijas .btn.grande { min-height: 52px; padding: 0 20px; }
  /* Atrás a la izquierda; a la derecha la tarifa encima de Continuar si no caben en una línea. */
  .acciones-fijas { flex-wrap: nowrap; }
  .acciones-fijas > .fila { justify-content: flex-end; row-gap: 4px; }
  /* Con el teclado abierto (clase puesta por app.js) la barra inferior tapaba el formulario: se oculta. */
  body.teclado .menu { display: none; }
  body.teclado .acciones-fijas { bottom: 0; }
  .encabezado { margin-bottom: 16px; }
  .hero { padding: 22px; border-radius: 20px; }
  .card { padding: 16px; }
  /* Avisos arriba: abajo tapaban los botones Atrás / Continuar del asistente. */
  body #toasts { left: 16px; right: 16px; top: calc(72px + env(safe-area-inset-top)); bottom: auto; max-width: none; }
  .paso { font-size: .68rem; }
  /* iOS acerca la pantalla al tocar un campo con letra menor a 16 px. */
  input, select, textarea { font-size: 16px; }
  /* El fondo no se desplaza detrás de una hoja abierta. */
  body:has(.modal-fondo) { overflow: hidden; }
  .menu a { flex-direction: column; gap: 3px; font-size: .66rem; padding: 7px 6px; margin: 0; text-align: center; }
  .vista { padding: 20px 16px 110px; }
}

/* Los hijos de grillas no deben ensanchar la página (tablas y gráficos en celular). */
.grid > *, .vista > *, .fila > * { min-width: 0; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--magenta-500); }

/* ---------- Solo celular / solo escritorio ---------- */
.solo-movil { display: none !important; }
.perfil-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px 0 4px; border-radius: 99px;
  background: var(--superficie-2); border: 1px solid var(--borde); color: var(--texto); font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer;
}
.perfil-chip .avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--degradado-btn); font-size: .8rem; }
.hoja-lista { display: grid; gap: 8px; }
.hoja-lista a, .hoja-lista button.item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--superficie);
  border: 1px solid var(--borde); color: var(--texto); text-decoration: none; font: inherit; font-weight: 600; text-align: left; width: 100%; cursor: pointer;
}
.hoja-lista a svg, .hoja-lista button.item svg { width: 22px; height: 22px; flex: none; }
.hoja-lista .activo { border-color: var(--magenta-400); background: rgba(224, 33, 138, .18); }
.hoja-titulo { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--texto-3); margin: 16px 0 8px; font-weight: 700; }
.banner-instalar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; margin-bottom: 16px;
  background: var(--blanco); color: var(--azul-900); box-shadow: var(--sombra); }
.banner-instalar img { width: 40px; height: 40px; border-radius: 10px; }
.banner-instalar div { flex: 1; font-size: .88rem; line-height: 1.3; }
.banner-instalar .btn { min-height: 38px; padding: 0 14px; font-size: .85rem; }
.banner-instalar .cerrar-banner { background: none; border: 0; color: var(--azul-900); font-size: 1.2rem; cursor: pointer; padding: 4px 6px; }

/* ---------- Componentes ---------- */
.card {
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 20px; box-shadow: var(--sombra);
}
.card + .card { margin-top: 16px; }
.card-titulo { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-titulo h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: 1fr; } }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.entre { justify-content: space-between; }
.pila > * + * { margin-top: 12px; }
.encabezado { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.encabezado p { margin: 0; color: var(--texto-2); }

.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: 28px; margin-bottom: 20px;
  background: var(--degradado); box-shadow: 0 18px 40px rgba(123, 47, 247, .35);
}
.hero::after {
  content: ''; position: absolute; inset: auto -60px -80px auto; width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); overflow-wrap: anywhere; }
.hero h1.folio-grande { font-size: clamp(1.5rem, 7.5vw, 2.4rem); }
.hero p { color: rgba(255, 255, 255, .9); max-width: 560px; }
.hero .fila { position: relative; z-index: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px;
  border-radius: 14px; border: 1px solid transparent; font: inherit; font-weight: 700; font-size: .95rem;
  cursor: pointer; text-decoration: none; transition: transform .08s ease, filter .15s ease, background .15s;
  color: var(--blanco); background: var(--degradado-btn); box-shadow: 0 8px 20px rgba(224, 33, 138, .35);
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn { white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); box-shadow: none; }
/* Secundarios más visibles (pedido 07-10, p. ej. "Etiqueta 80 mm"): fondo más claro, borde marcado y sombra. */
.btn.sec { background: rgba(255, 255, 255, .16); border: 1.5px solid rgba(248, 184, 218, .55); box-shadow: 0 4px 14px rgba(0, 0, 0, .28); }
.btn.sec:hover { background: rgba(255, 255, 255, .24); border-color: var(--magenta-200); filter: none; }
.btn.blanco { background: var(--blanco); color: var(--azul-900); box-shadow: 0 8px 20px rgba(0, 0, 0, .2); }
.btn.azul { background: var(--azul-700); box-shadow: 0 8px 20px rgba(21, 55, 214, .4); }
.btn.peligro { background: rgba(255, 107, 138, .22); border: 1.5px solid rgba(255, 107, 138, .7); color: #ffd1dc; box-shadow: none; }
.btn.grande { min-height: 58px; font-size: 1.05rem; border-radius: 16px; padding: 0 26px; }
.btn.chico { min-height: 36px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn.ancho { width: 100%; }

label.campo { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .86rem; color: var(--texto-2); }
label.campo small { font-weight: 500; color: var(--texto-3); }
input, select, textarea {
  font: inherit; color: var(--texto); background: rgba(255, 255, 255, .08); border: 1px solid var(--borde);
  border-radius: var(--radio-sm); padding: 11px 13px; min-height: 46px; width: 100%;
}
select option { color: #0a1a6b; background: #fff; }
textarea { min-height: 80px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--texto-3); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, .btn-icono:focus-visible {
  outline: 3px solid rgba(232, 71, 155, .55); outline-offset: 1px; border-color: var(--magenta-400);
}
.campo.invalido input, .campo.invalido select, .campo.invalido textarea { border-color: var(--error); background: rgba(255, 107, 138, .08); }
.error-campo { color: var(--error); font-size: .8rem; font-weight: 600; }
.interruptor { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.interruptor input { appearance: none; width: 48px; height: 28px; min-height: 0; padding: 0; border-radius: 99px; position: relative; cursor: pointer; flex: none; }
.interruptor input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--blanco); transition: left .15s; }
.interruptor input:checked { background: var(--magenta-500); border-color: var(--magenta-500); }
.interruptor input:checked::after { left: 23px; }

.segmentos { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 5px; border-radius: 16px; background: rgba(255, 255, 255, .06); border: 1px solid var(--borde); }
.segmentos button { font: inherit; font-weight: 700; color: var(--texto-2); background: transparent; border: 0; border-radius: 12px; padding: 12px 10px; cursor: pointer; }
.segmentos button.activo { background: var(--blanco); color: var(--azul-900); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: .76rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.e-borrador { background: rgba(255, 255, 255, .1); color: var(--texto-2); }
.e-creado { background: rgba(111, 139, 255, .18); color: var(--azul-200); border-color: rgba(111, 139, 255, .4); }
.e-asignado { background: rgba(123, 47, 247, .22); color: #d9c6ff; border-color: rgba(123, 47, 247, .5); }
.e-en_ruta { background: rgba(224, 33, 138, .2); color: var(--magenta-200); border-color: rgba(224, 33, 138, .5); }
.e-entregado { background: rgba(52, 211, 153, .16); color: #a7f3d0; border-color: rgba(52, 211, 153, .45); }
.e-fallido, .e-rechazado { background: rgba(255, 107, 138, .16); color: #ffc2cf; border-color: rgba(255, 107, 138, .45); }
.e-reagendado, .e-en_revision, .e-solicitado { background: rgba(251, 191, 36, .14); color: #fde68a; border-color: rgba(251, 191, 36, .45); }
.e-devuelto, .e-anulado { background: rgba(255, 255, 255, .08); color: var(--texto-3); border-color: var(--borde); }
.e-aprobado { background: rgba(111, 139, 255, .18); color: var(--azul-200); border-color: rgba(111, 139, 255, .4); }
.e-pagado { background: rgba(52, 211, 153, .16); color: #a7f3d0; border-color: rgba(52, 211, 153, .45); }
.e-pendiente { background: rgba(251, 191, 36, .14); color: #fde68a; border-color: rgba(251, 191, 36, .45); }
.e-en_revision { background: rgba(56, 189, 248, .15); color: #bae6fd; border-color: rgba(56, 189, 248, .45); }
.e-reembolsado { background: rgba(255, 255, 255, .08); color: var(--texto-3); border-color: var(--borde); }

.kpi { padding: 18px; border-radius: var(--radio); background: var(--superficie); border: 1px solid var(--borde); }
.kpi .etiqueta { color: var(--texto-3); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi .valor { font-size: clamp(1.4rem, 2.4vw, 1.9rem); font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .nota { color: var(--texto-2); font-size: .82rem; }
.kpi.destacado { background: var(--degradado); border: 0; }
.kpi.destacado .etiqueta, .kpi.destacado .nota { color: rgba(255, 255, 255, .88); }

.lista-envios { display: grid; gap: 10px; }
.item-envio {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; align-items: center; padding: 16px 18px;
  border-radius: 16px; background: var(--superficie); border: 1px solid var(--borde); color: var(--texto); text-decoration: none;
  transition: background .15s, border-color .15s, transform .08s;
}
.item-envio:hover { background: var(--superficie-2); border-color: rgba(232, 71, 155, .5); }
.item-envio .folio { font-weight: 800; font-variant-numeric: tabular-nums; }
/* El folio se lee de una vez: no se corta en "ENV-2026-" / "000983" cuando la tarjeta tiene etiquetas a la derecha. */
.vista .item-envio .folio { white-space: nowrap; overflow-wrap: normal; }
/* Textos que pueden ser largos dentro de una tabla (folios en los que se repitió un comprobante) sí pueden cortarse. */
td .ajustable { white-space: normal; display: inline-block; max-width: 260px; line-height: 1.35; }
.item-envio .dir { color: var(--texto-2); font-size: .9rem; }
.item-envio .der { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.item-envio .monto { font-weight: 800; font-variant-numeric: tabular-nums; }

.tabla-wrap { overflow-x: auto; border-radius: var(--radio-sm); border: 1px solid var(--borde); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { white-space: nowrap; text-align: left; padding: 11px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); vertical-align: middle; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-3); font-weight: 700; background: rgba(255, 255, 255, .04); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pasos { display: flex; gap: 8px; margin-bottom: 20px; }
.paso { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: .78rem; font-weight: 700; color: var(--texto-3); }
.paso::before { content: ''; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .14); }
.paso.hecho, .paso.actual { color: var(--texto); }
.paso.hecho::before { background: var(--azul-400); }
.paso.actual::before { background: var(--degradado-btn); }

.linea-tiempo { list-style: none; margin: 0; padding: 0; }
.linea-tiempo li { position: relative; padding: 0 0 18px 30px; }
.linea-tiempo li::before { content: ''; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: rgba(255, 255, 255, .14); }
.linea-tiempo li:last-child::before { display: none; }
.linea-tiempo li::after { content: ''; position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--azul-600); border: 3px solid var(--azul-900); box-shadow: 0 0 0 2px var(--azul-400); }
.linea-tiempo li:last-child::after { background: var(--magenta-500); box-shadow: 0 0 0 2px var(--magenta-400); }
.linea-tiempo .cuando { color: var(--texto-3); font-size: .8rem; }
/* Pasos del pago dentro del historial: punto verde para distinguirlos de los cambios de estado. */
.linea-tiempo li.pago::after { background: #10b981; box-shadow: 0 0 0 2px #6ee7b7; }
.linea-tiempo li.pago.rechazo::after, .linea-tiempo li.rechazo::after { background: #f43f5e; box-shadow: 0 0 0 2px #fda4af; }

.progreso-envio { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 16px 0 6px; }
.progreso-envio div { text-align: center; font-size: .72rem; font-weight: 700; color: var(--texto-3); }
.progreso-envio div::before { content: ''; display: block; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .14); margin-bottom: 8px; }
.progreso-envio div.on { color: var(--texto); }
.progreso-envio div.on::before { background: var(--degradado-btn); }

.foto-mini { width: 110px; height: 110px; object-fit: cover; border-radius: 12px; border: 1px solid var(--borde); background: rgba(0, 0, 0, .2); }
.intentos { display: inline-flex; gap: 5px; vertical-align: middle; }
.intentos i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--texto-3); }
.intentos i.usado { background: var(--error); border-color: var(--error); }

.aviso { padding: 12px 14px; border-radius: 12px; background: rgba(111, 139, 255, .14); border: 1px solid rgba(111, 139, 255, .35); color: var(--azul-200); font-size: .9rem; }
.aviso.magenta { background: rgba(224, 33, 138, .14); border-color: rgba(224, 33, 138, .4); color: var(--magenta-200); }
.aviso.alerta { background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .4); color: #fde68a; }
.aviso.ok { background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .4); color: #a7f3d0; }

.desglose { display: grid; gap: 8px; }
.desglose div { display: flex; justify-content: space-between; color: var(--texto-2); }
.desglose .total { border-top: 1px dashed var(--borde); padding-top: 10px; margin-top: 4px; color: var(--texto); font-weight: 800; font-size: 1.25rem; }

.cuenta-regresiva { width: 150px; height: 150px; margin: 6px auto; position: relative; }
.cuenta-regresiva svg { transform: rotate(-90deg); }
.cuenta-regresiva .tiempo { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.vacio { text-align: center; padding: 40px 20px; color: var(--texto-2); }
.vacio svg { width: 56px; height: 56px; opacity: .6; margin-bottom: 8px; }

/* Gráfico de barras */
.grafico { position: relative; }
.grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
.grafico .barra { fill: var(--magenta-400); }
.grafico .barra-hit { fill: transparent; cursor: pointer; }
.grafico .barra-hit:hover + .barra, .grafico .barra.hover { fill: #f06fb0; }
.grafico .eje { fill: var(--texto-3); font-size: 11px; font-family: var(--fuente); }
.grafico .grilla { stroke: rgba(255, 255, 255, .08); stroke-width: 1; }
.tooltip { position: absolute; pointer-events: none; background: var(--blanco); color: var(--azul-900); padding: 8px 10px; border-radius: 10px; font-size: .8rem; font-weight: 600; box-shadow: var(--sombra); transform: translate(-50%, -110%); white-space: nowrap; }
.ranking { display: grid; gap: 10px; }
.ranking .r { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: .88rem; }
.ranking .r .b { height: 10px; border-radius: 0 4px 4px 0; background: var(--magenta-400); }
.ranking .r .v { font-variant-numeric: tabular-nums; color: var(--texto-2); font-weight: 600; }

/* Modal y avisos */
.modal-fondo { position: fixed; inset: 0; z-index: 50; background: rgba(3, 8, 40, .72); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: aparecer .15s ease; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: linear-gradient(180deg, var(--azul-800), var(--azul-900)); border: 1px solid var(--borde); border-radius: 22px; padding: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.modal { position: relative; }
.modal .cerrar { position: absolute; top: 14px; right: 14px; z-index: 1; }
.modal-cuerpo > h2:first-child, .modal-cuerpo > .hoja-titulo:first-child { padding-right: 48px; }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes subir { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
#toasts { position: fixed; z-index: 60; right: 16px; bottom: 90px; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; }
.toast { padding: 13px 16px; border-radius: 14px; font-weight: 600; background: var(--blanco); color: var(--azul-900); box-shadow: var(--sombra); border-left: 5px solid var(--magenta-500); animation: aparecer .2s ease; }
.toast.error { border-left-color: var(--error); }
.toast.ok { border-left-color: var(--ok); }

.pasarela { background: var(--blanco); color: #1b1f3b; border-radius: 18px; padding: 20px; }
.pasarela input { background: #f3f5ff; color: #1b1f3b; border-color: #d6dcf5; }
.pasarela .monto { font-size: 2rem; font-weight: 800; color: var(--azul-900); }
.monto-grande { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cargando { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); border-top-color: var(--blanco); animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.esqueleto { height: 72px; border-radius: 16px; background: linear-gradient(90deg, var(--superficie), var(--superficie-2), var(--superficie)); background-size: 200% 100%; animation: brillo 1.2s infinite; }
@keyframes brillo { to { background-position: -200% 0; } }

/* ---------- Celular angosto ---------- */
@media (max-width: 640px) {
  /* Los botones largos ("Pagar $4.500 con transferencia (subir comprobante)") bajan de línea en vez de salirse de la
     pantalla y empujar toda la página hacia el lado. */
  .btn { white-space: normal; text-align: center; line-height: 1.25; padding-top: 8px; padding-bottom: 8px; }
  .hero .fila .btn { flex: 1 1 100%; }
  /* Tarjetas de envío: los estados y el monto van debajo, así el nombre y la dirección usan todo el ancho. */
  a.item-envio { grid-template-columns: minmax(0, 1fr); }
  a.item-envio .der { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; text-align: left; }
  /* Filtros de "Mis envíos": las dos fechas lado a lado y los botones del encabezado en una fila. */
  #filtros .grid .grid.g2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .encabezado > .fila .btn { flex: 1 1 auto; min-height: 42px; font-size: .88rem; padding-left: 14px; padding-right: 14px; }
  /* Pasos del asistente: solo se lee el nombre del paso actual (los nombres no caben y se montaban). */
  .paso:not(.actual) { font-size: 0; gap: 0; }
  .paso.actual { white-space: nowrap; }
}
.nowrap { white-space: nowrap; }
/* Opciones con radio dentro de una tarjeta (tamaño, destinatario, dirección): el título sí puede bajar de línea. */
.item-envio .titulo-item { font-weight: 800; }
/* Radios visibles sobre el fondo oscuro (antes un círculo gris oscuro casi invisible). */
input[type="radio"] {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; min-height: 22px; padding: 0; flex: none; cursor: pointer;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, .6); background: transparent;
}
input[type="radio"]:checked { border-color: var(--magenta-400); background: radial-gradient(circle, var(--magenta-500) 0 42%, transparent 48%); }
/* Campo de archivo con el estilo de la app (antes el botón gris del navegador y "No se h… archivo"). */
input[type="file"] { padding: 8px; font-size: .88rem; color: var(--texto-2); }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 700; color: var(--blanco); background: var(--superficie-2); border: 1px solid var(--borde);
  border-radius: 10px; padding: 8px 12px; margin-right: 10px; cursor: pointer;
}
.grupo-error { border-radius: 18px; outline: 2px solid var(--error); outline-offset: 4px; }
.desglose div { gap: 12px; }
.desglose b { text-align: right; overflow-wrap: anywhere; min-width: 0; }
.modal .pila > .btn, .modal form > .btn:last-child { width: 100%; }
/* Firma de quien recibió (entregas anteriores al 09-10; fondo blanco: se ve igual al imprimirla). */
.foto-mini.firma-mini { object-fit: contain; background: #fff; }
/* Escáner de QR */
.escaner { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; max-height: 60vh; }
.escaner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.escaner::after { content: ''; position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }
/* Botón "Copiar" junto a los datos de la transferencia */
.copiar { font: inherit; font-size: .78rem; font-weight: 700; color: var(--magenta-200); background: rgba(224, 33, 138, .14); border: 1px solid rgba(224, 33, 138, .45);
  border-radius: 8px; padding: 4px 10px; margin-left: 6px; cursor: pointer; vertical-align: middle; min-height: 30px; }
/* Volver más notorio (pedido 07-10): botón con borde, no un texto chico. */
.volver { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-bottom: 10px; font-size: 1rem; text-decoration: none; }
.campo, .item-envio { scroll-margin: 96px 0 170px; }

/* Tablas que en el celular se muestran como tarjetas */
@media (max-width: 640px) {
  .tabla-wrap:has(.tabla-cards) { border: 0; overflow: visible; }
  .tabla-cards thead { display: none; }
  .tabla-cards, .tabla-cards tbody { display: block; }
  .tabla-cards tr { display: block; padding: 14px 16px; margin-bottom: 10px; border-radius: 16px; background: var(--superficie); border: 1px solid var(--borde); }
  .tabla-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border: 0; white-space: normal; text-align: right; }
  .tabla-cards td::before { content: attr(data-label); color: var(--texto-3); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; text-align: left; }
  .tabla-cards td:last-child { padding-top: 10px; }
  .tabla-cards td[data-label="Acción"]:not(:has(button)) { display: none; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  body { background: #fff; color: #000; }
  .topbar, .menu, #toasts { display: none; }
}
#f-clave input::placeholder { color: #5a67a6; font-weight: 600; }

/* ---------- Inicio de sesión (AUTH_MODE=jwt) ---------- */
.modo-sesion .chip-demo, .modo-sesion .perfil { display: none !important; }
.modo-sesion #chip-perfil { display: inline-flex !important; }
.sin-sesion .shell { grid-template-columns: minmax(0, 1fr); }
.sin-sesion .menu { display: none; }
.sin-sesion #chip-perfil { display: none !important; }
/* Sin sesión el menú queda vacío: se quita su columna para que la tarjeta quede al centro de la pantalla. */
.shell:has(.login-caja) { grid-template-columns: minmax(0, 1fr); }
.shell:has(.login-caja) .menu { display: none; }
.shell:has(.login-caja) .vista { max-width: none; }
.login-caja { min-height: calc(100vh - 76px - 138px); display: grid; place-items: center; }
.login { width: min(430px, 100%); margin: 0; padding: 30px 26px; }
.login .logo { height: 96px; width: auto; max-width: 220px; object-fit: contain; border-radius: 16px; margin-bottom: 14px; }
.login h1 { margin: 0 0 4px; }
.login form { display: grid; gap: 14px; margin-top: 20px; }
.login .clave { position: relative; display: block; }
.login .clave input { padding-right: 96px; width: 100%; }
.login .ver-clave { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 0 12px; }
.login details { margin-top: 16px; color: var(--texto-2); font-size: .9rem; }
.login summary { cursor: pointer; font-weight: 600; }
.login .pie { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--borde); text-align: center; }
.cuenta-resumen { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--superficie); border: 1px solid var(--borde); }
.cuenta-resumen .avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--degradado-btn); font-weight: 800; flex: none; }
.cuenta-resumen div { min-width: 0; } .cuenta-resumen .sub { overflow-wrap: anywhere; }
/* Orden de la ruta del repartidor: flechas a la izquierda de cada parada */
.parada { display: flex; gap: 8px; align-items: stretch; }
.parada > .item-envio { flex: 1; min-width: 0; }
/* Celular: en la tarjeta de la ruta, el estado va debajo y el folio y la dirección usan todo el ancho. */
@media (max-width: 640px) {
  .parada > .item-envio { grid-template-columns: minmax(0, 1fr); }
  .parada > .item-envio .der { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; text-align: left; }
}
.flechas-ruta { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.flechas-ruta .btn-icono { width: 36px; height: 36px; font-size: .8rem; }
/* Flecha de orden de ruta sin efecto (primera o última parada de su sección). */
.flechas-ruta .btn-icono:disabled { opacity: .3; cursor: default; }
/* Orden de entrega en la ruta del repartidor (pedido 07-10): 1.º … último. */
.badge.orden-ruta { background: var(--degradado-btn); color: var(--blanco); font-weight: 800; }
/* Revisión de pagos (pedido 07-10): comprobante a la izquierda, envíos y cuadre del total a la derecha. */
.modal.ancho { width: min(1100px, 100%); }
.revision-pago { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 12px; }
.visor-comprobante { position: sticky; top: 0; display: grid; gap: 10px; }
.visor-comprobante img { width: 100%; max-height: 68vh; object-fit: contain; border-radius: 12px; background: rgba(255, 255, 255, .06); }
.visor-comprobante .vacio-pdf { display: grid; place-items: center; gap: 10px; min-height: 180px; border: 1px dashed var(--borde); border-radius: 12px; padding: 16px; text-align: center; }
.tabla-pago { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla-pago th, .tabla-pago td { padding: 7px 6px; border-bottom: 1px solid var(--borde); text-align: left; vertical-align: top; }
.tabla-pago td.num, .tabla-pago th.num { text-align: right; white-space: nowrap; }
.tabla-pago tfoot td { font-weight: 800; font-size: 1.05rem; border-bottom: 0; }
.cuadre { margin-top: 6px; padding: 10px 12px; border-radius: 12px; font-weight: 700; }
.cuadre.ok { background: rgba(52, 211, 153, .16); border: 1px solid rgba(52, 211, 153, .5); }
.cuadre.mal { background: rgba(255, 107, 138, .16); border: 1px solid rgba(255, 107, 138, .6); }
@media (max-width: 860px) { .revision-pago { grid-template-columns: minmax(0, 1fr); } .visor-comprobante { position: static; } }
/* Aviso de versión nueva publicada (pedido 07-10): arriba, sobre todo, hasta que se actualiza. */
.aviso-version { position: fixed; left: 50%; transform: translateX(-50%); top: calc(84px + env(safe-area-inset-top)); z-index: 60;
  width: min(560px, calc(100% - 32px)); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 14px; background: var(--degradado-btn); color: var(--blanco); box-shadow: 0 12px 30px rgba(0, 0, 0, .4); }
@media (max-width: 860px) { .aviso-version { top: calc(70px + env(safe-area-inset-top)); } }

/* ---------- Pedidos 09-10 ---------- */
/* Nombre completo en el chip de la cuenta: si no cabe, baja a dos líneas en vez de cortarse ("SOLO"). */
#chip-perfil { max-width: min(46vw, 220px); padding-top: 3px; padding-bottom: 3px; }
#chip-rol { min-width: 0; text-align: left; line-height: 1.15; font-size: .8rem; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#chip-perfil .avatar { flex: none; }
/* Inicio del cliente: cobertura bajo la descripción del servicio, en letra más pequeña. */
.hero p.cobertura { font-size: .82rem; font-weight: 600; opacity: .85; margin-top: -2px; position: relative; z-index: 1; }
/* Inicio de sesión: botones en vez de enlaces subrayados; el seguimiento destaca en blanco. */
.acciones-login { display: grid; gap: 10px; }
.acciones-login .btn { min-height: 48px; }
/* Soporte */
.card.ayuda { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.card.ayuda h2 { margin-bottom: 2px; }
.card.ayuda p { margin: 0; }
.texto-mensaje { white-space: pre-line; margin: 6px 0 0; }
.respuesta-soporte { white-space: pre-line; margin-top: 12px; padding: 10px 12px; border-radius: 12px; border-left: 4px solid var(--magenta-400); background: rgba(224, 33, 138, .1); }
.respuesta-soporte .muted { white-space: normal; font-size: .8rem; margin-bottom: 4px; }
.menu a, .menu button { position: relative; }
.contador { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--magenta-500); color: var(--blanco);
  font-size: .72rem; font-weight: 800; display: inline-grid; place-items: center; margin-left: auto; }
.contador[hidden] { display: none; }
@media (max-width: 860px) { .menu .contador { position: absolute; top: 2px; right: 50%; margin: 0 -22px 0 0; } }
.hoja-lista .contador { margin-left: auto; }
@media (max-width: 640px) { .segmentos.desplazable { grid-auto-columns: max-content; overflow-x: auto; } }
/* Seguimiento: foto del paquete bajo "Creado" y acceso a soporte. */
.foto-seguimiento { margin-top: 10px; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .06); border: 1px solid var(--borde); }
.foto-seguimiento svg { width: 20px; height: 20px; }
.foto-paquete { display: block; width: 100%; max-height: 420px; object-fit: contain; margin-top: 10px; border-radius: 12px; background: rgba(0, 0, 0, .25); }
.ayuda-seguimiento { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--borde); }
/* Entrega del repartidor: la foto es un recuadro grande que se nota (antes se perdía en la pantalla). */
.foto-entrega { display: grid; justify-items: center; gap: 4px; padding: 22px 16px; border-radius: 18px; cursor: pointer; text-align: center;
  border: 2px dashed var(--magenta-400); background: rgba(224, 33, 138, .14); color: var(--texto); }
.foto-entrega:focus-within { outline: 3px solid var(--magenta-200); outline-offset: 2px; }
.foto-entrega .icono-foto { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--degradado-btn); box-shadow: 0 8px 20px rgba(224, 33, 138, .35); }
.foto-entrega .icono-foto svg { width: 32px; height: 32px; }
.foto-entrega b { font-size: 1.1rem; }
.foto-entrega small { color: var(--texto-2); }
.foto-entrega img { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; margin-top: 8px; }
.foto-entrega.lista { border-style: solid; border-color: rgba(52, 211, 153, .6); background: rgba(52, 211, 153, .1); }
.foto-entrega.lista .icono-foto { display: none; }
.foto-entrega.falta { border-color: var(--error); background: rgba(255, 107, 138, .12); }

/* Bolsas de envío (pedido 11-10): casillas numéricas dentro de las tablas de pedido y de precios. */
.cantidad-bolsa, .celda-num { max-width: 110px; min-height: 38px; text-align: right; }
.cantidad-bolsa { max-width: 76px; }
.tabla-bolsas th, .tabla-bolsas td { padding: 10px 8px; }
.tabla-bolsas td:first-child { white-space: normal; }

/* Arranque de la app (pedido 13-10): pantalla de carga en vez de los textos de relleno. */
.iniciando .shell { grid-template-columns: minmax(0, 1fr); }
.iniciando .menu { display: none; }
.iniciando .topbar-der { visibility: hidden; }
.iniciando:not(.marca-lista) .marca { visibility: hidden; }
.pantalla-carga { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--texto-2); animation: aparecer .4s ease .15s both; }
.pantalla-carga img { width: 88px; height: 88px; border-radius: 22px; object-fit: contain; background: var(--blanco); padding: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); }
.pantalla-carga .cargando { width: 26px; height: 26px; }
.pantalla-carga p { margin: 0; font-weight: 600; }

/* Soporte como conversación (pedido 13-10): burbujas de chat, notas internas y fotos adjuntas. */
.hilo { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.burbuja { max-width: min(560px, 88%); padding: 10px 14px; border-radius: 16px; background: var(--superficie-2); border: 1px solid var(--borde); }
.burbuja.propio { align-self: flex-end; background: rgba(224, 33, 138, .16); border-color: rgba(224, 33, 138, .4); border-bottom-right-radius: 4px; }
.burbuja.otro { align-self: flex-start; border-bottom-left-radius: 4px; }
.burbuja.interna { background: rgba(251, 191, 36, .12); border: 1px dashed rgba(251, 191, 36, .6); }
.burbuja .meta { font-size: .78rem; color: var(--texto-3); }
.burbuja .texto-mensaje { margin-top: 4px; overflow-wrap: anywhere; }
.adjunto-img { display: block; margin-top: 8px; padding: 0; border: 0; background: none; cursor: zoom-in; }
.adjunto-img img { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; background: rgba(255, 255, 255, .06); min-width: 80px; min-height: 60px; }
.caso-soporte { color: inherit; text-decoration: none; }
.caso-soporte.sin-leer { border-color: rgba(224, 33, 138, .6); box-shadow: 0 0 0 1px rgba(224, 33, 138, .35); }
.caso-soporte .der { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
