* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: 320px 1fr;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1a1f2e;
  background: #0e1626;
}

#map { height: 100vh; width: 100%; background: #0e1626; }

#sidebar {
  height: 100vh;
  overflow-y: auto;
  background: #f4f3ee;
  border-right: 1px solid #d8d5c7;
  padding: 18px 20px 32px;
}

#sidebar header h1 {
  margin: 0 0 2px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #2a3144;
}
#sidebar header .sub {
  margin: 0 0 18px;
  font-size: 12px;
  color: #6b6f7d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#sidebar h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b6f7d;
  margin: 0 0 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}
.stat {
  background: #fff;
  border: 1px solid #e2decf;
  border-radius: 6px;
  padding: 10px 12px;
}
.stat .num {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #2a3144;
  line-height: 1.1;
}
.stat .lbl {
  display: block;
  font-size: 11px;
  color: #6b6f7d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.cat-block, .filter-block, .draw-block, .legend {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e2decf;
}
.legend { border-bottom: none; }

.cat-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  cursor: pointer;
}
.cat-row input { margin: 0; }
.cat-row .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.cat-row .cat-name { color: #2a3144; }
.cat-row .cat-count {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: #6b6f7d;
  background: #ece9dd;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 28px;
  text-align: center;
}
.cat-row input:not(:checked) ~ .cat-name,
.cat-row input:not(:checked) ~ .cat-count { opacity: 0.45; }
.cat-row input:not(:checked) ~ .dot { opacity: 0.3; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
}
.check input { margin: 0; }

.rating-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: #4a5060;
}
.rating-row input[type=range] {
  width: 100%;
}

.hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: #6b6f7d;
}

.btn-row { display: flex; gap: 6px; margin-bottom: 6px; }
.btn {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border: 1px solid #c7c2ae;
  background: #2a3144;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: #1a1f2e; }
.btn:disabled { background: #aaa; border-color: #aaa; cursor: not-allowed; }
.btn-ghost {
  width: 100%;
  background: transparent;
  color: #6b6f7d;
  border: 1px solid #d8d5c7;
  margin-top: 4px;
}
.btn-ghost:hover { background: #ece9dd; color: #2a3144; }

.poly-stats {
  margin-top: 8px;
  font-size: 12px;
  color: #4a5060;
  font-variant-numeric: tabular-nums;
}
.poly-stats strong { color: #2a3144; }

.legend ul { list-style: none; padding: 0; margin: 0; }
.legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #4a5060;
  margin-bottom: 4px;
}
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.dot-search { background: #ff6b3d; }
.dot-inside { background: #fff; box-shadow: 0 0 0 2px #18a651, 0 0 0 1px rgba(0,0,0,0.15); }

/* Leaflet popup overrides */
.leaflet-popup-content {
  margin: 12px 14px;
  font-size: 13px;
  line-height: 1.4;
  min-width: 240px;
}
.leaflet-popup-content .p-title {
  font-weight: 700;
  font-size: 14px;
  color: #2a3144;
  margin-bottom: 4px;
}
.leaflet-popup-content .p-cat {
  color: #6b6f7d;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.leaflet-popup-content .p-row {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #eee;
  padding: 5px 0;
  font-size: 12px;
}
.leaflet-popup-content .p-row .k {
  color: #6b6f7d;
}
.leaflet-popup-content .p-row .v {
  color: #2a3144;
  font-weight: 500;
  text-align: right;
}
.leaflet-popup-content a { color: #4a5fd8; text-decoration: none; }
.leaflet-popup-content a:hover { text-decoration: underline; }

/* Responsive: collapse sidebar on narrow screens */
@media (max-width: 800px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #sidebar { height: auto; max-height: 45vh; }
  #map { height: 55vh; }
}
