/* ===========================================================================
   物联网云监测系统 · 全站样式
   ---------------------------------------------------------------------------
   本轮为界面重构：只换视觉，不改类名。
   `templates/*.html` 共 17 个模板共用本文件，历史上用到的每一个类名都必须
   继续存在且有合理表现，否则会出现「有的页面对、有的页面裸奔」。

   设计令牌来自 ui-design-proposal.html / ui-prototype.html：
     · 主色 #2563EB（品牌蓝），强调 #14B8A6（青）
     · 语义色 成功 #16A34A / 警告 #D97706 / 危险 #DC2626 / 信息 #0EA5E9
     · 中性色 侧栏 #0F172A、正文 #0F172A、次级 #475569、提示 #94A3B8
     · 间距 4px 基础栅格；圆角 8px（组件）/ 12px（卡片）/ 16px（大容器）
     · 字重只用 400 / 500 两档
   =========================================================================== */

/* ---------------------------------------------------------------------------
   1. 设计令牌 · 浅色主题（默认）
   --------------------------------------------------------------------------- */
:root {
  /* 品牌色 */
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-ink: #1e3a8a;
  --brand-soft: #eff6ff;
  --accent: #14b8a6;
  --accent-strong: #0d9488;
  --accent-soft: #f0fdfa;

  /* 语义色 */
  --success: #16a34a;
  --success-ink: #15803d;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-ink: #b45309;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-ink: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0ea5e9;
  --info-ink: #0369a1;
  --info-soft: #f0f9ff;

  /* 中性色 */
  --bg: #f8fafc;
  --card: #ffffff;
  --card-soft: #f8fafc;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --hint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;

  /* 侧边栏（深色，深浅主题下都保持深色） */
  --sidebar: #0f172a;
  --sidebar-end: #131f36;
  --sidebar-text: #94a3b8;
  --sidebar-text-strong: #e2e8f0;
  --sidebar-line: rgba(255, 255, 255, 0.07);
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active-bg: rgba(37, 99, 235, 0.18);
  --sidebar-group: rgba(148, 163, 184, 0.62);

  /* 顶栏 */
  --topbar-bg: #ffffff;
  --topbar-border: #e2e8f0;

  /* 组件底 */
  --mono-bg: #f1f5f9;
  --secondary-btn-bg: #dbe4f0;
  --secondary-btn-hover-bg: #c9d7ea;
  --secondary-btn-border: #dbe4f0;
  --secondary-btn-text: #334155;
  /* 行内「查看详情」：琥珀底白字（用户指定）。底色压到 amber-600/700 保证白字可读。 */
  --action-warning-bg: #d97706;
  --action-warning-hover-bg: #b45309;
  --action-warning-text: #ffffff;
  --theme-btn-bg: rgba(255, 255, 255, 0.05);
  --theme-btn-border: rgba(255, 255, 255, 0.1);
  --theme-btn-active-bg: rgba(37, 99, 235, 0.24);
  --theme-btn-active-border: rgba(96, 165, 250, 0.45);

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 4px 16px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);

  /* 高亮行 / 提示底色 */
  --row-active-bg: #eff6ff;
  --overlay-bg: rgba(15, 23, 42, 0.45);

  /* 主题动作小胶囊配色：11 种，数量与后端的主题动作集合
     （RAW_TELEMETRY_TOPIC_ACTIONS）一致，模板按筛选项顺序取色即可保证不重复。 */
  --chip-red-bg: #fee2e2;
  --chip-red-fg: #b91c1c;
  --chip-orange-bg: #ffedd5;
  --chip-orange-fg: #c2410c;
  --chip-amber-bg: #fef3c7;
  --chip-amber-fg: #b45309;
  --chip-lime-bg: #ecfccb;
  --chip-lime-fg: #4d7c0f;
  --chip-green-bg: #dcfce7;
  --chip-green-fg: #15803d;
  --chip-teal-bg: #ccfbf1;
  --chip-teal-fg: #0f766e;
  --chip-cyan-bg: #cffafe;
  --chip-cyan-fg: #0e7490;
  --chip-blue-bg: #dbeafe;
  --chip-blue-fg: #1d4ed8;
  --chip-indigo-bg: #e0e7ff;
  --chip-indigo-fg: #4338ca;
  --chip-violet-bg: #ede9fe;
  --chip-violet-fg: #6d28d9;
  --chip-pink-bg: #fce7f3;
  --chip-pink-fg: #be185d;
  --chip-slate-bg: #eef2f7;
  --chip-slate-fg: #475569;

  /* 圆角与尺寸 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --sidebar-w: 248px;
  --topbar-h: 64px;

  /* 排版 */
  --font-ui: "PingFang SC", "Microsoft YaHei", "Alibaba PuHuiTi", "Segoe UI",
    -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;

  /* 过渡 */
  --t-fast: 0.15s ease;
  --t-base: 0.2s ease;
}

/* ---------------------------------------------------------------------------
   2. 设计令牌 · 深色主题
   --------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  --brand: #3b82f6;
  --brand-strong: #60a5fa;
  --brand-ink: #dbeafe;
  --brand-soft: rgba(37, 99, 235, 0.18);
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: rgba(20, 184, 166, 0.16);

  --success: #22c55e;
  --success-ink: #86efac;
  --success-soft: rgba(22, 163, 74, 0.16);
  --warning: #f59e0b;
  --warning-ink: #fcd34d;
  --warning-soft: rgba(217, 119, 6, 0.16);
  --danger: #ef4444;
  --danger-ink: #fca5a5;
  --danger-soft: rgba(220, 38, 38, 0.16);
  --info: #38bdf8;
  --info-ink: #7dd3fc;
  --info-soft: rgba(14, 165, 233, 0.16);

  --bg: #0b1220;
  --card: #111a2c;
  --card-soft: #16223a;
  --text: #e5eef8;
  --text-2: #cbd5e1;
  --muted: #8fa3bd;
  --hint: #64748b;
  --line: #22304a;
  --line-soft: #1a2740;

  --sidebar: #080d18;
  --sidebar-end: #0e1728;
  --sidebar-text: #8b9cb5;
  --sidebar-text-strong: #f1f5f9;
  --sidebar-line: rgba(255, 255, 255, 0.06);
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: rgba(37, 99, 235, 0.3);
  --sidebar-group: rgba(148, 163, 184, 0.5);

  --topbar-bg: #111a2c;
  --topbar-border: #22304a;

  --mono-bg: #16223a;
  --secondary-btn-bg: #2b3b57;
  --secondary-btn-hover-bg: #3a4d6f;
  --secondary-btn-border: #2b3b57;
  --secondary-btn-text: #e5eef8;
  --action-warning-bg: #d97706;
  --action-warning-hover-bg: #f59e0b;
  --action-warning-text: #ffffff;
  --theme-btn-bg: rgba(255, 255, 255, 0.05);
  --theme-btn-border: rgba(255, 255, 255, 0.1);
  --theme-btn-active-bg: rgba(37, 99, 235, 0.32);
  --theme-btn-active-border: rgba(96, 165, 250, 0.45);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.26);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

  --row-active-bg: rgba(37, 99, 235, 0.14);
  --overlay-bg: rgba(2, 6, 15, 0.62);

  --chip-red-bg: rgba(239, 68, 68, 0.22);
  --chip-red-fg: #fca5a5;
  --chip-orange-bg: rgba(249, 115, 22, 0.22);
  --chip-orange-fg: #fdba74;
  --chip-amber-bg: rgba(245, 158, 11, 0.22);
  --chip-amber-fg: #fcd34d;
  --chip-lime-bg: rgba(132, 204, 22, 0.22);
  --chip-lime-fg: #bef264;
  --chip-green-bg: rgba(34, 197, 94, 0.22);
  --chip-green-fg: #86efac;
  --chip-teal-bg: rgba(20, 184, 166, 0.22);
  --chip-teal-fg: #5eead4;
  --chip-cyan-bg: rgba(6, 182, 212, 0.22);
  --chip-cyan-fg: #67e8f9;
  --chip-blue-bg: rgba(59, 130, 246, 0.22);
  --chip-blue-fg: #93c5fd;
  --chip-indigo-bg: rgba(99, 102, 241, 0.22);
  --chip-indigo-fg: #a5b4fc;
  --chip-violet-bg: rgba(139, 92, 246, 0.22);
  --chip-violet-fg: #c4b5fd;
  --chip-pink-bg: rgba(236, 72, 153, 0.22);
  --chip-pink-fg: #f9a8d4;
  --chip-slate-bg: rgba(148, 163, 184, 0.18);
  --chip-slate-fg: #cbd5e1;
}

/* ---------------------------------------------------------------------------
   2.1 浅色主题专属：导航栏浅蓝色填充
   深色主题由 :root[data-theme="dark"] 控制、导航栏保持深蓝；浅色即「非 dark」时改浅蓝。
   侧边栏与顶栏统一浅蓝调，菜单文字用深蓝保证对比度。
   --------------------------------------------------------------------------- */
:root:not([data-theme="dark"]) {
  --sidebar: #c0d8ff;
  --sidebar-end: #a3c0f6;
  --sidebar-text: #1e3a8a;
  --sidebar-text-strong: #1e3a8a;
  --sidebar-line: rgba(37, 99, 235, 0.26);
  --sidebar-hover: rgba(37, 99, 235, 0.16);
  --sidebar-active-bg: rgba(37, 99, 235, 0.23);
  --sidebar-group: rgba(30, 58, 138, 0.78);
  --topbar-bg: #c0d8ff;
  --topbar-border: rgba(37, 99, 235, 0.26);
}
/* 浅蓝底上：品牌名 / 菜单项用深蓝，避免原白字看不清。 */
:root:not([data-theme="dark"]) .brand-name { color: #1e3a8a; }
:root:not([data-theme="dark"]) .menu-item { color: #1e3a8a; }
:root:not([data-theme="dark"]) .menu-item.active { color: #1e3a8a; }

/* ---------------------------------------------------------------------------
   3. 基础重置
   --------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3 {
  font-weight: 500;
}

/* 屏幕阅读器专用文本：只给辅助技术读，视觉上不占位。 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------------------
   4. 整体布局：左侧固定导航 + 右侧顶栏/内容
   --------------------------------------------------------------------------- */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
   5. 侧边栏
   --------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-end) 100%);
  color: var(--sidebar-text);
}

/* 品牌块（原 .brand，改成 logo + 名称的横向组合）。 */
.brand {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 18px;
  border-bottom: 1px solid var(--sidebar-line);
  font-size: var(--fs-base);
}

.brand-logo {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 500;
}

.brand-name {
  color: #fff;
  font-size: var(--fs-base);
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* 菜单容器：可独立滚动，底部信息区固定。 */
.menu {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 12px 8px;
}

.menu::-webkit-scrollbar {
  width: 4px;
}

.menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
}

/* 菜单分组标题（本轮新增，默认渲染成很轻的说明文字）。 */
.menu-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-group-label {
  padding: 10px 10px 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--sidebar-group);
}

/* 菜单项：图标 + 文字 + 可选角标。 */
.menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  color: var(--sidebar-text);
  font-size: var(--fs-sm);
  transition: background var(--t-fast), color var(--t-fast);
}

.menu-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
}

.menu-item.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 500;
}

/* 激活态左侧竖条：不依赖颜色也能看出当前页。 */
.menu-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand) 0%, var(--accent) 100%);
}

.menu-icon {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: 0.85;
}

.menu-item.active .menu-icon {
  opacity: 1;
}

/* 菜单角标：例如告警中心的未处理条数。 */
.menu-badge {
  margin-left: auto;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
}

/* 侧边栏底部：主题切换 + 用户信息 + 退出。 */
.sidebar-foot {
  flex: none;
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--sidebar-line);
  color: var(--sidebar-text);
}

.sidebar-user {
  font-size: var(--fs-sm);
  color: var(--sidebar-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link {
  display: inline-block;
  color: var(--sidebar-text);
  transition: color var(--t-fast);
}

.sidebar-link:hover {
  color: #fff;
}

/* 主题切换按钮组。 */
.theme-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.05);
}

.theme-btn {
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--sidebar-text);
  background: var(--theme-btn-bg);
  font-family: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.theme-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.theme-btn.active {
  color: #fff;
  font-weight: 500;
  background: var(--theme-btn-active-bg);
  border-color: var(--theme-btn-active-border);
}

.theme-btn:focus-visible {
  outline: 2px solid var(--brand-strong);
  outline-offset: 2px;
}

/* 用户行：头像 + 姓名/角色 + 退出。 */
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 500;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  display: block;
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  display: block;
  font-size: 11px;
  color: var(--sidebar-text);
}

.user-logout {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--sidebar-text);
  transition: background var(--t-fast), color var(--t-fast);
}

.user-logout:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* ---------------------------------------------------------------------------
   6. 右侧主区与顶栏
   --------------------------------------------------------------------------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
}

.topbar-heading {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1.3;
}

.topbar p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.topbar-spacer {
  flex: 1;
}

/* 顶栏右侧用户标识（避免和侧栏底部重复展示，这里只做主标识）。 */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-soft);
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.topbar-user .user-avatar {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

/* 内容滚动区。 */
.content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 24px;
}

/* ---------------------------------------------------------------------------
   7. 面板与卡片
   --------------------------------------------------------------------------- */
.panel {
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text);
}

/* 面板内相邻块之间统一 16px 竖向节奏。
   历史模板里这些块只靠各自的 margin-bottom 撑开，一旦相邻元素把 margin-top 设为 0
   就会贴在一起（新增设备表单后面的说明文字就是这样）。这里统一兜住。 */
.panel > * + * {
  margin-top: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-head .panel-hint {
  margin-bottom: 0;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 竖向间距统一由 .panel > * + * 负责，这里不再自带上下外边距。 */
.panel-hint {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.65;
}

/* 检索提示里的编码片段用等宽小片，方便逐位核对设备号。
   注意：这里必须允许换行。主题名（/keleji/rawMaterials/xxx/getinfo）很长，
   历史样式用了 white-space:nowrap，长串会横向溢出 inline-block 的 280px 上限，
   直接压在后面的文字上 —— 这是重构前就存在的显示缺陷，一并修掉。 */
.panel-hint code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--mono-bg);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  white-space: pre-wrap;
  word-break: break-all;
}

.panel-hint-warning {
  color: var(--warning-ink);
}

/* 双列面板网格，常用于总览页。 */
.panel-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  /* 🔴 栅格子项的下外边距被下面那条规则清零了，所以栅格自身必须补上和 `.panel`
     一样的 20px 下外边距 —— 否则「相邻两个栅格 section」之间是 0 间隙，两块卡片
     会严丝合缝贴在一起（2026-09-21 总览页插入第二块栅格时暴露）。
     注意：`.panel` 靠的是 margin-bottom 撑竖向节奏，栅格不能只靠内部 gap。 */
  margin-bottom: 20px;
}

.panel-grid > .panel {
  margin-bottom: 0;
}

/* 空数据占位文本。 */
.empty-state {
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------------------------------------------------------------------------
   8. KPI 指标卡（总览大屏）
   --------------------------------------------------------------------------- */
.stats-grid,
.kpi-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 20px;
}

.stat-card,
.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}

.stat-card:hover,
.kpi-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* 可点击的 KPI 卡：整卡是 <a>，补上块级显示与链接色继承；
   没有 href 的那张（非管理员的「固件数量」）不进入 Tab 顺序、也不给点击反馈。 */
a.kpi-card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}

a.kpi-card[href]:hover {
  border-color: var(--kpi-accent, var(--brand));
}

a.kpi-card[href]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

a.kpi-card:not([href]) {
  cursor: default;
}

/* 顶部 3px 色条：用 --kpi-accent 区分指标语义。 */
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--kpi-accent, var(--brand));
}

.kpi-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--kpi-soft, var(--brand-soft));
  color: var(--kpi-accent, var(--brand));
}

.kpi-label,
.stat-card > span {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.kpi-value,
.stat-card strong {
  display: block;
  margin: 0;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.4px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-value .kpi-unit,
.kpi-value .unit {
  margin-left: 3px;
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--hint);
  letter-spacing: 0;
}

.kpi-foot,
.stat-card small {
  display: block;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: var(--fs-xs);
}

/* 设备编码这类长串放不进 30px 的数字字号里，单独降到等宽小号并允许断行。 */
.stat-card strong.stat-code {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0;
  word-break: break-all;
}

/* 指标卡放进面板时不要自带外底距 —— 面板内子元素的间距统一由 .panel > * + * 负责，
   否则「卡片 + 提示」之间会出现 20px 与 16px 叠加的 36px 大缝。 */
.panel .stats-grid,
.panel .kpi-grid {
  margin-bottom: 0;
}

.trend-up {
  color: var(--success);
}

.trend-down {
  color: var(--danger);
}

/* ---------------------------------------------------------------------------
   9. 按钮
   --------------------------------------------------------------------------- */
/* 基础按钮共同样式（圆角 / 尺寸 / 对齐）。`.action-*` 也纳入：
   它们既会叠加在 secondary-btn 上（设备列表行内按钮），也经常单独使用
   （安装定位页等），必须自带圆角与尺寸，否则单独用时变直角。 */
.primary-btn,
.secondary-btn,
.danger-btn,
.success-btn,
.action-primary,
.action-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast),
    color var(--t-fast), filter var(--t-fast);
}

/* align-self:end 让按钮在 .form-grid 里和输入框底边对齐。 */
.primary-btn {
  align-self: end;
  background: var(--brand);
  color: #fff;
}

.primary-btn:hover {
  background: var(--brand-strong);
}

/* 次按钮：填充底色（不是描边白底），和主按钮形成「主蓝 / 次灰」的层级。 */
.secondary-btn {
  background: var(--secondary-btn-bg);
  border-color: var(--secondary-btn-border);
  color: var(--secondary-btn-text);
}

.secondary-btn:hover {
  background: var(--secondary-btn-hover-bg);
  border-color: var(--secondary-btn-hover-bg);
  color: var(--brand-strong);
}

/* 行内「主要动作」：在次按钮的尺寸上换主色填充，用于设备列表的「参数设置」。
   和灰底的「详情」、红底的「删除」一起构成 灰 / 蓝 / 红 三级。 */
.action-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.action-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
}

/* 行内「查看详情」：琥珀填充 + 白字（用户指定）。 */
.action-warning {
  background: var(--action-warning-bg);
  border-color: var(--action-warning-bg);
  color: var(--action-warning-text);
}

.action-warning:hover {
  background: var(--action-warning-hover-bg);
  border-color: var(--action-warning-hover-bg);
  color: var(--action-warning-text);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
}

.danger-btn:hover {
  filter: brightness(0.92);
}

/* 绿色按钮：绿底白字，用于「生成设备标签」这类正向操作，与 蓝主/灰次/红险 并列。 */
.success-btn {
  background: var(--success);
  color: #fff;
}

.success-btn:hover {
  filter: brightness(0.92);
  color: #fff;
}

.secondary-btn.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.danger-btn:focus-visible,
.success-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   10. 表单
   --------------------------------------------------------------------------- */
.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid.two {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  color: var(--text);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

textarea {
  height: auto;
  min-height: 88px;
  padding: 9px 11px;
  line-height: 1.6;
}

input::placeholder,
textarea::placeholder {
  color: var(--hint);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

input:disabled,
select:disabled {
  background: var(--card-soft);
  color: var(--muted);
}

/* 表单底部操作区。 */
.filter-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

/* 操作按钮行直接跟在字段区后面时补一段间距：作为 form-grid 的格子时由 gap 负责，
   作为兄弟节点时两者之间没有任何容器撑开，按钮会贴到输入框上。 */
.form-grid + .filter-actions {
  margin-top: 16px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 单按钮内联表单：保持 flex 让模板里写的 gap / flex-wrap 生效。 */
.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
}

.command-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.command-input {
  flex: 1 1 640px;
}

.command-bar .primary-btn {
  align-self: center;
}

.inline-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-fields input {
  width: auto;
  min-width: 120px;
}

/* 个人设置页：表单底部操作条（角色标签 + 保存按钮）。 */
.form-grid .form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.role-tag {
  font-size: 13px;
  line-height: 1;
  color: var(--text-2);
  background: var(--card-soft, #f8fafc);
  border: 1px solid var(--line, #e2e8f0);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.inline-fields label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------------------
   11. 表格
   --------------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.table-scroll::-webkit-scrollbar {
  height: 8px;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: var(--fs-sm);
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: var(--fs-xs);
  white-space: nowrap;
  background: var(--card-soft);
  border-bottom-color: var(--line);
}

td {
  color: var(--text-2);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background var(--t-fast);
}

tbody tr:hover td {
  background: var(--card-soft);
}

/* 可点击查看详情的行。 */
tr.row-clickable {
  cursor: pointer;
}

.device-table th,
.device-table td {
  white-space: nowrap;
}

.flow-stats-table th,
.flow-stats-table td {
  white-space: nowrap;
}

/* 单元格语义色（本轮新增，供精简表格用）。 */
.cell-code {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--brand-strong);
}

.cell-strong {
  color: var(--text);
  font-weight: 500;
}

.cell-muted {
  color: var(--muted);
}

.cell-dim {
  color: var(--hint);
}

/* 时间戳单元格：不折行 + 等宽数字。
   日期时间串里有空格，列一被压缩就会在空格处断成两行。 */
.cell-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

/* 操作者 IP 单元格：同样不折行（IPv6 很长），等宽数字便于纵向比对。
   取不到 IP 的历史记录显示 —，颜色与普通文本一致，不做特殊弱化。 */
.cell-ip {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

/* 发布者单元格（2026-09-20）：显示「平台下发 / 设备自发 / 外部：<clientid>」。
   外部 clientid 可能很长，列宽固定，故单行 + 省略号，完整值放在 title 里悬停可见。 */
.cell-publisher {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
}

.table-note {
  color: var(--muted);
  font-size: var(--fs-xs);
}

/* 遥测表：列宽固定，payload 单独占剩余宽度。 */
.telemetry-list-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 168px);
}

.telemetry-table-scroll {
  min-height: 260px;
  overflow: auto;
}

.telemetry-table {
  table-layout: fixed;
  min-width: 100%;
}

.telemetry-table th,
.telemetry-table td {
  white-space: nowrap;
  padding: 8px 6px;
}

.telemetry-table col.telemetry-col-device {
  width: 138px;
}

.telemetry-table col.telemetry-col-ip {
  width: 108px;
}

.telemetry-table col.telemetry-col-publisher {
  width: 132px;
}

.telemetry-table col.telemetry-col-topic {
  width: 104px;
}

.telemetry-table col.telemetry-col-volume {
  width: 100px;
}

.telemetry-table col.telemetry-col-state {
  width: 72px;
}

.telemetry-table col.telemetry-col-time {
  width: 150px;
}

/* 138 + 108 + 104 + 100 + 72 + 150 = 672，其余留给「消息」列。
   流量列 100px：fixed 布局下 nowrap 的流量值（如 1035012.8）超 66px 会
   溢出压到相邻「来源IP」列，100px 可容纳 11 位数值。 */
.telemetry-table col.telemetry-col-message {
  width: calc(100% - 672px);
}

/* 主题动作小胶囊：不同动作给不同底色，便于横向扫读。
   注意这里不再复用 .mono-chip —— 两者特异性相同、而 .mono-chip 在本文件中靠后，
   会把 max-width / white-space 盖掉。 */
.telemetry-topic-chip {
  display: inline-block;
  max-width: 100px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--chip-slate-bg);
  color: var(--chip-slate-fg);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 18px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.telemetry-topic-chip.t-red {
  background: var(--chip-red-bg);
  color: var(--chip-red-fg);
}

.telemetry-topic-chip.t-orange {
  background: var(--chip-orange-bg);
  color: var(--chip-orange-fg);
}

.telemetry-topic-chip.t-amber {
  background: var(--chip-amber-bg);
  color: var(--chip-amber-fg);
}

.telemetry-topic-chip.t-lime {
  background: var(--chip-lime-bg);
  color: var(--chip-lime-fg);
}

.telemetry-topic-chip.t-green {
  background: var(--chip-green-bg);
  color: var(--chip-green-fg);
}

.telemetry-topic-chip.t-teal {
  background: var(--chip-teal-bg);
  color: var(--chip-teal-fg);
}

.telemetry-topic-chip.t-cyan {
  background: var(--chip-cyan-bg);
  color: var(--chip-cyan-fg);
}

.telemetry-topic-chip.t-blue {
  background: var(--chip-blue-bg);
  color: var(--chip-blue-fg);
}

.telemetry-topic-chip.t-indigo {
  background: var(--chip-indigo-bg);
  color: var(--chip-indigo-fg);
}

.telemetry-topic-chip.t-violet {
  background: var(--chip-violet-bg);
  color: var(--chip-violet-fg);
}

.telemetry-topic-chip.t-pink {
  background: var(--chip-pink-bg);
  color: var(--chip-pink-fg);
}

.telemetry-topic-chip.t-slate {
  background: var(--chip-slate-bg);
  color: var(--chip-slate-fg);
}

/* 分页条：吸在面板底部。负 margin 与 .panel 的 24px 内边距配套。 */
.pagination {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px -24px -24px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: var(--fs-sm);
}

.pagination span {
  padding: 0 6px;
}

/* ---------------------------------------------------------------------------
   12. 状态徽标 / 标签 / 等宽片段
   --------------------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

/* 用圆点 + 文字双重标识状态，不单靠颜色区分。 */
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.pill.success {
  color: var(--success-ink);
  background: var(--success-soft);
}

.pill.warning {
  color: var(--warning-ink);
  background: var(--warning-soft);
}

.pill.danger {
  color: var(--danger-ink);
  background: var(--danger-soft);
}

.pill.info {
  color: var(--info-ink);
  background: var(--info-soft);
}

.pill.muted {
  color: var(--muted);
  background: var(--card-soft);
  border: 1px solid var(--line);
}

/* 可点击的胶囊（例如告警「待处理」按钮）。 */
.status-action {
  border: 0;
  cursor: pointer;
  transition: filter var(--t-fast);
}

.status-action:hover {
  filter: brightness(0.96);
}

/* 设备接入来源标记：区分「自动接入」和「手工新增」。 */
.source-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

/* 设备列表「编码」单元格里的备注（2026-09-21 由「自动接入」徽标改为显示备注）。
   备注是人手填的短标签，可能偏长：定宽截断 + title 悬浮看全文，
   避免它把最右边的「操作」列挤出视口（.table-scroll 只给横向滚动条，用户会以为按钮没了）。
   注意字体要显式回到 UI 字体 —— 父级 .cell-code 是等宽字体。 */
.device-code-text {
  font-family: var(--font-mono);
}

.device-remark {
  display: inline-block;
  margin-left: 6px;
  max-width: 180px;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card-soft);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* 设备列表「刷新」按钮 + 同步状态（2026-09-21 新增）。
   按钮在 .panel-head 右侧，panel-tools 是行内 flex，primary-btn 自带 align-self:end
   会把按钮推到行底，这里按标题行居中对齐。 */
.devices-refresh-tools {
  align-items: center;
}

.devices-refresh-tools .primary-btn {
  align-self: center;
}

.refresh-state {
  font-size: var(--fs-sm);
  color: var(--muted);
  white-space: nowrap;
}

.refresh-state.is-active {
  color: var(--info-ink);
}

.refresh-state.is-ok {
  color: var(--success-ink);
}

.refresh-state.is-error {
  color: var(--danger-ink);
}

/* 单行代码 / 报文片段。 */
.mono-chip {
  display: inline-block;
  max-width: 280px;
  padding: 4px 7px;
  border-radius: var(--r-sm);
  background: var(--mono-bg);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  vertical-align: middle;
  white-space: pre-wrap;
  word-break: break-all;
}

.telemetry-payload {
  display: block;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  white-space: nowrap;
  word-break: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 系统设置 · 用户管理「密码」列：等宽明文 + 行内显示/隐藏按钮。
   占用整行是刻意的 —— 密码是可读回内容，旁边的「重置密码」输入框不该跟它挤在一起。 */
.pwd-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.pwd-cell .pwd-value {
  min-width: 88px;
  white-space: nowrap;
  letter-spacing: 1px;
}

.pwd-cell .pwd-toggle {
  padding: 3px 10px;
  font-size: var(--fs-xs);
  white-space: nowrap;
}

/* 用户管理表有 8 列，按全局的 11px/14px 内边距 + 120px 输入框会把「操作」列挤出视口
   （`.table-scroll` 只会给横向滚动条，禁用/删除按钮就点不到了）。这里左右各收 4px，
   并把「重置密码」的输入框和按钮锁成一行 —— 实测省下约 90px，常见分辨率下一屏放下。 */
.user-table th,
.user-table td {
  padding-inline: 10px;
}

.user-table .inline-fields {
  flex-wrap: nowrap;
}

.user-table .inline-fields input {
  width: 96px;
  min-width: 96px;
}

.log-preview {
  display: block;
  max-width: 420px;
  margin-top: 8px;
}

.raw-log-list {
  display: grid;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.raw-log-line {
  display: block;
  min-width: 100%;
  width: max-content;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--mono-bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
  white-space: pre;
}

.receive-block {
  min-width: 280px;
}

.receive-title {
  margin: 0 0 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--brand-strong);
}

.receive-preview {
  display: block;
  max-width: 420px;
  margin: 6px 0 12px;
}

/* ---------------------------------------------------------------------------
   13. 提示框
   --------------------------------------------------------------------------- */
.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

.alert.success {
  color: var(--success-ink);
  border-color: var(--success);
  background: var(--success-soft);
}

.alert.warning {
  color: var(--warning-ink);
  border-color: var(--warning);
  background: var(--warning-soft);
}

.alert.danger {
  color: var(--danger-ink);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.alert.info {
  color: var(--info-ink);
  border-color: var(--info);
  background: var(--info-soft);
}

/* ---------------------------------------------------------------------------
   14. 登录页
   ---------------------------------------------------------------------------
   固定深色场景（不跟随主题切换）：左侧品牌 + 右侧表单，窄屏叠成单列。
   底色画在 html 上而不是 body 上 —— body 的 min-height:100vh 只覆盖到「布局视口」，
   视口比可视区小时底部会留一条没有渐变的带子（canvas 的 background-color 露出来），
   形成横贯整屏的硬边。html 的背景直接铺满画布，再配 background-attachment: fixed
   按视口定位，就不会有拼接缝。background-color 取渐变下段的色，作为兜底也看不出接缝。 */
html.login-page {
  min-height: 100%;
  background-color: #0a1a2b;
  background-image: linear-gradient(152deg, #101f3a 0%, #0b1730 34%, #08111f 66%, #07222c 100%);
  background-attachment: fixed;
}

.login-body {
  min-height: 100vh;
  display: grid;
  /* minmax(0, 1fr) 而不是默认的 auto 列：默认列宽由子项 min-content 决定，
     窄屏下卡片最小内容宽度会顶大列宽，卡片就横向溢出到视口外。 */
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 28px;
  color: #e8eefc;
  background: transparent;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  width: min(980px, 100%);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 24px;
  background: rgba(9, 16, 30, 0.82);
  box-shadow: 0 36px 90px -32px rgba(2, 6, 23, 0.9);
}

/* 两栏都不允许被内容顶宽；长串（设备名、主题）在需要时断行而不是撑破卡片。 */
.login-brand,
.login-panel {
  min-width: 0;
}

/* ---- 左侧品牌区：只留标识与系统名，居中放置，不放任何说明文案 ---- */
.login-brand {
  position: relative;
  display: grid;
  place-items: center;
  padding: 44px 40px;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(37, 99, 235, 0.28), transparent 62%),
    linear-gradient(160deg, #101c33 0%, #0d1830 58%, #0b2036 100%);
}

/* 点阵纹理，自左上向右下淡出 */
.login-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(148, 163, 184, 0.18) 1px, transparent 0);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(158deg, #000 18%, transparent 76%);
  mask-image: linear-gradient(158deg, #000 18%, transparent 76%);
}

.login-brand-inner {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 16px;
}

.login-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #3b82f6, #2563eb 55%, #1d4ed8);
  box-shadow: 0 12px 26px -12px rgba(37, 99, 235, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.login-mark svg {
  width: 28px;
  height: 28px;
}

.login-brand-name {
  color: #fff;
  font-size: var(--fs-lg);
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ---- 右侧表单 ---- */
.login-panel {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 44px 40px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-title {
  margin: 0;
  color: #fff;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.login-field {
  display: grid;
  gap: 7px;
  color: rgba(203, 213, 225, 0.82);
  font-size: var(--fs-sm);
}

/* 登录页固定在深色底上，表单控件要单独反色，不能走全局浅色令牌。 */
.login-field input {
  height: 44px;
  border-color: rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.login-field input::placeholder {
  color: rgba(226, 232, 240, 0.42);
}

.login-field input:hover {
  border-color: rgba(255, 255, 255, 0.24);
}

.login-field input:focus {
  border-color: var(--brand);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.32);
}

.login-submit {
  width: 100%;
  height: 44px;
  margin-top: 2px;
  font-size: var(--fs-md);
  letter-spacing: 1px;
  box-shadow: 0 16px 32px -18px rgba(37, 99, 235, 0.95);
}

.login-panel .alert {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(220, 38, 38, 0.18);
}

/* 窄屏：品牌块在上、表单在下，光晕跟着收一收，别把内容顶出屏幕。 */
@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    padding: 32px 28px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  .login-panel {
    padding: 30px 28px 34px;
  }
}

@media (max-width: 560px) {
  .login-body {
    padding: 14px;
  }

  .login-shell {
    border-radius: 18px;
  }

  .login-brand {
    padding: 26px 20px;
  }

  .login-mark {
    width: 48px;
    height: 48px;
    border-radius: 15px;
  }

  .login-mark svg {
    width: 24px;
    height: 24px;
  }

  .login-panel {
    padding: 24px 20px 28px;
  }
}

/* ---------------------------------------------------------------------------
   15. OTA：设备勾选区 + 进度条
   --------------------------------------------------------------------------- */
.ota-picker {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card-soft);
  overflow: hidden;
}

.ota-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.ota-picker-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-sm);
  font-weight: 500;
}

.ota-picker-count {
  color: var(--muted);
  font-size: var(--fs-xs);
}

.ota-picker-count strong {
  color: var(--brand-strong);
  font-size: var(--fs-md);
  font-weight: 500;
}

/* 勾选区右上角：显示范围 / 硬件版本 / 当前版本 三个下拉 + 全选·清空切换按钮 */
.ota-picker-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.ota-picker-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

/* 全局 select 是 width:100%，这里要按内容收窄 */
.ota-picker-filter select {
  width: auto;
  min-width: 132px;
}

/* 设备多时只滚动列表区域，避免把整页拉得很长。 */
.ota-picker-scroll {
  max-height: 360px;
  overflow: auto;
}

.ota-picker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.ota-picker-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 14px;
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  background: var(--card-soft);
  border-bottom: 1px solid var(--line);
}

.ota-picker-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.ota-picker-table tbody tr:hover {
  background: var(--row-active-bg);
}

.ota-picker-table .ota-col-check {
  width: 48px;
  text-align: center;
}

.ota-picker-table .ota-col-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.ota-progress-text {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.ota-progress-bar {
  display: block;
  width: 100%;
  min-width: 120px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.ota-progress-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 100%);
  transition: width 0.3s ease;
}

.ota-progress-bar-lg {
  height: 10px;
  margin: 16px 0 12px;
}

/* ---------------------------------------------------------------------------
   16. 参数设置页
   --------------------------------------------------------------------------- */
.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 18px 0 8px;
}

.param-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card-soft);
  transition: border-color var(--t-base);
}

.param-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.param-label {
  color: var(--text);
  font-weight: 500;
}

.param-unit {
  color: var(--muted);
  font-size: var(--fs-xs);
}

.param-body {
  display: flex;
  align-items: center;
  gap: 10px;
}

.param-body input {
  flex: 1 1 auto;
  min-width: 0;
}

.param-current {
  color: var(--muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.param-current-value {
  color: var(--text);
}

.param-range {
  margin-top: 8px;
  color: var(--muted);
  font-size: var(--fs-xs);
}

/* 填的值和设备当前值不一致时标黄，提醒下发前再核对一遍。 */
.param-item.param-changed {
  border-color: var(--warning);
}

.param-item.param-changed .param-current-value {
  color: var(--warning);
}

.param-json {
  margin: 16px 0;
}

.param-json summary {
  cursor: pointer;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.param-json input {
  width: 100%;
  margin-top: 12px;
}

.param-actions {
  margin-top: 18px;
}

.param-summary {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  word-break: break-all;
}

/* 当前正在配置的那台设备，在选择表里高亮一行。 */
.param-row-active td {
  background: var(--row-active-bg);
}

/* ---------------------------------------------------------------------------
   17. 系统设置页
   --------------------------------------------------------------------------- */
.sub-title {
  margin: 22px 0 12px;
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text);
}

.cleanup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.cleanup-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card-soft);
}

.cleanup-card h3 {
  margin: 0 0 10px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}

.kv-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 16px;
  margin: 0;
  font-size: var(--fs-sm);
}

.kv-list dt {
  color: var(--muted);
}

.kv-list dd {
  margin: 0;
  color: var(--text);
}

/* 各表占用：数值 + 百分比 + 一条占比条。 */
.size-cell {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 120px;
}

.size-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.size-percent {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

.size-bar {
  display: block;
  margin-top: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.size-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
}

/* 全部表与索引的明细折叠区（也用作「显示完整字段表」）。 */
.storage-details {
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card-soft);
}

.storage-details > summary {
  cursor: pointer;
  color: var(--text);
  font-size: var(--fs-sm);
}

.storage-details > summary:hover {
  color: var(--brand-strong);
}

.storage-details .table-scroll {
  margin-top: 12px;
}

/* ---------------------------------------------------------------------------
   18. 设备详情抽屉（设备管理页：精简表格 + 点行看全字段）
   --------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: 580px;
  max-width: 94vw;
  display: flex;
  flex-direction: column;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.drawer.show {
  transform: none;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-title {
  font-size: var(--fs-md);
  font-weight: 500;
}

/* 抽屉头部主区：标题 + 设备编码 + 备注填写框。
   原来是裸 div（宽度由内容决定），塞进输入框后会被挤成一条线，所以让它吃掉剩余宽度；
   布局用 grid 的 gap 撑开行距，不用给每个子元素写下外边距。 */
.drawer-head-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

/* 备注填写框（一行：输入框 + 保存 + 结果提示）。 */
.drawer-remark {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.drawer-remark .remark-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  font-size: var(--fs-xs);
}

.remark-save {
  flex: none;
  white-space: nowrap;
}

.remark-hint {
  flex: none;
  color: var(--muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.remark-hint.is-ok {
  color: var(--success-ink);
}

.remark-hint.is-error {
  color: var(--danger-ink);
}

/* 观察员只读视角：不渲染输入框，只把现有备注念出来。 */
.remark-readonly {
  color: var(--muted);
  font-size: var(--fs-xs);
}

/* 抽屉头部里的说明文字贴紧标题，不沿用 .panel-hint 的下外边距。 */
.drawer-head .panel-hint {
  margin: 0;
  font-size: var(--fs-xs);
}

.drawer-close {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.drawer-close:hover {
  background: var(--card-soft);
  color: var(--text);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.kv-item {
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.kv-item.full {
  grid-column: 1 / -1;
}

.kv-label {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.kv-value {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-sm);
  word-break: break-all;
}

.kv-value.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.drawer-foot {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.drawer-foot .btn {
  flex: 1;
}

/* ---------------------------------------------------------------------------
   19. 响应式：窄屏把双栏改成上下结构
   --------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .layout {
    height: auto;
    min-height: 100vh;
    flex-direction: column;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    height: auto;
  }

  .menu {
    max-height: 260px;
  }

  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    padding: 12px 20px;
    flex-wrap: wrap;
  }

  .content {
    overflow: visible;
    padding: 20px;
  }

  .telemetry-list-panel {
    max-height: none;
  }

  .pagination {
    margin: 18px -24px -24px;
  }
}

@media (max-width: 720px) {
  .kv {
    grid-template-columns: 1fr;
  }

  .drawer {
    width: 100%;
    max-width: none;
  }

  .topbar-user .topbar-user-name {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   20. 动效偏好：用户要求减少动态效果时全部关掉
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------------------------
   21. 克制色彩点缀（字段与卡片模块）
   --------------------------------------------------------------------------- */
/* 顶栏标题左侧品牌色竖条，与侧边栏激活态竖条呼应。 */
.topbar h1 {
  position: relative;
  padding-left: 13px;
}

.topbar h1::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--accent) 100%);
}

/* 面板标题前加品牌色圆点，让模块标题有辨识度。 */
.panel h2 {
  position: relative;
  padding-left: 16px;
}

.panel h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
}

/* KPI 卡片：图标底色加渐变层次，hover 时数字亮起强调色。 */
.kpi-icon {
  background: linear-gradient(135deg, var(--kpi-soft, var(--brand-soft)) 0%, transparent 130%);
}

.kpi-value {
  transition: color var(--t-fast);
}

.kpi-card:hover .kpi-value {
  color: var(--kpi-accent, var(--brand));
}

/* 在线状态纯文字字段上色（在线绿 / 离线灰），与 pill 口径一致。 */
.status-on {
  color: var(--success);
  font-weight: 500;
}

.status-off {
  color: var(--muted);
}

/* 侧边栏菜单 hover 时图标提亮。 */
.menu-item:hover .menu-icon {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   22. 表头与卡片块的多色彩点缀
   ---------------------------------------------------------------------------
   用主题自带的 8 种 chip 前景色做循环（浅色=深色调、深色=浅色调，可读性已验证）：
   红/绿/蓝/橙/青(浅蓝)/紫/琥珀/天蓝，相邻色相互错开避免同色系扎堆。
   循环按 nth-child 计算，列数不同的表格、节数不同的卡片组各自独立循环。
   --------------------------------------------------------------------------- */

/* --- 表格字段头：每一列文字按循环取色 --- */
th:nth-child(8n + 1) { color: var(--chip-red-fg); }
th:nth-child(8n + 2) { color: var(--chip-green-fg); }
th:nth-child(8n + 3) { color: var(--chip-blue-fg); }
th:nth-child(8n + 4) { color: var(--chip-orange-fg); }
th:nth-child(8n + 5) { color: var(--chip-teal-fg); }
th:nth-child(8n + 6) { color: var(--chip-violet-fg); }
th:nth-child(8n + 7) { color: var(--chip-amber-fg); }
th:nth-child(8n + 8) { color: var(--chip-cyan-fg); }

/* --- 参数设置卡片：顶部彩条（与 KPI 卡片同款）+ 参数名同色 --- */
.param-item {
  position: relative;
  overflow: hidden;
}

.param-item::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--pc, var(--brand));
}

.param-item .param-label {
  color: var(--pc, var(--text));
}

.param-item:nth-child(8n + 1) { --pc: var(--chip-red-fg); }
.param-item:nth-child(8n + 2) { --pc: var(--chip-green-fg); }
.param-item:nth-child(8n + 3) { --pc: var(--chip-blue-fg); }
.param-item:nth-child(8n + 4) { --pc: var(--chip-orange-fg); }
.param-item:nth-child(8n + 5) { --pc: var(--chip-teal-fg); }
.param-item:nth-child(8n + 6) { --pc: var(--chip-violet-fg); }
.param-item:nth-child(8n + 7) { --pc: var(--chip-amber-fg); }
.param-item:nth-child(8n + 8) { --pc: var(--chip-cyan-fg); }

/* --- 系统设置页的清理卡片：同一套循环彩条 --- */
.cleanup-card {
  position: relative;
  overflow: hidden;
}

.cleanup-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--pc, var(--brand));
}

.cleanup-card:nth-child(8n + 1) { --pc: var(--chip-red-fg); }
.cleanup-card:nth-child(8n + 2) { --pc: var(--chip-green-fg); }
.cleanup-card:nth-child(8n + 3) { --pc: var(--chip-blue-fg); }
.cleanup-card:nth-child(8n + 4) { --pc: var(--chip-orange-fg); }
.cleanup-card:nth-child(8n + 5) { --pc: var(--chip-teal-fg); }
.cleanup-card:nth-child(8n + 6) { --pc: var(--chip-violet-fg); }
.cleanup-card:nth-child(8n + 7) { --pc: var(--chip-amber-fg); }
.cleanup-card:nth-child(8n + 8) { --pc: var(--chip-cyan-fg); }

/* --- 统计指标卡：顶部彩条 + 数值同色循环（与参数卡同一套 8 色）---
   流量统计/断层分析等页的 stats-grid 里的 stat-card 此前是灰框白字，
   未参与多彩循环。这里补齐：顶部 3px 彩条按容器内位置循环 8 色，
   数值(strong)与标签(span)随 --pc 同色，保持与 param-item 风格统一。 */
.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--pc, var(--brand));
}

.stat-card strong,
.stat-card > span {
  color: var(--pc, var(--text));
}

.stat-card small {
  color: var(--muted);
}

.stat-card strong.stat-code {
  color: var(--pc, var(--text));
}

.stat-card:nth-child(8n + 1) { --pc: var(--chip-red-fg); }
.stat-card:nth-child(8n + 2) { --pc: var(--chip-green-fg); }
.stat-card:nth-child(8n + 3) { --pc: var(--chip-blue-fg); }
.stat-card:nth-child(8n + 4) { --pc: var(--chip-orange-fg); }
.stat-card:nth-child(8n + 5) { --pc: var(--chip-teal-fg); }
.stat-card:nth-child(8n + 6) { --pc: var(--chip-violet-fg); }
.stat-card:nth-child(8n + 7) { --pc: var(--chip-amber-fg); }
.stat-card:nth-child(8n + 8) { --pc: var(--chip-cyan-fg); }

/* ---------------------------------------------------------------------------
   23. 下拉框与数据展示框的多彩边框
   ---------------------------------------------------------------------------
   表单栅格里的控件按所在 label 的位置循环取色（8 色），下拉框 select 与
   数据输入框 input 四周统一上色；聚焦时回到品牌蓝高亮，禁用态回退灰色。
   参数卡片内的输入框复用卡片彩条色 --pc，保证输入框与顶部彩条同色。
   --------------------------------------------------------------------------- */
.form-grid > label:nth-child(8n + 1) { --fc: var(--chip-red-fg); }
.form-grid > label:nth-child(8n + 2) { --fc: var(--chip-green-fg); }
.form-grid > label:nth-child(8n + 3) { --fc: var(--chip-blue-fg); }
.form-grid > label:nth-child(8n + 4) { --fc: var(--chip-orange-fg); }
.form-grid > label:nth-child(8n + 5) { --fc: var(--chip-teal-fg); }
.form-grid > label:nth-child(8n + 6) { --fc: var(--chip-violet-fg); }
.form-grid > label:nth-child(8n + 7) { --fc: var(--chip-amber-fg); }
.form-grid > label:nth-child(8n + 8) { --fc: var(--chip-cyan-fg); }

.form-grid input,
.form-grid select {
  border-color: var(--fc, var(--line));
}

.form-grid input:focus,
.form-grid select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* 禁用态只弱化底色（见全局 input:disabled），边框仍跟字段色走 ——
   2026-09-18 用户指出「通信协议 / 自动触发 / 告警标题」这几个只读框漏了上色。 */
.form-grid input:disabled,
.form-grid select:disabled {
  border-color: var(--fc, var(--line));
}

/* 面板四周边框：全站 .panel 按其在父容器内的顺序循环 8 色（每面板一种），
   与表头/卡片/输入框同一套 chip 色。nth-child 按父容器内兄弟位置计数，
   嵌套或跨容器面板随之从 1 重新循环，故为局部顺序而非全站连续顺序。 */
/* 同时把面板色暴露成 --pc：Section 24 的控件兜底色要用它。 */
.panel:nth-child(8n + 1) { --pc: var(--chip-red-fg); border-color: var(--pc); }
.panel:nth-child(8n + 2) { --pc: var(--chip-green-fg); border-color: var(--pc); }
.panel:nth-child(8n + 3) { --pc: var(--chip-blue-fg); border-color: var(--pc); }
.panel:nth-child(8n + 4) { --pc: var(--chip-orange-fg); border-color: var(--pc); }
.panel:nth-child(8n + 5) { --pc: var(--chip-teal-fg); border-color: var(--pc); }
.panel:nth-child(8n + 6) { --pc: var(--chip-violet-fg); border-color: var(--pc); }
.panel:nth-child(8n + 7) { --pc: var(--chip-amber-fg); border-color: var(--pc); }
.panel:nth-child(8n + 8) { --pc: var(--chip-cyan-fg); border-color: var(--pc); }

.param-item .param-body input {
  border-color: var(--pc, var(--line));
}

.param-item .param-body input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ---------------------------------------------------------------------------
   24. 控件上色全覆盖（2026-09-18）
   ---------------------------------------------------------------------------
   Section 23 只给 `.form-grid > label` 里的控件取色，其余容器的控件全部停在
   默认灰边：工具条（.ota-picker-tools）、行内表单（.inline-form）、
   cleanup 卡片 / 用户表（.inline-fields）、命令栏（.command-bar）、
   高级 JSON 折叠区（.param-json）。用户按截图逐处指出这批「框框漏了上色」。
   这里做三件事：
     1) 把取色来源扩到上述容器（每个容器内按序循环 8 色）；
     2) 面板内所有文本类控件兜底 —— 取不到 --fc 就跟该面板自己的边框色（--pc），
        以后新增容器不会再漏；
     3) 只读 / 禁用框同样上色（禁用感由浅底色 + 灰字表达，不再靠灰边）。
   登录页不在 .panel 内，沿用自己那套深色反色样式，不受影响。
   --------------------------------------------------------------------------- */
.inline-form > *:nth-child(8n + 1),
.inline-fields > *:nth-child(8n + 1),
.ota-picker-tools > *:nth-child(8n + 1),
.command-bar > *:nth-child(8n + 1),
.param-json > *:nth-child(8n + 1) { --fc: var(--chip-red-fg); }

.inline-form > *:nth-child(8n + 2),
.inline-fields > *:nth-child(8n + 2),
.ota-picker-tools > *:nth-child(8n + 2),
.command-bar > *:nth-child(8n + 2),
.param-json > *:nth-child(8n + 2) { --fc: var(--chip-green-fg); }

.inline-form > *:nth-child(8n + 3),
.inline-fields > *:nth-child(8n + 3),
.ota-picker-tools > *:nth-child(8n + 3),
.command-bar > *:nth-child(8n + 3),
.param-json > *:nth-child(8n + 3) { --fc: var(--chip-blue-fg); }

.inline-form > *:nth-child(8n + 4),
.inline-fields > *:nth-child(8n + 4),
.ota-picker-tools > *:nth-child(8n + 4),
.command-bar > *:nth-child(8n + 4),
.param-json > *:nth-child(8n + 4) { --fc: var(--chip-orange-fg); }

.inline-form > *:nth-child(8n + 5),
.inline-fields > *:nth-child(8n + 5),
.ota-picker-tools > *:nth-child(8n + 5),
.command-bar > *:nth-child(8n + 5),
.param-json > *:nth-child(8n + 5) { --fc: var(--chip-teal-fg); }

.inline-form > *:nth-child(8n + 6),
.inline-fields > *:nth-child(8n + 6),
.ota-picker-tools > *:nth-child(8n + 6),
.command-bar > *:nth-child(8n + 6),
.param-json > *:nth-child(8n + 6) { --fc: var(--chip-violet-fg); }

.inline-form > *:nth-child(8n + 7),
.inline-fields > *:nth-child(8n + 7),
.ota-picker-tools > *:nth-child(8n + 7),
.command-bar > *:nth-child(8n + 7),
.param-json > *:nth-child(8n + 7) { --fc: var(--chip-amber-fg); }

.inline-form > *:nth-child(8n + 8),
.inline-fields > *:nth-child(8n + 8),
.ota-picker-tools > *:nth-child(8n + 8),
.command-bar > *:nth-child(8n + 8),
.param-json > *:nth-child(8n + 8) { --fc: var(--chip-cyan-fg); }

/* 面板内的文本类控件统一取色；复选框 / 单选框保持原生外观不参与。 */
.panel input:not([type="checkbox"]):not([type="radio"]),
.panel select,
.panel textarea {
  border-color: var(--fc, var(--pc, var(--line)));
}

.panel input:not([type="checkbox"]):not([type="radio"]):focus,
.panel select:focus,
.panel textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* 工具条里的次级按钮（全选 / 清空）也吃所在位置的色，只有描边、
   底色与 hover 观感仍走 .secondary-btn 自己那套。 */
.ota-picker-tools > .secondary-btn {
  border-color: var(--fc, var(--secondary-btn-border));
}

/* 参数卡片内的输入框永远跟卡片彩条同色（--pc），优先于上面的行色：
   与 Section 23 末尾那条同值，放这里是为了压过上面的面板兜底规则（同优先级取后者）。 */
.param-item .param-body input {
  border-color: var(--pc, var(--line));
}

/* ---------------------------------------------------------------------------
   25. 列表滑过浮起（2026-09-18）
   ---------------------------------------------------------------------------
   用户要求「凡是涉及列表的都加鼠标滑过浮动效果」，覆盖三处：
     ① 侧栏导航项（.menu-item）
     ② 各页表格行（设备列表 / 设备日志 / 流量统计 / 告警中心 / OTA / 系统日志 / 总览）
     ③ 卡片型列表（参数卡 .param-item、清理卡 .cleanup-card）
   统一手感：行上移 1px，卡片上移 2px，都配同一档 --shadow（深浅主题各一套），
   过渡用 --t-fast，避免鼠标扫过时拖影。
   ⚠️ 表格行用 transform 是安全的：tr 属于「可变换盒子」（规范只排除
   table-column / table-column-group），Edge 无头实测 getBoundingClientRect().top
   确实上移 1px。行再加 position/z-index 是为了阴影压住相邻行的下边框。
   --------------------------------------------------------------------------- */

/* ① 侧栏导航：右移 2px + 投影 + 一圈内描边（深色侧栏上纯黑投影几乎看不见） */
.menu-item {
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.menu-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
  transform: translateX(2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* ② 表格行：整行浮起。背景统一用 --row-active-bg（深浅主题都够醒目，
   原来的 --card-soft 在深色底上几乎看不出变化），左侧 3px 品牌色内描边
   当「被指到」的锚点，再叠位移 + 阴影。 */
tbody tr {
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

tbody tr:hover {
  position: relative;
  z-index: 1;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

tbody tr:hover td {
  background: var(--row-active-bg);
}

/* 左侧 3px 品牌色内描边当「被指到」的锚点，只画在第一格，避免每格都来一条 */
tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--brand);
}

.ota-picker-table tbody tr:hover {
  background: var(--row-active-bg);
}

/* ③ 卡片型列表：上移 2px + 投影，边框顺带取卡片自己的彩条色 */
.param-item,
.cleanup-card {
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}

.param-item:hover,
.cleanup-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--pc, var(--line));
}

/* ④ 指标卡/统计卡本就有抬升，统一成与卡片列表同一档位移，免得两套手感 */
.stat-card:hover,
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* 26. 设备详情：字段小卡片（顶色横线 + 悬停浮空四边描边）+ 阀头异常累计区（2026-09-18） */
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.field-card {
  position: relative;
  background: var(--panel-2, var(--card));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px 11px;
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
/* 卡片顶部色横线：颜色由下方 nth-child 循环赋给 --accent */
.field-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent, var(--brand));
}
/* 悬停：整卡上浮，方框四边描边取与顶线同色 */
.field-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent, var(--brand));
}
/* 8 色循环，让相邻字段顶线不同色 */
.detail-col > .field-card:nth-child(8n+1) { --accent: #3b82f6; }
.detail-col > .field-card:nth-child(8n+2) { --accent: #22d3ee; }
.detail-col > .field-card:nth-child(8n+3) { --accent: #22c55e; }
.detail-col > .field-card:nth-child(8n+4) { --accent: #eab308; }
.detail-col > .field-card:nth-child(8n+5) { --accent: #f97316; }
.detail-col > .field-card:nth-child(8n+6) { --accent: #ef4444; }
.detail-col > .field-card:nth-child(8n+7) { --accent: #a855f7; }
.detail-col > .field-card:nth-child(8n+8) { --accent: #ec4899; }
.field-card.field-card--full { grid-column: 1 / -1; }
/* 设备详情：左列 6 个重点字段，右列其余字段，竖向排列 */
.detail-cols {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.detail-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
@media (max-width: 560px) {
  .detail-cols { flex-direction: column; }
}

.field-card .fc-label {
  font-size: 12px;
  color: var(--muted);
}
.field-card .fc-value {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
.field-card .fc-value.mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 14px;
}
/* 阀头异常累计区：置于字段卡片之下 */
.valve-section {
  margin-top: 18px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.section-title .section-bar {
  width: 4px;
  height: 16px;
  border-radius: 3px;
  background: var(--danger, #ef4444);
}
.section-title .section-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}
.valve-loading {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
}
.valve-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.valve {
  position: relative;
  background: var(--panel-2, var(--card));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 8px 10px;
  text-align: center;
  overflow: hidden;
}
.valve .bar {
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--danger, #ef4444);
  opacity: 0.55;
}
.valve .bar.zero {
  background: var(--line);
  opacity: 1;
}
.valve .num {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: var(--danger, #ef4444);
}
.valve .num.zero {
  color: var(--muted);
}
.valve .lbl {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text, #e5eef8);
}
.valve .cnt {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

/* 设备详情：操作次数统计（开机 / 锁机） */
.op-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.op-card {
  background: var(--panel-2, var(--card));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 8px 12px;
  text-align: center;
}
.op-num {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent, #38bdf8);
}
.op-lbl {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* 设备详情：消耗流量（本月 / 本年 + 近 12 个月趋势） */
.flow-section {
  margin-top: 18px;
}
.section-title .section-bar.flow-bar {
  background: var(--accent, #14b8a6);
}
.flow-loading {
  color: var(--muted);
  font-size: 13px;
}

/* 总览「当年流量月分布」两图的系列标题：加粗 + 冒号 + 全年合计值（2026-09-19）。
   与 .panel-hint 同用时靠后定义覆盖字重/字号/颜色，数值部分随整行一起加粗。 */
.flow-chart-legend {
  font-weight: 700;
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.flow-chart-legend-gap {
  margin-top: 16px;
}
.flow-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.flow-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-soft, rgba(148, 163, 184, 0.12));
}
.flow-metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.flow-metric-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.flow-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0.5px solid rgba(148, 163, 184, 0.35);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.flow-nav:hover:not([disabled]) {
  color: var(--text, #e5e7eb);
  border-color: rgba(148, 163, 184, 0.6);
}
.flow-nav[disabled] {
  opacity: 0.35;
  cursor: default;
}
.flow-metric-value {
  font-size: 22px;
  font-weight: 600;
}
.flow-metric-unit {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}
.flow-trend {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 14px;
  min-height: 84px;
}
.flow-trend-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  cursor: pointer;
}
.flow-trend-cell.active .flow-trend-bar {
  background: var(--brand, #2563eb);
}
.flow-trend-cell:hover .flow-trend-bar {
  opacity: 0.85;
}
.flow-trend-bar {
  width: 100%;
  max-width: 18px;
  border-radius: 3px 3px 0 0;
  background: var(--accent, #14b8a6);
}
.flow-trend-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
/* 27. 系统设置页：阀头告警自动锁机面板（2026-09-19） */
.alarm-counter-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}
.alarm-counter-device {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-2, rgba(148, 163, 184, 0.06));
}
.alarm-counter-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.alarm-counter-head form {
  margin-left: auto;
}
.alarm-counter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.alarm-counter-item {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface, transparent);
}
.alarm-counter-item.zero {
  opacity: 0.55;
}
.alarm-counter-label {
  font-size: 12px;
  color: var(--muted, #94a3b8);
}
.alarm-counter-num {
  font-size: 20px;
  font-weight: 600;
  color: var(--text, #e5e7eb);
  line-height: 1.3;
}
.alarm-counter-num small {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted, #94a3b8);
}
.alarm-counter-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--line, #e2e8f0);
  overflow: hidden;
  margin: 5px 0 6px;
}
.alarm-counter-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--brand, #2563eb);
}
.alarm-counter-item.zero .alarm-counter-bar span {
  background: var(--muted, #94a3b8);
}
.alarm-counter-meta {
  font-size: 11px;
  color: var(--muted, #94a3b8);
  line-height: 1.5;
}
.panel-hint-inline {
  margin: 0;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
/* 设备详情：该阀头未处理告警已达锁机阈值（开关关闭时会停在这个状态，用于提醒）。 */
.valve.hit {
  border-color: var(--danger, #ef4444);
}
.valve.hit .cnt {
  color: var(--danger, #ef4444);
}
