





:root{
  --brand:#0a3d62; --bg:#f8f9fb; --card:#fff; --text:#111827; --muted:#6b7280;
  --map-h:560px; /* adjust map height here */
}

.cv-panel{ position:relative; }

/* Zoom-gated legend notes */
.legend .muted[id$="-note"]{
  font-size:11px;
  line-height:1.3;
}

header .brand .brand-mark{
  display:flex !important;
  align-items:center;
  justify-content:center;

  width:44px;
  height:44px;
  padding:6px;

  background:#fff !important;
  border-radius:0 !important;
  overflow:hidden;

  border:1px solid rgba(0,0,0,24);
  box-sizing:border-box;
  text-decoration:none;
}
header .brand .brand-mark img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.cv-panel .app{
  display:grid;
  grid-template-columns:340px 1fr;
  grid-template-rows:64px auto;
  gap:0;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji";
}

/* keep heat non-clickable */
.leaflet-heatmap-layer,
.leaflet-heatmap-layer canvas{
  pointer-events:none !important;
}

/* Header */
.cv-panel header{
  grid-column:1/3;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
  background:var(--card);
  border-bottom:1px solid #e5e7eb;
}
.cv-panel .brand{ display:flex; align-items:center; gap:10px; }
.cv-panel .brand-title{ font-size:16px; font-weight:700; }
.cv-panel .cta a{
  display:inline-block;
  padding:6px 10px;
  border-radius:8px;
  background:var(--brand);
  color:#fff;
  text-decoration:none;
  font-weight:600;
}

/* Sidebar */
.cv-panel .sidebar{
  grid-column:1; grid-row:2;
  background:var(--card);
  border-right:1px solid #e5e7eb;
  padding:12px;
  overflow:auto;
  max-height:var(--map-h);
}
.cv-panel .sidebar h2{ font-size:14px; margin:8px 0 6px; }
.cv-panel .sidebar .section{ margin-bottom:12px; }
.cv-panel .sidebar .muted{ color:var(--muted); font-size:12px; }
.cv-panel .layer-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin:2px 0;
  padding:6px 2px;
  font-size:13px;
}
.cv-panel .layer-item + .layer-item{ border-top:1px solid #f0f2f5; }
.cv-panel .layer-item input[type="checkbox"]{ transform:scale(.9); accent-color:var(--brand); }

/* Map */
.cv-panel #cv-map{
  width:100%; height:var(--map-h);
  border-radius:10px;
  overflow:hidden;
  background:#e5e7eb;
}

.cv-panel .leaflet-container{ width:100%; height:100%; }

/* Anchor overlays (legend) to the map area */
.cv-panel .map-wrap{
  position: relative;
  grid-column: 2;
  grid-row: 2;
}

/* Make the map fill the wrapper */
.cv-panel .map-wrap #cv-map{
  width: 100%;
  height: var(--map-h);
}

/* Legend now positions relative to .map-wrap */
.cv-panel .map-wrap .legend{
  position: absolute;
  bottom: 12px;
  right: 12px;
}

/* Legend */
.cv-panel .legend{
  z-index:9999;
  background:var(--card);
  border:1px solid #e5e7eb;
  border-radius:8px;
  padding:6px 8px;
  box-shadow:0 6px 20px rgba(0,0,0,0.06);
  line-height:1.15;
}
.cv-panel .legend h3{
  margin:0 0 4px;
  font-size:13px;
  color:var(--muted);
  font-weight:600;
}
.cv-panel .legend .item{
  display:flex;
  align-items:center;
  gap:6px;
  margin:1px 0;
  font-size:12.5px;
}
.cv-panel .legend .legend-title{
  font-weight:600;
  margin:3px 0 2px;
  font-size:12.5px;
}
.cv-panel .legend .swatch{
  width:12px;
  height:12px;
  border-radius:2px;
  border:1px solid #e5e7eb;
}

/* Heat legend */
.cv-panel #legend-heat{
  background:#fff;
  padding:8px 10px;
  border-radius:6px;
  box-shadow:0 1px 4px rgba(0,0,0,0.15);
}
.cv-panel #legend-heat .legend-title{
  font-size:12px;
  font-weight:600;
  margin-bottom:6px;
}
.cv-panel #legend-heat .heat-gradient{
  height:12px;
  border-radius:6px;
  margin:6px 0 4px 0;
  background: linear-gradient(to right,#6b21a8,#2563eb,#06b6d4,#facc15,#dc2626);
}
.cv-panel #legend-heat .heat-labels{
  display:flex;
  justify-content:space-between;
  font-size:11px;
  color:#374151;
}
.leaflet-popup-content .legend-title{ font-weight:700; }

/* Attribution */
.cv-panel .attribution{
  position:absolute;
  bottom:12px;
  left:12px;
  font-size:11.5px;
  color:var(--muted);
  background:rgba(255,255,255,.85);
  border-radius:6px;
  padding:4px 6px;
}

/* Mobile */
@media (max-width:900px){
  :root{ --map-h:min(56vh,560px); }
  .cv-panel .app{
    grid-template-columns:1fr;
    grid-template-rows:56px auto auto;
  }
  .cv-panel #cv-map{ grid-column:1; grid-row:2; }
  .cv-panel .sidebar{ grid-column:1; grid-row:3; max-height:none; }
}

/* keep MRP blocks tidy */
.cv-panel{
  height: calc(var(--map-h) + 64px);
  overflow:hidden;
}
.cv-panel .app{ height:100%; } 

/* --- School matrix popups (from Rental map) --- */
.school-matrix-wrap{ max-width: 640px; overflow-x: hidden; }
.school-matrix{ width:100%; border-collapse:collapse; table-layout: auto; font-size:12px; }
.school-matrix th, .school-matrix td{
  padding:6px 8px !important;
  border:1px solid rgba(15,23,42,.10);
  vertical-align: top;
  word-break: break-word;
}
.school-matrix th{ font-size:12px; line-height:1.15; font-weight:800; background:#f1f5f9; }
.school-matrix th:first-child{ width: 110px; }
.leaflet-popup-content{ margin:10px 12px; }

/* Avoid Leaflet internal scrollbars */
.leaflet-popup-scrolled{
  overflow: visible !important;
  max-height: none !important;
  padding-right: 0 !important;
}
.leaflet-popup-content{
  max-height: none !important;
  overflow: visible !important;
} 
@media (max-width:900px){
  /* Allow header to become 2 lines/taller */
  .cv-panel .app{
    grid-template-rows: auto auto auto; /* was: 56px auto auto */
  }

  /* Stack brand + CTA */
  .cv-panel header{
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px; /* give it a bit of breathing room */
  }

  .cv-panel header .brand{
    width: 100%;
  }

  .cv-panel header .brand-title{
    line-height: 1.15;
    font-size: 14px; /* optional: slightly smaller to fit nicer */
  }

  .cv-panel header .cta{
    width: 100%;
    text-align: left;
  }
} 

/* ============================
   CLEAN MOBILE OVERRIDES
   ============================ */
@media (max-width:900px){

  /* Layout: header, map, sidebar, attribution */
  :root{ --map-h:min(56vh,560px); }

  .cv-panel{
    height: auto !important;
    overflow: visible !important;
  }

  .cv-panel .app{
    height: auto !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto auto !important; /* + attribution row */
  }

  /* Header: stacked */
  .cv-panel header{
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
  }
  .cv-panel header .brand{ width: 100%; }
  .cv-panel header .brand-title{ line-height: 1.15; font-size: 14px; }
  .cv-panel header .cta{ width: 100%; text-align: left; }

  /* Map wrapper becomes the map row */
  .cv-panel .map-wrap{
    grid-column: 1 !important;
    grid-row: 2 !important;
  }

  /* Sidebar becomes the layers row */
  .cv-panel .sidebar{
    grid-column: 1 !important;
    grid-row: 3 !important;
    max-height: none !important;
    overflow: visible !important; /* change to auto if you want the sidebar to scroll */
    border-right: 0;
    border-top: 1px solid #e5e7eb;
    padding-bottom: 12px !important;
  }

  /* Attribution: its own row under layers (never overlaps) */
  .cv-panel .attribution{
    position: static !important;
    grid-column: 1 / -1 !important;
    grid-row: 4 !important;
    margin: 6px 12px 10px !important; /* tighter spacing */
    background: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }
} 
/* Mobile-friendly school catchment popup layout */
.school-list{
  font-size: 12.5px;
}

.school-card{
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 8px 0;
  background: #fff;
  max-height: 38vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px; /* avoids scrollbar overlay feel */
}

.school-card__head{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.school-card__title{
  font-weight: 800;
  line-height: 1.15;
}

.school-band-dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  border: 2px solid rgba(0,0,0,.10);
  box-sizing: border-box;
}

/* Color dots using your grade bands */
.school-band-dot[data-band="P-6"]   { background: #22c55e; }
.school-band-dot[data-band="7-9"]   { background: #f97316; }
.school-band-dot[data-band="10-12"] { background: #ef4444; }
.school-band-dot[data-band="P-12"]  { background: #a855f7; }
.school-band-dot[data-band="OTHER"] { background: #94a3b8; }

.school-card__list{
  list-style: none;
  padding: 0;
  margin: 0;
}

.school-card__item{
  padding: 6px 0;
  border-top: 1px solid rgba(15,23,42,.06);
}
.school-card__item:first-child{ border-top: 0; }

.school-card__name{
  font-weight: 700;
}

.school-card__meta{
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #64748b;
  font-size: 12px;
}

.school-card__program{
  font-weight: 600;
} 
.school-mini{ font-size: 12.5px; }

.school-mini__group{
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 10px;
  background: #fff;
  margin: 8px 0;
  overflow: hidden;
}

.school-mini__summary{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}
.school-mini__summary::-webkit-details-marker{ display:none; }

.school-mini__count{
  margin-left: auto;
  font-weight: 700;
  font-size: 12px;
  color: #64748b;
}

.school-mini__items{
  border-top: 1px solid rgba(15,23,42,.08);
  padding: 8px 10px;
}

.school-mini__item{
  padding: 6px 0;
  border-top: 1px solid rgba(15,23,42,.06);
}
.school-mini__item:first-child{ border-top: 0; }

.school-mini__program{ font-weight: 700; color: #334155; }
.school-mini__name{ color: #64748b; margin-top: 1px; }

/* band dots */
.school-mini__dot{
  width: 10px; height: 10px; border-radius: 999px; display:inline-block;
  border: 2px solid rgba(0,0,0,.10); box-sizing: border-box;
}
.school-mini__dot[data-band="P-6"]   { background: #22c55e; }
.school-mini__dot[data-band="7-9"]   { background: #f97316; }
.school-mini__dot[data-band="10-12"] { background: #ef4444; }
.school-mini__dot[data-band="P-12"]  { background: #a855f7; }
.school-mini__dot[data-band="OTHER"] { background: #94a3b8; }