html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 10px;
    text-align: center;
    font-weight: bold;
}

/* Estilos de la barra de filtros superior */
#filter-bar {
    background-color: #f8f9fa;
    padding: 8px 15px;
    border-bottom: 1px solid #ccc;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.filter-group {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    font-weight: bold;
    color: #333;
}

.filter-group select {
    padding: 4px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    margin-top: 2px;
    background-color: white;
}

#btn-reset {
    padding: 5px 10px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    align-self: flex-end;
}

#btn-reset:hover {
    background-color: #c0392b;
}

/* Contenedor principal que divide el panel lateral y el mapa con posición relativa */
#main-container {
    display: flex;
    position: relative;
    width: 100%;
    height: calc(100vh - 95px);
}

/* Estilos del Panel Lateral Izquierdo */
#sidebar {
    width: 380px;
    background-color: #ffffff;
    border-right: 1px solid #dcdcdc;
    display: flex;
    flex-direction: column;
    z-index: 999;
}

.sidebar-header {
    background-color: #34495e;
    color: white;
    padding: 10px 15px;
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
}

.sidebar-section {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-card {
    background: #f8f9fa;
    padding: 6px;
    border-radius: 4px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.stat-value {
    font-size: 15px;
    font-weight: bold;
    color: #2c3e50;
}

.stat-label {
    font-size: 10px;
    color: #6c757d;
}

/* Lista scrolleable completa en el panel izquierdo */
#sidebar-lista-maquinas {
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    padding-right: 4px;
}

.machine-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #3498db;
    border-radius: 4px;
    padding: 6px 8px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
}

.machine-card:hover {
    background-color: #f1f5f9;
    border-color: #3b82f6;
}

.machine-card b {
    color: #1e293b;
}

/* Panel Flotante de Detalle (sobre el mapa, exactamente donde iba el cuadro negro) */
.floating-detail-panel {
    position: absolute;
    bottom: 25px;
    left: 400px; /* Deja espacio al sidebar de 380px + margen */
    right: 400px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border: 1px solid #cbd5e1;
    border-left: 5px solid #3498db;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    padding: 15px;
    z-index: 1000;
    font-size: 12px;
    max-height: 190px;
    overflow-y: auto;
    padding-right: 5px;

}

.detalle-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.detalle-header-title {
    font-weight: bold;
    color: #1e293b;
    font-size: 13px;
    text-transform: uppercase;
}


#btn-cerrar-detalle {
    background: transparent;
    border: none;
    font-size: 16px;
    font-weight: bold;
    color: #64748b;
    cursor: pointer;
    padding: 0 5px;
}

#btn-cerrar-detalle:hover {
    color: #ef4444;
}

.detalle-row {
    margin-bottom: 4px;
}

#map {
    flex-grow: 1;
    height: 100%;
}

/* Estilos para el Botón de Modo Analítico */
#btn-modo-analitico {
    padding: 5px 12px;
    background-color: #475569;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: background-color 0.2s;
}

#btn-modo-analitico:hover {
    background-color: #334155;
}

/* Estado activo del botón analítico (Color violeta tecnológico) */
#btn-modo-analitico.activo {
    background-color: #8b5cf6;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.6);
}

#btn-modo-analitico.activo:hover {
    background-color: #7c3aed;
}

/* ESTO CONVIERTE CUALQUIER MAPA A ESCALA DE GRISES PERFECTA */
.leaflet-tile-pane {
    filter: invert(0%) hue-rotate(190deg) brightness(95%) contrast(90%);
}


/* =====================================================================
   v3 — componentes nuevos (todo el estilo vive aquí, sin estilos en línea)
   ===================================================================== */

[hidden] { display: none !important; }

header { transition: background-color 0.3s ease; }

/* ---------- barra de filtros ---------- */
.filter-check {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: bold;
    color: #5b21b6;
    align-self: flex-end;
    padding-bottom: 4px;
}

/* ---------- panel lateral ---------- */
.sidebar-botones {
    display: flex;
    gap: 5px;
    padding-bottom: 10px;
    margin-bottom: 0;
}

.sidebar-botones button {
    flex: 1;
    padding: 6px 4px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
}

.btn-instalar { background: #16a085; }
.btn-eliminar-modo { background: #d97706; }

.etiqueta-campo {
    font-size: 11px;
    font-weight: bold;
    color: #2c3e50;
    display: block;
    margin-bottom: 4px;
}

.sidebar-lista {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.titulo-lista {
    font-size: 12px;
    color: #2c3e50;
    margin-bottom: 8px;
    display: block;
}

#sidebar-lista-maquinas {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.machine-card-dir { color: #555; }

.badge-sin-ubicacion {
    display: inline-block;
    margin-top: 3px;
    padding: 1px 6px;
    border-radius: 3px;
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    font-weight: bold;
}

.btn-eliminar-equipo {
    margin-top: 6px;
    width: 100%;
    background: #7f1d1d;
    color: white;
    border: none;
    padding: 4px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    font-weight: bold;
}

body.modo-eliminar header { background-color: #dc2626; }
body.modo-eliminar #sidebar { border-left: 4px solid #dc2626; }
body.modo-eliminar .btn-eliminar-modo { background: #991b1b; }

/* ---------- autocompletado ---------- */
.autocompletado { position: relative; }

.autocompletado input,
#input-cliente-search {
    width: 100%;
    box-sizing: border-box;
}

#input-cliente-search {
    padding: 6px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.autocompletado-lista {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #cbd5e1;
    border-top: none;
    z-index: 1300;
    max-height: 180px;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 4px 4px;
}

.autocompletado-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.autocompletado-item:hover,
.autocompletado-item.activo { background: #eff6ff; }

.coincidencia { color: #2563eb; }

/* ---------- ficha técnica ---------- */
.detalle-vacio { color: #666; font-style: italic; }
.detalle-separado { border-top: 1px solid #cbd5e1; margin-top: 8px; padding-top: 8px; }

/* ---------- ventana flotante de instalación (no bloquea el mapa) ---------- */
.modal-flotante {
    position: fixed;
    top: 105px;
    right: 10px;
    width: 390px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-top: 4px solid #16a085;
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
    z-index: 1200;
    padding: 12px 14px 14px;
    box-sizing: border-box;
    font-size: 12px;
}

.modal-cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.modal-cabecera h3 { margin: 0; color: #2c3e50; font-size: 15px; }

#cerrar-modal {
    background: transparent;
    border: none;
    font-size: 16px;
    color: #64748b;
    cursor: pointer;
}

#cerrar-modal:hover { color: #ef4444; }

#form-instalacion { display: flex; flex-direction: column; gap: 10px; }

.campo { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.campo label { font-size: 11px; font-weight: bold; color: #333; }

.campo input,
.campo select,
.bloque-direccion select {
    padding: 5px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    background: #fff;
}

.campo input:disabled,
.campo select:disabled { background: #f1f5f9; color: #94a3b8; }

.campo-invalido { border-color: #dc2626 !important; background: #fef2f2 !important; }

.bloque-direccion {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    padding: 8px 10px 10px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bloque-direccion legend { font-size: 11px; font-weight: bold; color: #333; padding: 0 4px; }

.grid-direccion {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.g-tipo { grid-column: span 3; }
.g-numero { grid-column: span 2; }
.g-orient { grid-column: span 2; }

.lista-errores {
    margin: 0;
    padding: 6px 8px 6px 22px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 4px;
    color: #991b1b;
    font-size: 11px;
}

.dir-resumen {
    font-size: 12px;
    color: #64748b;
    background: #fff;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    padding: 5px 8px;
}

.dir-resumen-ok { color: #0f766e; border-style: solid; border-color: #99f6e4; font-weight: bold; }

.btn-buscar {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.btn-buscar:hover:not(:disabled) { background: #1d4ed8; }
.btn-buscar:disabled { background: #93c5fd; cursor: wait; }

.estado-linea { font-size: 11px; padding: 3px 0; }
.estado-info { color: #475569; }
.estado-ok { color: #15803d; }
.estado-error { color: #b91c1c; font-weight: bold; }
.estado-aviso {
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 11px;
    margin-top: 4px;
}

.lista-candidatos { display: flex; flex-direction: column; gap: 4px; }

.candidato {
    text-align: left;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 5px 7px;
    font-size: 11px;
    cursor: pointer;
}

.candidato:hover { border-color: #3b82f6; }
.candidato.seleccionado { border-color: #2563eb; background: #eff6ff; }

.candidato-tag {
    display: inline-block;
    padding: 0 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-right: 4px;
}

.candidato-tag.portal { background: #dcfce7; color: #166534; }
.candidato-tag.via { background: #fef3c7; color: #92400e; }

.fila-coordenadas { display: flex; gap: 6px; }
.fila-coordenadas input { flex: 1; }

.ayuda { color: #64748b; font-size: 10px; }

.ubicacion-previa {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ubicacion-previa.confirmada { border-color: #86efac; background: #f0fdf4; }
.previa-titulo { font-weight: bold; font-size: 12px; color: #1e3a8a; margin-bottom: 2px; }
.ubicacion-previa.confirmada .previa-titulo { color: #166534; }
.previa-nombre { color: #475569; font-size: 10px; margin: 2px 0; }
.previa-botones { display: flex; gap: 6px; }

.btn-confirmar {
    flex: 1;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}

.btn-confirmar:disabled { background: #86a98f; cursor: default; }

.btn-secundario {
    background: #e2e8f0;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
}

.btn-secundario:hover { background: #cbd5e1; }

.fila-3 { display: grid; grid-template-columns: 0.7fr 1fr 1fr; gap: 6px; }

.modal-botones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.btn-guardar {
    background: #10b981;
    color: #fff;
    border: none;
    padding: 7px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

.btn-guardar:disabled { background: #a7d8c6; cursor: not-allowed; }

/* ---------- pin de vista previa e íconos de respaldo ---------- */
.pin-previa span {
    display: block;
    font-size: 30px;
    line-height: 34px;
    animation: pin-pulso 1.2s ease-in-out infinite;
}

.pin-previa.confirmada span {
    animation: none;
    filter: drop-shadow(0 0 3px #16a34a) drop-shadow(0 0 3px #16a34a);
}

@keyframes pin-pulso {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.icono-maquina span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    font-size: 13px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #475569;
    box-sizing: border-box;
}

.icono-cafe span { border-color: #92400e; }
.icono-snack span { border-color: #16a34a; }
.icono-ambos span { border-color: #7c3aed; font-size: 9px; letter-spacing: -2px; }
.icono-otro span { border-color: #64748b; }

/* ---------- popup ---------- */
.popup-contenido { font-size: 13px; max-height: 160px; overflow-y: auto; }
.popup-contenido h3 { margin: 0 0 5px 0; color: #2c3e50; }
.popup-contenido p { margin: 3px 0; }
.popup-total { font-weight: bold; color: #16a085; }
.popup-maquina { border-top: 1px solid #eee; margin-top: 4px; padding-top: 4px; }

/* ---------- Modo Analítico ---------- */
.mesh-encabezado {
    padding: 8px;
    font-size: 11px;
    font-weight: bold;
    color: #7c3aed;
    background: #f3e8ff;
    border: 1px solid #ddd6fe;
    border-radius: 4px;
    margin-bottom: 8px;
    text-align: center;
}

.mesh-encabezado small { font-size: 9px; color: #5b21b6; }

.mesh-leyenda {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px 8px;
    margin-top: 5px;
    font-size: 9px;
    font-weight: normal;
    color: #475569;
}

.mesh-leyenda i {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 3px;
    border: 1px solid #94a3b8;
}

.mesh-aviso { padding: 10px; font-size: 11px; color: #475569; text-align: center; }
.mesh-fila { display: flex; justify-content: space-between; font-weight: bold; color: #1e293b; margin-bottom: 2px; gap: 6px; }
.mesh-badge { color: #fff; padding: 1px 5px; border-radius: 3px; font-size: 9px; align-self: flex-start; }
.mesh-detalle { font-size: 10px; color: #475569; }
.mesh-huerfano { border-left-color: #ef4444; background: #fef2f2; }
.mesh-huerfano-titulo { font-weight: bold; color: #991b1b; margin-bottom: 2px; }

/* ---------- avisos ---------- */
#toast-container {
    position: fixed;
    top: 105px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    max-width: 80vw;
}

.toast-ok { background: #15803d; }
.toast-error { background: #b91c1c; }

/* ---------- modificar máquina ---------- */
.btn-modificar-equipo {
    margin-top: 6px;
    width: 100%;
    background: #1d4ed8;
    color: white;
    border: none;
    padding: 4px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    font-weight: bold;
}

.btn-modificar-equipo:hover { background: #1e40af; }
