:root {
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --line: #dddbd3;
  --text: #0b0b0b;
  --text-2: #52514e;
  --accent: #14532d;
  --accent-soft: #e6efe9;
  --g0: #2a78d6;
  --g1: #eb6834;
  --g2: #1baf7a;
  --panel-w: 300px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font: 14px/1.4 system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

#mapa-wrap { position: absolute; inset: 0 0 0 var(--panel-w); }
#map { position: absolute; inset: 0; }

/* --- Panel ------------------------------------------------------------------ */
#panel {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--panel-w);
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

nav.top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; font-size: 12px; }
nav.top a { color: var(--text-2); text-decoration: none; }
nav.top a:hover { text-decoration: underline; }
nav.top a.brand { margin-right: auto; display: inline-flex; }
nav.top a.brand img { display: block; position: relative; top: 2px; }

.tytul { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
#panel-toggle { display: none; }

h1 { margin: 2px 0 2px; font-size: 18px; line-height: 1.25; }
h2 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.sub { margin: 0; color: var(--text-2); font-size: 12px; }

section { margin-top: 16px; }

/* --- Wyszukiwarka adresu ------------------------------------------------------ */
.szukaj { position: relative; margin-top: 12px; }
.szukaj-ikona { position: absolute; left: 10px; top: 10px; color: var(--text-2); pointer-events: none; }
#szukaj {
  width: 100%;
  padding: 9px 10px 9px 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}
#szukaj:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#wyniki {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 300px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
}
#wyniki li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
#wyniki li small { flex: none; color: var(--text-2); font-variant-numeric: tabular-nums; }
#wyniki li.aktywny, #wyniki li:hover { background: var(--accent-soft); }
#wyniki li.brak { cursor: default; color: var(--text-2); background: none; }

/* --- Przyciski i filtry ------------------------------------------------------- */
.seg { display: flex; gap: 4px; }
.seg button, #panel-toggle {
  flex: 1;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
}
.seg button small { display: block; font-size: 11px; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg button:hover:not([aria-pressed="true"]) { border-color: var(--accent); color: var(--text); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--g0); outline-offset: 2px; }

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.grupa { margin-bottom: 8px; }
.grupa-nazwa { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; font-size: 12px; font-weight: 600; cursor: pointer; }

.klasa { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.klasa:hover, .grupa-nazwa:hover { color: var(--accent); }
.klasa .ile { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 12px; }

.chip {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.chip.g0 { background: var(--g0); }
.chip.g1 { background: var(--g1); }
.chip.g2 { background: var(--g2); }

.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; cursor: pointer; }
.check small { color: var(--text-2); }

.summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 10px;
  margin: 16px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

#panel footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11px;
}
#panel footer a { color: var(--accent); }

.help {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text-2);
  font-size: 10px;
  letter-spacing: 0;
  text-decoration: none;
  vertical-align: 1px;
}
.help:hover { border-color: var(--accent); color: var(--accent); }

/* --- Nakładki na mapie -------------------------------------------------------- */
#ladowanie, #pusto, #wskazowka {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.14);
  white-space: nowrap;
}
#ladowanie { top: 50%; display: flex; align-items: center; gap: 10px; transform: translate(-50%, -50%); }
#pusto { top: 50%; display: flex; align-items: center; gap: 12px; transform: translate(-50%, -50%); }
#wskazowka { top: 12px; font-size: 13px; color: var(--text-2); pointer-events: none; }
#ladowanie[hidden], #pusto[hidden], #wskazowka[hidden] { display: none; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: obrot 0.8s linear infinite;
}
@keyframes obrot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.dymek .maplibregl-popup-content {
  padding: 8px 10px;
  border-radius: 8px;
  font: 12px/1.35 system-ui, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.18);
  pointer-events: none;
}
.dymek strong { display: block; font-size: 13px; }
.dymek span { color: var(--text-2); }

/* --- Mapa cen: legenda i okno pola --------------------------------------------------- */
#legenda {
  position: absolute;
  z-index: 3;
  left: 10px;
  bottom: 44px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 230px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.14);
  font-size: 12px;
}
#legenda[hidden] { display: none; }
#legenda strong { font-size: 13px; }
#legenda .leg-temat { color: var(--text-2); }
#legenda ul { margin: 6px 0; padding: 0; list-style: none; font-variant-numeric: tabular-nums; }
#legenda li { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
#legenda li i { flex: none; width: 18px; height: 12px; border-radius: 3px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08); }
#legenda .leg-uwaga { color: var(--text-2); font-size: 11px; line-height: 1.3; }

.okno-pola .maplibregl-popup-content > div { display: flex; flex-direction: column; gap: 2px; }
.okno-pola .maplibregl-popup-content {
  padding: 10px 28px 10px 12px;
  border-radius: 8px;
  font: 12px/1.35 system-ui, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.18);
}
.okno-pola strong { font-size: 14px; }
.okno-pola span { color: var(--text-2); }
.okno-pola button.link { margin-top: 6px; text-align: left; font-size: 12px; }

/* --- Okno szczegółów ---------------------------------------------------------- */
#szczegoly {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  width: min(460px, calc(100vw - var(--panel-w) - 24px));
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}
#szczegoly[hidden] { display: none; }
#szczegoly header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
}
#szczegoly h2 { margin: 0 0 2px; font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--text); }
#sz-zamknij {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--text-2);
  cursor: pointer;
}
#sz-zamknij:hover { background: var(--surface-2); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; text-align: left; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
}
td { border-bottom: 1px solid var(--surface-2); vertical-align: top; }
tbody tr:hover td { background: var(--surface-2); }
.num { text-align: right; }
td.rodzaj { white-space: normal; }
td.rodzaj .chip { margin-right: 6px; }
.tagi { display: block; margin-top: 2px; color: var(--text-2); font-size: 11px; }
.tagi a { color: inherit; text-decoration: underline dotted; text-underline-offset: 2px; }
.tagi a:hover { color: var(--accent); }
.brak { color: var(--text-2); }

.maplibregl-ctrl-attrib { font-size: 11px; }

/* --- Telefon: panel u góry, filtry zwijane ------------------------------------- */
@media (max-width: 720px) {
  body { display: flex; flex-direction: column; }
  #panel {
    position: static;
    flex: none;
    width: 100%;
    padding: 10px 12px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  h1 { font-size: 15px; }
  #panel-toggle { display: block; flex: none; padding: 6px 12px; }
  #panel-toggle[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
  .szukaj { margin-top: 8px; }
  #panel-body { display: none; max-height: 52vh; overflow-y: auto; }
  body.panel-otwarty #panel-body { display: block; }
  #mapa-wrap { position: relative; inset: auto; flex: 1; min-height: 0; }
  #szczegoly { position: fixed; top: auto; right: 8px; bottom: 8px; left: 8px; width: auto; max-height: 55vh; }
  #wskazowka { white-space: normal; width: max-content; max-width: calc(100% - 24px); text-align: center; border-radius: 12px; }
  #pusto { flex-direction: column; gap: 4px; border-radius: 12px; white-space: normal; text-align: center; }
  #legenda { width: 190px; bottom: 40px; padding: 8px 10px; }
}
