:root {
    --paper: #F2F0E6;
    --ink: #111111;
    --acid: #D6FF3D;
    --coral: #FF4B3E;
    --cobalt: #2B4EFF;
    --best: #1F9E63;
    --good: #D6FF3D;
    --bad: #FF9F1C;
    --worst: #FF4B3E;
    --shadow: 6px 6px 0 var(--ink);
    --shadow-sm: 4px 4px 0 var(--ink);
  }
  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'IBM Plex Mono', monospace;
  }
  .display { font-family: 'Archivo Black', sans-serif; text-transform: uppercase; }
  a { color: inherit; }

  /* ---------- Nav ---------- */
  nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--paper);
    border-bottom: 4px solid var(--ink);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  nav .brand {
    font-size: 20px;
    letter-spacing: -0.02em;
  }
  nav .links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  nav .links a {
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    border: 3px solid var(--ink);
    background: #fff;
    padding: 6px 12px;
    box-shadow: var(--shadow-sm);
  }
  nav .links a:hover { transform: translate(-1px, -1px); }
  nav .links a.cta { background: var(--acid); }

  /* ---------- Hero / Mission ---------- */
  header.hero {
    background: var(--acid);
    border-bottom: 4px solid var(--ink);
    padding: 56px 24px 48px;
  }
  .hero-inner {
    max-width: 1080px;
    margin: 0 auto;
  }
  header.hero h1 {
    margin: 0 0 16px;
    font-size: clamp(36px, 7vw, 64px);
    line-height: 0.95;
    letter-spacing: -0.02em;
  }
  header.hero p.lede {
    max-width: 640px;
    font-size: 17px;
    font-weight: 500;
    line-height: 1.5;
  }
  header.hero .tag {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    border: 3px solid var(--ink);
    background: var(--paper);
    padding: 6px 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
  }

  main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
  }

  section { padding: 56px 0; border-bottom: 4px solid var(--ink); }
  section:last-of-type { border-bottom: none; }

  .block-label {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: var(--ink);
    color: var(--paper);
    padding: 4px 10px;
    margin-bottom: 14px;
  }
  h2.section-title {
    margin: 0 0 20px;
    font-size: clamp(26px, 4vw, 38px);
    line-height: 1;
  }

  .prose { font-size: 15px; line-height: 1.7; max-width: 680px; }
  .prose p { margin: 0 0 16px; }

  .step-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 24px;
  }
  .step-card {
    background: #fff;
    border: 4px solid var(--ink);
    box-shadow: var(--shadow);
    padding: 18px;
  }
  .step-card .num {
    font-family: 'Archivo Black', sans-serif;
    font-size: 30px;
    color: var(--cobalt);
    line-height: 1;
    margin-bottom: 8px;
  }
  .step-card h3 { margin: 0 0 6px; font-size: 15px; text-transform: uppercase; }
  .step-card p { margin: 0; font-size: 13px; line-height: 1.5; }

  .stat-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 24px;
  }
  .stat-box {
    border: 4px solid var(--ink);
    background: var(--cobalt);
    color: #fff;
    padding: 16px;
    box-shadow: var(--shadow);
  }
  .stat-box .n { font-family: 'Archivo Black', sans-serif; font-size: 32px; line-height: 1; }
  .stat-box .l { font-size: 12px; margin-top: 6px; }

  /* ---------- Dashboard section ---------- */
  #map {
    height: 360px;
    border: 4px solid var(--ink);
    box-shadow: var(--shadow);
    filter: grayscale(1) contrast(1.1);
  }
  .range-row { display: flex; gap: 10px; margin: 24px 0 16px; flex-wrap: wrap; }
  .range-btn {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    background: #fff;
    border: 3px solid var(--ink);
    box-shadow: var(--shadow-sm);
    padding: 6px 14px;
    cursor: pointer;
    color: var(--ink);
  }
  .range-btn.active { background: var(--cobalt); color: #fff; }
  .range-btn:hover { transform: translate(-1px, -1px); }

  .sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 24px;
  }
  .sensor-card {
    background: #ffffff;
    border: 4px solid var(--ink);
    box-shadow: var(--shadow);
    padding: 20px;
    position: relative;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
  }
  .sensor-card:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
  .sensor-card.stale { opacity: 0.55; }
  .sensor-card h3 { margin: 0 0 10px; font-size: 16px; font-weight: 700; text-transform: uppercase; }

  .meta-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; font-weight: 600; color: #444; margin-bottom: 10px;
  }
  .trend { font-weight: 700; }
  .trend.up { color: var(--worst); }
  .trend.down { color: var(--best); }
  .trend.flat { color: #666; }

  .status {
    display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em; border: 3px solid var(--ink); padding: 3px 10px;
    margin-bottom: 14px; transform: rotate(-1.5deg);
  }
  .status.best { background: var(--best); color: #fff; }
  .status.good { background: var(--good); color: var(--ink); }
  .status.bad { background: var(--bad); color: var(--ink); }
  .status.worst { background: var(--worst); color: #fff; }
  .status.offline { background: #999; color: #fff; }

  .reading { font-family: 'Archivo Black', sans-serif; font-size: 42px; line-height: 1; margin-bottom: 4px; }
  .reading span { font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 500; }
  .reading .raw { font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 500; color: #555; display: block; margin-top: 2px; }

  .stat-row { display: flex; gap: 16px; margin-top: 10px; font-size: 13px; font-weight: 600; }
  .stat-row span.val { font-family: 'Archivo Black', sans-serif; font-size: 16px; margin-right: 4px; }

  canvas { max-height: 120px; margin-top: 14px; }

  .empty {
    font-size: 14px; font-weight: 600; padding: 48px 24px; text-align: center;
    border: 4px dashed var(--ink); background: #fff;
  }

  /* ---------- Footer ---------- */
  footer {
    text-align: center;
    padding: 32px 24px;
    border-top: 4px solid var(--ink);
    font-size: 13px;
  }
  footer .links { margin-top: 10px; }
  footer .links a { text-decoration: underline; margin: 0 8px; font-weight: 600; }
  footer .fine { margin-top: 14px; font-size: 11px; color: #555; }

/* ---------- Active Sensors ---------- */

.sensor-intro {
  max-width: 680px;
  font-size: 14px;
  line-height: 1.7;
  margin: 0 0 28px;
}

.active-sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 24px;
}

.active-sensor-card {
  background: #fff;
  border: 4px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.active-sensor-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 var(--ink);
}

.active-sensor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.sensor-number {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  color: #555;
}

.active-sensor-header h3 {
  margin: 0;
  font-size: 20px;
  text-transform: uppercase;
}

.sensor-id {
  display: inline-block;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.active-sensor-description {
  font-size: 12px;
  line-height: 1.7;
  margin: 16px 0 20px;
  color: #333;
}

/* Status badge */

.active-sensor-card .status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  margin: 0;
  transform: none;
  font-size: 10px;
  padding: 5px 8px;
}

.status-dot,
.sensor-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
}

.active-sensor-card .status.offline {
  background: #999;
  color: #fff;
}

.active-sensor-card .status.online {
  background: var(--best);
  color: #fff;
}

/* Sensor metadata */

.sensor-details {
  border-top: 3px solid var(--ink);
}

.sensor-detail {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #ccc;
  font-size: 11px;
}

.detail-label {
  color: #555;
  font-weight: 600;
}

.detail-value {
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.sensor-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #666;
}

.sensor-card-footer .sensor-indicator {
  background: #999;
}

@media (max-width: 480px) {
  .active-sensor-grid {
    grid-template-columns: 1fr;
  }

  .active-sensor-card {
    padding: 16px;
  }

  .active-sensor-header h3 {
    font-size: 17px;
  }
}
