/* 
  Dashboard Ejecutivo SIHCE - MINSA REUNIS
  Estilos Visuales Institucionales
*/

:root {
  /* Paleta Institucional MINSA REUNIS */
  --minsa-blue-dark: #002b49;
  --minsa-blue-header: #003366;
  --minsa-blue-accent: #005691;
  --minsa-red: #c0392b;
  --minsa-red-light: #e74c3c;
  
  /* Simbología de Módulos */
  --color-sihce: #2563eb;       /* 🔵 Azul SIHCE */
  --color-sihce-bg: #dbeafe;
  --color-hisminsa: #16a34a;    /* 🟢 Verde HISMINSA */
  --color-hisminsa-bg: #dcfce7;
  --color-integracion: #ea580c; /* 🟠 Naranja INTEGRACION */
  --color-integracion-bg: #ffedd5;
  --color-otros: #64748b;       /* ⚪ Gris OTROS */
  --color-otros-bg: #f1f5f9;

  /* Neutros y Fondos */
  --bg-page: #f4f6f9;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  /* Sombras y Radios */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Clases de Alineación */
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }

/* ==========================================================================
   HEADER REUNIS / MINSA
   ========================================================================== */
.reunis-header {
  background: linear-gradient(135deg, var(--minsa-blue-dark) 0%, var(--minsa-blue-header) 100%);
  color: #ffffff;
  padding: 14px 24px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 4px solid var(--minsa-red);
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-badge {
  background-color: #ffffff;
  color: var(--minsa-blue-dark);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.logo-badge span {
  color: var(--minsa-red);
}

/* ==========================================================================
   LOGOTIPOS INSTITUCIONALES CABECERA (MINSA + PERÚ RESPONDE)
   ========================================================================== */
.header-logos {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background-color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.header-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
  display: block;
}

.header-logo.logo-minsa {
  width: 60px;
  height: 60px;
}

.header-logo.logo-peru-responde {
  width: 60px;
  height: 60px;
}

.logo-divider {
  width: 1px;
  height: 42px;
  background-color: #cbd5e1;
}

.header-title-group h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin-bottom: 2px;
}

.header-title-group p {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 400;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.header-timestamps {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.header-credits {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 1px;
  padding-right: 4px;
}

.header-credits .credit-source {
  font-size: 11px;
  color: #cbd5e1;
  font-weight: 500;
  line-height: 1.3;
}

.header-credits .credit-author {
  font-size: 11px;
  color: #93c5fd;
  font-weight: 600;
  letter-spacing: 0.3px;
  line-height: 1.3;
}

.timestamp-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
}

.timestamp-item i {
  color: #38bdf8;
  font-size: 13px;
}

.timestamp-label {
  color: #e2e8f0;
  font-weight: 400;
}

.timestamp-val {
  color: #ffffff;
  font-weight: 700;
}

/* Indicador Interactivo de Modo de Operación (Online / Offline) */
.header-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  border: 1px solid transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.header-mode-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.header-mode-badge.mode-offline {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.6);
}

.header-mode-badge.mode-offline i {
  color: #f59e0b;
}

.header-mode-badge.mode-offline:hover {
  background: rgba(245, 158, 11, 0.3);
  border-color: #f59e0b;
}

.header-mode-badge.mode-online {
  background: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  border-color: rgba(16, 185, 129, 0.6);
}

.header-mode-badge.mode-online i {
  color: #34d399;
}

.header-mode-badge.mode-online:hover {
  background: rgba(16, 185, 129, 0.3);
  border-color: #10b981;
}

/* ==========================================================================
   MAIN DASHBOARD LAYOUT
   ========================================================================== */
.dashboard-container {
  max-width: 1600px;
  margin: 20px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================================================
   PANEL DE FILTROS MULTINIVEL
   ========================================================================== */
.filter-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group > label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.filter-select {
  width: 100%;
  height: 38px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  box-sizing: border-box;
}

.filter-select option {
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-main);
}

.filter-select:focus {
  border-color: var(--minsa-blue-accent);
  box-shadow: 0 0 0 3px rgba(0, 86, 145, 0.15);
}

.filter-buttons {
  display: flex;
  gap: 8px;
}

.btn-primary {
  background-color: var(--minsa-blue-header);
  color: #ffffff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--minsa-blue-accent);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: #f1f5f9;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  height: 38px;
  min-height: 38px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  width: 100%;
}

.btn-secondary:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
}

/* ==========================================================================
   KPIS PRINCIPALES (GRID 2x2 Y COMPATIBILIDAD)
   ========================================================================== */
.kpi-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.kpi-grid-2x2 .kpi-card {
  margin-bottom: 0;
  padding: 14px 16px;
}

.kpi-grid-2x2 .kpi-value {
  font-size: 24px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .kpi-grid,
  .kpi-grid-2x2 {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
}

.kpi-card.total::before { background-color: var(--minsa-blue-header); }
.kpi-card.hisminsa::before { background-color: var(--color-hisminsa); }
.kpi-card.sihce::before { background-color: var(--color-sihce); }
.kpi-card.integracion::before { background-color: var(--color-integracion); }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.kpi-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.kpi-card.total .kpi-icon { background-color: #e0f2fe; color: #0369a1; }
.kpi-card.hisminsa .kpi-icon { background-color: var(--color-hisminsa-bg); color: var(--color-hisminsa); }
.kpi-card.sihce .kpi-icon { background-color: var(--color-sihce-bg); color: var(--color-sihce); }
.kpi-card.integracion .kpi-icon { background-color: var(--color-integracion-bg); color: var(--color-integracion); }

.kpi-body {
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-subtext {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
  font-size: 11px;
}

.badge-variation {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.badge-variation.up {
  background-color: #dcfce7;
  color: #15803d;
}

.badge-variation.down {
  background-color: #fee2e2;
  color: #b91c1c;
}

.badge-variation.neutral {
  background-color: #f1f5f9;
  color: #64748b;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background-color: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ==========================================================================
   ESTRUCTURA PRINCIPAL EN 2 COLUMNAS (MAPA VERTICAL + ANALÍTICA DERECHA)
   ========================================================================== */
.dashboard-split-grid {
  display: grid;
  grid-template-columns: 44% 56%;
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 1200px) {
  .dashboard-split-grid {
    grid-template-columns: 46% 54%;
  }
}

@media (max-width: 1024px) {
  .dashboard-split-grid {
    grid-template-columns: 1fr;
  }
}

/* Columna Izquierda: Panel del Mapa Territorial Vertical Alto */
.col-map-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.col-map-panel .map-wrapper {
  flex: 1;
  height: auto;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.col-map-panel #map-container {
  flex: 1;
  height: 100%;
  min-height: 510px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Columna Derecha: Bloque Analítico (KPIs 2x2 + Gráfico de Evolución) */
.col-analytics-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.col-analytics-panel .chart-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.col-analytics-panel .chart-wrapper {
  height: 310px;
  padding: 12px 16px;
  position: relative;
}

/* Tooltip personalizado estandarizado para Gráfico de Evolución Mensual (idéntico al del mapa) */
.chart-custom-tooltip {
  position: absolute;
  background-color: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  padding: 8px 12px;
  font-family: var(--font-family);
  z-index: 1000;
  pointer-events: none;
  transition: opacity 0.15s ease;
  min-width: 240px;
  max-width: 295px;
  box-sizing: border-box;
}

/* Compatibilidad para grid simple anterior */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .col-map-panel .map-wrapper {
    min-height: 480px;
  }
  .col-map-panel #map-container {
    min-height: 430px;
  }
}

.card-panel {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
}

.panel-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fafafa;
}

.panel-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}

.panel-title i {
  color: var(--minsa-blue-header);
  font-size: 14px;
}

.panel-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
}

.map-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  background-color: transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.map-legend .legend-item:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.map-legend .legend-item.active {
  background-color: #ffffff;
  border-color: #0284c7;
  color: var(--minsa-blue-header);
  box-shadow: 0 1px 4px rgba(2, 132, 199, 0.2);
  font-weight: 700;
}

.map-legend .legend-item.dimmed {
  opacity: 0.35;
}

.btn-legend-reset {
  background: #f8fafc;
  border: 1px dashed #0284c7;
  color: #0284c7;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-legend-reset:hover {
  background: #e0f2fe;
  border-color: #0369a1;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0,0,0,0.25);
}

.legend-dot.sihce { background-color: var(--color-sihce); }
.legend-dot.hisminsa { background-color: var(--color-hisminsa); }
.legend-dot.integracion { background-color: var(--color-integracion); }

.map-wrapper {
  height: 420px;
  width: 100%;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.map-breadcrumb-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 12px;
  font-size: 11.5px;
  min-height: 36px;
  z-index: 5;
}

.map-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.map-breadcrumbs .crumb {
  color: var(--minsa-blue-accent);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.map-breadcrumbs .crumb:hover {
  color: var(--minsa-blue-header);
  text-decoration: underline;
}

.map-breadcrumbs .crumb.current {
  color: #1e293b;
  font-weight: 700;
  cursor: default;
  text-decoration: none;
}

.map-breadcrumbs .sep {
  color: #94a3b8;
  font-size: 9px;
}

.map-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-level-badge {
  background-color: #e0f2fe;
  color: #0369a1;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid #bae6fd;
}

.btn-map-back {
  background-color: #ffffff;
  color: var(--minsa-blue-header);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.15s ease;
}

.btn-map-back:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
  color: var(--minsa-blue-accent);
}

#map-container {
  flex: 1;
  height: 100%;
  width: 100%;
  background-color: #f1f5f9;
}

/* Tooltip personalizado Leaflet (sin recortes, máxima legibilidad) */
.leaflet-tooltip.map-custom-tooltip {
  background-color: #ffffff !important;
  color: #1e293b !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16) !important;
  padding: 8px 12px !important;
  font-family: var(--font-family) !important;
  z-index: 9999 !important;
  max-width: 310px !important;
  white-space: normal !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  pointer-events: none;
}

.leaflet-tooltip-top.map-custom-tooltip:before {
  border-top-color: #cbd5e1 !important;
}
.leaflet-tooltip-bottom.map-custom-tooltip:before {
  border-bottom-color: #cbd5e1 !important;
}
.leaflet-tooltip-left.map-custom-tooltip:before {
  border-left-color: #cbd5e1 !important;
}
.leaflet-tooltip-right.map-custom-tooltip:before {
  border-right-color: #cbd5e1 !important;
}

/* Leyenda interactiva flotante en el mapa (ubicada en inferior izquierda y minimizada por defecto) */
.map-legend-box {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  padding: 8px 12px;
  font-size: 11px;
  min-width: 175px;
  max-width: 220px;
  color: #1e293b;
  transition: all 0.2s ease;
  user-select: none;
}

.map-legend-box .legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding-bottom: 5px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
  color: #002b49;
}

.map-legend-box .legend-header:hover {
  color: var(--minsa-blue-accent);
}

.map-legend-box .legend-toggle-icon {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  margin-left: 8px;
  transform: rotate(180deg); /* Cuando está abierta, la flecha apunta hacia abajo */
}

.map-legend-box.collapsed {
  min-width: auto;
  max-width: 150px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.95);
  cursor: pointer;
}

.map-legend-box.collapsed .legend-body {
  display: none;
}

.map-legend-box.collapsed .legend-header {
  border-bottom: none;
  padding-bottom: 0;
}

.map-legend-box.collapsed .legend-toggle-icon {
  transform: rotate(0deg); /* Cuando está colapsada en bottom-left, apunta hacia arriba */
}

.legend-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  font-weight: 700;
  margin: 6px 0 4px 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin-bottom: 3px;
  font-weight: 500;
}

.legend-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

.legend-intensity-bar {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.intensity-chip {
  flex: 1;
  text-align: center;
  padding: 2px 0;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: #1e293b;
}

/* ==========================================================================
   VENTANA EMERGENTE (POPUP) DE ESTABLECIMIENTO CON GOOGLE MAPS
   ========================================================================== */
.leaflet-popup.estab-leaflet-popup .leaflet-popup-content-wrapper {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
  padding: 0;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.leaflet-popup.estab-leaflet-popup .leaflet-popup-content {
  margin: 0;
  padding: 12px 14px;
  line-height: 1.4;
  font-family: var(--font-family);
  max-width: 315px;
  box-sizing: border-box;
}

.leaflet-popup.estab-leaflet-popup .leaflet-popup-close-button {
  top: 8px;
  right: 8px;
  color: #64748b;
  font-size: 16px;
  font-weight: 700;
}

.estab-gmap-popup {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.estab-popup-header {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 6px;
}

.estab-popup-badge {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--minsa-blue-accent);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.estab-popup-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: #002b49;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.3;
}

.estab-popup-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.estab-popup-geo {
  font-size: 10.5px;
  color: #64748b;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.estab-popup-map-frame {
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.estab-popup-offline-geo {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 6px 0;
}

.estab-popup-offline-icon {
  font-size: 24px;
  color: var(--minsa-blue-header);
}

.estab-popup-offline-text strong {
  display: block;
  font-size: 12px;
  color: var(--text-main);
}

.estab-popup-offline-text p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: monospace;
}

.estab-popup-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.estab-popup-coords {
  font-size: 10px;
  color: #64748b;
  font-family: monospace;
}

.btn-gmap-open {
  background-color: #1a73e8;
  color: #ffffff !important;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-gmap-open:hover {
  background-color: #1557b0;
  box-shadow: 0 2px 6px rgba(26, 115, 232, 0.35);
}

/* Efectos visuales de polígonos */
path.leaflet-interactive {
  transition: fill 0.15s ease, stroke-width 0.15s ease;
  cursor: pointer;
}

.chart-toggle-group {
  display: flex;
  background-color: #f1f5f9;
  padding: 3px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-btn.active {
  background-color: #ffffff;
  color: var(--minsa-blue-header);
  box-shadow: var(--shadow-sm);
}

.chart-wrapper {
  padding: 14px 16px;
  height: 420px;
  width: 100%;
  position: relative;
}

/* ==========================================================================
   TABLA DE REPORTE DETALLADO (AJUSTE Y DISTRIBUCIÓN DE ANCHURA)
   ========================================================================== */
.table-panel {
  margin-bottom: 30px;
  width: 100%;
}

.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 280px;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 13px;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

.search-input:focus {
  border-color: var(--minsa-blue-accent);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  min-height: 480px; /* Mantiene la altura del reporte para visualizar los tooltips sin cortes al buscar */
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
  table-layout: auto; /* Permite una distribución flexible y proporcionada */
}

.custom-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  padding: 12px 10px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.custom-table th:hover {
  color: var(--minsa-blue-header);
}

.custom-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.custom-table td.estab-cell {
  white-space: normal;
  word-break: break-word;
  max-width: 320px;
  line-height: 1.35;
}

.custom-table tbody tr:hover {
  background-color: #f8fafc;
}

.table-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}

.table-badge.sihce { background-color: var(--color-sihce-bg); color: var(--color-sihce); }
.table-badge.hisminsa { background-color: var(--color-hisminsa-bg); color: var(--color-hisminsa); }
.table-badge.integracion { background-color: var(--color-integracion-bg); color: var(--color-integracion); }
.table-badge.otros { background-color: var(--color-otros-bg); color: var(--color-otros); }

.table-footer {
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-btn {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  background-color: #f1f5f9;
  border-color: var(--minsa-blue-accent);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==========================================================================
   DROPDOWN MULTI-SELECCIÓN MODERNO
   ========================================================================== */
.multiselect-wrapper {
  position: relative;
  width: 100%;
}

.multiselect-btn {
  width: 100%;
  height: 38px;
  min-height: 38px;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  text-align: left;
}

.multiselect-btn:hover {
  border-color: #94a3b8;
}

.multiselect-btn.open {
  border-color: var(--minsa-blue-accent);
  box-shadow: 0 0 0 3px rgba(0, 86, 145, 0.15);
}

.multiselect-text {
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-main);
  line-height: 1.4;
  letter-spacing: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 20px);
  display: inline-block;
}

.multiselect-btn i {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.multiselect-btn.open i {
  transform: rotate(180deg);
}

.multiselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 1050;
  display: none;
  flex-direction: column;
  max-height: 290px;
}

.multiselect-menu.active {
  display: flex;
}

.multiselect-header-actions {
  padding: 7px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-family: inherit;
}

.multiselect-action-link {
  color: var(--minsa-blue-accent);
  text-decoration: none;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.multiselect-action-link:hover {
  text-decoration: underline;
}

.multiselect-search-box {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-color);
}

.multiselect-search-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 400;
  font-family: inherit;
  letter-spacing: normal;
  color: var(--text-main);
  outline: none;
  box-sizing: border-box;
}

.multiselect-search-input:focus {
  border-color: var(--minsa-blue-accent);
}

.multiselect-list {
  overflow-y: auto;
  padding: 4px 0;
  max-height: 190px;
}

.multiselect-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--text-main) !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
  line-height: 1.4;
}

.multiselect-option span {
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--text-main) !important;
  letter-spacing: normal !important;
  text-transform: none !important;
}

.multiselect-option:hover {
  background-color: #f1f5f9;
}

.multiselect-option input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--minsa-blue-header);
  width: 14px;
  height: 14px;
}

.multiselect-footer-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px;
  background-color: #f8fafc;
  border-top: 1px solid #e2e8f0;
  border-bottom-left-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

.multiselect-btn-apply {
  background-color: var(--minsa-blue-header);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.multiselect-btn-apply:hover {
  background-color: var(--minsa-blue-accent);
}

/* ==========================================================================
   TOOLTIPS Y VIÑETAS DE VARIACIÓN EN TABLA DETALLADA
   ========================================================================== */
.cell-interactive {
  position: relative;
  cursor: pointer;
}

.cell-interactive:hover {
  z-index: 1300;
}

.cell-interactive .cell-val {
  border-bottom: 1px dashed #94a3b8;
  display: inline-block;
  cursor: pointer;
}

/* Envoltura para número de medida + viñeta de variación */
.cell-measure-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
  white-space: nowrap;
}

/* Viñeta de variación porcentual interanual en celdas de tabla (solo ícono) */
.table-var-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  font-size: 9px;
  border-radius: 4px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.table-var-badge.up {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.table-var-badge.down {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.table-var-badge.neutral {
  background-color: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

/* Tooltip interactivo Top 10 Sistemas */
.top10-tooltip {
  display: none;
  position: absolute;
  right: 0;
  top: 85%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 11px 14px;
  z-index: 1200;
  width: 480px;
  min-width: 440px;
  max-width: 520px;
  text-align: left;
  font-family: var(--font-family);
  color: var(--text-main);
  pointer-events: none;
}

.top10-tooltip.tooltip-up {
  top: auto;
  bottom: 85%;
}

.cell-interactive:hover .top10-tooltip {
  display: block;
}

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

.top10-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top10-header-left strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--minsa-blue-header);
}

.top10-var-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  white-space: nowrap;
}

.top10-var-badge.up {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.top10-var-badge.down {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.top10-var-badge.neutral {
  background-color: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.top10-subtitle {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.top10-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.top10-table th {
  padding: 5px 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid #e2e8f0;
  background: transparent;
}

.top10-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #f8fafc;
  font-size: 11px;
  vertical-align: top;
}

.top10-table tr:hover td {
  background: #f8fafc;
}

.top10-empty {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
}

@media (max-width: 768px) {
  .header-actions {
    align-items: flex-start;
    width: 100%;
  }
  .header-timestamps {
    justify-content: flex-start;
  }
  .header-credits {
    align-items: flex-start;
    text-align: left;
    padding-right: 0;
  }
}

