:root {
  --bg: #b9d3ec;
  --panel-bg: rgba(13, 18, 30, 0.86);
  --panel-border: rgba(120, 140, 180, 0.18);
  --text: #e8edf6;
  --text-dim: #9aa7bd;
  --accent: #f6821f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#globeViz {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* Top bar */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(233, 241, 250, 0.92) 0%, rgba(233, 241, 250, 0) 100%);
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: radial-gradient(circle at 30% 30%, #ffb454, var(--accent));
  box-shadow: 0 0 22px rgba(246, 130, 31, 0.5);
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: 0.2px; color: #12233d; }
.brand p { margin: 2px 0 0; font-size: 12px; color: #3f5573; }

.status {
  pointer-events: auto;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 14px;
  backdrop-filter: blur(8px);
}
.status.ready { color: #7ee0a7; }

/* Control panel */
#panel {
  position: fixed;
  top: 74px;
  left: 20px;
  z-index: 10;
  width: 288px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 6px 18px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.panel-group { padding: 12px 0; border-bottom: 1px solid var(--panel-border); }
.panel-group:last-of-type { border-bottom: none; }
.panel-group h2 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
}

.toggles { display: flex; flex-direction: column; gap: 4px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease;
}
.toggle:hover { background: rgba(255, 255, 255, 0.05); }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.toggle .label { flex: 1; }
.toggle .count { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.swatch {
  width: 12px; height: 12px; border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  flex: 0 0 auto;
}

/* Hierarchical agency groups with regional sub-toggles */
.agency-group { border-radius: 9px; }
.agency-head { gap: 8px; }
.expander {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  padding: 0; margin: 0;
  border: none; background: none;
  color: var(--text-dim);
  font-size: 10px; line-height: 16px;
  cursor: pointer;
}
.expander:hover { color: var(--text); }
.agency-head .agency-master { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.agency-head .label { font-weight: 500; }

.region-list {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px 8px;
  padding-left: 8px;
  border-left: 1px solid var(--panel-border);
}
.agency-group.open .region-list { display: flex; }

.toggle.region { padding: 5px 8px; font-size: 12px; }
.toggle.region .label { color: var(--text-dim); }
.toggle.region input { width: 13px; height: 13px; }

.hint { margin: 8px 2px 0; font-size: 11px; line-height: 1.4; color: var(--text-dim); }

.panel-foot {
  padding-top: 12px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: rgba(10, 14, 22, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  max-width: 240px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, calc(-100% - 14px));
}
.tooltip .t-title { font-weight: 600; margin-bottom: 3px; }
.tooltip .t-sub { color: var(--text-dim); }

@media (max-width: 640px) {
  #panel { width: calc(100vw - 40px); max-height: 44vh; }
  .brand p { display: none; }
}
