:root {
  --bg: #10141c;
  --panel: #171c26;
  --panel-2: #1e2532;
  --text: #e8ecf3;
  --muted: #8b95a7;
  --accent: #ffd233;
  --border: #2a3242;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar__title { font-size: 16px; font-weight: 600; }
.topbar__title .bolt { color: var(--accent); }
.topbar__source { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 10px; }
.topbar__meta { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.badge {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  color: var(--text);
}

/* ------------------------------------------------------------------ layout */
.layout { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; min-width: 0; background: #0b0e14; }

/* ------------------------------------------------------------------ panel */
.panel {
  width: 420px;
  max-width: 46vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.panel__hint { padding: 18px; }
.panel__hint h2 { margin: 0 0 8px; font-size: 17px; }
.panel__hint p { color: var(--muted); }

.district-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.district-head h2 { margin: 0 0 6px; font-size: 19px; }
.district-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 86px;
}
.stat b { display: block; font-size: 16px; }
.stat span { color: var(--muted); font-size: 11px; }
.stat.off b { color: #ff7b72; }
.stat.maybe b { color: #f2a03d; }
.stat.partial b { color: #f6c445; }
.stat.on b { color: #57d98f; }

.groups-title { padding: 12px 18px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

.group-card { padding: 10px 18px 14px; border-bottom: 1px solid var(--border); }
.group-card__top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.group-card__id { font-weight: 600; font-size: 15px; }
.group-card__name { color: var(--muted); font-size: 12.5px; }
.group-card__houses { margin-left: auto; color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.slots-row { display: flex; gap: 2px; margin-top: 8px; }
.slot {
  flex: 1;
  height: 18px;
  border-radius: 3px;
  min-width: 0;
  cursor: default;
}
.slot.current { outline: 2px solid #fff; outline-offset: 1px; }
.slots-caption { color: var(--muted); font-size: 11px; margin-top: 3px; display: flex; justify-content: space-between; }

/* ------------------------------------------------------------------ legend */
.legend { display: flex; flex-direction: column; gap: 5px; margin: 14px 0; }
.legend__row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); }
.legend__line { width: 26px; height: 5px; border-radius: 3px; display: inline-block; }
.legend__line--mixed {
  background: repeating-linear-gradient(90deg, #e5484d 0 6px, #3fb26f 6px 12px);
}
.mixed-note {
  margin: 10px 18px 0;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.house-numbers {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.house-numbers summary {
  cursor: pointer;
  color: var(--text);
  user-select: none;
}
.house-numbers summary:hover { color: var(--accent); }
.house-numbers[open] summary { margin-bottom: 4px; }
.status-legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.status-legend span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.status-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* leaflet dark tweaks */
.leaflet-container { background: #0b0e14; outline: none !important; }
.leaflet-container:focus { outline: none !important; }

/* Темна карта: інверсія світлих тайлів OSM (лише за класом теми, не вектори) */
#map.invert-filter .leaflet-tile-pane {
  filter: invert(1) hue-rotate(185deg) brightness(0.92) contrast(0.88) saturate(0.65);
}

.theme-picker {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.theme-picker:focus { outline: 1px solid var(--accent); }
.leaflet-tooltip.district-tip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 12.5px;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.leaflet-tooltip.district-tip b { font-size: 13.5px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .panel { width: 100%; max-width: none; max-height: 46vh; border-left: none; border-top: 1px solid var(--border); }
}
