:root {
    --marca: #e60000;
    --marca-oscura: #b80000;
    --marca-suave: #fff1f1;
    --marca-halo: rgba(230, 0, 0, .22);
    --marca-texto: #ffffff;
    --tinta: #151515;
    --tinta-2: #5b5b63;
    --linea: #ececf0;
    --fondo: #f5f5f7;
    --verde: #1f9d55;
    --ambar: #e08a00;
    --gris: #8a8a93;
    --sombra: 0 10px 30px rgba(20, 20, 30, .16);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--tinta);
    background: var(--fondo);
    overflow: hidden;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
.oculto { display: none !important; }

#vista { position: fixed; inset: 0; background: #e9e9ee; }
#mapa { position: absolute; inset: 0; z-index: 1; }
.leaflet-container { font-family: inherit; background: #e9e9ee; }
.leaflet-control-attribution { font-size: 10px !important; }

/* barra superior */
.barra-superior {
    position: absolute; z-index: 500; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top));
    display: flex; gap: 10px; align-items: center; pointer-events: none;
}
.barra-superior > * { pointer-events: auto; }
.chip {
    background: #fff; border-radius: 23px; height: 46px; padding: 0 16px 0 10px; box-shadow: var(--sombra);
    display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; min-width: 0;
}
.chip img { height: 28px; max-width: 90px; object-fit: contain; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.guia { padding-left: 14px; color: var(--tinta-2); flex: none; }
.barra-superior .chip:first-child { flex: 0 1 auto; }
@media (max-width: 480px) { .chip img + span { display: none; } .chip { padding-right: 12px; } }
.chip.guia b { color: var(--tinta); }
.espacio { flex: 1; }
.btn-redondo {
    width: 46px; height: 46px; border-radius: 50%; background: #fff; box-shadow: var(--sombra);
    display: grid; place-items: center; font-size: 17px; flex: none;
}

/* hoja inferior */
.hoja {
    position: absolute; z-index: 600; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
    background: #fff; border-radius: 24px 24px 0 0; box-shadow: 0 -8px 30px rgba(20, 20, 30, .18);
    padding: 0 18px calc(18px + env(safe-area-inset-bottom));
    max-height: 56vh; display: flex; flex-direction: column;
    transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.agarre { padding: 10px 0 8px; display: grid; place-items: center; cursor: grab; touch-action: none; flex: none; }
.agarre::before { content: ""; width: 44px; height: 5px; border-radius: 3px; background: #d6d6dc; }
.hoja-scroll { overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; scrollbar-width: none; }
.hoja-scroll::-webkit-scrollbar { display: none; }

.estado-fila { display: flex; align-items: center; gap: 14px; }
.estado-icono {
    width: 52px; height: 52px; border-radius: 16px; background: var(--marca-suave); color: var(--marca);
    display: grid; place-items: center; font-size: 22px; flex: none;
}
.estado-icono.ok { background: #e8f7ee; color: var(--verde); }
.estado-icono.aviso { background: #fff4e0; color: var(--ambar); }
.estado-icono.malo { background: #f1f1f3; color: var(--gris); }
.estado-texto { min-width: 0; flex: 1; }
.estado-texto h2 { font-size: 20px; font-weight: 800; line-height: 1.2; }
.estado-texto p { font-size: 14px; color: var(--tinta-2); margin-top: 3px; line-height: 1.35; }

/* hora de llegada */
.llegada {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 16px; padding: 14px 16px; border-radius: 18px; background: var(--marca-suave);
}
.llegada small { display: block; font-size: 12px; font-weight: 700; color: var(--tinta-2); text-transform: uppercase; letter-spacing: .4px; }
.llegada b { font-size: 34px; font-weight: 800; line-height: 1.05; color: var(--marca); }
.llegada .faltan { text-align: right; font-size: 15px; font-weight: 700; }
.llegada .faltan span { display: block; font-size: 12px; color: var(--tinta-2); font-weight: 600; margin-top: 2px; }

/* progreso */
.progreso { display: flex; align-items: flex-start; margin: 18px 0 6px; }
.paso { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; text-align: center; }
.paso::before { content: ""; position: absolute; top: 11px; right: 50%; width: 100%; height: 4px; background: var(--linea); z-index: 0; }
.paso:first-child::before { display: none; }
.paso .punto {
    width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 4px solid var(--linea);
    z-index: 1; display: grid; place-items: center; font-size: 10px; color: var(--marca-texto); transition: all .4s;
}
.paso small { font-size: 11px; font-weight: 600; color: var(--gris); margin-top: 6px; line-height: 1.15; }
.paso.hecho::before { background: var(--marca); }
.paso.hecho .punto { background: var(--marca); border-color: var(--marca); }
.paso.hecho small { color: var(--tinta); }
.paso.actual .punto { border-color: var(--marca); box-shadow: 0 0 0 5px var(--marca-halo); }
.paso.actual::before { background: var(--marca); }
.paso.actual small { color: var(--marca); }

.banda-vivo {
    display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--tinta-2);
    background: var(--fondo); border-radius: 12px; padding: 9px 12px; margin-top: 14px;
}
.banda-vivo .luz { width: 9px; height: 9px; border-radius: 50%; background: var(--verde); animation: latido 1.6s infinite; flex: none; }
.banda-vivo.sin .luz { background: var(--gris); animation: none; }
@keyframes latido { 0% { box-shadow: 0 0 0 0 rgba(31, 157, 85, .5); } 100% { box-shadow: 0 0 0 10px rgba(31, 157, 85, 0); } }

.tarjeta-chofer { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px; border: 1.5px solid var(--linea); border-radius: 18px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--marca); color: var(--marca-texto); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.chofer-datos { flex: 1; min-width: 0; }
.chofer-datos small { color: var(--tinta-2); font-size: 12px; font-weight: 600; }
.chofer-datos b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acciones { display: flex; gap: 8px; }
.acciones a { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; font-size: 18px; color: #fff; }
.acciones .llamar { background: var(--tinta); }
.acciones .wsp { background: #25d366; }

.punto-propio { display: flex; gap: 12px; padding: 12px 0 0; margin-top: 12px; border-top: 1px solid var(--linea); align-items: flex-start; }
.punto-propio i { width: 20px; text-align: center; color: var(--marca); margin-top: 3px; }
.punto-propio small { display: block; font-size: 12px; color: var(--tinta-2); font-weight: 600; }
.punto-propio span { font-size: 15px; font-weight: 600; }

/* marcadores */
.mk-chofer { position: relative; width: 52px; height: 52px; }
.mk-chofer .halo { position: absolute; inset: 0; border-radius: 50%; background: var(--marca-halo); animation: onda 2s infinite; }
.mk-chofer .cuerpo {
    position: absolute; inset: 6px; border-radius: 50%; background: var(--marca); color: var(--marca-texto); border: 3px solid #fff;
    display: grid; place-items: center; font-size: 17px; box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}
.mk-chofer.tenue { opacity: .55; }
@keyframes onda { 0% { transform: scale(.55); opacity: .9; } 100% { transform: scale(1.25); opacity: 0; } }
.mk-destino { display: flex; flex-direction: column; align-items: center; transform: translateX(-50%); margin-left: 5px; }
.mk-destino .globo { background: var(--tinta); color: #fff; border-radius: 12px; padding: 6px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); display: flex; gap: 6px; align-items: center; }
.mk-destino .pico { width: 0; height: 0; border: 7px solid transparent; border-top-color: var(--tinta); margin-top: -1px; }

/* página de enlace vencido */
.centro { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; }
.centro .caja { background: #fff; border-radius: 24px; padding: 32px 24px; box-shadow: var(--sombra); max-width: 380px; }
.centro img { height: 44px; margin-bottom: 16px; }
.centro h1 { font-size: 22px; margin-bottom: 8px; }
.centro p { color: var(--tinta-2); line-height: 1.4; }

@media (min-width: 900px) {
    .hoja { left: 20px; right: auto; bottom: 20px; margin: 0; border-radius: 24px; width: 420px; max-height: calc(100vh - 100px); }
    .barra-superior { left: 20px; right: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- casa del cliente (siempre roja) ---- */
.mk-destino.casa .globo { background: #d32f2f; }
.mk-destino.casa .pico { border-top-color: #d32f2f; }

/* ---- contacto ---- */
.btn-contacto { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; border-radius: 16px; font-weight: 800; font-size: 16px; text-decoration: none; color: #fff; background: #25d366; padding: 0 16px; text-align: center; }
.btn-contacto { margin-top: 14px; background: var(--fondo); color: var(--tinta); font-size: 15px; font-weight: 700; }
.btn-contacto i { color: #1fa855; font-size: 20px; }

/* ---- calificación ---- */
.calif { margin-top: 16px; padding: 14px; border: 1.5px solid var(--linea); border-radius: 18px; display: grid; gap: 10px; }
.calif b { font-size: 16px; }
.calif textarea { width: 100%; min-height: 72px; border: 1.5px solid var(--linea); border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 15px; resize: vertical; background: #fafafc; }
.estrellas { display: flex; gap: 6px; }
.estrellas button { font-size: 30px; line-height: 1; color: #d6d6dc; padding: 4px; background: none; }
.estrellas button.on, .estrellas.fija i.on { color: #f5a623; }
.estrellas.fija i { font-size: 24px; color: #d6d6dc; }
.btn-enviar { height: 48px; border-radius: 14px; background: var(--marca); color: var(--marca-texto); font-weight: 800; font-size: 15px; }
.btn-enviar:disabled { opacity: .45; }
.cal-error { color: #b00020; font-size: 13px; font-weight: 600; }
.cal-nota { color: var(--tinta-2); font-size: 13px; line-height: 1.45; }
.cal-nota i { color: #f5a623; margin-right: 4px; }

/* botón actualizar */
#btnActualizar:disabled { cursor: default; opacity: .75; }
#btnActualizar.girando i { animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #btnActualizar.girando i { animation: none; } }

/* ---- registrar la ubicación desde la página ---- */
.ubicar { margin-top: 14px; display: grid; gap: 8px; }
.pila { display: grid; gap: 8px; }
.cambiar { margin-top: 12px; }
.cambiar.oculto { display: none; }
.pila small { color: var(--tinta-2); font-size: 14px; line-height: 1.4; }
.btn-pri, .btn-sec { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; border-radius: 16px; font-weight: 800; font-size: 16px; padding: 0 16px; width: 100%; }
.btn-pri { background: var(--marca); color: var(--marca-texto); }
.btn-pri:disabled { opacity: .45; cursor: default; }
.btn-sec { background: var(--fondo); color: var(--tinta); font-weight: 700; font-size: 15px; }
.btn-sec i { color: var(--tinta-2); }
.campo { width: 100%; height: 50px; border: 1.5px solid var(--linea); border-radius: 14px; padding: 0 14px; font: inherit; font-size: 16px; background: #fafafc; }
