:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --topbar: #0f172a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --sidebar-w: 344px;
  --topbar-h: 60px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Topbar */
.topbar {
  height: var(--topbar-h); flex: 0 0 auto; background: var(--topbar); color: #fff;
  display: flex; align-items: center; gap: 16px; padding: 0 18px; z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; line-height: 1; }
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; font-weight: 700; }
.tag { margin: 0; font-size: 12px; color: #94a3b8; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.legend { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #cbd5e1; flex-wrap: wrap; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.datadate { font-size: 11.5px; color: #94a3b8; }
.filter-toggle { display: none; }

/* Layout */
.layout { flex: 1 1 auto; display: flex; min-height: 0; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--bg);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
.map { flex: 1 1 auto; min-width: 0; background: #e8eef3; }

/* Panel */
.panel { padding: 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.field { display: block; margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 7px; }
input[type="search"] {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--ink);
}
input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; user-select: none; display: inline-flex;
  align-items: center; gap: 7px; transition: .12s;
}
.chip:hover { border-color: #cbd5e1; }
.chip .cdot { width: 9px; height: 9px; border-radius: 50%; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on .cdot { box-shadow: 0 0 0 2px rgba(255,255,255,.5); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .65; font-size: 12px; }
.chip.on .n { opacity: .85; }

/* Types */
details.types summary { cursor: pointer; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); list-style: none; }
details.types summary::-webkit-details-marker { display: none; }
details.types summary::before { content: "▸ "; color: var(--muted); }
details.types[open] summary::before { content: "▾ "; }
details.types #typeSearch { margin: 9px 0; }
.type-list { max-height: 260px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.type-group-h { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 4px; }
.type-row { display: flex; align-items: center; gap: 9px; padding: 5px 4px; border-radius: 7px; cursor: pointer; }
.type-row:hover { background: var(--bg); }
.type-row input { accent-color: var(--accent); width: 15px; height: 15px; }
.type-row img { width: 34px; height: 22px; object-fit: contain; border-radius: 3px; background: #f8fafc; }
.type-row .tn { font-size: 13px; line-height: 1.15; }
.type-row .tx { font-size: 11px; color: var(--muted); }

/* Actions */
.filter-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.match-count { font-size: 13px; font-weight: 600; }
.match-count b { color: var(--accent); }
.clear-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.clear-btn:hover { border-color: #cbd5e1; color: var(--ink); }
.hint { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; }
.muted { color: var(--muted); font-weight: 400; }

/* Results */
.results { flex: 1 1 auto; overflow-y: auto; padding: 8px; }
.rcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px; margin-bottom: 8px; cursor: pointer; transition: .12s; }
.rcard:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.rcard .rname { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.rcard .rcity { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.rcard .rtags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tagpill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.tagpill.p { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.results-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 12px; }

/* Popup */
.leaflet-popup-content { margin: 12px 14px; font-family: inherit; }
.pop h3 { margin: 0 0 2px; font-size: 15px; }
.pop .paddr { color: var(--muted); font-size: 12.5px; margin: 0 0 9px; }
.pop .pgroup { margin-top: 8px; }
.pop .pgh { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 3px; }
.pop ul { margin: 0; padding-left: 16px; font-size: 13px; }
.pop li { margin: 1px 0; }
.pop .plink { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--accent); text-decoration: none; font-weight: 600; }
.pop .plink:hover { text-decoration: underline; }
.pin .dot { display: block; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.pin.premium .dot { width: 15px; height: 15px; border-color: #f59e0b; box-shadow: 0 0 0 2px #f59e0b, 0 1px 4px rgba(0,0,0,.45); }
.pin.premium .prembadge { position: absolute; top: -11px; left: 6px; font-size: 12px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.pop .ppremium { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 5px 8px; }
.tagpill.prem { background: #fffbeb; color: #b45309; border-color: #fde68a; font-weight: 600; }

/* Footer */
.footer { flex: 0 0 auto; background: var(--topbar); color: #94a3b8; font-size: 11.5px; padding: 7px 18px; text-align: center; }
.footer a { color: #cbd5e1; }

/* Mobile */
@media (max-width: 780px) {
  body { overflow: auto; height: auto; }
  .layout { flex-direction: column; height: auto; }
  .filter-toggle { display: inline-block; margin-left: auto; background: #1e293b; color: #fff; border: 1px solid #334155; border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer; }
  .topbar-meta { display: none; }
  .sidebar { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--line); max-height: 62vh; }
  .sidebar.collapsed { display: none; }
  .map { height: 58vh; flex: none; }
  .results { max-height: none; }
}
