:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --border: #e2e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#app { display: flex; flex-direction: column; height: 100vh; }

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: var(--bg);
  color: #fff;
  z-index: 1100;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  font-weight: 800;
  font-size: 15px;
}

.titles h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.titles p { font-size: 12px; color: #94a3b8; }

.search-wrap { position: relative; width: min(440px, 44vw); }

.controls { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.filter-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.f-label {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  margin-right: 2px;
}

.filter-bar input[type="number"] {
  width: 96px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #fff;
  font-size: 13px;
  outline: none;
}

.filter-bar input[type="number"]:focus { border-color: var(--accent); }
.filter-bar input[type="number"]::placeholder { color: #64748b; }

.dash { color: #64748b; font-weight: 600; }

.btn-sm {
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background: #334155;
  color: #e2e8f0;
}

.btn-sm:hover { background: #475569; }
.btn-sm.accent { background: var(--accent); color: #fff; }
.btn-sm.accent:hover { background: var(--accent-dark); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: none;
  background: #334155;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover { background: #475569; color: #fff; }
.chip.active { background: var(--accent); color: #fff; }

#results-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 350px;
  max-width: calc(100vw - 28px);
  max-height: calc(100% - 70px);
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 800;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

.rp-title { flex: 1; font-size: 14px; font-weight: 700; white-space: nowrap; }
#rp-count { color: var(--muted); font-weight: 600; }

#rp-sort {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 12.5px;
  color: var(--ink);
}

#rp-close {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

#rp-close:hover { background: #e2e8f0; color: var(--ink); }

#rp-list {
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}

#rp-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

#rp-list li:last-child { border-bottom: none; }
#rp-list li:hover { background: #eff6ff; }

.r-main { min-width: 0; }
.r-top { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.r-right { text-align: right; flex-shrink: 0; }
.r-val { font-size: 12.5px; font-weight: 700; color: var(--accent-dark); }
.r-ppsf { font-size: 10.5px; color: var(--muted); }

li.r-note { cursor: default; justify-content: center; font-size: 12px; color: var(--muted); font-style: italic; }
li.r-note:hover { background: none; }

#search {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #fff;
  font-size: 14px;
  outline: none;
}

#search:focus { border-color: var(--accent); }
#search::placeholder { color: #64748b; }

#results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  list-style: none;
  overflow: hidden;
  z-index: 1200;
}

#results li {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

#results li:last-child { border-bottom: none; }
#results li:hover { background: #eff6ff; }
#results .r-addr { font-weight: 600; }
#results .r-sub { color: var(--muted); font-size: 12px; }

#main { position: relative; flex: 1; min-height: 0; }

#map { height: 100%; width: 100%; background: #cbd5e1; }

#stats {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 16px;
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  font-size: 12.5px;
  border-radius: 999px;
  z-index: 900;
  pointer-events: none;
  white-space: nowrap;
}

#panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 92vw;
  height: 100%;
  background: var(--panel);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  overflow-y: auto;
  padding: 22px 22px 28px;
  animation: slide-in 0.18s ease-out;
}

@keyframes slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

#close-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

#close-panel:hover { background: #e2e8f0; color: var(--ink); }

.p-addr { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 4px; padding-right: 30px; }
.p-city { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--accent-dark);
}

.badge.neutral { background: #f1f5f9; color: var(--muted); }

.section { margin-top: 18px; }
.section h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.kv .item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
}

.kv .label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.kv .value { font-size: 14.5px; font-weight: 700; }
.kv .value small { font-size: 11px; font-weight: 500; color: var(--muted); }

.value-hero {
  display: flex;
  gap: 10px;
}

.value-hero .item { flex: 1; background: linear-gradient(135deg, #eff6ff, #f5f3ff); border: 1px solid #dbeafe; border-radius: 10px; padding: 10px 12px; }
.value-hero .value { font-size: 17px; font-weight: 800; color: var(--accent-dark); }

.rows { display: flex; flex-direction: column; gap: 6px; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}

.row:last-child { border-bottom: none; }
.row .k { color: var(--muted); }
.row .v { font-weight: 600; text-align: right; }

.empty-note { color: var(--muted); font-size: 12.5px; font-style: italic; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  #topbar { flex-wrap: wrap; }
  .search-wrap { width: 100%; order: 3; }
}
