:root {
  --bg: #0f1419;
  --bg-soft: #161d25;
  --bg-card: #1b242e;
  --line: #263140;
  --text: #e8eef5;
  --muted: #8b9aab;
  --accent: #25d07a;
  --accent-dim: rgba(37, 208, 122, .14);
  --warn: #ff9f43;
  --danger: #ff5c5c;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.bolt {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
}
.brand h1 { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.brand p { font-size: 12px; color: var(--muted); }

.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.source-hint { padding: 0 10px; font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); user-select: none; }
.range { display: flex; flex-direction: column; gap: 2px; }
.range label { font-size: 11px; color: var(--muted); }
.range b { color: var(--accent); font-weight: 600; }
.range input { width: 120px; accent-color: var(--accent); }

select, .btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06281a; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 主体 ---------- */
main { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 350px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.list-head { border-bottom: 1px solid var(--line); }
.muted { color: var(--muted); font-weight: 400; }

.switch { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; cursor: pointer; }
.switch input { accent-color: var(--accent); }
.switch.auto { color: var(--muted); padding: 0 4px; user-select: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 96px; overflow-y: auto; }
.chip {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.list { flex: 1; overflow-y: auto; padding: 8px; }

.card {
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: .15s;
}
.card:hover { border-color: var(--line); transform: translateX(2px); }
.card.active { border-color: var(--accent); background: #1f2b36; }
.card .title { display: flex; align-items: flex-start; gap: 8px; }
.card .name { font-size: 14px; font-weight: 600; flex: 1; line-height: 1.35; }
.card .addr { margin-top: 4px; font-size: 12px; color: var(--muted); }
.card .meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.card .tags { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.card .price { color: var(--accent); font-weight: 600; font-size: 13px; }
.card .price small { color: var(--muted); font-weight: 400; }
.badge {
  padding: 2px 8px; font-size: 11px; border-radius: 6px;
  background: var(--bg-soft); color: var(--muted);
}
.badge.free { background: var(--accent-dim); color: var(--accent); }
.badge.busy { background: rgba(255, 92, 92, .14); color: var(--danger); }
.badge.fast { background: rgba(255, 159, 67, .14); color: var(--warn); }
.badge.slow { background: rgba(96, 165, 250, .14); color: #60a5fa; }
.badge.brand { background: rgba(96, 165, 250, .14); color: #60a5fa; }
.badge.src { background: rgba(255, 159, 67, .16); color: var(--warn); }
.pop-link { display: inline-block; margin-top: 8px; color: var(--accent); font-size: 12px; text-decoration: none; }
.pop-link:hover { text-decoration: underline; }

#map { flex: 1; background: #0b1016; }

/* ---------- 地图标记 ---------- */
.pin {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  font-size: 11px; font-weight: 700;
  color: #06281a;
  background: var(--accent);
  border: 2px solid #0f1419;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.pin span { transform: rotate(45deg); }
.pin.zero { background: #5d6b7a; color: #cfd8e3; }
.pin.active { background: #fff; color: #06281a; transform: rotate(-45deg) scale(1.25); }

.leaflet-popup-content-wrapper {
  background: var(--bg-card); color: var(--text); border-radius: var(--radius);
}
.leaflet-popup-tip { background: var(--bg-card); }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }
.pop h3 { font-size: 14px; margin-bottom: 4px; }
.pop p { font-size: 12px; color: var(--muted); }
.pop .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution { background: rgba(15, 20, 25, .8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

/* ---------- 状态 ---------- */
.loading {
  position: fixed; inset: 0;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(15, 20, 25, .72); z-index: 999;
  color: var(--muted); font-size: 13px;
}
.loading.show { display: flex; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translate(-50%, 20px);
  padding: 10px 18px; border-radius: 8px;
  background: var(--bg-card); border: 1px solid var(--line);
  font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 1000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  main { flex-direction: column-reverse; }
  .sidebar { width: 100%; height: 45%; border-right: none; border-top: 1px solid var(--line); }
}
