:root {
  --bg: #09111f;
  --panel: rgba(10, 19, 35, 0.92);
  --panel-alt: rgba(14, 27, 48, 0.92);
  --border: rgba(116, 156, 224, 0.18);
  --text: #e7eefc;
  --muted: #8ba0c7;
  --accent: #6ae3ff;
  --a: #7ef29a;
  --b: #ffd166;
  --c: #f98f6f;
  --contacted: #b084f5;
  --danger: #ff7a90;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at top, #11203b 0, #09111f 45%, #050a13 100%); color: var(--text); }
body { min-height: 100vh; }
button, input, select { font: inherit; }
a { color: var(--accent); }

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(620px, 1fr) 360px;
  min-height: 100vh;
}

.sidebar, .map-panel {
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.detail-panel {
  border-right: none;
  border-left: 1px solid var(--border);
}
.panel-header, .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.12em; }

.panel-block, .kpi-grid > .kpi-card, .detail-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.panel-block { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.kpi-card {
  padding: 14px;
}
.kpi-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; }
.kpi-subtext { font-size: 12px; color: var(--muted); margin-top: 4px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
input[type="search"], select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(6, 14, 27, 0.95);
  color: var(--text);
  padding: 10px 12px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.inline-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.inline-toggle input { accent-color: var(--accent); }
.push-right { margin-left: auto; }
.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.ghost-button:hover { border-color: var(--accent); color: var(--accent); }

.layer-stack { display: flex; flex-direction: column; gap: 12px; }
.layer-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}
.checkbox-chip input { accent-color: var(--accent); }

.lead-list-panel { min-height: 0; flex: 1; }
.lead-list-meta {
  font-size: 12px;
  color: var(--muted);
}
.lead-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.pagination-bar button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.lead-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(7, 13, 24, 0.9);
  cursor: pointer;
}
.lead-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(106, 227, 255, 0.3); }
.lead-card.contacted { opacity: 0.68; }
.lead-card-header, .lead-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.lead-card-name { font-weight: 700; font-size: 14px; }
.lead-card-subtitle, .lead-card-score { color: var(--muted); font-size: 12px; }
.lead-card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.lead-card-row input { accent-color: var(--accent); }

.map-panel {
  position: relative;
  background: linear-gradient(180deg, rgba(7, 16, 30, 0.95), rgba(4, 10, 20, 1));
}
.map-toolbar {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 18px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(7, 17, 31, 0.85);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.dot {
  width: 10px; height: 10px; border-radius: 999px; display: inline-block; margin-right: 6px;
}
.dot-a { background: var(--a); }
.dot-b { background: var(--b); }
.dot-c { background: var(--c); }
.dot-contacted { background: var(--contacted); }
#map { height: 100vh; width: 100%; }

.detail-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 4px;
}
.detail-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hidden { display: none; }
.priority-row, .detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  font-size: 12px;
}
.pill.muted { color: var(--muted); }
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.metric {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.02);
}
.metric-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.metric-value { font-size: 16px; font-weight: 700; }
.detail-block { display: flex; flex-direction: column; gap: 8px; }
.detail-actions a, .detail-actions button { text-decoration: none; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: rgba(9, 18, 35, 0.96);
  color: var(--text);
}
.popup-card { min-width: 220px; }
.popup-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.popup-meta { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.popup-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.popup-actions button {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}
.popup-actions a { font-size: 12px; }

@media (max-width: 1500px) {
  .app-shell { grid-template-columns: 320px minmax(520px, 1fr) 320px; }
}

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar, .detail-panel { min-height: auto; }
  #map { height: 68vh; }
}
