/* =============================================================================
   【文件说明】温度监测网页的样式表（深色主题，无预处理器）

   在整条链路里的位置：index.html 负责结构，app.js 负责数据/画布，本文件只负责外观。
   所有颜色/圆角/字体先集中在 :root 的 CSS 变量里，下面按页面分区组织：
     :root        设计变量（配色、圆角、字体、阴影）
     全局/背景     reset、body 渐变、body::before/::after 网格与噪点、.ambient 光斑
     top bar      品牌、刷新按钮、在线状态灯
     hero         CH1..CH6 六张实时数值卡、右侧圆环、设备/更新时间
     stats        按通道的最低/最高/平均统计表
     panels       通用面板 + 曲线面板（canvas、空状态、tooltip、可点击图例）
     lower grid   最近读数表格 + 数据链路
     footer       页脚
     responsive   1040/760/520px 三档响应式 + 减少动画偏好

    通道色：.channel-card / .legend-item / .stats-table tr 都带 data-channel，
    app.js 在启动时把颜色写进它们的 --ch-color 变量；本文件只引用变量，
    不在样式里重复写 6 个色值。
   ============================================================================= */
:root {
  --bg: #071014;
  --bg-soft: #0a151b;
  --surface: rgba(15, 27, 34, 0.78);
  --surface-solid: #0e1b22;
  --surface-raised: rgba(22, 38, 46, 0.86);
  --line: rgba(154, 190, 198, 0.13);
  --line-strong: rgba(154, 190, 198, 0.22);
  --text: #e9f2f3;
  --muted: #8aa3a9;
  --muted-strong: #b5c8cc;
  --teal: #5eead4;
  --teal-strong: #2dd4bf;
  --teal-soft: rgba(94, 234, 212, 0.1);
  --amber: #fbbf24;
  --rose: #fb7185;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono",
    monospace;
}

/* ---- 全局重置与背景 ----
   box-sizing 统一；body 用两层渐变做底色；
   body::before 画淡网格、body::after 叠一层噪点，两者都是 fixed + pointer-events:none，
   只做氛围，不接收鼠标事件。 */
* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(ellipse 80% 55% at 50% -12%, rgba(45, 212, 191, 0.13), transparent 64%),
    linear-gradient(155deg, #071014 0%, #081218 45%, #071015 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(146, 184, 192, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(146, 184, 192, 0.14) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 75%);
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

svg {
  display: block;
}

/* ---- 背景光斑 ----
   两团大半径模糊色块：teal 在顶部、amber 在右侧，给纯深色背景增加层次；
   z-index:0 位于内容之下，pointer-events:none 不影响点击。 */
.ambient {
  position: fixed;
  z-index: 0;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(100px);
  opacity: 0.32;
}

.ambient--teal {
  top: -220px;
  left: 42%;
  background: rgba(45, 212, 191, 0.2);
}

.ambient--amber {
  top: 46%;
  right: -360px;
  background: rgba(251, 191, 36, 0.12);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 64px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

/* ---- 顶栏：品牌、刷新按钮、状态灯 ----
   状态灯颜色由 app.js 切换的 status--online/delayed/offline/waiting 类决定。 */
/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 2px 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 45px;
  height: 45px;
  color: var(--teal);
  border: 1px solid rgba(94, 234, 212, 0.24);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(94, 234, 212, 0.15), rgba(94, 234, 212, 0.025)),
    rgba(10, 24, 29, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  place-items: center;
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-copy strong {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand-copy small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--muted-strong);
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(15, 27, 34, 0.6);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
  place-items: center;
}

.icon-button:hover {
  color: var(--teal);
  border-color: rgba(94, 234, 212, 0.28);
  background: rgba(94, 234, 212, 0.06);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button.is-spinning svg {
  animation: spin 700ms linear infinite;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted-strong);
  font-size: 12.5px;
  font-weight: 560;
  letter-spacing: 0.01em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 27, 34, 0.64);
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(138, 163, 169, 0.06);
}

.status--online {
  color: #baf7e9;
  border-color: rgba(94, 234, 212, 0.25);
  background: rgba(45, 212, 191, 0.08);
}

.status--online .status-dot {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.1), 0 0 12px rgba(94, 234, 212, 0.8);
  animation: breathe 2.2s ease-in-out infinite;
}

.status--delayed {
  color: #fde7ac;
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.075);
}

.status--delayed .status-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.09);
}

.status--offline {
  color: #ffc2cb;
  border-color: rgba(251, 113, 133, 0.24);
  background: rgba(251, 113, 133, 0.075);
}

.status--offline .status-dot {
  background: var(--rose);
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.08);
}

/* ---- Hero：6 张实时卡片与装饰圆环 ----
   六张卡排成 3×2；数字用等宽 + tabular-nums，跳动时宽度不变；
   每张卡顶部的色线由 --ch-color 控制，与曲线、图例共用同一套调色板。
   圆环的旋转/呼吸动画定义在文件末尾的 @keyframes 里。 */
/* ---------- hero ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  align-items: center;
  min-height: 292px;
  padding: 34px 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 78% 20%, rgba(94, 234, 212, 0.1), transparent 33%),
    linear-gradient(120deg, rgba(18, 35, 42, 0.94), rgba(10, 20, 26, 0.9));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.hero::before {
  position: absolute;
  top: 0;
  left: 38px;
  width: 180px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, var(--teal), transparent);
  opacity: 0.7;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.live-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 5px;
  background: rgba(94, 234, 212, 0.07);
}

/* ---- 实时通道卡片 ----
   3×2 网格；每张卡的颜色由 app.js 写进 --ch-color。
   温度用 tabular-nums，数字跳动时宽度不变，避免六张卡左右抖动。 */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 5px;
}

.channel-card {
  position: relative;
  min-width: 0;
  padding: 10px 13px 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008) 72%),
    rgba(7, 18, 24, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: opacity 180ms ease, border-color 180ms ease;
}

.channel-card::before {
  position: absolute;
  top: 0;
  right: 14px;
  left: 14px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, var(--ch-color, var(--teal)), transparent 82%);
  opacity: 0.72;
}

.channel-card.is-empty {
  opacity: 0.58;
}

/* 单通道掉线：有历史读数但超过 CHANNEL_OFFLINE_MS（见 app.js）没有新数据。
   温度不再显示旧值；虚线和灰点用于和“从未有数据”的 is-empty 区分。 */
.channel-card.is-offline {
  opacity: 0.72;
  border-style: dashed;
}

.channel-card.is-offline .channel-temp {
  color: var(--muted);
}

.channel-card.is-offline .channel-dot {
  background: var(--muted);
  box-shadow: none;
}

.channel-card.is-offline .channel-age {
  color: #ffc2cb;
}

.channel-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.channel-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ch-color, var(--teal));
  box-shadow: 0 0 8px var(--ch-color, var(--teal));
}

.channel-name {
  color: var(--muted-strong);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.channel-age {
  margin-left: auto;
  color: #70888e;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.channel-reading {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 4px;
}

.channel-temp {
  color: var(--text);
  font-size: clamp(27px, 2.6vw, 35px);
  font-weight: 320;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.channel-unit {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.channel-card.is-empty .channel-temp {
  color: var(--muted);
}

.hero-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 17px;
  color: var(--muted);
  font-size: 13px;
}

.device-chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  color: var(--muted-strong);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
}

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

.hero-orbit {
  position: relative;
  display: grid;
  width: 214px;
  height: 214px;
  margin-left: auto;
  place-items: center;
}

.orbit {
  position: absolute;
  border-radius: 50%;
}

.orbit--outer {
  inset: 0;
  border: 1px solid rgba(94, 234, 212, 0.13);
  background: radial-gradient(circle, rgba(94, 234, 212, 0.035), transparent 68%);
}

.orbit--outer::before,
.orbit--outer::after {
  position: absolute;
  width: 5px;
  height: 5px;
  content: "";
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 10px rgba(94, 234, 212, 0.75);
}

.orbit--outer::before {
  top: 15px;
  right: 40px;
}

.orbit--outer::after {
  bottom: 25px;
  left: 27px;
  opacity: 0.5;
}

.orbit--inner {
  inset: 30px;
  border: 1px dashed rgba(94, 234, 212, 0.18);
  animation: spin 38s linear infinite;
}

.orbit-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 118px;
  height: 118px;
  border: 1px solid rgba(94, 234, 212, 0.16);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(94, 234, 212, 0.12), transparent 60%),
    rgba(6, 18, 22, 0.66);
  box-shadow: inset 0 0 30px rgba(45, 212, 191, 0.05), 0 0 50px rgba(45, 212, 191, 0.03);
}

.orbit-value {
  color: var(--teal);
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.orbit-unit {
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.orbit-caption {
  position: absolute;
  bottom: -5px;
  left: 50%;
  padding: 3px 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  background: #101f26;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* ---- 通道统计面板 ----
   一个宽面板 + 6 行表格：通道 / 最低 / 最高 / 平均 / 采样点。
   表格沿用下方“最近读数”的视觉语言，行首色点与卡片/曲线同色。 */
/* ---------- stats ---------- */
.stats-panel {
  margin-top: 14px;
  padding: 21px 24px 14px;
}

.stats-scroll {
  margin-top: 7px;
}

.stats-table th,
.stats-table td {
  padding: 9px 10px;
}

.stats-table th:first-child,
.stats-table td:first-child {
  padding-left: 4px;
}

.stats-table td {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.stat-channel {
  color: var(--muted-strong);
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 560;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.stat-channel .channel-dot {
  margin-right: 8px;
  vertical-align: 1px;
}

.stats-table .stat-count {
  color: var(--muted);
  font-size: 11px;
}

.stats-table tr.is-empty td:not(.stat-channel) {
  color: #5d747a;
}

.stats-table tr.is-empty .channel-dot {
  opacity: 0.4;
  box-shadow: none;
}

.th-unit {
  color: #5d747a;
  font-size: 8.5px;
  letter-spacing: 0.02em;
}

/* ---- 面板与曲线 ----
   .panel 是所有卡片的基础样式（半透明底 + 细边框 + 背景模糊）；
   曲线面板包含 canvas、空状态覆盖层、hover tooltip 和底部图例。 */
/* ---------- panels ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(12px);
}

.chart-panel {
  margin-top: 14px;
  padding: 24px 24px 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}

.panel-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.panel-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(5, 14, 18, 0.46);
}

.segmented button {
  height: 27px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 540;
  cursor: pointer;
  border: 0;
  border-radius: 6px;
  background: transparent;
  transition: color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.segmented button:hover {
  color: var(--muted-strong);
}

.segmented button.is-active {
  color: #d8fff8;
  background: rgba(94, 234, 212, 0.11);
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.1);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 33px;
  padding: 0 11px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 520;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.ghost-button:hover {
  color: var(--teal);
  border-color: rgba(94, 234, 212, 0.22);
  background: rgba(94, 234, 212, 0.045);
}

.ghost-button svg {
  width: 14px;
  height: 14px;
}

.chart-wrap {
  position: relative;
  height: 346px;
  margin-top: 20px;
}

#chart {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
  background: radial-gradient(circle at 50% 46%, rgba(7, 16, 20, 0.72), rgba(7, 16, 20, 0.2) 54%, transparent 74%);
}

.chart-empty[hidden] {
  display: none;
}

.chart-empty strong {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 560;
}

.chart-empty span:last-child {
  font-size: 11px;
}

.empty-mark {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 7px;
  color: rgba(94, 234, 212, 0.55);
  border: 1px solid rgba(94, 234, 212, 0.14);
  border-radius: 50%;
  background: rgba(94, 234, 212, 0.04);
  place-items: center;
}

.empty-mark svg {
  width: 21px;
  height: 21px;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 124px;
  padding: 8px 11px;
  pointer-events: none;
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 9px;
  background: rgba(8, 19, 24, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
  transform: translate(-50%, calc(-100% - 14px));
  backdrop-filter: blur(8px);
}

.tooltip-time {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  white-space: nowrap;
}

.tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

.tooltip-row .channel-dot {
  width: 6px;
  height: 6px;
}

.tooltip-channel {
  min-width: 25px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.04em;
}

.tooltip-value {
  margin-left: auto;
  color: var(--ch-color, var(--teal));
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}

.chart-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 9px 18px;
  padding-top: 9px;
  color: #70888e;
  font-size: 10.5px;
  border-top: 1px solid rgba(154, 190, 198, 0.07);
}

.chart-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  color: var(--muted-strong);
  font: inherit;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 540;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease,
    opacity 140ms ease;
}

.legend-item:hover {
  color: var(--text);
  border-color: var(--ch-color, var(--line-strong));
  background: rgba(255, 255, 255, 0.04);
}

.legend-item.is-off {
  color: #5d747a;
  opacity: 0.55;
  text-decoration: line-through;
}

.legend-item.is-empty:not(.is-off) {
  opacity: 0.65;
}

.legend-swatch {
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: var(--ch-color, var(--teal));
}

.legend-item.is-off .legend-swatch {
  background: #546a70;
}

/* ---- 下半区：最近读数表格 + 数据链路 ----
   左宽右窄的两列网格；表格容器可横向滚动，窄屏不会把页面撑破。 */
/* ---------- lower grid ---------- */
.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.8fr);
  gap: 14px;
  margin-top: 14px;
}

.table-panel,
.chain-panel {
  min-height: 324px;
  padding: 23px 24px 16px;
}

.panel-head--compact {
  align-items: center;
}

.tiny-status {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 7px;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  border: 1px solid rgba(94, 234, 212, 0.16);
  border-radius: 5px;
  background: rgba(94, 234, 212, 0.05);
}

.table-scroll {
  margin-top: 12px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  padding: 8px 7px;
  color: #6f888e;
  font-size: 9.5px;
  font-weight: 550;
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(154, 190, 198, 0.09);
}

td {
  padding: 10px 7px;
  color: var(--muted-strong);
  border-bottom: 1px solid rgba(154, 190, 198, 0.065);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.time-cell {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.channel-cell {
  color: var(--muted-strong);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

td.channel-cell .channel-dot {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  vertical-align: 1px;
}

td.device-cell {
  color: #8da6ab;
  font-family: var(--mono);
  font-size: 10.5px;
}

td.temp-cell {
  color: #d9f4ef;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.temp-cell span {
  color: #668086;
  font-size: 9.5px;
}

.align-right {
  text-align: right;
}

.table-empty td {
  padding: 48px 0;
  color: #6f888e;
  font-size: 12px;
  text-align: center;
}

.chain {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 17px 0 0;
  padding: 0;
  list-style: none;
}

.chain li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
}

.chain li:not(:last-child)::after {
  position: absolute;
  top: 34px;
  bottom: -7px;
  left: 13px;
  width: 1px;
  content: "";
  background: linear-gradient(to bottom, rgba(94, 234, 212, 0.18), rgba(94, 234, 212, 0.03));
}

.chain-icon {
  display: grid;
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 9px;
  border: 1px solid rgba(94, 234, 212, 0.17);
  border-radius: 7px;
  background: rgba(94, 234, 212, 0.045);
  place-items: center;
}

.chain div {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.chain strong {
  color: var(--muted-strong);
  font-size: 11.5px;
  font-weight: 560;
}

.chain small {
  color: #6d858b;
  font-size: 10px;
}

.chain-tag {
  flex: 0 0 auto;
  padding: 2px 5px;
  color: #789197;
  font-family: var(--mono);
  font-size: 8.5px;
  border: 1px solid rgba(154, 190, 198, 0.11);
  border-radius: 4px;
}

.chain-foot {
  margin: 12px 0 0;
  padding-top: 12px;
  color: #657e84;
  font-size: 10px;
  border-top: 1px solid rgba(154, 190, 198, 0.065);
}

/* ---- 页脚 ---- */
/* ---------- footer ---------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 25px 0 0;
  color: #61787e;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
}

.footer-sep {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #4b6267;
}

/* ---- 响应式 ----
   1040px：下半区改单列、统计/曲线面板收紧；
   760px：顶栏/面板间距收紧，通道卡片改两列，图表高度降低；
   520px：手机竖屏，卡片/字号和留白再缩一档；
   最后 prefers-reduced-motion 在系统开启“减少动态效果”时关掉动画。 */
/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .shell {
    width: min(100% - 40px, 980px);
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) 190px;
  }

  .hero-orbit {
    width: 184px;
    height: 184px;
  }

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

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

  .chain li:nth-child(2)::after {
    display: none;
  }
}

@media (max-width: 760px) {
  .shell {
    width: calc(100% - 28px);
    padding-top: 16px;
  }

  .topbar {
    padding-bottom: 17px;
  }

  .brand-copy small {
    font-size: 9px;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) 116px;
    min-height: 238px;
    padding: 28px 23px;
  }

  .hero-orbit {
    width: 112px;
    height: 112px;
  }

  .orbit--inner {
    inset: 18px;
  }

  .orbit-core {
    width: 68px;
    height: 68px;
  }

  .orbit-value {
    font-size: 15px;
  }

  .orbit-unit,
  .orbit-caption {
    display: none;
  }

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

  .channel-card {
    padding: 9px 11px 8px;
  }

  .channel-temp {
    font-size: 28px;
  }

  .stats-panel {
    margin-top: 10px;
    padding: 18px 16px 12px;
  }

  .stats-table th,
  .stats-table td {
    padding: 8px 7px;
  }

  .chart-panel {
    margin-top: 10px;
    padding: 20px 15px 13px;
  }

  .panel-head {
    flex-direction: column;
    gap: 13px;
  }

  .panel-tools {
    width: 100%;
    justify-content: space-between;
  }

  .chart-wrap {
    height: 300px;
    margin-top: 13px;
  }

  .lower-grid {
    gap: 10px;
    margin-top: 10px;
  }

  .table-panel,
  .chain-panel {
    min-height: auto;
    padding: 20px 16px 14px;
  }

  .chart-footer {
    font-size: 9.5px;
  }

  .footer {
    flex-wrap: wrap;
    padding-top: 19px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: calc(100% - 22px);
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .brand-mark svg {
    width: 21px;
    height: 21px;
  }

  .brand-copy strong {
    font-size: 16px;
  }

  .brand-copy small {
    max-width: 176px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-button {
    display: none;
  }

  .status {
    min-height: 34px;
    padding: 0 11px;
    font-size: 11.5px;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 25px 19px 23px;
  }

  .hero-orbit {
    display: none;
  }

  .channel-grid {
    gap: 7px;
  }

  .channel-card {
    padding: 9px 10px 8px;
  }

  .channel-name {
    font-size: 9.5px;
  }

  .channel-age {
    font-size: 8px;
  }

  .channel-temp {
    font-size: 26px;
  }

  .hero-meta {
    margin-top: 12px;
    font-size: 11.5px;
  }

  .stats-panel {
    padding: 16px 12px 10px;
  }

  .stats-table th,
  .stats-table td {
    padding: 7px 5px;
  }

  .stats-table td {
    font-size: 11.5px;
  }

  .th-unit {
    display: none;
  }

  .segmented button {
    padding: 0 8px;
    font-size: 10px;
  }

  .chart-legend {
    gap: 5px;
  }

  .legend-item {
    padding: 3px 6px;
    font-size: 9px;
  }

  .legend-swatch {
    width: 10px;
  }

  .ghost-button {
    padding: 0 8px;
    font-size: 10px;
  }

  .panel-head--compact {
    flex-direction: row;
  }

  .panel-head--compact > div {
    min-width: 0;
  }

  .chart-wrap {
    height: 244px;
  }

  .chart-panel {
    padding-right: 12px;
    padding-left: 12px;
  }

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

  .chain li:nth-child(2)::after {
    display: block;
  }

  .footer {
    gap: 7px;
    font-size: 8.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- 动画关键帧 ----
   breathe：状态灯呼吸；spin：刷新按钮旋转（.is-spinning 由 app.js 添加）。 */
@keyframes breathe {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.82);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.8);
  outline-offset: 3px;
}

button,
a {
  outline-offset: 3px;
}
