:root {
  --bg: #0f1720;
  --panel: #16202b;
  --panel-2: #1d2a38;
  --line: #2a3a4c;
  --text: #e8eef5;
  --muted: #93a4b8;
  --accent: #2f7fd8;
  --accent-2: #38b26b;
  --warn: #d8862f;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", Roboto, system-ui, sans-serif;
}

/* ---------- gorny pasek ---------- */

.topbar {
  height: 58px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: linear-gradient(90deg, #12324f, #14507e 60%, #1a6fa8);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow); position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 26px; color: #7fd0ff; text-shadow: 0 0 12px rgba(127, 208, 255, .6);
}
.brand-name { font-weight: 700; letter-spacing: .14em; font-size: 17px; }
.brand-sub { font-size: 11px; color: #b9d6ef; letter-spacing: .04em; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.app-info { font-size: 12px; color: #cfe4f6; }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 13px; text-decoration: none; cursor: pointer;
  transition: filter .15s ease, transform .05s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn-app { background: #ffffff; color: #14507e; }
.btn-primary { background: var(--accent-2); color: #04250f; width: 100%; text-align: center; }
.btn-secondary {
  background: transparent; color: var(--text); border-color: var(--line); width: 100%;
  text-align: center; margin-top: 8px;
}

/* ---------- uklad ---------- */

.layout { display: flex; height: calc(100% - 58px); }

.panel {
  width: 380px; min-width: 380px; background: var(--panel);
  border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column;
}
.panel.collapsed { width: 0; min-width: 0; overflow: hidden; border-right: none; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.panel-title { font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 12px; }
.panel-toggle {
  background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1;
}

.panel-section { padding: 16px; border-bottom: 1px solid var(--line); }
.section-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: #cfe0f2; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- lista regionow ---------- */

.region-list, .layer-list { list-style: none; margin: 10px 0 0; padding: 0; }

.region-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent;
}
.region-item:hover { background: var(--panel-2); }
.region-item.active { background: #17384f; border-color: var(--accent); }
.region-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.region-name { flex: 1; font-weight: 600; }
.region-size { font-size: 12px; color: var(--muted); }

.region-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* ---------- warstwy ---------- */

.layer-item {
  display: flex; gap: 10px; padding: 10px; border-radius: 8px; align-items: flex-start;
  border: 1px solid var(--line); margin-bottom: 8px; background: var(--panel-2);
}
.layer-item.disabled { opacity: .45; }
.layer-item input { margin-top: 3px; accent-color: var(--accent-2); }
.layer-body { flex: 1; }
.layer-title { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.layer-size { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
.layer-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.layer-tag {
  display: inline-block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 4px; margin-top: 6px;
}
.tag-required { background: #2b4a68; color: #cfe6ff; }
.tag-missing { background: #4a3a22; color: #f0cf9a; }

.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 12px; background: var(--panel-2); border-radius: 8px; margin-bottom: 10px;
}
.total-row strong { font-size: 17px; color: var(--accent-2); }

/* ---------- legenda wysokosci ---------- */

/* ---------- podglad danych ---------- */

.switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-row input { accent-color: var(--accent-2); }

.search-input {
  width: 100%; margin-top: 10px; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-size: 13px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.search-results { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.search-result {
  padding: 8px 10px; border-radius: 6px; cursor: pointer; border-bottom: 1px solid var(--line);
}
.search-result:hover { background: var(--panel-2); }
.search-result .sr-name { font-weight: 600; }
.search-result .sr-meta { font-size: 11px; color: var(--muted); }

.legend-section { padding-bottom: 20px; }
.legend { display: flex; flex-direction: column-reverse; gap: 0; border-radius: 6px; overflow: hidden; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.legend-chip { width: 26px; height: 14px; flex: none; }

.attrib { padding: 14px 16px; font-size: 11px; color: #7e90a5; line-height: 1.6; }

/* ---------- mapa ---------- */

.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }
.map-badge {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  background: rgba(15, 23, 32, .82); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 6px; font-size: 11px; color: var(--muted);
}
/* Plakietka zamienia sie w klikalna podpowiedz, gdy mapa pogladowa nie ma
   juz czego pokazac w tej skali. */
.map-badge.badge-hint {
  background: rgba(232, 182, 44, .95); border-color: #b98f10;
  color: #1a1206; font-weight: 600; cursor: pointer;
}
.map-badge.badge-hint:hover { background: #f0c94a; }

.maplibregl-popup-content {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; font-size: 13px; padding: 10px 12px;
}
.maplibregl-popup-tip { border-top-color: var(--panel-2) !important; }
.popup-title { font-weight: 700; margin-bottom: 4px; }
.popup-line { font-size: 12px; color: var(--muted); }
