:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-strong: #f0f4ef;
  --text: #17211a;
  --muted: #607063;
  --line: #d9e1d9;
  --accent: #19735a;
  --accent-2: #bf5a36;
  --accent-3: #3f6fb5;
  --warn: #a45f08;
  --bad: #b3261e;
  --good: #187044;
  --shadow: 0 12px 30px rgba(32, 45, 35, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #adc0b0;
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 16px 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px max(16px, calc((100vw - 1180px) / 2 + 16px));
  border-bottom: 1px solid rgba(217, 225, 217, 0.9);
  background: rgba(246, 247, 243, 0.92);
  backdrop-filter: blur(14px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.15;
}

h2 {
  font-size: 1rem;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button {
  width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
}

.controls {
  display: grid;
  gap: 10px;
  padding: 16px 0;
}

.range-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.range-button {
  min-width: 0;
  padding: 0 8px;
  font-weight: 700;
}

.range-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

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

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

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
}

.resolution-control {
  width: min(280px, 100%);
}

.status-strip,
.hero-panel,
.chart-panel,
.data-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-strip {
  display: grid;
  grid-template-columns: 1.2fr 1.3fr 0.8fr;
  gap: 1px;
  overflow: hidden;
}

.status-strip > div {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: var(--surface);
}

.status-strip strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: stretch;
  margin-top: 16px;
  padding: 18px;
}

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

.current-metric,
.score-box,
.insight-card {
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 14px;
}

.current-metric {
  display: grid;
  gap: 6px;
  min-height: 86px;
}

.current-metric span,
.score-box span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.current-metric strong {
  font-size: 1.45rem;
  line-height: 1.1;
}

.score-box {
  min-width: 148px;
  display: grid;
  align-content: center;
  gap: 8px;
  text-align: center;
}

.score-box strong {
  font-size: 2.25rem;
  line-height: 1;
}

.score-good {
  color: var(--good);
}

.score-warn {
  color: var(--warn);
}

.score-bad {
  color: var(--bad);
}

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

.insight-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.insight-card strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.insight-card p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.chart-panel {
  min-width: 0;
  padding: 14px;
}

.chart-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.chart-title span {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

canvas {
  width: 100%;
  max-width: 100%;
  height: 220px;
  display: block;
}

#tempHumidityChart {
  height: 260px;
}

.data-section {
  margin-top: 16px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-size: 0.9rem;
}

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

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

dialog {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 26px 80px rgba(18, 27, 20, 0.24);
}

dialog::backdrop {
  background: rgba(12, 18, 14, 0.45);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 0 16px 16px;
}

.settings-form .section-heading {
  padding-inline: 0;
}

.settings-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

menu button[value="default"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  main {
    padding-inline: 12px;
  }

  .status-strip,
  .hero-panel,
  .chart-grid {
    grid-template-columns: 1fr;
  }

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

  .score-box {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding-block: 12px;
  }

  h1 {
    font-size: 1.22rem;
  }

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

  .custom-range,
  .current-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .current-metric {
    min-height: 72px;
  }
}
