:root { --primary: #2c3e50; --accent: #e67e22; --success: #2ecc71; --warning: #f39c12; --danger: #e74c3c; }
body { margin: 0; padding: 0; display: flex; font-family: 'Segoe UI', system-ui, sans-serif; height: 100vh; overflow: hidden; background: #1a1a1a; }


#toolbar { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; background: rgba(255,255,255,0.9); backdrop-filter: blur(10px); padding: 12px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); display: flex; gap: 12px; }

#stats-panel { position: absolute; bottom: 30px; left: 20px; z-index: 1000; background: rgba(44, 62, 80, 0.95); color: white; padding: 18px; border-radius: 15px; font-size: 13px; min-width: 220px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); border-bottom: 4px solid var(--success); }
.stat-item { display: flex; justify-content: space-between; margin-bottom: 8px; align-items: center; }
.stat-val { font-weight: 800; color: var(--success); font-family: 'Courier New', monospace; font-size: 16px; }

#sidebar { width: 0; opacity: 0; background: white; border-left: 4px solid var(--primary); display: none; overflow-y: auto; z-index: 2000; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.sidebar-content { padding: 25px; min-width: 360px; }

.card-tecnica { background: #fdfdfd; padding: 15px; border-radius: 12px; margin-bottom: 20px; border: 1px solid #eee; position: relative; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
.grid-puertos { display: grid; gap: 8px; margin: 15px 0; grid-template-columns: repeat(4, 1fr); animation: fadeIn 0.5s; }
.pto { padding: 10px 0; text-align: center; border-radius: 6px; font-weight: bold; color: white; font-size: 11px; }
.libre { background: var(--success); }
.ocupado { background: var(--danger); }

.btn { padding: 10px 16px; border: none; border-radius: 8px; cursor: pointer; font-weight: 700; color: white; font-size: 12px; transition: all 0.2s; text-transform: uppercase; }

.modal-form { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9); z-index: 3000; background: white; padding: 30px; border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); display: none; width: 340px; opacity: 0; transition: all 0.3s; }
.modal-form.active { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.modal-form input, .modal-form select { width: 100%; padding: 14px; margin: 10px 0; border: 2px solid #f0f0f0; border-radius: 10px; font-size: 14px; outline: none; }

.item-cliente { border-bottom: 1px solid #eee; padding: 12px 0; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.badge-precinto { background: #f1f2f6; color: #7f8c8d; padding: 2px 6px; border-radius: 4px; font-size: 11px; margin-left: 5px; font-weight: bold; }

#indicador { position: absolute; top: 85px; left: 50%; transform: translateX(-50%); z-index: 2000; background: var(--warning); padding: 12px 28px; border-radius: 40px; font-weight: 800; display: none; box-shadow: 0 10px 20px rgba(0,0,0,0.15); align-items: center; gap: 15px; color: #fff; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* 1. VARIABLES GLOBALES */
:root {
    --bg-dark: #0f172a;
    --sidebar-bg: #1e293b;
    --accent: #38bdf8;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --sidebar-width: 260px;
}

/* 2. RESET Y ESTRUCTURA BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

#app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* 3. BARRA LATERAL (SIDEBAR) */
.main-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
    z-index: 2000; /* Siempre por encima del mapa */
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 30px;
}

.logo span { color: var(--accent); }

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
    color: #94a3b8;
}

.nav-links li:hover, .nav-links li.active {
    background: #334155;
    color: var(--accent);
}

/* 4. ÁREA DE CONTENIDO (DERECHA) */
.content-area {
    flex: 1;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* 5. GESTIÓN DE VISTAS (HABITACIONES) */
.vista {
    display: none; /* Por defecto todas ocultas */
    width: 100%;
    height: 100%;
}

/* Solo la vista activa se muestra */
.vista.active {
    display: block; 
}

/* El Dashboard necesita scroll si hay muchos datos */
#v-dashboard {
    padding: 40px;
    overflow-y: auto;
}

/* La Ingeniería debe ser exacta al tamaño de la pantalla */
#v-mapa-ingenieria.active {
    display: flex; 
    flex-direction: column;
}

/* 6. EL MAPA (PANTALLA COMPLETA) */
#map {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    z-index: 1;
}

/* 7. TARJETAS DEL DASHBOARD (DISEÑO) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.stat-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #334155;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    color: #94a3b8;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-top: 10px;
    color: var(--accent);
}

/* 8. CONTROLES SOBRE EL MAPA */
.controles-flotantes {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}


/* === MODALES === */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(5px);
    display: none; align-items: center; justify-content: center; z-index: 10000;
}

.modal-content {
    background: #1e293b; width: 90%; max-width: 500px;
    border-radius: 15px; border: 1px solid #334155; padding: 25px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); color: white;
}

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; border-bottom: 1px solid #334155; padding-bottom: 10px; }
.modal-header h2 { margin: 0; font-size: 1.2rem; }
.close-btn { background: none; border: none; color: white; font-size: 24px; cursor: pointer; }

.input-group { margin-bottom: 15px; display: flex; flex-direction: column; gap: 5px; }
.input-group label { color: #94a3b8; font-size: 0.9rem; text-align: left; }
.input-group input, .input-group select { background: #0f172a; border: 1px solid #334155; padding: 10px; border-radius: 8px; color: white; outline: none; }
.input-group input:focus { border-color: #38bdf8; }

.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-cancel { background: transparent; color: #94a3b8; border: none; cursor: pointer; padding: 10px; }
.btn-confirm { background: #38bdf8; color: #0f172a; border: none; padding: 10px 25px; border-radius: 8px; font-weight: bold; cursor: pointer; }

/* === VISTAS Y NAVEGACIÓN === */
.vista { display: none; width: 100%; height: 100%; overflow-y: auto; padding: 20px; }
.vista.active { display: block; }
#v-mapa-ingenieria.active, #v-clientes.active, #v-ventas.active { display: flex; padding: 0; } 

.clientes-layout { display: flex; width: 100%; height: 100vh; overflow: hidden; }

/* === MAPA === */
#map { width: 100%; height: 100%; min-height: 100vh; }
.map-wrapper { flex: 1; position: relative; }
#map-container-ing { width: 100%; height: 100%; }

/* === SIDEBAR DE CLIENTES === */
#sidebar-info { 
    width: 350px; background: #1e293b; border-left: 1px solid #334155; 
    display: none; flex-direction: column; padding: 25px; color: white;
}

/* === PANEL DE VENTAS (FLOTANTE) === */
.floating-panel-ventas {
    position: absolute; top: 15px; left: 80px; z-index: 1000; width: 320px; 
    background: #1e293b; padding: 20px; border-radius: 12px; border: 1px solid #38bdf8; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
.floating-panel-ventas h3 { color: #38bdf8; margin: 0 0 15px 0; font-size: 1rem; }
.search-container-ventas { display: flex; gap: 8px; }
.search-container-ventas input { 
    flex: 1; padding: 12px; background: #0f172a; border: 1px solid #334155; 
    color: white; border-radius: 8px; font-size: 13px; 
}
.search-container-ventas button { 
    background: #38bdf8; color: #0f172a; border: none; padding: 10px 15px; 
    border-radius: 8px; cursor: pointer; transition: 0.3s; 
}
.results-container { margin-top: 20px; max-height: 350px; overflow-y: auto; }
.results-container p { color: #64748b; font-size: 12px; text-align: center; }

/* === ANIMACIONES DE PULSO (MONITOREO) === */
@keyframes pulso-alerta {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); border-color: #4ade80; }
    50% { box-shadow: 0 0 15px 10px rgba(239, 68, 68, 0.5); border-color: #ef4444; }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); border-color: #4ade80; }
}

@keyframes pulso-critico {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
    50% { transform: scale(1.1); box-shadow: 0 0 20px 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.pulso-cliente { animation: pulso-alerta 2s infinite; border-width: 3px !important; }
.pulso-critico { animation: pulso-critico 1s infinite; background: #ef4444 !important; }

/* === OTROS AJUSTES === */
.olt-vincular-box { 
    background: #0f172a; padding: 15px; border-radius: 8px; 
    border: 1px solid #334155; margin-bottom: 15px;
    display: flex; align-items: center; justify-content: space-between;
}
.olt-vincular-box label { color: #4ade80; font-size: 0.9rem; font-weight: bold; }
.olt-vincular-box input { width: 20px; height: 20px; cursor: pointer; }

#campos-conexion { opacity: 0.4; pointer-events: none; transition: 0.3s; }
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

/* === SIDEBAR: SELECTOR DE NODO Y BOTÓN AGREGAR === */
.nodo-selector {
    padding: 20px 15px;
    border-bottom: 1px solid #334155;
    margin-bottom: 15px;
}

.nodo-selector label {
    display: block;
    font-size: 10px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.nodo-selector select {
    width: 100%;
    background: #0f172a;
    color: white;
    border: 1px solid #38bdf8;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    font-size: 13px;
    transition: all 0.3s ease;
}

.nodo-selector select:hover {
    border-color: #4ade80; /* Cambia a verde al pasar el mouse */
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.nodo-selector button {
    width: 100%;
    margin-top: 12px;
    background: rgba(56, 189, 248, 0.05);
    color: #38bdf8;
    border: 1px dashed #38bdf8;
    padding: 10px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 8px;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
}

.nodo-selector button:hover {
    background: rgba(56, 189, 248, 0.15);
    border-style: solid;
    transform: translateY(-1px);
}

.nodo-selector button i {
    font-size: 14px;
}


/* Ocultar el panel de texto de Leaflet Routing Machine */
.leaflet-routing-container {
    display: none !important;
}

/* Estilo para que la línea de la calle resalte */
.leaflet-interactive {
    stroke-linejoin: round;
    stroke-linecap: round;
}


/* --- ANIMACIONES DE MONITOREO EN TIEMPO REAL --- */

/* Estado 1: Falla Parcial (Un cliente con mala potencia) */
/* Pulso entre Verde (Normal) y Amarillo (Advertencia) */
@keyframes pulso-advertencia {
    0% { filter: drop-shadow(0 0 0px #4ade80); transform: scale(1); }
    50% { filter: drop-shadow(0 0 10px #fbbf24); transform: scale(1.2); }
    100% { filter: drop-shadow(0 0 0px #4ade80); transform: scale(1); }
}

.icono-nap-advertencia {
    animation: pulso-advertencia 2s infinite ease-in-out !important;
    z-index: 1000 !important; /* Que se vea por encima de todo */
}

/* Estado 2: Falla Crítica (Corte de Fibra / Puerto Caído) */
/* Pulso Rojo Intenso estilo "Alarma Nuclear" */
@keyframes pulso-critico {
    0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.7); background: #ef4444; }
    70% { box-shadow: 0 0 0 20px rgba(248, 113, 113, 0); background: #991b1b; }
    100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); background: #ef4444; }
}

.icono-nap-critico {
    border-radius: 50%;
    animation: pulso-critico 1s infinite !important;
    border: 2px solid white !important;
}

/* Estilo para la potencia en el panel (dBm) */
.etiqueta-potencia {
    font-family: monospace;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
}
.dbm-ok { color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.dbm-warn { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.dbm-bad { color: #f87171; background: rgba(248, 113, 113, 0.1); }

/* === ESTILOS BASE DEL LAYOUT (Asegúrate de tener esto así) === */
.main-sidebar {
    position: fixed; /* CLAVE: Para que flote y pueda salir de la pantalla */
    top: 0;
    left: 0;
    width: 250px;
    height: 100vh;
    background: #0f172a; /* Tu color azul oscuro */
    z-index: 1000;
    transition: left 0.4s ease; /* Animación suave al moverse */
    overflow-y: auto;
}

.content-area {
    margin-left: 250px; /* Espacio para el menú */
    width: calc(100% - 250px);
    height: 100vh;
    transition: margin-left 0.4s ease, width 0.4s ease; /* Animación suave al estirarse */
    position: relative;
}

/* === ESTADOS DE PANTALLA COMPLETA (ANIMACIÓN) === */

/* Cuando activamos el modo full, el menú se va a la izquierda (-250px) */
body.modo-full .main-sidebar {
    left: -250px;
}

/* Y el contenido ocupa el 100% y quita el margen */
body.modo-full .content-area {
    margin-left: 0;
    width: 100%;
}

/* Botón flotante para regresar (Animación de opacidad) */
#btn-volver-menu {
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
}

body.modo-full #btn-volver-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}


/* === PERSONALIZACIÓN DE SCROLLBAR (ESTILO DARK) === */

/* 1. Para navegadores basados en Webkit (Chrome, Edge, Opera, Brave) */
::-webkit-scrollbar {
    width: 8px;              /* Ancho vertical más delgado */
    height: 8px;             /* Alto horizontal más delgado */
}

/* El fondo del riel (Track) */
::-webkit-scrollbar-track {
    background: #0f172a;     /* Mismo color que tu fondo oscuro */
    border-left: 1px solid #1e293b; /* Borde sutil separador */
}

/* La barra que se mueve (Thumb) */
::-webkit-scrollbar-thumb {
    background-color: #334155; /* Gris azulado oscuro (Slate 700) */
    border-radius: 4px;        /* Bordes redondeados */
    border: 2px solid #0f172a; /* Espacio alrededor para que se vea flotante */
}

/* Efecto al pasar el mouse por encima */
::-webkit-scrollbar-thumb:hover {
    background-color: #38bdf8; /* Azul cyan de tu marca al interactuar */
}

/* 2. Soporte para Firefox (Estándar moderno) */
* {
    scrollbar-width: thin;          /* Barra delgada */
    scrollbar-color: #334155 #0f172a; /* Color Barra | Color Fondo */
}


/* === ESTILO TÉCNICO PARA CAJAS EN INGENIERÍA === */
.nap-ingenieria {
    background: #1e293b; /* Fondo pizarra oscuro */
    border: 2px solid #38bdf8; /* Borde azul brillante */
    border-radius: 4px;
    color: #f8fafc;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    padding: 2px 5px;
}

.nap-status-diseno { border-color: #64748b; opacity: 0.8; } /* Gris para diseño */
.nap-status-activo { border-color: #4ade80; }               /* Verde para activo */

/* Pequeña "antena" o conector visual para la caja */
.nap-ingenieria::after {
    content: '';
    position: absolute;
    bottom: -5px;
    width: 2px;
    height: 5px;
    background: inherit;
}


/* TOOLBAR DE INGENIERÍA HORIZONTAL */
.toolbar-ingenieria {
    position: absolute;
    top: 15px; /* Distancia del borde superior */
    left: 50%; /* Centrado horizontal */
    transform: translateX(-50%); /* Ajuste para centrado perfecto */
    z-index: 1000;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    display: flex;
    flex-direction: row; /* CAMBIO: De arriba-abajo a izquierda-derecha */
    padding: 6px;
    gap: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.6);
    align-items: center;
}

/* Ajuste del separador vertical */
.toolbar-ingenieria hr {
    height: 25px; /* Altura del separador */
    width: 1px;
    border: none;
    border-left: 1px solid #334155;
    margin: 0 5px;
}

.btn-tool {
    width: 40px;
    height: 40px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.btn-tool:hover {
    background: #334155;
    color: #38bdf8;
}

.btn-tool.active {
    background: #38bdf8;
    color: #0f172a;
    border-color: #38bdf8;
}

/* Cursor especial cuando una herramienta está activa */
.cursor-diseno {
    cursor: crosshair !important;
}



/* CONTENEDOR MAESTRO DE INGENIERÍA */
#v-mapa-ingenieria {
    display: none; /* Se activa por JS */
    width: 100vw !important;
    height: 100vh !important;
    position: fixed !important;
    top: 0;
    left: 0;
    z-index: 999;
    background: #020617;
    flex-direction: row !important; /* Fuerza la sidebar a la izquierda y mapa a la derecha */
    overflow: hidden;
}

/* SIDEBAR IZQUIERDA PROFESIONAL */
.sidebar-ingenieria-pon {
    width: 320px !important;
    min-width: 320px !important;
    height: 100% !important;
    background: #0f172a;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 15px rgba(0,0,0,0.5);
}

/* ÁREA DEL MAPA */
#map-container-ing {
    flex-grow: 1 !important;
    height: 100% !important;
    position: relative;
}

/* MOVER EL BOTÓN VOLVER A LA DERECHA PARA QUE NO CHOQUE */
#btn-volver-menu {
    left: auto !important; /* Quitamos el left */
    right: 20px !important; /* Lo mandamos a la derecha */
    top: 20px !important;
    background: #1e293b !important;
    border: 1px solid #ef4444 !important; /* Rojo para que destaque como "Salir" */
    color: #ef4444 !important;
}


/* TOOLTIP DE FIBRA */
.tooltip-fibra {
    background: #0f172a !important;
    border: 1px solid #334155 !important;
    color: white !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    border-radius: 6px;
    padding: 5px;
}
/* Quitar la flechita blanca por defecto de Leaflet */
.leaflet-tooltip-top:before {
    border-top-color: #0f172a !important;
}



/* ELIMINAR BORDE NEGRO DE SELECCIÓN EN EL MAPA */
.leaflet-interactive {
    outline: none !important;
}

path.leaflet-interactive:focus {
    outline: none !important;
}



/* MENÚ CONTEXTUAL (CLIC DERECHO) */
#menu-contextual {
    display: none;
    position: absolute;
    z-index: 10000;
    background: #1e293b;
    border: 1px solid #38bdf8;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    min-width: 180px;
    padding: 5px 0;
}

.item-contextual {
    padding: 8px 15px;
    color: #f8fafc;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.item-contextual:hover {
    background: #38bdf8;
    color: #0f172a;
}

.separador-contextual {
    height: 1px;
    background: #334155;
    margin: 4px 0;
}

/* ESTILOS DEL ÁRBOL LATERAL (GOOGLE EARTH STYLE) */
.carpeta-pon {
    margin-bottom: 5px;
}

.titulo-carpeta {
    padding: 8px 12px;
    background: #1e293b;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 4px;
}

.titulo-carpeta:hover { background: #334155; }

.contenido-carpeta {
    padding-left: 20px; /* Indentación de jerarquía */
    display: none; /* Colapsado por defecto */
    border-left: 1px solid #334155;
    margin-left: 10px;
}

.item-arbol {
    padding: 4px 8px;
    font-size: 11px;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 4px;
    margin-top: 2px;
}

.item-arbol:hover {
    background: #38bdf822;
    color: #38bdf8;
}



/* HILO SELECCIONADO (MOMENTO PREVIO A FUSIONAR) */
.hilo-seleccionado {
    background: #38bdf844 !important; /* Azul brilloso transparente */
    border: 1px solid #38bdf8 !important;
    box-shadow: 0 0 10px #38bdf8;
    transition: all 0.2s;
}

/* LÍNEAS DE FUSIÓN SVG */
.linea-fusion {
    stroke: #4ade80; /* Verde éxito */
    stroke-width: 2px;
    fill: none;
    pointer-events: stroke; /* Para poder hacer clic en la línea y borrarla */
    cursor: pointer;
}

.linea-fusion:hover {
    stroke: #ef4444; /* Rojo al pasar el mouse (indica borrar) */
    stroke-width: 4px;
}


/* Transición suave para la barra lateral */
.sidebar {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; /* Necesario para anclar el botón */
    z-index: 1000;
}

/* Clase que aplicaremos con JS para esconderla (ajusta los 320px al ancho real de tu sidebar) */
.sidebar.escondida {
    margin-left: -320px; 
}

/* El contenido del mapa debe expandirse suavemente */
.main-content {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), flex-grow 0.3s;
}

/* Transición suave para la barra lateral de INGENIERÍA */
.sidebar-ingenieria-pon {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; /* Necesario para anclar el botón */
    z-index: 1000;
}

/* Clase que aplicaremos con JS para esconderla */
.sidebar-ingenieria-pon.escondida {
    margin-left: -320px; /* Exactamente el mismo ancho que tiene tu barra */
}

/* Botón flotante para ocultar/mostrar */
.btn-toggle-sidebar {
    position: absolute;
    top: 20px;
    right: -36px; /* Lo sacamos hacia el área del mapa */
    width: 36px;
    height: 36px;
    background: #1e293b;
    color: #38bdf8;
    border: 1px solid #334155;
    border-left: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 0 6px rgba(0,0,0,0.5);
    transition: background 0.2s, color 0.2s;
}

.btn-toggle-sidebar:hover {
    background: #38bdf8;
    color: #020617;
}


/* === BALIZA DE FALLA OTDR === */
.icono-falla-otdr {
    background-color: #ef4444; /* Rojo emergencia */
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 rgba(239, 68, 68, 0.8);
    animation: pulso-falla 1.5s infinite;
}

@keyframes pulso-falla {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
    70% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}




/* ================================================================ */
/* ESTILOS PARA DROPS (ACOMETIDAS)                                  */
/* ================================================================ */
.tooltip-drop {
    background-color: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid #38bdf8 !important;
    color: #f8fafc !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(4px);
}

/* Quitar la flechita blanca por defecto de Leaflet */
.leaflet-tooltip-left.tooltip-drop::before, 
.leaflet-tooltip-right.tooltip-drop::before,
.leaflet-tooltip-top.tooltip-drop::before,
.leaflet-tooltip-bottom.tooltip-drop::before {
    border: none !important;
    display: none !important;
}



.dashboard-container { padding: 20px; display: flex; flex-direction: column; gap: 25px; height: 100%; overflow-y: auto; }

/* Grid de Tarjetas Superiores */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }

.kpi-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 25px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease;
}

.kpi-card:hover { transform: translateY(-5px); border-color: rgba(56, 189, 248, 0.3); }

.kpi-icon { width: 55px; height: 55px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; }

/* Colores de Brillo */
.purple-glow .kpi-icon { background: rgba(139, 92, 246, 0.1); color: #a78bfa; }
.blue-glow .kpi-icon { background: rgba(56, 189, 248, 0.1); color: #38bdf8; }
.green-glow .kpi-icon { background: rgba(74, 222, 128, 0.1); color: #4ade80; }
.red-glow .kpi-icon { background: rgba(239, 68, 68, 0.1); color: #f87171; }

.kpi-value { display: block; font-size: 32px; font-weight: 800; color: #f8fafc; line-height: 1; }
.kpi-label { font-size: 13px; color: #94a3b8; font-weight: 500; }

/* Contenedores Grandes */
.main-stats-grid { display: grid; grid-template-columns: 1fr 350px; gap: 20px; flex: 1; }

.chart-container, .activity-container {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 25px;
}

.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.chart-header h3 { font-size: 16px; color: #94a3b8; margin: 0; }

/* Barra de Progreso Visual */
.visual-progress-bar { background: #0f172a; height: 12px; border-radius: 6px; overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #38bdf8, #818cf8); width: 0%; transition: width 1s ease; }



.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item:hover {
    background: rgba(56, 189, 248, 0.03);
}

.text-purple { color: #a78bfa; }
.text-blue { color: #38bdf8; }
.text-red { color: #f87171; }
.text-slate { color: #94a3b8; }



/* ================================================================ */
/* ESTILOS DEL BOTÓN DE HERRAMIENTAS (IMPORTAR KML)                 */
/* ================================================================ */
.btn-herramienta {
    background-color: #0f172a;       /* Fondo oscuro del panel */
    color: #38bdf8;                  /* Texto azul tecnológico */
    border: 1px solid #334155;       /* Borde sutil */
    padding: 10px 16px;              /* Espaciado interno */
    border-radius: 8px;              /* Bordes redondeados modernos */
    cursor: pointer;                 /* Manito al pasar el mouse */
    font-family: sans-serif;
    font-size: 13px;
    font-weight: 600;
    display: flex;                   /* Para alinear ícono y texto */
    align-items: center;
    gap: 8px;                        /* Espacio entre el ícono y la palabra */
    transition: all 0.2s ease-in-out; /* Animación suave */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3); /* Sombra ligera */
    width: 100%;                     /* Para que ocupe el ancho del panel lateral */
    justify-content: center;         /* Centra el contenido */
}

/* Efecto al pasar el mouse por encima */
.btn-herramienta:hover {
    background-color: #38bdf8;       /* El fondo se vuelve azul */
    color: #0f172a;                  /* El texto y el ícono se vuelven oscuros */
    transform: translateY(-2px);     /* Efecto de que el botón se levanta */
    box-shadow: 0 6px 8px -1px rgba(56, 189, 248, 0.4); /* Sombra azulada (glow) */
}

/* Efecto al hacer clic */
.btn-herramienta:active {
    transform: translateY(0);        /* Vuelve a bajar */
    box-shadow: none;
}



/* Ícono para las Reservas de Fibra */
.marcador-reserva {
    background: #f97316; /* Naranja de advertencia/reserva */
    color: white;
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    cursor: pointer;
}




/* Clase para congelar el sistema */
body.cuenta-bloqueada .toolbar, 
body.cuenta-bloqueada .btn-accion,
body.cuenta-bloqueada #map {
    filter: grayscale(1) blur(2px); /* Ponemos el mapa en gris y borroso */
    pointer-events: none; /* Nadie puede hacer clic en nada */
    user-select: none;
}

/* Permitir que el mensaje de error sí sea visible y clicable */
body.cuenta-bloqueada #bloqueo-pantalla {
    display: flex !important;
    pointer-events: auto !important;
}











/* ================================================================ */
/* REDISEÑO DEFINITIVO: CHIPS CON SALTO DE LÍNEA AUTOMÁTICO         */
/* ================================================================ */

/* --------------------------------------------------- */
/* 1. ELEMENTOS OCULTOS EN PC (ESCRITORIO)             */
/* --------------------------------------------------- */
.hamburguesa-btn, 
#btn-menu-movil,
.cerrar-menu-movil, 
.overlay-menu,
.mobile-header { 
    display: none !important; 
}


/* --------------------------------------------------- */
/* 2. VISTA INGENIERÍA EN PC (ESCRITORIO)              */
/* --------------------------------------------------- */
#map-container-ing {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* BARRA DE HERRAMIENTAS PC: Salto de línea dinámico (flex-wrap: wrap) */
.toolbar-ingenieria-flotante {
    position: absolute !important;
    top: 20px !important;  
    
    /* Espacio reservado para el panel (izq) y el botón rojo (der) */
    left: 100px !important; 
    right: 80px !important; 
    
    margin: 0 auto !important; 
    width: auto !important; 
    
    display: flex !important;
    flex-direction: row !important;
    
    /* LA SOLUCIÓN: Permite que los botones bajen si no caben */
    flex-wrap: wrap !important; 
    justify-content: center !important; 
    align-items: center !important;
    gap: 12px !important;
    
    background: transparent !important; 
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    z-index: 1000 !important; 
    pointer-events: none !important; 
}

/* Botones estilo Píldora/Chip */
.toolbar-ingenieria-flotante button {
    pointer-events: auto !important; 
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 20px !important; 
    background: rgba(15, 23, 42, 0.85) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(56, 189, 248, 0.3) !important;
    border-radius: 50px !important; 
    cursor: pointer !important;
    font-size: 11px !important;
    font-weight: bold !important;
    letter-spacing: 0.5px !important;
    backdrop-filter: blur(8px) !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
    transition: all 0.3s ease !important;
    flex: 0 0 auto !important; 
    white-space: nowrap !important; 
}

.toolbar-ingenieria-flotante button:hover {
    background: #38bdf8 !important; 
    color: #0f172a !important; 
    border-color: #38bdf8 !important;
    transform: translateY(-3px) !important; 
}

.toolbar-ingenieria-flotante .separador-tools { display: none !important; }

/* Colores para los botones de cancelar/simulador */
.toolbar-ingenieria-flotante .btn-cancel, 
.toolbar-ingenieria-flotante .btn-otdr { 
    color: #fca5a5 !important; border-color: rgba(248, 113, 113, 0.3) !important; 
}
.toolbar-ingenieria-flotante .btn-cancel:hover, 
.toolbar-ingenieria-flotante .btn-otdr:hover { 
    background: #ef4444 !important; color: white !important; border-color: #ef4444 !important; 
}

/* RESUMEN DE INFRAESTRUCTURA PC */
#dash-flotante-ing {
    position: absolute !important;
    top: auto !important;
    bottom: 20px !important; 
    left: 10px !important; 
    min-width: 180px !important;
    padding: 15px !important;
    z-index: 1000 !important;
    transform: scale(0.9) !important; 
    transform-origin: bottom left !important;
}




/* Ocultar botón de cerrar panel en PC */
.btn-cerrar-panel-movil {
    display: none !important;
}

/* Ocultar botón de estructura móvil en PC con mayor jerarquía */
.toolbar-ingenieria-flotante .btn-estructura-movil {
    display: none !important; 
}
/* --------------------------------------------------- */
/* 3. ADAPTACIÓN EXCLUSIVA PARA TELÉFONOS (MÓVIL)      */
/* --------------------------------------------------- */
@media (max-width: 768px) {
    #map-container-ing {
        position: fixed !important; top: 60px !important; left: 0 !important; width: 100vw !important; height: calc(100vh - 60px) !important; z-index: 1 !important;
    }
    
    .hamburguesa-btn, #btn-menu-movil {
        display: flex !important; position: fixed !important; top: 15px !important; left: 15px !important; z-index: 9000 !important; background: #020617 !important; color: #38bdf8 !important; border: 1px solid #1e293b !important; padding: 10px 15px !important; border-radius: 8px !important; font-size: 20px !important; cursor: pointer !important; box-shadow: 0 4px 6px rgba(0,0,0,0.3) !important;
    }
    .mobile-header { display: flex !important; }
    
    #sidebar-principal {
        position: fixed !important; top: 0 !important; left: -100% !important; width: 260px !important; height: 100vh !important; z-index: 10000 !important; background: #0f172a !important; border-right: 1px solid #1e293b !important; transition: left 0.3s ease-in-out !important; overflow-y: auto !important; display: block !important;
    }
    #sidebar-principal.activo { left: 0 !important; }
    
    .cerrar-menu-movil {
        display: block !important; background: transparent !important; border: none !important; color: #ef4444 !important; font-size: 24px !important; position: absolute !important; top: 15px !important; right: 15px !important; cursor: pointer !important; z-index: 10001 !important;
    }
    
    .overlay-menu.activo {
        display: block !important; position: fixed !important; inset: 0 !important; background: rgba(2, 6, 23, 0.7) !important; backdrop-filter: blur(4px) !important; z-index: 9998 !important;
    }
    
    .sidebar-ingenieria-pon {
        position: fixed !important; top: 60px !important; left: -100% !important; width: 85% !important; max-width: 320px !important; height: calc(100vh - 60px) !important; z-index: 2000 !important; transition: left 0.3s ease-in-out !important; box-shadow: 5px 0 15px rgba(0,0,0,0.5) !important;
    }
    .sidebar-ingenieria-pon[style*="width: 300px"], .sidebar-ingenieria-pon[style*="left: 0"] { left: 0 !important; }
    
    .btn-toggle-sidebar {
        display: flex !important; position: fixed !important; top: 130px !important; left: 0 !important; z-index: 10001 !important; width: 40px !important; height: 40px !important; background: #0284c7 !important; color: white !important; border-radius: 0 8px 8px 0 !important; align-items: center !important; justify-content: center !important; box-shadow: 2px 2px 10px rgba(0,0,0,0.5) !important; border: 1px solid #38bdf8 !important; border-left: none !important; cursor: pointer !important;
    }

    .btn-toggle-sidebar {
    display: none !important; /* Desaparecemos la flecha azul estorbosa en móvil */
}

/* Usamos la misma jerarquía para "revivir" el botón solo en móvil */
    .toolbar-ingenieria-flotante .btn-estructura-movil {
        display: inline-flex !important;
    }

/* La magia: cuando el botón le inyecte esta clase al panel, se forzará a entrar a la pantalla */
.sidebar-ingenieria-pon.abierto-en-movil {
    left: 0 !important;
    box-shadow: 10px 0 25px rgba(0,0,0,0.8) !important; /* Una sombra elegante para que resalte */
}



/* Pestaña flotante para cerrar el panel en móvil */
    .btn-cerrar-panel-movil {
        display: flex !important;
        position: absolute !important;
        top: 20px !important;
        right: -40px !important; /* TRUCO: Lo empuja 40px hacia afuera del panel */
        width: 40px !important;
        height: 40px !important;
        background: #ef4444 !important; /* Rojo intuitivo para cerrar */
        color: white !important;
        border: none !important;
        border-radius: 0 8px 8px 0 !important; /* Redondeado solo del lado derecho */
        align-items: center !important;
        justify-content: center !important;
        font-size: 20px !important;
        box-shadow: 4px 0 10px rgba(0,0,0,0.3) !important;
        cursor: pointer !important;
        z-index: 10001 !important;
    }

    /* BARRA HORIZONTAL MÓVIL (Carrusel deslizable) */
    .toolbar-ingenieria-flotante {
        position: fixed !important;
        top: 60px !important;
        bottom: auto !important;
        left: 0 !important;
        right: auto !important;
        margin: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        background: rgba(15, 23, 42, 0.95) !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        padding: 8px 10px !important;
        z-index: 9000 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important; /* En móvil sí forzamos una sola línea */
        justify-content: flex-start !important;
        overflow-x: auto !important;
        pointer-events: auto !important; 
    }
    
    .toolbar-ingenieria-flotante button {
        pointer-events: auto !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 10px 15px !important;
        background: #1e293b !important;
        color: #f8fafc !important;
        border: 1px solid #334155 !important;
        border-radius: 6px !important; 
        font-size: 11px !important;
        white-space: nowrap !important; 
        box-shadow: none !important;
        transform: none !important;
    }
    .toolbar-ingenieria-flotante .separador-tools { display: none !important; }

    #dash-flotante-ing {
        position: fixed !important; top: auto !important; bottom: 20px !important; left: 10px !important; transform: scale(0.85) !important; transform-origin: bottom left !important; z-index: 1000 !important;
    }
}





/* ================================================================ */
/* VISTA CLIENTES: BÚSQUEDA ALINEADA Y PANEL NAP COMPACTO (MÓVIL)   */
/* ================================================================ */

@media (max-width: 768px) {
    
    /* --------------------------------------------------- */
    /* 1. BARRA DE BÚSQUEDA Y BOTÓN GPS (ALINEACIÓN FORZADA)*/
    /* --------------------------------------------------- */
    
    /* Forzamos la posición del GPS añadiendo #v-clientes para tener máxima jerarquía */
    #v-clientes #contenedor-gps {
        top: 80px !important; 
        left: 10px !important;
        width: 44px !important;
        height: 44px !important;
    }
    
    #v-clientes #btn-gps-pro {
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
    }

    /* Reducimos la barra de búsqueda y la anclamos a la derecha del GPS */
    #v-clientes #buscador-global {
        top: 80px !important;
        left: 60px !important; /* Espacio para el GPS (10px left + 44px ancho + 6px margen) */
        width: calc(80vw - 75px) !important; /* Evita que se salga de la pantalla */
    }
    
    #v-clientes #input-busqueda {
        width: 100% !important;
        height: 44px !important; /* Misma altura que el botón GPS */
        padding: 10px 15px 10px 35px !important; /* Ajuste interno */
        font-size: 13px !important;
    }

    /* Centrar la lupita dentro de la nueva barra */
    #v-clientes #buscador-global i.fa-search {
        top: 15px !important; 
    }

    /* Ocultamos el botón azul grande de "Auditoría" en móvil */
    #v-clientes button[onclick="abrirDashboard()"] {
        display: none !important; 
    }

    /* --------------------------------------------------- */
    /* 2. PANEL DE CAJA NAP (BOTTOM SHEET COMPACTO)        */
    /* --------------------------------------------------- */
    
    /* Hacemos el contenedor más bajo (máximo 55% de la pantalla) */
    #v-clientes #sidebar-info {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        max-height: 80vh !important; /* Reducido para no comerse el mapa */
        background: #0f172a !important; 
        border-radius: 20px 20px 0 0 !important; 
        box-shadow: 0 -10px 25px rgba(0,0,0,0.8) !important; 
        z-index: 10000 !important;
        overflow-y: auto !important;
        padding: 15px !important; /* Menos espacio vacío a los lados */
        padding-bottom: 25px !important;
    }

    /* Píldora deslizable superior */
    #v-clientes #sidebar-info::before {
        content: '';
        display: block;
        width: 35px;
        height: 4px;
        background: #475569;
        border-radius: 10px;
        margin: 0 auto 10px auto;
    }

    /* MAGIA COMPACTA: Achicamos dinámicamente todo lo que JavaScript ponga adentro */
    
    /* 1. Títulos y textos más pequeños */
    #v-clientes #sidebar-info h1, 
    #v-clientes #sidebar-info h2, 
    #v-clientes #sidebar-info h3 {
        font-size: 14px !important;
        margin-bottom: 5px !important;
    }
    
    #v-clientes #sidebar-info p, 
    #v-clientes #sidebar-info span {
        font-size: 11px !important;
    }
    
    /* 2. Reducimos los rellenos (paddings) gigantes de las tarjetas interiores */
    #v-clientes #sidebar-info div[style*="padding"] {
        padding: 10px !important;
        margin-bottom: 10px !important;
        border-radius: 8px !important;
    }

    /* 3. Botones más chiquitos */
    #v-clientes #sidebar-info button {
        padding: 6px 12px !important;
        font-size: 11px !important;
    }

    /* 4. Achicamos forzosamente el círculo naranja del porcentaje de capacidad */
    #v-clientes #sidebar-info div[style*="width: 80px"],
    #v-clientes #sidebar-info div[style*="height: 80px"],
    #v-clientes #sidebar-info div[style*="width:80px"],
    #v-clientes #sidebar-info div[style*="height:80px"] {
        width: 45px !important;
        height: 45px !important;
    }
    
    /* 5. Iconos interiores proporcionados */
    #v-clientes #sidebar-info i {
        font-size: 14px !important;
    }
}



/* ================================================================ */
/* VISTA FACTIBILIDAD: CARRUSEL HORIZONTAL COMPACTO (MÓVIL)         */
/* ================================================================ */

/* --------------------------------------------------- */
/* 1. AJUSTES PARA PC (Escritorio)                     */
/* --------------------------------------------------- */
#v-ventas #panel-busqueda-ventas {
    position: absolute !important;
    top: 20px !important;
    left: 20px !important;
    width: 350px !important;
    max-height: 85vh !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: 1000 !important;
}

#v-ventas #resultados-factibilidad {
    overflow-y: auto !important;
    max-height: calc(85vh - 120px) !important;
}

/* --------------------------------------------------- */
/* 2. DISEÑO EXCLUSIVO PARA MÓVILES (Carrusel Inferior)*/
/* --------------------------------------------------- */
@media (max-width: 768px) {
    
    /* El panel principal ahora es una burbuja flotante compacta en el fondo */
    #v-ventas #panel-busqueda-ventas {
        position: fixed !important;
        top: auto !important;
        bottom: 15px !important;
        left: 10px !important;
        width: calc(100vw - 20px) !important; /* Deja un margen a los lados */
        max-height: none !important; 
        
        background: rgba(15, 23, 42, 0.95) !important; 
        backdrop-filter: blur(8px) !important;
        border-radius: 16px !important; /* Bordes redondeados en todos lados */
        box-shadow: 0 5px 25px rgba(0,0,0,0.8) !important;
        
        padding: 12px !important;
        box-sizing: border-box !important;
        z-index: 10000 !important;
        margin: 0 !important;
    }

    /* Destruimos la "píldora" de deslizar si quedó alguna del código anterior */
    #v-ventas #panel-busqueda-ventas::before {
        display: none !important;
    }

    /* Ocultamos el título para ahorrar espacio vital en la pantalla */
    #v-ventas #panel-busqueda-ventas h3 {
        display: none !important;
    }

    /* Barra de búsqueda súper compacta */
    #v-ventas .search-container-ventas {
        display: flex !important;
        gap: 8px !important;
        width: 100% !important;
        margin-bottom: 8px !important;
    }

    #v-ventas #input-busqueda-ventas {
        flex-grow: 1 !important;
        width: auto !important;
        height: 42px !important; /* Altura táctil ideal */
        padding: 10px !important;
    }
    
    #v-ventas .search-container-ventas button {
        flex-shrink: 0 !important;
        width: 42px !important;
        height: 42px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* ========================================= */
    /* LA MAGIA: CONTENEDOR HORIZONTAL DE CAJAS  */
    /* ========================================= */
    #v-ventas #resultados-factibilidad {
        display: flex !important;
        flex-direction: row !important; /* Alinea todo de izquierda a derecha */
        flex-wrap: nowrap !important;   /* Prohíbe que las cajas caigan a la línea de abajo */
        overflow-x: auto !important;    /* Habilita el desplazamiento táctil hacia los lados */
        overflow-y: hidden !important;  /* Elimina el scroll vertical */
        gap: 12px !important;
        padding-bottom: 5px !important; /* Espacio para que la sombra no se corte */
        scroll-snap-type: x mandatory !important; /* Efecto magnético al deslizar */
    }
    
    /* Ocultamos la barra de scroll del navegador para que se vea como una App nativa */
    #v-ventas #resultados-factibilidad::-webkit-scrollbar {
        display: none !important;
    }

    /* Tarjetas de las NAPs (Se vuelven bloques compactos y fijos) */
    #v-ventas #resultados-factibilidad > div {
        flex: 0 0 240px !important; /* Cada tarjeta medirá exactamente 240px de ancho */
        scroll-snap-align: center !important; /* Se centra automáticamente en la pantalla al soltar el dedo */
        margin-bottom: 0 !important; 
        padding: 12px !important;
    }

    /* Achicamos un poco los botones dentro de las tarjetas (Añadir Curva / Analizar) */
    #v-ventas #resultados-factibilidad > div button {
        padding: 8px 10px !important;
        font-size: 11px !important;
    }
}





 /* NUEVOS ESTILOS PARA EL DASHBOARD */


    #v-dashboard {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: #07090e !important;
            background-image: none !important;
            color: #f8fafc;
            width: 100%;
            height: 100%;
            overflow-y: auto;
            overflow-x: hidden;
            box-sizing: border-box;
            padding: 0;
            -webkit-font-smoothing: antialiased;
        }

        .fp-dash-shell {
            width: 100%;
            min-height: 100%;
            padding: 28px 36px 48px 36px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            gap: 22px;
        }

        .fp-mono {
            font-family: 'JetBrains Mono', monospace;
        }

        .fp-top-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 16px;
        }
        .fp-top-left {
            display: flex;
            align-items: baseline;
            gap: 16px;
            flex-wrap: wrap;
        }
        .fp-top-left h1 {
            font-size: 24px;
            font-weight: 700;
            letter-spacing: -0.6px;
            color: #f8fafc;
            margin: 0;
        }
        .fp-node-indicator {
            display: inline-flex;
            align-items: center;
            gap: 7px;
            font-family: 'JetBrains Mono', monospace;
            font-size: 11.5px;
            color: #94a3b8;
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.07);
            padding: 4px 10px;
            border-radius: 6px;
        }
        .fp-node-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #10b981;
        }

        .fp-top-actions {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .fp-btn {
            background: #0c1018;
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: #cbd5e1;
            padding: 9px 16px;
            border-radius: 8px;
            font-family: inherit;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            transition: all 0.16s ease;
        }
        .fp-btn:hover {
            background: #131926;
            border-color: rgba(255, 255, 255, 0.18);
            color: #ffffff;
        }
        .fp-btn-white {
            background: #f8fafc;
            color: #07090e;
            border-color: #f8fafc;
            font-weight: 600;
        }
        .fp-btn-white:hover {
            background: #38bdf8;
            border-color: #38bdf8;
            color: #020617;
            box-shadow: 0 4px 18px rgba(56, 189, 248, 0.25);
        }

        .fp-kpi-band {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            background: rgba(255, 255, 255, 0.06);
            gap: 1px;
            border: 1px solid rgba(255, 255, 255, 0.07);
            border-radius: 12px;
            overflow: hidden;
        }
        .fp-kpi-cell {
            background: #0a0d14;
            padding: 22px 26px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            transition: background 0.18s ease;
        }
        .fp-kpi-cell:hover {
            background: #0d111a;
        }
        .fp-kpi-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        .fp-kpi-title {
            font-size: 12.5px;
            font-weight: 500;
            color: #94a3b8;
        }
        .fp-kpi-tag {
            font-family: 'JetBrains Mono', monospace;
            font-size: 10.5px;
            color: #64748b;
        }
        .fp-kpi-number {
            font-family: 'Inter', sans-serif;
            font-size: 40px;
            font-weight: 700;
            letter-spacing: -1.8px;
            color: #f8fafc;
            line-height: 1;
            margin: 4px 0 14px 0;
            transition: color 0.2s ease;
        }
        .fp-kpi-meta {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 11.5px;
            color: #64748b;
            padding-top: 12px;
            border-top: 1px solid rgba(255, 255, 255, 0.04);
            gap: 8px;
        }

        .fp-ops-band {
            display: grid;
            grid-template-columns: 1.15fr 1fr;
            gap: 20px;
        }
        .fp-surface {
            background: #0a0d14;
            border: 1px solid rgba(255, 255, 255, 0.07);
            border-radius: 12px;
            padding: 22px 26px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
        .fp-surface-head {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 18px;
            gap: 12px;
            flex-wrap: wrap;
        }
        .fp-surface-title {
            font-size: 15px;
            font-weight: 600;
            color: #f8fafc;
            letter-spacing: -0.2px;
            margin: 0;
        }
        .fp-surface-sub {
            font-size: 12px;
            color: #64748b;
            margin-top: 3px;
        }

        .visual-progress-bar {
            height: 8px;
            width: 100%;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 100px;
            overflow: hidden;
            margin: 8px 0 14px 0;
        }
        .progress-fill {
            height: 100%;
            width: 0%;
            background: #f8fafc;
            border-radius: 100px;
            transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .fp-inline-stats {
            display: grid;
            grid-template-columns: 0.8fr 1.5fr 0.9fr 1fr;
            gap: 14px;
            padding-top: 16px;
            margin-top: 12px;
            border-top: 1px solid rgba(255, 255, 255, 0.06);
        }
        .fp-inline-stat-label {
            font-size: 11px;
            color: #64748b;
            margin-bottom: 4px;
        }
        .fp-inline-stat-val {
            font-family: 'JetBrains Mono', monospace;
            font-size: 14.5px;
            font-weight: 600;
            color: #f8fafc;
        }
        .fp-inline-stat-sub {
            font-family: 'JetBrains Mono', monospace;
            font-size: 10px;
            color: #38bdf8;
            margin-top: 3px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .fp-spectrum-bar {
            height: 8px;
            width: 100%;
            background: rgba(255, 255, 255, 0.04);
            border-radius: 100px;
            overflow: hidden;
            display: flex;
            gap: 3px;
            margin: 8px 0 18px 0;
        }
        .fp-spec-seg {
            height: 100%;
            transition: width 0.4s ease;
        }
        .fp-spectrum-legend {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 14px;
            padding-top: 16px;
            border-top: 1px solid rgba(255, 255, 255, 0.06);
        }
        .fp-leg-item {
            display: flex;
            flex-direction: column;
        }
        .fp-leg-top {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 11.5px;
            color: #94a3b8;
            margin-bottom: 4px;
        }
        .fp-leg-dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
        }
        .fp-leg-num {
            font-family: 'JetBrains Mono', monospace;
            font-size: 20px;
            font-weight: 600;
            color: #f8fafc;
        }
        .fp-leg-range {
            font-family: 'JetBrains Mono', monospace;
            font-size: 10px;
            color: #475569;
            margin-top: 2px;
        }

        .fp-bottom-band {
            display: grid;
            grid-template-columns: 1.55fr 1fr;
            gap: 20px;
            flex: 1;
        }

        .fp-filter-pills {
            display: inline-flex;
            background: #07090e;
            border: 1px solid rgba(255, 255, 255, 0.07);
            border-radius: 8px;
            padding: 3px;
            gap: 3px;
        }
        .fp-filter-btn {
            background: transparent;
            border: none;
            color: #64748b;
            font-family: 'JetBrains Mono', monospace;
            font-size: 11px;
            padding: 4px 10px;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.15s;
        }
        .fp-filter-btn.active {
            background: #131926;
            color: #f8fafc;
            font-weight: 600;
        }

        .fp-nap-matrix {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 12px;
            max-height: 360px;
            overflow-y: auto;
            padding-right: 4px;
            align-content: start;
        }

        .fp-nap-tile {
            background: #07090e;
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 10px;
            padding: 14px 16px;
            cursor: pointer;
            transition: all 0.16s ease;
            display: flex;
            flex-direction: column;
            gap: 10px;
            position: relative;
        }
        .fp-nap-tile.iluminada:hover {
            border-color: #38bdf8;
            background: #0c121e;
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
        }

        .fp-nap-tile.sin-potencia {
            background: rgba(7, 9, 14, 0.45);
            border: 1px dashed rgba(255, 255, 255, 0.06);
            opacity: 0.58;
            cursor: not-allowed;
        }
        .fp-nap-tile.sin-potencia:hover {
            border-color: rgba(239, 68, 68, 0.35);
            opacity: 0.78;
        }

        .fp-nap-tile-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 6px;
        }
        .fp-nap-name {
            font-size: 13.5px;
            font-weight: 600;
            color: #f8fafc;
            letter-spacing: -0.2px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .fp-nap-badge-pwr {
            font-family: 'JetBrains Mono', monospace;
            font-size: 9.5px;
            font-weight: 600;
            padding: 2px 6px;
            border-radius: 4px;
            display: inline-flex;
            align-items: center;
            gap: 5px;
            flex-shrink: 0;
        }
        .fp-nap-bar-bg {
            height: 4px;
            width: 100%;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 4px;
            overflow: hidden;
        }
        .fp-nap-bar-fill {
            height: 100%;
            border-radius: 4px;
        }
        .fp-nap-tile-foot {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-family: 'JetBrains Mono', monospace;
            font-size: 11px;
            color: #64748b;
        }

        #fp-dash-toast {
            position: fixed;
            bottom: 24px;
            right: 24px;
            background: #0f1420;
            border: 1px solid rgba(245, 158, 11, 0.4);
            border-left: 4px solid #f59e0b;
            color: #f8fafc;
            padding: 12px 18px;
            border-radius: 10px;
            font-size: 12.5px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.75);
            z-index: 99999;
            display: none;
            align-items: center;
            gap: 10px;
            max-width: 380px;
        }

        .activity-list {
            display: flex;
            flex-direction: column;
            gap: 0;
            max-height: 360px;
            overflow-y: auto;
            padding-right: 4px;
        }
        .activity-list .activity-item {
            background: transparent !important;
            border: none !important;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
            border-radius: 0 !important;
            padding: 13px 4px !important;
            margin: 0 !important;
            box-shadow: none !important;
        }
        .activity-list .activity-item:last-child {
            border-bottom: none !important;
        }
        .activity-list .activity-item.empty {
            text-align: center;
            padding: 48px 16px !important;
            color: #475569 !important;
            border: none !important;
        }

        @media (max-width: 1200px) {
            .fp-kpi-band { grid-template-columns: repeat(2, 1fr); }
            .fp-ops-band, .fp-bottom-band { grid-template-columns: 1fr; }
        }
        @media (max-width: 680px) {
            .fp-dash-shell { padding: 18px 16px 80px 16px; gap: 18px; }
            .fp-kpi-band { grid-template-columns: 1fr; }
            .fp-kpi-number { font-size: 34px; }
            .fp-inline-stats, .fp-spectrum-legend { grid-template-columns: repeat(2, 1fr); }
            .fp-top-actions { width: 100%; }
            .fp-btn { flex: 1; justify-content: center; }
        }





        /* ====================================================================== */
/* ESTILOS MÓDULO DE LICENCIA Y FACTURACIÓN (#v-licencia)                 */
/* ====================================================================== */

.lic-sidebar-badge {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

#v-licencia {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #07090e !important;
    color: #f8fafc;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

.lic-shell {
    width: 100%;
    min-height: 100%;
    padding: 28px 36px 60px 36px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.lic-mono {
    font-family: 'JetBrains Mono', monospace;
}

.lic-text-cyan { color: #38bdf8 !important; }
.lic-text-emerald { color: #10b981 !important; }
.lic-text-amber { color: #f59e0b !important; }
.lic-text-rose { color: #ef4444 !important; }

/* 1. Barra Superior */
.lic-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.lic-top-left {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
}

.lic-top-left h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.6px;
    color: #f8fafc;
    margin: 0;
}

.lic-node-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    padding: 4px 10px;
    border-radius: 6px;
}

.lic-node-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #38bdf8;
}

.lic-top-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.lic-btn {
    background: #0c1018;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    padding: 8.5px 15px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.16s ease;
}

.lic-btn:hover {
    background: #131926;
    border-color: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.lic-btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.lic-btn-primary {
    background: #f8fafc;
    color: #07090e;
    border-color: #f8fafc;
    font-weight: 600;
}

.lic-btn-primary:hover {
    background: #38bdf8;
    border-color: #38bdf8;
    color: #020617;
    box-shadow: 0 4px 16px rgba(56, 189, 248, 0.25);
}

/* 2. Banda de 4 KPIs */
.lic-kpi-band {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(255, 255, 255, 0.06);
    gap: 1px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    overflow: hidden;
}

.lic-kpi-cell {
    background: #0a0d14;
    padding: 22px 26px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.lic-kpi-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.lic-kpi-label {
    font-size: 12.5px;
    font-weight: 500;
    color: #94a3b8;
}

.lic-kpi-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #64748b;
}

.lic-kpi-val {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1.4px;
    color: #f8fafc;
    line-height: 1.05;
    margin: 4px 0 14px 0;
}

.lic-kpi-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11.5px;
    color: #64748b;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* 3. Banda Media */
.lic-mid-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 20px;
}

.lic-surface {
    background: #0a0d14;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.lic-surface-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.lic-mb-compact {
    margin-bottom: 8px;
}

.lic-surface-title {
    font-size: 15px;
    font-weight: 600;
    color: #f8fafc;
    margin: 0;
    letter-spacing: -0.2px;
}

.lic-surface-sub {
    font-size: 12px;
    color: #64748b;
    margin-top: 3px;
}

.lic-cycle-pct {
    font-size: 13px;
    font-weight: 700;
    color: #10b981;
}

.lic-badge-subtle {
    font-size: 10px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
    padding: 3px 8px;
    border-radius: 5px;
}

.lic-progress-track {
    height: 10px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 100px;
    overflow: hidden;
    margin: 10px 0 18px 0;
}

.lic-progress-fill {
    height: 100%;
    width: 0%;
    background: #10b981;
    border-radius: 100px;
    transition: width 0.5s ease, background 0.3s ease;
}

.lic-specs-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.lic-spec-lbl {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 4px;
}

.lic-spec-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13.5px;
    font-weight: 600;
    color: #f8fafc;
}

/* Tarjetas de Métodos de Pago */
.lic-pay-methods {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.lic-pay-card {
    background: #07090e;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 11px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lic-pay-card span {
    font-size: 11px;
    color: #64748b;
    display: block;
}

.lic-pay-card strong {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #f8fafc;
}

/* 4. Tabla de Facturas */
.lic-filter-group {
    display: inline-flex;
    background: #07090e;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
}

.lic-flt-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}

.lic-flt-btn.active {
    background: #131926;
    color: #f8fafc;
    font-weight: 600;
}

.lic-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.lic-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.lic-table th {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.lic-table td {
    padding: 15px 14px;
    font-size: 13px;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.lic-table tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

.lic-badge-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.lic-badge-paid {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.28);
}

.lic-badge-pending {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

/* 5. Modal de Factura */
#lic-invoice-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(8px);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lic-invoice-paper {
    background: #0a0d14;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    padding: 32px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.85);
    color: #f8fafc;
    position: relative;
}

/* Responsivo */
@media (max-width: 1150px) {
    .lic-kpi-band { grid-template-columns: repeat(2, 1fr); }
    .lic-mid-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .lic-shell { padding: 18px 14px 80px 14px; }
    .lic-kpi-band, .lic-specs-row, .lic-pay-methods { grid-template-columns: 1fr; }
    .lic-kpi-val { font-size: 28px; }
}