/* 1) Full‐viewport flex container */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}
#viz-container {
  margin: 0 auto;
  max-width: 960px;
  width: 100%;
  position: relative; 
  box-sizing: border-box;
}

/* 2) Controls bar (top) */
#controls {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;  
  align-items: center;
  padding: 10px;
  background: #f9f9f9;
  border-bottom: 1px solid #ddd;
}
#controls .annotation {
  margin-left: 20px;
  font-size: 14px;
}

/* 3) SVG map (middle) */
#map {
  display: block;
  width: 100%;
  height: 600px;    
  margin: 0 auto;     
}

/* Legend container sits just beneath the map */
#legend-container {
  width: 100%;
  max-width: 960px;
  margin: 8px auto 20px; /* top / auto‐center / bottom */
  text-align: center;
  font-family: sans-serif;
  font-size: 12px;
}


/* legend item: stack bar and labels vertically */
.legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}

.legend-bar {
  width: 520px;
  height: 14px;
  background: lightgray; 
  margin: 0 0 8px 0;
  border-radius: 6px;
  position: relative;
}

.legend-labels {
  width: 520px;
  display: flex;
  justify-content: space-between;
  gap: 0;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  flex-wrap: nowrap;
}

.legend-labels span {
  flex: 1 1 0;
  text-align: center;
  white-space: nowrap;
  min-width: 0;
}

#legend-toggle {
  text-align: left;
  margin-bottom: 8px;
}


#loading {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;           
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.9);
  font-size: 24px;
  font-weight: bold;
  z-index: 1000;
}

#loading::after {
  content: "";
  width: 24px;
  height: 24px;
  margin-left: 12px;
  border: 4px solid #ccc;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}