:root {
  --bg: #ffffff;
  --bg-soft: #f4f5f7;
  --text: #1c1f24;
  --muted: #646b75;
  --border: #dde1e6;
  --accent: #1c1f24;
  --panel-w: 390px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.subtitle { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.segmented {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
}
.segmented button[aria-checked="true"] {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);
}

.mode { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.mode select {
  font: inherit;
  font-size: 14px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  max-width: 260px;
}

/* ---------- layout ---------- */
.layout {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
}

#map { min-height: 0; }
/* calm, greyscale base map so party colours stand out */
#map .leaflet-tile-pane { filter: grayscale(0.9) contrast(0.95) brightness(1.04); }

.panel {
  overflow-y: auto;
  border-left: 1px solid var(--border);
  padding: 16px;
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr 46vh; }
  .panel { border-left: 0; border-top: 1px solid var(--border); }
  .topbar h1 { font-size: 15px; }
  .subtitle { display: none; }
}

/* ---------- panel content ---------- */
.panel h2 { font-size: 20px; margin: 0; }
.panel .council-name { margin: 2px 0 12px; color: var(--muted); font-size: 13px; }

.back {
  border: 0;
  background: none;
  padding: 0;
  margin-bottom: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.back:hover { color: var(--text); text-decoration: underline; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.stat { background: var(--bg-soft); border-radius: 8px; padding: 8px 10px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }

.parties { list-style: none; margin: 0; padding: 0; }
.party {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 7px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.party:hover { background: var(--bg-soft); }
.party.active { background: var(--bg-soft); outline: 1px solid var(--border); }
.party .name { font-size: 14px; line-height: 1.25; }
.party .num { color: var(--muted); font-size: 12px; margin-right: 4px; font-variant-numeric: tabular-nums; }
.party .pct { font-weight: 650; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.party .bar {
  grid-column: 1 / -1;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
}
.party .bar span { display: block; height: 100%; border-radius: 4px; }
.party .votes { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.note { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.45; }
.note a { color: inherit; }

/* ---------- legend ---------- */
.legend {
  position: absolute;
  left: 10px;
  bottom: 22px;
  z-index: 800;
  background: rgb(255 255 255 / 0.94);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  min-width: 150px;
  max-width: min(260px, calc(100% - 20px));
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.1);
}
.legend .lt { font-weight: 600; margin-bottom: 4px; }
.legend .row { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend .ramp { height: 10px; border-radius: 3px; margin: 4px 0 2px; }
.legend .ends { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }

@media (max-width: 760px) {
  .legend { bottom: calc(46vh + 10px); }
}

/* ---------- map labels & tooltips ---------- */
.okrsek-label {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: #1c1f24;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
}
.okrsek-label::before { display: none; }
.hide-labels .okrsek-label { display: none; }

.leaflet-tooltip.hover-tip { font-size: 13px; }

.note.source {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.callout {
  background: #fff8e1;
  border: 1px solid #f0d98a;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
}
.legend .lnote { margin-top: 6px; color: var(--muted); }
