/* =====================================================================
   OK SENIOR – mapa | układ
   Desktop: mapa z nakładkami (wyszukiwarka, przełącznik, zoom) + formularz obok, pasek firm pod spodem.
   Telefon/tablet pionowo (< 900 px): wszystko w jednej kolumnie.
   ===================================================================== */

:root {
  --navy: #0f1f45;          /* tekst */
  --navy-soft: #4a5878;     /* tekst pomocniczy */
  --accent: #18478E;        /* główny akcent (PRD) */
  --accent-hover: #123a76;
  --accent-tint: #e9f0fb;   /* tła kafli statystyk, aktywne stany */
  --page: #f5f8fd;          /* tło strony */
  --surface: #ffffff;
  --line: #e3e9f3;
  --focus: #f2a900;         /* wyraźny, ciepły fokus – widoczny na niebieskim i białym */
  --danger: #b3261e;

  --r-lg: 24px;             /* panele */
  --r-md: 16px;             /* pozycje listy, kafle */
  --r-pill: 999px;          /* pola i przyciski */
  --shadow: 0 10px 32px rgba(24, 71, 142, .12);
  --shadow-sm: 0 3px 12px rgba(24, 71, 142, .10);

  --gap: clamp(12px, 1.1vw, 20px);
  --panel-w: clamp(360px, 31vw, 560px);
  --header-h: auto;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --fs-base: 18px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--navy);
  font: 400 var(--fs-base)/1.5 var(--font);
  overflow-x: hidden;               /* zabezpieczenie: brak poziomego przewijania */
}

/* 98vw – min() z 100% chroni przed przepełnieniem, gdy pasek przewijania zabiera miejsce */
.app {
  width: min(98vw, 100%);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding-bottom: var(--gap);
}

.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

h1, h2, p { margin: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link {
  position: absolute; left: 12px; top: -100px; z-index: 100;
  background: var(--accent); color: #fff; padding: 12px 20px; border-radius: var(--r-pill);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 12px 28px;
  border: 0; border-radius: var(--r-pill);
  font: 600 1rem/1.2 var(--font); cursor: pointer; text-align: center;
}
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(24, 71, 142, .28); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: var(--surface); color: var(--accent); border: 2px solid var(--accent); min-height: 48px; padding: 10px 22px; }
.btn--ghost:hover { background: var(--accent-tint); }

/* ---------- Nagłówek ---------- */
.site-header {
  display: flex; align-items: flex-start; gap: clamp(14px, 2vw, 32px);   /* logo przy tytule także po rozwinięciu opisu */
  padding: clamp(12px, 1.4vw, 20px) clamp(4px, 2vw, 40px) 0;
}
.brand { flex: 0 0 auto; display: block; border-radius: 50%; }
.brand__logo { display: block; width: clamp(64px, 5.2vw, 96px); height: auto; }
.brand__fallback {
  display: grid; place-content: center; text-align: center;
  width: clamp(64px, 5.2vw, 96px); aspect-ratio: 1; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-sm);
  color: var(--accent); font-weight: 800; font-size: 1.6rem; line-height: 1;
}
.brand__fallback small { font-size: .55rem; letter-spacing: .08em; margin-top: 2px; }
.site-header h1 {
  font-size: clamp(1.35rem, 1.05rem + 1vw, 2.1rem); font-weight: 700; line-height: 1.2;
  letter-spacing: -.01em; text-wrap: balance;
}
.site-header p { margin-top: 6px; color: var(--navy-soft); font-size: clamp(1rem, .95rem + .2vw, 1.15rem); max-width: 110ch; }

/* Rozwijany opis certyfikatu */
.about { margin-top: 4px; max-width: 110ch; }
.about__toggle {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 2px;
  color: var(--accent); font-weight: 700; font-size: clamp(1rem, .95rem + .2vw, 1.1rem);
  cursor: pointer; list-style: none; border-radius: 8px;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}
.about__toggle::-webkit-details-marker { display: none; }
.about__toggle:hover { text-decoration-thickness: 2px; }
.about__chev { transition: transform .2s ease; }
.about[open] .about__chev { transform: rotate(180deg); }
.about__body {
  margin: 6px 0 4px; padding: 18px 22px; border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-sm); color: var(--navy);
}
.site-header .about__body p { color: var(--navy); max-width: none; margin: 0 0 10px; }
.about__body ul { margin: 0 0 10px; padding-left: 1.3em; }
.about__body li { margin-bottom: 4px; }
.about__report {
  margin-top: 14px; padding: 16px 18px; border-radius: var(--r-md);
  background: #fff7e6; border-left: 5px solid var(--focus);
}
.site-header .about__report p { margin-bottom: 12px; }
.about__row { display: flex; gap: 10px; flex-wrap: wrap; }
.about__row input {
  flex: 1 1 280px; min-width: 0; min-height: 52px; padding: 11px 16px;
  border: 1.5px solid #b9c6dc; border-radius: 12px; background: #fff; font: inherit; color: var(--navy);
}
.about__row input:focus-visible { border-color: var(--accent); outline-offset: 1px; }
.about__row .btn { flex: 0 0 auto; }

/* ---------- Układ: mapa | formularz, pod spodem pasek firm ---------- */
.layout {
  display: grid; gap: var(--gap); align-items: start;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-areas: "stage panel" "firms firms";
}
.stage { grid-area: stage; }
.panel { grid-area: panel; }
.firms { grid-area: firms; }

/* ---------- Scena (mapa + nakładki) – desktop ---------- */
.stage {
  position: relative;
  min-height: 560px;
  height: calc(100dvh - 260px);   /* nagłówek + pasek firm + odstępy; dokładne dopasowanie w JS */
  max-height: 1100px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #dfe9f5;
  box-shadow: var(--shadow-sm);
}

.map { position: absolute; inset: 0; }
.map__canvas { position: absolute; inset: 0; }
.map__placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.7), transparent 45%),
    linear-gradient(160deg, #e8f0fa 0%, #d6e4f3 60%, #cddcef 100%);
  color: var(--navy-soft); text-align: center;
}
.map__placeholder { z-index: 2; }
.map__placeholder[hidden] { display: none; }
.map__placeholder p { max-width: 34ch; }
.map__placeholder.is-error p { color: var(--danger); font-weight: 600; }
/* komunikat o błędzie mapy pod wyszukiwarką, w odsłoniętej części */
.map__placeholder.is-error { place-items: start center; padding-top: calc(var(--search-h, 110px) + var(--gap) * 3); }
.map__placeholder.is-error p + p { color: inherit; font-weight: 400; }
/* mapa nie działa – kontrolki mapy nie mają sensu */
.stage.map-failed .map-ctrl { display: none; }

/* ---------- Mapbox: klastry, atrybucja, okienka ---------- */
.ok-cluster { pointer-events: none; line-height: 0; filter: drop-shadow(0 2px 3px rgba(15, 31, 69, .25)); }
.map .mapboxgl-ctrl-bottom-left { margin: 0 0 4px 4px; }
.mapboxgl-popup-content {
  padding: 16px 44px 16px 18px; border-radius: var(--r-md); box-shadow: var(--shadow);
  font: 400 1rem/1.45 var(--font); color: var(--navy);
}
.mapboxgl-popup-close-button {
  width: 44px; height: 44px; font-size: 26px; line-height: 1; color: var(--navy-soft);
  border-radius: 0 var(--r-md) 0 var(--r-md);
}
.mapboxgl-popup-close-button:hover { background: var(--accent-tint); color: var(--navy); }
.pp__net { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--navy-soft); margin-bottom: 4px; }
.pp__dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.pp__name { font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.pp__addr { margin-top: 4px; }
.pp__list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.pp__item {
  width: 100%; min-height: 44px; display: flex; align-items: flex-start; gap: 10px; text-align: left;
  padding: 8px 6px; border: 0; border-top: 1px solid var(--line); background: none;
  font: inherit; color: var(--navy); cursor: pointer;
}
.pp__item .pp__dot { margin-top: 6px; }
.pp__item small { display: block; color: var(--navy-soft); font-size: .9rem; }
.pp__item:hover { background: var(--accent-tint); }

/* Wyszukiwarka */
.search {
  position: absolute; z-index: 5;
  top: var(--gap); left: var(--gap);
  width: min(460px, calc(100% - 220px));
  min-width: 300px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}
.search__label { display: block; font-weight: 700; font-size: 1rem; margin-bottom: 10px; }
.search__row { display: flex; gap: 10px; align-items: center; }
.search__field { position: relative; flex: 1 1 auto; min-width: 0; }
.search__pin { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--navy-soft); pointer-events: none; }
.search__field input {
  width: 100%; min-height: 52px; padding: 12px 18px 12px 50px;
  border: 1.5px solid var(--line); border-radius: var(--r-pill); background: #f8fafd;
  font: inherit; font-size: 1rem; color: var(--navy);
}
.search__field input::placeholder { color: #6b7894; }
.search__field input:focus-visible { outline-offset: 1px; border-color: var(--accent); background: #fff; }
.search__btn {
  flex: 0 0 auto; width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(24, 71, 142, .3);
}
.search__btn:hover { background: var(--accent-hover); }
.search__list {
  position: absolute; z-index: 20; left: 12px; right: 12px; top: calc(100% - 6px);
  margin: 0; padding: 6px; list-style: none;
  max-height: min(50vh, 420px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
}
.search__list[hidden] { display: none; }
.search__opt {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  min-height: 52px; padding: 8px 14px; border-radius: 12px; cursor: pointer;
}
.search__opt + .search__opt { margin-top: 2px; }
.search__opt:hover, .search__opt[aria-selected="true"] { background: var(--accent-tint); }
.search__opt[aria-selected="true"] { box-shadow: inset 4px 0 0 var(--accent); }
.search__opt-name { font-weight: 600; font-size: 1.05rem; }
.search__opt-region { font-size: .9rem; color: var(--navy-soft); }
.search__msg { font-size: .95rem; color: var(--navy-soft); }
.search__msg:not(:empty) { margin-top: 10px; }
.search__msg.is-error { color: var(--danger); }

/* Kontrolki mapy */
.map-ctrl { position: absolute; z-index: 4; }
.map-ctrl--style, .map-ctrl--fullscreen, .map-ctrl--zoom { right: var(--gap); }

.map-ctrl--style {
  top: var(--gap);
  display: flex; gap: 4px; padding: 5px;
  background: var(--surface); border-radius: var(--r-pill); box-shadow: var(--shadow-sm);
}
.seg {
  min-height: 46px; min-width: 96px; padding: 8px 20px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--navy); font: 600 1rem/1 var(--font); cursor: pointer;
}
.seg.is-active { background: var(--accent); color: #fff; }
.seg:not(.is-active):hover { background: var(--accent-tint); }

.map-ctrl--icon, .map-ctrl__btn {
  width: 52px; height: 52px; display: grid; place-items: center;
  border: 0; background: var(--surface); color: var(--navy); cursor: pointer;
}
.map-ctrl--fullscreen { top: calc(var(--gap) + 76px); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.map-ctrl--fullscreen .icon--exit { display: none; }
.stage.is-fullscreen .map-ctrl--fullscreen .icon--enter { display: none; }
.stage.is-fullscreen .map-ctrl--fullscreen .icon--exit { display: block; }

.map-ctrl--zoom {
  bottom: var(--gap);
  display: flex; flex-direction: column; border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-sm);
}
.map-ctrl__btn + .map-ctrl__btn { border-top: 1px solid var(--line); }
.map-ctrl--icon:hover, .map-ctrl__btn:hover { background: var(--accent-tint); }
.map-ctrl__btn:focus-visible, .map-ctrl--icon:focus-visible { outline-offset: -3px; }

/* ---------- Panel boczny: zgłoszenie firmy ---------- */
.panel {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: clamp(18px, 1.7vw, 30px);
  overflow-y: auto; overscroll-behavior: contain;
}
.panel section:focus { outline: none; }
.panel__title {
  font-size: clamp(1.5rem, 1.05rem + 1.15vw, 2.3rem); font-weight: 800; line-height: 1.15;
  letter-spacing: -.015em; text-wrap: balance;
}
.panel__lead { margin: 6px 0 14px; font-size: 1.1rem; color: var(--navy-soft); }
.panel .rform__field { margin-bottom: 12px; }
.panel .rform textarea { min-height: 84px; }
.panel .rform__more { margin: 0 0 14px; }
.panel .rform, .panel .rform__done { padding: 0; }
.panel .rform .rform__actions .btn, .panel .rform__done .btn { width: 100%; min-height: 56px; font-size: 1.1rem; }
.panel .rform__note { margin: 12px 0 0; text-align: center; }

/* ---------- Pasek certyfikowanych firm ---------- */
.firms {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 12px clamp(12px, 1.2vw, 20px) 14px;
}
.firms:focus { outline: none; }
.firms__hint { font-size: .95rem; color: var(--navy-soft); margin: 0 4px 10px; }
.firms__list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 236px), 1fr)); gap: 10px;
}
.firms__loading, .firms__error { color: var(--navy-soft); padding: 8px 4px; grid-column: 1 / -1; }
.firms__error { color: var(--danger); }
.firms__retry { margin-top: 10px; }

.firm {
  width: 100%; height: 100%; min-height: 64px;
  display: grid; grid-template-columns: 28px 72px 1fr; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md);
  color: var(--navy); font: 500 1rem/1.3 var(--font); text-align: left;
}
button.firm { cursor: pointer; }
button.firm:hover { border-color: #c4d3ea; background: #fafcff; }
/* Znacznik w kolorze sieci = stan filtra: wypełniony ze znakiem ✓ (widoczne) albo pusty (ukryte) */
.firm__dot {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c, var(--accent)); border: 2px solid var(--c, var(--accent)); color: var(--navy);
}
.firm__dot .icon { width: 16px; height: 16px; stroke-width: 3.5; }
.firm__dot--phone { background: none; border: 0; border-radius: 0; color: var(--navy-soft); }
.firm__dot--phone .icon { width: 22px; height: 22px; stroke-width: 2; }
.firm__logo { height: 44px; display: grid; place-items: center; }
.firm__logo img { max-width: 100%; max-height: 44px; width: auto; height: auto; object-fit: contain; }
.firm__badge {
  display: grid; place-items: center; width: 100%; height: 40px; padding: 0 6px; border-radius: 10px;
  background: #fff; border: 3px solid var(--accent); color: var(--navy);
  font-weight: 700; font-size: .85rem; line-height: 1.1; text-align: center; overflow: hidden;
}
.firm__name { min-width: 0; }
.firm__meta { display: block; font-size: .9rem; color: var(--navy-soft); margin-top: 2px; }

/* Stan filtra: ramka + znak ✓ + dopisek „ukryte” (nie tylko kolor) */
.firm[aria-pressed="true"] { border-color: var(--accent); }
.firm[aria-pressed="false"] .firm__dot { background: #fff; border-color: #9aa8c2; color: transparent; }
.firm[aria-pressed="false"] .firm__logo,
.firm[aria-pressed="false"] .firm__name { opacity: .5; }
.firm[aria-pressed="false"] .firm__meta::after { content: " – ukryte"; }
a.firm { text-decoration: none; }

/* ---------- Tajemniczy klient 60+: baner w panelu + okno z formularzem ---------- */
/* Grafika tła jest zawsze rozciągnięta na pełną szerokość boksu (100% auto), więc jej lewa połowa
   pokrywa się z lewą połową boksu i nic jej nie zasłania; napis i przycisk siedzą w prawej połowie.
   Proporcje boksu ustawia report.js na podstawie rozmiaru grafiki. */
.mcta {
  margin-top: 16px; min-height: 148px;
  display: grid; grid-template-columns: 1fr 1fr;
  border-radius: var(--r-md);   /* bez overflow: hidden – boks może urosnąć, gdy napis się nie mieści */
  background: #18478E url("https://oksenior.pl/mapa/tlo.webp") center / 100% auto no-repeat;
}
.mcta__body {
  grid-column: 2; align-self: center;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 10px 14px 10px 8px;
}
.mcta__title {
  color: #fff; font-size: clamp(1.05rem, .7rem + .75vw, 1.5rem); font-weight: 800; line-height: 1.15;
  text-wrap: balance; text-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.mcta__btn {
  background: #2075BB; color: #fff; min-height: 46px; padding: 8px 18px; max-width: 100%; font-size: clamp(.92rem, .8rem + .25vw, 1rem);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.mcta__btn:hover { background: #1b66a5; }
.panel__own { width: 100%; min-height: 52px; margin-top: 16px; font-size: 1.05rem; }

.dialog {
  border: 0; border-radius: var(--r-lg); padding: 0; width: min(720px, 94vw);
  max-height: 92vh; max-height: 92dvh; overflow: auto;
  box-shadow: var(--shadow); color: var(--navy); background: var(--surface);
}
.dialog::backdrop { background: rgba(15, 31, 69, .5); }
.dialog__head {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 24px 14px; border-bottom: 1px solid var(--line);
}
.dialog__head h2 { font-size: 1.4rem; line-height: 1.25; }
.dialog__head .pcard__close { position: static; flex: 0 0 auto; }
.dialog__body { padding: 16px 24px 24px; }
.dialog .rform, .dialog .rform__done { padding: 0; }
.dialog .rform__done:focus { outline: none; }
.mystery__lead { font-size: 1.1rem; color: var(--navy-soft); margin-bottom: 12px; }
.mystery__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ---------- Lista placówek ---------- */
.plist {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 18px clamp(16px, 2vw, 32px);
}
.plist:focus { outline: none; }
.plist:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.plist__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.plist__title { font-size: 1.35rem; }
.plist__stats { margin-top: 2px; }
.plist__stats strong { font-variant-numeric: tabular-nums; }
.plist__summary { color: var(--navy-soft); margin-top: 2px; }
.plist__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.plist__body { margin-top: 16px; }
.plist__items {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 10px;
}
.plist__item {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-md);
}
.plist__dot { width: 14px; height: 14px; border-radius: 50%; align-self: start; margin-top: 6px; }
.plist__text { display: flex; flex-direction: column; min-width: 0; }
.plist__net { font-size: .9rem; color: var(--navy-soft); }
.plist__name { font-weight: 700; overflow-wrap: anywhere; }
.plist__addr { overflow-wrap: anywhere; }
.plist__dist { font-size: .9rem; color: var(--accent); font-weight: 600; }
.plist__btn { min-height: 44px; padding: 8px 16px; }
.plist__empty { grid-column: 1 / -1; padding: 12px 0; color: var(--navy-soft); }
.plist__more { margin-top: 14px; text-align: center; }
.plist__more:empty { display: none; }
.map__placeholder .btn { margin-top: 14px; }

/* ---------- Formularze (zgłoszenie firmy, tajemniczy klient) ---------- */
.rform, .rform__done { padding: 18px 24px 24px; }
.rform__intro { color: var(--navy-soft); margin-bottom: 12px; }
.rform__alert {
  margin-bottom: 14px; padding: 12px 16px; border-radius: var(--r-md);
  background: #fdecea; color: var(--danger); font-weight: 600;
}
.rform fieldset { border: 0; margin: 0 0 18px; padding: 0; min-width: 0; }
.rform legend { font-weight: 700; font-size: 1.1rem; margin-bottom: 10px; padding: 0; }
.rform__opt { font-weight: 400; font-size: .95rem; color: var(--navy-soft); }
.rform__field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.rform__row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.rform label { font-weight: 600; }
.rform__req { font-weight: 400; color: var(--navy-soft); }
.rform input:not([type="checkbox"]), .rform textarea, .rform select {
  width: 100%; min-height: 50px; padding: 11px 14px;
  border: 1.5px solid #b9c6dc; border-radius: 12px; background: #fff;
  font: inherit; color: var(--navy);
}
.rform textarea { min-height: 96px; resize: vertical; }
.rform select { cursor: pointer; }
.rform input, .rform textarea, .rform__alert { scroll-margin-top: 120px; }
.rform input:focus-visible, .rform textarea:focus-visible, .rform select:focus-visible { border-color: var(--accent); outline-offset: 1px; }
.rform [aria-invalid="true"] { border-color: var(--danger); background: #fff8f7; }
.rform__error { color: var(--danger); font-size: .95rem; font-weight: 600; }
.rform__error::before { content: "⚠ "; }
.rform__more {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; margin: 2px 0 16px;
  padding: 10px 18px; border: 2px dashed #9fb4d6; border-radius: var(--r-md);
  background: var(--accent-tint); color: var(--accent); font: 600 1rem/1.2 var(--font); cursor: pointer;
}
.rform__more:hover { border-color: var(--accent); }
.rform__more .icon { transition: transform .2s ease; }
.rform__more[aria-expanded="true"] .icon { transform: rotate(45deg); }
.rform__extra { border-top: 1px solid var(--line); padding-top: 16px; }
.rform__trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.rform__check { display: grid; grid-template-columns: 28px 1fr; gap: 4px 12px; align-items: start; margin: 4px 0 18px; }
.rform__check input { width: 28px; height: 28px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.rform__check label { font-weight: 400; cursor: pointer; }
.rform__check a { color: var(--accent); font-weight: 600; }
.rform__check .rform__error { grid-column: 2; }
.rform__note { font-size: .95rem; color: var(--navy-soft); margin: 4px 0 18px; }
.rform__note a { color: var(--accent); font-weight: 600; }
.rform__actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.rform__done:focus { outline: none; }
.rform__done-msg {
  font-size: 1.2rem; font-weight: 700; padding: 18px 20px; margin-bottom: 18px;
  border-radius: var(--r-md); background: #e8f6ee; color: #155d33;
}
.rform__done-msg::before { content: "✓ "; }
.panel .rform__row { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
@media (max-width: 599.98px) {
  .dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .dialog__head, .dialog__body { padding-left: 16px; padding-right: 16px; }
  .rform__row, .mystery__grid { grid-template-columns: 1fr; }
  .rform__actions .btn { flex: 1 1 100%; }
}

/* ---------- Karta placówki ---------- */
.pcard {
  position: absolute; z-index: 7;
  left: var(--gap);
  top: calc(var(--gap) * 2 + var(--search-h, 110px));
  width: min(420px, calc(100% - var(--gap) * 2 - 70px));
  min-width: 300px;
  max-height: calc(100% - var(--gap) * 3 - var(--search-h, 110px));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 20px 20px 20px;
}
.pcard[hidden] { display: none; }
.pcard:focus { outline: none; }
.pcard:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pcard__handle { display: none; }
.pcard__close {
  position: absolute; top: 10px; right: 10px;
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--accent-tint); color: var(--navy); cursor: pointer;
}
.pcard__close:hover { background: #d8e5f7; }
.pcard__net { display: flex; align-items: center; gap: 12px; padding-right: 52px; margin-bottom: 12px; }
.pcard__net .firm__logo { flex: 0 0 96px; height: 40px; }
.pcard__net .firm__badge { height: 36px; }
.pcard__netname { font-size: .95rem; color: var(--navy-soft); line-height: 1.3; }
.pcard__name { font-size: 1.35rem; line-height: 1.25; font-weight: 700; padding-right: 8px; overflow-wrap: anywhere; }
.pcard__rows { margin: 14px 0 0; display: flex; flex-direction: column; gap: 12px; }
.pcard__row { position: relative; padding-left: 36px; }
.pcard__row dt .icon { position: absolute; left: 0; top: 2px; color: var(--accent); }
.pcard__row dt { font-size: .9rem; color: var(--navy-soft); }
.pcard__row dd { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.pcard__row a { color: var(--accent); font-weight: 600; text-underline-offset: 3px; }
.pcard__pre { white-space: pre-line; }
.pcard__note { margin-top: 12px; color: var(--navy-soft); font-size: .95rem; }
.pcard__note--error { color: var(--danger); }
.pcard__route { width: 100%; margin-top: 18px; text-decoration: none; }
.pcard__report { margin-top: 12px; text-align: center; }
.pcard__report a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 600; text-underline-offset: 3px; }

/* ---------- Pełny ekran ---------- */
.stage.is-fullscreen { border-radius: 0; height: 100%; max-height: none; }
.stage:fullscreen { border-radius: 0; height: 100vh; max-height: none; }
.map:fullscreen { height: 100vh; border-radius: 0; }
.stage.is-pseudo-fullscreen { position: fixed; inset: 0; z-index: 50; height: auto; max-height: none; border-radius: 0; }

/* =====================================================================
   Tablet poziomo / mniejsze laptopy
   ===================================================================== */
@media (max-width: 1500px) and (min-width: 900px) {
  /* wąska mapa: przełącznik stylu na dół, wyszukiwarka na całą szerokość */
  .search { min-width: 0; width: calc(100% - var(--gap) * 3 - 52px); max-width: 460px; }
  .map-ctrl--style { top: auto; bottom: var(--gap); right: calc(var(--gap) + 64px); }
  .map-ctrl--fullscreen { top: var(--gap); }
  .pcard { min-width: 0; width: min(420px, calc(100% - var(--gap) * 2)); }
  .firm { grid-template-columns: 28px 56px 1fr; gap: 10px; padding: 8px 10px; }
}
@media (max-width: 1200px) {
  :root { --panel-w: 350px; }
}

/* Niskie okna (laptopy 768 px, tablet poziomo) – gęstszy panel i pasek firm */
@media (min-width: 900px) and (max-height: 860px) {
  .stage { min-height: 480px; }
  .site-header h1 { font-size: clamp(1.3rem, 1rem + .8vw, 1.7rem); }
  .panel { padding: 18px; }
  .panel__title { font-size: clamp(1.35rem, 1rem + .8vw, 1.7rem); }
  .panel__lead { margin-bottom: 12px; }
  .mcta { min-height: 132px; margin-top: 12px; }
  .firms { padding-top: 10px; padding-bottom: 10px; }
  .firms__hint { display: none; }
  .firm { min-height: 54px; padding: 6px 10px; }
  .firm__logo, .firm__badge { height: 36px; }
  .firm__logo img { max-height: 36px; }
}

/* =====================================================================
   Telefon i tablet pionowo – jedna kolumna
   ===================================================================== */
@media (max-width: 899.98px) {
  :root { --fs-base: 16px; --gap: 12px; }
  body { font-size: 16px; }

  .site-header { padding: 12px 4px 0; align-items: flex-start; }
  .site-header h1 { font-size: 1.3rem; }
  .site-header p { font-size: 1rem; }

  .stage {
    position: static; height: auto; max-height: none; min-height: 0; overflow: visible;
    background: none; box-shadow: none; border-radius: 0;
    display: flex; flex-direction: column; gap: var(--gap);
  }
  .search { position: relative; left: auto; top: auto; width: 100%; min-width: 0; padding: 16px; z-index: 6; }
  .search__label { font-size: 1.05rem; }

  .map {
    position: relative; inset: auto; order: 2;
    height: clamp(360px, 62svh, 640px);
    border-radius: var(--r-lg); overflow: hidden; background: #dfe9f5; box-shadow: var(--shadow-sm);
  }
  .map-ctrl--style, .map-ctrl--fullscreen, .map-ctrl--zoom { right: var(--gap); }
  .map-ctrl--style { top: var(--gap); left: var(--gap); right: auto; }
  .map-ctrl--fullscreen { top: var(--gap); }
  .seg { min-width: 84px; padding: 8px 14px; }

  .layout { display: flex; flex-direction: column; }
  .panel { overflow: visible; padding: 18px 16px; }
  .firms { padding: 12px; }
  .firm { grid-template-columns: 28px 72px 1fr; }
  .firm__logo { height: 40px; }
  .plist { padding: 16px; }
  .plist__actions, .plist__actions .btn { width: 100%; }
  .plist__item { grid-template-columns: 14px 1fr; }
  .plist__btn { grid-column: 2; justify-self: start; }

  .stage.is-pseudo-fullscreen .map { position: fixed; inset: 0; height: auto; border-radius: 0; z-index: 50; }

  /* Karta placówki jako panel wysuwany od dołu */
  .pcard {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; min-width: 0; max-height: 78svh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 32px rgba(15, 31, 69, .22);
    animation: pcard-up .22s ease-out;
  }
  .pcard__handle { display: block; width: 48px; height: 5px; border-radius: 3px; background: #c9d3e3; margin: 0 auto 10px; }
  .pcard__close { top: 8px; }
  body.has-pcard { padding-bottom: 40svh; }   /* dół strony da się przewinąć nad kartę */
  .stage.is-pseudo-fullscreen { position: static; }
}

@keyframes pcard-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

@media (max-width: 420px) {
  .site-header { flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
