:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #647283;
  --line: #d9e1e8;
  --green: #1c9b62;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --ink: #111827;
  --shadow: 0 10px 30px rgba(25, 36, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

select {
  font: inherit;
  letter-spacing: 0;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

.settings {
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(190px, 260px) minmax(140px, 190px) minmax(140px, 190px);
  gap: 10px;
  align-items: end;
  justify-content: end;
}

.settings label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.settings input,
.settings select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
}

.settings button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  min-width: 78px;
}

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

.settings button.danger {
  color: var(--red);
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

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

.hero-panel {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(420px, 1.2fr);
  gap: 18px;
  padding: 20px;
  margin-bottom: 18px;
}

.soc-block {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.soc-ring {
  --soc: 0;
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--green) calc(var(--soc) * 1%), #dce4eb 0);
}

.soc-ring > div {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
}

.soc-ring span {
  font-size: 27px;
  font-weight: 800;
}

.soc-ring small {
  margin-top: -24px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.status-pill.ok {
  color: #0f6b43;
  background: #dff5e9;
}

.status-pill.warn {
  color: #8a4b00;
  background: #fff0cc;
}

.status-pill.bad {
  color: #991b1b;
  background: #fee2e2;
}

.status-pill.neutral {
  color: #455568;
  background: #e7edf3;
}

#deviceTitle {
  font-size: 20px;
  word-break: break-word;
}

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

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

.hero-grid article {
  min-height: 106px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  align-content: space-between;
}

.hero-grid span,
.panel-head span {
  color: var(--muted);
  font-size: 13px;
}

.hero-grid strong {
  font-size: 24px;
  word-break: break-word;
}

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

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

.panel.wide {
  grid-column: 1 / -1;
}

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

.panel-head h3 {
  font-size: 17px;
}

.metric-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.metric-list div {
  display: grid;
  grid-template-columns: minmax(86px, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.metric-list div:first-child {
  border-top: 0;
}

.metric-list dt {
  color: var(--muted);
}

.metric-list dd {
  margin: 0;
  font-weight: 700;
  word-break: break-word;
}

.metric-list.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-list.compact div {
  grid-template-columns: 1fr;
}

canvas {
  width: 100%;
  display: block;
}

.temp-bars {
  display: grid;
  gap: 9px;
}

.temp-row {
  display: grid;
  grid-template-columns: 44px 1fr 52px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.temp-track {
  height: 10px;
  border-radius: 999px;
  background: #e5ebf1;
  overflow: hidden;
}

.temp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--amber));
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .topbar,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 120px;
  }

  .hero-grid,
  .content-grid,
  .metric-list.compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  h1 {
    font-size: 24px;
  }

  .soc-block {
    align-items: flex-start;
  }

  .soc-ring {
    width: 104px;
    height: 104px;
  }

  .soc-ring > div {
    width: 76px;
    height: 76px;
  }

  .soc-ring span {
    font-size: 21px;
  }

  .hero-grid strong {
    font-size: 21px;
  }
}
