:root {
  --bg: #0f172a;      /* Fundo escuro */
  --panel: #1e293b;   /* Painel */
  --muted: #94a3b8;   /* Texto secundário */
  --text: #e5e7eb;    /* Texto principal */
  --border: #334155;  /* Bordas */
  --accent: #3b82f6;  /* Azul destaque */
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden; /* Evita scroll duplo com o mapa */
}

/* --- TOPO (TOOLBAR) --- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: #111827;
  border-bottom: 1px solid var(--border);
  height: auto;
  min-height: 60px;
  z-index: 1000;
  position: relative;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  margin-right: auto; /* Empurra o resto para a direita */
}
.brand strong { font-size: 16px; color: #fff; }
.brand .muted { font-size: 11px; color: var(--muted); }

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Estilo dos inputs e selects */
label {
  display: flex;
  flex-direction: column;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

select, button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

select:focus, button:focus {
  border-color: var(--accent);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 600;
  margin-top: auto; /* Alinha com os selects */
  height: 32px; /* Altura fixa para alinhar */
}

button:hover { opacity: 0.9; }

.meta-info {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* --- MAPA --- */
#map {
  width: 100%;
  height: calc(100vh - 64px); /* Altura total menos toolbar */
  background: #ddd;
}

/* --- LEGENDA --- */
.legend {
  position: absolute;
  bottom: 24px;
  right: 12px;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  color: #333;
  font-size: 12px;
  z-index: 999; /* Acima do mapa */
  max-width: 150px;
}
.legend h4 { margin: 0 0 8px 0; font-size: 13px; text-transform: uppercase; color: #555; }
.legend .row { display: flex; align-items: center; margin-bottom: 4px; }
.legend .swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  margin-right: 8px;
  display: inline-block;
}

/* --- RESPONSIVIDADE (CELULAR / TABLET) --- */
@media (max-width: 768px) {
  /* Toolbar vira coluna */
  .toolbar {
    flex-direction: column;
    align-items: stretch; /* Estica elementos */
    height: auto;
    gap: 12px;
    padding-bottom: 15px;
  }

  .brand {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    margin-right: 0;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    width: 100%;
  }

  .controls {
    flex-direction: column; /* Selects um embaixo do outro */
    width: 100%;
  }

  label, select, button {
    width: 100%; /* Ocupa largura total */
  }

  label { font-size: 12px; margin-bottom: 2px; }
  select, button {
    padding: 10px; /* Maior para o dedo */
    font-size: 16px; /* Evita zoom no iPhone */
    height: 44px;
  }
  
  .meta-info {
    text-align: center;
    padding-top: 5px;
    border-top: 1px solid var(--border);
  }

  /* Ajusta altura do mapa considerando a toolbar maior */
  #map {
    height: calc(100vh - 280px); /* Ajuste aproximado para menu aberto */
  }

  .legend {
    bottom: 10px;
    right: 10px;
    padding: 6px;
    font-size: 10px;
  }
}