* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: row;
  background: #1a3a1a;
  overflow: hidden;
}

/* Sidebar - igual que antes pero más limpio */
#sidebar {
  width: 320px;
  flex-shrink: 0;
  background: #1a3a1a;
  color: #f0f2e9;
  padding: 1.5rem;
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0,0,0,0.3);
  z-index: 10;
  height: 100%;
}

/* Mapa - clave: flex:1 y width:100% como en tu ejemplo funcional */
#map {
  flex: 1;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Botón toggle móvil */
.sidebar-toggle {
  display: none;
  position: fixed;
  left: 10px;
  top: 10px;
  z-index: 1001;
  background: #1a3a1a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.sidebar-toggle:hover {
  background: #2a5a2a;
}

/* ============================================ */
/* ESTILOS PARA MÓVIL - Adaptado del ejemplo funcional */
/* ============================================ */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: auto;
    right: 14px;
    bottom: 18px;
    top: auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #7cb342;
    color: #000;
    font-size: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.6);
  }
  
  #sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    max-height: 70vh;
    border-radius: 14px 14px 0 0;
    background: rgba(26, 58, 26, 0.97);
    border-top: 1px solid #2a2a2a;
    padding: 8px 15px 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: none;
  }
  
  /* Tirador visual arriba del cajón */
  #sidebar::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #4a6e3a;
    margin: 0 auto 10px;
    flex-shrink: 0;
  }
  
  #sidebar.open {
    transform: translateY(0);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
  }
  
  #map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    flex: none;
  }
}

/* Móvil pequeño */
@media (max-width: 480px) {
  #sidebar {
    padding: 6px 12px 16px;
    max-height: 65vh;
  }
  
  #sidebar h2 {
    font-size: 1rem;
    padding-bottom: 5px;
  }
  
  #sidebar h3 {
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
  }
  
  .filter-group label {
    font-size: 0.7rem;
  }
  
  select {
    padding: 5px;
    font-size: 0.75rem;
  }
  
  button {
    padding: 5px;
    font-size: 0.75rem;
    margin-top: 5px;
  }
  
  .legend-item {
    font-size: 0.65rem;
    gap: 5px;
  }
  
  #legendWFS h3, #legendImpactos h3 {
    font-size: 0.75rem;
  }
  
  #resultCount {
    font-size: 0.65rem;
    margin-top: 8px;
  }
  
  hr {
    margin: 10px 0;
  }
}

/* ============================================ */
/* RESTO DE ESTILOS (sidebar, botones, leyendas) */
/* ============================================ */
#sidebar h2 {
  text-align: center;
  margin-bottom: 0.25rem;
  font-weight: 500;
  border-bottom: 2px solid #7cb342;
  display: inline-block;
  width: 100%;
  padding-bottom: 8px;
}

#sidebar h3 {
  text-align: center;
  margin-bottom: 1rem;
  font-weight: 400;
  font-size: 0.9rem;
  color: #c8e6c9;
}

#sidebar a {
  color: #66ccff;
  text-decoration: none;
  transition: color 0.2s ease;
}

#sidebar a:hover {
  color: #99ddff;
  text-decoration: underline;
}

#sidebar hr {
  border: none;
  border-top: 1px solid #4a6e3a;
  margin: 15px 0;
}

.filter-group {
  margin-bottom: 1rem;
}

.filter-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 5px;
  font-weight: bold;
  color: #c8e6c9;
}

select {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background: #f5f7f0;
  font-size: 0.9rem;
}

button {
  width: 100%;
  padding: 8px;
  margin-top: 8px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
}

#filtrarBtn {
  background-color: #7cb342;
  color: #1e2a1c;
}

#filtrarBtn:hover {
  background-color: #689f38;
}

#resetBtn {
  background-color: #a1887f;
  color: white;
}

#resetBtn:hover {
  background-color: #8d6e63;
}

#legendWFS, #legendImpactos {
  margin-top: 10px;
}

#legendWFS h3, #legendImpactos h3 {
  font-size: 0.9rem;
  margin-bottom: 10px;
  text-align: left;
  border-bottom: 1px solid #4a6e3a;
  padding-bottom: 5px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.75rem;
  gap: 8px;
}

#resultCount {
  font-size: 0.8rem;
  text-align: center;
  margin-top: 15px;
  padding: 5px;
  background: #2a4a2a;
  border-radius: 5px;
}