/* ============================================================================
   styles.css  —  Tema de marca BiiSensing (navy glassmorphism + acento azul)
   ============================================================================ */

:root {
  /* Paleta navy de marca */
  --navy-900: #030914;
  --navy-800: #0a1226;
  --navy-700: #0e1630;
  --navy-600: #0a1a3a;
  /* Acento azul de marca */
  --blue-500: #008ed5;
  --blue-400: #00a7ec;
  --blue-300: #00d0ff;
  /* Texto */
  --text: #e8f0fb;
  --text-dim: #8ea3c4;
  --text-faint: #5a6f92;
  /* Glass */
  --glass-bg: rgba(10, 22, 48, 0.55);
  --glass-border: rgba(120, 170, 255, 0.14);
  --glass-blur: 18px;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Font Awesome 6 Free Solid (fuente local, igual que en beta) */
@font-face {
  font-family: 'FA Solid';
  src: url('fonts/fa-solid-900.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: block;
}
.fa {
  font-family: 'FA Solid';
  font-weight: 900;
  font-style: normal;
  line-height: 1;
  display: inline-block;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--navy-900);
  color: var(--text);
  overflow: hidden;
}

#map { position: absolute; inset: 0; }

/* --- Splash / pantalla de carga ------------------------------------------ */
#splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 700px at 50% 38%, #0a1c3f 0%, #061229 45%, #030914 100%);
  transition: opacity 0.7s ease, visibility 0.7s ease;
}
#splash.hidden { opacity: 0; visibility: hidden; }

/* Halo/partículas suaves detrás del logo */
#splash::before {
  content: '';
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,142,213,0.28) 0%, rgba(0,142,213,0) 62%);
  filter: blur(6px);
  animation: haloPulse 3.4s ease-in-out infinite;
}

.splash-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  text-align: center;
}
.splash-logo {
  width: 300px; max-width: 70vw; height: auto;
  filter: drop-shadow(0 0 26px rgba(0,167,236,0.45));
  animation: logoIn 0.9s cubic-bezier(0.16,1,0.3,1) both;
}

/* Barra de carga con luz que recorre (tema fibra) */
.splash-track {
  position: relative;
  width: 260px; height: 3px;
  border-radius: 3px;
  background: rgba(120,170,255,0.14);
  overflow: hidden;
}
.splash-track::after {
  content: '';
  position: absolute;
  top: 0; left: -40%;
  width: 40%; height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(0,208,255,0) 0%, #00a7ec 45%, #00d0ff 60%, rgba(0,208,255,0) 100%);
  box-shadow: 0 0 14px 2px rgba(0,208,255,0.7);
  animation: sweep 1.5s cubic-bezier(0.65,0,0.35,1) infinite;
}
.splash-text {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.splash-text::after { content: ''; animation: dots 1.6s steps(4, end) infinite; }

@keyframes sweep { 0% { left: -40%; } 100% { left: 100%; } }
@keyframes haloPulse { 0%,100% { transform: scale(0.92); opacity: 0.7; } 50% { transform: scale(1.06); opacity: 1; } }
@keyframes logoIn { 0% { opacity: 0; transform: translateY(10px) scale(0.96); } 100% { opacity: 1; transform: none; } }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* --- Toggle de idioma ---------------------------------------------------- */
#lang-toggle {
  display: flex;
  gap: 2px;
  padding: 4px;
  align-items: center;
}
#lang-toggle .lang {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
#lang-toggle .lang.active { background: var(--blue-500); color: #fff; box-shadow: 0 0 12px rgba(0,167,236,0.5); }

/* Barlow para títulos */
h1, h2, h3, .title { font-family: 'Barlow', 'Inter', sans-serif; }

/* --- Contenedor de glass reutilizable ------------------------------------ */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* --- Header --------------------------------------------------------------- */
#header {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  z-index: 10;
  pointer-events: none;
}
#header > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
}
.brand .logo { height: 30px; width: auto; display: block; }
.brand .vsep { width: 1px; height: 30px; background: var(--glass-border); }
.brand .name-das {
  font-family: 'Barlow', sans-serif;
  font-size: 18px; font-weight: 800; letter-spacing: 3px;
  color: var(--blue-300);
}
.brand .sub { font-size: 10px; color: var(--text-dim); letter-spacing: 2px; text-transform: uppercase; }

.header-right { display: flex; align-items: center; gap: 12px; }

.badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue-300);
  border: 1px solid var(--glass-border);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 141, 213, 0.12);
  letter-spacing: 1px;
}

/* --- Panel lateral (KPIs + leyenda) -------------------------------------- */
#sidebar {
  position: absolute;
  top: 84px;
  left: 16px;
  width: 268px;
  padding: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-title {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.kpi .val { font-size: 22px; font-weight: 700; font-family: 'Barlow', sans-serif; }
.kpi .lbl { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.kpi.alert .val { color: var(--blue-300); }

/* Leyenda de tipos de evento (clic = mostrar/ocultar) */
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, opacity 0.12s ease;
}
.legend-item:hover { background: rgba(255, 255, 255, 0.05); }
.legend-item.off { opacity: 0.38; }
.legend-item.off .label { text-decoration: line-through; }
.legend-item .cnt { margin-left: auto; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.legend-item .eye { color: var(--text-faint); font-size: 11px; width: 14px; text-align: center; }

/* Marcadores de inicio / fin de la ruta de fibra */
.route-marker { display: flex; flex-direction: column; align-items: center; cursor: default; }
.route-marker .pin {
  font-size: 26px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  line-height: 1;
}
.route-marker .tag {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

/* --- Controles (abajo) --------------------------------------------------- */
#controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  z-index: 10;
}

.btn {
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: rgba(0, 141, 213, 0.2); border-color: var(--blue-400); }
.btn.active { background: var(--blue-500); border-color: var(--blue-300); color: #fff; box-shadow: 0 0 16px rgba(0, 167, 236, 0.5); }
.btn.primary { background: var(--blue-500); border-color: var(--blue-300); color: #fff; }
.btn.primary:hover { background: var(--blue-400); }

.divider { width: 1px; height: 24px; background: var(--glass-border); margin: 0 4px; }

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
}
.seg .btn { padding: 7px 12px; border: none; background: transparent; }
.seg .btn.active { background: var(--blue-500); }

/* --- Popup de evento ----------------------------------------------------- */
.maplibregl-popup-content {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 12px !important;
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 11px 13px !important;
  font-family: 'Inter', sans-serif;
}
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { color: var(--text-dim); font-size: 18px; padding: 2px 8px; }

.evt-pop .evt-type { font-family: 'Barlow', sans-serif; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.evt-pop .evt-type .swatch { width: 10px; height: 10px; border-radius: 3px; box-shadow: 0 0 8px 1px currentColor; }
.evt-pop .evt-row { display: flex; justify-content: space-between; gap: 24px; font-size: 12px; margin-top: 8px; color: var(--text-dim); }
.evt-pop .evt-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- Ticker de último evento --------------------------------------------- */
#ticker {
  position: absolute;
  bottom: 20px;
  left: 16px;
  padding: 12px 16px;
  z-index: 10;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 12px;
}
#ticker .icon { font-size: 22px; }
#ticker .txt .t { font-size: 13px; font-weight: 600; }
#ticker .txt .s { font-size: 11px; color: var(--text-dim); }

/* --- Marcador de evento en el mapa (glifo FA en círculo, como en beta) --- */
.evt-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease;
}
.evt-marker:hover { transform: scale(1.18); }
.evt-marker .fa { font-size: 14px; }
.evt-marker.alert { animation: markerPulse 1.4s ease-in-out infinite; }

@keyframes markerPulse {
  0%, 100% { box-shadow: 0 0 10px 1px rgba(0,0,0,0.5), 0 0 0 0 currentColor; }
  50% { box-shadow: 0 0 10px 1px rgba(0,0,0,0.5), 0 0 0 8px transparent; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Ocultar atribución voluminosa por defecto de MapLibre pero dejar el enlace */
.maplibregl-ctrl-attrib { font-size: 10px; background: rgba(3, 9, 20, 0.6) !important; }
.maplibregl-ctrl-attrib a { color: var(--text-dim); }

/* ==========================================================================
   SHELL / APP DE UNA SOLA PÁGINA
   ========================================================================== */
:root { --topbar-h: 58px; }

/* --- Barra superior ------------------------------------------------------ */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; z-index: 500;
  background: rgba(6, 14, 34, 0.9);
  backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
}
body.logged-out #topbar { display: none; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 14px; }
.tb-logo { height: 26px; }
.apptabs { display: flex; gap: 4px; }
.apptab {
  font-family: 'Barlow', sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 0.5px;
  color: var(--text-dim); background: transparent; border: 1px solid transparent;
  padding: 7px 14px; border-radius: 9px; cursor: pointer;
}
.apptab:hover { color: var(--text); }
.apptab.active { color: #fff; background: rgba(0,141,213,0.16); border-color: var(--glass-border); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.user-chip .fa { color: var(--blue-300); }
.btn-logout {
  font-family: inherit; font-size: 11px; color: var(--text-dim);
  background: transparent; border: 1px solid var(--glass-border);
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.btn-logout:hover { color: var(--text); border-color: var(--blue-400); }
.tb-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; }

/* --- Sistema de pantallas ------------------------------------------------ */
.screen { position: absolute; inset: var(--topbar-h) 0 0 0; display: none; overflow: auto; }
.screen.active { display: block; }
.screen.fullbleed { inset: 0; }
#screen-map.active, #screen-hub.active, #screen-users.active, #screen-visor.active { display: block; }
#screen-map { overflow: hidden; }

/* --- Login --------------------------------------------------------------- */
#screen-login {
  display: none; align-items: center; justify-content: center; z-index: 400;
  background: radial-gradient(1200px 700px at 50% 35%, #0a1c3f 0%, #061229 50%, #030914 100%);
}
#screen-login.active { display: flex; }
.login-card { width: 380px; max-width: 90vw; padding: 34px 34px 26px; text-align: center; }
.login-logo { width: 200px; margin: 0 auto 18px; filter: drop-shadow(0 0 20px rgba(0,167,236,0.4)); display: block; }
.login-title { font-size: 22px; margin: 0 0 4px; }
.login-sub { font-size: 12px; color: var(--text-dim); margin: 0 0 24px; letter-spacing: 1px; text-transform: uppercase; }
.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 6px; letter-spacing: 1px; text-transform: uppercase; }
.field input, .modal-body input, .modal-body select {
  width: 100%; padding: 11px 13px; font-family: inherit; font-size: 14px;
  color: var(--text); background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border); border-radius: 10px; outline: none;
}
.field input:focus, .modal-body input:focus, .modal-body select:focus { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(0,141,213,0.18); }
.login-error { color: #ff6b6b; font-size: 12px; margin: 2px 0 10px; }
.login-hint { font-size: 11px; color: var(--text-faint); margin-top: 14px; }
.btn.block { width: 100%; justify-content: center; margin-top: 6px; }

/* --- Cabecera de pantalla ------------------------------------------------ */
.screen-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px 14px; gap: 16px; flex-wrap: wrap;
}
.screen-title { font-size: 24px; margin: 0; }
.head-actions { display: flex; gap: 10px; }

/* --- Tarjetas / tablas --------------------------------------------------- */
.card {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow: auto; max-height: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-weight: 600; font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-faint); padding: 8px 10px; border-bottom: 1px solid var(--glass-border); position: sticky; top: 0;
  background: rgba(8,18,40,0.9); backdrop-filter: blur(6px);
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,0.05); color: var(--text); vertical-align: middle; }
.data-table tr:hover td { background: rgba(255,255,255,0.03); }
.data-table .fa { margin-right: 6px; }
.type-badge { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.type-badge .dot { width: 9px; height: 9px; border-radius: 3px; box-shadow: 0 0 7px 1px currentColor; }
.link-btn { background: none; border: none; color: var(--blue-300); cursor: pointer; font: inherit; font-size: 12px; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { background: rgba(0,141,213,0.16); }

/* --- Hub ----------------------------------------------------------------- */
.hub-grid {
  display: grid; gap: 16px; padding: 0 28px 28px;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: 'map side' 'graphs graphs';
  height: calc(100% - 92px);
}
.card.hub-map { grid-area: map; padding: 0; overflow: hidden; position: relative; min-height: 0; min-width: 0; }
#hub-map-slot { position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden; }
.hub-side { grid-area: side; display: flex; flex-direction: column; gap: 16px; min-height: 0; min-width: 0; }
.hub-side .card { flex: 1; min-height: 0; overflow: hidden; }
.card.graphs { grid-area: graphs; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.card.minimap { display: flex; flex-direction: column; }
.card.eventviewer { display: flex; flex-direction: column; overflow: hidden; }
.card.graphs canvas { flex: 1; width: 100%; min-height: 0; border-radius: 10px; background: #050f22; }
.card.minimap canvas { flex: 1; width: 100%; min-height: 0; border-radius: 10px; background: #050f22; }
.card.eventviewer .table-wrap { flex: 1; min-height: 0; }
.mini-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; font-size: 11px; color: var(--text-dim); }
.mini-legend .mi { display: flex; align-items: center; gap: 6px; }
.mini-legend .fa { font-size: 12px; }

/* --- Botones extra ------------------------------------------------------- */
.btn.small { padding: 7px 11px; font-size: 12px; }
.seg.small { padding: 3px; }
.seg.small .btn { padding: 6px 11px; font-size: 12px; border: none; background: transparent; }
.seg.small .btn.active { background: var(--blue-500); color: #fff; }

/* --- Toolbar del mapa ---------------------------------------------------- */
#map-toolbar {
  position: absolute; top: 14px; left: 14px; right: 14px; z-index: 10;
  display: flex; align-items: center; gap: 8px; padding: 8px; flex-wrap: wrap;
}
#sidebar { top: 74px !important; }

/* --- Modales ------------------------------------------------------------- */
.modal-backdrop {
  position: absolute; inset: 0; z-index: 800;
  background: rgba(3,8,20,0.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.18s ease;
}
.modal {
  width: 460px; max-width: 92vw; max-height: 86vh; overflow: auto;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 16px; box-shadow: var(--shadow);
  animation: modalIn 0.2s cubic-bezier(0.16,1,0.3,1);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--glass-border); }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; line-height: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--glass-border); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wp-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.wp-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.wp-row input { padding: 8px 10px; font-size: 13px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type=range] { flex: 1; accent-color: var(--blue-400); }
.range-val { font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; color: var(--blue-300); font-weight: 700; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* --- Toasts -------------------------------------------------------------- */
#toast-root { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 900; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(8,18,40,0.95); border: 1px solid var(--glass-border);
  color: var(--text); padding: 10px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px;
  animation: toastIn 0.25s ease;
}
.toast .fa { color: var(--blue-300); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --- Visor DAS ----------------------------------------------------------- */
.vpane { padding: 0 28px 28px; height: calc(100% - 92px); }
.card.fill { height: 100%; display: flex; flex-direction: column; }
.card.fill canvas { flex: 1; width: 100%; min-height: 0; border-radius: 10px; background: #050f22; }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; height: 100%; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 0 28px 16px; }
.stat-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 18px 20px; }
.stat-card .val { font-family: 'Barlow', sans-serif; font-size: 34px; font-weight: 800; color: var(--blue-300); }
.stat-card .lbl { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.export-card { max-width: 720px; }
.export-card p { color: var(--text-dim); }

/* ==========================================================================
   EXTENSIONES: timeline, notificaciones, detalle, filtros, salud, a11y
   ========================================================================== */

/* --- Badge de simulación + salud + campana ------------------------------- */
.sim-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  color: #ffd23f; border: 1px solid rgba(255,210,63,0.4); background: rgba(255,210,63,0.1);
  padding: 4px 9px; border-radius: 999px;
}
.tb-health { display: flex; gap: 5px; align-items: center; background: transparent; border: 1px solid var(--glass-border); border-radius: 9px; padding: 8px 10px; cursor: pointer; }
.tb-health:hover { border-color: var(--blue-400); }
.hdot { width: 9px; height: 9px; border-radius: 50%; background: #00c864; box-shadow: 0 0 7px 1px currentColor; color: #00c864; }
.hdot.warn { background: #ffd23f; color: #ffd23f; }
.hdot.down { background: #ff4444; color: #ff4444; }
.icon-btn { position: relative; background: transparent; border: 1px solid var(--glass-border); border-radius: 9px; color: var(--text); padding: 8px 11px; cursor: pointer; }
.icon-btn:hover { border-color: var(--blue-400); }
.icon-btn .fa { font-size: 15px; }
.badge-count {
  position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px;
  background: #ff4444; color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* --- Panel de notificaciones --------------------------------------------- */
#notif-panel {
  position: absolute; top: calc(var(--topbar-h) + 6px); right: 200px; width: 340px; z-index: 700;
  padding: 6px; max-height: 60vh; overflow: auto;
  background: #0a1428; backdrop-filter: none;
}
#notif-panel[hidden] { display: none; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px; }
.notif-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.notif-item:hover { background: rgba(255,255,255,0.05); }
.notif-item.unread { background: rgba(0,141,213,0.1); }
.notif-item .fa { font-size: 16px; }
.notif-item .n-txt { flex: 1; }
.notif-item .n-t { font-size: 13px; font-weight: 600; }
.notif-item .n-s { font-size: 11px; color: var(--text-dim); }
.notif-empty { padding: 22px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* --- Timeline ------------------------------------------------------------ */
#timeline {
  position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 8px 14px; z-index: 10;
  width: min(620px, 76vw);
}
#timeline input[type=range] { flex: 1; accent-color: var(--blue-400); }
.tl-time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--blue-300); font-weight: 700; min-width: 46px; }

/* --- Barra de filtros ---------------------------------------------------- */
.filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.filter-bar input[type=search], .filter-bar select {
  padding: 7px 10px; font-family: inherit; font-size: 12px; color: var(--text);
  background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border); border-radius: 9px; outline: none;
}
.filter-bar input[type=search] { flex: 1; min-width: 120px; }
.filter-bar .minint { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.filter-bar .minint input { width: 80px; accent-color: var(--blue-400); }
.data-table.sortable th[data-sort] { cursor: pointer; user-select: none; }
.data-table.sortable th[data-sort]:hover { color: var(--text); }
.data-table th.sorted::after { content: ' ▾'; color: var(--blue-300); }
.data-table th.sorted.asc::after { content: ' ▴'; }

/* --- Insignias de estado ------------------------------------------------- */
.status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.status-badge.new { color: #00d0ff; background: rgba(0,208,255,0.12); }
.status-badge.ack { color: #00c864; background: rgba(0,200,100,0.12); }
.status-badge.false { color: var(--text-faint); background: rgba(255,255,255,0.06); }
.evt-marker.muted { opacity: 0.4; }
.evt-marker.ack { border-color: #00c864; }

/* --- Drawer de detalle --------------------------------------------------- */
.drawer {
  position: absolute; top: var(--topbar-h); right: 0; bottom: 0; width: 340px; max-width: 88vw; z-index: 750;
  background: rgba(8,18,40,0.96); backdrop-filter: blur(var(--glass-blur));
  border-left: 1px solid var(--glass-border); box-shadow: -12px 0 40px rgba(0,0,0,0.45);
  padding: 20px; overflow: auto; animation: drawerIn 0.24s cubic-bezier(0.16,1,0.3,1);
}
.drawer[hidden] { display: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.drawer-head h2 { font-size: 17px; margin: 0; }
.drawer .d-type { display: flex; align-items: center; gap: 10px; font-family: 'Barlow', sans-serif; font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.drawer .d-type .fa { font-size: 22px; }
.drawer .d-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; }
.drawer .d-row span { color: var(--text-dim); }
.drawer textarea {
  width: 100%; min-height: 74px; margin-top: 6px; padding: 10px; resize: vertical;
  font-family: inherit; font-size: 13px; color: var(--text);
  background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border); border-radius: 10px; outline: none;
}
.drawer .d-actions { display: flex; gap: 8px; margin-top: 16px; }
.drawer .d-actions .btn { flex: 1; justify-content: center; }
@keyframes drawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Salud (modal sparklines) -------------------------------------------- */
.health-metric { margin-bottom: 16px; }
.health-metric .hm-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.health-metric .hm-val { color: var(--blue-300); font-weight: 700; font-variant-numeric: tabular-nums; }
.health-metric canvas { width: 100%; height: 46px; display: block; }
.health-sim { font-size: 12px; color: #ffd23f; margin-top: 4px; }

/* --- Tooltip de evento enriquecido --------------------------------------- */
.evt-pop.rich { width: 232px; }
.ep-head { display: flex; align-items: center; gap: 7px; font-family: 'Barlow', sans-serif; font-weight: 700; font-size: 13.5px; }
.ep-head .fa { font-size: 15px; }
.ep-head .ep-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-status { font-size: 8px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; padding: 2px 6px; border-radius: 999px; }
.ep-status.new { color: #00d0ff; background: rgba(0,208,255,0.14); }
.ep-status.ack { color: #00c864; background: rgba(0,200,100,0.14); }
.ep-status.false { color: var(--text-faint); background: rgba(255,255,255,0.08); }
.ep-meter { height: 5px; border-radius: 6px; background: rgba(255,255,255,0.08); margin: 7px 0 6px; overflow: hidden; }
.ep-meter span { display: block; height: 100%; border-radius: 6px; box-shadow: 0 0 8px 1px currentColor; }
.ep-wave { width: 100%; height: 18px; display: block; opacity: 0.85; margin-bottom: 6px; }
.ep-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 8px; }
.ep-grid > div { display: flex; flex-direction: column; }
.ep-grid span { font-size: 8px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; }
.ep-grid b { font-size: 11px; color: var(--text); font-variant-numeric: tabular-nums; }
.ep-foot { margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--glass-border); font-size: 9px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* --- Accesibilidad: foco visible ----------------------------------------- */
:focus-visible { outline: 2px solid var(--blue-300); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible, .apptab:focus-visible, .icon-btn:focus-visible { outline-offset: 3px; }

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 1040px) {
  .hub-grid { grid-template-columns: 1fr; grid-template-rows: 1.1fr 0.9fr 1.1fr; grid-template-areas: 'graphs' 'minimap' 'events'; height: auto; }
  .cmp-grid { grid-template-columns: 1fr; }
  #notif-panel { right: 12px; }
}
@media (max-width: 760px) {
  #topbar { padding: 0 10px; gap: 8px; }
  .apptab { padding: 6px 9px; font-size: 12px; }
  .sim-badge, .user-chip #tb-user { display: none; }
  .screen-head { padding: 16px; }
  .screen-title { font-size: 19px; }
  #sidebar { display: none; }
  #map-toolbar { gap: 4px; padding: 6px; }
  #map-toolbar .btn.small span:not(.fa) { display: none; }
  #timeline { width: 92vw; bottom: 84px; }
  .stats-row { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}
