:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1d2522;
  --muted: #64706b;
  --line: #dfe5df;
  --brand: #166b5b;
  --brand-strong: #0d4d41;
  --accent: #cf5a24;
  --shadow: 0 10px 30px rgba(22, 37, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

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

.brand {
  font-weight: 800;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a {
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  background: var(--ink);
  color: #fff;
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

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

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--brand-strong);
}

.button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 16px;
}

.metric-link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.metric-link:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.device-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-heading span {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf3ef;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.reading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.reading-row strong {
  font-size: 2.1rem;
  line-height: 1;
}

.reading-row span {
  color: var(--muted);
  font-weight: 700;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.mini-stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.mini-stats dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.chart-wrap {
  min-height: 360px;
}

#temperatureChart {
  display: block;
  width: 100%;
  min-height: 360px;
}

.empty-state {
  padding: 28px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.report-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, auto));
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}

.report-form.compact {
  grid-template-columns: minmax(180px, 240px) auto;
}

.report-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .device-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar,
  .hero,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    width: 100%;
  }

  .nav a {
    flex: 1;
    text-align: center;
  }

  .cards,
  .report-form,
  .report-form.compact,
  .device-summary {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .reading-row strong {
    font-size: 1.8rem;
  }
}
