:root {
  --bg: #0f1419;
  --panel: #161d26;
  --line: #2a3542;
  --text: #e8eef5;
  --muted: #8b9aab;
  --accent: #4ea1ff;
  --accent-2: #7dd3a7;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);
}

.app {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.sidebar__head h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.sidebar__sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}
.sidebar__sub em { color: var(--accent-2); font-style: normal; }

.toggles { display: grid; gap: 0.5rem; }
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  background: #0c1117;
  border-radius: 10px;
}
.seg:first-child { grid-template-columns: 1fr 1fr; }
.seg__btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.seg__btn.is-active {
  background: #243041;
  color: var(--text);
  box-shadow: inset 0 0 0 1px #35506d;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0c1117;
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font: inherit;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
}

.nav-bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 0.35rem;
}
.nav-btn {
  border: 1px solid var(--line);
  background: #121821;
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.4rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
}
.nav-btn:hover { border-color: #4a6788; background: #182231; }

.stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
}
.stats strong { color: var(--text); font-weight: 600; }

.list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-right: 0.2rem;
}
.list-group {
  margin: 0.35rem 0 0.15rem;
  padding: 0.2rem 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.item {
  text-align: left;
  border: 1px solid var(--line);
  background: #121821;
  color: inherit;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  font: inherit;
}
.item:hover, .item.is-active {
  border-color: #4a6788;
  background: #182231;
}
.item.is-active {
  box-shadow: inset 3px 0 0 var(--accent);
}
.item__top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}
.item__name { font-size: 0.92rem; font-weight: 550; }
.item__metric { color: var(--accent-2); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.item__meta { margin-top: 0.2rem; color: var(--muted); font-size: 0.75rem; }
.item__swatch {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 0.4rem; vertical-align: middle;
}

.detail {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  max-height: 26vh;
  overflow: auto;
}
.detail h2 {
  margin: 0 0 0.4rem;
  color: var(--text);
  font-size: 1rem;
}
.detail p { margin: 0.35rem 0; line-height: 1.45; }

.map-wrap { position: relative; }
#map { height: 100%; width: 100%; background: #0b1016; }
.map-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 500;
  background: rgba(15, 20, 25, 0.85);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  pointer-events: none;
  max-width: min(420px, 70vw);
}

.leaflet-popup-content-wrapper {
  background: #161d26;
  color: var(--text);
  border-radius: 10px;
}
.leaflet-popup-tip { background: #161d26; }
.leaflet-container a { color: var(--accent); }
.leaflet-control-attribution { display: none !important; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 42vh 58vh; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
}
