:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #eaf1f6;
  --text: #14212b;
  --muted: #5f6f7a;
  --accent: #0b7285;
  --accent-strong: #0f5965;
  --line: #d8e1e8;
  --good: #2f9e44;
  --warn: #c92a2a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

.site-header,
main,
.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.header-status {
  display: grid;
  justify-items: end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-link {
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: underline;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--accent-strong);
  font-weight: 700;
}

.status-pill.error {
  color: var(--warn);
}

.conditions-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.condition,
.status-row,
.storm-panel,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgb(20 33 43 / 6%);
}

.condition {
  display: grid;
  gap: 8px;
  min-height: 126px;
  padding: 18px;
}

.condition.primary {
  grid-column: span 2;
  background: #dff5f2;
  border-color: #b9e3de;
}

.condition span,
.status-row span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.condition strong {
  align-self: end;
  font-size: clamp(1.85rem, 5vw, 3.7rem);
  line-height: 1;
}

.condition:not(.primary) strong {
  font-size: clamp(1.55rem, 4vw, 2.3rem);
}

.condition-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
}

.condition-meta small:first-child {
  color: var(--accent-strong);
  font-weight: 800;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 14px 0;
  overflow: hidden;
}

.status-row div {
  display: grid;
  gap: 8px;
  min-height: 82px;
  padding: 18px;
  background: var(--surface);
}

.status-row strong {
  font-size: 1.2rem;
}

.storm-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(240px, 1.2fr);
  gap: 16px 22px;
  align-items: center;
  margin: 14px 0;
  padding: 18px;
}

.storm-summary {
  display: grid;
  gap: 6px;
}

.storm-summary span,
.storm-components span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.storm-summary strong {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1;
}

.storm-summary small {
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.storm-meter {
  height: 18px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.storm-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--good);
  transition: width 180ms ease-out;
}

.storm-meter span[data-level="watch"] {
  background: #f08c00;
}

.storm-meter span[data-level="elevated"],
.storm-meter span[data-level="high"] {
  background: var(--warn);
}

.storm-components {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.storm-components div {
  display: grid;
  gap: 6px;
  min-height: 70px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.storm-components strong {
  font-size: 1.35rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 30px;
}

.chart-panel {
  padding: 18px;
}

.chart-panel.wide {
  grid-column: 1 / -1;
}

.chart-frame {
  position: relative;
  width: 100%;
  height: 260px;
  overflow: hidden;
}

.chart-empty {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.chart-empty[hidden],
.chart-frame canvas[hidden] {
  display: none;
}

.chart-frame canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.readings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgb(20 33 43 / 6%);
  overflow: hidden;
}

.history-controls {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgb(20 33 43 / 6%);
}

.preset-group,
.custom-history {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.preset-button,
.custom-history button,
.custom-history input,
.custom-history select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.preset-button,
.custom-history button {
  padding: 0 14px;
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

.preset-button.active,
.custom-history button {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.custom-history label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.custom-history input,
.custom-history select {
  padding: 0 10px;
}

.readings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.readings-table th,
.readings-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.readings-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.readings-table tr:last-child td {
  border-bottom: 0;
}

.value-cell {
  font-weight: 800;
}

.topic-cell {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-end;
  padding: 16px 0 24px;
  color: var(--muted);
  font-size: 0.86rem;
}

.site-footer strong {
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11191f;
    --surface: #18242c;
    --surface-muted: #21313b;
    --text: #edf4f7;
    --muted: #a8b7c0;
    --accent: #49b6c5;
    --accent-strong: #70d5de;
    --line: #2b3a44;
  }

  .condition.primary {
    background: #173a3e;
    border-color: #28575d;
  }
}

@media (max-width: 860px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-status {
    justify-items: start;
  }

  .conditions-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .site-header,
  main,
  .site-footer {
    width: min(100% - 20px, 1180px);
  }

  .site-header {
    padding-top: 22px;
  }

  .conditions-grid,
  .status-row,
  .storm-panel,
  .storm-components {
    grid-template-columns: 1fr;
  }

  .condition.primary {
    grid-column: auto;
  }

  .chart-panel {
    padding: 14px;
  }

  .chart-frame {
    height: 220px;
  }

  .readings-panel {
    overflow-x: auto;
  }

  .readings-table {
    min-width: 680px;
  }
}
