:root {
  color-scheme: dark;
  --bg: #0b1016;
  --surface: #111923;
  --surface-raised: #16202d;
  --surface-soft: #0d151f;
  --line: rgba(148, 170, 195, .13);
  --line-strong: rgba(148, 170, 195, .22);
  --text: #e8eef6;
  --muted: #8b9ab0;
  --subtle: #627388;
  --accent: #72aaff;
  --temp: #ff805c;
  --hum: #55a4ff;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  padding: 28px clamp(16px, 3vw, 36px) 32px;
  background:
    radial-gradient(ellipse at 14% -10%, rgba(55, 105, 160, .14), transparent 40%),
    radial-gradient(ellipse at 88% 0%, rgba(85, 164, 255, .06), transparent 35%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page-shell {
  width: min(100%, 1060px);
  margin: 0 auto;
}

/* 顶部栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand { display: flex; align-items: center; gap: 13px; }

.brand-mark {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(114, 170, 255, .25);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(77, 139, 218, .22), rgba(77, 139, 218, .06));
}
.brand-mark span {
  display: block;
  width: 5px;
  border-radius: 5px;
  background: var(--accent);
}
.brand-mark span:first-child { height: 13px; opacity: .65; }
.brand-mark span:last-child { height: 21px; }

.eyebrow {
  margin: 0 0 3px;
  color: var(--subtle);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .15em;
}
h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -.025em;
}
h1 span {
  margin-left: 5px;
  color: #aab8c9;
  font-size: 17px;
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}
.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #48c99a;
  box-shadow: 0 0 0 4px rgba(72, 201, 154, .1), 0 0 12px rgba(72, 201, 154, .35);
}
.status {
  color: inherit;
  font-size: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.refresh-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(114, 170, 255, .42);
  border-radius: 9px;
  background: linear-gradient(180deg, #78b0ff, #5798f1);
  color: #071321;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(53, 126, 220, .18);
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
}
.refresh-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.refresh-button:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 16px rgba(53, 126, 220, .28);
}
.refresh-button:active { transform: translateY(1px); }
.refresh-button:focus-visible {
  outline: 3px solid rgba(114, 170, 255, .32);
  outline-offset: 2px;
}

/* 通用卡片容器 */
.panel {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(22, 32, 45, .98), rgba(15, 23, 33, .98));
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 顶部三卡：左侧查询参数，右侧温度、湿度等大 */
.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 16px;
  align-items: stretch;
}

.config-card,
.metric-card {
  display: flex;
  flex-direction: column;
  padding: 16px 18px 14px;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-title {
  color: #a8b6c8;
  font-size: 12px;
  font-weight: 600;
}

.card-tag {
  color: var(--subtle);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
}

.config-rows {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: auto 0;
}

.config-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}

.field > span { flex: 0 0 auto; }

.config-card select,
.config-card input:not([type="checkbox"]) {
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
  background-color: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.config-card select {
  min-width: 112px;
  padding: 0 22px 0 9px;
}

.config-card input[type="datetime-local"] {
  min-width: 0;
  padding: 0 8px;
  font-size: 11px;
}

.config-card input[type="number"] {
  width: 64px;
  padding: 0 8px;
}

.config-card select:hover,
.config-card input:not([type="checkbox"]):hover {
  border-color: rgba(114, 170, 255, .42);
}

.config-card select:focus,
.config-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(114, 170, 255, .12);
}

.check-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  cursor: pointer;
  user-select: none;
}

.check-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.custom-check {
  width: 15px;
  height: 15px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-soft);
}

.check-control input:checked + .custom-check {
  border-color: var(--accent);
  background: var(--accent);
}

.check-control input:checked + .custom-check::after {
  content: "";
  width: 6px;
  height: 3.5px;
  margin-top: -2px;
  border: solid #081321;
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}

.check-control input:focus-visible + .custom-check {
  outline: 3px solid rgba(114, 170, 255, .25);
}

/* 温湿度卡片 */
.metric-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  content: "";
  opacity: .92;
}
.temperature-card::before { background: var(--temp); }
.humidity-card::before { background: var(--hum); }

.metric-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}
.temperature-card .metric-icon { color: var(--temp); background: rgba(255, 128, 92, .12); }
.humidity-card .metric-icon { color: var(--hum); background: rgba(85, 164, 255, .12); }

.metric-reading {
  margin: auto 0;
  padding-top: 2px;
}

.card-value {
  display: inline-flex;
  align-items: baseline;
  font-size: clamp(30px, 2.8vw, 38px);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.card-value.temp { color: var(--temp); }
.card-value.hum { color: var(--hum); }
.card-value .unit {
  margin-left: 5px;
  color: inherit;
  opacity: .88;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  color: var(--subtle);
  font-size: 10px;
}
.metric-indicator { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.temperature-card .metric-indicator { color: var(--temp); }
.humidity-card .metric-indicator { color: var(--hum); }

/* 图表面板 */
.chart-panel {
  padding: 18px 18px 12px;
  background: linear-gradient(145deg, rgba(18, 27, 38, .98), rgba(15, 23, 33, .98));
}

.chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 2px 10px;
}
.chart-heading h2 {
  margin: 0;
  color: #e2eaf4;
  font-size: 16px;
  font-weight: 620;
  letter-spacing: -.015em;
}
.chart-heading .eyebrow { margin-bottom: 2px; }

.chart-key {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 11px;
}
.chart-key span { display: inline-flex; align-items: center; gap: 7px; }
.key-dot, .footer-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.temp-key { background: var(--temp); }
.hum-key { background: var(--hum); }

#chart { width: 100%; min-height: 250px; }
#chart .u-legend { margin-top: 4px; color: var(--muted); font-size: 11px; }
#chart .u-legend th { color: #9aabbe; font-weight: 550; }
#chart .u-legend td { padding: 3px 5px; }
#chart .u-legend .u-series { white-space: nowrap; }
#chart .u-legend .u-value { color: #dce6f2; font-variant-numeric: tabular-nums; }
#chart .u-axis { color: var(--muted); }
#chart .u-over { cursor: crosshair; }

.empty {
  margin: 0;
  padding: 72px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.hidden { display: none !important; }

/* 页脚 */
.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 2px 0;
  color: var(--subtle);
  font-size: 10px;
  letter-spacing: .02em;
}
.page-footer > span:last-child { display: inline-flex; align-items: center; gap: 6px; }
.footer-dot { width: 6px; height: 6px; }

@media (max-width: 900px) {
  body { padding-top: 22px; }
  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .config-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  body { padding: 16px 12px 24px; }
  .topbar { margin-bottom: 16px; }
  h1 { font-size: 18px; }
  h1 span { font-size: 15px; }
  .brand-mark { width: 34px; height: 34px; }
  .status-wrap { max-width: 130px; font-size: 11px; }
  .config-card,
  .metric-card { padding: 14px; }
  .config-card select { flex: 1 1 auto; min-width: 96px; }
  .overview-grid { gap: 10px; }
  .card-value { font-size: 30px; }
  .chart-panel { padding: 14px 8px 10px; }
  .chart-heading { padding: 0 6px; }
  .chart-key { gap: 10px; font-size: 10px; }
  .page-footer { font-size: 9px; }
}