:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5d6875;
  --line: #d5dde5;
  --page: #f4f7f8;
  --surface: #ffffff;
  --green: #177245;
  --green-soft: #e7f4ec;
  --gold: #a96800;
  --gold-soft: #fff3d6;
  --red: #a93634;
  --blue: #225ea8;
  --offline: #77818c;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.public-header {
  position: sticky;
  z-index: 1000;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.public-header-inner {
  width: min(1280px, calc(100vw - 40px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.project-name {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

nav a {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

nav a:hover {
  color: var(--ink);
}

.admin-link {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.project-intro {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 46px 0 36px;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(360px, 0.8fr);
  align-items: end;
  gap: 56px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1, h2, h3, h4, p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 13px;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
}

h3 {
  margin-bottom: 5px;
  font-size: 22px;
}

h4 {
  margin-bottom: 0;
  font-size: 15px;
}

.project-description {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
}

.partner-line {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.partner-line a {
  color: var(--blue);
  font-weight: 700;
}

.network-summary {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.network-summary div {
  min-width: 0;
  padding: 15px 13px;
  border-right: 1px solid var(--line);
}

.network-summary div:last-child {
  border-right: 0;
}

.network-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.network-summary dd {
  margin: 4px 0 0;
  font-size: 25px;
  font-weight: 700;
}

.network-band {
  padding: 30px max(20px, calc((100vw - 1280px) / 2)) 46px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 50%;
}

.status-dot.recent, .map-marker.recent {
  background: var(--green);
}

.status-dot.stale, .map-marker.stale {
  background: var(--gold);
}

.status-dot.offline, .map-marker.offline {
  background: var(--offline);
}

.network-layout {
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(340px, 0.9fr);
  border: 1px solid var(--line);
}

.site-map {
  min-height: 560px;
  background: #dfe9e8;
}

.map-loading {
  padding: 24px;
  color: var(--muted);
}

.map-marker {
  width: 20px;
  height: 20px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(23, 33, 43, 0.4);
}

.site-detail {
  min-width: 0;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.empty-detail {
  max-width: 330px;
  padding-top: 20px;
}

.empty-detail p:last-child, .site-updated, .site-notes {
  color: var(--muted);
}

.site-detail-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.site-region {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status-label {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
}

.status-label.recent {
  color: var(--green);
  background: var(--green-soft);
}

.status-label.stale {
  color: var(--gold);
  background: var(--gold-soft);
}

.status-label.offline {
  color: #ffffff;
  background: var(--offline);
}

.site-updated {
  margin-bottom: 16px;
  font-size: 13px;
}

.public-sensor-picker {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
}

.public-sensor-picker select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

.public-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.public-metric {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.public-metric span {
  display: block;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.public-metric strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
}

.trend-heading {
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.trend-heading span {
  color: var(--muted);
  font-size: 12px;
}

#publicTrend {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.site-notes {
  margin: 14px 0 0;
  font-size: 13px;
}

.no-sites {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-top: 0;
  color: var(--muted);
  background: var(--page);
}

footer {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 24px 0 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  color: var(--muted);
  font-size: 12px;
}

footer p {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

footer a {
  color: var(--blue);
}

@media (max-width: 900px) {
  .project-intro {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .network-layout {
    grid-template-columns: 1fr;
  }

  .site-map {
    min-height: 440px;
  }

  .site-detail {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 660px) {
  .public-header-inner {
    width: min(100% - 28px, 1280px);
    min-height: 58px;
  }

  .project-name {
    max-width: 52vw;
    font-size: 14px;
  }

  nav {
    gap: 8px;
  }

  nav a:not(.admin-link) {
    display: none;
  }

  .admin-link {
    font-size: 12px;
  }

  .project-intro {
    width: min(100% - 28px, 1280px);
    padding: 30px 0 26px;
  }

  h1 {
    font-size: 36px;
  }

  .network-summary div {
    padding: 12px 8px;
  }

  .network-summary dt {
    font-size: 11px;
  }

  .network-summary dd {
    font-size: 21px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .map-legend {
    justify-content: flex-start;
  }

  .site-map {
    min-height: 390px;
  }

  .site-detail {
    padding: 18px;
  }
}
