/* ============================================================
   智慧安全用电管理平台 - 现代 UI 主题
   设计语言：玻璃拟态 + 渐变强调色 + 圆角卡片
   二开改这里即可换肤（CSS 变量驱动）
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --sidebar-1: #0f172a;
  --sidebar-2: #1e293b;
  --text: #1e293b;
  --text-soft: #64748b;
  --text-invert: #e2e8f0;
  --border: #e7ebf3;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow: 0 8px 30px rgba(30, 41, 59, 0.08);
  --shadow-sm: 0 2px 10px rgba(30, 41, 59, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
}
html.dark {
  --bg: #0b1120;
  --surface: #131c30;
  --surface-2: #0f172a;
  --text: #e2e8f0;
  --text-soft: #94a3b8;
  --border: #243049;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2));
  color: var(--text-invert); display: flex; flex-direction: column; position: fixed; height: 100vh; left: 0; top: 0; z-index: 20;
  transition: width .2s;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-grad); display: grid; place-items: center; font-size: 18px; }
.brand small { display:block; font-size: 11px; font-weight: 400; color: #94a3b8; }
.menu { flex: 1; overflow-y: auto; padding: 8px 12px; }
.menu-group-title { font-size: 11px; color: #64748b; padding: 14px 12px 6px; text-transform: uppercase; letter-spacing: 1px; }
.menu-item { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 10px; color: #cbd5e1; font-size: 14px; margin: 2px 0; transition: .15s; cursor: pointer; }
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-item.active { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.4); }
.menu-item svg { width: 18px; height: 18px; flex: none; }
.menu-item .sub { padding-left: 14px; font-size: 13px; }
.chev { margin-left: auto; transition: transform .2s; }
.menu-item.open .chev { transform: rotate(90deg); }
.submenu {
  margin-left: 18px; border-left: 1px solid rgba(255,255,255,.08); padding-left: 6px;
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease, padding .2s ease;
}
.menu-group.open .submenu { max-height: 600px; opacity: 1; }

/* ===== 侧边栏折叠（图标栏模式） ===== */
.main { transition: margin-left .2s; }
.sidebar.collapsed { width: 64px; }
.main.collapsed { margin-left: 64px; }
.sidebar.collapsed .brand { justify-content: center; padding: 22px 0; }
.sidebar.collapsed .brand > div { display: none; }
.sidebar.collapsed .menu { padding: 8px 8px; overflow: visible; }
.sidebar.collapsed .menu-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .menu-item > span:not(:first-child) { display: none; }
.sidebar.collapsed .menu-group { position: relative; }
.sidebar.collapsed .submenu {
  display: none; position: absolute; left: 64px; top: 0; margin-left: 0;
  border-left: none; padding: 6px; min-width: 184px; background: var(--sidebar-2);
  border-radius: 0 10px 10px 0; box-shadow: 8px 4px 24px rgba(0,0,0,.35); z-index: 40;
}
.sidebar.collapsed .menu-group:hover .submenu { display: block; }
.sidebar-trigger {
  position: absolute; right: -14px; bottom: 90px; width: 14px; height: 64px;
  background: var(--sidebar-2, #1e293b); border: 1px solid rgba(255,255,255,.10);
  border-left: none; border-radius: 0 8px 8px 0;
  color: #94a3b8; cursor: pointer; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 4px 0 14px rgba(0,0,0,.25); transition: .15s; z-index: 30;
}
.sidebar-trigger:hover { background: rgba(99,102,241,.25); color: #fff; }
.sidebar.collapsed .sidebar-trigger { right: -14px; bottom: 90px; }

.main { flex: 1; margin-left: 232px; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 62px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 10; box-shadow: var(--shadow-sm); }
.topbar .page-title { font-size: 17px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 32px; height: 32px; border-radius: 10px; border: none; background: transparent; display: grid; place-items: center; color: var(--text-soft); cursor: pointer; transition: .18s; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--accent); background: rgba(99,102,241,.10); transform: translateY(-1px); }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; }
.icon-btn.sm svg { width: 14px; height: 14px; }
.icon-btn.danger { color: var(--text-soft); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(239,68,68,.10); }

/* 精致 tooltip：通过 title 属性 */
[title] { position: relative; }
[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 50%; bottom: 120%;
  transform: translateX(-50%);
  padding: 5px 9px;
  border-radius: 6px;
  background: rgba(15,23,42,.88);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  animation: tipIn .15s ease forwards;
  z-index: 20;
}
[title]:hover::before {
  content: "";
  position: absolute;
  left: 50%; bottom: 112%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(15,23,42,.88);
  opacity: 0;
  animation: tipIn .15s ease forwards;
  z-index: 20;
}
@keyframes tipIn { to { opacity: 1; } }

.user-box { display: flex; align-items: center; gap: 10px; padding: 5px 12px 5px 6px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.user-box .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-grad); color: #fff; display: grid; place-items: center; font-weight: 600; box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.user-box .uname { font-size: 14px; font-weight: 500; line-height: 1.1; }
.user-box .uname .role { color: var(--text-soft); font-size: 12px; font-weight: 400; }
.ai-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; border: none; cursor: pointer; color: #fff; background: var(--accent-grad); font-size: 14px; font-weight: 600; box-shadow: 0 6px 18px rgba(99,102,241,.4); transition: .18s; }
.ai-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(99,102,241,.5); }
.ai-btn-ico { display: grid; place-items: center; }
.ai-btn-ico svg { width: 18px; height: 18px; }

/* ---------- AI 数据助手抽屉 ---------- */
.ai-mask { position: fixed; inset: 0; background: rgba(15,23,42,.35); backdrop-filter: blur(2px); z-index: 200; display: flex; justify-content: flex-end; }
.ai-drawer { width: 400px; max-width: 92vw; height: 100%; background: var(--surface); box-shadow: -12px 0 40px rgba(0,0,0,.25); display: flex; flex-direction: column; animation: aiSlide .22s ease; border-left: 1px solid var(--border); }
@keyframes aiSlide { from { transform: translateX(30px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.ai-title { display: flex; align-items: center; gap: 12px; }
.ai-logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: var(--accent-grad); box-shadow: 0 6px 16px rgba(99,102,241,.4); }
.ai-logo svg { width: 20px; height: 20px; }
.ai-title b { font-size: 15px; display: block; }
.ai-title small { color: var(--text-soft); font-size: 11px; }
.ai-list { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble { max-width: 86%; padding: 11px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; }
.ai-msg.assistant .ai-bubble { background: var(--surface-2, rgba(99,102,241,.08)); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text); }
.ai-msg.user .ai-bubble { background: var(--accent-grad); color: #fff; border-bottom-right-radius: 4px; }
.ai-bubble p { margin: 0; }
.ai-bubble p + p { margin-top: 6px; }
.ai-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ai-stat { flex: 1 1 30%; min-width: 72px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; text-align: center; }
.ai-stat .v { font-size: 18px; font-weight: 700; }
.ai-stat .l { font-size: 11px; color: var(--text-soft); margin-top: 2px; }
.ai-stat.ok .v { color: #34d399; }
.ai-stat.warn .v { color: #fbbf24; }
.ai-stat.danger .v { color: #f87171; }
.ai-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.ai-table th { background: rgba(99,102,241,.1); color: var(--text-soft); font-weight: 600; padding: 6px 8px; text-align: left; white-space: nowrap; }
.ai-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; }
.ai-table tr:last-child td { border-bottom: none; }
.ai-table td { padding: 6px 8px; border-top: 1px solid var(--border); }
.ai-table tbody tr:nth-child(even) { background: rgba(148,163,184,.06); }
.ai-typing { display: inline-flex; gap: 4px; align-items: center; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-soft); animation: aiBlink 1s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .2s; } .ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%,100%{ opacity:.3; } 50%{ opacity:1; } }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 10px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer; transition: .15s; }
.chip:hover { color: var(--accent); border-color: var(--accent); background: rgba(99,102,241,.08); }
.ai-foot { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); align-items: flex-end; }
.ai-input { flex: 1; resize: none; max-height: 120px; line-height: 1.5; font-family: inherit; }
.ai-send { width: 40px; height: 40px; border-radius: 12px; border: none; background: var(--accent-grad); color: #fff; display: grid; place-items: center; cursor: pointer; transition: .15s; flex: none; }
.ai-send svg { width: 18px; height: 18px; }
.ai-send:disabled { opacity: .45; cursor: not-allowed; }
.ai-send:not(:disabled):hover { transform: translateY(-1px); }

.content { padding: 24px; flex: 1; min-width: 0; position: relative; }
.breadcrumb { color: var(--text-soft); font-size: 13px; margin-bottom: 16px; }

/* ---------- 卡片 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px){ .grid.cols-4{grid-template-columns:repeat(2,1fr);} .grid.cols-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 700px){ .grid.cols-4,.grid.cols-3,.grid.cols-2{grid-template-columns:1fr;} }

/* 统计卡 */
.stat { position: relative; overflow: hidden; }
.stat .ic { position: absolute; right: 14px; top: 14px; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; opacity: .9; }
.stat .label { color: var(--text-soft); font-size: 13px; }
.stat .num { font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: .5px; }
.stat .sub { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

/* ---------- 表格 ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.btn.active { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,.08); }
.input, select, textarea { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; outline: none; transition: .15s; }
.input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.toolbar .input { min-width: 220px; }
.btn.sm.primary { background: var(--accent-grad); color: #fff; border: none; }
.btn.sm.danger { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.3); color: var(--danger); }
.btn.sm.danger:hover { background: rgba(239,68,68,.16); }

/* 筛选面板 */
.filter-panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px; }
.filter-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.filter-item { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.filter-item label { font-size: 12px; color: var(--text-soft); }
.filter-item .input { min-width: 150px; width: auto; padding: 7px 10px; }
.filter-actions { margin-top: 12px; display: flex; gap: 10px; }

/* 批量操作条 */
.batch-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: rgba(239,68,68,.06); border: 1px solid rgba(239,68,68,.2); border-radius: var(--radius-sm); margin-bottom: 12px; }
.batch-bar .sel-count { font-size: 13px; color: var(--text-soft); }
.batch-bar .sel-count b { color: var(--danger); }

/* 列表选择列 + 拖拽列设置（选择列固定样式见下方 col-check sticky 规则） */
.col-list { max-height: 50vh; overflow: auto; }
.col-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--surface); cursor: grab; }
.col-row:active { cursor: grabbing; }
.col-row .col-label { flex: 1; font-size: 14px; }
.col-move { display: flex; gap: 4px; }
.mini { width: 26px; height: 26px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; font-size: 12px; line-height: 1; color: var(--text-soft); }
.mini:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.mini:disabled { opacity: .4; cursor: not-allowed; }

/* 硬件接入弹窗 */
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv span { color: var(--text-soft); }
.hw-actions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.hw-err { color: var(--danger); font-size: 13px; margin: 8px 0; }
.hw-json { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-size: 12px; white-space: pre-wrap; word-break: break-all; max-height: 280px; overflow: auto; }
.hw-doc { margin-top: 8px; }
.hw-doc code { background: rgba(99,102,241,.1); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ===== 列表通用：横向滚动 + 表头固定 + 操作列 sticky 固定 ===== */
.table-wrap {
  position: relative;
  max-height: calc(100vh - 230px);
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,.5) transparent;
}
.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: rgba(148,163,184,.45); border-radius: 4px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

/* 卡片作为列表容器，必须能被 flex 父容器压缩，避免内部宽表格撑破页面 */
.card:has(.table-wrap) { min-width: 0; overflow: visible; }

table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }

thead th {
  position: sticky; top: 0; z-index: 3;
  background: #f1f5f9; color: var(--text); font-weight: 600;
  padding: 12px 14px; border-bottom: 2px solid var(--border);
  white-space: nowrap; text-align: left; min-width: 80px;
}
html.dark thead th { background: #1e293b; }

th.col-ops {
  position: sticky; top: 0; right: 0; z-index: 4;
  background: #f1f5f9; text-align: center; border-left: 1px solid var(--border);
  min-width: 120px; box-shadow: -6px 0 12px -4px rgba(15,23,42,.18);
}
html.dark th.col-ops { background: #1e293b; }

/* 最左侧多选框列固定：左上角锁死，z 最高压住横纵双向滚动 */
th.col-check {
  position: sticky; top: 0; left: 0; z-index: 5;
  background: #f1f5f9; text-align: center; border-right: 1px solid var(--border);
  width: 44px; min-width: 44px; padding-left: 0; padding-right: 0;
  box-shadow: 6px 0 12px -4px rgba(15,23,42,.18);
}
html.dark th.col-check { background: #1e293b; }

.col-sort { cursor: pointer; user-select: none; transition: color .15s; }
.col-sort:hover { color: var(--accent); }
.col-sort.active { color: var(--accent); }
.th-label { vertical-align: middle; }
.sort-ico { display: inline-flex; vertical-align: middle; margin-left: 4px; }
.sort-ico svg { width: 14px; height: 14px; }
/* 所有单元格不换行，确保行高恒定，宽度不足时横向滚动 */
td, th { white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface); min-width: 80px; }
.data-row { cursor: pointer; transition: background .12s; }
.data-row:hover td { background: var(--surface-2); }

td.col-ops {
  position: sticky; right: 0; z-index: 2;
  background: var(--surface); text-align: center; border-left: 1px solid var(--border);
  min-width: 120px; box-shadow: -6px 0 12px -4px rgba(15,23,42,.14);
  background-clip: padding-box;
}
.data-row:hover td.col-ops { background: var(--surface-2); }

/* 最左侧多选框列固定：横向滚动时始终钉在最左，右侧分隔阴影 */
td.col-check {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface); text-align: center; border-right: 1px solid var(--border);
  width: 44px; min-width: 44px; padding-left: 0; padding-right: 0;
  box-shadow: 6px 0 12px -4px rgba(15,23,42,.14);
  background-clip: padding-box;
}
.data-row:hover td.col-check { background: var(--surface-2); }
html.dark td.col-check { background: #1e293b; }
html.dark .data-row:hover td.col-check { background: #243044; }
.row-actions { display: flex; gap: 4px; justify-content: center; }
.link-btn { color: var(--accent); cursor: pointer; font-size: 13px; }
.link-btn.danger { color: var(--danger); }
.link-btn:hover { text-decoration: underline; }

/* ===== 嵌入式数据表统一基础标准（弹窗子表 / 大屏 / 已覆盖 AI 表） ===== */
/* 弹窗内 mini-table：弹窗本身是滚动容器(sticky 会冲突)，故只做边框+紧凑+暗色，不固定表头 */
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mini-table th, .mini-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.mini-table th { background: var(--surface-2); font-weight: 600; color: var(--text-soft); white-space: nowrap; }
.mini-table td { white-space: nowrap; }
.mini-table tr:last-child td { border-bottom: none; }
html.dark .mini-table th { background: #1e293b; }
/* 大屏内表格：保持深色驾驶舱风格，仅做轻量统一（边框+紧凑），不套浅色表头 */
.bs-panel table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.bs-panel th, .bs-panel td { padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,.12); text-align: left; white-space: nowrap; }
.bs-panel th { color: #93c5fd; font-weight: 600; }
.bs-panel tr:last-child td { border-bottom: none; }

/* 列表单元格特殊渲染 */
.cell-thumb { width: 72px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.cell-ellipsis { display: inline-block; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; color: var(--text-soft); }
.cell-tip { cursor: help; color: var(--text-soft); max-width: 420px; display: inline-block; white-space: nowrap; overflow: hidden; vertical-align: middle; }
.text-muted { color: var(--text-soft); }

/* 徽章 */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: rgba(16,185,129,.12); color: var(--success); }
.badge.warning { background: rgba(245,158,11,.12); color: var(--warning); }
.badge.danger { background: rgba(239,68,68,.12); color: var(--danger); }
.badge.info { background: rgba(59,130,246,.12); color: var(--info); }
.badge.muted { background: rgba(100,116,139,.14); color: var(--text-soft); }

/* ---------- 按钮 ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; transition: .15s; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent-grad); color: #fff; border: none; box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.btn.primary:hover { filter: brightness(1.05); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 13px; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.pager .info { color: var(--text-soft); font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--radius); width: 560px; max-width: 92vw; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600; display: flex; align-items: center; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--text-soft); }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
/* 小程序绑定码弹窗 */
.bind-code-box { text-align: center; padding: 18px 10px; }
.bind-code { display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 28px; letter-spacing: 4px; font-weight: 700; color: var(--accent); background: var(--surface-2); border: 1px dashed var(--accent); border-radius: var(--radius-sm); padding: 14px 22px; user-select: all; }
.bind-expire { margin-top: 12px; font-size: 12px; color: var(--text-soft); }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
.form-row .input, .form-row select, .form-row textarea { width: 100%; }
.form-row textarea { min-height: 84px; resize: vertical; }
.form-row .hint { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 80% -10%, #312e81 0%, transparent 60%), radial-gradient(900px 500px at 0% 110%, #0ea5e9 0%, transparent 55%), linear-gradient(135deg,#0f172a,#1e293b); }
.login-card { width: 400px; max-width: 92vw; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(18px); border-radius: 22px; padding: 38px 34px; color: #e2e8f0; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .sub { color: #94a3b8; font-size: 13px; margin-bottom: 26px; }
.login-card .input { width: 100%; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #fff; }
.login-card .input::placeholder { color: #94a3b8; }
.login-card .btn.primary { width: 100%; margin-top: 8px; padding: 12px; font-size: 15px; }
.login-err { color: #fca5a5; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- 大屏 ---------- */
.bigscreen { background: #060b1a; color: #cfe3ff; min-height: 100vh; padding: 18px; }
.bigscreen .bs-title { text-align: center; font-size: 26px; font-weight: 700; letter-spacing: 4px; background: linear-gradient(90deg,#38bdf8,#818cf8,#c084fc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bigscreen .bs-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin: 16px 0; }
.bigscreen .bs-stat { background: linear-gradient(135deg, rgba(56,189,248,.12), rgba(129,140,248,.12)); border: 1px solid rgba(99,140,248,.25); border-radius: 14px; padding: 18px; text-align: center; }
.bigscreen .bs-stat .n { font-size: 34px; font-weight: 800; color: #7dd3fc; }
.bigscreen .bs-stat .l { color: #94a3b8; font-size: 13px; margin-top: 4px; }
.bigscreen .bs-panel { background: rgba(15,23,42,.6); border: 1px solid rgba(99,140,248,.2); border-radius: 14px; padding: 14px; }
.bigscreen .bs-panel h3 { font-size: 14px; color: #93c5fd; margin-bottom: 8px; font-weight: 600; }

.empty { text-align: center; color: var(--text-soft); padding: 40px; }
.loading { text-align: center; padding: 40px; color: var(--text-soft); }
.fade-enter-active, .fade-leave-active { transition: opacity .15s; }
.fade-enter-from, .fade-leave-to { opacity: 0; }

/* ---------- 大屏地图驾驶舱 ---------- */
.bs-main { display: grid; grid-template-columns: 1fr 340px; gap: 14px; margin-top: 14px; min-height: 600px; }
.bs-map-card { background: rgba(15,23,42,.6); border: 1px solid rgba(99,140,248,.2); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.bs-map-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid rgba(99,140,248,.15); }
.bs-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #94a3b8; }
.bs-breadcrumb span { cursor: pointer; transition: .15s; }
.bs-breadcrumb span:hover { color: #38bdf8; }
.bs-breadcrumb span.active { color: #38bdf8; font-weight: 600; }
.bs-breadcrumb span:not(:last-child)::after { content: '>'; margin-left: 8px; color: #475569; }
.bs-map-actions { display: flex; gap: 8px; }
.bs-map-actions .btn { background: rgba(56,189,248,.12); border-color: rgba(56,189,248,.25); color: #7dd3fc; }
.bs-map-actions .btn:hover { background: rgba(56,189,248,.2); color: #fff; }
.bs-map-wrap { flex: 1; min-height: 540px; background: #020617; }
.bs-map-legend { display: flex; gap: 14px; padding: 10px 14px; font-size: 12px; color: #94a3b8; border-top: 1px solid rgba(99,140,248,.15); flex-wrap: wrap; }
.bs-map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bs-map-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.bs-map-legend i.dot { border-radius: 50%; }

.bs-side { display: flex; flex-direction: column; gap: 14px; }
.bs-side .bs-panel { flex: none; }
.bs-side-stat { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(99,140,248,.12); }
.bs-side-stat:last-child { border-bottom: none; }
.bs-side-stat .label { color: #94a3b8; font-size: 13px; }
.bs-side-stat .num { font-size: 20px; font-weight: 700; color: #7dd3fc; }
.bs-side-stat .num.success { color: #4ade80; }
.bs-side-stat .num.danger { color: #f87171; }
.bs-side-stat .num.warning { color: #fbbf24; }
.bs-side-stat .num.muted { color: #94a3b8; }

/* Leaflet 聚合气泡与设备点 */
.map-cluster { border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; font-weight: 700; border: 2px solid rgba(255,255,255,.25); cursor: pointer; transition: transform .15s; }
.map-cluster:hover { transform: scale(1.08); }
.map-cluster .n { font-size: 16px; line-height: 1; }
.map-cluster .t { font-size: 11px; line-height: 1; margin-top: 2px; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-device-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; cursor: pointer; transition: transform .15s; }
.map-device-dot:hover { transform: scale(1.3); }
.bs-tooltip { background: rgba(15,23,42,.9); border: 1px solid rgba(99,140,248,.3); color: #cfe3ff; border-radius: 8px; padding: 8px 12px; font-size: 13px; }

/* 权限勾选树（角色权限 editor:'perms'） */
.perm-tree { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); }
.perm-tree-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.perm-count { font-size: 13px; color: var(--text-soft); }
.perm-group { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.perm-group-head { background: var(--bg); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.perm-all { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.perm-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; padding: 10px 12px; }
.perm-item { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.perm-tree input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

/* Leaflet 暗色适配 */
.leaflet-container { background: #020617; }
@media (max-width: 1100px) {
  .bs-main { grid-template-columns: 1fr; }
  .bs-side { flex-direction: row; flex-wrap: wrap; }
  .bs-side .bs-panel { flex: 1; min-width: 260px; }
}

/* ===== 小程序绑定申请审核页 ===== */
.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.page-head .sub { color: var(--text-soft); font-size: 13px; line-height: 1.6; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.tag.green { background: rgba(16,185,129,.12); color: var(--success); }
.tag.orange { background: rgba(245,158,11,.14); color: var(--warning); }
.tag.red { background: rgba(239,68,68,.12); color: var(--danger); }
.tag.gray { background: rgba(100,116,139,.14); color: var(--text-soft); }
.err-box { background: rgba(239,68,68,.1); color: var(--danger); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.apply-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 14px; }
.apply-top { display: flex; align-items: center; justify-content: space-between; }
.apply-name { font-size: 16px; font-weight: 600; }
.apply-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; color: var(--text-soft); font-size: 13px; }
.apply-remark { margin-top: 8px; font-size: 13px; color: var(--text); background: var(--bg); border-radius: 8px; padding: 8px 12px; }
.apply-actions { display: flex; gap: 10px; margin-top: 14px; }
.seg { display: flex; gap: 8px; margin: 6px 0 18px; }
.seg-item { flex: 1; text-align: center; padding: 9px 0; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; cursor: pointer; color: var(--text-soft); }
.seg-item.on { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,.08); font-weight: 600; }
.field { display: grid; grid-template-columns: 120px 1fr; gap: 12px 16px; align-items: start; margin-bottom: 16px; }
.field-label { font-size: 13px; color: var(--text-soft); line-height: 1.45; padding-top: 9px; }
.field .input, .field select, .field textarea { width: 100%; box-sizing: border-box; }

.apply-modal { width: 620px; }
.apply-modal .modal-body { padding-bottom: 22px; }
.user-list { max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.user-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.user-item:last-child { border-bottom: none; }
.user-item.on { background: rgba(99,102,241,.1); color: var(--accent); }
.user-item small { color: var(--text-soft); }
.li-right { color: var(--text-soft); }

/* ===== 通用图片字段（image 类型） ===== */
.image-field { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.image-preview { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.image-preview img { max-height: 120px; max-width: 240px; border-radius: 8px; object-fit: cover; }
.image-field .mini { white-space: nowrap; }
/* 多图上传（工单照片附件） */
.image-list { display: flex; flex-wrap: wrap; gap: 10px; }
.image-item { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.image-item img { display: block; width: 96px; height: 96px; object-fit: cover; }
.image-item .mini { position: absolute; top: 2px; right: 2px; padding: 2px 6px; line-height: 1; }

/* ===== 富文本编辑器 ===== */
.rich-editor { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); align-items: center; }
.rich-toolbar .mini { padding: 4px 10px; min-width: 32px; }
.rich-toolbar select,
.rich-toolbar input[type="color"] { padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 12px; height: 28px; }
.rich-toolbar input[type="color"] { width: 32px; padding: 2px; cursor: pointer; }
.rich-input { min-height: 160px; padding: 12px 14px; line-height: 1.7; outline: none; }
.rich-input:empty::before { content: "请输入内容…"; color: var(--text-soft); }
.rich-input p { margin: 0 0 8px; }
.rich-input a { color: var(--accent); text-decoration: underline; }

/* ===== 消息通知详情预览弹窗 ===== */
.notice-preview-modal { width: 640px; max-width: 92vw; }
.notice-preview-body { max-height: 70vh; overflow-y: auto; }
.notice-preview-cover { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 16px; }
.notice-preview-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-soft); margin-bottom: 14px; }
.notice-preview-content { line-height: 1.8; color: var(--text); }
.notice-preview-content p { margin: 0 0 10px; }
.notice-preview-content img { max-width: 100%; border-radius: var(--radius-sm); }
.notice-preview-content a { color: var(--accent); }

/* ===== 设备详情页（DeviceDetailView） ===== */
.dd { padding: 4px 0; }
.dd-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.dd-title { display: flex; align-items: center; gap: 10px; }
.dd-name { font-size: 18px; font-weight: 700; }
.dd-chart-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.dd-stat { color: var(--text-soft); font-size: 13px; }
.dd .seg { margin: 0; }

/* 设备详情 — 左右面板等高，右侧标题固定、表头吸顶、仅数据滚动 */
.dd .grid.cols-2 > .card {
  height: 540px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dd .grid.cols-2 > .card .card-title {
  flex-shrink: 0;
}
.dd .grid.cols-2 > .card .dd-rt-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
/* 表头吸顶：必须覆盖全局 .mini-table 的 overflow:hidden，否则会切断 sticky */
.dd .grid.cols-2 > .card .mini-table {
  overflow: visible;
  margin-top: 4px;
}
.dd .grid.cols-2 > .card .mini-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  box-shadow: inset 0 -1px 0 var(--border);
}
@media (max-width: 700px) {
  .dd .grid.cols-2 > .card { height: auto; overflow: visible; }
  .dd .grid.cols-2 > .card .dd-rt-body { overflow-y: visible; }
}

/* 设备详情 — 连接态说明行（长文本换行） */
.dd .kv.hint-line { flex-direction: column; align-items: flex-start; gap: 2px; }
.dd .kv.hint-line b { font-weight: 400; font-size: 12px; color: var(--text-soft); line-height: 1.5; }

/* 设备详情 — 数据过期警告横幅 */
.dd-stale-warn {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #856404;
  line-height: 1.5;
}
.dd-stale-warn .badge { margin: 0 4px; }

/* ===== 登录页安全机制（验证码 + 提示） ===== */
.captcha-row { display: flex; align-items: center; gap: 8px; }
.captcha-img { display: inline-flex; width: 124px; height: 46px; border-radius: 6px; overflow: hidden; cursor: pointer; border: 1px solid rgba(255,255,255,.16); flex: 0 0 auto; }
.captcha-img svg { display: block; width: 100%; height: 100%; }
.captcha-row .input { flex: 1; min-width: 0; }
.login-secure { margin-top: 14px; font-size: 12px; color: #94a3b8; line-height: 1.6; background: rgba(16,185,129,.08); border: 1px solid rgba(16,185,129,.2); border-radius: 8px; padding: 8px 10px; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.2); color: #cbd5e1; }
.btn.ghost:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.35); color: #fff; }

/* ===== 登录审计日志页 ===== */
.sec-stat { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sec-stat .muted, .muted { color: var(--text-soft); font-size: 13px; }

/* ===== 数据驾驶舱 DataCockpit（独立页面，与可视化大屏无关） ===== */
.cp-root { position: absolute; inset: 0; background: #020617; color: #e2f6ff; overflow: hidden; }
.cp-root.fullscreen { position: fixed !important; inset: 0 !important; z-index: 999999 !important; }
/* 全屏=整个驾驶舱（含抬头/工具栏/左右数据栏/地图），仅隐藏边缘把手 */
.cp-root.fullscreen .cp-handle { display: none !important; }
.cp-root.fullscreen .cp-stage { top: 64px !important; }
.cp-root.fullscreen .cp-side { top: 70px !important; bottom: 40px !important; }
.cp-root.fullscreen .cp-map-legend { bottom: 22px !important; }
.cp-root * { box-sizing: border-box; }
.cp-scanline { position: absolute; left: 0; right: 0; height: 2px; background: rgba(0,240,255,0.35); box-shadow: 0 0 16px rgba(0,240,255,0.5); animation: cp-scan 8s linear infinite; z-index: 50; pointer-events: none; }
@keyframes cp-scan { 0% { top: 0; opacity: 0; } 12% { opacity: 1; } 90% { opacity: 1; } 100% { top: 100%; opacity: 0; } }
.cp-header { position: absolute; z-index: 100000; top: 0; left: 0; right: 0; height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: linear-gradient(180deg, rgba(4,22,30,0.98), rgba(4,22,30,0.85)); border-bottom: 1px solid rgba(0,240,255,0.22); }
.cp-header-right { display: flex; align-items: center; gap: 16px; }
.cp-toolbar { display: flex; align-items: center; gap: 8px; }
.cp-toolbar button { background: rgba(4,18,26,0.9); border: 1px solid rgba(0,240,255,0.35); color: #eafdff; padding: 8px 14px; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 7px; transition: background .2s, box-shadow .2s; white-space: nowrap; }
.cp-toolbar button:hover { background: rgba(0,240,255,0.16); box-shadow: 0 0 14px rgba(0,240,255,0.4); }
.cp-fs-btn { background: rgba(0,240,255,0.18) !important; border-color: rgba(0,240,255,0.6) !important; color: #fff !important; }
.cp-fs-btn:hover { background: rgba(0,240,255,0.32) !important; box-shadow: 0 0 18px rgba(0,240,255,0.6) !important; }
.cp-header::after { content: ''; position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%); width: 420px; height: 2px; background: linear-gradient(90deg, transparent, #00f0ff, transparent); box-shadow: 0 0 12px #00f0ff; }
.cp-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: 2px; background: linear-gradient(90deg, #fff, #00f0ff); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 0 22px rgba(0,240,255,0.25); }
.cp-sub { font-size: 11px; color: #7fb6c9; letter-spacing: 4px; margin-top: 2px; }
.cp-meta { display: flex; align-items: center; gap: 18px; font-size: 13px; color: #94b8c7; }
.cp-tenant { padding: 4px 12px; border: 1px solid rgba(0,240,255,0.3); border-radius: 6px; background: rgba(0,240,255,0.06); }
.cp-clock { font-size: 18px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }

.cp-stage { position: absolute; top: 64px; left: 0; right: 0; bottom: 0; z-index: 10; }
.cp-map-wrap { position: absolute; inset: 0; background: #04101a; }
.cp-map { width: 100%; height: 100%; }
.cp-map-overlay { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(0,240,255,0.06); }
.cp-map-overlay::before, .cp-map-overlay::after { content: ''; position: absolute; width: 44px; height: 44px; border: 2px solid rgba(0,240,255,0.5); }
.cp-map-overlay::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.cp-map-overlay::after { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }
.cp-map-head { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); z-index: 100000; display: flex; gap: 12px; align-items: center; }
.cp-breadcrumb { display: flex; gap: 8px; align-items: center; background: rgba(4,18,26,0.85); border: 1px solid rgba(0,240,255,0.18); padding: 7px 14px; font-size: 13px; color: #94b8c7; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.cp-breadcrumb span { cursor: pointer; }
.cp-breadcrumb span:hover, .cp-breadcrumb span.active { color: #00f0ff; }
.cp-breadcrumb span:not(:last-child)::after { content: '>'; margin-left: 8px; color: #475569; }
.cp-map-actions { display: flex; gap: 8px; }
.cp-map-actions button { background: rgba(4,18,26,0.85); border: 1px solid rgba(0,240,255,0.18); color: #fff; padding: 7px 14px; font-size: 12px; cursor: pointer; clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px); }
.cp-map-actions button:hover { background: rgba(0,240,255,0.14); }
.cp-exit-fullscreen { position: absolute; top: 18px; right: 18px; z-index: 10000; display: none; align-items: center; gap: 6px; background: rgba(239,68,68,0.9); border: 1px solid rgba(239,68,68,0.7); color: #fff; padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 8px; box-shadow: 0 0 20px rgba(239,68,68,0.45); }
.cp-exit-fullscreen:hover { background: rgba(239,68,68,1); box-shadow: 0 0 28px rgba(239,68,68,0.65); }
.cp-root.fullscreen .cp-exit-fullscreen { display: none !important; }
.cp-map-legend { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 1000; background: rgba(4,18,26,0.85); border: 1px solid rgba(0,240,255,0.18); padding: 9px 14px; display: flex; gap: 16px; font-size: 12px; color: #94b8c7; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.cp-map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.cp-map-legend i.dot { border-radius: 50%; }

.cp-side { position: absolute; top: 70px; bottom: 40px; width: 340px; z-index: 9999 !important; display: block !important; opacity: 1 !important; visibility: visible !important; background: rgba(5,20,28,0.98) !important; border: 1px solid rgba(0,240,255,0.45) !important; box-shadow: 0 0 40px rgba(0,240,255,0.18), inset 0 0 60px rgba(0,240,255,0.04); transition: transform .45s cubic-bezier(.16,1,.3,1); will-change: transform; }
.cp-side.left { left: 12px; }
.cp-side.right { right: 12px; width: 360px; }
.cp-side.left.collapsed { transform: translateX(calc(-100% - 24px)); }
.cp-side.right.collapsed { transform: translateX(calc(100% + 24px)); }
.cp-side-inner { height: 100%; display: flex; flex-direction: column; gap: 13px; overflow: hidden; padding: 10px; }

.cp-panel { position: relative; border-radius: 10px; border: 1px solid rgba(0,240,255,0.25); background: rgba(8,30,40,0.94); box-shadow: 0 0 30px rgba(0,240,255,0.07) inset, 0 0 18px rgba(0,240,255,0.05); overflow: hidden; }
.cp-side.left .cp-panel { background: rgba(8,30,40,0.94); }
.cp-side.right .cp-panel { background: rgba(8,30,40,0.94); }
.cp-panel::before { content: ''; position: absolute; inset: 0; border-radius: 10px; padding: 1px; background: linear-gradient(120deg, transparent 30%, rgba(0,240,255,0.45) 50%, transparent 70%); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: cp-flow 4s linear infinite; pointer-events: none; }
@keyframes cp-flow { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.cp-corner { position: absolute; width: 12px; height: 12px; border: 2px solid #00f0ff; pointer-events: none; }
.cp-corner.tl { top: 5px; left: 5px; border-right: 0; border-bottom: 0; }
.cp-corner.br { bottom: 5px; right: 5px; border-left: 0; border-top: 0; }
.cp-panel-title { display: flex; align-items: center; gap: 10px; padding: 12px 16px 8px; font-size: 15px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(0,240,255,0.12); }
.cp-panel-title::before { content: ''; width: 4px; height: 15px; background: #00f0ff; box-shadow: 0 0 8px #00f0ff; transform: skewX(-15deg); flex-shrink: 0; }
.cp-collapse-btn { margin-left: auto; background: rgba(0,240,255,0.12); border: 1px solid rgba(0,240,255,0.45); color: #eafdff; font-size: 12px; padding: 3px 10px; cursor: pointer; border-radius: 6px; display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; transition: background .2s, box-shadow .2s; }
.cp-collapse-btn.left-edge { margin-left: 0; margin-right: auto; }
.cp-collapse-btn:hover { background: rgba(0,240,255,0.3); box-shadow: 0 0 14px rgba(0,240,255,0.5); }
.cp-collapse-btn .ar { font-size: 15px; line-height: 1; }
.cp-panel-body { padding: 13px 16px; }

.cp-kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.cp-kpi { position: relative; padding: 12px 8px; text-align: center; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); background: linear-gradient(135deg, rgba(0,240,255,0.1), rgba(0,240,255,0.02)); border: 1px solid rgba(0,240,255,0.16); }
.cp-kpi .num { font-size: 24px; font-weight: 800; color: #fff; line-height: 1; margin-bottom: 5px; text-shadow: 0 0 12px rgba(0,240,255,0.25); }
.cp-kpi .num.warn { color: #f59e0b; text-shadow: 0 0 12px rgba(245,158,11,0.25); }
.cp-kpi .num.danger { color: #ef4444; text-shadow: 0 0 12px rgba(239,68,68,0.25); }
.cp-kpi .num.success { color: #22c55e; text-shadow: 0 0 12px rgba(34,197,94,0.25); }
.cp-kpi .label { font-size: 11px; color: #94b8c7; }

.cp-stat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.cp-stat-row .label { width: 58px; font-size: 12px; color: #94b8c7; }
.cp-stat-row .bar { flex: 1; height: 8px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; }
.cp-stat-row .bar > div { height: 100%; border-radius: 4px; box-shadow: 0 0 10px currentColor; transition: width .6s ease; }
.cp-stat-row .num { width: 38px; text-align: right; font-size: 14px; font-weight: 700; }

.cp-level-row { display: flex; gap: 10px; margin-top: 10px; }
.cp-level-row .lv { flex: 1; text-align: center; padding: 7px; font-size: 12px; border-radius: 6px; }
.cp-level-row .lv.danger { background: rgba(239,68,68,0.15); color: #ef4444; }
.cp-level-row .lv.warn { background: rgba(245,158,11,0.15); color: #f59e0b; }

.cp-alarm-item { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 12px; }
.cp-alarm-item:last-child { border-bottom: 0; }
.cp-alarm-item .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: #22c55e; }
.cp-alarm-item .dot.warn { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.cp-alarm-item .dot.danger { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.cp-alarm-item .dot.ok { background: #64748b; }
.cp-alarm-item .time { color: #94b8c7; font-size: 11px; min-width: 54px; }
.cp-alarm-item .txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-empty { color: #64748b; font-size: 13px; text-align: center; padding: 20px 0; }

.cp-gauge-wrap { height: 190px; }
.cp-chart-wrap { flex: 1; min-height: 150px; }
.cp-rank-table,
.cp-rank-table thead,
.cp-rank-table tbody,
.cp-rank-table tr,
.cp-rank-table th,
.cp-rank-table td { background: rgba(4,18,26,0.95) !important; color: #e2f6ff !important; }
.cp-rank-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; border-radius: 8px; overflow: hidden; border: 1px solid rgba(0,240,255,0.25) !important; }
.cp-rank-table th { text-align: left; color: #00f0ff !important; background: rgba(4,18,26,0.98) !important; font-weight: 600; padding: 9px 8px; border-bottom: 1px solid rgba(0,240,255,0.3) !important; }
.cp-rank-table tbody tr { background: rgba(4,18,26,0.92) !important; transition: background .2s; }
.cp-rank-table tbody tr:nth-child(even) { background: rgba(6,28,38,0.95) !important; }
.cp-rank-table tbody tr:hover { background: rgba(0,240,255,0.14) !important; }
.cp-rank-table td { padding: 9px 8px; color: #e2f6ff !important; border-bottom: 1px solid rgba(0,240,255,0.12) !important; }
.cp-rank-table tbody tr:last-child td { border-bottom: 0 !important; }
.cp-rank-table tbody tr:nth-child(1) td:first-child { color: #ef4444 !important; font-weight: 700; }
.cp-rank-table tbody tr:nth-child(2) td:first-child { color: #f59e0b !important; font-weight: 700; }
.cp-rank-table tbody tr:nth-child(3) td:first-child { color: #00f0ff !important; font-weight: 700; }
.cp-rank-table .cp-empty { color: #64748b !important; background: transparent !important; }
.cp-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; background: rgba(239,68,68,0.15); color: #ef4444; }

.cp-handle { position: absolute; top: 50%; transform: translateY(-50%); z-index: 9999; width: 32px; height: 112px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #eafdff; background: rgba(0,240,255,0.16); border: 1px solid rgba(0,240,255,0.55); box-shadow: 0 0 16px rgba(0,240,255,0.35), inset 0 0 12px rgba(0,240,255,0.22); transition: all .4s cubic-bezier(.16,1,.3,1); }
.cp-handle:hover { background: rgba(0,240,255,0.32); box-shadow: 0 0 28px rgba(0,240,255,0.65), inset 0 0 16px rgba(0,240,255,0.4); }
.cp-handle svg { width: 20px; height: 20px; flex-shrink: 0; }
.cp-handle .ic-expand { display: none; }
.cp-handle .ic-collapse { display: block; }
.cp-handle.collapsed .ic-expand { display: block; }
.cp-handle.collapsed .ic-collapse { display: none; }
.cp-handle .hint { display: none; }
.cp-handle.collapsed .hint { display: block; writing-mode: vertical-rl; font-size: 12px; letter-spacing: 3px; color: #eafdff; line-height: 1.1; }
.cp-handle.left { left: 352px; border-radius: 0 14px 14px 0; }
.cp-handle.right { right: 372px; border-radius: 14px 0 0 14px; }
.cp-handle.left.collapsed { left: 8px; }
.cp-handle.right.collapsed { right: 8px; }
.cp-handle.collapsed { background: rgba(0,240,255,0.3); animation: cp-pulse 2s ease-in-out infinite; }
@keyframes cp-pulse { 0%, 100% { box-shadow: 0 0 14px rgba(0,240,255,0.4), inset 0 0 10px rgba(0,240,255,0.3); } 50% { box-shadow: 0 0 34px rgba(0,240,255,0.85), inset 0 0 18px rgba(0,240,255,0.5); } }

.cp-ticker { position: absolute; bottom: 0; left: 0; right: 0; z-index: 45; height: 30px; background: rgba(4,18,26,0.92); border-top: 1px solid rgba(0,240,255,0.22); display: flex; align-items: center; overflow: hidden; }
.cp-ticker .label { padding: 0 16px; background: rgba(0,240,255,0.1); color: #00f0ff; font-size: 12px; height: 100%; display: flex; align-items: center; }
.cp-ticker .scroll { flex: 1; overflow: hidden; position: relative; }
.cp-ticker .scroll span { display: inline-block; white-space: nowrap; padding-left: 100%; animation: cp-marquee 26s linear infinite; font-size: 12px; color: #94b8c7; }
@keyframes cp-marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

.cp-cluster { border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; font-weight: 700; border: 2px solid rgba(255,255,255,0.35); box-shadow: 0 0 18px currentColor; }
.cp-cluster .n { font-size: 15px; line-height: 1; }
.cp-cluster .t { font-size: 10px; opacity: .9; margin-top: 1px; white-space: nowrap; }
.cp-device-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 12px currentColor; }

/* ============================================================
   设备详情 — 参数说明浮层 + 行点击联动
   ============================================================ */

/* 实时参数表格：可点击行 */
.dd-metric-table { cursor: default; }
.dd-metric-table tbody tr { cursor: pointer; transition: background-color .15s ease; }
.dd-metric-table tbody tr:hover { background-color: rgba(99,102,241,.06); }
.dd-metric-table tbody tr


.dd-row-selected {
  background-color: rgba(99,102,241,.18) !important;
  box-shadow: inset 3px 0 0 #6366f1;
}
html.dark .dd-metric-table tbody tr:hover { background-color: rgba(99,102,241,.15); }
html.dark .dd-metric-table tbody tr.dd-row-selected { background-color: rgba(99,102,241,.28) !important; }

/* 指标名称 + ? 图标 */
.dd-metric-name-cell { display: flex; align-items: center; gap: 4px; }
.dd-help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(99,102,241,.12); color: #6366f1;
  font-size: 11px; font-weight: 700; line-height: 1;
  cursor: help; flex-shrink: 0;
  transition: background-color .15s, color .15s;
}
.dd-help-icon:hover { background: #6366f1; color: #fff; }

/* 参数说明浮层 â ä» hover ? å¾æ æ¶æ¾ç¤ºï¼å®ä½å¨ ? ä¸æ¹ */
.dd-rt-body { position: relative; }
.dd-metric-tooltip {
  position: absolute; left: 50%; top: 0;
  transform: translateX(-50%);
  z-index: 20; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.12);
  padding: 12px 14px; font-size: 12.5px; line-height: 1.6;
  width: min(380px, calc(100% - 24px));
  animation: dd-tooltip-in .15s ease-out;
  pointer-events: none;
}
@keyframes dd-tooltip-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.dd-tooltip-title {
  font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px; color: var(--text);
}
.dd-tooltip-desc { color: var(--text-soft); margin-bottom: 6px; }
.dd-tooltip-thr { color: var(--text); margin-bottom: 4px; }
.dd-tooltip-thr b { color: var(--warning); }
.dd-tooltip-conseq { color: #dc2626; padding: 5px 8px; background: rgba(239,68,68,.06); border-radius: 6px; margin-bottom: 4px; }
.dd-tooltip-conseq b { color: #dc2626; }
.dd-tooltip-hint { color: var(--text-soft); font-size: 11.5px; opacity: .7; margin-top: 4px; }
html.dark .dd-metric-tooltip { box-shadow: 0 8px 30px rgba(0,0,0,.4); border-color: rgba(255,255,255,.1); }
html.dark .dd-tooltip-conseq { background: rgba(239,68,68,.12); }

/* ===== 接口文档 / 接口调试页 ===== */
.doc-list { margin: 0; padding-left: 18px; line-height: 1.9; }
.doc-list code, .doc-ep-path, .doc-params code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; color: var(--accent); }
.doc-ep-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.doc-ep-path { font-size: 14px; font-weight: 600; }
.doc-ep-title { color: var(--text-soft); font-size: 13px; }
.doc-ep-desc { color: var(--text-soft); line-height: 1.7; margin: 0 0 12px; }
.doc-params { margin-bottom: 12px; }
.doc-example { background: var(--surface-2); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.doc-example-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-soft); margin-bottom: 6px; }
.doc-example pre, .doc-curl pre, .doc-response { margin: 0; white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.6; }
.doc-curl { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.doc-curl pre { color: var(--text-soft); }
.doc-response { background: var(--surface-2); border-radius: 10px; padding: 14px; max-height: 440px; overflow: auto; color: var(--text); }
.form-row .checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.form-row .checkbox input { width: auto; }
.err { color: var(--danger); font-size: 13px; margin-left: 8px; }


/* ===== 设备范围选择器（api_keys device_ids）===== */
.scope-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--surface); }
.scope-search { margin-bottom: 6px; }
.scope-search .input.sm { width: 100%; box-sizing: border-box; font-size: 13px; }
.scope-hint { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.scope-list { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 4px; }
.scope-item { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.scope-item:hover { background: rgba(99,102,241,.06); }
.scope-item input[type="checkbox"] { accent-color: #6366f1; }
.scope-count { font-size: 12px; color: var(--muted); }
html.dark .scope-box { border-color: rgba(255,255,255,.1); }
html.dark .scope-list { border-color: rgba(255,255,255,.1); background: rgba(0,0,0,.15); }

/* 文档页操作按钮 */
.doc-actions .btn.sm { font-size: 12.5px; padding: 5px 12px; }
.doc-actions .btn.outline { border: 1px solid var(--border); background: transparent; }
html.dark .doc-actions .btn.outline { border-color: rgba(255,255,255,.15); }
@media print {
  .sidebar, .topbar, .doc-actions, .menu-toggle { display: none !important; }
  .page { margin: 0 !important; padding: 20px !important; }
}

/* ===== 自动生成字段（Key/Secret 明文只读展示）===== */
.gen-field { display:flex; gap:8px; align-items:center; flex-wrap:wrap; padding:4px 0; }
.gen-field .input[readonly] { background:var(--surface-2,#f5f5f5); color:var(--text-1,#111); cursor:text; min-width:280px; font-family:ui-monospace,monospace; letter-spacing:0.3px; }
html.dark .gen-field .input[readonly] { background:rgba(255,255,255,.06); color:#eee; }
.gen-field .hint { font-size:12px; opacity:0.65; white-space:nowrap; }
