/* 全屋温湿度监控 —— 样式（主页面背景 + 可拖动圆角面板 + 订阅页） */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: #0d0e13;   /* 舞台外留白底色，略深于舞台以便区分 */
  color: #e8eaf0;
  overflow: auto;        /* 窗口小于 2560×1440 虚拟舞台时页面滚动，面板不压缩 */
}

#app { display: flex; flex-direction: column; min-height: 100%; }

/* ---------- 顶部 Tab ---------- */
.tabbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #1d1f27;
  border-bottom: 1px solid #2b2e3a;
  flex: none;
}
.tab {
  padding: 8px 20px;
  font-size: 15px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #9aa0b0;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { background: #262936; }
.tab.active {
  background: #3b5bdb;
  color: #fff;
}
/* 顶栏「手机视图」入口链接：复用 .tab 外观，去除下划线 */
.mobile-link { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.mobile-link:hover { color: #fff; }

.btn {
  padding: 7px 14px;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  background: #2c2f3c;
  color: #cfd3de;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: #363a4a; }

/* ---------- 主页面 ---------- */
.main-stage {
  position: relative;
  flex: 1;               /* 填满主页面可用空间（单面板展示，不再用固定 2560×1440 画布） */
  min-width: 0;
  min-height: 0;
  overflow: hidden;      /* 舞台超出显示区域时由内部滚动容器处理，页面不增高/增宽 */
  background:
    radial-gradient(1200px 800px at 20% 0%, #20263a 0%, transparent 60%),
    radial-gradient(1000px 700px at 85% 100%, #1d2336 0%, transparent 55%),
    linear-gradient(160deg, #151720 0%, #1a1c26 100%);
}
/* 主舞台滚动容器：填满主页面；舞台超出显示区域时在此内部滚动（工具栏/缩放按钮固定在外部不随内容滚动） */
.stage-scroll {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: auto;
}
.stage-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.stage-scroll::-webkit-scrollbar-thumb { background: #2c2f3c; border-radius: 5px; }
.stage-scroll::-webkit-scrollbar-corner { background: transparent; }
.stage-toolbar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(20, 22, 30, .72);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 6px 10px;
  z-index: 10;
  backdrop-filter: blur(6px);
}
.stage-hint { font-size: 12px; color: #8a90a2; margin-left: 6px; }

/* 主页面缩放控制：底部中间，加减按钮 + 当前缩放百分比（100% = 窗口等比铺满的默认尺寸） */
.stage-zoom {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: rgba(20, 22, 30, .72);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}
.zoom-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #cfd3de;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.zoom-btn:hover { background: #363a4a; color: #fff; }
.zoom-btn:disabled { opacity: .4; cursor: not-allowed; }
.zoom-pct {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  color: #e8eaf0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  user-select: none;
}

/* 主页面布局：舞台 + 右侧边栏 */
.main-page {
  flex: 1;
  display: flex;
  align-items: stretch;   /* 舞台纵向填满可用空间 */
  position: relative;
  min-width: 0;
}

/* 右侧边栏（固定贴屏幕右缘，始终可见，可收起/展开；上下留出空间、左上/左下圆角） */
.side-rail {
  position: fixed;
  right: 0;
  top: 64px;                 /* 上方让出 Tab 栏高度 */
  bottom: 16px;              /* 下方留白，不贯穿式铺满 */
  width: 200px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  background: #1d1f27;
  border: 1px solid #2b2e3a;
  border-top-left-radius: 14px;    /* 左上、左下圆角 */
  border-bottom-left-radius: 14px;
  box-shadow: -6px 0 20px rgba(0, 0, 0, .35);
  z-index: 60;
  transition: width .18s ease;
}
.side-rail.collapsed {
  width: 38px;
  padding: 12px 5px;
  align-items: center;
}
/* 拖拽调节宽度时去掉过渡，跟随鼠标实时变化 */
.side-rail.resizing { transition: none; }
/* 左侧拖拽把手：跨在边栏左缘，悬停高亮 */
.rail-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  width: 6px;
  cursor: col-resize;
  z-index: 5;
  background: transparent;
  transition: background .15s;
}
.rail-resizer:hover,
.side-rail.resizing .rail-resizer {
  background: rgba(255, 255, 255, .14);
}
.rail-toggle {
  flex: none;
  align-self: flex-start;   /* 展开时贴在边栏左缘（靠向舞台） */
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: #2c2f3c;
  color: #cfd3de;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.rail-toggle:hover { background: #363a4a; }
.side-rail.collapsed .rail-toggle { align-self: center; }
.rail-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
/* 面板管理表（侧边栏）：面板容器 → 节点小面板 */
.add-panel-btn { width: 100%; }
.panel-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.panel-list-empty {
  padding: 10px 4px;
  font-size: 12px;
  color: #6b7080;
  text-align: center;
}
.panel-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.panel-item-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.panel-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 13px;
  text-align: left;
  color: #cfd3de;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background .15s, border-color .15s;
}
.panel-item:hover { background: #2f3344; }
.panel-item.active {
  background: #3b5bdb;
  border-color: #3b5bdb;
  color: #fff;
}
.panel-caret {
  flex: none;
  width: 12px;
  font-size: 10px;
  color: #8a90a2;
}
.panel-item.active .panel-caret { color: #dfe6ff; }
.panel-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-widget-count {
  flex: none;
  min-width: 18px;
  text-align: center;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(92, 124, 250, .14);
  color: #9db1f8;
}
.panel-item.active .panel-widget-count {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}
.panel-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: 8px;
  padding: 4px 0 4px 10px;
  border-left: 2px solid #33374a;
}
.widget-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  font-size: 12px;
  color: #cfd3de;
  background: #1f212b;
  border: 1px solid #2b2e3a;
  border-radius: 6px;
}
.widget-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.widget-row-temp {
  flex: none;
  font-size: 12px;
  color: #9db1f8;
}
.widget-row-empty {
  padding: 2px 4px;
  font-size: 11px;
  color: #6b7080;
}
.widget-add-select {
  width: 100%;
  padding: 5px 6px;
  font-size: 12px;
  color: #fff;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}
.widget-add-select:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.panel-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7ee2a8;
}
.panel-dot.off { background: #e74c3c; }
.panel-icon-btn {
  flex: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: #9aa0b0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.panel-icon-btn:hover { background: #363a4a; color: #fff; }
.panel-icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.panel-icon-btn.del { color: #ff9d8f; }
.panel-icon-btn.del:hover { background: rgba(231, 76, 60, .2); color: #fff; }
.panel-icon-btn.locked { color: #ffd76a; }
.panel-icon-btn.locked:hover { background: rgba(255, 215, 106, .18); color: #ffe9a8; }
.panel-rename-input {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  font-size: 13px;
  color: #fff;
  background: #17181f;
  border: 1px solid #3b5bdb;
  border-radius: 5px;
  outline: none;
}

/* 节点面板：圆角矩形 */
.node-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(28, 32, 44, .82);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  backdrop-filter: blur(8px);
  user-select: none;
  touch-action: none;                 /* 触屏拖动时不滚动页面 */
  overflow: hidden;
  min-width: 120px;
  min-height: 90px;
}
.node-panel.stale {
  border-color: rgba(231, 76, 60, .7);
  box-shadow: 0 0 0 1px rgba(231,76,60,.4), 0 8px 24px rgba(0,0,0,.35);
}
/* 主舞台虚拟画布：2560×1440 按窗口等比缩放（app.js STAGE_W/STAGE_H，与 db.js 一致） */
.stage {
  position: relative;
  flex: none;
  margin: auto;          /* 舞台小于容器时居中；超出时 margin 归零，滚动可达左上角 */
  border: 1px dashed rgba(255, 255, 255, .08);
  border-radius: 14px;
  background:
    radial-gradient(900px 600px at 30% 20%, rgba(255, 255, 255, .03), transparent 60%);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, .22);
}
/* 节点小面板：绝对定位，x/y/w/h 由后端保存、按舞台缩放系数渲染 */
.node-panel.widget {
  position: absolute;
}
.node-panel.widget.editable { cursor: grab; }
.node-panel.widget.editable:hover { border-color: rgba(157, 177, 248, .5); }
/* 面板锁定态：小面板可双击打开详情大弹窗（解锁态仍为拖动/缩放） */
.node-panel.widget.dblclickable { cursor: pointer; }
.node-panel.widget.dblclickable:hover { border-color: rgba(157, 177, 248, .5); }
.node-panel.widget.dragging {
  cursor: grabbing;
  box-shadow: 0 0 0 2px rgba(157, 177, 248, .5), 0 8px 24px rgba(0, 0, 0, .35);
}
/* 四边拖拽调整大小的手柄：细长热区横贯整条边（仅面板解锁编辑时渲染），悬停显示中部短杠提示；
   四角留空，不影响角部移动拖拽，也不遮挡内容 */
.node-panel .resize-edge {
  position: absolute;
  z-index: 3;
  background: transparent;
  transition: background .15s;
}
.node-panel .resize-edge::before {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: #9db1f8;
  opacity: 0;
  transition: opacity .15s;
}
.node-panel .resize-edge:hover { background: rgba(157, 177, 248, .12); }
.node-panel .resize-edge:hover::before { opacity: 1; }

.node-panel .resize-edge-top {
  top: 0; left: 8px; right: 8px; height: 6px;
  cursor: ns-resize;
}
.node-panel .resize-edge-top::before {
  top: 1px; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px;
}
.node-panel .resize-edge-bottom {
  bottom: 0; left: 8px; right: 8px; height: 6px;
  cursor: ns-resize;
}
.node-panel .resize-edge-bottom::before {
  bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px;
}
.node-panel .resize-edge-left {
  left: 0; top: 8px; bottom: 8px; width: 6px;
  cursor: ew-resize;
}
.node-panel .resize-edge-left::before {
  left: 1px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 28px;
}
.node-panel .resize-edge-right {
  right: 0; top: 8px; bottom: 8px; width: 6px;
  cursor: ew-resize;
}
.node-panel .resize-edge-right::before {
  right: 1px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 28px;
}
.widget-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #8a90a2;
  font-size: 15px;
  text-align: center;
  pointer-events: none;
}
.widget-empty .sub { font-size: 12px; opacity: .8; }
/* 节点面板头部：名字 + 「离线」标记 + 图表设置齿轮（齿轮仅面板解锁时渲染，常显） */
.node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.node-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.head-right {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* 设置齿轮：悬浮在面板右上角、不占 flex 流，避免挤压节点名/离线标记等头部内容。
   .node-panel.widget 是绝对定位元素，作为其定位上下文。 */
.widget-gear {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;                    /* 高于四边缩放手柄(z-index 3)，点击不受影响 */
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  color: #9aa0b0;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
/* 编辑态头部右侧留出齿轮悬浮空间（齿轮占右上角约 10→36px），名字/离线标记不被其遮挡 */
.node-panel.widget.editable .node-head {
  padding-right: 40px;
}
.widget-gear:focus-visible { outline: none; background: #363a4a; color: #fff; }
.widget-gear:hover { background: #363a4a; color: #fff; }
.node-temp {
  font-size: 34px;
  font-weight: 700;
  color: #6ea8fe;
  text-shadow: 0 2px 6px rgba(0,0,0,.5);
  line-height: 1.1;
  white-space: nowrap;           /* 温度数值单行不换行（水平布局信息列较窄时也不折行） */
}
/* 水平布局：信息列较窄，温度数值缩小字号以容纳 "23.5 °C" 单行显示 */
.node-body.layout-h .node-temp {
  font-size: 22px;
}
.node-row { font-size: 13px; color: #c6cbd8; }
.node-row.sub { font-size: 12px; color: #8a90a2; }
.stale-badge {
  flex: none;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e74c3c;
  color: #fff;
}

/* 面板内容区：默认纵向（基础信息在上、曲线区在下）；水平布局改为横向一行（基础信息在左、曲线区在右） */
.node-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.node-body.layout-h {
  flex-direction: row;
  gap: 8px;
  align-items: stretch;         /* 两列等高：信息列内容垂直居中，曲线区填满高度 */
}
/* 基础信息（温度数值/湿度/电量/信号）：纵向列；水平布局时固定宽度靠左，曲线区占据剩余宽度 */
.node-info {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.node-body.layout-h .node-info {
  justify-content: center;      /* 水平时信息列垂直居中，与曲线区对齐 */
  width: 100px;                 /* 与 app.js CHART_INFO_W 一致，固定宽度保证曲线区可用宽度可预估 */
  min-width: 0;
  overflow: hidden;
}
/* 曲线小图表：按布局排列（垂直堆叠 / 水平并排）、均分剩余空间；放不下就只显示前面几个，不挤压、不用滚动区 */
.node-charts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;             /* 由 JS 控制显示数量，保证内容一定放得下，无需滚动 */
}
/* 水平布局：曲线横向并排；宽度不足时由 JS（chartCount）少显示后面几个，不挤压 */
.node-body.layout-h .node-charts {
  flex-direction: row;
  gap: 6px;
  width: auto;                  /* 横向时不再占满整行，只占基础信息右侧的剩余宽度 */
  align-self: stretch;
}
.node-body.layout-h .mini-chart {
  flex: 1 1 0;
  min-width: 88px;              /* 与 app.js CHART_COL_MIN_W 一致 */
  min-height: 0;
}
.mini-chart {
  flex: 1 1 0;                  /* 均分曲线区剩余高度（按布局而定，随面板伸缩，不设上限） */
  width: 100%;
  min-height: 50px;             /* 曲线最低高度：不够就少显示几个，不挤压 */
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
}
.mini-chart-title {
  font-size: 10px;
  line-height: 1;
  color: #8a90a2;
}
.mini-chart-title.temp { color: #6ea8fe; }
.mini-chart-title.hum { color: #4ed8a8; }
.mini-chart-title.bat { color: #ffd76a; }
/* 曲线容器：占满 mini-chart 剩余高度（按布局而定），图区 + 底部时间轴两段 */
.spark-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spark-plot {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.spark {
  display: block;
  width: 100%;
  height: 100%;
}
/* 网格线：与刻度一一对应，颜色淡一点（背景刻度网格），细线不抢曲线 */
.spark-grid { stroke-width: 1; }
.spark-grid-h { stroke: rgba(255, 255, 255, .08); }
.spark-grid-v { stroke: rgba(255, 255, 255, .05); }
.spark-line {
  fill: none;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.spark-line.temp { stroke: #6ea8fe; }
.spark-line.hum { stroke: #4ed8a8; }
.spark-line.bat { stroke: #ffd76a; }
/* y 轴刻度值：图区左侧叠加的小标签（半透明底，压着网格线也可读）；首尾贴边、中间居中 */
.spark-ytick {
  position: absolute;
  left: 2px;
  padding: 1px 3px;
  font-size: 9px;
  line-height: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #9aa0b0;
  background: rgba(15, 17, 24, .62);
  border-radius: 3px;
  pointer-events: none;
}
/* x 轴时间刻度：图区底部独立一行，各刻度按位置排布 */
.spark-xaxis {
  position: relative;
  flex: none;
  width: 100%;
  height: 12px;
}
.spark-xtick {
  position: absolute;
  bottom: 1px;
  padding: 0 2px;
  font-size: 8px;
  line-height: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #8a90a2;
  white-space: nowrap;
  pointer-events: none;
}
.spark-empty {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #5f6472;
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #8a90a2;
  text-align: center;
  pointer-events: none;
}
.empty-hint p { font-size: 18px; }
.empty-hint p.sub { font-size: 13px; opacity: .8; }
/* 订阅页用的普通流内空态（覆盖主页面 .empty-hint 的绝对定位） */
.empty-hint.subs-empty {
  position: static;
  inset: auto;
  padding: 32px 0;
}

/* ---------- 订阅页面 ---------- */
.subs-page {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #17181f;
}
.node-list { display: flex; flex-direction: column; gap: 8px; }
.gateway-group { display: flex; flex-direction: column; gap: 8px; }
.gateway-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 4px;
}
.gateway-header .gw-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: #adb5bd;
}
.gateway-header .gw-count { font-size: 12px; color: #6b7080; }
.node-row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #1f212b;
  border: 1px solid #2b2e3a;
  border-radius: 12px;
}
.type-badge {
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  color: #5c7cfa;
  background: rgba(92, 124, 250, .12);
  border-radius: 999px;
}
.row-main { flex: 1; min-width: 0; }
.name-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 15px;
  color: #fff;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 8px;
  outline: none;
}
.name-input:focus { border-color: #3b5bdb; }
.row-sub { margin-top: 4px; font-size: 12px; color: #8a90a2; }
.node-topic { color: #6b7080; word-break: break-all; }
.gw-tag {
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 11px;
  color: #8a90a2;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 6px;
  vertical-align: middle;
}
.row-sub .warn { color: #e67e22; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row-time {
  flex: none;
  font-size: 12px;
  color: #6b7080;
  white-space: nowrap;
}

/* 自定义勾选框 */
.check { position: relative; flex: none; width: 22px; height: 22px; }
.check input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}
.checkmark {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #262936;
  border: 1px solid #3a3f52;
  transition: background .15s, border-color .15s;
}
.check input:checked + .checkmark {
  background: #3b5bdb;
  border-color: #3b5bdb;
}
.check input:checked + .checkmark::after {
  content: "✓";
  display: block;
  text-align: center;
  line-height: 20px;
  color: #fff;
  font-size: 14px;
}
.check input:focus-visible + .checkmark { outline: 2px solid #5c7cfa; }

/* ---------- MQTT 服务设置 ---------- */
.btn-mini {
  float: right;
  padding: 3px 10px;
  font-size: 12px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, .12);
  color: inherit;
  cursor: pointer;
}
.btn-mini:hover { background: rgba(255, 255, 255, .2); }

.mqtt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.mqtt-field { display: flex; flex-direction: column; gap: 5px; }
.mqtt-field label { font-size: 12px; color: #8a90a2; }
.mqtt-field input {
  padding: 8px 10px;
  font-size: 14px;
  color: #fff;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 8px;
  outline: none;
}
.mqtt-field input:focus { border-color: #3b5bdb; }
.mqtt-field.mqtt-topics { grid-column: 1 / -1; }   /* 主题列表独占一整行 */
.mqtt-pwd-row { display: flex; gap: 8px; }         /* 保存按钮紧贴密码输入框右侧 */
.mqtt-pwd-row input { flex: 1; min-width: 0; }
.mqtt-pwd-row .btn { flex-shrink: 0; white-space: nowrap; }
.topic-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 8px;
  padding: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.topic-empty { font-size: 13px; color: #6b7080; padding: 4px 2px; }
.topic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  padding: 6px 10px;
  background: #1f212b;
  border: 1px solid #2b2e3a;
  border-radius: 6px;
  font-size: 13px;
}
.topic-label {
  flex-shrink: 0;
  width: 96px;
  padding: 4px 8px;
  font-size: 13px;
  color: #fff;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 6px;
  outline: none;
}
.topic-label:focus { border-color: #3b5bdb; }
.topic-type {
  flex-shrink: 0;
  padding: 4px 6px;
  font-size: 13px;
  color: #fff;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}
.topic-row .topic-name { flex: 1; min-width: 0; word-break: break-all; }
/* 主题后展示的最新节点数据 / 状态 / 时间（订阅页） */
.topic-latest {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #8a90a2;
  white-space: nowrap;
}
.topic-latest .tl-data { color: #adb5bd; }
.topic-latest .tl-sep { color: #5c6370; }
.topic-latest .tl-status.on { color: #2f9e44; }
.topic-latest .tl-status.off { color: #e67e22; }
.topic-latest .tl-none { color: #5c6370; }
.topic-del {
  flex-shrink: 0;
  color: #ff9d8f;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.topic-del:hover { background: rgba(231, 76, 60, .2); color: #fff; }
.topic-add { display: flex; gap: 8px; }
.topic-add input { flex: 1; min-width: 0; }
.topic-add input:first-of-type { flex: none; width: 96px; }   /* 添加行的节点名字输入 */

/* 节点信息列表（订阅页只读展示） */
.node-name-text {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

/* 多 MQTT 连接卡片（平铺在订阅页） */
.mqtt-add-row { display: flex; margin-bottom: 12px; }
.mqtt-conns { display: flex; flex-direction: column; gap: 14px; }
.mqtt-conn-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #1f212b;
  border: 1px solid #2b2e3a;
  border-radius: 12px;
  padding: 14px;
}
.unassigned-block { margin-top: 14px; }
.mqtt-conn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mqtt-conn-name {
  flex: 1;
  min-width: 160px;
  padding: 8px 10px;
  font-size: 14px;
  color: #fff;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 8px;
  outline: none;
}
.mqtt-conn-name:focus { border-color: #3b5bdb; }
.conn-badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.conn-badge.ok { background: rgba(46, 160, 92, .18); color: #7ee2a8; }
.conn-badge.err { background: rgba(231, 76, 60, .18); color: #ff9d8f; }
.conn-count {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(92, 124, 250, .14);
  color: #9db1f8;
  white-space: nowrap;
}
.conn-err {
  font-size: 12px;
  color: #ff9d8f;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conn-cfg { color: #9aa0b0; }
.conn-cfg:hover { background: rgba(92, 124, 250, .18); color: #fff; }
.conn-del { color: #ff9d8f; }
.conn-del:hover { background: rgba(231, 76, 60, .2); }
.mqtt-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.btn.primary { background: #3b5bdb; color: #fff; }
.btn.primary:hover { background: #4a6af0; }
.btn.primary:disabled { opacity: .6; cursor: not-allowed; }
.mqtt-tip { font-size: 12px; color: #6b7080; }

/* ---------- 图表设置弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
}
.modal {
  width: 340px;
  max-width: calc(100vw - 32px);
  background: #1f212b;
  border: 1px solid #33374a;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid #2b2e3a;
}
.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-close {
  flex: none;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: #9aa0b0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.modal-close:hover { background: #363a4a; color: #fff; }
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
}
.modal-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  font-size: 14px;
  color: #cfd3de;
  cursor: pointer;
  border: 1px solid #2b2e3a;
  border-radius: 8px;
  background: #262936;
  transition: background .15s, border-color .15s;
}
.modal-check:hover { background: #2f3344; border-color: #3a3f52; }
.modal-check input { width: 16px; height: 16px; accent-color: #3b5bdb; cursor: pointer; }
.modal-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  font-size: 14px;
  color: #cfd3de;
  border: 1px solid #2b2e3a;
  border-radius: 8px;
  background: #262936;
}
.modal-field-label { flex: 1; }
.modal-select {
  flex: none;
  min-width: 132px;
  padding: 5px 8px;
  font-size: 13px;
  color: #e6e9f2;
  background: #1f222d;
  border: 1px solid #3a3f52;
  border-radius: 6px;
  cursor: pointer;
}
.modal-select:focus-visible { outline: none; border-color: #3b5bdb; }
.modal-tip { font-size: 12px; color: #8a90a2; margin-top: 2px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #2b2e3a;
}

/* ---------- 节点小面板详情大弹窗（双击锁定面板的节点小面板打开） ---------- */
.detail-mask {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(4px);
}
.detail-modal {
  width: 760px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: #1f212b;
  border: 1px solid #33374a;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid #2b2e3a;
}
.detail-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.detail-name {
  flex: none;
  max-width: 40%;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-topic {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #6b7080;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 详情大弹窗头部的曲线时间范围下拉（与设置弹窗同一套选项，默认近 1 天） */
.detail-range {
  flex: none;
  max-width: 132px;
  padding: 4px 8px;
  font-size: 12px;
  color: #e6e9f2;
  background: #262936;
  border: 1px solid #3a3f52;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
}
.detail-range:focus-visible { border-color: #3b5bdb; }
/* 当前温湿度 + 电量：三张统计卡并排 */
.detail-stats {
  display: flex;
  gap: 12px;
  padding: 16px 20px 2px;
}
.detail-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  background: #262936;
  border: 1px solid #2b2e3a;
  border-radius: 12px;
}
.detail-stat-label { font-size: 12px; color: #8a90a2; }
.detail-stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: #e8eaf0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.detail-stat-value.temp { color: #6ea8fe; }
.detail-stat-value.hum { color: #4ed8a8; }
.detail-stat-value.bat { color: #ffd76a; }
/* 三条曲线垂直布局，均分剩余高度；视口太矮时纵向滚动 */
.detail-charts {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px 20px;
  overflow-y: auto;
}
.detail-chart {
  flex: 1 1 0;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
}
.detail-chart-head { display: flex; align-items: center; gap: 8px; }
.detail-chart-head .mini-chart-title { font-size: 12px; }
/* 大弹窗里曲线刻度/标签/线条适当加大，保证在大尺寸下可读 */
.detail-ytick { font-size: 11px; }
.detail-xtick { font-size: 10px; }
.detail-chart .spark-line { stroke-width: 2; }
.detail-chart .spark-empty { font-size: 12px; }
/* 详情大弹窗曲线十字线：随鼠标移动，xy 轴显示对应标签 */
.crosshair-line {
  stroke: rgba(255, 255, 255, .38);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.crosshair-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #3b5bdb;
  box-shadow: 0 0 4px rgba(0, 0, 0, .5);
  pointer-events: none;
  z-index: 3;
}
.crosshair-ylabel {
  position: absolute;
  left: 2px;
  padding: 1px 5px;
  font-size: 10px;
  line-height: 1.3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #fff;
  background: rgba(59, 91, 219, .88);
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}
.crosshair-xlabel {
  position: absolute;
  bottom: 1px;
  padding: 1px 5px;
  font-size: 10px;
  line-height: 1.3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #fff;
  background: rgba(59, 91, 219, .88);
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

/* ---------- 登录 / 注册 ---------- */
.login-wrap {
  flex: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 700px at 30% 20%, rgba(92, 124, 250, .12), transparent 60%),
    radial-gradient(800px 600px at 80% 80%, rgba(78, 216, 168, .06), transparent 55%),
    #0d0e13;
}
.login-card {
  width: 360px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px 28px 24px;
  background: #1d1f27;
  border: 1px solid #2b2e3a;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}
.login-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #3b5bdb, #5c7cfa);
  border-radius: 12px;
}
.login-brand-text { font-size: 19px; font-weight: 700; color: #e8eaf0; }
.login-tabs {
  display: flex;
  padding: 4px;
  gap: 4px;
  background: #262936;
  border-radius: 10px;
}
.login-tab {
  flex: 1;
  padding: 8px 0;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #9aa0b0;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.login-tab:hover { color: #cfd3de; }
.login-tab.active { background: #3b5bdb; color: #fff; }
.login-label {
  display: block;
  font-size: 12px;
  color: #8a90a2;
  margin: 12px 0 5px;
}
.login-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: #fff;
  background: #262936;
  border: 1px solid #33374a;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s;
}
.login-input:focus { border-color: #3b5bdb; }
.login-input::placeholder { color: #5f6472; }
.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: #ff9d8f;
}
.login-submit {
  width: 100%;
  margin-top: 16px;
  padding: 10px 0;
  font-size: 15px;
}

/* ---------- 右上角用户区 + 下拉菜单 ---------- */
.user-area {
  position: relative;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.user-area:hover { background: #262936; }
.user-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3b5bdb, #5c7cfa);
  border-radius: 50%;
}
.user-name {
  font-size: 14px;
  color: #cfd3de;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-caret { font-size: 11px; color: #8a90a2; }
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 90;
  min-width: 148px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: #1f212b;
  border: 1px solid #2b2e3a;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.user-menu-item {
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
  color: #cfd3de;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.user-menu-item:hover { background: #2f3344; color: #fff; }
.user-menu-item.danger { color: #ff9d8f; }
.user-menu-item.danger:hover { background: rgba(231, 76, 60, .2); color: #fff; }

/* ---------- 用户管理页面（管理员） ---------- */
.users-page {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: #17181f;
}
.users-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.users-title { font-size: 18px; font-weight: 700; color: #e8eaf0; }
.users-sub { font-size: 12px; color: #6b7080; }
.users-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 820px;
}
.users-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: #1f212b;
  border: 1px solid #2b2e3a;
  border-radius: 10px;
  font-size: 13px;
}
.users-head-row {
  background: #262936;
  font-size: 12px;
  color: #8a90a2;
  border-color: #33374a;
}
.u-col { flex: none; }
.u-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cfd3de; }
.u-role { width: 90px; }
.u-time { width: 160px; color: #6b7080; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.u-actions { width: 180px; display: flex; gap: 8px; justify-content: flex-end; }
.role-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  color: #9db1f8;
  background: rgba(92, 124, 250, .14);
  border-radius: 999px;
}
.role-badge.admin { color: #ffd76a; background: rgba(255, 215, 106, .14); }

/* 滚动条 */
.subs-page::-webkit-scrollbar { width: 10px; }
.subs-page::-webkit-scrollbar-thumb { background: #2c2f3c; border-radius: 5px; }
.users-page::-webkit-scrollbar { width: 10px; }
.users-page::-webkit-scrollbar-thumb { background: #2c2f3c; border-radius: 5px; }
