:root {
  --bg: #0f1419;
  --panel: #171d25;
  --panel-2: #1e2630;
  --line: #2a3441;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --primary: #1f6feb;
  --primary-ink: #ffffff;
  --danger: #d9534f;
}

* { box-sizing: border-box; }
/* Atrybut `hidden` MUSI ukrywać element, nawet gdy klasa ustawia własne `display`
   (inaczej modal/panel pokazują się przed czasem). Dlatego wymuszamy `!important`. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

button { cursor: pointer; font: inherit; border-radius: 8px; border: 1px solid var(--line); }
button.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
button.ghost { background: transparent; color: var(--text); }
button.tool { background: var(--panel-2); color: var(--text); padding: 8px 14px; }
button.mini { padding: 4px 10px; font-size: 13px; background: var(--panel-2); color: var(--text); }
button.mini.primary { background: var(--primary); border-color: var(--primary); }
button:disabled { opacity: .5; cursor: default; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; padding: 9px 10px; margin-top: 4px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
/* Checkboksy i radia mają zostać natywne (globalny styl input je rozjeżdżał). */
input[type="checkbox"], input[type="radio"] {
  width: auto; margin: 0; padding: 0; accent-color: var(--accent, #2f6fed);
  background: none; border: 0; border-radius: 0; box-shadow: none; appearance: auto; vertical-align: middle;
}

/* ---------- Logowanie ---------- */
.login-screen { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 26px; }
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: .5px; }
.login-card .subtitle { margin: 2px 0 18px; color: var(--muted); }
.login-card label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.login-card .primary { width: 100%; padding: 11px; margin-top: 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 14px; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.or-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 16px 0 12px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
button.google { width: 100%; padding: 11px; display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; background: #ffffff; color: #1f2328; border: 1px solid var(--line); font-weight: 600; }
button.google:hover { background: #f2f4f7; }
button.google svg { width: 18px; height: 18px; }

/* ---------- Layout ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; }
.brand span { color: var(--muted); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.session-pick { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.session-pick select { width: auto; min-width: 160px; margin-top: 0; }
.ended-toggle { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }
.ended-toggle input { width: auto; margin: 0; }
.whoami { font-size: 13px; color: var(--muted); }
.banner { padding: 8px 14px; background: #3a2a12; color: #ffd79a; border-bottom: 1px solid var(--line); font-size: 13.5px; }

.layout { flex: 1; display: flex; min-height: 0; }
.map-pane { position: relative; flex: 1 1 60%; min-width: 0; }
#map { position: absolute; inset: 0; background: #223; }
.map-tools { position: absolute; z-index: 500; left: 10px; top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.draw-hint { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.draw-hint-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.side-pane { flex: 0 0 380px; max-width: 380px; overflow-y: auto; background: var(--panel);
  border-left: 1px solid var(--line); padding: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 6px 4px 12px; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.legend .dot { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255,255,255,.35); }

.block { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 12px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.block-head h2 { font-size: 15px; margin: 0; }
.empty { color: var(--muted); font-size: 13px; margin: 6px 2px; }

.table-wrap { overflow-x: auto; }
table.teams { width: 100%; border-collapse: collapse; font-size: 13px; }
table.teams th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.teams td { padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.teams tr:last-child td { border-bottom: none; }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; color: #fff; font-size: 12px; white-space: nowrap; cursor: pointer; }
.row-actions { display: inline-flex; gap: 6px; }
.icon-btn { background: transparent; border: none; color: var(--muted); padding: 2px 4px; font-size: 15px; }
.icon-btn:hover { color: var(--text); }

.pool { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.chip .swatch { width: 11px; height: 11px; border-radius: 3px; }
.chip select { width: auto; margin: 0; padding: 3px 6px; font-size: 12.5px; }

.sector-list { display: flex; flex-direction: column; gap: 8px; }
.sector-row { display: flex; flex-direction: column; gap: 8px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.sector-row.selected { outline: 2px solid var(--primary); }
.sec-top { display: flex; align-items: center; gap: 8px; }
.sec-top .swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.sec-top .name { font-size: 13.5px; font-weight: 600; flex: 1; cursor: pointer; }
.sec-top .sec-actions { display: inline-flex; gap: 4px; }
.sec-controls { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.sec-controls label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.sec-controls select { width: auto; margin: 0; padding: 4px 6px; font-size: 12.5px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 1000; padding: 16px; }
.modal-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; max-height: 90vh; overflow-y: auto; }
.modal-card h3 { margin: 0 0 14px; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal-actions button { padding: 9px 16px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #222c38; color: #fff; border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 10px; z-index: 2000; font-size: 14px; max-width: 90vw; }

/* label na mapie */
.leaflet-control-layers { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.leaflet-control-layers-expanded { padding: 8px 10px; }
.leaflet-control-layers label { color: var(--text); font-size: 13px; }

/* Wybór warstwy mapy — czytelny wiersz: kropka po lewej, w jednej linii z nazwą.
   (Neutralizuje globalne input{width:100%} które rozjeżdżało kontrolkę Leaflet.) */
.leaflet-control-layers-expanded { padding: 6px 10px; min-width: 132px; }
.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label { display: block; margin: 4px 0; cursor: pointer; }
.leaflet-control-layers-base label > div,
.leaflet-control-layers-overlays label > div { display: flex; align-items: center; gap: 8px; }
.leaflet-control-layers input[type="radio"],
.leaflet-control-layers input[type="checkbox"] {
  width: auto; flex: 0 0 auto; margin: 0; padding: 0;
  background: none; border: 0; border-radius: 0; box-shadow: none; appearance: auto;
}
.leaflet-control-layers-base span,
.leaflet-control-layers-overlays span { white-space: nowrap; }
.sector-label { background: rgba(0,0,0,.6); color: #fff; padding: 1px 6px; border-radius: 6px;
  font-size: 12px; font-weight: 700; white-space: nowrap; border: none; }
.trail-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 0 4px 10px; }
.trail-toggle input { width: auto; margin: 0; }
.export-row { display: flex; gap: 8px; }
.export-note { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
.peer-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.peer-name { background: rgba(0,0,0,.6); color: #fff; padding: 0 5px; border-radius: 5px; font-size: 11px; margin-left: 4px; white-space: nowrap; }

/* Przewodnicy (roster) */
.roster-pool { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.guide { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.guide-info { display: flex; flex-direction: column; min-width: 0; }
.guide-name { font-size: 13.5px; font-weight: 600; }
.guide-dogs { font-size: 12px; color: var(--muted); }
.guide select { width: auto; margin: 0; padding: 4px 6px; font-size: 12.5px; flex: 0 0 auto; }
.roster-teams { display: flex; flex-direction: column; gap: 8px; }
.roster-team { border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; background: var(--panel); }
.roster-team-head { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.guide-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.guide-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px 3px 9px;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; }
.chip-x { background: transparent; border: none; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 2px; cursor: pointer; }
.chip-x:hover { color: var(--danger); }
.draft-vertex { background: #8e24aa; color: #fff; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.draft-vertex.first { background: #2e7d32; }

/* ---------- Responsywność ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .map-pane { flex: 0 0 46vh; }
  .side-pane { flex: 1 1 auto; max-width: none; border-left: none; border-top: 1px solid var(--line); }
}

/* ---------- Nowa akcja: paski Pro / potwierdzenie kodu ---------- */
.banner-warn { background: #3a1f1f; color: #ffb4b4; }
.banner-ok { background: #16301f; color: #9be6b4; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.banner-ok #createdInfoText { flex: 1; min-width: 200px; }
.banner-ok code { background: rgba(255,255,255,0.12); padding: 1px 7px; border-radius: 6px; font-size: 15px; letter-spacing: 1px; }
#newActionBtn { white-space: nowrap; }
#newActionBtn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Szukanie na mapie (adres / współrzędne / moja pozycja) ---------- */
.map-search { display: flex; gap: 4px; padding: 4px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,.45); }
.map-search input { width: 240px; max-width: 46vw; padding: 5px 8px; font-size: 13px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; }
.map-search button { padding: 5px 9px; font-size: 13px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.map-search button:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.map-search button:disabled { opacity: .5; cursor: default; }

/* ---------- Podgląd współrzędnych (klik = dymek, kursor = odczyt na żywo) ---------- */
.coord-readout { background: rgba(23,29,37,.85); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.coord-popup .coord-val { font-size: 14px; font-variant-numeric: tabular-nums; margin-bottom: 6px; color: #1f2328; }
.coord-popup button.mini { margin: 0; }

/* ---------- Mój profil / psy ---------- */
.plan-badge { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.plan-badge.pro { background: #16301f; color: #9be6b4; border: 1px solid #2E7D32; }
.plan-badge.free { background: #3a2a12; color: #ffd79a; border: 1px solid #8a6d3b; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text); margin-bottom: 10px; }
.dogs-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
.dog-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.dog-main { font-size: 13.5px; color: var(--text); }
.dog-name { font-weight: 600; }
.dog-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.dog-badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; margin-left: 4px; }
.dog-badge.on { background: #16301f; color: #9be6b4; }
.dog-badge.off { background: #3a1f1f; color: #ffb4b4; }
.dog-btns { display: flex; gap: 4px; flex-shrink: 0; }

/* ---------- Uwagi w miejscu (❗) + akcje w popupie lokalizacji ---------- */
.note-pin { width: 26px; height: 26px; display: grid; place-items: center; font-size: 16px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.note-pin > * { transform: rotate(45deg); }
.note-pin.warn { background: #7a1f1f; border-color: #ffb4b4; }
.note-popup { min-width: 160px; color: #1f2328; }
.note-popup .sub { color: #6b7280; font-size: 11px; }
.note-popup .note-text { margin: 4px 0 6px; font-size: 13px; white-space: pre-wrap; }
.loc-label { font-size: 12px; color: #374151; margin-bottom: 3px; }
.loc-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }

/* Komunikaty + widoczność śladów */
.field-lbl { display:block; font-size:13px; color:#334; margin:4px 0; }
.field-lbl select { margin-left:6px; }
#msgText { width:100%; box-sizing:border-box; margin:6px 0; resize:vertical; font:inherit; padding:6px; border:1px solid #cfd6e0; border-radius:6px; }
.msg-pick { display:flex; flex-wrap:wrap; gap:6px 12px; margin:4px 0 2px; max-height:120px; overflow:auto; }
.msg-chk { font-size:13px; display:inline-flex; align-items:center; gap:4px; }
.track-list { display:flex; flex-direction:column; gap:3px; max-height:160px; overflow:auto; }
.track-item { display:flex; align-items:center; gap:6px; font-size:13px; cursor:pointer; }
.track-item .sub { color:#889; margin-left:auto; }
.track-dot { width:12px; height:3px; border-radius:2px; display:inline-block; }

/* Alerty z terenu (feed ❗/uwagi od uczestników) */
.alert-list { display:flex; flex-direction:column; gap:6px; max-height:260px; overflow:auto; }
.alert-item { display:flex; gap:8px; padding:7px 9px; border:1px solid var(--line); border-radius:8px;
  background:var(--panel-2); cursor:pointer; }
.alert-item:hover { border-color:#8aa; }
.alert-item.warn { border-left:3px solid #d32f2f; }
.alert-ic { font-size:16px; line-height:1.2; flex:0 0 auto; }
.alert-body { min-width:0; }
.alert-text { font-size:13px; color:var(--text); word-break:break-word; }
.alert-meta { font-size:11px; color:var(--muted); margin-top:2px; }

/* „Sektory nieprzypisane" jako uwaga (ciepły akcent) */
.block-warn { border-left: 3px solid #E0A020; }
.block-warn .block-head h2 { color: #C8871A; }

/* Raporty w chmurze */
.cloud-reports { display:flex; flex-direction:column; gap:5px; max-height:220px; overflow:auto; margin-top:6px; }
.cloud-report { display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:6px 8px; border:1px solid var(--line); border-radius:8px; background:var(--panel-2); }
.cr-name { font-size:12px; color:var(--text); word-break:break-word; }
.cr-actions { display:flex; gap:6px; flex:0 0 auto; }
.mini.danger { color:#d9534f; border-color:#d9534f; }

/* Baner „tryb podglądu" (akcja zakończona) */
.readonly-note { background:#3a2a10; color:#f0c060; border:1px solid #7a5a20; border-radius:8px;
  padding:8px 10px; font-size:13px; margin-bottom:8px; }

/* Przycisk „pokaż na mapie" przy przewodniku */
.mini.locate { padding:2px 6px; line-height:1; }
.guide .mini.locate { margin-left:auto; }
.chip-loc { background:none; border:0; cursor:pointer; font-size:12px; padding:0 2px; }
.chip-loc:hover { opacity:0.7; }
