:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-strong: #eef3f4;
  --text: #172126;
  --muted: #66767d;
  --line: #d8e1e4;
  --accent: #0f7c80;
  --accent-strong: #095a60;
  --amber: #b76d20;
  --violet: #6e5aa8;
  --radius: 8px;
  --shadow: 0 12px 28px rgba(20, 37, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

video {
  display: block;
  max-width: 100%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 42px);
  background: rgba(244, 247, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 720;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(15, 124, 128, 0.12);
}

.site-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.site-nav a,
.button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

.site-nav a.active,
.site-nav a:hover,
.button {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(20, 37, 45, 0.08);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.status-strip,
.page-title,
.night-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.page-title {
  align-items: start;
  flex-direction: column;
}

.night-title {
  align-items: center;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1.02;
}

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

.status-pill {
  padding: 8px 12px;
  background: #14343a;
  color: #f2fbfc;
  border-radius: 999px;
  font-weight: 750;
}

.dashboard-grid,
.charts-grid,
.nights-grid {
  display: grid;
  gap: 16px;
}

.side-panels {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.85fr);
  margin-bottom: 16px;
}

.dashboard-grid.compact {
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.55fr);
}

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

.charts-grid .wide {
  grid-column: 1 / -1;
}

.nights-grid {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.panel,
.night-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-heading {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-heading h2 {
  color: var(--text);
}

.update-status {
  margin-right: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.update-status.is-error {
  color: var(--amber);
}

.chart-select {
  min-height: 34px;
  max-width: 220px;
  padding: 6px 9px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 0.88rem;
}

.chart-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chart-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.chart-toggles input {
  accent-color: var(--accent);
}

.allsky-frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #05080a;
  overflow: hidden;
}

.latest-frame {
  max-width: 680px;
  margin: 0 auto;
}

.preview-frame {
  max-width: 520px;
  margin: 0 auto;
}

.preview-links {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.latest-image,
.allsky-frame video,
.allsky-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.preview-image {
  aspect-ratio: 1 / 1;
}

.preview-unavailable {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  margin: 0;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sensor-groups {
  display: grid;
  gap: 14px;
}

.metric-group-heading {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric {
  min-height: 74px;
  padding: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 1.28rem;
}

.chart {
  width: 100%;
  height: 320px;
}

.chart svg,
.chart .plot-container {
  width: 100%;
  height: 100%;
}

.chart .axis {
  stroke: #b9c6ca;
  stroke-width: 1;
}

.chart .grid {
  stroke: #e2e9eb;
  stroke-width: 1;
}

.chart .label {
  fill: var(--muted);
  font-size: 11px;
}

.chart .empty {
  color: var(--muted);
  display: grid;
  place-items: center;
  height: 100%;
  background: var(--surface-strong);
  border-radius: var(--radius);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--legend-color);
}

.night-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
}

.night-card-frame {
  width: 136px;
  margin: 12px 0 12px 12px;
}

.night-card-body {
  padding: 12px 14px;
}

.night-card h2 {
  font-size: 1.12rem;
}

.night-meta {
  display: grid;
  gap: 4px;
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.night-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.night-actions a {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 650;
}

.compact-list {
  display: grid;
  gap: 10px;
}

.compact-night {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.compact-night img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  object-position: center;
  border-radius: 6px;
  background: #05080a;
}

.compact-night strong,
.compact-night span {
  display: block;
}

.compact-night span {
  color: var(--muted);
  font-size: 0.86rem;
}

@media (max-width: 860px) {
  .site-header,
  .status-strip,
  .night-title {
    align-items: stretch;
    flex-direction: column;
  }

  .site-nav {
    width: 100%;
  }

  .site-nav a {
    flex: 1;
  }

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

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

@media (max-width: 520px) {
  .nights-grid {
    grid-template-columns: 1fr;
  }

  .night-card {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .night-card-frame {
    width: 96px;
  }
}
