:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #16181d;
  --muted: #666c78;
  --accent: #1a6ef5;
  --warn: #c2410c;
  --ok: #15803d;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 20px rgba(0,0,0,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --border: #272b33;
    --text: #e8eaed;
    --muted: #9aa1ad;
    --accent: #5b9cff;
    --warn: #fb923c;
    --ok: #4ade80;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 13px;
  min-width: 84px;
}
.stat b { display: block; font-size: 18px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat.warn b { color: var(--warn); }

/* ---------- layout ---------- */
.layout { flex: 1 1 auto; display: flex; min-height: 0; }

.sidebar {
  width: 380px;
  flex: 0 0 380px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.filters { padding: 14px; border-bottom: 1px solid var(--border); display: grid; gap: 9px; }

input[type=search], select {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input[type=search]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.field { display: grid; gap: 3px; }
.field > span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }

.filter-actions { display: flex; gap: 8px; }
.btn-ghost {
  flex: 1;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.result-count { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.result-count strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- list ---------- */
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; }
.list li {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.list li:hover { background: var(--bg); }
.list li.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.list .li-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.list .li-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.li-flags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--warn) 15%, transparent);
  color: var(--warn);
  white-space: nowrap;
}

/* ---------- map ---------- */
.map-wrap { flex: 1 1 auto; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }

.legend {
  position: absolute;
  bottom: 18px;
  right: 12px;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 9px 11px;
  font-size: 12px;
  max-width: 190px;
}
.legend div { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.legend strong { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.leaflet-container { font: inherit; }
.marker-pin {
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

/* ---------- detail panel ---------- */
.detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-y: auto;
  z-index: 1200;
  padding: 20px 22px 40px;
}
.detail-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; font-size: 26px; line-height: 1;
  color: var(--muted); cursor: pointer;
}
.detail h2 { margin: 0 8px 4px 0; font-size: 19px; letter-spacing: -.01em; }
.detail .d-type { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.detail dl { display: grid; grid-template-columns: 116px 1fr; gap: 7px 12px; margin: 0 0 16px; font-size: 13.5px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; word-break: break-word; }
.detail a { color: var(--accent); }
.detail .review {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
}
.detail h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 7px; }
.detail .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.btn-maps {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff !important;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 550;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  body { overflow: auto; height: auto; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--border); }
  .list { max-height: 320px; }
  .map-wrap { height: 62vh; flex: none; }
  .stat-row { width: 100%; overflow-x: auto; }
}
