:root {
  --blue: #0b6bcb;
  --blue-dark: #084e94;
  --ice: #eaf4fd;
  --ink: #1c2733;
  --muted: #5b6b7b;
  --line: #dde6ee;
  --verified: #14883f;
  --unknown: #b98a00;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; color: var(--ink); }
body { display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 8px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(10, 40, 70, .07);
  flex: 0 0 auto;
  position: relative; z-index: 1200;
}
.brand { display: flex; align-items: center; text-decoration: none; flex: 0 0 auto; }
.brand-logo { display: block; height: 72px; width: auto; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.topnav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 9px 14px; border-radius: 999px;
}
.nav-link:hover { background: var(--ice); color: var(--blue-dark); }
.nav-active { background: var(--ice); color: var(--blue-dark); }
.topnav .btn { margin-left: 8px; }
.btn {
  border: 0; border-radius: var(--radius); padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(11, 107, 203, .3); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-small { padding: 6px 10px; font-size: 12px; background: var(--ice); color: var(--blue-dark); margin-top: 8px; }
.modal .btn-primary { background: var(--blue); color: #fff; width: 100%; }
.modal .btn-primary:hover { background: var(--blue-dark); }

.map-wrap { position: relative; flex: 1; }
#map { position: absolute; inset: 0; }

/* ── Pasek sterowania: środek, góra ── */
.controlbar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 1100;
  display: flex; flex-direction: column; gap: 10px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 6px 24px rgba(10, 40, 70, .25);
  padding: 14px 18px;
  max-width: min(94vw, 780px);
}
.controlbar-row { display: flex; align-items: center; gap: 12px; }
#city-select {
  font-size: 16px; font-weight: 600; color: var(--ink);
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; min-width: 240px; max-width: 300px; cursor: pointer;
}
#city-select:focus { outline: 2px solid var(--blue); }

.ctrl-btn {
  font-size: 16px; font-weight: 600; color: var(--ink);
  padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; cursor: pointer; white-space: nowrap;
}
.ctrl-btn:hover { background: var(--ice); }
.filter-count {
  background: var(--blue); color: #fff; border-radius: 999px;
  font-size: 12px; padding: 1px 8px; margin-left: 2px;
}
.result-count { font-size: 14px; color: var(--muted); white-space: nowrap; padding-right: 4px; }

.quick-cities { flex-wrap: wrap; gap: 8px; }
.quick-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.city-chip {
  border: 1px solid var(--line); background: var(--ice); color: var(--blue-dark);
  font-size: 14px; font-weight: 600; padding: 7px 14px; border-radius: 999px;
  cursor: pointer;
}
.city-chip:hover, .city-chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Okno startowe ── */
.welcome-modal { width: min(560px, 94vw); text-align: center; }
.welcome-modal h2 { font-size: 24px; }
.welcome-tiles {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0 6px;
}
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 12px; border: 2px solid var(--line); border-radius: 14px;
  background: #fff; cursor: pointer; font-family: inherit;
}
.tile:hover { border-color: var(--blue); background: var(--ice); }
.tile-icon { font-size: 34px; }
.tile-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.tile-count { font-size: 12.5px; color: var(--muted); }
.welcome-all {
  margin-top: 12px; border: 0; background: none; color: var(--blue);
  font-size: 14px; font-weight: 600; cursor: pointer; padding: 8px;
}
.welcome-all:hover { text-decoration: underline; }

.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  width: 320px; background: #fff; border-radius: 12px;
  box-shadow: 0 8px 30px rgba(10, 40, 70, .3);
  padding: 14px;
}
.dropdown-panel[hidden] { display: none; }
.dropdown-panel h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dropdown-panel hr { border: 0; border-top: 1px dashed var(--line); margin: 10px 0; }

.filter { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 5px 0; cursor: pointer; }
.filter input { accent-color: var(--blue); width: 16px; height: 16px; flex: 0 0 auto; }

.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; padding: 2px 6px; border-radius: 6px;
  font-size: 11px; font-weight: 700; background: var(--ice); color: var(--blue-dark);
}
.chip-r1234yf { background: #e8f7ee; color: #14883f; }
.chip-trucks { background: #fdeeea; color: #b3401f; }

.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.badge-verified { background: #e8f7ee; color: var(--verified); }
.badge-unverified { background: #fdf6e3; color: var(--unknown); }

/* ── Panel najbliższych serwisów ── */
.nearby {
  position: absolute; left: 14px; top: 80px; bottom: 40px; z-index: 1050;
  width: 320px; max-width: 88vw;
  background: #fff; border-radius: 14px;
  box-shadow: 0 4px 18px rgba(10, 40, 70, .22);
  display: flex; flex-direction: column; overflow: hidden;
}
.nearby[hidden] { display: none; }
.nearby-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.nearby-head h2 { margin: 0; font-size: 15px; }
.nearby-close { border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.nearby-tabs { display: flex; gap: 6px; padding: 8px 10px 0; }
.tab-btn {
  flex: 1; border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 13px; font-weight: 700; padding: 8px; border-radius: 999px; cursor: pointer;
}
.tab-btn:hover { background: var(--ice); }
.tab-active { background: var(--blue); color: #fff; border-color: var(--blue); }
.tab-active:hover { background: var(--blue-dark); }

.nearby ul { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.nearby li { padding: 10px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; }
.nearby li:hover { background: var(--ice); border-color: var(--line); }
.rank-item { display: grid; grid-template-columns: 34px 1fr; grid-auto-flow: dense; align-items: start; }
.rank-item .rank-medal { grid-row: span 3; font-size: 20px; font-weight: 800; color: var(--muted); padding-top: 2px; }
.rank-item .r-name, .rank-item .r-meta, .rank-item .r-chips { grid-column: 2; }
.r-empty, .r-note { cursor: default !important; color: var(--muted); font-size: 12px; }
.r-note { border-top: 1px dashed var(--line); border-radius: 0; margin-top: 4px; }
.r-empty:hover, .r-note:hover { background: none !important; border-color: transparent; }
.r-note:hover { border-top-color: var(--line); }

.rank-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; margin: 1px 0;
}
.b-green { background: #e8f7ee; color: var(--verified); }
.b-gold { background: #fff6dd; color: #a07800; }
.b-blue { background: var(--ice); color: var(--blue-dark); }
.b-gray { background: #f2f5f8; color: var(--muted); }
.nearby .r-name { font-weight: 600; font-size: 13.5px; }
.nearby .r-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nearby .r-dist { color: var(--blue-dark); font-weight: 700; }
.nearby .r-chips { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }

.map-credits {
  position: absolute; left: 8px; bottom: 8px; z-index: 1000;
  font-size: 10.5px; color: var(--muted);
  background: rgba(255, 255, 255, .85); border-radius: 6px; padding: 2px 8px;
}
.map-credits a { color: var(--blue); }

/* ── Popup ── */
.leaflet-popup-content { margin: 14px 16px; font-family: inherit; }
.popup h3 { margin: 0 0 4px; font-size: 15px; }
.popup .p-addr { font-size: 12.5px; color: var(--muted); margin: 0 0 6px; }
.popup .p-row { font-size: 13px; margin: 3px 0; }
.popup .p-row a { color: var(--blue); }
.popup .p-attrs { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.popup .attr { font-size: 11px; padding: 2px 7px; border-radius: 999px; }
.popup .attr-yes { background: #e8f7ee; color: var(--verified); }
.popup .attr-unknown { background: #f2f5f8; color: var(--muted); }
.popup .p-claim {
  display: block; margin-top: 8px; text-align: center;
  font-size: 12.5px; font-weight: 600; color: var(--blue);
  padding: 7px; border: 1px dashed var(--blue); border-radius: var(--radius);
  cursor: pointer; background: none; width: 100%;
}
.popup .p-claim:hover { background: var(--ice); }

/* ── Modal ── */
.panel-hint { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 30, 45, .55);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative; width: min(480px, 92vw); max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 14px; padding: 22px;
}
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal-close {
  position: absolute; top: 10px; right: 12px; border: 0; background: none;
  font-size: 26px; color: var(--muted); cursor: pointer;
}
.modal form label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0; }
.modal form input:not([type="checkbox"]) {
  width: 100%; margin-top: 4px; padding: 9px 10px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px;
}
.modal fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; }
.modal legend { font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 6px; }
.modal fieldset .filter { display: flex; margin: 0; padding: 5px 10px; font-weight: 400; }

.form-section {
  font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--blue-dark); margin: 18px 0 4px; border-bottom: 2px solid var(--ice);
  padding-bottom: 4px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-req {
  font-size: 12px; color: var(--muted); background: var(--ice);
  border-radius: 8px; padding: 8px 10px; margin: 8px 0;
}
.form-req-error { background: #fdeeea; color: #b3401f; font-weight: 700; }

#services-groups details {
  border: 1px solid var(--line); border-radius: var(--radius);
  margin: 8px 0; padding: 0 10px;
}
#services-groups summary {
  cursor: pointer; font-size: 14px; font-weight: 700; padding: 10px 2px;
  color: var(--ink); user-select: none;
}
#services-groups details[open] summary { border-bottom: 1px dashed var(--line); margin-bottom: 6px; }
#services-groups .filter { display: flex; font-weight: 400; margin: 0; padding: 4px 2px; font-size: 13.5px; }
#services-groups details > .filter:last-child { padding-bottom: 10px; }

.p-badges { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0 6px; }

/* ── Strony artykułów ── */
.page-body { display: block; background: #f6fafd; min-height: 100vh; }
.page { max-width: 980px; margin: 0 auto; padding: 34px 20px 60px; }
.page-title { font-size: 32px; margin: 0 0 8px; color: var(--blue-dark); }
.page-lead { font-size: 16px; color: var(--muted); margin: 0 0 28px; }
.article-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.article-card {
  display: flex; flex-direction: column; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; text-decoration: none; color: var(--ink);
  transition: box-shadow .15s, transform .15s;
}
.article-card:hover { box-shadow: 0 8px 24px rgba(10, 40, 70, .14); transform: translateY(-2px); }
.article-card h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.article-card p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; flex: 1; }
.article-tag {
  align-self: flex-start; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; background: var(--ice); color: var(--blue-dark);
  padding: 3px 10px; border-radius: 999px;
}
.article-date { font-size: 12.5px; color: var(--blue); font-weight: 600; }
.article-page { max-width: 720px; }
.back-link { color: var(--blue); text-decoration: none; font-size: 14px; font-weight: 600; }
.back-link:hover { text-decoration: underline; }
.prose { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 34px; margin-top: 14px; }
.prose h1 { font-size: 27px; line-height: 1.25; margin: 10px 0 4px; color: var(--blue-dark); }
.prose h2 { font-size: 19px; margin: 24px 0 8px; }
.prose p, .prose li { font-size: 15.5px; line-height: 1.65; color: var(--ink); }
.prose ul { padding-left: 22px; }
.prose em { color: var(--muted); }
.article-cta {
  margin-top: 22px; background: linear-gradient(105deg, var(--blue-dark), var(--blue));
  border-radius: 16px; padding: 26px 30px; color: #fff;
  position: relative; overflow: hidden;
}
.cta-mark {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  width: 96px; height: 96px; opacity: .9;
  filter: brightness(0) invert(1) opacity(.22);
}
.article-cta > * { position: relative; }
.article-cta h3 { margin: 0 0 6px; font-size: 19px; }
.article-cta p { margin: 0 0 14px; font-size: 14px; opacity: .9; }
.btn-cta { display: inline-block; background: #fff; color: var(--blue-dark); text-decoration: none; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.btn-cta:hover { background: var(--ice); }
.page-footer { text-align: center; font-size: 12px; color: var(--muted); padding: 20px; }
.page-footer a { color: var(--blue); }

@media (max-width: 720px) {
  .brand-logo { height: 42px; }
  .topbar { padding: 6px 10px; gap: 6px; }
  .btn-long { display: none; }
  .topnav { gap: 0; }
  .topnav .btn { margin-left: 4px; padding: 9px 12px; font-size: 13px; }
  .controlbar { top: 8px; padding: 10px 12px; gap: 8px; }
  .controlbar-row { flex-wrap: wrap; justify-content: center; gap: 8px; }
  #city-select { min-width: 0; max-width: 52vw; font-size: 14px; padding: 10px; }
  .ctrl-btn { font-size: 14px; padding: 10px 12px; }
  .welcome-tiles { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topnav .nav-link { padding: 6px 8px; font-size: 13px; }
  .result-count { display: none; }
  .nearby { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: 45vh; }
  .dropdown-panel { position: fixed; left: 50%; top: 120px; width: min(320px, 92vw); }
}
