:root {
  /* Główne tła */
  --bg: #ffffff; /* bazowe tło strony – białe */
  --bg-elevated: #f3f4f6; /* szare tło pośrednie (np. mapa zanim się załaduje) */
  --bg-sidebar: #f3f4f6; /* szare tło bocznego panelu */

  /* Kolory nagłówka zgodne z załącznikiem (nowy odcień zieleni) */
  --header-bg: #94b021;
  --header-text: #ffffff;

  /* Akcenty kolorystyczne – spójne z nagłówkiem */
  --border-subtle: #d1d5db;
  --accent: #4d7c0f;
  --accent-soft: rgba(189, 216, 73, 0.2);
  --accent-strong: rgba(132, 204, 22, 0.4);
  --text: #111827;
  --text-dim: #6b7280;
  --danger: #b91c1c;
  --highlight: #38bdf8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "Museo Sans", "Trebuchet MS", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.page {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1320px;
  padding: 20px;
  gap: 16px;
  min-height: 100vh;
}

.page-footer {
  margin-top: auto;
  padding-top: 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.page-footer a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.page-footer-logo-wrap {
  text-align: center;
  padding: 1rem 0 0.5rem;
}

.page-footer-logo-wrap .page-footer-logo-link {
  display: inline-block;
  line-height: 0;
}

.page-footer-zhp-logo {
  max-height: 48px;
  width: auto;
  display: block;
  opacity: 0.85;
}

.page-footer-logo-wrap .page-footer-logo-link:hover .page-footer-zhp-logo {
  opacity: 1;
}

.page-header {
  background-color: var(--header-bg) !important;
  color: var(--header-text) !important;
  border-radius: 18px;
  padding: 18px 22px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
}

.page-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-header-logo-link {
  display: block;
  line-height: 0;
  flex-shrink: 0;
}

.page-header-logo {
  max-height: 80px;
  width: auto;
  display: block;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 2.1vw, 1.7rem);
  letter-spacing: 0.02em;
}

.page-header-title-link {
  color: inherit;
  text-decoration: none;
}

.page-header-title-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.page-header p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.92rem;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);
  gap: 16px;
}

.sidebar {
  border-radius: 18px;
  /* szare tło pośrednie */
  background-color: var(--bg-sidebar) !important;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-content {
  padding: 16px 18px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Desktop: mapa i panel mają stałą wysokość (jak w /bazy),
   długa lista hufców przewija się w panelu, zamiast wydłużać stronę. */
@media (min-width: 769px) {
  .map,
  .sidebar {
    height: 560px;
  }

  .sidebar-content {
    max-height: 560px;
  }
}

.toolbar {
  border-radius: 16px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  padding: 14px 18px;
}

.toolbar-content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-search {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(640px, 100%);
}

.toolbar-search-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.toolbar-search input {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 12px 18px;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

.toolbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(148, 176, 33, 0.22);
}

.map {
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.sidebar {
  border-radius: 18px;
  /* szare tło pośrednie */
  background-color: var(--bg-sidebar) !important;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
}

.sidebar-content {
  padding: 16px 18px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-footer-logo-link {
  flex-shrink: 0;
  display: block;
  text-align: center;
  line-height: 0;
  padding: 10px 18px 14px;
}

.sidebar-footer-logo {
  max-height: 80px;
  width: auto;
  display: inline-block;
}

.sidebar-content h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.sidebar-content p {
  margin: 0 0 10px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.county-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.county-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.county-meta {
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.county-meta span {
  opacity: 0.9;
}

.county-meta strong {
  color: var(--accent);
}

.hufiec-card {
  border-radius: 14px;
  padding: 10px 11px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  margin-bottom: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.hufiec-card:last-child {
  margin-bottom: 0;
}

.hufiec-name {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 0.98rem;
}

.hufiec-commander {
  margin: 0 0 4px;
  font-size: 0.86rem;
  color: var(--text-dim);
}

.hufiec-address {
  margin: 0 0 6px;
  font-size: 0.86rem;
  color: var(--text-dim);
}

.hufiec-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  text-decoration: none;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease,
    box-shadow 0.15s ease;
}

.link-pill:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #111827;
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(15, 23, 42, 0.9);
}

.link-pill-icon {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #022c22;
  font-size: 10px;
}

.leaflet-container {
  /* szare tło pod kafelkami mapy */
  background-color: var(--bg-elevated) !important;
}

.leaflet-control-attribution {
  font-size: 9px !important;
  background: var(--bg) !important;
  color: #6b7280 !important;
}

.leaflet-control-zoom a {
  background: var(--bg);
  color: #111827;
  border-color: var(--border-subtle);
}

.leaflet-control-zoom a:hover {
  background: var(--accent-soft);
  color: #111827;
  border-color: var(--accent);
}

.legend {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(31, 41, 55, 0.9);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.legend-note {
  margin-top: 4px;
}

.zone-legend {
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.zone-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.zone-legend-row:last-child {
  margin-bottom: 0;
}
.zone-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid;
  flex-shrink: 0;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1.4fr);
  }
}

@media (max-width: 768px) {
  .page {
    padding: 12px;
  }

  .page-header {
    padding: 14px 14px;
  }

  .page-header-content {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .page-header-content > div {
    flex: 1 1 auto;
    min-width: 0;
  }

  .page-header-content .page-header-logo-link {
    flex: 0 0 auto;
    order: 2;
    margin-left: auto;
  }

  .page-header-logo {
    max-height: 52px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    /* Mniejsza mapa na mobile niż w bazach – ważniejsza lista/opis */
    grid-template-rows: minmax(220px, auto) minmax(0, auto);
    /* Na mobile całość ma się naturalnie wydłużać – wysokość sekcji nie jest sztywno ograniczona */
    height: auto;
  }

  .sidebar {
    min-height: 240px;
  }
}

