:root {
  --bg: #f7f9fb;
  --surface: #ffffff;
  --text: #0f1b2d;
  --muted: #5c6b7f;
  --border: #e4e9ef;
  --accent: #0b6bcb;
  --accent-dark: #064e95;
  --accent-soft: #e7f1fc;
  --shadow: 0 1px 3px rgba(15, 27, 45, 0.06), 0 4px 12px rgba(15, 27, 45, 0.05);

  --c-hemo: #d9342b;
  --c-udm: #1a73e8;
  --c-auto: #16a34a;
  --c-dp: #a855f7;
  --c-alt: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- Topbar ---------- */
.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  display: block;
  width: 32px;
  height: auto;
  flex-shrink: 0;
}
.brand h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand .subtitle {
  font-size: 13px;
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 500;
}
.filter-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 64px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #d1d8e0; border-radius: 3px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  display: block;
}

input[type="text"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-results {
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.search-results .sr-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
}
.search-results .sr-item:hover { background: var(--accent-soft); }
.search-results .sr-item:last-child { border-bottom: none; }
.search-results .sr-name { font-weight: 600; display: block; color: var(--text); }
.search-results .sr-meta { color: var(--muted); font-size: 12px; }
.search-results .sr-empty { padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }

.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.check:hover { background: var(--accent-soft); }
.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.check .tag-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.check .count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.btn-reset {
  width: 100%;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-reset:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 4px 0;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}
.dot-hemo { background: var(--c-hemo); }
.dot-udm  { background: var(--c-udm); }
.dot-auto { background: var(--c-auto); }
.dot-dp   { background: var(--c-dp); }
.dot-alt  { background: var(--c-alt); }

.sources p, .hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}
.hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.sources a {
  color: var(--accent);
  text-decoration: none;
}
.sources a:hover { text-decoration: underline; }

/* ---------- Map ---------- */
.map-wrap {
  position: relative;
  background: #e4e9ef;
}
#map {
  width: 100%;
  height: 100%;
}
.map-counter {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ---------- Markers ---------- */
.marker-pin {
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ---------- Popup ---------- */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 6px 24px rgba(15, 27, 45, 0.15);
}
.leaflet-popup-content {
  margin: 0;
  min-width: 280px;
  max-width: 320px;
  font-family: 'Inter', sans-serif;
}
.popup {
  padding: 14px 16px;
}
.popup h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.35;
  color: var(--text);
}
.popup .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.popup .tag {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.popup .row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}
.popup .row .icon {
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 2px;
}
.popup a {
  color: var(--accent);
  text-decoration: none;
}
.popup a:hover { text-decoration: underline; }
.popup .actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.popup .btn {
  flex: 1;
  padding: 7px 10px;
  text-align: center;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.popup .btn:hover { background: var(--accent-dark); }
.popup .btn.secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.popup .btn.secondary:hover { background: var(--accent-soft); }

/* ---------- Cluster custom ---------- */
.marker-cluster div {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateY(0); }
  .filter-toggle { display: inline-flex; }
  .map-wrap { height: calc(100vh - 64px); }
  .brand h1 { font-size: 15px; }
}

/* ---------- Regions hub (home page) ---------- */
.regions-hub {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 48px 24px;
}
.regions-hub-inner {
  max-width: 1100px;
  margin: 0 auto;
}
.regions-hub h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.regions-hub > .regions-hub-inner > p {
  color: var(--muted);
  margin: 0 0 24px;
}
.regions-hub h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  margin: 24px 0 12px;
}
.regions-hub-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
}
.regions-hub-list li {
  padding: 12px 14px;
  background: #f0f6fd;
  border-radius: 8px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: background 0.15s;
}
.regions-hub-list li:hover { background: #e0ebf7; }
.regions-hub-list li a {
  color: var(--accent-dark);
  font-weight: 500;
  text-decoration: none;
  flex: 1;
}
.regions-hub-list li .count {
  background: var(--accent);
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.site-footer-home {
  background: #f0f3f8;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.site-footer-home p { margin: 0 0 6px; max-width: 900px; margin-left: auto; margin-right: auto; }

@media (max-width: 600px) {
  .regions-hub { padding: 32px 16px; }
  .regions-hub-list { grid-template-columns: 1fr; }
}
