:root {
  --c-primary: #1e3a5f;
  --c-primary-2: #2c5282;
  --c-accent: #0ea5a4;
  --c-bg: #eef2f7;
  --c-card: #ffffff;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-border: #e2e8f0;
  --c-shadow: 0 6px 20px rgba(30, 58, 95, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-2) 60%, #3b6ea5 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(30, 58, 95, 0.25);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 20px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; backdrop-filter: blur(4px);
}
.brand-text h1 { margin: 0; font-size: 22px; letter-spacing: 1px; }
.brand-text p { margin: 4px 0 0; font-size: 13px; opacity: 0.85; }
.stat {
  background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px; border-radius: 999px; font-size: 14px; white-space: nowrap;
}

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 22px; }

/* Toolbar */
.toolbar {
  background: var(--c-card); border-radius: var(--radius);
  box-shadow: var(--c-shadow); padding: 18px; margin-bottom: 20px;
}
.toolbar-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.toolbar-row + .toolbar-row { margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 240px; }
.field label { font-size: 13px; color: var(--c-muted); font-weight: 600; }

input[type="text"] {
  height: 42px; padding: 0 14px; border: 1.5px solid var(--c-border); border-radius: 10px;
  font-size: 15px; color: var(--c-text); background: #fff;
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
input[type="text"]:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px rgba(14, 165, 164, 0.15); }

/* 镇街选择 */
.town-field { position: relative; }
.town-trigger {
  height: 42px; padding: 0 14px; min-width: 170px; text-align: left;
  border: 1.5px solid var(--c-border); border-radius: 10px; background: #fff;
  font-size: 15px; color: var(--c-text); cursor: pointer; transition: border-color .15s;
}
.town-trigger:hover { border-color: var(--c-accent); }
.town-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 40;
  background: #fff; border: 1px solid var(--c-border); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18); padding: 12px; width: min(560px, 94vw);
}
.town-panel-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--c-muted); padding: 0 2px 8px; }
.link-btn { border: none; background: none; color: var(--c-accent); font-size: 13px; cursor: pointer; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }
.town-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px; max-height: 320px; overflow-y: auto; padding-top: 4px;
}
.town-opt {
  border: 1.5px solid var(--c-border); background: #fff; border-radius: 9px;
  padding: 9px 6px; font-size: 13px; cursor: pointer; text-align: center; transition: all .12s;
}
.town-opt:hover { border-color: var(--c-accent); }
.town-opt.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 600; }

/* 学段 toggle */
.seg-group { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-btn {
  height: 42px; padding: 0 18px; border: 1.5px solid var(--c-border); background: #fff;
  border-radius: 10px; font-size: 15px; color: var(--c-text); cursor: pointer; transition: all .15s;
}
.seg-btn:hover { border-color: var(--c-accent); }
.seg-btn.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 600; }
.reset-btn {
  height: 42px; padding: 0 18px; border: none; background: #f1f5f9; color: var(--c-muted);
  border-radius: 10px; font-size: 14px; cursor: pointer; transition: background .15s, color .15s;
}
.reset-btn:hover { background: #e2e8f0; color: var(--c-text); }

/* View title */
.view-title { font-size: 17px; font-weight: 700; color: var(--c-primary); margin: 0 2px 14px; }
.view-title .muted { font-size: 13px; font-weight: 400; color: var(--c-muted); }

/* 镇街卡片 */
.town-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.town-card {
  border-radius: 16px; padding: 18px; color: #fff; cursor: pointer; min-height: 132px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.14); transition: transform .15s, box-shadow .15s;
  position: relative; overflow: hidden; text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
.town-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(15, 23, 42, 0.22); }
.town-card .tname { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.town-card .tcounts { display: flex; gap: 14px; font-size: 13px; opacity: 0.96; margin-top: 8px; }
.town-card .tcounts b { font-size: 18px; font-weight: 700; margin-right: 3px; }
.town-card .ttotal { font-size: 12px; opacity: 0.9; margin-top: 6px; }

/* Result bar */
.result-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 2px 14px; }
#resultCount { font-weight: 700; color: var(--c-primary); font-size: 15px; }
.active-filter { color: var(--c-accent); font-size: 14px; }
.back-btn {
  margin-left: auto; border: 1.5px solid var(--c-border); background: #fff; color: var(--c-primary);
  border-radius: 10px; padding: 8px 14px; font-size: 14px; cursor: pointer; transition: all .15s;
}
.back-btn:hover { border-color: var(--c-accent); color: var(--c-accent); }

/* 学校卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 16px 18px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 10px;
}
/* 办学性质底色区分 */
.card--public { background: #f4f9ff; border-color: #cfe3fb; border-left: 4px solid #2c5282; }
.card--private { background: #fffaf0; border-color: #f6e0c0; border-left: 4px solid #e08e0b; }
.card:hover { transform: translateY(-3px); box-shadow: var(--c-shadow); border-color: var(--c-accent); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-name { font-size: 16px; font-weight: 600; line-height: 1.4; color: var(--c-primary); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-town { background: #e0f2f1; color: #00796b; }
.badge-seg { background: #e8eaf6; color: #303f9f; }
.badge-prop-public { background: #dbeafe; color: #1d4ed8; font-weight: 600; }
.badge-prop-private { background: #fde68a; color: #b45309; font-weight: 600; }
.card-addr { font-size: 12.5px; color: var(--c-muted); line-height: 1.5; }

.empty-tip { text-align: center; color: var(--c-muted); padding: 40px 0; }

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 60;
}
.modal-mask.show { display: flex; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 18px; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto;
  padding: 26px 26px 30px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-close {
  position: absolute; top: 14px; right: 16px; width: 34px; height: 34px; border: none; border-radius: 50%;
  background: #f1f5f9; color: var(--c-muted); font-size: 22px; line-height: 1; cursor: pointer; transition: background .15s;
}
.modal-close:hover { background: #e2e8f0; }
.modal-title { margin: 0 36px 12px 0; font-size: 20px; color: var(--c-primary); line-height: 1.4; }
.modal-badges { margin-bottom: 16px; }
.modal-info { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.modal-info > div { display: flex; flex-direction: column; gap: 4px; }
.modal-info .full { grid-column: 1 / -1; }
.modal-info dt { font-size: 12px; color: var(--c-muted); font-weight: 600; }
.modal-info dd { margin: 0; font-size: 15px; color: var(--c-text); line-height: 1.5; word-break: break-word; }

/* Footer */
.site-footer { text-align: center; color: var(--c-muted); font-size: 13px; padding: 24px 16px 32px; }

/* Responsive */
@media (max-width: 640px) {
  .header-inner { padding: 16px; }
  .brand-text h1 { font-size: 18px; }
  .container { padding: 14px; }
  .toolbar-row { gap: 12px; }
  .field.grow { flex: 1 1 100%; }
  .town-trigger { width: 100%; }
  .town-field { flex: 1 1 100%; }
  .reset-btn { width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .town-cards { grid-template-columns: 1fr 1fr; }
  .modal-info { grid-template-columns: 1fr; }
  .stat { font-size: 13px; padding: 6px 12px; }
}
