:root{
  --bg:#eef2f6;
  --panel:#ffffff;
  --panel-soft:#f7f9fc;
  --line:#d8e0ea;
  --text:#183046;
  --muted:#698196;
  --shadow:0 22px 60px rgba(22,40,65,.10);
  --radius:22px;
  --blue:#2c80ff;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:linear-gradient(180deg,#f7f9fc 0%,#ecf1f7 100%);
  color:var(--text);
}

.appShell{min-height:100%;padding:16px}
.mapWorkspace{
  display:grid;
  grid-template-columns:minmax(0,1fr) 360px;
  gap:16px;
  min-height:calc(100vh - 32px);
}

.mapViewport,
.detailsRail{
  min-height:calc(100vh - 32px);
}

.mapViewport{
  position:relative;
  border-radius:28px;
  overflow:hidden;
  background:#dce5ef;
  box-shadow:var(--shadow);
  border:1px solid rgba(112,135,161,.18);
}

#map{position:absolute;inset:0;height:100%;width:100%}

.mapHeaderOverlay{
  position:absolute;
  top:14px;
  left:14px;
  right:14px;
  z-index:3;
  display:grid;
  gap:10px;
  pointer-events:none;
}
.mapHeaderOverlay > *{pointer-events:auto}

.searchWrap,
.toolbarWrap,
.legendDock{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  background:rgba(255,255,255,.94);
  border:1px solid rgba(130,150,173,.20);
  box-shadow:0 14px 35px rgba(19,38,61,.10);
  border-radius:18px;
  padding:10px;
  backdrop-filter:blur(10px);
}
.searchWrap{justify-content:flex-start}
.toolbarWrap{justify-content:space-between}
.legendDock{padding:8px 10px}

.statCluster,
.toolbarActions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}

.searchInput,
.select{
  appearance:none;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  min-height:42px;
  border-radius:14px;
  padding:0 14px;
  font-size:14px;
}
.searchInput{width:min(360px,42vw)}
.select{min-width:220px}

.btn,
.inlineLink{
  appearance:none;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  min-height:42px;
  border-radius:14px;
  padding:0 14px;
  font-size:14px;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.btn:hover,
.inlineLink:hover{background:#f6f9fc}
.btn.ghost{background:#f7f9fc}

.chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:34px;
  padding:0 12px;
  border-radius:999px;
  background:#edf4ff;
  color:#245ba7;
  border:1px solid #d3e5ff;
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
}
.chipLight{background:#fff;border-color:var(--line);color:var(--muted)}

.toggleChip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:42px;
  padding:0 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--muted);
  font-size:14px;
}

.legendItem{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:999px;
  background:#fff;
  border:1px solid var(--line);
  cursor:pointer;
}
.legendItem[aria-pressed="false"]{opacity:.48}
.swatch{width:10px;height:10px;border-radius:999px;display:inline-block;border:2px solid rgba(255,255,255,.95);box-shadow:0 2px 8px rgba(0,0,0,.10)}
.legendLabel{font-size:12px;font-weight:700;color:var(--text)}
.legendCount{font-size:12px;color:var(--muted)}

.bottomTray{
  position:absolute;
  left:16px;
  right:16px;
  bottom:16px;
  z-index:3;
  background:rgba(255,255,255,.96);
  border:1px solid rgba(130,150,173,.22);
  border-radius:24px;
  box-shadow:0 18px 40px rgba(17,37,62,.16);
  padding:14px;
}
.trayTop{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.eyebrow{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.12em;
  color:#8195a9;
  font-weight:700;
}
.trayTop h2,
.selectedPanelHead h1{margin:4px 0 0}
.trayTop h2{font-size:18px}
.selectedPanelHead h1{font-size:26px;line-height:1.1}

.nearbyScroller{
  display:flex;
  gap:12px;
  overflow-x:auto;
  padding-bottom:4px;
  scroll-snap-type:x proximity;
}
.nearbyScroller::-webkit-scrollbar{height:10px}
.nearbyScroller::-webkit-scrollbar-thumb{background:#d4dce6;border-radius:999px}
.nearbyItem{
  flex:0 0 290px;
  scroll-snap-align:start;
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
  background:#fff;
  color:var(--text);
  text-align:left;
  cursor:pointer;
  box-shadow:0 8px 20px rgba(24,48,70,.06);
}
.nearbyItem.active{border-color:#9ec1ff;box-shadow:0 0 0 3px rgba(44,128,255,.15)}
.nearbyTop{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:10px}
.nearbyTitle{font-size:16px;font-weight:800;line-height:1.2}
.nearbyMeta{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:8px;color:var(--muted);font-size:12px}
.nearbyMeta span{padding:5px 8px;border-radius:999px;background:var(--panel-soft);border:1px solid #e7edf4}
.nearbyNotes{font-size:13px;line-height:1.45;color:#476176}

.detailsRail{
  display:grid;
  grid-template-rows:minmax(0,1fr) auto;
  gap:16px;
}
.selectedPanel,
.helperPanel{
  background:rgba(255,255,255,.95);
  border:1px solid rgba(130,150,173,.22);
  box-shadow:var(--shadow);
  border-radius:28px;
}
.selectedPanel{padding:24px;display:flex;flex-direction:column}
.selectedPanelHead{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:18px;
}
.metaStack{display:grid;grid-template-columns:1fr;gap:12px;margin-bottom:18px}
.metaCard{padding:14px;border:1px solid var(--line);border-radius:18px;background:var(--panel-soft)}
.metaLabel{font-size:11px;text-transform:uppercase;letter-spacing:.1em;color:#8296aa;font-weight:700;margin-bottom:6px}
.metaValue{font-size:14px;font-weight:700;color:var(--text)}
.bodyPanel{
  padding:16px;
  border:1px solid var(--line);
  border-radius:20px;
  background:#fff;
  min-height:220px;
}
.bodyLabel{font-size:12px;font-weight:800;color:#8296aa;margin-bottom:10px;text-transform:uppercase;letter-spacing:.1em}
.selectedNotes{margin:0;font-size:14px;line-height:1.7;color:#476176;white-space:pre-wrap}
.selectedActions{display:flex;gap:10px;flex-wrap:wrap;margin-top:18px}
.helperPanel{padding:18px;color:#5f768b;font-size:14px;line-height:1.6}
.helperPanel p{margin:8px 0 0}

.status{
  position:fixed;
  left:50%;
  bottom:18px;
  transform:translateX(-50%);
  min-width:240px;
  max-width:min(88vw,740px);
  padding:12px 16px;
  border-radius:14px;
  background:rgba(24,48,70,.92);
  color:#fff;
  font-size:13px;
  text-align:center;
  box-shadow:0 18px 44px rgba(9,18,30,.24);
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease;
}
.status:not(:empty){opacity:1}

.infoCard{max-width:300px;padding:2px 2px 4px;color:var(--text)}
.infoTitle{font-size:16px;font-weight:800;margin-bottom:6px}
.infoSub{font-size:12px;color:var(--muted);margin-bottom:4px}
.infoNotes{font-size:13px;line-height:1.5;color:#476176;margin-top:10px}
.infoActions{margin-top:12px}
.infoActions a{color:var(--blue);text-decoration:none;font-weight:700}
.pinMarker{
  width:18px;
  height:18px;
  border-radius:999px;
  border:3px solid #fff;
  box-shadow:0 10px 20px rgba(18,34,57,.22);
  position:relative;
}
.pinMarker::after{
  content:"";
  position:absolute;
  left:50%;
  top:50%;
  width:34px;
  height:34px;
  transform:translate(-50%,-50%);
  border-radius:999px;
  background:rgba(44,128,255,.16);
  opacity:0;
}
.pinMarker.active::after{opacity:1}

@media (max-width: 1180px){
  .mapWorkspace{grid-template-columns:1fr}
  .detailsRail{grid-template-rows:auto auto;min-height:auto}
  .mapViewport{min-height:72vh}
  .detailsRail,.mapViewport{min-height:auto}
}
@media (max-width: 760px){
  .appShell{padding:10px}
  .mapWorkspace{gap:10px;min-height:auto}
  .mapViewport{border-radius:22px;min-height:78vh}
  .mapHeaderOverlay{top:10px;left:10px;right:10px}
  .searchWrap,.toolbarWrap,.legendDock{padding:8px;border-radius:16px}
  .searchInput,.select{width:100%;min-width:0}
  .toolbarWrap{justify-content:flex-start}
  .bottomTray{left:10px;right:10px;bottom:10px;padding:12px;border-radius:20px}
  .nearbyItem{flex-basis:240px}
  .selectedPanel,.helperPanel{border-radius:22px;padding:18px}
  .selectedPanelHead h1{font-size:22px}
}
