:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: #0d1a2b;
  --panel-2: #101f33;
  --line: #1d3048;
  --text: #e6f0ff;
  --muted: #7f94ae;
  --cyan: #22d3ee;
  --blue: #60a5fa;
  --green: #34d399;
  --purple: #a78bfa;
  --yellow: #fbbf24;
  --red: #fb7185;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 80% -10%, rgba(34, 211, 238, .1), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans Thai", "DejaVu Sans", system-ui, sans-serif;
}

.site-header, main, footer {
  width: min(1440px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px 0 18px;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 3vw, 2.75rem); letter-spacing: .08em; text-transform: uppercase; }
h2 { font-size: clamp(1.05rem, 1.8vw, 1.35rem); }

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.eyebrow.cyan { color: #7dd3fc; }
.eyebrow.green { color: var(--green); }
.eyebrow.purple { color: var(--purple); }
.subtitle, .muted { color: var(--muted); }
.subtitle { margin-top: 3px; font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }

.header-status {
  display: grid;
  justify-items: end;
  gap: 8px;
  color: var(--muted);
  font-size: .82rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(13, 26, 43, .88);
  font-size: .78rem;
  font-weight: 800;
}

.badge i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.online { color: var(--green); border-color: #155e52; }
.badge.offline { color: var(--red); border-color: #6b2637; }
.badge.waiting { color: var(--yellow); }

main { display: grid; gap: 14px; padding-bottom: 24px; }

.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(16, 31, 51, .96), rgba(10, 23, 39, .98));
  box-shadow: 0 14px 40px rgba(0, 0, 0, .14);
}

.location-strip {
  display: grid;
  grid-template-columns: repeat(3, max-content) 1fr;
  align-items: center;
  gap: 32px;
  padding: 13px 18px;
}

.location-strip > div { display: grid; gap: 3px; }
.label, .index-grid span, .eci-breakdown span {
  color: var(--muted);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .1em;
}

.privacy-note { justify-self: end; color: #60748e; font-size: .75rem; }
.acoustic, .trend-card, .audio-card, .eci-card { padding: 18px; }

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

.compact-heading { margin: 4px 2px 10px; }

.index-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.index-grid article {
  display: grid;
  gap: 3px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(7, 17, 31, .45);
}

.index-grid strong { color: var(--cyan); font-size: 1.55rem; }
.index-grid article:nth-child(2) strong { color: var(--green); }
.index-grid article:nth-child(3) strong { color: var(--yellow); }
.index-grid article:nth-child(4) strong { color: var(--red); }

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

.sensor-card {
  position: relative;
  min-height: 132px;
  overflow: hidden;
  padding: 16px;
}

.sensor-card::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -40px;
  width: 120px;
  height: 120px;
  border: 18px solid color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 50%;
}

.sensor-title { color: #9fb2ca; font-size: .72rem; font-weight: 800; letter-spacing: .07em; }
.sensor-value { display: block; margin-top: 14px; font-size: 1.8rem; line-height: 1; }
.sensor-unit { margin-left: 5px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.sensor-state { display: flex; align-items: center; gap: 7px; margin-top: 15px; color: var(--muted); font-size: .68rem; font-weight: 800; }
.sensor-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.sensor-card.online .sensor-state { color: var(--green); }
.sensor-card.online .sensor-state i { background: var(--green); }

.analytics-grid { display: grid; grid-template-columns: .82fr 1.18fr; gap: 14px; }
.eci-score { font-size: 2rem; color: var(--green); }
.progress { height: 11px; margin: 16px 0; overflow: hidden; border-radius: 999px; background: #182942; }
.progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--green)); transition: width .35s ease; }
.eci-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.eci-breakdown div { display: grid; gap: 3px; padding: 9px; border-radius: 9px; background: rgba(7, 17, 31, .46); }
.eci-breakdown strong { font-size: 1.1rem; }

.audio-numbers { display: grid; justify-items: end; gap: 3px; }
.audio-numbers strong { color: var(--cyan); font-size: 1.25rem; }
.audio-numbers span { color: var(--muted); font-size: .74rem; }

.spectrum {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 9px;
  height: 170px;
  padding-top: 8px;
}

.band { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 7px; }
.band-track { display: flex; align-items: end; overflow: hidden; border-radius: 7px; background: #18263b; }
.band-fill { width: 100%; min-height: 3px; border-radius: 7px 7px 0 0; background: linear-gradient(0deg, var(--cyan), var(--green) 64%, var(--yellow) 84%, var(--red)); transition: height .18s ease; }
.band label { color: var(--muted); font-size: .63rem; font-weight: 800; text-align: center; }

.trend-card canvas { display: block; width: 100%; height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: .72rem; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 3px; border-radius: 3px; background: var(--cyan); }
.legend i.soil { background: var(--green); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 28px;
  color: #60748e;
  font-size: .72rem;
}

@media (max-width: 900px) {
  .sensor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-grid { grid-template-columns: 1fr; }
  .location-strip { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .privacy-note { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 620px) {
  .site-header { align-items: flex-start; }
  .header-status { justify-items: start; }
  .site-header, footer { flex-direction: column; }
  .subtitle { max-width: 28ch; line-height: 1.5; }
  .index-grid { grid-template-columns: repeat(2, 1fr); }
  .sensor-grid { grid-template-columns: 1fr; }
  .location-strip { grid-template-columns: 1fr 1fr; }
  .location-strip > div:first-child { grid-column: 1 / -1; }
  .section-heading { align-items: flex-start; }
  .audio-card .section-heading { flex-direction: column; }
  .audio-numbers { justify-items: start; }
  .spectrum { gap: 5px; height: 150px; }
  .band label { font-size: .53rem; }
}
