/* ════════════════════════════════════════════════════════════════════
   MODO DE REPARTO — gestión de rutas
   Botón que sustituye al de "Reparto automatizado" (que pasa dentro),
   cabecera sobre el mapa, panel de vehículos a la derecha, marcadores
   grandes del día y pequeños del día siguiente, rutas dibujadas.
   ════════════════════════════════════════════════════════════════════ */
:root { --mr-ancho: 400px; --mr-anim: .42s cubic-bezier(.22, .9, .3, 1); }

/* ── El botón de entrada (donde estaba el de reparto automatizado) ── */
.mr-boton {
    position: absolute; top: 118px; right: 10px; z-index: 1000;
    display: flex; align-items: center; gap: 8px;
    padding: 9px 15px 9px 12px; border: none; border-radius: 999px;
    background: linear-gradient(135deg, #0f766e 0%, #0891b2 55%, #0ea5e9 100%);
    color: #fff; font-family: 'Segoe UI', Arial, sans-serif; font-size: 13.5px; font-weight: 600;
    cursor: pointer; box-shadow: 0 4px 14px rgba(8, 145, 178, .38); transition: transform .18s, box-shadow .18s;
}
.mr-boton:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(8, 145, 178, .5); }
body.mr-activo .mr-boton, body.mr-activo .view-controls { display: none !important; }
/* El de reparto automatizado ya no flota: vive en la cabecera del modo */
#raBoton { display: none; }
#mrCabecera #raBoton { display: inline-flex; position: static; box-shadow: none; padding: 7px 12px 7px 9px; font-size: 12.5px; }

/* ── Transición: el panel de pedidos se pliega, el de reparto entra ── */
.sidebar { transition: width var(--mr-anim), min-width var(--mr-anim); }
body.mr-activo .sidebar { width: 0 !important; min-width: 0 !important; overflow: hidden; box-shadow: none; }
body.mr-activo .sidebar-resizer { display: none; }
#mrPanel {
    width: 0; min-width: 0; overflow: hidden; background: #fff; border-left: 1px solid #e2e8f0;
    display: flex; flex-direction: column; transition: width var(--mr-anim), min-width var(--mr-anim);
    font-family: 'Segoe UI', Arial, sans-serif; color: #0f172a; z-index: 900; position: relative;
}
body.mr-activo #mrPanel { width: var(--mr-ancho); min-width: var(--mr-ancho); }
.mr-flash {
    position: absolute; inset: 0; z-index: 1200; pointer-events: none;
    background: radial-gradient(circle at 50% 50%, rgba(14, 165, 233, .35), rgba(15, 118, 110, .55));
    animation: mr-wipe .7s ease-out forwards;
}
@keyframes mr-wipe { from { clip-path: circle(0 at 50% 50%); opacity: 1; } 60% { opacity: .6; } to { clip-path: circle(140% at 50% 50%); opacity: 0; } }

/* ── Cabecera sobre el mapa ── */
#mrCabecera {
    position: absolute; top: 12px; left: 14px; right: 74px; z-index: 1001;
    display: none; grid-template-columns: auto 1fr; align-items: center; gap: 6px 10px;
    padding: 8px 12px; border-radius: 14px; background: rgba(255, 255, 255, .96);
    box-shadow: 0 8px 28px rgba(15, 23, 42, .18); backdrop-filter: blur(6px);
    font-family: 'Segoe UI', Arial, sans-serif; transform: translateY(-140%); opacity: 0;
    transition: transform var(--mr-anim), opacity .3s;
}
body.mr-activo #mrCabecera { display: grid; transform: none; opacity: 1; }
/* Lo que flota sobre el mapa se aparta: la barra de FLORE se oculta y la
   hamburguesa se queda en el borde del mapa, no encima del panel */
body.mr-activo .pr-barra-busqueda { display: none !important; }
body.mr-activo .hamburger-menu { right: calc(var(--mr-ancho) + 10px) !important; }
.mr-fecha { display: flex; align-items: center; gap: 4px; }
.mr-fecha button { border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; width: 30px; height: 32px; cursor: pointer; color: #334155; }
.mr-fecha button:hover { background: #f1f5f9; }
.mr-fecha input { border: 1px solid #cbd5e1; border-radius: 8px; padding: 5px 8px; font-family: inherit; font-size: 13px; height: 32px; box-sizing: border-box; }
.mr-fecha .mr-fecha-larga { font-weight: 700; font-size: 13.5px; margin-left: 6px; color: #0f172a; white-space: nowrap; }
.mr-fecha .mr-atajo { font-size: 11.5px; color: #0891b2; background: #ecfeff; border: 1px solid #a5f3fc; border-radius: 999px; padding: 2px 8px; cursor: pointer; }
.mr-cifras { display: flex; gap: 14px; grid-column: 1 / -1; padding-top: 4px; border-top: 1px solid #eef2f7; }
.mr-cifra { display: flex; flex-direction: column; align-items: center; min-width: 46px; }
.mr-cifra b { font-size: 16px; line-height: 1; } .mr-cifra span { font-size: 10px; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
.mr-cifra.mala b { color: #dc2626; } .mr-cifra.aviso b { color: #d97706; }
.mr-acciones { justify-self: end; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.mr-btn {
    display: inline-flex; align-items: center; gap: 6px; border: 1px solid #cbd5e1; background: #fff; color: #0f172a;
    border-radius: 999px; padding: 7px 12px; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: background .15s, transform .15s;
}
.mr-btn:hover { background: #f1f5f9; transform: translateY(-1px); }
.mr-btn.primario { background: #0091d8; border-color: #0091d8; color: #fff; } .mr-btn.primario:hover { background: #007bb8; }
.mr-btn.salir { color: #b91c1c; border-color: #fecaca; background: #fff5f5; }
.mr-btn.activo { background: #0f766e; border-color: #0f766e; color: #fff; }

/* ── Panel derecho ── */
.mr-panel-cab { padding: 12px 14px 8px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 8px; }
.mr-panel-cab h3 { margin: 0; font-size: 14px; flex: 1; }
.mr-tabs { display: flex; background: #f1f5f9; border-radius: 999px; padding: 3px; }
.mr-tabs button { border: 0; background: transparent; padding: 5px 11px; border-radius: 999px; font-family: inherit; font-size: 12px; font-weight: 600; color: #475569; cursor: pointer; }
.mr-tabs button.activo { background: #fff; color: #0f172a; box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.mr-panel-cuerpo { flex: 1; overflow-y: auto; padding: 10px 12px 24px; }
.mr-seccion { margin-bottom: 14px; }
.mr-seccion > h4 { margin: 8px 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: #64748b; display: flex; align-items: center; gap: 6px; }
.mr-seccion > h4 b { background: #e2e8f0; color: #0f172a; border-radius: 999px; padding: 0 7px; font-size: 11px; }
.mr-vacio { font-size: 12px; color: #94a3b8; padding: 6px 2px; }

.mr-tarjeta { border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; margin-bottom: 8px; overflow: hidden; transition: box-shadow .15s, border-color .15s; }
.mr-tarjeta.taller { opacity: .55; background: #f8fafc; }
.mr-tarjeta.recibe { border-color: #0891b2; box-shadow: 0 0 0 3px rgba(8, 145, 178, .2); }
.mr-tarjeta-cab { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #f8fafc; border-bottom: 1px solid #eef2f7; }
.mr-tarjeta-cab .mr-mat { font-weight: 800; font-size: 14px; letter-spacing: .02em; }
.mr-tarjeta-cab .mr-clase { font-size: 10.5px; color: #64748b; text-transform: uppercase; }
.mr-tarjeta-cab .mr-desc { font-size: 11.5px; color: #475569; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-tarjeta-cab .mr-punto { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; border: 2px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; }
.mr-etiq { font-size: 10.5px; border-radius: 999px; padding: 1px 7px; background: #e2e8f0; color: #334155; white-space: nowrap; }
.mr-etiq.taller { background: #fee2e2; color: #991b1b; }
.mr-etiq.libre { background: #dcfce7; color: #166534; }
.mr-viaje { padding: 8px 10px; border-top: 1px dashed #e2e8f0; }
.mr-viaje:first-of-type { border-top: 0; }
.mr-viaje-cab { display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin-bottom: 6px; flex-wrap: wrap; }
.mr-viaje-cab .mr-cond { font-weight: 700; }
.mr-viaje-cab .mr-hora { border: 1px solid #cbd5e1; border-radius: 6px; font-family: inherit; font-size: 11.5px; padding: 1px 4px; }
.mr-viaje-cab .mr-km { margin-left: auto; font-size: 11px; color: #64748b; }
.mr-barras { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 4px 0 6px; }
.mr-barra { font-size: 11px; color: #334155; }
.mr-barra-fondo { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin-top: 2px; }
.mr-barra-relleno { height: 100%; background: #16a34a; transition: width .35s; }
.mr-barra-relleno.naranja { background: #d97706; } .mr-barra-relleno.roja { background: #dc2626; }
.mr-aviso { font-size: 11px; color: #92400e; background: #fef3c7; border: 1px solid #fde68a; border-radius: 6px; padding: 3px 7px; margin: 3px 0; }
.mr-paradas { list-style: none; margin: 0; padding: 0; }
.mr-parada {
    display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 8px; font-size: 12px; cursor: grab;
    border: 1px solid transparent; transition: background .12s;
}
.mr-parada:hover { background: #f0f9ff; }
.mr-parada.recibe { border-color: #0891b2; background: #ecfeff; }
.mr-parada.seleccionado { background: #fef9c3; border-color: #fde047; }
.mr-parada .mr-n { width: 20px; height: 20px; border-radius: 50%; background: #0f172a; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mr-parada .mr-nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-parada .mr-nom small { display: block; color: #64748b; font-size: 10.5px; }
.mr-parada .mr-kg { font-size: 11px; color: #475569; white-space: nowrap; }
.mr-parada .mr-x { border: 0; background: transparent; color: #94a3b8; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.mr-parada .mr-x:hover { color: #b91c1c; background: #fee2e2; }
.mr-parada .mr-al { color: #d97706; }
.mr-parada.manana { opacity: .7; } .mr-parada.manana .mr-n { background: #94a3b8; }
.mr-parada.ayer .mr-n { background: #b91c1c; }
.mr-parada.arrastrando { opacity: .4; }
.mr-parada .mr-traer { border: 1px solid #a5f3fc; background: #ecfeff; color: #0e7490; border-radius: 999px; font-size: 10.5px; padding: 1px 7px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.mr-parada .mr-traer:hover { background: #cffafe; }
.mr-soltar { border: 2px dashed #cbd5e1; border-radius: 10px; padding: 8px; text-align: center; font-size: 11.5px; color: #94a3b8; margin: 6px 10px 10px; }
.mr-tarjeta.recibe .mr-soltar { border-color: #0891b2; color: #0e7490; background: #ecfeff; }
.mr-elegir { padding: 8px 10px; background: #f0f9ff; border-top: 1px solid #bae6fd; display: grid; gap: 6px; font-size: 12px; }
.mr-elegir label { display: grid; gap: 2px; color: #334155; font-size: 11px; }
.mr-elegir select, .mr-elegir input { border: 1px solid #cbd5e1; border-radius: 6px; padding: 5px 6px; font-family: inherit; font-size: 12px; }
.mr-elegir .mr-elegir-botones { display: flex; gap: 6px; justify-content: flex-end; }
.mr-elegir .mr-elegir-pedido { font-weight: 600; }
.mr-selec-aviso { position: sticky; top: 0; z-index: 2; background: #fef9c3; border: 1px solid #fde047; border-radius: 8px; padding: 6px 8px; font-size: 12px; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.mr-selec-aviso button { margin-left: auto; border: 0; background: transparent; cursor: pointer; color: #713f12; }
.mr-cond-tarjeta .mr-tarjeta-cab { background: #f5f3ff; }

/* ── Marcadores ── */
.mr-pin-icono { background: none !important; border: 0 !important; }
.mr-pin {
    --c: #0f172a; position: relative; width: 40px; height: 40px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    background: var(--c); border: 3px solid #fff; box-shadow: 0 6px 16px rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center;
    transition: transform .15s; cursor: grab;
}
.mr-pin:hover { transform: rotate(-45deg) scale(1.12); }
.mr-pin .mr-pin-n { transform: rotate(45deg); color: #fff; font: 800 15px/1 'Segoe UI', Arial, sans-serif; text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.mr-pin-conjunto { display: flex; flex-direction: column; align-items: center; width: 40px; height: 72px; justify-content: flex-end; }
.mr-pin-conjunto .mr-pin { flex-shrink: 0; margin: 0 0 6px; }
.mr-pin-conjunto .mr-pin-kg {
    white-space: nowrap; display: flex; flex-direction: column; align-items: center; line-height: 1.15; margin-bottom: 4px;
    background: #fff; color: #0f172a; font: 700 10px 'Segoe UI', Arial, sans-serif; padding: 2px 6px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.mr-pin-conjunto .mr-pin-kg i { font-style: normal; font-weight: 600; font-size: 9px; color: #475569; }
.mr-pin.mr-pin-alerta::after { content: '!'; position: absolute; right: -8px; bottom: -6px; transform: rotate(45deg); width: 16px; height: 16px; border-radius: 50%; background: #dc2626; color: #fff; font: 800 11px/16px 'Segoe UI', Arial, sans-serif; text-align: center; border: 2px solid #fff; }
.mr-pin.mr-pin-selec { outline: 3px solid #facc15; outline-offset: 2px; }
.mr-pin-manana { width: 20px; height: 20px; border: 2px dashed #fff; opacity: .45; box-shadow: 0 2px 6px rgba(15, 23, 42, .35); filter: saturate(.6); }
.mr-pin-manana .mr-pin-n { font-size: 9px; }
.mr-pin-manana:hover { opacity: .95; }
.mr-pin-realizado { opacity: .5; filter: grayscale(.8); }
.mr-km-etiqueta { background: rgba(255, 255, 255, .92); border: 0; border-radius: 999px; padding: 1px 7px; font: 700 11px 'Segoe UI', Arial, sans-serif; color: #0f172a; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.mr-km-etiqueta::before { display: none; }

@media (max-width: 900px) {
    :root { --mr-ancho: 100%; }
    #mrCabecera { right: 14px; }
    body.mr-activo .map-container { display: none; }
}

/* ── La ficha del pedido (ventana del marcador) ── */
.mr-popup .leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .25); padding: 0; }
.mr-popup .leaflet-popup-content { margin: 0; width: auto !important; font-family: 'Segoe UI', Arial, sans-serif; color: #0f172a; }
.mr-ficha { padding: 12px 14px 12px; font-size: 12.5px; }
.mr-ficha-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; border-left: 4px solid #0f172a; padding-left: 8px; margin-bottom: 8px; }
.mr-ficha-cab b { font-size: 14px; display: block; } .mr-ficha-cab small { color: #64748b; display: block; }
.mr-ficha-fila { display: flex; gap: 8px; align-items: flex-start; margin: 3px 0; line-height: 1.3; }
.mr-ficha-fila i { width: 14px; text-align: center; color: #94a3b8; margin-top: 2px; }
.mr-ficha-fila a { color: #0891b2; text-decoration: none; font-weight: 600; }
.mr-ficha-art { list-style: none; margin: 8px 0 4px; padding: 6px 8px; background: #f8fafc; border-radius: 8px; }
.mr-ficha-art li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.mr-ficha-art li b { white-space: nowrap; }
.mr-ficha-obs { margin: 6px 0; padding: 6px 8px; background: #fef3c7; border-left: 3px solid #f59e0b; border-radius: 6px; font-size: 12px; }
.mr-ficha-botones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mr-ficha-botones .mr-btn { padding: 6px 10px; font-size: 12px; }

/* Asignar desde el propio marcador */
.mr-ficha-asignar { margin-top: 10px; padding: 10px; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 10px; display: grid; gap: 6px; }
.mr-ficha-asignar label { display: grid; gap: 2px; min-width: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; font-weight: 700; }
.mr-ficha-asignar select { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; text-overflow: ellipsis; border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 7px; font-family: inherit; font-size: 12.5px; text-transform: none; letter-spacing: 0; color: #0f172a; font-weight: 400; background: #fff; }
.mr-ficha-fila2 { display: flex; gap: 6px; align-items: end; }
.mr-ficha-fila2 label { flex: 1; }
.mr-ficha-fila2 .mr-btn { flex: 0 0 auto; padding: 7px 12px; }
.mr-popup .leaflet-popup-content-wrapper { width: 380px; max-width: calc(100vw - 40px); }
.mr-ficha { max-width: 100%; box-sizing: border-box; overflow: hidden; }
.mr-ficha-fila2 label { flex: 1 1 0; min-width: 0; }

/* La pregunta (quitar del viaje) */
.mr-pregunta-fondo { position: fixed; inset: 0; z-index: 3000; background: rgba(15, 23, 42, 0); display: flex; align-items: center; justify-content: center; transition: background .18s; }
.mr-pregunta-fondo.abierto { background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); }
.mr-pregunta { width: min(420px, 92vw); background: #fff; border-radius: 16px; padding: 22px 22px 18px; text-align: center; box-shadow: 0 24px 60px rgba(15, 23, 42, .35); font-family: 'Segoe UI', Arial, sans-serif; color: #0f172a; transform: translateY(16px) scale(.96); opacity: 0; transition: transform .2s, opacity .2s; }
.mr-pregunta-fondo.abierto .mr-pregunta { transform: none; opacity: 1; }
.mr-pregunta-icono { width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: #e0f2fe; color: #0284c7; }
.mr-pregunta-icono.peligro { background: #fee2e2; color: #dc2626; }
.mr-pregunta h3 { margin: 0 0 6px; font-size: 17px; }
.mr-pregunta p { margin: 0 0 16px; font-size: 13.5px; line-height: 1.45; color: #334155; }
.mr-pregunta p small { color: #64748b; }
.mr-pregunta-botones { display: flex; gap: 8px; justify-content: center; }
.mr-pregunta-botones .mr-btn { padding: 9px 16px; font-size: 13px; }
.mr-btn.peligro { background: #dc2626; border-color: #dc2626; color: #fff; } .mr-btn.peligro:hover { background: #b91c1c; }
.mr-ficha-asignar label[hidden] { display: none; }
.mr-etiq.mr-giahsa { background: #cffafe; color: #0e7490; font-size: 9.5px; padding: 0 5px; vertical-align: middle; }
