html,
body,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  color: #17202a;
}

.panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 500;
  width: 220px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(23, 32, 42, 0.18);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.16);
}

.panel__title {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  font-size: 13px;
}

.legend {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(23, 32, 42, 0.14);
  font-size: 12px;
}

.legend div {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
}

.legend__swatch {
  width: 18px;
  height: 12px;
  border: 1px solid rgba(23, 32, 42, 0.18);
}

.legend__swatch--low {
  background: #2c7bb6;
}

.legend__swatch--mid {
  background: #fdae61;
}

.legend__swatch--high {
  background: #d7191c;
}

.popup-table {
  border-collapse: collapse;
  min-width: 210px;
  font-size: 12px;
}

.popup-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #e7eaee;
}

.popup-table td:first-child {
  font-weight: 700;
  color: #415161;
}

@media (max-width: 700px) {
  .panel {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 18px;
    width: auto;
  }
}

.popup-table small {
  display: block;
  margin-top: 2px;
  color: #657281;
  font-size: 11px;
  line-height: 1.25;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.leaflet-popup-content {
  width: 292px !important;
  margin: 0;
}

.risk-popup {
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
}

.risk-popup__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 8px;
  border-bottom: 1px solid #e7eaee;
}

.risk-popup__top strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  line-height: 1.2;
}

.risk-popup__eyebrow {
  display: block;
  color: #657281;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.risk-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.risk-badge--low {
  background: #2c7bb6;
}

.risk-badge--medium {
  background: #d9822b;
}

.risk-badge--high {
  background: #c8191e;
}

.risk-score {
  padding: 10px 12px 8px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.risk-score--low {
  color: #2c7bb6;
}

.risk-score--medium {
  color: #d9822b;
}

.risk-score--high {
  color: #c8191e;
}

.metric-list {
  padding: 0 12px 10px;
}

.metric-row {
  padding: 8px 0;
  border-top: 1px solid #edf0f3;
}

.metric-row__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
}

.metric-row__head strong {
  font-variant-numeric: tabular-nums;
}

.metric-bar {
  overflow: hidden;
  height: 9px;
  margin-top: 6px;
  border-radius: 999px;
  background: #e8edf1;
}

.metric-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2c7bb6 0%, #fdae61 55%, #d7191c 100%);
}

.metric-row small {
  display: block;
  margin-top: 4px;
  color: #657281;
  font-size: 11px;
}

.popup-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid #e7eaee;
  background: #f7f9fb;
}

.popup-facts div {
  padding: 10px 12px;
}

.popup-facts div + div {
  border-left: 1px solid #e7eaee;
}

.popup-facts span {
  display: block;
  color: #657281;
  font-size: 11px;
}

.popup-facts strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.legend__swatch--critical {
  background: #7f0000;
}

.map-title {
  position: absolute;
  top: 14px;
  left: 58px;
  z-index: 500;
  max-width: min(560px, calc(100vw - 430px));
  padding: 12px 40px 12px 14px;
  border: 1px solid rgba(23, 32, 42, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(23, 32, 42, 0.16);
}

.map-title span,
.map-title small {
  display: block;
}

.map-title span {
  color: #657281;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.map-title strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.2;
}

.map-title small {
  margin-top: 4px;
  color: #4c5a67;
  font-size: 12px;
  line-height: 1.35;
}

.map-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: #edf0f3;
  color: #17202a;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.map-dismiss:hover {
  background: #dfe5ea;
}

.map-tip {
  position: absolute;
  left: 14px;
  bottom: 28px;
  z-index: 500;
  max-width: 300px;
  padding: 9px 38px 9px 11px;
  border: 1px solid #cfe8d9;
  border-radius: 8px;
  background: rgba(241, 250, 245, 0.96);
  color: #123d24;
  box-shadow: 0 8px 22px rgba(23, 32, 42, 0.14);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.dashboard-toggle {
  display: none;
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 510;
  height: 34px;
  padding: 0 12px;
  border: 1px solid #2c7bb6;
  border-radius: 6px;
  background: #2c7bb6;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.dashboard-toggle.is-visible {
  display: block;
}

.dashboard-hidden .map-title {
  max-width: min(720px, calc(100vw - 120px));
}

.dashboard-hidden .map-tip {
  bottom: 28px;
}

.dashboard {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 18px;
  z-index: 500;
  width: 340px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(23, 32, 42, 0.16);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23, 32, 42, 0.18);
}

.dashboard.is-hidden,
.map-title.is-hidden,
.map-tip.is-hidden {
  display: none;
}

.dashboard__close {
  position: sticky;
  top: 8px;
  float: right;
  z-index: 1;
  width: 30px;
  height: 30px;
  margin: 8px 8px -38px 0;
  border: 0;
  border-radius: 50%;
  background: #edf0f3;
  color: #17202a;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.dashboard__section {
  padding: 12px 14px;
  border-bottom: 1px solid #e7eaee;
}

.dashboard__section:last-child {
  border-bottom: 0;
}

.dashboard__hero {
  padding-right: 48px;
}

.dashboard__hero h1 {
  margin: 4px 0 8px;
  font-size: 24px;
  line-height: 1.05;
}

.dashboard__hero p {
  margin: 0;
  color: #4c5a67;
  font-size: 12px;
  line-height: 1.45;
}


.eyebrow {
  color: #657281;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-title,
.formula__title {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: #415161;
}

.formula__body {
  padding: 10px;
  border-radius: 6px;
  background: #f2f5f7;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.buffer-btn {
  height: 34px;
  border: 1px solid #cfd7df;
  border-radius: 6px;
  background: #fff;
  color: #27323d;
  font-weight: 700;
  cursor: pointer;
}

.buffer-btn.is-active {
  border-color: #006d2c;
  background: #dff2e7;
  color: #005322;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-card {
  min-height: 66px;
  padding: 10px;
  border: 1px solid #e1e6eb;
  border-radius: 6px;
  background: #fbfcfd;
}

.stat-card span {
  display: block;
  color: #657281;
  font-size: 11px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
  line-height: 1;
}

.district-list {
  display: grid;
  gap: 7px;
}

.district-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #e4e9ee;
  border-radius: 6px;
  background: #fff;
}

.district-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #7f0000;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.district-main strong,
.district-main small {
  display: block;
}

.district-main strong {
  font-size: 13px;
}

.district-main small {
  margin-top: 2px;
  color: #657281;
  font-size: 11px;
}

.district-pct {
  font-size: 12px;
  font-weight: 800;
  color: #7f0000;
}

.loading-row {
  color: #657281;
  font-size: 12px;
}

@media (max-width: 900px) {
  .map-title {
    left: 10px;
    right: 10px;
    top: 10px;
    max-width: none;
  }

  .map-title strong {
    font-size: 15px;
  }

  .map-tip {
    left: 10px;
    right: 10px;
    bottom: calc(45vh + 28px);
    max-width: none;
  }

  .dashboard-toggle {
    top: auto;
    right: 10px;
    bottom: 18px;
  }

  .dashboard { 
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 18px;
    width: auto;
    max-height: 45vh;
  }
}

.chart-wrap {
  height: 180px;
  margin: 4px 0 10px;
  padding: 6px;
  border: 1px solid #e4e9ee;
  border-radius: 6px;
  background: #fff;
}

.nearest-card {
  margin: 0 12px 10px;
  padding: 10px;
  border: 1px solid #cfe8d9;
  border-radius: 6px;
  background: #f1faf5;
}

.nearest-card span,
.nearest-card small {
  display: block;
  color: #4f665a;
  font-size: 11px;
}

.nearest-card strong {
  display: block;
  margin: 3px 0;
  color: #123d24;
  font-size: 13px;
  line-height: 1.25;
}

.search-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.search-box input {
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid #cfd7df;
  border-radius: 6px;
  font-size: 13px;
}

.search-box button,
.wide-btn {
  height: 34px;
  border: 1px solid #2c7bb6;
  border-radius: 6px;
  background: #2c7bb6;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.wide-btn {
  width: 100%;
  margin-top: 7px;
}

.nearest-result {
  margin-top: 8px;
  padding: 9px;
  border: 1px solid #e1e6eb;
  border-radius: 6px;
  background: #fbfcfd;
  color: #4c5a67;
  font-size: 12px;
  line-height: 1.35;
}

.nearest-result strong,
.nearest-result span {
  display: block;
}

.nearest-result strong {
  color: #17202a;
}

.legend__point {
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #00a651;
  box-shadow: 0 0 0 1px #007a3d;
}

.openspace-popup > strong {
  display: block;
  padding: 12px 12px 4px;
  color: #123d24;
  font-size: 15px;
}

.formula-notes {
  margin: 8px 0 0;
}

.formula-notes div {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid #e7eaee;
}

.formula-notes dt {
  font-weight: 800;
  color: #17202a;
}

.formula-notes dd {
  margin: 0;
  color: #4c5a67;
  font-size: 12px;
  line-height: 1.35;
}

.stat-card--wide {
  grid-column: 1 / -1;
}

.legend__swatch--population {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #54278f;
  border-color: #ffffff;
  box-shadow: 0 0 0 1px #54278f;
}

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

.popup-facts--three div + div {
  border-left: 1px solid #e7eaee;
}

.wide-btn--plain {
  border-color: #cfd7df;
  background: #ffffff;
  color: #27323d;
}

.legend__triangle {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 13px solid #e31a1c;
  filter: drop-shadow(0 0 0 #fff);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 16, 22, 0.48);
}

.modal.is-open {
  display: flex;
}

.modal__content {
  position: relative;
  max-width: 680px;
  max-height: 82vh;
  overflow: auto;
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.modal__content h2 {
  margin: 0 34px 14px 0;
}

.modal__content h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.modal__content p,
.modal__content li {
  color: #4c5a67;
  font-size: 13px;
  line-height: 1.5;
}

.modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #edf0f3;
  font-size: 20px;
  cursor: pointer;
}

.temperature-popup > strong {
  display: block;
  padding: 12px 12px 4px;
  color: #7f0000;
  font-size: 15px;
}


.legend__swatch--intervention {
  background: #ffd92f;
  border-color: #4d2600;
}

.intervention-popup > strong {
  display: block;
  padding: 12px 12px 4px;
  color: #4d2600;
  font-size: 15px;
}
