:root {
  --navy: #0f1f3d;
  --navy-2: #16294d;
  --teal: #0ea5a4;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --shadow: 0 6px 24px rgba(15, 31, 61, .12);
  --radius: 10px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---- Top bar ---------------------------------------------------------- */
#topbar {
  position: fixed; inset: 0 0 auto 0; height: 64px; z-index: 20;
  display: flex; align-items: center; gap: 24px; padding: 0 20px;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff; box-shadow: var(--shadow);
}
.brand {
  display: flex; align-items: center; gap: 13px; flex: none;
  padding-right: 22px; border-right: 1px solid rgba(255,255,255,.12);
}
.brand-logo { flex: none; display: block; filter: drop-shadow(0 2px 6px rgba(0,0,0,.28)); }
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: #9fb3d1; letter-spacing: .2px; white-space: nowrap; }

#search-wrap { position: relative; flex: 1; max-width: 460px; }
#search {
  width: 100%; height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.10);
  color: #fff; font-size: 14px; outline: none;
}
#search::placeholder { color: #aebfd8; }
#search:focus { background: #fff; color: var(--ink); border-color: var(--teal); }
#suggestions {
  position: absolute; top: 44px; left: 0; right: 0; background: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  max-height: 340px; overflow-y: auto; z-index: 30;
}
.sugg {
  padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.sugg:last-child { border-bottom: 0; }
.sugg:hover { background: #f0fdfa; }
.sugg-badge {
  font-size: 10px; font-weight: 700; color: #fff; border-radius: 4px;
  padding: 2px 6px; letter-spacing: .3px; flex: none;
}
.sugg-main { font-size: 13.5px; color: var(--ink); }
.sugg-sub { font-size: 11.5px; color: var(--muted); }

#kpis {
  display: flex; gap: 22px; margin-left: auto;
  padding-left: 22px; border-left: 1px solid rgba(255,255,255,.12);
}
.kpi { text-align: right; }
.kpi-val { display: block; font-size: 18px; font-weight: 700; line-height: 1.1; }
.kpi-lbl { font-size: 10.5px; color: #9fb3d1; text-transform: uppercase; letter-spacing: .4px; }

/* ---- Left panel ------------------------------------------------------- */
#panel {
  position: fixed; top: 84px; left: 16px; z-index: 15; width: 252px;
  max-height: calc(100vh - 104px); overflow-y: auto;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 4px 0 10px;
}
.panel-section { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-section h3 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted);
}
.lg-group-title {
  font-size: 10.5px; font-weight: 700; color: var(--navy);
  margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .4px;
}
.lg-group-title:first-child { margin-top: 0; }
.toggle {
  display: flex; align-items: center; gap: 9px; padding: 5px 0;
  font-size: 13px; cursor: pointer; user-select: none;
}
.toggle input { accent-color: var(--teal); width: 15px; height: 15px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.swatch.line { height: 4px; border-radius: 2px; }
.swatch.ring { border-radius: 50%; }

#legend .leg { display: flex; align-items: center; gap: 9px; padding: 3px 0; font-size: 12.5px; }
.panel-foot { padding: 12px 16px 4px; font-size: 10.5px; color: var(--muted); line-height: 1.5; }

/* ---- Map / popup ------------------------------------------------------ */
#map { position: fixed; inset: 64px 0 0 0; }
#loading {
  position: fixed; inset: 64px 0 0 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; background: var(--bg);
}

.maplibregl-popup { max-width: 320px !important; }
.maplibregl-popup-content {
  padding: 0; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); font-size: 13px;
}
.pp-head {
  background: var(--navy); color: #fff; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.pp-title { font-weight: 700; font-size: 14px; }
.pp-type { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px; letter-spacing: .3px; }
.pp-body { max-height: 300px; overflow-y: auto; }
.pp-row { display: flex; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.pp-row:last-child { border-bottom: 0; }
.pp-k { color: var(--muted); flex: none; width: 44%; }
.pp-v { color: var(--ink); font-weight: 500; word-break: break-word; }
.status-pill { padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.maplibregl-popup-close-button { color: #fff; font-size: 18px; padding: 4px 9px; }
