/* Layout: strona bazy danych w stylu Notion: nagłówek z właściwościami, pasek widoków (Tabela / Mapa), panel podglądu wysuwany z prawej. */
:root {
  --bg: #ffffff; --bg-soft: #f7f7f5; --bg-hover: #f1f1ef; --fg: #37352f; --fg-muted: #787774; --fg-faint: #a5a49f;
  --border: #e9e9e7; --accent: #2383e2; --shadow: rgba(15, 15, 15, .1);
  --map-land: #f3f3f0; --map-line: #cfcdc6; --map-sea: #fafaf8;
  --tile-filter: grayscale(.6) contrast(.9) brightness(1.04);
  --b0: #2e9e5b; --b1: #7cb342; --b2: #d9a800; --b3: #e8801f; --b4: #dc3c3c; --b5: #8e2a6b; --bx: #9b9a97;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #191919; --bg-soft: #202020; --bg-hover: #2c2c2c; --fg: #e6e5e3; --fg-muted: #9b9b9b; --fg-faint: #6b6b6b;
  --border: #2f2f2f; --accent: #529cca; --shadow: rgba(0, 0, 0, .5);
  --map-land: #242424; --map-line: #3d3d3d; --map-sea: #191919;
  --tile-filter: grayscale(.7) invert(1) hue-rotate(180deg) brightness(.85) contrast(.85);
  --b0: #4cb782; --b1: #9ccc65; --b2: #f2c94c; --b3: #f2994a; --b4: #eb5757; --b5: #c46bb4; --bx: #7d7d7d;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #191919; --bg-soft: #202020; --bg-hover: #2c2c2c; --fg: #e6e5e3; --fg-muted: #9b9b9b; --fg-faint: #6b6b6b;
  --border: #2f2f2f; --accent: #529cca; --shadow: rgba(0, 0, 0, .5);
  --map-land: #242424; --map-line: #3d3d3d; --map-sea: #191919;
  --tile-filter: grayscale(.7) invert(1) hue-rotate(180deg) brightness(.85) contrast(.85);
  --b0: #4cb782; --b1: #9ccc65; --b2: #f2c94c; --b3: #f2994a; --b4: #eb5757; --b5: #c46bb4; --bx: #7d7d7d;
  color-scheme: dark }

* { box-sizing: border-box }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); }
.page { max-width: 1240px; margin: 0 auto; padding: 48px 24px 64px; }
@media (max-width: 600px) { .page { padding: 28px 16px 48px } }

.crumb { color: var(--fg-muted); font-size: 13px; margin-bottom: 20px }
h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.15; font-weight: 700; margin: 0 0 4px; text-wrap: balance; letter-spacing: -.01em }
.tagline { color: var(--fg-muted); font-size: 15px; margin: 0 0 18px }
.disclaimer { max-width: 80ch; font-size: 13px; line-height: 1.5; color: var(--fg); background: var(--bg-soft); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 14px; margin: 0 0 22px }
.disclaimer a, footer a { color: inherit }

.props { display: grid; grid-template-columns: 160px 1fr; gap: 2px 8px; margin-bottom: 22px; max-width: 720px }
.props dt { color: var(--fg-muted); padding: 4px 6px; display: flex; align-items: center; gap: 6px }
.props dd { margin: 0; padding: 4px 6px; min-width: 0 }
.props svg { width: 14px; height: 14px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6 }
@media (max-width: 520px) { .props { grid-template-columns: 1fr } .props dt { padding-bottom: 0 } .props dd { padding-top: 0 } }

.lede { max-width: 68ch; color: var(--fg); margin: 0 0 22px }
.lede .muted { color: var(--fg-muted) }

/* rozkład pasm */
.dist { margin-bottom: 30px; max-width: 900px }
.dist-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; background: var(--bg-hover); gap: 2px }
.dist-bar span { display: block; height: 100%; min-width: 2px }
.dist-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 13px; color: var(--fg-muted) }
.dist-legend b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px }

/* widoki + narzędzia */
.viewbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; border-bottom: 1px solid var(--border) }
.tabs { display: flex; gap: 4px }
.tab { appearance: none; border: 0; background: none; color: var(--fg-muted); font: inherit; font-weight: 500; padding: 6px 8px 8px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; align-items: center; gap: 6px; border-radius: 4px 4px 0 0 }
.tab:hover { background: var(--bg-hover) }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg) }
.tab svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6 }
.tools { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 6px; align-items: center }
.tools input[type="search"], .tools select { font: inherit; font-size: 13px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; min-width: 0 }
.tools input[type="search"] { width: 220px }
.tools select:hover, .tools input:hover { background: var(--bg-hover) }
.tools label.chk { font-size: 13px; color: var(--fg-muted); display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer }
.tools label.chk:hover { background: var(--bg-hover) }
@media (max-width: 640px) { .tools { width: 100% } .tools input[type="search"] { flex: 1 1 100%; width: auto } .tools select { flex: 1 1 40% } }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }

.count { font-size: 13px; color: var(--fg-muted); padding: 10px 2px 6px; font-variant-numeric: tabular-nums }

/* tabela */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--border) }
table { border-collapse: collapse; width: 100%; min-width: 1060px; font-variant-numeric: tabular-nums }
th, td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 6px 8px; text-align: left; white-space: nowrap; vertical-align: middle }
th:last-child, td:last-child { border-right: 0 }
th { font-weight: 500; color: var(--fg-muted); font-size: 13px; position: sticky; top: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 1 }
th button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 4px; width: 100% }
th button:focus-visible { outline: 2px solid var(--accent) }
th .arr { color: var(--fg); font-size: 11px }
th.num button, td.num { justify-content: flex-end; text-align: right }
tbody tr { cursor: pointer }
tbody tr:hover td { background: var(--bg-hover) }
td.code { font-family: var(--mono); font-size: 12.5px; font-weight: 500 }
td.addr { max-width: 260px; overflow: hidden; text-overflow: ellipsis }
td.addr small { color: var(--fg-muted); display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis }
td .na { color: var(--fg-faint) }
.pill { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 12.5px; line-height: 20px; white-space: nowrap; color: var(--fg) }
.pill.gray { background: var(--bg-hover) }
.pm { display: inline-flex; align-items: center; gap: 6px }
.more { display: block; width: 100%; text-align: left; font: inherit; color: var(--fg-muted); background: none; border: 0; border-bottom: 1px solid var(--border); padding: 8px; cursor: pointer }
.more:hover { background: var(--bg-hover) }
.empty { padding: 32px 8px; color: var(--fg-muted) }

/* mapa */
.map-view { position: relative; margin-top: 4px }
#map { height: min(72vh, 720px); min-height: 420px; border: 1px solid var(--border); border-radius: 6px; background: var(--map-sea) }
.leaflet-container { font: inherit; background: var(--map-sea) }
.leaflet-bar a { background: var(--bg); color: var(--fg); border-color: var(--border) }
.leaflet-bar a:hover { background: var(--bg-hover) }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg); color: var(--fg); box-shadow: 0 4px 16px var(--shadow) }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; line-height: 1.45 }
.leaflet-container a.leaflet-popup-close-button { color: var(--fg-muted) }
.pop-code { font-family: var(--mono); font-weight: 600 }
.pop-row { display: flex; gap: 10px; margin-top: 4px; color: var(--fg-muted); font-variant-numeric: tabular-nums }
.pop-row b { color: var(--fg); font-weight: 600 }
.linkbtn { all: unset; color: var(--accent); cursor: pointer; margin-top: 6px; display: inline-block }
.legend { position: absolute; left: 10px; bottom: 10px; z-index: 500; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 12px; box-shadow: 0 2px 8px var(--shadow); display: grid; gap: 2px }
.legend strong { font-weight: 600; margin-bottom: 2px }
.legend span { color: var(--fg-muted) }

/* panel podglądu */
.scrim { position: fixed; inset: 0; background: transparent; z-index: 900 }
.peek { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--bg); border-left: 1px solid var(--border); box-shadow: -8px 0 24px var(--shadow); z-index: 1000; overflow-y: auto; padding: calc(16px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px)) }
.peek-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px }
.iconbtn { appearance: none; border: 0; background: none; color: var(--fg-muted); cursor: pointer; padding: 4px 6px; border-radius: 4px; font: inherit; display: flex; align-items: center; gap: 6px }
.iconbtn:hover { background: var(--bg-hover) }
.peek h2 { font-size: 26px; margin: 0 0 4px; font-family: var(--mono); letter-spacing: -.01em }
.peek .sub { color: var(--fg-muted); margin-bottom: 16px }
.peek .props { grid-template-columns: 150px 1fr; max-width: none }
@media (max-width: 520px) { .peek .props { grid-template-columns: 1fr } }
.peek .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px }
.btn { font: inherit; font-size: 13px; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; cursor: pointer; text-decoration: none }
.btn:hover { background: var(--bg-hover) }
.note { font-size: 12.5px; color: var(--fg-muted); margin-top: 16px }
.warn { color: var(--b4) }

footer { margin-top: 36px; color: var(--fg-muted); font-size: 12.5px; max-width: 80ch }
@media (prefers-reduced-motion: no-preference) { .peek { animation: slide .16s ease-out } @keyframes slide { from { transform: translateX(24px); opacity: .6 } } }

a { color: var(--accent) }
.leaflet-tile-pane { filter: var(--tile-filter) }
.leaflet-control-attribution { background: color-mix(in srgb, var(--bg) 80%, transparent) !important; color: var(--fg-muted) }
.leaflet-control-attribution a { color: var(--fg-muted) }
.err { color: var(--b4) }
