body {
  margin: 0;
  font-family: Arial, sans-serif;
  overflow: hidden;
}

#container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Left filter panel */
#leftPanel {
  width: 220px;
  background: #fafafa;
  border-right: 2px solid #ccc;
  padding: 15px;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Map */
#map {
  flex: 1;
  height: 100%;
}

/* Right chart panel */
#rightPanel {
  width: 350px;
  background: #ffffff;
  border-left: 2px solid #ccc;
  padding: 10px;
  box-sizing: border-box;
  display: block; /* <-- force visible for testing */
  flex-shrink: 0;
  position: relative;
}

#rightPanel h3 {
  margin-top: 0;
}

#closeCharts {
  position: absolute;
  top: 5px;
  right: 5px;
  border: none;
  background: #eee;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
}

.chart-box {
  width: 100%;
  height: 200px;
  margin: 15px 0;
}

.control-section {
  margin-bottom: 15px;
  font-size: 14px;
}

#yearControl {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 15px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  font-size: 14px;
  z-index: 1000;
  text-align: center;
}

#yearSlider {
  width: 500px;
  margin: 0 auto 8px auto;
}

.info-btn {
  display: inline-block;
  margin-left: 6px;
  background: #0073e6;
  color: white;
  font-size: 12px;
  font-weight: bold;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  text-align: center;
  line-height: 18px;
  cursor: pointer;
}

.info-box {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  padding: 0 8px;           /* keep horizontal padding so width doesn’t jump */
  margin: 0;
  background: #f0f8ff;
  border: 1px solid #cce5ff;
  border-radius: 4px;
  font-size: 13px;
  color: #333;
  transition:
    max-height 220ms ease,
    opacity 220ms ease,
    margin 220ms ease,
    padding-top 220ms ease,
    padding-bottom 220ms ease;
}

/* Open state (JS will also set inline max-height) */
.info-box.open {
  opacity: 1;
  margin: 5px 0 10px 0;
  padding-top: 8px;
  padding-bottom: 8px;
}


.ms { position: relative; }
.ms-toggle {
  width: 100%; padding: 8px 10px;
  border: 1px solid #ccc; border-radius: 4px;
  background: #fff; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.ms-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid #ccc; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-height: 240px; overflow: auto;
  display: none;  /* hidden by default */
}
.ms.open .ms-menu { display: block; }  /* show when parent has open */


.ms-header, .ms-group-header {
  position: sticky; top: 0; background: #f7f7f7; padding: 8px 10px; border-bottom: 1px solid #eee;
  font-weight: 600;
}

.ms-group { padding-bottom: 6px; }
.ms-options { padding: 6px 10px; display: grid; gap: 6px; }
.ms-options label { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.ms-toggle:focus, .ms-menu input:focus { outline: 2px solid #0073e6; outline-offset: 2px; }

/* Compact on small widths */
@media (max-width: 480px) {
  .ms-menu { max-height: 220px; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .info-box { transition: none; }
}

.legend {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  /* z-index: 999; */
}
.legend img { display: block; }
.legend .legend-title { font-weight: 600; margin-right: 6px; }


/* Loading overlay */
.loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 160px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.96);
  border: 1px solid #e3e3e3;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  z-index: 1000;
}
.loading.hidden { display: none; }
.loading .loading-text { font-size: 13px; color: #333; }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid #d0d7de;
  border-top-color: #0073e6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}


.chips { position:absolute; left:12px; bottom:12px; display:flex; gap:6px; flex-wrap:wrap; }
.chip { background:#fff; border:1px solid #e5e7eb; padding:2px 8px; border-radius:999px; font-size:12px; box-shadow:0 1px 2px rgba(0,0,0,.06); background-color: lightsteelblue;}


.left-header {
  display:flex; gap:8px; align-items:center; margin-bottom:8px;
}
.btn {
  font: 500 13px/1.2 system-ui, -apple-system, Segoe UI, Roboto, Arial;
  padding:8px 10px; border-radius:8px; cursor:pointer; border:1px solid #d0d5dd;
  background:#fff;
}
.btn.primary { background:#2563eb; color:#fff; border-color:#2563eb; }
.btn.ghost { background:#fff; color:#111827; }
.btn.primary.is-loading {
  opacity: .7;
  pointer-events: none;
}

.overlay {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .55);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.overlay.hidden { display: none; }
.overlay-panel {
  width:min(780px, 92vw); max-height: 80vh; overflow:auto;
  background:#fff; border-radius:12px; padding:20px 22px; box-shadow: 0 20px 40px rgba(0,0,0,.18);
}
.overlay-close {
  position:absolute; right:14px; top:12px; border:0; background:#f3f4f6; border-radius:8px; cursor:pointer;
  width:32px; height:32px; font-size:16px;
}

/* =========================================
   Education controls (compact vs detailed)
   ========================================= */

/* Container that can sit above/below the education chart */
.edu-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0 10px 0;
  font-size: 13px;
}

/* Left side: label + switch */
.edu-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Right side: Top-K pills (optional) */
.edu-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Switch (Detailed / Compact) --- */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #e5e7eb;
  transition: background 0.2s ease;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px #d1d5db;
}
.switch .slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  transition: transform 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.switch input:checked + .slider {
  background: #2563eb;
  box-shadow: inset 0 0 0 1px #2563eb;
}
.switch input:checked + .slider:before {
  transform: translateX(22px);
}

/* Label text next to switch */
.switch-label {
  user-select: none;
  color: #111827;
}

/* --- Pill group for Top-K selection --- */
.pill-group {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pill {
  font: 500 12px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.pill:hover {
  background: #f9fafb;
  border-color: #cbd5e1;
}
.pill.is-active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* Optional: tiny legend for bucket labels (if you show them under the chart) */
.edu-legend {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  font-size: 12px;
  color: #374151;
}
.edu-legend .row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.edu-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af; /* neutral; chart provides actual colors */
  border: 1px solid #e5e7eb;
}

/* Compact on tight panels */
@media (max-width: 420px) {
  .edu-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .edu-right { width: 100%; flex-wrap: wrap; }
}
