:root {
  --bg: #0a0d12;
  --panel: #161a22;
  --panel-2: #1c2230;
  --line: #2a3142;
  --text: #e6e9ef;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --accent-2: #6dd5ed;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --grey: #7f8c8d;
  --red: #e74c3c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
code { font-family: "JetBrains Mono", Consolas, monospace; font-size: 0.9em;
       background: rgba(255,255,255,0.05); padding: 1px 5px; border-radius: 3px; }

/* NAV */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 1.3em; }
.brand strong { font-size: 1.05em; }
.brand .ver { color: var(--muted); font-size: 0.8em; margin-left: 4px; }
.counts { display: flex; gap: 10px; flex: 1; justify-content: center; }
.badge {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85em;
}
.badge.green { border-color: var(--green); }
.nav nav a { color: var(--text); font-size: 0.9em; }

/* LAYOUT: 3 columns */
.dash-layout {
  display: grid;
  grid-template-columns: 260px 1fr 360px;
  height: calc(100vh - 50px);
  min-height: 0;
}
.side, .detail {
  background: var(--panel);
  overflow-y: auto;
  padding: 14px;
}
.side { border-right: 1px solid var(--line); }
.detail { border-left: 1px solid var(--line); }
.map-wrap { position: relative; min-width: 0; }
#map { width: 100%; height: 100%; background: #0a1929; }

/* DISTRICT LIST */
.side h2 { font-size: 1.05em; margin: 0 0 6px; }
.side h3 { font-size: 0.8em; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.hint { color: var(--muted); font-size: 0.82em; margin: 0 0 8px; }
.district-list { list-style: none; padding: 0; margin: 0; }
.district-list li {
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.92em;
}
.district-list li:hover { background: var(--panel-2); }
.district-list li.active { background: var(--panel-2); border-color: var(--accent); }
.district-list li.loading { color: var(--muted); }
.zone-tag { font-size: 0.7em; padding: 2px 6px; border-radius: 4px; background: #2a3a55; color: #b9d2ff; margin-left: 6px; }
.zone-tag.FAR { background: #4a2a55; color: #e3b9ff; }
.district-list .n { color: var(--muted); font-size: 0.8em; }

/* LEGEND */
.legend div { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 0.85em; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.green  { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.grey   { background: var(--grey); }

/* DETAIL PANEL */
.empty { color: var(--muted); padding: 20px 4px; text-align: center; }
.empty h2 { font-size: 1.05em; }
.detail .head { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 12px; }
.detail .head h2 { margin: 0; font-size: 1.15em; }
.detail .sub { color: var(--muted); font-size: 0.85em; margin: 4px 0 0; }
.detail .zone-tag { display: inline-block; font-size: 0.7em; padding: 2px 8px; border-radius: 4px; background: #2a3a55; color: #b9d2ff; margin-left: 6px; }
.detail .zone-tag.FAR { background: #4a2a55; color: #e3b9ff; }
.pool-card { background: var(--panel-2); padding: 12px; border-radius: 8px; margin: 12px 0; border: 1px solid var(--line); }
.pool-card .amount { font-size: 1.5em; font-weight: 600; }
.pool-card .amount small { font-size: 0.5em; color: var(--muted); font-weight: 400; }
.progress { height: 10px; background: #2a3142; border-radius: 4px; margin: 8px 0; overflow: hidden; }
.progress > div { height: 100%; transition: width 0.3s; }
.progress.met > div { background: var(--green); }
.progress.almost > div { background: var(--yellow); }
.progress.low > div { background: var(--grey); }
.pool-status { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 0.75em; font-weight: 600; }
.pool-status.MET { background: var(--green); color: #0e1116; }
.pool-status.ACCUMULATING { background: #2a3a55; color: #b9d2ff; }
.pool-status.DISPATCHED { background: #4a2a55; color: #e3b9ff; }
.helper-list { list-style: none; padding: 0; margin: 8px 0; }
.helper-list li {
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.helper-list li .name { font-weight: 500; font-size: 0.92em; }
.helper-list li .name .star { color: var(--yellow); }
.helper-list li .meta { color: var(--muted); font-size: 0.74em; margin-top: 2px; }
.helper-list li .wallet { font-size: 0.78em; color: var(--accent); text-align: right; }
.add-customer { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-top: 14px; }
.add-customer h3 { margin: 0 0 6px; font-size: 0.85em; color: var(--muted); }
.add-customer input, .add-customer select {
  width: 100%; background: #0b0e14; border: 1px solid var(--line); color: var(--text);
  padding: 5px; margin: 3px 0; border-radius: 4px; font-size: 0.82em;
}
.add-customer button {
  background: var(--accent); border: 0; color: white; padding: 6px 12px;
  border-radius: 4px; cursor: pointer; width: 100%; margin-top: 4px; font-size: 0.85em;
}
.add-customer label { font-size: 0.78em; color: var(--muted); }
.toast { position: fixed; bottom: 16px; right: 16px; background: var(--panel-2);
  border: 1px solid var(--line); padding: 10px 14px; border-radius: 6px;
  font-size: 0.85em; display: none; z-index: 9999; max-width: 360px; }
.toast.show { display: block; }
.toast.ok    { border-color: var(--green); }
.toast.error { border-color: var(--red); }

/* Leaflet overrides */
.leaflet-container { background: #0a1929; }
.leaflet-popup-content-wrapper { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.leaflet-popup-tip { background: var(--panel-2); }
.leaflet-control-zoom a { background: var(--panel-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(14, 17, 22, 0.8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--accent-2) !important; }

@media (max-width: 980px) {
  .dash-layout { grid-template-columns: 200px 1fr 280px; }
  .counts { display: none; }
}


/* District text labels (no polygons) — dark with blue border so they stand out on light OSM tiles */
.dt-label-clean {
  background: transparent !important;
  border: 0 !important;
  pointer-events: none;
}
.dt-label-clean span {
  display: inline-block;
  background: rgba(20, 24, 35, 0.88);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1.5px solid rgba(77, 171, 247, 0.9);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  white-space: nowrap;
}


/* District -> block list */
.block-list { list-style: none; padding: 0; margin: 0; }
.block-list li {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  cursor: pointer; border-radius: 4px;
}
.block-list li:hover { background: var(--panel-2); }
.block-list .name { font-weight: 500; font-size: 0.92em; }
.block-list .addr { color: var(--muted); font-size: 0.78em; margin-top: 2px; }
.block-list .meta { font-size: 0.78em; color: var(--muted); text-align: right; }


/* Buildings search */
.search-row {
  display: flex; gap: 6px; margin-bottom: 4px;
}
.search-row input {
  flex: 1; background: #0b0e14; border: 1px solid var(--line);
  color: var(--text); padding: 8px 10px; border-radius: 6px;
  font-size: 0.85em;
}
.search-row input:focus { outline: none; border-color: var(--accent); }
.search-row button {
  background: var(--accent); color: white; border: 0; padding: 0 12px;
  border-radius: 6px; cursor: pointer; font-size: 0.9em;
}

.building-list { list-style: none; padding: 0; margin: 0; }
.building-list li {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 4px;
}
.building-list li:hover { background: var(--panel-2); }
.building-list .name { font-weight: 500; font-size: 0.92em; }
.building-list .addr { color: var(--muted); font-size: 0.78em; margin-top: 2px; }
.building-list .kind {
  display: inline-block; font-size: 0.7em; padding: 1px 6px;
  background: #2a3a55; color: #b9d2ff; border-radius: 3px;
  margin-top: 3px;
}
