:root {
  --ink: #193238;
  --muted: #607875;
  --paper: #fffdf8;
  --line: rgba(25, 50, 56, 0.14);
  --accent: #d85f4f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Helvetica Neue", Helvetica, sans-serif;
  font-variant-numeric: lining-nums tabular-nums;
  background: #e5eee9;
  color: var(--ink);
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 32px 72px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
}

.page-switcher {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.58);
  font-family: Arial, sans-serif;
}

.page-tab {
  border: 0;
  background: transparent;
  padding: 9px 14px;
}

.page-tab.is-active {
  background: #d8e5e0;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(25, 50, 56, 0.12);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font: 700 1.25rem/1.2 Arial, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 400;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.intro {
  max-width: 440px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.5;
}

.page-view[hidden] {
  display: none;
}

.view-heading,
.battery-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.section-kicker,
.reading-label {
  margin: 0 0 7px;
  color: var(--accent);
  font: 700 0.75rem/1.2 Arial, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.view-heading h2,
.battery-heading h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  letter-spacing: -0.03em;
}

.battery-heading h2 {
  font-size: 1.15rem;
  letter-spacing: 0;
}

.received-time {
  margin: 0;
  color: var(--muted);
  font: 0.88rem Arial, sans-serif;
}

.latest-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.reading-card,
.battery-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 8px 28px rgba(25, 50, 56, 0.05);
}

.reading-card {
  min-height: 190px;
  padding: 22px;
  border-top: 4px solid var(--accent);
}

.reading-card-temperature .reading-value,
.reading-card-temperature .reading-label,
.reading-card-temperature .reading-unit {
  color: #d85f4f;
}

.reading-card-pressure .reading-value,
.reading-card-pressure .reading-label,
.reading-card-pressure .reading-unit {
  color: #bf882c;
}

.reading-card-humidity .reading-value,
.reading-card-humidity .reading-label,
.reading-card-humidity .reading-unit {
  color: #247f83;
}

.reading-card-pressure {
  border-top-color: #bf882c;
}

.reading-card-humidity {
  border-top-color: #247f83;
}

.reading-value,
.battery-percent {
  margin: 42px 0 0;
  font-size: clamp(2.9rem, 8vw, 5.5rem);
  letter-spacing: -0.06em;
  line-height: 0.9;
}

.reading-value {
  font-variant-numeric: lining-nums tabular-nums;
}

.pressure-trend {
  margin: 26px 0 0;
  color: #bf882c;
  font-size: 0.9rem;
  font-weight: 600;
}

.trend-steady {
  color: #bf882c;
}

.trend-rising {
  color: #bf882c;
}

.trend-falling {
  color: #bf882c;
}

.reading-unit {
  margin-left: 7px;
  color: var(--muted);
  font: 700 clamp(0.9rem, 2vw, 1.25rem) Arial, sans-serif;
  letter-spacing: 0;
}

.battery-panel {
  margin-bottom: 18px;
  padding: 24px 22px 20px;
}

.battery-percent {
  margin: 0;
  color: var(--accent);
}

.battery-percent span:last-child {
  margin-left: 5px;
  font: 700 1.2rem Arial, sans-serif;
  letter-spacing: 0;
}

.battery-track {
  height: 18px;
  overflow: hidden;
  border-radius: 10px;
  background: #d8e5e0;
}

.battery-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 350ms ease;
}

.battery-voltage {
  margin: 13px 0 0;
  color: var(--muted);
  font: 0.9rem Arial, sans-serif;
}

.battery-voltage strong {
  color: var(--ink);
}

.history-heading {
  align-items: center;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  font-family: Arial, sans-serif;
}

.range-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.range-switcher {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.58);
}

button {
  border: 1px solid #a5b6b1;
  border-radius: 5px;
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 13px;
}

button {
  cursor: pointer;
  border-color: #a5b6b1;
  background: #d8e5e0;
  color: var(--ink);
  font-weight: 700;
}

button:hover {
  background: #c8dcd5;
}

.range-button {
  min-width: 48px;
  border-color: transparent;
  background: transparent;
  padding: 7px 10px;
  color: var(--muted);
}

.range-button:hover,
.range-button.is-active {
  border-color: rgba(25, 50, 56, 0.12);
  background: #d8e5e0;
  color: var(--ink);
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

#status {
  min-height: 21px;
  margin-bottom: 18px;
  font-family: Arial, sans-serif;
  font-size: 0.88rem;
}

.status-loading {
  color: var(--accent);
}

.status-success {
  color: var(--muted);
}

.status-error {
  color: #a23c32;
}

.chart-container {
  position: relative;
  height: 330px;
  margin-bottom: 18px;
  padding: 20px 22px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 8px 28px rgba(25, 50, 56, 0.05);
}

.chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 400;
}

.unit {
  color: var(--muted);
  font: 700 0.75rem Arial, sans-serif;
  letter-spacing: 0.08em;
}

canvas {
  width: 100% !important;
  height: calc(100% - 34px) !important;
}

@media (max-width: 600px) {
  .container {
    padding: 32px 18px 48px;
  }

  .page-header {
    display: block;
    margin-bottom: 28px;
  }

  .page-switcher {
    margin-top: 24px;
  }

  .page-tab {
    flex: 1;
  }

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

  .reading-card {
    min-height: 150px;
  }

  .reading-value {
    margin-top: 26px;
  }

  .view-heading,
  .battery-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .battery-percent {
    margin-top: 0;
  }

  .controls {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .controls .range-switcher,
  .controls .update-button {
    flex: 1 1 150px;
  }

  .range-switcher {
    justify-content: space-between;
  }

  .range-button {
    min-width: 0;
    flex: 1;
  }

  .chart-container {
    height: 270px;
    padding: 16px 12px 12px;
  }
}