:root {
  color-scheme: light;
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --primary-active: #0958d9;
  --success: #52c41a;
  --warning: #faad14;
  --error: #ff4d4f;
  --info-bg: #e6f4ff;
  --success-bg: #f6ffed;
  --warning-bg: #fffbe6;
  --error-bg: #fff2f0;
  --text: #262626;
  --text-secondary: #595959;
  --text-tertiary: #8c8c8c;
  --line: #d9d9d9;
  --line-soft: #f0f0f0;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --page: #f5f5f5;
  --shadow-card: 0 1px 2px rgb(0 0 0 / 4%), 0 6px 16px rgb(0 0 0 / 6%);
  --shadow-hover: 0 6px 16px rgb(0 0 0 / 8%);
  --radius: 8px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgb(22 119 255 / 7%), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, var(--page) 18%, var(--page) 100%);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgb(22 119 255 / 20%);
}

hr {
  border: 0;
  border-top: 1px solid var(--line-soft);
  margin: 20px 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgb(255 255 255 / 88%);
  border-bottom: 1px solid rgb(240 240 240 / 92%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 3%);
}

.topbar-inner,
.content {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  padding: 16px 0;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0;
}

.brand p {
  max-width: 560px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgb(250 250 250 / 92%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%);
}

.nav-button {
  min-height: 36px;
  padding: 0 16px;
  border-color: transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
}

.nav-button:hover {
  background: rgb(22 119 255 / 8%);
  color: var(--primary);
}

.nav-button.active {
  border-color: #91caff;
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgb(0 0 0 / 6%);
}

.primary-button {
  padding: 0 16px;
  border-color: var(--primary);
  background: var(--primary);
  color: var(--surface);
  font-weight: 600;
}

.primary-button:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  color: var(--surface);
}

.primary-button:active {
  border-color: var(--primary-active);
  background: var(--primary-active);
}

.secondary-button {
  padding: 0 16px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

.secondary-button:hover {
  border-color: #91caff;
  color: var(--primary);
}

.link-button {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.link-button:hover {
  color: var(--primary-hover);
  text-decoration: underline;
  transform: none;
}

.content {
  padding: 28px 0 56px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric,
.panel,
.school-card,
.result-card {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.metric {
  padding: 18px 20px 16px;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-soft) 100%);
}

.metric-value {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 700;
}

.metric-label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
}

.panel {
  margin-bottom: 16px;
  padding: 24px;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  color: var(--text);
  letter-spacing: 0;
}

.panel h2 {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
}

.panel h3 {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
}

.muted,
.helper {
  color: var(--text-secondary);
}

.helper {
  font-size: 13px;
  line-height: 1.6;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.explorer-search {
  display: grid;
  gap: 16px;
}

.search-section {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 16px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-heading h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.section-heading .helper {
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label,
.field-label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: #434343;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 2%);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.field select {
  appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, #8c8c8c 50%),
    linear-gradient(135deg, #8c8c8c 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.field select[multiple] {
  min-height: 104px;
  padding: 8px;
  background-image: none;
}

.field select[multiple] option {
  border-radius: 6px;
  padding: 6px 8px;
}

.field input::placeholder {
  color: #bfbfbf;
}

.field-help {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.field input:hover,
.field select:hover {
  border-color: #91caff;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
}

.multi-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.checkbox-pill:has(input:checked) {
  border-color: #91caff;
  background: var(--info-bg);
  color: var(--primary-active);
}

.checkbox-pill input {
  width: auto;
  min-height: auto;
  margin: 0;
  accent-color: var(--primary);
  box-shadow: none;
}

.checkbox-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 14px;
}

.checkbox-row label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.checkbox-row input {
  accent-color: var(--primary);
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid #91caff;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--primary-active);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

.toolbar {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.school-list,
.results-list {
  display: grid;
  gap: 12px;
}

.pagination-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pagination-bar .helper {
  margin: 0;
}

.pagination-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pagination-controls label,
.page-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.pagination-controls select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 28px 0 10px;
  color: var(--text);
  font: inherit;
}

.compact-button {
  min-height: 36px;
}

.school-card,
.result-card {
  padding: 18px 20px;
}

.school-card:hover,
.result-card:hover {
  box-shadow: var(--shadow-hover);
}

.school-card-summary,
.result-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
}

.school-card h3,
.result-card h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.3;
}

.school-card p,
.result-card p {
  margin: 0 0 8px;
}

.result-card ul {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--text-secondary);
}

.result-card li + li {
  margin-top: 6px;
}

.result-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.profile-button {
  min-width: 88px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.chip.official {
  border-color: #91caff;
  background: var(--info-bg);
  color: var(--primary-active);
}

.band {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.band.high {
  border-color: #b7eb8f;
  background: var(--success-bg);
  color: #389e0d;
}

.band.medium {
  border-color: #91caff;
  background: var(--info-bg);
  color: var(--primary-active);
}

.band.low {
  border-color: #ffe58f;
  background: var(--warning-bg);
  color: #d48806;
}

.band.very-low {
  border-color: #ffccc7;
  background: var(--error-bg);
  color: #cf1322;
}

.school-card:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(22 119 255 / 18%), var(--shadow-card);
}

.school-card.expanded {
  border-color: #91caff;
}

.school-profile-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
}

.fact-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.fact-list-spaced {
  margin-top: 16px;
}

.fact {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px 14px;
}

.fact span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.fact strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.tile-map {
  position: relative;
  width: 100%;
  min-height: 300px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #edf3fb;
}

.tile-map img {
  position: absolute;
  width: 256px;
  height: 256px;
}

.map-marker {
  position: absolute;
  min-width: 18px;
  min-height: 18px;
  border-radius: 999px 999px 999px 0;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--surface), 0 4px 10px rgb(0 0 0 / 20%);
  transform: translate(-50%, -100%);
  rotate: -45deg;
}

.map-marker.home {
  background: var(--success);
}

.map-marker.property {
  background: var(--warning);
}

.map-marker.property span {
  top: -7px;
  left: 18px;
  min-width: 18px;
  color: #874d00;
}

.map-marker.home span {
  top: -15px;
  left: -58px;
  min-width: 54px;
  text-align: right;
}

.map-marker span {
  position: absolute;
  top: -5px;
  left: 20px;
  min-width: 120px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 0 var(--surface);
  rotate: 45deg;
}

.map-link {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 92%);
  padding: 7px 10px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.source-list {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.source-list a {
  font-weight: 500;
}

.phase-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.table-scroll::-webkit-scrollbar {
  height: 10px;
}

.table-scroll::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #d9d9d9;
  background-clip: padding-box;
}

.table-scroll .phase-table {
  min-width: 980px;
}

.phase-table th,
.phase-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

.phase-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.phase-table tbody td {
  color: #434343;
}

.phase-table tbody tr:hover td {
  background: #fcfcfc;
}

.history-section {
  margin-top: 24px;
}

.history-section h3 {
  margin-top: 0;
}

.history-table td {
  font-size: 13px;
}

.property-table td {
  font-size: 13px;
}

.history-unavailable td {
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.notice {
  border: 1px solid #91caff;
  background: var(--info-bg);
  color: var(--primary-active);
  box-shadow: none;
  padding: 12px 16px;
}

.empty {
  padding: 32px;
  border-style: dashed;
  color: var(--text-secondary);
  text-align: center;
}

.loading {
  padding: 48px;
  color: var(--text-secondary);
}

@media (max-width: 1100px) {
  .topbar-inner {
    grid-template-columns: 1fr;
  }

  .nav {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .topbar-inner,
  .grid.two,
  .grid.three,
  .form-grid,
  .form-grid.two-col,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .form-actions,
  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-controls {
    justify-content: stretch;
  }

  .pagination-controls select,
  .pagination-controls button {
    flex: 1 1 120px;
  }

  .school-card-summary,
  .result-card {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 20px;
  }

  .nav-button {
    flex: 1 1 calc(50% - 4px);
  }

  .result-aside {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .content,
  .topbar-inner {
    width: min(100% - 24px, 1180px);
  }

  .status-strip,
  .fact-list {
    grid-template-columns: 1fr;
  }

  .brand h1 {
    font-size: 24px;
  }

  .panel h2 {
    font-size: 24px;
  }

  .panel h3 {
    font-size: 18px;
  }
}
