:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #8b95a5;
  --line: #e8ecf3;
  --primary: #2f6fed;
  --primary-2: #5b8df7;
  --green: #16a34a;
  --red: #e5484d;
  --amber: #d97706;
  --side: #111c2e;
  --side-2: #16243a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录 ---------- */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 10% 10%, #1d3b6e 0%, #0c1626 45%, #070d16 100%);
}
.login-panel {
  display: grid; grid-template-columns: 1.1fr .9fr; width: 880px; max-width: 94vw; min-height: 480px;
  background: var(--panel); border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.login-brand {
  padding: 46px 44px; color: #e8eefc;
  background: linear-gradient(160deg, #1d4ed8 0%, #1e3a8a 55%, #0f172a 100%);
  position: relative;
}
.login-brand::after {
  content: ""; position: absolute; inset: auto -60px -90px auto; width: 260px; height: 260px;
  border-radius: 50%; background: rgba(255, 255, 255, .07);
}
.brand-badge {
  width: 44px; height: 44px; border-radius: 12px; background: rgba(255, 255, 255, .16);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700;
  margin-bottom: 22px;
}
.login-brand h1 { font-size: 26px; letter-spacing: .4px; }
.brand-sub { margin-top: 8px; color: rgba(232, 238, 252, .72); font-size: 13px; }
.brand-points { margin-top: 40px; list-style: none; display: grid; gap: 14px; font-size: 13px; }
.brand-points li { padding-left: 18px; position: relative; color: rgba(232, 238, 252, .86); }
.brand-points li::before {
  content: ""; position: absolute; left: 0; top: 6px; width: 6px; height: 6px;
  border-radius: 50%; background: #7dd3fc;
}
.login-form { padding: 52px 46px; display: flex; flex-direction: column; }
.login-form h2 { font-size: 20px; margin: 0 0 26px; }
.login-form .muted { color: var(--ink-3); margin: 8px 0 26px; }
.login-form label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 16px; }
.login-form input {
  width: 100%; height: 44px; margin-top: 8px; padding: 0 12px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fbfcfe;
  transition: border-color .15s, box-shadow .15s;
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); background: #fff; }
.form-error { min-height: 18px; margin-top: 10px; color: var(--red); font-size: 12px; }
.login-foot { margin-top: auto; padding-top: 30px; color: var(--ink-3); font-size: 11px; }

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 216px; flex: 0 0 216px; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
  color: #c7d2e2;
}
.logo {
  display: flex; align-items: center; gap: 10px; height: 62px; padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .06); font-size: 15px; font-weight: 600; color: #fff;
}
.logo small { display: block; font-size: 10px; font-weight: 400; color: #7c8aa0; margin-top: 2px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8); font-size: 15px; font-weight: 700;
}
.menu { flex: 1; overflow-y: auto; padding: 10px 8px; }
.menu::-webkit-scrollbar { width: 6px; }
.menu::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }
.menu-item, .menu-group-title {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; margin: 2px 0;
  border-radius: 8px; cursor: pointer; font-size: 13px; user-select: none;
  transition: background .15s, color .15s;
}
.menu-group-title { justify-content: space-between; color: #a9b7cb; }
.menu-item { color: #c7d2e2; }
.menu-item:hover, .menu-group-title:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.menu-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, .28), rgba(59, 130, 246, .10));
  color: #fff; box-shadow: inset 2px 0 0 #60a5fa;
}
.menu-children { overflow: hidden; }
.menu-children .menu-item { padding-left: 38px; height: 38px; color: #a9b7cb; }
.menu-children .menu-item.active { color: #fff; }
.menu-arrow { font-size: 10px; color: #6b7a90; transition: transform .18s; }
.menu-group.open .menu-arrow { transform: rotate(180deg); }
.mi { width: 16px; height: 16px; flex: 0 0 16px; opacity: .9; }
.sidebar-foot { padding: 12px 18px; font-size: 11px; color: #64748b; border-top: 1px solid rgba(255, 255, 255, .06); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 58px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  border-bottom: 1px solid var(--line); z-index: 5;
}
.crumb { color: var(--ink-3); font-size: 12.5px; }
.crumb b { color: var(--ink); font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 12.5px; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .15); }
.who { padding: 4px 10px; background: #f1f5fb; border-radius: 20px; color: var(--ink-2); }
.content { flex: 1; overflow: auto; padding: 20px 22px 28px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel); border-radius: 12px; padding: 18px 18px 16px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.page-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.page-title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: linear-gradient(180deg, #3b82f6, #1d4ed8); }
.page-title .sub { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 4px; }

/* ---------- 搜索 / 工具 ---------- */
.searchbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.searchbar input, .searchbar select {
  height: 34px; min-width: 158px; padding: 0 11px; font-size: 13px; color: var(--ink-2);
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.searchbar input:focus, .searchbar select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 237, .10); background: #fff;
}
.toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.toolbar .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notice {
  display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; margin-bottom: 14px;
  background: #f0f6ff; border: 1px solid #dbe9ff; color: #35538a; border-radius: 8px; font-size: 12.5px;
}

/* ---------- 按钮 ---------- */
.btn {
  height: 34px; padding: 0 15px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); font-size: 13px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #c9d9f5; color: var(--primary); background: #f5f9ff; }
.btn.primary { background: linear-gradient(135deg, var(--primary), #1d5fe0); border-color: transparent; color: #fff; box-shadow: 0 4px 10px rgba(47, 111, 237, .22); }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: #fff1f1; border-color: #ffd9d9; color: var(--red); }
.btn.danger:hover { background: #ffe7e7; }
.btn.block { width: 100%; height: 44px; font-size: 14px; }
.btn.link { border: none; background: none; color: var(--primary); padding: 0 6px; height: 26px; }
.btn.link:hover { background: #eef4ff; }
.btn.link.danger-text { color: var(--red); }
.btn.link.danger-text:hover { background: #fff1f1; }

/* ---------- 表格 ---------- */
.table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
thead th {
  position: sticky; top: 0; background: #f8fafd; color: #5c6b82; font-size: 12.5px; font-weight: 600;
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #f1f4f9; color: var(--ink-2); font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f7faff; }
.empty { text-align: center; color: var(--ink-3); padding: 42px 0; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; line-height: 18px; }
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tag.online { background: #ecfdf3; color: #15803d; }
.tag.offline { background: #f3f4f6; color: #6b7280; }
.tag.danger { background: #fff1f1; color: #c2262b; }
.tag.blue { background: #eef4ff; color: #2559c4; }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 14px; color: var(--ink-3); font-size: 12.5px; }
.pager button {
  min-width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 7px;
  cursor: pointer; color: var(--ink-2); transition: all .15s;
}
.pager button:hover { border-color: #c9d9f5; color: var(--primary); }
.pager button.cur { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex;
  align-items: flex-start; justify-content: center; padding-top: 7vh; z-index: 100; backdrop-filter: blur(2px);
}
.modal {
  width: 920px; max-width: 94vw; background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .35); animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  height: 56px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 600;
}
.modal-close { border: none; background: none; font-size: 24px; line-height: 1; color: var(--ink-3); cursor: pointer; }
.modal-body { padding: 20px; max-height: 62vh; overflow: auto; }
.modal-foot { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-item { display: flex; flex-direction: column; gap: 7px; }
.form-item.full { grid-column: 1 / -1; }
.form-item > label { color: var(--ink-2); font-size: 12.5px; }
.req { color: var(--red); margin-right: 2px; }
.form-item input, .form-item select, .form-item textarea {
  width: 100%; height: 36px; padding: 0 11px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; outline: none;
}
.form-item textarea { height: 80px; padding: 9px 11px; resize: vertical; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
  border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(47, 111, 237, .10);
}

/* ---------- 首页 ---------- */
.hero {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 22px 24px; border-radius: 14px; color: #eaf1ff; margin-bottom: 16px;
  background: linear-gradient(120deg, #1d4ed8 0%, #2563eb 45%, #0ea5e9 100%);
  box-shadow: 0 12px 30px rgba(37, 99, 235, .25);
}
.hero h2 { font-size: 19px; font-weight: 600; }
.hero p { margin-top: 6px; color: rgba(234, 241, 255, .78); font-size: 12.5px; }
.hero .hero-badge { font-size: 12px; padding: 6px 12px; border-radius: 20px; background: rgba(255, 255, 255, .16); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: flex-start; transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .label { color: var(--ink-3); font-size: 12.5px; }
.stat-card .value { font-size: 28px; font-weight: 650; margin: 8px 0 4px; letter-spacing: -.5px; }
.stat-card .sub { color: var(--ink-3); font-size: 11.5px; }
.stat-card .sub b { color: var(--green); font-weight: 600; }
.stat-icon {
  width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  background: #eef4ff; color: var(--primary);
}
.stat-icon svg { width: 20px; height: 20px; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

.dept-picker { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.dept-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--line); background: #fbfcfe; color: var(--ink-2); cursor: pointer;
  font-size: 12.5px; transition: all .15s;
}
.dept-chip:hover { border-color: #c9d9f5; color: var(--primary); }
.dept-chip input { accent-color: var(--primary); }
.dept-chip:has(input:checked) { background: #eef4ff; border-color: #bfd6fb; color: #1d4ed8; }
.dept-chip:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.dept-hint { color: var(--ink-3); font-size: 11.5px; margin-top: 6px; }

.sys-list { display: grid; gap: 10px; }
.sys-list > div {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 0;
  border-bottom: 1px dashed #edf1f7; font-size: 12.5px; color: var(--ink-3);
}
.sys-list > div:last-child { border-bottom: none; }
.sys-list b { color: var(--ink-1); font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { background: #fff1f1; color: #c2262b; border: 1px solid #f5c9c9; }
.btn.danger:hover { background: #ffe4e4; }

.map-canvas {
  width: 100%; height: 240px; border-radius: 10px; border: 1px solid var(--line);
  background: #f4f7fb; overflow: hidden; z-index: 1;
}
.map-coord { margin-top: 8px; color: var(--ink-3); font-size: 12px; }
.map-coord b { color: var(--ink-1); font-weight: 600; }
.map-fallback { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--ink-3); font-size: 12px; }
.map-picker .leaflet-container { font: inherit; }

code.hex {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px; color: #1e3a8a; background: #f4f7ff; padding: 2px 6px;
  border-radius: 4px; white-space: nowrap;
}

/* ---------- 菜单权限 ---------- */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.perm-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: #fcfdff; }
.perm-role { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.perm-group { border-top: 1px dashed #e6ebf4; padding: 10px 0; }
.perm-group:first-of-type { border-top: none; }
.perm-group-title { color: var(--ink-3); font-size: 12px; margin-bottom: 8px; }
.perm-item {
  display: flex; align-items: center; gap: 7px; padding: 6px 4px; border-radius: 6px;
  color: var(--ink-2); cursor: pointer;
}
.perm-item:hover { background: #f2f7ff; }
.perm-item input { accent-color: var(--primary); width: 14px; height: 14px; }
.perm-path { margin-left: auto; color: #a8b3c4; font-size: 11px; font-family: ui-monospace, monospace; }
.perm-card > .btn { margin-top: 14px; }

@media (max-width: 900px) {
  .perm-grid { grid-template-columns: 1fr; }
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  padding: 11px 20px; border-radius: 10px; background: #1f2937; color: #fff; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 300;
}
.toast.err { background: var(--red); }

@media (max-width: 900px) {
  .login-panel { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .two-col { grid-template-columns: 1fr; }
}

/* ---------- 模板寄存器 ---------- */
.reg-editor { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.reg-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.reg-tip { color: var(--ink-3); font-size: 12px; }
.reg-head .btn { margin-left: auto; }
.reg-table { table-layout: fixed; width: 100%; min-width: 0; }
.reg-table th, .reg-table td { padding: 6px 5px; overflow: hidden; }
.reg-table input, .reg-table select {
  width: 100%; height: 32px; padding: 0 7px; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 7px; background: #fbfcfe; outline: none;
}
.reg-table .c-unit { width: 5%; }
.reg-table .c-regtype { width: 6%; }
.reg-table .c-regtype select { padding: 0 2px 0 4px; }
.reg-table .c-offset { width: 6%; }
.reg-table .c-offset input { text-align: center; padding: 0 2px; }
.reg-table .c-datatype { width: 12%; }
.reg-table .c-dec { width: 7%; }
.reg-table .c-dec input { text-align: center; padding: 0 2px; }
.reg-table .c-rw { width: 10%; }
.reg-table .c-display { width: 9%; }
.reg-table .c-style { width: 12%; white-space: nowrap; }
.reg-table .c-style select { height: 26px; }
.reg-table .c-hide { width: 4%; text-align: center; }
.reg-table .c-addr { width: 8%; }
/* 设备查看里的寄存器列表：收窄名称列，给右侧字段留空间 */
.reg-view .c-name { width: 26%; }
.reg-view .c-unit { width: 7%; }
.reg-view .c-dec { width: 7%; }
.reg-view .c-regtype { width: 7%; }
.reg-view .c-offset { width: 9%; }
.reg-view .c-datatype { width: 20%; }
.reg-view .c-rw { width: 12%; }
.reg-view .c-addr { width: 12%; }
.reg-table .c-op { width: 12%; white-space: nowrap; }
.reg-table .c-op .btn { padding: 0 2px; }
.reg-table .c-wval { width: 14%; }
.reg-table .c-fc { width: 10%; white-space: nowrap; }
.reg-table .c-start { width: 13%; }
.reg-table .c-qty { width: 11%; }
.reg-op { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.reg-move { display: inline-flex; flex: none; }
.reg-op [data-reg-del] { margin-left: auto; }
.reg-table input[type="color"] { width: 24px; height: 26px; padding: 1px; margin-right: 2px; }
.reg-table input[type="checkbox"] { width: 15px; height: 15px; }
.reg-addr { color: var(--primary); font-weight: 600; font-family: ui-monospace, monospace; }
.poll-box { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.poll-box .form-grid { gap: 12px 16px; }
.poll-auto { display: flex; align-items: center; gap: 6px; margin-left: auto; color: var(--ink-2); font-size: 12.5px; }
.poll-auto input { width: auto; height: auto; }
.poll-box input[readonly] { background: #f2f5fa; color: var(--ink-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .5px; }
.ctrl-frame { background: #f2f5fa; color: var(--ink-2); }

/* ---------- 报文监控（设备 / 服务器 对话视图） ---------- */
.chat-box {
  height: 430px; overflow-y: auto; padding: 16px 18px;
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px;
}
.chat-row { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-start; }
.chat-row.right { flex-direction: row-reverse; }
.chat-avatar {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
  background: #e9edf4; color: #6b7280; display: flex; align-items: center;
  justify-content: center; margin-top: 16px;
}
.chat-avatar .chat-icon { width: 18px; height: 18px; }
.chat-main { max-width: 72%; }
.chat-row.right .chat-main { text-align: right; }
.chat-time { font-size: 11.5px; color: #8a94a6; margin-bottom: 4px; }
.chat-name { font-size: 12px; font-weight: 600; color: #4b5563; margin-bottom: 3px; }
.chat-bubble {
  display: inline-block; text-align: left; padding: 10px 12px; border-radius: 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
  line-height: 1.6; word-break: break-all; white-space: pre-wrap;
}
.chat-row.left .chat-bubble { background: #e9f8e5; border: 1px solid #d5efce; color: #2f5d2a; }
.chat-row.right .chat-bubble { background: #e8f2fe; border: 1px solid #d3e4fb; color: #1e4b8f; }
.chat-parse { margin-top: 4px; font-size: 12px; }

/* ---------- 物理量解析面板 ---------- */
.parse-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; font-size: 13px; color: var(--ink-2);
}
.parse-hex {
  background: #1f2430; color: #c9f7c1; border-radius: 8px;
  padding: 12px 14px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.9; word-break: break-all; white-space: pre-wrap;
  margin-bottom: 14px;
}
.parse-note { margin-bottom: 10px; font-size: 12.5px; }
.parse-table .parse-val { color: #16a34a; font-weight: 600; }
.parse-table td, .parse-table th { padding: 9px 12px; }

/* ---------- 设备数据展示 ---------- */
.muted { color: var(--ink-3); }
.ind-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 2px rgba(0, 0, 0, .06);
}
.sw {
  display: inline-block; width: 34px; height: 18px; border-radius: 9px;
  background: #d6dbe5; position: relative; vertical-align: -3px; margin-right: 6px;
}
.sw::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; transition: left .15s;
}
.sw.on { background: var(--green); }
.sw.green.on { background: #16a34a; }
.sw.blue.on { background: #2f6fed; }
.sw.orange.on { background: #f59e0b; }
.sw.red.on { background: #e5484d; }
.sw.on::after { left: 18px; }
.sw-text { color: var(--ink-2); font-size: 12.5px; }
.val-input {
  width: 100%; height: 30px; padding: 0 8px; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; outline: none;
}



/* 网关 AT 指令调试 */
.at-card { margin-top: 14px; border: 1px solid var(--line); }
.at-card .page-title { margin-bottom: 10px; }
.at-actions { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.at-out {
  margin: 0; padding: 12px 14px; min-height: 96px; max-height: 240px; overflow: auto;
  background: #0f172a; color: #d7e3ff; border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}


/* 网关参数面板 */
.gp-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 14px;
  padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 10px; font-size: 12.5px; color: var(--ink-2);
}
.gp-tag { background: #eef4ff; color: var(--primary); border-radius: 6px; padding: 2px 8px; font-weight: 600; }
.gp-group { margin-bottom: 16px; }
.gp-title {
  font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 10px;
  padding-left: 8px; border-left: 3px solid var(--primary);
}
.gp-ctl { display: flex; align-items: center; gap: 8px; }
.gp-ctl input, .gp-ctl select { flex: 1; min-width: 0; }
.gp-ctl input[disabled] { background: #f1f5f9; color: var(--ink-3); }
.gp-unit { font-size: 12px; color: var(--ink-3); }
.gp-mode { flex: 0 0 92px !important; }
.gp-map { height: 220px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; }
.gp-map-empty {
  padding: 22px 12px; margin-bottom: 12px; text-align: center;
  color: var(--ink-3); font-size: 13px; background: #f8fafc; border-radius: 10px;
}
.gp-st { font-size: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-st.ok { color: #15803d; }
.gp-st.err { color: #b91c1c; }
.gp-adv { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.gp-adv > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.gp-adv[open] > summary { margin-bottom: 12px; }
.gp-logs { font-size: 12px; }
.gp-hint { color: #b45309; }
.gp-at-row { display: flex; gap: 8px; margin-bottom: 8px; }
.gp-at-tip { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.gp-at-row input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; }
.gp-at-out {
  margin: 0; padding: 10px 12px; max-height: 200px; overflow: auto;
  background: #0f172a; color: #d7e3ff; border-radius: 8px; font-size: 12px;
  line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
.gp-empty { padding: 36px 12px; text-align: center; color: var(--ink-3); font-size: 13px; }
.gp-logs > summary { cursor: pointer; color: var(--ink-2); }
.gp-logs pre {
  margin: 8px 0 0; padding: 10px 12px; max-height: 220px; overflow: auto;
  background: #0f172a; color: #d7e3ff; border-radius: 8px; font-size: 11.5px;
  line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}


/* 历史数据 */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  border: none; background: #fff; padding: 0 14px; height: 34px; font-size: 13px;
  color: var(--ink-2); cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: #eef4ff; color: var(--primary); font-weight: 600; }
.his-stats { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); margin-bottom: 12px; }
.his-stats b { color: var(--ink); }
.his-chart { border: 1px solid var(--line); border-radius: 10px; padding: 12px 8px; background: #fff; }
.his-chart svg { width: 100%; height: auto; display: block; }


/* 可视化：编排与设备展示 */
.vz-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vz-overlay { position: fixed; inset: 0; z-index: 1200; background: #f4f6fb; display: flex; flex-direction: column; }
.vz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.vz-title { font-size: 16px; font-weight: 600; }
.vz-meta { font-size: 12px; color: var(--ink-3); margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.vz-body { flex: 1; overflow: auto; padding: 14px; }
.vz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.vz-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.vz-card.span2 { grid-column: span 2; }
.vz-name { font-size: 12.5px; color: var(--ink-3); margin-bottom: 8px; }
.vz-val { font-size: 26px; font-weight: 700; color: var(--ink); line-height: 1.1; word-break: break-all; }
.vz-val small { font-size: 12px; color: var(--ink-3); margin-left: 4px; font-weight: 400; }
.vz-section { grid-column: 1 / -1; font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 4px 2px 0; }
.vz-status { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.vz-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.vz-bar { height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden; margin-top: 10px; }
.vz-bar i { display: block; height: 100%; background: linear-gradient(90deg, #3b82f6, #1d4ed8); }
.vz-bar-v { height: 60px; display: flex; align-items: flex-end; margin-top: 4px; }
.vz-bar-v i { display: block; width: 100%; }
.vz-switch-block { display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 24px; padding: 0 10px; border-radius: 12px; color: #fff; font-size: 12px; }
.vz-switch { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.vz-switch i { width: 38px; height: 20px; border-radius: 10px; background: #d7dee8; position: relative; display: inline-block; }
.vz-switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: .2s; }
.vz-switch.on i { background: #16a34a; }
.vz-switch.on i::after { left: 20px; }
.vz-node-inner { position: relative; }
.vz-node .vz-edit { pointer-events: none; }
.vz-edit { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 20px; height: 20px; margin: 0 2px; padding: 0; border: 1px solid var(--line);
  border-radius: 5px; background: rgba(255, 255, 255, .94); color: var(--ink-2); cursor: pointer; }
.vz-edit:hover { border-color: var(--blue); color: var(--blue); }
.vz-val-edit { display: flex; align-items: center; justify-content: center; gap: 1px;
  white-space: nowrap; }
.vz-val-edit small { margin-left: 1px; }
.vz-dlg-mask { position: fixed; inset: 0; z-index: 1500; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; }
.vz-dlg { width: 320px; background: #fff; border-radius: 10px; padding: 16px 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25); }
.vz-dlg-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.vz-dlg-row { display: flex; align-items: center; gap: 8px; }
.vz-dlg-input { flex: 1; height: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 7px; font-size: 14px; }
.vz-dlg-unit { font-size: 13px; color: var(--ink-3); min-width: 30px; }
.vz-dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.vz-clickable { cursor: pointer; }
.sw-click { cursor: pointer; }
.vz-io-edit { display: flex; align-items: center; gap: 6px; }
.vz-io-edit .vz-input { width: 66px; padding: 4px 6px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 6px; }
.vz-io-edit small { font-size: 12px; color: var(--ink-3); }
.vz-io-edit .vz-send { padding: 3px 8px; font-size: 12px; border-radius: 6px;
  border: 1px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; }
.vz-io-edit .vz-send:disabled { opacity: .6; cursor: default; }
.vz-canvas { position: relative; width: 100%; }
.vz-canvas img { width: 100%; display: block; border-radius: 12px; }
.vz-hot { position: absolute; transform: translate(-50%, -50%); cursor: pointer; }
.vz-hot i { display: block; width: 14px; height: 14px; border-radius: 50%; background: #2f6fed;
  border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(47, 111, 237, .25); }
.vz-bubble { display: none; position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  white-space: nowrap; box-shadow: var(--shadow); font-size: 14px; }
.vz-bubble span { display: block; font-size: 11px; color: var(--ink-3); }
.vz-hot.open .vz-bubble { display: block; }
@media (max-width: 640px) {
  .vz-grid { grid-template-columns: repeat(2, 1fr); }
  .vz-body { padding: 10px; }
}


/* 可视化：HMI 画布编辑 */
.vz-edit-wrap { display: grid; grid-template-columns: 375px 1fr; gap: 14px; align-items: start; }
.vz-stage {
  position: relative; width: 375px; height: 667px; border: 1px dashed #c9d6ea;
  border-radius: 10px; overflow: hidden; background-color: #fff;
  background-position: 0 0; background-size: 100% 100%; background-repeat: no-repeat;
}
.vz-node {
  position: absolute; background: rgba(255, 255, 255, .94); border: 1px solid #dbe3ee;
  border-radius: 8px; overflow: hidden; cursor: move; user-select: none; touch-action: none;
}
.vz-node.sel { outline: 2px solid var(--primary); outline-offset: 1px; z-index: 5; }
.vz-node-inner { height: 100%; padding: 6px 8px; display: flex; flex-direction: column;
  justify-content: center; gap: 2px; overflow: hidden; }
.vz-node-name { font-size: 10px; color: #7a8699; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vz-node-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.vz-node .vz-val, .vz-node-static .vz-val { font-size: 20px; }
.vz-node .vz-status, .vz-node-static .vz-status { font-size: 14px; }
.vz-node .vz-bar { margin-top: 4px; }
.vz-resize { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px;
  cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--primary) 50%); }
.vz-props { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; min-height: 200px; }
.vz-hint { color: var(--ink-3); font-size: 12.5px; line-height: 2; padding: 14px 6px; }
.vz-prop-grid { display: grid; grid-template-columns: repeat(3, minmax(86px, 1fr)); gap: 10px; }
.vz-prop-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); }
.vz-prop-grid input, .vz-prop-grid select {
  height: 30px; padding: 0 6px; font-size: 12.5px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; outline: none;
}
.vz-prop-actions { margin-top: 12px; display: flex; gap: 8px; }
@media (max-width: 900px) {
  .vz-edit-wrap { grid-template-columns: 1fr; }
  .vz-stage { width: 100%; max-width: 375px; }
}
/* 可视化：设备端画布 */
.vz-canvas-wrap { width: 100%; overflow: hidden; border-radius: 12px; }
.vz-stage-static {
  position: relative; transform-origin: top left; background-color: #fff; margin: 0 auto;
  background-position: 0 0; background-size: 100% 100%; background-repeat: no-repeat;
}
.vz-node-static {
  position: absolute; background: rgba(255, 255, 255, .94); border: 1px solid #dbe3ee;
  border-radius: 8px; overflow: hidden;
}
.vz-dev { height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--ink-2); }
.vz-bg-row { display: flex; gap: 8px; align-items: center; }
.vz-bg-row input { flex: 1; }
.vz-bg-prev img { max-width: 180px; max-height: 120px; border: 1px solid var(--line);
  border-radius: 8px; margin-top: 8px; display: block; }
/* 可视化编排：全屏弹窗 */
#modal.modal-full .modal {
  width: 100vw; height: 100vh; max-width: none; max-height: none;
  border-radius: 0; display: flex; flex-direction: column;
}
#modal.modal-full .modal-body { flex: 1; max-height: none; overflow: auto; }
#modal.modal-full .modal-foot { flex: none; }
#modal.modal-full .vz-edit-wrap { grid-template-columns: 375px minmax(320px, 1fr); }
/* 可视化编排：左数据 / 中手机 / 右设置 */
#modal.modal-full .modal-body { overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.vz-tools { flex: none; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line); }
.vz-work { flex: 1; min-height: 0; display: grid;
  grid-template-columns: 220px 375px minmax(320px, 1fr); gap: 14px; padding: 14px;
  box-sizing: border-box; }
.vz-palette-col, .vz-stage-col, .vz-props-col { min-height: 0; display: flex; flex-direction: column; }
.vz-col-title { flex: none; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 8px; }
.vz-palette { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column;
  gap: 8px; padding-right: 4px; }
.vz-pal { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  cursor: grab; font-size: 13px; color: var(--ink-2); }
.vz-pal:active { cursor: grabbing; }
.vz-pal small { color: var(--ink-3); }
.vz-pal.used { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.vz-stage-scroll { flex: 1; min-height: 0; overflow: auto; display: flex;
  justify-content: center; align-items: flex-start; }
.vz-stage.drop { outline: 2px dashed var(--primary); outline-offset: 2px; }
.vz-props-col { overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; }
.vz-side-form { grid-template-columns: 1fr 1fr; }
.vz-side-form .full { grid-column: 1 / -1; }
.vz-bg-row { flex-wrap: wrap; }
@media (max-width: 900px) {
  .vz-work { grid-template-columns: 1fr; grid-auto-rows: auto; overflow: auto; }
  .vz-palette-col { max-height: 160px; }
}
/* 已拖入画布的变量：置灰 */
.vz-pal.used { background: #f2f4f7; border-color: #e2e7ef; color: #9aa4b2;
  box-shadow: none; }
.vz-pal.used small { color: #b8c0cb; }
.vz-pal.used::after { content: "已添加"; font-size: 11px; color: #b8c0cb; }
/* 全屏编排：底部按钮固定可见 */
#modal.modal-full { padding-top: 0; }
#modal.modal-full .modal { height: 100vh; max-height: 100vh; }
#modal.modal-full .modal-foot { flex: none; border-top: 1px solid var(--line); background: #fff; }
/* 组件属性 */
.vz-prop-grid .vz-chk { flex-direction: row; align-items: center; gap: 6px; height: 30px;
  font-size: 12px; color: var(--ink-3); }
.vz-prop-grid .vz-chk input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }
/* 左侧分组与按钮控件 */
.vz-pal-group { font-size: 12px; color: var(--ink-3); margin: 6px 0 2px; }
.vz-pal-group:first-child { margin-top: 0; }
.vz-btn { height: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border-radius: 4px; font-size: 13px; }
/* 编排：操作按钮组 */
.vz-actions { display: flex; gap: 6px; height: 100%; align-items: stretch; }
.vz-action-btn { flex: 1; display: flex; align-items: center; justify-content: center;
  border: 1px solid #3c96f3; border-radius: 6px; background: #fff; white-space: nowrap; }
/* 编排：中间栏标题与编辑/预览切换 */
.vz-col-head { flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px; }
.vz-col-head .vz-col-title { margin: 0; }
.vz-head-tools { display: flex; align-items: center; gap: 8px; }
.vz-seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.vz-seg button { border: none; background: #fff; padding: 5px 12px; font-size: 12.5px;
  color: var(--ink-3); cursor: pointer; }
.vz-seg button.active { background: var(--primary); color: #fff; }
.vz-stage.preview .vz-node { cursor: default; }
.vz-stage.preview .vz-resize { display: none; }
