/* ==============================================================
   VARIABLES DE TEMA
============================================================== */
:root {
  --primary-color:#3498db;
  --primary-color-hover:#2980b9;
  --secondary-color:#2c3e50;
  --secondary-color-alt:#5d6d7e;
  --success-color:#27ae60;
  --warning-color:#f39c12;
  --danger-color:#e74c3c;

  --text-light:#ecf0f1;
  --text-muted:#bdc3c7;
  --text-dark:#2c3e50;

  --bg-dark:#34495e;
  --bg-darker:#2c3e50;
  --bg-panel-glass:rgba(52,73,94,0.6);
  --bg-panel-solid:rgba(52,73,94,0.85);

  --border-radius:8px;
  --shadow:0 4px 6px rgba(0,0,0,0.15);
  --transition:all .3s ease;
  --focus-ring:0 0 0 2px rgba(52,152,219,.45);

  --scrollbar-track:rgba(255,255,255,0.10);
  --scrollbar-thumb:var(--primary-color);

  --panel-border:1px solid rgba(255,255,255,0.07);
  --panel-divider:1px solid rgba(255,255,255,0.12);

  --search-bg:#1f2731;
  --search-border:#3a4a5d;
  --search-border-focus:#3498db;
  --search-placeholder:#8da2b5;
  --search-text:#ecf0f1;
  --search-clear-bg:#5d6d7e;
  --search-clear-bg-hover:#6d7e8f;
  --search-icon:#95a5b0;
}

/* ==============================================================
   RESET BÁSICO
============================================================== */
* { margin:0; padding:0; box-sizing:border-box; }
html,body { width:100%; height:100%; }
body {
  font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background:#ffffff; /* Fondo de página blanco */
  color:var(--text-light);
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
}

/* ==============================================================
   MAPA & SIDEBAR
============================================================== */
#map {
  position:absolute;
  inset:0 0 0 450px;
  height:100vh;
  background:#ffffff; /* CAMBIO: Fondo del mapa a blanco para carga de teselas */
  transition:var(--transition);
}
#sidebar {
  position:absolute;
  inset:0 auto 0 0;
  width:450px;
  background:linear-gradient(135deg,var(--bg-darker) 0%,var(--bg-dark) 100%);
  color:var(--text-light);
  overflow-y:auto;
  padding:20px 22px 28px;
  z-index:1000;
  box-shadow:var(--shadow);
  backdrop-filter:blur(6px);
  will-change:transform;
  transition:transform .32s ease;
}
body.sidebar-collapsed #sidebar { transform:translateX(-100%); }
body.sidebar-collapsed #map { inset:0; }

/* Scroll interior */
#sidebar::-webkit-scrollbar { width:8px; }
#sidebar::-webkit-scrollbar-track { background:rgba(255,255,255,0.08); }
#sidebar::-webkit-scrollbar-thumb { background:var(--secondary-color); border-radius:4px; }
#sidebar::-webkit-scrollbar-thumb:hover { background:var(--primary-color); }

/* ==============================================================
   FAB TOGGLE
============================================================== */
.sidebar-fab {
  position:fixed;
  bottom:18px;
  right:18px;
  width:56px;
  height:56px;
  border:none;
  border-radius:50%;
  background:var(--primary-color);
  color:#fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:1.25rem;
  box-shadow:0 6px 18px -6px rgba(0,0,0,.55),0 2px 5px -2px rgba(0,0,0,0.4);
  cursor:pointer;
  z-index:1600;
  transition:background .25s ease,transform .25s ease;
}
.sidebar-fab:hover { background:var(--primary-color-hover); transform:translateY(-3px);}
.sidebar-fab:active { transform:translateY(-1px) scale(.97); }
.sidebar-fab:focus { outline:none; box-shadow:0 0 0 3px rgba(52,152,219,0.35),0 6px 18px -6px rgba(0,0,0,0.55); }
body:not(.sidebar-collapsed) .sidebar-fab { background:var(--secondary-color); }
body:not(.sidebar-collapsed) .sidebar-fab:hover { background:var(--secondary-color-alt); }
.sidebar-fab i { transition:opacity .18s ease,transform .18s ease; }
.sidebar-fab.changing i { opacity:0; transform:scale(.55) rotate(-25deg); }

/* ==============================================================
   CABECERA
============================================================== */
.header h1 {
  font-size:1.6em;
  margin-bottom:4px;
  color:var(--primary-color);
  display:flex;
  align-items:center;
  gap:10px;
  letter-spacing:.5px;
}
.subtitle {
  color:var(--text-muted);
  font-size:.9em;
  margin-bottom:18px;
  font-style:italic;
  letter-spacing:.4px;
}

/* ==============================================================
   BLOQUES / PANELES
============================================================== */
#time-controls,
#controls,
#pais,
#stations-panel,
#stats,
#legend {
  background:var(--bg-panel-glass);
  backdrop-filter:blur(4px);
  border-radius:var(--border-radius);
  padding:15px 16px 18px;
  margin-bottom:20px;
  border:var(--panel-border);
  position:relative;
  border-left:4px solid var(--primary-color);
}

/* ==============================================================
   SLIDER / HORAS
============================================================== */
.control-group { margin-bottom:16px; }
.control-group:last-child { margin-bottom:0; }
.control-group label {
  display:block;
  margin-bottom:7px;
  font-weight:600;
  font-size:.78rem;
  letter-spacing:.5px;
  text-transform:uppercase;
  color:var(--text-muted);
}
.range-container { display:flex; align-items:center; gap:15px; }
#hours-range {
  flex:1;
  height:6px;
  border-radius:3px;
  background:linear-gradient(90deg,#5d6d7e,#6d7e8f);
  outline:none;
  -webkit-appearance:none;
  cursor:pointer;
}
#hours-range::-webkit-slider-thumb {
  -webkit-appearance:none;
  width:18px; height:18px;
  border-radius:50%;
  background:var(--primary-color);
  cursor:pointer;
  border:2px solid #fff;
  box-shadow:0 2px 6px rgba(0,0,0,.35);
  transition:var(--transition);
}
#hours-range::-webkit-slider-thumb:hover { background:var(--primary-color-hover); transform:scale(1.05); }
#hours-value {
  font-weight:700;
  color:var(--primary-color);
  min-width:88px;
  font-size:.86em;
  letter-spacing:.3px;
  text-align:right;
}

/* ==============================================================
   BOTONES RÁPIDOS
============================================================== */
.quick-buttons { display:flex; gap:6px; flex-wrap:wrap; margin-top:12px; }
.btn-time {
  padding:8px 10px;
  background:#5d6d7e;
  border:none;
  border-radius:5px;
  color:#fff;
  cursor:pointer;
  font-size:.78em;
  font-weight:600;
  letter-spacing:.3px;
  flex:1;
  min-width:50px;
  transition:var(--transition),transform .15s ease;
  position:relative;
}
.btn-inactivity {
  padding:8px 10px;
  background:#5d6d7e;
  border:none;
  border-radius:5px;
  color:#fff;
  cursor:pointer;
  font-size:.78em;
  font-weight:600;
  letter-spacing:.3px;
  flex:1;
  min-width:50px;
  transition:var(--transition),transform .15s ease;
  position:relative;
}
.btn-time:hover { background:#6d7e8f; transform:translateY(-2px); }
.btn-inactivity:hover { background:#6d7e8f; transform:translateY(-2px); }
.btn-time.active {
  background:var(--primary-color);
  color:#fff;
  box-shadow:0 3px 10px -2px rgba(52,152,219,0.5);
  transform:translateY(-2px);
  font-weight:700;
}
.btn-inactivity.active {
  background:var(--primary-color);
  color:#fff;
  box-shadow:0 3px 10px -2px rgba(52,152,219,0.5);
  transform:translateY(-2px);
  font-weight:700;
}
/* ==============================================================
   ESTADÍSTICAS
============================================================== */
#stats { padding:18px 18px 20px; }
.stat-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(130px,1fr));
  gap:14px;
  margin-bottom:14px;
}
.stat-item {
  display:flex;
  align-items:center;
  gap:8px;
  padding:4px 0;
}
.stat-item i { color:#d3dbe0; width:16px; text-align:center; }
.stat-label {
  color:var(--text-muted);
  font-size:.72rem;
  letter-spacing:.5px;
  text-transform:uppercase;
  font-weight:600;
}
.stat-value {
  color:var(--primary-color);
  font-weight:700;
  margin-left:auto;
  font-size:.9rem;
  text-shadow:0 0 4px rgba(52,152,219,0.4);
}
.status-info {
  border-top:1px solid rgba(255,255,255,0.1);
  padding-top:12px;
  margin-top:4px;
}
.status-item {
  display:flex;
  justify-content:space-between;
  margin:5px 0;
  font-size:.75rem;
}
.status-label { color:var(--text-muted); }
.status-value {
  color:var(--primary-color);
  font-weight:500;
  font-family:monospace;
}

/* ==============================================================
   CONTROLES PRINCIPALES
============================================================== */
#controls .control-group { display:flex; flex-wrap: wrap; gap:8px; }
#controls .control-group .btn {
  flex: 1 1 calc(50% - 8px);  /* 2 columnas considerando el gap */
  box-sizing: border-box;
}
.btn {
  padding:12px 15px;
  border:none;
  border-radius:6px;
  cursor:pointer;
  font-size:.86em;
  transition:var(--transition),transform .15s ease;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-weight:600;
  border:2px solid transparent;
  letter-spacing:.4px;
  background:#5d6d7e;
  color:#fff;
  position:relative;
}
.btn:hover { transform:translateY(-2px); }
.btn:active { transform:translateY(0); }
.btn-primary { background:var(--primary-color); }
.btn-primary:hover { background:var(--primary-color-hover); }
.btn-secondary { background:#95a5a6; }
.btn-secondary:hover { background:#7f8c8d; }
.btn-small { padding:6px 10px; font-size:.92em; font-weight:600; border-radius:5px; }
.btn.active {
  box-shadow:0 3px 10px -2px rgba(52,152,219,.5);
  transform:translateY(-2px);
  border-color:rgba(255,255,255,0.35);
}
#auto-update.active { background:var(--success-color); border-color:var(--success-color); }
#auto-update:not(.active) { background:var(--secondary-color); }
#toggle-inactive.active { background:var(--primary-color); }
#toggle-inactive:not(.active) { background:var(--secondary-color); }
.btn.active-label-toggle { background:var(--secondary-color); color:#fff; }
#toggle-tracks.active { background:var(--success-color); }
#toggle-tracks:not(.active) { background:var(--secondary-color); }
@media (max-width:520px) {
  #controls .control-group .btn {
    flex: 1 1 100%;
  }
}

/* ==============================================================
   PANEL ESTACIONES
============================================================== */
#stations-panel { padding:0; overflow:hidden; }
.panel-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 18px;
  background:linear-gradient(90deg,rgba(0,0,0,0.25),rgba(255,255,255,0.05));
  border-bottom:var(--panel-divider);
}
.panel-header h3 {
  color:var(--text-light);
  font-size:.95em;
  margin:0;
  letter-spacing:.5px;
  display:flex;
  align-items:center;
  gap:8px;
}
.panel-header h3 i { color:var(--primary-color); }
.panel-content {
  max-height:400px;
  overflow-y:auto;
}
.panel-content::-webkit-scrollbar { width:6px; }
.panel-content::-webkit-scrollbar-thumb { background:var(--primary-color); border-radius:3px; }

/* Búsqueda */
.station-search-wrapper {
  padding:10px 16px 4px;
  background:rgba(255,255,255,0.04);
  border-bottom:1px solid rgba(255,255,255,0.1);
}
.search-input-group {
  position:relative;
  display:flex;
  align-items:center;
  background:var(--search-bg);
  border:1px solid var(--search-border);
  border-radius:6px;
  padding:4px 8px 4px 34px;
  transition:var(--transition);
}
.search-input-group:focus-within {
  border-color:var(--search-border-focus);
  box-shadow:0 0 0 2px rgba(52,152,219,0.35);
}
.search-icon {
  position:absolute;
  left:10px;
  font-size:.9rem;
  color:var(--search-icon);
  pointer-events:none;
}
#station-search {
  flex:1;
  background:transparent;
  border:none;
  outline:none;
  color:var(--search-text);
  font-size:.83rem;
  font-weight:600;
  letter-spacing:.3px;
  padding:4px 4px;
}
#station-search::placeholder {
  color:var(--search-placeholder);
  font-weight:400;
  letter-spacing:.4px;
}
.clear-search-btn {
  background:var(--search-clear-bg);
  border:none;
  color:#fff;
  width:26px;
  height:26px;
  border-radius:5px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:var(--transition);
  margin-left:6px;
  font-size:.8rem;
}
.clear-search-btn:hover {
  background:var(--search-clear-bg-hover);
  transform:translateY(-2px);
}
.search-feedback {
  font-size:.65rem;
  margin-top:4px;
  color:var(--text-muted);
  font-style:italic;
  min-height:14px;
  letter-spacing:.4px;
}

.station-item {
  padding:12px 18px;
  border-bottom:1px solid rgba(255,255,255,0.07);
  cursor:pointer;
  transition:var(--transition);
  display:flex;
  align-items:center;
  gap:12px;
  position:relative;
}
.station-item:hover { background:rgba(255,255,255,0.06); }
.station-item:last-child { border-bottom:none; }
.station-item.highlight-search {
  outline:2px solid var(--primary-color);
  outline-offset:-2px;
  background:rgba(52,152,219,0.12);
}

.station-icon-img {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:26px;
  height:26px;
  margin-right:2px;
  flex-shrink:0;
}
.station-list-symbol {
  display:block;
  max-width:100%;
  max-height:100%;
  image-rendering:auto;
}
.station-info { flex:1; min-width:0; }
.station-callsign {
  font-weight:700;
  color:var(--primary-color);
  margin-bottom:3px;
  font-size:.86em;
  letter-spacing:.4px;
}
.station-meta {
  display:flex;
  justify-content:space-between;
  font-size:.7em;
  color:var(--text-muted);
  letter-spacing:.3px;
}
.station-time {
  color:#95a5a6;
  font-family:monospace;
  font-size:1.30em;
}
.station-inactive { opacity:.62; }
.station-inactive .station-callsign { color:#95a5a6; }

/* ==============================================================
   POPUPS LEAFLET
============================================================== */
.station-popup {
  min-width:255px;
  font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size:.9em;
}
.station-popup h3 {
  color:var(--primary-color);
  margin-bottom:8px;
  border-bottom:1px solid #eee;
  padding-bottom:4px;
  font-size:1.15em;
  letter-spacing:.5px;
}
.station-popup .info-row {
  display:flex;
  justify-content:space-between;
  margin:7px 0;
  font-size:1em;
  align-items:center;
  gap:10px;
}
.station-popup .info-label {
  font-weight:600;
  color:#555;
  min-width:95px;
  font-size:1em;
  letter-spacing:.3px;
  text-transform:uppercase;
}
.station-popup .info-value {
  color:#222;
  text-align:right;
  flex:1;
  font-weight:500;
}
.symbol-cell { display:flex; align-items:center; gap:0; justify-content:flex-end; }

.popup-symbol-img {
  border-radius:4px;
  background:#ffffff;
  padding:2px;
  display:inline-block;
  box-shadow:0 1px 3px rgba(0,0,0,.4);
  image-rendering:auto;
  border:1px solid rgba(0,0,0,0.1);
}

.station-popup .actions {
  margin-top:12px;
  display:flex;
  gap:8px;
  justify-content:space-between;
}

/* --- INICIO: NUEVO ESTILO POPUP TIEMPO --- */
.weather-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 12px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}
.weather-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
}
.weather-item i {
    color: var(--primary-color);
    width: 16px;
    text-align: center;
}
.weather-item .value {
    font-weight: 600;
    color: #333;
}
/* --- FIN: NUEVO ESTILO POPUP TIEMPO --- */


/* ==============================================================
   ICONOS / MARKERS
============================================================== */
.aprssym {
  display:block;
  user-select:none;
  -webkit-user-drag:none;
  image-rendering:auto;
  pointer-events:none;
}
.station-marker { background:transparent!important; border:none!important; }

/* ==============================================================
   ETIQUETAS (TOOLTIPS)
============================================================== */
.label-active,
.label-inactive {
  background:rgba(255,255,255,0.9);
  border-radius:4px;
  padding:2px 4px;
  font-size:11px;
  font-weight:600;
  line-height:1.1;
  box-shadow:0 1px 3px rgba(0,0,0,0.25);
  letter-spacing:.4px;
}
.label-inactive {
  background:rgba(240,240,240,0.65);
  color:#7f8c8d;
  filter:grayscale(.4);
}

/* ==============================================================
   SELECTOR PAÍS
============================================================== */
.country-group {
  margin:10px 0 18px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.country-group label {
  font-size:.72rem;
  font-weight:700;
  letter-spacing:.6px;
  text-transform:uppercase;
  color:var(--text-muted);
  display:flex;
  align-items:center;
  gap:6px;
}
#country-select {
  width:100%;
  padding:8px 12px;
  border:1px solid #3a4a5d;
  border-radius:6px;
  background:#1f2731;
  color:#fff;
  font-size:.78rem;
  font-weight:600;
  letter-spacing:.4px;
  outline:none;
  appearance:none;
  cursor:pointer;
  position:relative;
  transition:var(--transition);
  background-image:
    linear-gradient(45deg,transparent 50%,var(--primary-color) 50%),
    linear-gradient(135deg,var(--primary-color) 50%,transparent 50%),
    linear-gradient(to right,#1f2731,#1f2731);
  background-position:
    calc(100% - 18px) calc(50% - 4px),
    calc(100% - 13px) calc(50% - 4px),
    100% 0;
  background-size:6px 6px,6px 6px,2.6rem 100%;
  background-repeat:no-repeat;
}
#country-select:hover { background:#24303c; border-color:#4c6277; }
#country-select:focus { border-color:var(--primary-color); box-shadow:var(--focus-ring); }
#country-select option { background:#1f2731; color:#e5edf5; font-weight:500; }

/* ==============================================================
   LOADING OVERLAY
============================================================== */
.loading-overlay {
  position:fixed;
  inset:0;
  background:rgba(14,16,20,0.96);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:20000;
  font-family:system-ui, Arial, sans-serif;
}
.loading-box {
  width:min(430px,90%);
  background:#1c242e;
  border:1px solid #2d3a47;
  padding:26px 30px 32px;
  border-radius:14px;
  box-shadow:0 8px 40px -10px rgba(0,0,0,.55);
  color:#eef3f8;
  display:flex;
  flex-direction:column;
  gap:20px;
}
.loading-title {
  font-size:1.05rem;
  font-weight:600;
  display:flex;
  gap:10px;
  align-items:center;
  color:#d8e3ed;
  letter-spacing:.5px;
}
.loading-title i { color:#4da3ff; font-size:1.25rem; }
.progress-bar-wrapper {
  width:100%;
  height:14px;
  background:#13181f;
  border:1px solid #2a3744;
  border-radius:7px;
  overflow:hidden;
  position:relative;
}
.progress-bar {
  height:100%;
  width:8%;
  min-width:8px;
  background:linear-gradient(90deg,#1570ef,#45b2ff 50%,#1570ef);
  background-size:200% 100%;
  animation:moveGradient 2.8s linear infinite;
  transition:width .35s ease, opacity .4s ease .15s;
  box-shadow:0 0 0 1px #1570ef,0 0 10px -2px #1597ef;
  border-radius:7px;
}
.progress-bar.done {
  animation:none;
  background:var(--success-color);
  box-shadow:0 0 0 1px var(--success-color),0 0 10px -3px var(--success-color);
}
@keyframes moveGradient {
  0% { background-position:0 0; }
  100% { background-position:200% 0; }
}
.loading-hint {
  font-size:.72rem;
  letter-spacing:.4px;
  font-weight:500;
  color:#96aac0;
  text-align:right;
  opacity:.9;
  min-height:14px;
}

/* ==============================================================
   ACCESIBILIDAD / ESTADOS
============================================================== */
.btn:focus,
.btn-time:focus, .btn-inactivity:focus,
#country-select:focus,
#station-search:focus {
  outline:none;
  box-shadow:var(--focus-ring);
}
.btn:disabled,
.btn-inactivity:disabled,
.btn-time:disabled {
  opacity:.55;
  cursor:not-allowed;
  filter:grayscale(.3);
}
.btn:disabled:hover,
.btn-inactivity:disabled:hover
.btn-time:disabled:hover {
  transform:none;
}
.station-inactive { opacity:.6; }
.aprssym { pointer-events:none; }

/* ==============================================================
   SCROLLBAR GLOBAL
============================================================== */
::-webkit-scrollbar { width:6px; }
::-webkit-scrollbar-track { background:var(--scrollbar-track); border-radius:3px; }
::-webkit-scrollbar-thumb { background:var(--scrollbar-thumb); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:var(--primary-color-hover); }

/* ==============================================================
   SISTEMA DE NOTIFICACIONES (TOAST)
============================================================== */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 21000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.notification-toast {
    pointer-events: auto;
    padding: 12px 18px;
    border-radius: var(--border-radius);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateX(120%);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.notification-toast.show {
    opacity: 1;
    transform: translateX(0);
}
.notification-toast.info { background-color: var(--primary-color); }
.notification-toast.error { background-color: var(--danger-color); }


/* ==============================================================
   RESPONSIVE
============================================================== */
@media (max-width:900px) {
  #sidebar {
    width:100%;
    height:44vh;
    position:relative;
    inset:0;
  }
  #map {
    left:0;
    top:44vh;
    height:56vh;
    inset:auto 0 0 0;
  }
  body.sidebar-collapsed #sidebar { transform:translateY(-100%); }
  body.sidebar-collapsed #map { top:0; height:92vh; }
  .stat-grid { grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); }
  .sidebar-fab { bottom:14px; right:14px; }
}
@media (max-width:520px) {
  #sidebar { padding:14px 14px 24px; }
  .header h1 { font-size:1.35em; }
  .btn { padding:10px 12px; font-size:.78em; }
  .quick-buttons { gap:4px; }
  .panel-content { max-height:300px; }
  .search-input-group { padding-left:32px; }
  #station-search { font-size:.76rem; }
}

/* ==============================================================
   UTIL / ANIMACIONES / VISIBILIDAD
============================================================== */
@keyframes spin { to { transform:rotate(360deg); } }

/* Oculta los puntos del track cuando el mapa tiene esta clase */
.hide-track-points .track-point-marker {
  display: none;
}

/* --- INICIO: NUEVO MODAL HISTORIAL --- */
.history-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.history-modal-content {
    background: #fff;
    color: #333;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: min(600px, 94vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}
.history-modal-backdrop.visible { opacity: 1; }
.history-modal-backdrop.visible .history-modal-content { transform: scale(1); }
.history-modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-modal-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: var(--primary-color);
}
.history-modal-header .close-btn {
    background: none; border: none; font-size: 1.5em; cursor: pointer; color: #888;
}
.history-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.history-modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}
.history-modal-table th, .history-modal-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.history-modal-table th { font-weight: 600; color: #555; }
.history-modal-table tr:hover { background-color: #f9f9f9; }
.history-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f7f7f7;
    display:flex;
    justify-content: end;
}
/* --- FIN: NUEVO MODAL HISTORIAL --- */


/* --- INICIO: EFECTOS VISUALES SALTO (v4 - FINAL) --- */
.last-hop-line {
    /* FIX: Animación corregida para fluir de origen a destino */
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    animation: dash 1.2s ease-out forwards;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
@keyframes dash {
    from {
        stroke-dashoffset: 20;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.last-hop-pulse {
    stroke: none;
    animation: pulse 1.5s ease-out forwards;
}
@keyframes pulse {
    0% { r: 0; opacity: 0.9; }
    70% { r: 50px; opacity: 0.7; }
    100% { r: 60px; opacity: 0; }
}

/* FIX: Estrategia de onda con pseudo-elementos para un centrado perfecto */
.transmitting-wave-effect {
    pointer-events: none; /* El contenedor principal no captura eventos */
}
.transmitting-wave-effect::before,
.transmitting-wave-effect::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 25px; /* Tamaño inicial */
    height: 25px; /* Tamaño inicial */
    border-radius: 50%;
    animation: radio-wave-standalone 2s ease-out forwards;
}
.transmitting-wave-effect::before {
    border: 4px solid #ff9800;
    box-shadow: 0 0 15px 5px rgba(255, 152, 0, 0.7);
}
.transmitting-wave-effect::after {
    border: 2px solid #ffeb3b;
    animation-delay: 0.25s;
}
@keyframes radio-wave-standalone {
    from {
        width: 25px;
        height: 25px;
        opacity: 1;
    }
    to {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}
/* --- FIN: EFECTOS VISUALES SALTO --- */


/* --- INICIO: SECCIÓN RESTAURADA - INDICADOR DE ZOOM --- */
.zoom-level-indicator {
    background-color: rgba(44, 62, 80, 0.75);
    color: var(--text-light);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow);
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: left 0.32s ease; /* Transición suave al mover el panel */

    /* Posicionamiento manual robusto */
    position: absolute;
    bottom: 20px;
    left: 50%; /* Se actualizará con JS */
    transform: translateX(-50%);
    z-index: 1000;
}
/* --- FIN: SECCIÓN RESTAURADA - INDICADOR DE ZOOM --- */


/* ==============================================================
   NOTA SOBRE TRACKS
   El estilo de los polylines se establece dinámicamente desde JS.
============================================================== */
/* Iconos expandidos - solo borde amarillo */
.star-burst-item {
  z-index: 410 !important;
  border: 3px solid #FFD700 !important;
  border-radius: 50% !important;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.7) !important;
}

/* Icono central - borde naranja para distinguirlo */
.star-burst-center {
  z-index: 409 !important;
  border: 3px solid #FF8C00 !important;
  border-radius: 50% !important;
  box-shadow: 0 0 10px rgba(255, 140, 0, 0.7) !important;
}

/* Etiquetas de iconos expandidos */
.star-burst-label {
  z-index: 411 !important;
  background: rgba(52, 152, 219, 0.95) !important;
  color: #fff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}

/* Polígono con filtro (cuando método css-filter) */
.coverage-polygon-shadowed {
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.45));
  transition: filter 150ms ease;
}

/* Camino principal para permitir resaltar al pasar ratón */
.leaflet-interactive.coverage-polygon {
  stroke-linejoin: round;
  transition: opacity 120ms ease, fill-opacity 120ms ease;
}
.leaflet-interactive.coverage-polygon:hover {
  fill-opacity: 0.35;
  cursor: pointer;
}

/* 1) Popup efímero: aspecto diferenciado y legible sobre cualquier fondo */
.leaflet-popup.ephemeral-station-popup .leaflet-popup-content-wrapper {
  border: 1px solid rgba(255, 152, 0, 0.6);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  border-radius: 10px;
}
.leaflet-popup.ephemeral-station-popup .leaflet-popup-tip {
  background: #fff;
  border: 1px solid rgba(255, 152, 0, 0.6);
}

/* Estilos anti-parpadeo para popups y sus botones */
.leaflet-container .leaflet-popup,
.leaflet-container .leaflet-popup-content,
.leaflet-container .leaflet-popup-content-wrapper,
.station-popup,
.station-popup .btn,
.station-popup button {
  /* Fuerza capa compuesta para evitar “repintados” y parpadeo en animaciones/auto-pan */
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

/* Opcional: aísla el layout del contenido del popup para reducir reflows */
.leaflet-container .leaflet-popup-content-wrapper {
  contain: layout paint;
}