:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #627084;
  --line: #d8dee8;
  --accent: #0f7b6c;
  --accent-weak: #e3f3ef;
  --warn: #a64800;
  --warn-bg: #fff1df;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px) 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

p {
  margin: 0;
}

#lastSeen {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.rangeControls {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 8px;
}

.rangeControls button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.rangeControls button.active {
  border-color: var(--accent);
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 700;
}

main {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
}

.statusLine {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.statusLine div {
  min-height: 84px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.statusLine span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.statusLine strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.stale {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid #f2c28d;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn);
}

.chartArea {
  height: min(62vh, 620px);
  min-height: 340px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

#powerChart {
  width: 100%;
  height: 100%;
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .chartArea {
    min-height: 300px;
  }
}
