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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1a1a2e;
}

/* ── Top Navigation ──────────────────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  z-index: 100;
}

.topnav-brand {
  font-size: 16px;
  font-weight: 700;
  color: #1A7ADB;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.topnav-brand span { color: #e63946; }

.topnav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.nav-link:hover { background: #f1f5f9; color: #1a1a2e; }
.nav-link.active { background: #eff6ff; color: #1A7ADB; font-weight: 600; }

.donate-btn {
  padding: 8px 18px;
  background: #ff5e14;
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 24px;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.1px;
  box-shadow: 0 2px 8px rgba(255,94,20,0.35);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.donate-btn:hover {
  background: #e64d00;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255,94,20,0.45);
}

/* ── Layout ──────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: calc(100vh - 52px);
  margin-top: 52px;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  z-index: 10;
  box-shadow: 2px 0 8px rgba(0,0,0,0.06);
}

.sidebar-header {
  padding: 16px 14px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.logo {
  font-size: 17px;
  font-weight: 700;
  color: #1A7ADB;
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}

.logo span { color: #e63946; }

.logo-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 10px;
}

.search-box { position: relative; }

.search-box input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: #f8fafc;
  color: #1a1a2e;
  transition: border-color 0.15s;
}

.search-box input:focus { border-color: #1A7ADB; background: #fff; }

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
}

/* ── Area filter ─────────────────────────────────────────────────────── */
.area-filters {
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.area-filters select {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  color: #1a1a2e;
  background: #f8fafc;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.area-filters select:focus { border-color: #1A7ADB; background-color: #fff; }

/* ── Sidebar meta bar ────────────────────────────────────────────────── */
.sidebar-meta {
  padding: 7px 14px 5px;
  font-size: 11.5px;
  color: #94a3b8;
  border-bottom: 1px solid #f1f5f9;
}

/* ── Legend ──────────────────────────────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  padding: 7px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #64748b;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-ring {
  background: transparent;
  border: 2px solid #94a3b8;
}

.legend-star {
  font-size: 16px;
  line-height: 1;
  color: #FFD700;
  -webkit-text-stroke: 0.8px #92400e;
  text-stroke: 0.8px #92400e;
  flex-shrink: 0;
}

/* ── School list ─────────────────────────────────────────────────────── */
.school-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 12px;
}

.no-results {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  padding: 28px 0;
}

/* ── School card ─────────────────────────────────────────────────────── */
.school-card {
  padding: 10px 12px;
  border-radius: 9px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.1s, border-color 0.1s;
  background: #f8fafc;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.school-card:hover { background: #eff6ff; border-color: #bfdbfe; }
.school-card.active { background: #eff6ff; border-color: #1A7ADB; }

.school-card-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.school-card-body { flex: 1; min-width: 0; }

.school-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
}

.school-name {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  color: #1a1a2e;
}

.school-meta {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}

.school-address {
  font-size: 11.5px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catchment-check {
  font-size: 12px;
  color: #16a34a;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Tags & badges ───────────────────────────────────────────────────── */
.tag {
  font-size: 10.5px;
  padding: 1.5px 7px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #475569;
  white-space: nowrap;
}

.ofsted-badge {
  font-size: 10.5px;
  padding: 1.5px 7px;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 600;
}

.ofsted-outstanding { background: #dcfce7; color: #16a34a; }
.ofsted-good { background: #dbeafe; color: #1d4ed8; }
.ofsted-requires-improvement { background: #fef9c3; color: #a16207; }
.ofsted-inadequate { background: #fee2e2; color: #dc2626; }

/* ── Official checker link (inside disclaimer) ───────────────────────── */
.official-checker-link {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: #1A7ADB;
  text-decoration: none;
  margin-bottom: 6px;
}

.official-checker-link:hover { text-decoration: underline; }

/* ── Disclaimer ──────────────────────────────────────────────────────── */
.disclaimer {
  padding: 10px 14px;
  font-size: 10.5px;
  color: #94a3b8;
  line-height: 1.6;
  border-top: 1px solid #f1f5f9;
  background: #fafafa;
}

.disclaimer-warning {
  font-size: 11px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 7px;
  padding: 7px 9px;
  margin-bottom: 8px;
  line-height: 1.55;
}

/* ── Map ─────────────────────────────────────────────────────────────── */
.map-wrapper { flex: 1; position: relative; }

#map { width: 100%; height: 100%; }

/* ── Google Maps InfoWindow overrides ────────────────────────────────── */
.gm-style .gm-style-iw-c { padding: 0 !important; border-radius: 10px !important; }
.gm-style .gm-style-iw-d { overflow: hidden !important; }

/* ── Sidebar top + tabs ───────────────────────────────────────────────── */
.sidebar-top { flex-shrink: 0; }

.sidebar-tabs {
  display: flex;
  padding: 6px 10px;
  gap: 4px;
  border-bottom: 1px solid #e2e8f0;
}

.tab-btn {
  flex: 1;
  padding: 7px 0;
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: #64748b;
  transition: background 0.12s, color 0.12s;
}

.tab-btn:hover { background: #f1f5f9; color: #1a1a2e; }
.tab-btn.active { background: #eff6ff; color: #1A7ADB; font-weight: 600; border-color: #bfdbfe; }

/* ── Tab panels ──────────────────────────────────────────────────────── */
.tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel.active { display: flex; }

/* ── Area panel ──────────────────────────────────────────────────────── */
.area-panel {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 16px;
}

.area-panel-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  padding: 48px 24px;
  line-height: 1.7;
}

.area-map-hint {
  font-size: 11px;
  color: #94a3b8;
  background: #f8fafc;
  border-radius: 7px;
  padding: 6px 10px;
  margin-bottom: 12px;
  text-align: center;
}

.area-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 12px;
}

.area-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 16px;
}

.area-stat {
  background: #f8fafc;
  border-radius: 8px;
  padding: 9px 10px;
}

.area-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.3;
}

.area-stat-label {
  font-size: 9.5px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}

.demo-section { margin-bottom: 14px; }

.demo-section-title {
  font-size: 9.5px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 7px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f1f5f9;
}

.demo-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.demo-bar-label {
  width: 88px;
  font-size: 10.5px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.demo-bar-track {
  flex: 1;
  height: 4px;
  background: #f1f5f9;
  border-radius: 2px;
  overflow: hidden;
}

.demo-bar-fill {
  height: 100%;
  border-radius: 2px;
}

.demo-bar-pct {
  width: 36px;
  font-size: 10.5px;
  color: #94a3b8;
  text-align: right;
  flex-shrink: 0;
}

.area-source {
  font-size: 10px;
  color: #cbd5e1;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
  margin-bottom: 4px;
}

/* ── IoD crime bar ───────────────────────────────────────────────────── */
.iod-bar-wrap { margin-bottom: 5px; }

.iod-bar-track {
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 3px;
}

.iod-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.iod-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: #94a3b8;
  margin-bottom: 5px;
}

.iod-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #64748b;
  flex-wrap: wrap;
  gap: 4px;
}

/* ── Mobile handle & toggle (unused — kept for compatibility) ────────── */
.mob-handle { display: none; }
.mob-toggle { display: none; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Nav compact */
  .topnav { padding: 0 12px; gap: 8px; }
  .topnav-brand { font-size: 14px; }
  .nav-link { padding: 5px 9px; font-size: 13px; }
  .donate-btn { padding: 7px 13px; font-size: 12.5px; }

  /* Layout: just a positioning context */
  .layout {
    position: relative;
    height: calc(100vh - 52px);
    overflow: hidden;
  }

  /* Sidebar-top strip: fixed just below the nav */
  .sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    z-index: 20;
    background: #fff;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
    overflow: visible;
    transition: none;
  }

  /* Hide everything inside sidebar except sidebar-top */
  .mob-handle     { display: none; }
  .sidebar-header { display: none; }
  .sidebar-meta   { display: none; }
  .legend         { display: none; }
  .school-list    { display: none; }
  .disclaimer     { display: none; }

  /* Schools tab panel: nothing to show on mobile */
  #tab-schools { display: none !important; }

  /* sidebar-top: area select and tabs side-by-side in one row */
  .sidebar-top {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
  }

  .area-filters {
    flex: 1;
    padding: 0;
    border-bottom: none;
  }

  .area-filters select {
    font-size: 12.5px;
    padding: 6px 8px;
    padding-right: 24px;
  }

  .sidebar-tabs {
    padding: 0;
    border-bottom: none;
    gap: 3px;
    flex-shrink: 0;
  }

  .tab-btn {
    flex: unset;
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Map: fixed, fills space below the fixed strip (52px nav + 48px strip) */
  .map-wrapper {
    position: fixed;
    top: 100px;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
  }

  /* Area Info tab: hide map, show scrollable area panel below the fixed strip */
  .layout[data-active-tab="area"] .map-wrapper {
    display: none;
  }

  #tab-area.active {
    position: fixed;
    top: 100px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    background: #fff;
    padding: 12px;
    box-sizing: border-box;
  }

  #tab-area.active .area-panel {
    overflow-y: visible;
  }
}

/* Very narrow screens: hide "Donate" text, keep emoji */
@media (max-width: 380px) {
  .donate-text { display: none; }
  .donate-btn { padding: 7px 10px; }
}
