:root {
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  background-color: #f5f7fb;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --muted: #64748b;
  --primary: #3058ff;
  --primary-light: #e0e7ff;
  --accent: #ff8b5d;
  --shadow-sm: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 50px rgba(15, 23, 42, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: #0f172a;
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: inherit;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  padding: 1.75rem 5vw 1.5rem;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.brand h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0.25rem 0;
}

.brand__tag {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand__desc {
  color: var(--muted);
  max-width: 520px;
}

.stage-tabs {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 0.4rem;
  gap: 0.4rem;
  justify-self: center;
}

.stage-tabs button {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 0.5rem 1.5rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.stage-tabs button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.ghost-button {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 0.55rem 1.25rem;
  font-weight: 500;
  cursor: pointer;
  justify-self: end;
}

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

.main-layout {
  display: grid;
  grid-template-columns: minmax(320px, 2fr) minmax(280px, 1fr);
  gap: 2rem;
  padding: 2rem 5vw 3rem;
}

.map-panel,
.info-panel {
  width: 100%;
}

.panel-card {
  background: var(--surface);
  border-radius: 28px;
  padding: 1.75rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel-card__toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: end;
}

.panel-card__toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.panel-card__toolbar input,
.panel-card__toolbar select {
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 0.55rem 0.85rem;
  font-size: 0.95rem;
}

.toolbar-stats {
  background: #eef2ff;
  border-radius: 18px;
  padding: 0.6rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 0.15rem;
}

.toolbar-stats__value {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--primary);
}

.map-grid {
  width: 100%;
  min-height: 480px;
  background: radial-gradient(circle at top, #eef2ff, #e2e8f0 60%, #dbe3f8);
  border-radius: 28px;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  grid-auto-rows: 140px;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.map-grid::after {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px dashed rgba(99, 102, 241, 0.2);
  border-radius: 24px;
  pointer-events: none;
}

.map-zone {
  position: relative;
  border: none;
  border-radius: 24px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  color: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(15, 23, 42, 0.15));
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
}

.map-zone strong {
  font-size: 1.05rem;
}

.map-zone span {
  font-size: 0.85rem;
  opacity: 0.85;
}

.map-zone .zone-communities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.map-zone .zone-communities span {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.75rem;
}

.map-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--zone-color, #3058ff), rgba(255, 255, 255, 0));
  opacity: 0.88;
}

.map-zone > * {
  position: relative;
  z-index: 1;
}

.map-zone.active,
.map-zone:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
  outline: 3px solid rgba(255, 255, 255, 0.85);
}

.panel-card__hint {
  font-size: 0.9rem;
  color: var(--muted);
}

.empty-state {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.info-card {
  background: var(--surface);
  border-radius: 28px;
  padding: 1.75rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 480px;
}

.info-card__header h2 {
  font-size: 1.6rem;
  margin: 0.4rem 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.info-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  border: 1px dashed var(--border);
  border-radius: 20px;
  padding: 1rem;
}

.info-meta dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.info-meta dd {
  font-weight: 600;
}

.list-block {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  color: var(--muted);
}

.pill-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill-list li {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
}

.pill-list li small {
  color: var(--muted);
  margin-left: 0.5rem;
  font-size: 0.8rem;
}

.school-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.school-list li {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.school-list li strong {
  font-size: 1rem;
}

.school-list li span {
  font-size: 0.85rem;
  color: var(--muted);
}

.school-list li small {
  font-size: 0.8rem;
  color: #475569;
}

.admin-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  box-shadow: inset 0 10px 25px rgba(15, 23, 42, 0.05);
}

.admin-bar {
  padding: 2rem 5vw 1.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-content {
  padding: 1.5rem 5vw 3rem;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 2rem;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #f8fafc;
}

.admin-form label {
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
  border-radius: 12px;
  border: 1px solid #cbd5f5;
  padding: 0.55rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.primary-btn {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.5rem;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.admin-table-wrapper {
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow-x: auto;
}

#zoneTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

#zoneTable thead {
  background: #f1f5f9;
}

#zoneTable th,
#zoneTable td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.95rem;
}

#zoneTable tbody tr:hover {
  background: #f8fafc;
}

.table-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.4rem;
}

.table-btn {
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  margin-right: 0.35rem;
}

.table-btn.edit {
  background: #e0f2fe;
  color: #0369a1;
}

.table-btn.danger {
  background: #fee2e2;
  color: #b91c1c;
}

.admin-panel.collapsed #adminContent {
  display: none;
}

@media (max-width: 1080px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .info-card {
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .app-header {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .stage-tabs {
    justify-self: start;
  }

  .ghost-button {
    justify-self: start;
  }

  .panel-card__toolbar {
    grid-template-columns: 1fr;
  }

  .admin-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .map-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    grid-auto-rows: 160px;
  }
}
