/* ============ tokens (align with waktukita) ============ */
:root {
  --bg: #f5f2ec;
  --bg-2: #efeadf;
  --surface: #ffffff;
  --surface-2: #f6f2e9;
  --border: #e6dfce;
  --border-strong: #14213d;
  --text: #14213d;
  --text-soft: #3b4a6b;
  --muted: #6b6a5e;
  --accent: #ff3b6b;
  --accent-ink: #ffffff;
  --accent-soft: #ffe1e9;
  --highlight: #ffe66b;
  --highlight-soft: #fff5b8;
  --good: #4b7a3a;
  --warn: #b08508;
  --crit: #a63b2a;
  --info: #2563a8;
  --ring: rgba(20, 33, 61, .12);
  --shadow-sm: 0 1px 0 rgba(20, 33, 61, .05);
  --shadow: 0 1px 2px rgba(20, 33, 61, .04), 0 10px 30px rgba(20, 33, 61, .06);
  --shadow-nav: 0 1px 0 rgba(20, 33, 61, .04), 0 12px 40px rgba(20, 33, 61, .08);
  --pop: 6px 6px 0 var(--border-strong);
  --pop-sm: 3px 3px 0 var(--border-strong);
  --pop-xs: 2px 2px 0 var(--border-strong);
}

:root[data-theme="dark"] {
  --bg: #0d1220;
  --bg-2: #121a2e;
  --surface: #16203a;
  --surface-2: #1c2947;
  --border: #263356;
  --border-strong: #0b1220;
  --text: #eef2fb;
  --text-soft: #c2ccdf;
  --muted: #8a97b3;
  --accent: #ff5c85;
  --accent-ink: #0d1220;
  --accent-soft: #3a1b2a;
  --highlight: #ffd447;
  --highlight-soft: #4a3a10;
  --good: #6fd39a;
  --warn: #f2c268;
  --crit: #ef7a7a;
  --info: #93c5fd;
  --ring: rgba(238, 242, 251, .12);
  --shadow-sm: 0 1px 0 rgba(0, 0, 0, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-nav: 0 1px 0 rgba(0, 0, 0, .3), 0 14px 40px rgba(0, 0, 0, .5);
  --pop: 6px 6px 0 #05080f;
  --pop-sm: 3px 3px 0 #05080f;
  --pop-xs: 2px 2px 0 #05080f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0d1220; --bg-2: #121a2e; --surface: #16203a; --surface-2: #1c2947;
    --border: #263356; --border-strong: #0b1220; --text: #eef2fb; --text-soft: #c2ccdf;
    --muted: #8a97b3; --accent: #ff5c85; --accent-ink: #0d1220; --accent-soft: #3a1b2a;
    --highlight: #ffd447; --highlight-soft: #4a3a10;
    --good: #6fd39a; --warn: #f2c268; --crit: #ef7a7a; --info: #93c5fd;
    --ring: rgba(238, 242, 251, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .45);
    --shadow-nav: 0 1px 0 rgba(0, 0, 0, .3), 0 14px 40px rgba(0, 0, 0, .5);
    --pop: 6px 6px 0 #05080f;
    --pop-sm: 3px 3px 0 #05080f;
    --pop-xs: 2px 2px 0 #05080f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition: background-color .4s ease, color .4s ease;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

#map { width: 100%; height: 100%; }
.leaflet-container {
  background: var(--surface-2) !important;
  font-family: "Plus Jakarta Sans", sans-serif !important;
}
.leaflet-control-attribution {
  background: rgba(255, 255, 255, .8) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
:root[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(13, 18, 32, .8) !important;
}
:root[data-theme="dark"] .leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
:root[data-theme="dark"] .leaflet-tile { filter: brightness(.85); }

/* ============ brand nav ============ */
.brand-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.brand-nav .brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
}
.brand-nav .brand-logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #a77bff, #ff3b6b);
  color: #fff; font-size: 15px;
}
.brand-nav .brand-name { font-weight: 800; letter-spacing: -0.02em; font-size: 16px; }
.brand-nav .brand-slash { color: var(--muted); margin: 0 2px; font-weight: 500; }
.brand-nav .brand-app { color: var(--accent); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-chip {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.brand-chip::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #37c47a; box-shadow: 0 0 0 3px rgba(55, 196, 122, .2);
}
.brand-nav-actions { display: flex; align-items: center; gap: 10px; }
.brand-nav .back-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text); text-decoration: none;
  font-size: 12px; font-weight: 700;
  box-shadow: var(--pop-xs);
  transition: transform .1s, box-shadow .1s;
}
.brand-nav .back-link:hover { transform: translate(-1px, -1px); box-shadow: var(--pop-sm); }

/* theme toggle (same as waktukita) */
.theme-toggle {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.theme-toggle button {
  appearance: none; border: 0;
  width: 30px; height: 30px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background-color .2s, color .2s;
}
.theme-toggle button svg { width: 15px; height: 15px; }
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px var(--ring);
}
.theme-toggle button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ toolbar (title + status + download) ============ */
.tool-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tool-title { display: flex; align-items: center; gap: 12px; }
.flag-mark {
  width: 24px; height: 24px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border-strong);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.flag-mark > div { flex: 1; }
.flag-mark .flag-top { background: var(--accent); }
.flag-mark .flag-bot { background: var(--surface); }
.tool-title h1 {
  margin: 0;
  font-size: 15px; font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}
.tool-title .sub {
  font-size: 11px; color: var(--muted);
  font-weight: 600; letter-spacing: .04em;
}
.tool-actions { display: flex; align-items: center; gap: 10px; }
.status-chip {
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  padding: 5px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ============ layout ============ */
.main-wrap { display: flex; flex: 1; overflow: hidden; }

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sb-sec {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}
.sb-sec:last-child { border-bottom: none; }
.sec-title {
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ============ form controls ============ */
input[type=color] {
  -webkit-appearance: none;
  width: 32px; height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: var(--surface);
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 6px; }

input[type=range] {
  -webkit-appearance: none;
  width: 100%; height: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 3px var(--ring);
  cursor: pointer;
}

input.txt-in, select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input.txt-in:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select option { background: var(--surface); color: var(--text); }

/* ============ buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  transition: transform .1s, box-shadow .1s;
  font-family: inherit;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--pop-sm);
}
.btn-primary:hover { transform: translate(-1px, -1px); box-shadow: var(--pop); }
.btn-primary:active { transform: translate(1px, 1px); box-shadow: var(--pop-xs); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--pop-xs);
}
.btn-secondary:hover { transform: translate(-1px, -1px); box-shadow: var(--pop-sm); }
.btn-secondary:active { transform: translate(1px, 1px); box-shadow: none; }

/* mode/interval tabs */
.mode-tab, .interval-tab {
  flex: 1;
  padding: 7px 8px;
  text-align: center;
  font-size: 11px; font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .2s, color .2s;
  color: var(--muted);
}
.mode-tab.active, .interval-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px var(--ring);
}
.tab-group {
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ============ color presets ============ */
.gradient-bar {
  height: 12px; border-radius: 999px;
  border: 1px solid var(--border);
  width: 100%; margin: 6px 0;
}
.color-preset {
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .15s;
  flex-shrink: 0;
  box-shadow: 0 1px 2px var(--ring);
}
.color-preset:hover, .color-preset.active {
  border-color: var(--border-strong);
  transform: scale(1.08);
}

/* ============ legend ============ */
.legend-item {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--text-soft);
}
.legend-swatch {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.legend-nodata-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
}
.legend-toggle-btn {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; padding: 0;
}
.legend-toggle-btn:hover .sec-title { color: var(--accent); }
.legend-vis-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 3px 9px;
  font-size: 10px;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--pop-xs);
  font-family: inherit;
  font-weight: 700;
  line-height: 1.4;
  transition: transform .1s, box-shadow .1s;
}
.legend-vis-btn:hover { transform: translate(-1px, -1px); box-shadow: var(--pop-sm); }

/* ============ stats ============ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}
.stat-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
}
.stat-val {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

/* ============ upload area ============ */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: all .2s;
}
.upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-area .up-lbl { font-size: 12px; color: var(--text); font-weight: 700; }
.upload-area .up-sub { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ============ toast ============ */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 15px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  z-index: 9999;
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--pop-sm);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--good); }
.toast.error { border-color: var(--crit); }

/* ============ loading overlay ============ */
.loading-overlay {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(2px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-txt { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ============ modal ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: var(--pop);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.modal-header .title { font-size: 14px; font-weight: 800; color: var(--text); }
.modal-header .subtitle { font-size: 11px; color: var(--muted); margin-top: 3px; }
.modal-body { overflow-y: auto; flex: 1; padding: 16px 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ============ map tooltip ============ */
.info-tooltip {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: inherit;
  color: var(--text);
  font-size: 12px;
  box-shadow: var(--pop-sm);
  min-width: 180px;
}
.info-tooltip .prov-name {
  font-weight: 800; font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.tt-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 4px;
}
.tt-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.tt-val {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px; color: var(--text); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tt-pct {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tt-pos { color: var(--good); }
.tt-neg { color: var(--crit); }
.tt-zero { color: var(--muted); }
.tt-divider { height: 1px; background: var(--border); margin: 6px 0; }

/* leaflet tooltip wrapper reset */
.leaflet-tooltip {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.leaflet-tooltip::before { display: none !important; }

/* ============ dropdown menu ============ */
.dropdown-menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  z-index: 999;
  overflow: hidden;
  box-shadow: var(--pop-sm);
  min-width: 180px;
}
.dropdown-menu.hidden { display: none; }
.dl-opt {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  transition: background-color .12s;
}
.dl-opt:hover { background: var(--surface-2); }
.dl-opt .dl-sub { font-size: 10px; color: var(--muted); font-weight: 500; margin-top: 1px; }
.dropdown-divider { height: 1px; background: var(--border); margin: 0 12px; }

/* ============ data table ============ */
.table-panel {
  border-top: 1px solid var(--border);
  overflow: auto;
  background: var(--bg-2);
}
.table-panel-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.table-panel-title {
  font-size: 11px; font-weight: 800;
  color: var(--accent);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.dt { width: 100%; border-collapse: collapse; font-size: 12px; }
.dt th {
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0;
  z-index: 2;
  font-weight: 700;
}
.dt th:first-child, .dt th:nth-child(2), .dt th:nth-child(3) { text-align: left; }
.dt td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
  color: var(--text);
}
.dt td:first-child, .dt td:nth-child(2), .dt td:nth-child(3) { text-align: left; }
.dt tr:hover td { background: var(--surface-2); }
.dt .row-region td {
  background: var(--highlight-soft);
  color: var(--text);
  font-weight: 700; font-size: 11px;
  letter-spacing: .04em;
}
.dt .row-region:hover td { background: var(--highlight); }
.dt .row-national td {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
}
.dt .row-national:hover td { background: var(--accent-soft); }
.dt .pct-pos, .dt .surplus { color: var(--good); font-weight: 700; }
.dt .pct-neg, .dt .deficit { color: var(--crit); font-weight: 700; }
.dt .pct-zero { color: var(--muted); }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted-cell { color: var(--muted); }
.dim-num { color: var(--muted); font-size: 10px; }

/* ============ manual edit table ============ */
.mi-table { width: 100%; border-collapse: collapse; }
.mi-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 700;
}
.mi-table td {
  padding: 5px 7px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
}
.mi-table td input {
  background: transparent;
  border: 1px solid transparent;
  outline: none;
  width: 100%;
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
}
.mi-table td input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.mi-table tr:hover td { background: var(--surface-2); }

/* ============ per-class colors ============ */
.cls-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.cls-row:last-child { border-bottom: none; }
.cls-swatch {
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  padding: 2px;
  background: var(--surface);
  flex-shrink: 0;
}
.cls-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.cls-swatch::-webkit-color-swatch { border: none; border-radius: 4px; }
.cls-label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  color: var(--text-soft);
  flex: 1; min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ custom breaks ============ */
.breaks-row {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 5px; padding: 4px 0;
}
.br-fixed {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.br-arrow { color: var(--border-strong); font-size: 13px; flex-shrink: 0; line-height: 1; opacity: .5; }
.br-input {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  padding: 5px 7px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  outline: none;
  width: 78px;
  text-align: center;
  -moz-appearance: textfield;
}
.br-input::-webkit-outer-spin-button,
.br-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.br-input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.br-input.invalid {
  border-color: var(--crit) !important;
  color: var(--crit) !important;
  background: color-mix(in srgb, var(--crit) 12%, var(--surface)) !important;
}

/* ============ map legend overlay ============ */
.map-legend-overlay {
  position: absolute;
  bottom: 28px; left: 14px;
  z-index: 400;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 180px;
  max-width: 230px;
  pointer-events: none;
  backdrop-filter: blur(4px);
  box-shadow: var(--pop-xs);
}
.map-legend-overlay.hidden { display: none; }
.map-legend-overlay .leg-title {
  font-size: 11px; font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.map-legend-overlay .leg-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--text-soft);
  font-family: inherit;
}
.map-legend-overlay .leg-swatch {
  width: 15px; height: 15px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.leg-nodata-row {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
}

/* ============ helper utility classes (replace tailwind) ============ */
.flex { display: flex; }
.flex-1 { flex: 1; min-width: 0; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: 1fr 1fr; }
.hidden { display: none !important; }
.relative { position: relative; }
.gap-1 { gap: 4px; }
.gap-15 { gap: 6px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.w-full { width: 100%; }

/* ============ reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
