:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #16202f;
  --muted: #6b7787;
  --line: #e3e8ef;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --orange: #c2410c;
  --orange-soft: #ffedd5;
  --purple: #6d28d9;
  --purple-soft: #ede9fe;
  --amber: #b45309;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --header-h: 74px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff; font-size: 20px; font-weight: 800;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.28);
  flex: 0 0 auto;
}

.brand-text h1 { margin: 0; font-size: 18px; letter-spacing: 0.2px; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

.year-badge {
  font-size: 12px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); border-radius: 999px; padding: 4px 10px;
}

.ghost-link {
  font-size: 12px; color: var(--muted); text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  transition: all 0.15s ease;
}
.ghost-link:hover { color: var(--primary); border-color: #bfdbfe; background: #f8fbff; }

/* ---------- layout ---------- */
.layout {
  flex: 1 1 auto;
  height: calc(100vh - var(--header-h));
  min-height: 0;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: stretch;
  overflow: hidden;
}

.sidebar, .map-card, .detail {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ---------- search ---------- */
.search-wrap {
  position: relative;
  padding: 14px 14px 8px;
}

.search-wrap input {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 0 38px 0 13px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: all 0.15s ease;
}
.search-wrap input:focus {
  border-color: #93c5fd;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}
.search-wrap kbd {
  position: absolute; right: 26px; top: 26px;
  font-size: 11px; color: #94a3b8; border: 1px solid var(--line);
  background: #fff; border-radius: 6px; padding: 1px 6px;
}

/* ---------- chips ---------- */
.chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 14px 10px;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.chip:hover { border-color: #cbd5e1; color: var(--ink); }
.chip.active {
  background: var(--ink); border-color: var(--ink); color: #fff;
}
.chip span { opacity: 0.65; margin-left: 2px; }

/* ---------- list ---------- */
.list-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 2px 16px 8px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.4px;
}
.list-head .muted { font-weight: 500; letter-spacing: 0; }

.school-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 10px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.school-list::-webkit-scrollbar { width: 7px; }
.school-list::-webkit-scrollbar-thumb { background: #d7dee8; border-radius: 99px; }

.school-item {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 11px;
  cursor: pointer;
  transition: all 0.14s ease;
  margin-bottom: 4px;
}
.school-item:hover { background: #f8fafc; border-color: var(--line); }
.school-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  box-shadow: inset 3px 0 0 var(--primary);
}
.school-item.dim { opacity: 0.35; }

.school-item .row1 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.school-item .name {
  font-size: 13.5px; font-weight: 700; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.school-item .meta {
  margin-top: 4px; font-size: 11.5px; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.school-item .zone-snip {
  margin-top: 5px; font-size: 11.5px; color: #7c8798;
  line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  font-size: 10.5px; font-weight: 700; border-radius: 999px;
  padding: 2px 7px; white-space: nowrap;
}
.badge.primary { color: #1d4ed8; background: var(--primary-soft); }
.badge.nine { color: var(--teal); background: var(--teal-soft); }
.badge.private { color: var(--orange); background: var(--orange-soft); }
.badge.pending { color: var(--purple); background: var(--purple-soft); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 10px 14px 12px;
  font-size: 11px; color: #8a95a5; line-height: 1.55;
  flex: 0 0 auto;
}
.sidebar-foot p { margin: 0 0 4px; }
.sidebar-foot p:last-child { margin: 0; }

/* ---------- map ---------- */
.map-card {
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.map-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mode-switch {
  display: inline-flex; background: #f1f5f9; border-radius: 10px; padding: 3px; gap: 2px;
}
.mode-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 700; padding: 6px 10px;
  border-radius: 8px; cursor: pointer; font-family: inherit;
  transition: all 0.15s ease;
}
.mode-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }

.legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot.primary { background: #60a5fa; }
.dot.nine { background: #2dd4bf; }
.dot.dashed { border: 1.5px dashed #94a3b8; background: transparent; }

.map-actions { display: flex; gap: 6px; }
.mini-btn {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; font-size: 11.5px; padding: 5px 9px; cursor: pointer;
  font-family: inherit;
}
.mini-btn:hover { color: var(--ink); border-color: #cbd5e1; }

.map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 8px 0;
  overflow: hidden;
}
#map {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: block;
}

/* ---------- real map ---------- */
.real-map {
  position: absolute;
  inset: 8px 8px 0;
  z-index: 1;
  border-radius: 12px;
  overflow: hidden;
}
.map-wrap.mode-real #map { display: none; }
.map-wrap.mode-real .north { display: none; }
.map-wrap.mode-real .real-map { display: block; }

.real-map .leaflet-container { background: #eef2f7; }
.real-map .leaflet-control-attribution { font-size: 9px; background: rgba(255,255,255,0.75); }
.real-map .leaflet-control-zoom a { border-radius: 6px; }
.qz-tip {
  background: #0f172a; color: #fff; border: 0; box-shadow: none;
  font-size: 11px; padding: 3px 7px; border-radius: 6px;
}
.qz-tip::before { border-top-color: #0f172a; }
.qz-compound {
  background: rgba(255, 251, 235, 0.94);
  color: #92400e;
  border: 1px solid #fcd34d;
  box-shadow: none;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
}
.qz-compound::before { display: none; }

/* SVG block styles */
.blk {
  cursor: pointer;
  transition: opacity 0.15s ease, filter 0.15s ease;
}
.blk.primary { fill: #93c5fd; stroke: #3b82f6; }
.blk.nine { fill: #5eead4; stroke: #0d9488; }
.blk.dashed { stroke-dasharray: 6 5; }
.blk.behind { opacity: 0.22; }
.blk:not(.behind) { opacity: 0.62; }
.blk:hover { opacity: 0.9; filter: url(#soft-shadow); }
.blk.active {
  opacity: 0.95;
  stroke: #0f172a;
  stroke-width: 2.6;
  filter: url(#soft-shadow);
}
.blk.dim { opacity: 0.12 !important; }
.blk.hit { stroke: #f59e0b; stroke-width: 3; opacity: 0.9; }

.blk-label {
  font-size: 12.5px;
  font-weight: 700;
  fill: #0f2a4a;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(255,255,255,0.75);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.blk-label.small { font-size: 11px; }
.blk-label.vertical { writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 1px; }

.road-line { stroke: #c9d4e2; stroke-width: 2; }
.road-line.major { stroke: #a9b8ca; stroke-width: 3; }
.road-label {
  font-size: 10px; fill: #9aa7b8; font-weight: 600;
  paint-order: stroke; stroke: #fbfcfe; stroke-width: 3px;
}
.road-label.v { writing-mode: vertical-rl; text-orientation: mixed; }
.river { stroke: #93c5fd; stroke-width: 7; opacity: 0.55; stroke-linecap: round; }
.river-label { font-size: 10px; fill: #60a5fa; font-weight: 700; }

.north {
  position: absolute; top: 14px; right: 14px;
  display: flex; flex-direction: column; align-items: center;
  color: #94a3b8; font-size: 10px; font-weight: 800;
}
.north svg { width: 16px; height: 26px; margin-top: 2px; }

.map-disclaimer {
  position: absolute; left: 14px; bottom: 10px; right: 14px;
  font-size: 10.5px; color: #94a3b8; text-align: center;
  pointer-events: none;
}

/* ---------- detail ---------- */
.detail {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 22px;
  scrollbar-width: thin;
}
.detail::-webkit-scrollbar { width: 7px; }
.detail::-webkit-scrollbar-thumb { background: #d7dee8; border-radius: 99px; }

.detail-empty { padding: 26px 6px; }
.empty-icon {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  background: #f1f5f9; color: #64748b; font-size: 22px;
  margin-bottom: 14px;
}
.detail-empty h2 { margin: 0 0 6px; font-size: 17px; }
.detail-empty p { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.65; }
.detail-empty ul { margin: 0; padding-left: 18px; font-size: 12px; color: #7c8798; line-height: 1.9; }

.detail-body .eyebrow {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.detail-body h2 { margin: 0 0 4px; font-size: 19px; line-height: 1.35; }
.detail-body .sub { margin: 0 0 14px; font-size: 12px; color: var(--muted); }

.stat-row {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px; margin: 14px 0;
}
.stat {
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { margin-top: 3px; font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.stat .v small { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.stat .v.over { color: #b91c1c; }

.phone-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 42px; border-radius: 11px;
  background: var(--ink); color: #fff; text-decoration: none;
  font-size: 13.5px; font-weight: 700; margin: 4px 0 16px;
}
.phone-btn:hover { background: #0b1220; }
.phone-btn.disabled { background: #e2e8f0; color: #94a3b8; pointer-events: none; }

.section-title {
  font-size: 11.5px; font-weight: 800; color: #64748b;
  letter-spacing: 0.8px; text-transform: uppercase;
  margin: 18px 0 8px;
}

.zone-box {
  border-left: 3px solid #93c5fd;
  background: #f8fbff;
  border-radius: 0 10px 10px 0;
  padding: 11px 13px;
  font-size: 13px; line-height: 1.8; color: #334155;
}
.zone-box mark {
  background: #fef3c7; color: #92400e; border-radius: 3px; padding: 0 2px;
}
.note-box {
  margin-top: 10px; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 10px; padding: 10px 12px;
  font-size: 12px; line-height: 1.7; color: #92400e;
}

.link-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.link-btn {
  flex: 1 1 auto; text-align: center; text-decoration: none;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; font-size: 12px; color: var(--ink); background: #fff;
}
.link-btn:hover { border-color: #bfdbfe; background: #f8fbff; color: var(--primary); }

/* ---------- modal ---------- */
.help-modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, 0.45);
  display: grid; place-items: center;
  padding: 20px;
}
.help-modal[hidden] { display: none; }
.help-card {
  position: relative;
  width: min(760px, 100%);
  max-height: 86vh; overflow: auto;
  background: #fff; border-radius: 18px;
  padding: 26px 26px 20px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
}
.help-card h2 { margin: 0 0 16px; font-size: 20px; }
.help-card .close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 18px; color: var(--muted);
}
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.help-grid h3 { margin: 0 0 5px; font-size: 13px; }
.help-grid p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.help-foot { margin: 20px 0 0; font-size: 12px; color: #8a95a5; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 270px minmax(0, 1fr) 340px; }
}

@media (max-width: 1080px) {
  body { height: auto; overflow: auto; }
  .layout {
    height: auto;
    overflow: visible;
    grid-template-columns: 270px minmax(0, 1fr);
    grid-template-rows: auto auto;
  }
  .map-wrap { height: 62vh; min-height: 480px; }
  .detail {
    grid-column: 1 / -1;
    max-height: 420px;
  }
}

@media (max-width: 760px) {
  :root { --header-h: auto; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; height: auto; }
  .brand-text h1 { font-size: 16px; }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    padding: 10px;
  }
  .sidebar { max-height: 380px; }
  .map-wrap { height: 62vh; min-height: 420px; }
  .detail { max-height: none; }
  .help-grid { grid-template-columns: 1fr; }
}
