:root {
  --ink: #1e2430;
  --muted: #5d6675;
  --line: #e1e5ea;
  --bg: #f6f7f9;
  --card: #fff;
  --accent: #334155;
  --panel-w: 380px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}
a { color: #1d4ed8; }

.app { display: flex; height: 100vh; height: 100dvh; }
.panel {
  width: var(--panel-w);
  flex: 0 0 var(--panel-w);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--line);
  min-height: 0;
  z-index: 2;
}
.panel-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--line); position: relative; }
.panel-head h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.panel-toggle { display: none; }
.panel-body { overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; min-height: 0; }

.filters { padding: 12px 18px 4px; }
#q { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.group { border: 0; margin: 10px 0 0; padding: 0; }
.group legend, .field { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.group legend { margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 4px 11px; font: inherit; font-size: 0.85rem; cursor: pointer; color: var(--ink);
}
.chip:hover { border-color: #9aa3af; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.club-chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.club-chip.active { background: var(--c); border-color: var(--c); }
.club-chip.active .dot { background: #fff; }
.chip .n { color: var(--muted); font-size: 0.75rem; }
.chip.active .n { color: inherit; opacity: 0.85; }

.shape { display: inline-block; width: 10px; height: 10px; background: currentColor; flex: none; }
.s-circle { border-radius: 50%; }
.s-square { border-radius: 2px; }
.s-diamond { transform: rotate(45deg) scale(0.85); }
.shape.approx { background: transparent; border: 1.5px dashed currentColor; }

.row { display: flex; gap: 10px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; flex: 1 1 0; min-width: 0; }
.field select, .field input { font: inherit; font-size: 0.9rem; text-transform: none; letter-spacing: 0; color: var(--ink);
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; width: 100%; min-width: 0; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.link { background: none; border: 0; padding: 0; margin: 10px 0 4px; color: #1d4ed8; text-decoration: underline; cursor: pointer; font: inherit; font-size: 0.85rem; }

.count { margin: 8px 18px; color: var(--muted); font-size: 0.85rem; }
.list { list-style: none; margin: 0; padding: 0 12px 16px; display: grid; gap: 8px; }
.item {
  border: 1px solid var(--line); border-left: 5px solid var(--c, #999); border-radius: 9px;
  padding: 9px 11px; cursor: pointer; background: #fff;
}
.item:hover, .item.focus { border-color: #9aa3af; border-left-color: var(--c, #999); background: #fafbfc; }
.item-top { display: flex; gap: 8px; align-items: baseline; font-size: 0.8rem; color: var(--muted); }
.item-top b { color: var(--ink); font-weight: 600; }
.item-title { margin: 3px 0 0; font-size: 0.92rem; }
.item-who { margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); }
.tag { margin-left: auto; font-size: 0.7rem; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.tag.ok { background: #e7f5ea; color: #166534; }
.tag.wait { background: #fdf0dc; color: #8a4b00; }
.tag.nomap { background: #eef0f3; color: var(--muted); }

.panel-foot { padding: 10px 18px 14px; border-top: 1px solid var(--line); font-size: 0.72rem; color: var(--muted); }

.map-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; background: #e9eef2; }
.tiles-muted { filter: saturate(0.25) brightness(1.06) contrast(0.92); }

.legend {
  position: absolute; left: 12px; bottom: 22px; z-index: 500;
  background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.75rem; max-width: 520px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend .shape { color: #6b7280; }
.legend .sep { width: 1px; height: 12px; background: var(--line); }

/* znaczniki */
.mk { background: none; border: 0; }
.mk svg { display: block; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35)); }
.cl { background: none; border: 0; }
.cl div {
  width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.cl span {
  background: #fff; border-radius: 50%; width: 64%; height: 64%; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 12px; color: var(--ink);
}

/* okienko */
.leaflet-popup-content { margin: 12px 14px; font-size: 13.5px; line-height: 1.45; }
.pop { max-width: 320px; }
.pop + .pop { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.pop-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.pop-head strong { color: var(--ink); }
.club-tag { background: var(--c); color: #fff; border-radius: 5px; padding: 1px 6px; font-weight: 700; font-size: 11.5px; }
.pop-who { margin: 4px 0 0; font-weight: 600; }
.pop-topic { margin: 4px 0 6px; color: var(--muted); }
.pop p { margin: 5px 0; }
.pop-place { font-size: 12px; color: var(--muted); margin-top: 6px; }
.pop-link { display: inline-block; margin-top: 6px; font-weight: 600; }
.pop-note { font-size: 11px; color: #8b93a1; margin-top: 4px; }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .panel { width: 100%; flex: 0 0 auto; max-height: 58vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .panel.collapsed { max-height: none; }
  .panel.collapsed .panel-body { display: none; }
  .panel-toggle {
    display: block; position: absolute; right: 14px; top: 14px; font: inherit; font-size: 0.8rem;
    border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; cursor: pointer;
  }
  .map-wrap { flex: 1 1 auto; min-height: 42vh; }
  .legend { left: 6px; right: 6px; bottom: 16px; padding: 4px 8px; gap: 2px 9px; font-size: 0.68rem; }
  .pop { max-width: 250px; }
}

/* pisma bez miejsca - zbiorczy znacznik przy urzędzie */
.urzad { background: none; border: 0; }
.urzad-pin {
  position: relative; width: 40px; height: 40px; margin: 2px; border-radius: 10px;
  background: #1e2430; color: #fff; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 0 0 2px #1e2430, 0 2px 6px rgba(0,0,0,.35);
}
.urzad-n {
  position: absolute; top: -10px; right: -12px; min-width: 22px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #fff; color: #1e2430; border: 2px solid #1e2430; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}
.legend .urzad-key { width: 11px; height: 11px; border-radius: 3px; background: #1e2430; display: inline-block; }
.pop-nomap { font-size: 11.5px; color: #fff; background: #1e2430; border-radius: 5px; padding: 2px 7px; margin-bottom: 6px; display: inline-block; }
.pop-list { margin: 4px 0 6px; padding-left: 18px; font-size: 12.5px; }
.pop-list li { margin: 2px 0; }
.only-bez { margin: -4px 18px 8px; font-size: 0.8rem; color: var(--ink); background: #eef0f3; border-radius: 7px; padding: 5px 9px; }
.only-bez .link { margin: 0 0 0 4px; }

/* statystyki w panelu */
.stats { margin: 10px 18px 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.stats summary {
  padding: 9px 12px; cursor: pointer; font-weight: 600; font-size: 0.9rem; list-style-position: inside;
}
.stats summary::marker { color: var(--muted); }
.stats-sum { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.stats-body { position: relative; padding: 0 12px 6px; border-top: 1px solid var(--line); }
.stats-note { margin: 8px 0 2px; font-size: 0.75rem; color: var(--muted); }
.stats .chart { margin: 0; padding: 10px 0; border-bottom: 1px solid #eef0f3; }
.stats .chart:last-of-type { border-bottom: 0; }
.stats .chart[hidden] { display: none; }
.stats figcaption {
  margin-bottom: 6px; font-size: 0.68rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.stats figcaption .sub { text-transform: none; letter-spacing: 0; font-weight: 500; }
.bars { display: flex; flex-direction: column; gap: 1px; }
.bars .none { margin: 0; font-size: 0.8rem; color: var(--muted); }
.bar-row {
  display: grid; grid-template-columns: minmax(80px, 40%) minmax(0, 1fr) 2.6em; align-items: center; gap: 8px;
  width: calc(100% + 8px); margin: 0 -4px; padding: 4px; border: 0; border-radius: 6px; background: none;
  font: inherit; font-size: 0.8rem; color: #3b4452; text-align: left; cursor: pointer;
}
.bar-row:hover { background: #f1f3f6; color: var(--ink); }
.bar-row[aria-pressed="true"] { background: #e6ebf1; color: var(--ink); font-weight: 600; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 10px; }
.bar-row .fill { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--bar, var(--accent)); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.cols { display: flex; align-items: flex-end; gap: 2px; height: 80px; border-bottom: 1px solid var(--line); }
.col {
  flex: 1 1 0; display: flex; align-items: flex-end; justify-content: center; height: 100%; min-width: 0;
  padding: 0; border: 0; background: none; cursor: pointer;
}
.col span { display: block; width: 100%; max-width: 24px; min-height: 1px; border-radius: 4px 4px 0 0; background: var(--accent); }
.col:hover span, .col:focus-visible span { background: #12964b; }
.col[aria-pressed="true"] span { background: #12964b; }
.col.is-zero span { background: var(--line); }
.cols-axis { display: flex; justify-content: space-between; margin-top: 4px; font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tip {
  position: absolute; z-index: 40; padding: 5px 9px; border-radius: 7px; background: var(--ink); color: #fff;
  font-size: 0.75rem; line-height: 1.35; pointer-events: none; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.tip[hidden] { display: none; }

.chips-small .chip { font-size: 0.78rem; padding: 3px 8px; }
.msi-label { background: none; border: 0; box-shadow: none; color: #475569; font-weight: 600; font-size: 0.72rem;
  letter-spacing: 0.08em; text-transform: uppercase; text-shadow: 0 0 3px #fff, 0 0 3px #fff; white-space: nowrap; }
.msi-label::before { display: none; }
.pop-tags { margin: 4px 0; display: flex; flex-wrap: wrap; gap: 4px; }
.pop-tags span { font-size: 0.72rem; background: #eef2f7; color: #334155; border-radius: 10px; padding: 1px 7px; }
