/* ============================================================
   副卡宝设备管理平台 · 界面样式
   设计基调：浅色、克制、信息密度高但不拥挤
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --surface-3: #f1f4f9;
  --line: #e6eaf2;
  --line-strong: #d8deea;
  --text: #0f172a;
  --text-2: #5b6478;
  --muted: #8a93a6;

  --primary: #2f54eb;
  --primary-600: #2445cf;
  --primary-50: #eef2ff;
  --primary-100: #dfe5ff;

  --ok: #0f9d58;
  --ok-50: #e8f7ee;
  --warn: #c2740a;
  --warn-50: #fdf3e3;
  --danger: #d93a3f;
  --danger-50: #fdecec;
  --info: #0b7ec4;
  --info-50: #e9f5fd;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 10px 30px rgba(15, 23, 42, .07);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .16);

  --sidebar-w: 236px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd6e4; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b9c2d4; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 基础骨架 ---------------- */

#app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 18px 14px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #3b5bfd 0%, #6d4bff 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .5px;
  box-shadow: 0 6px 16px rgba(59, 91, 253, .32);
}

.brand-text { line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
}

.nav-group {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .8px;
  padding: 14px 10px 6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13.5px;
  position: relative;
  transition: background .14s ease, color .14s ease;
  user-select: none;
}

.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .82; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--primary-50); color: var(--primary-600); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px; top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-foot .row { display: flex; justify-content: space-between; gap: 8px; }
.dot-live { display: inline-flex; align-items: center; gap: 6px; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 62px;
  flex: 0 0 62px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 15;
}

.topbar-title { font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.topbar-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.view {
  padding: 22px 24px 40px;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}

/* ---------------- 通用组件 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all .14s ease;
  white-space: nowrap;
}
.btn:hover { border-color: #c3cbdb; background: var(--surface-2); }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(47, 84, 235, .22);
}
.btn.primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn.danger { color: var(--danger); border-color: #f3c7c8; background: #fff; }
.btn.danger:hover { background: var(--danger-50); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 29px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all .14s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-50); color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.card-title { font-weight: 620; font-size: 14.5px; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.row-flex { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  right: -30px; top: -30px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--tint, var(--primary-50));
  opacity: .6;
}
.stat-ico {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--tint, var(--primary-50));
  color: var(--tone, var(--primary));
  flex: 0 0 38px;
  position: relative; z-index: 1;
}
.stat-ico svg { width: 19px; height: 19px; }
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-value { font-size: 24px; font-weight: 680; letter-spacing: -.4px; line-height: 1.15; margin-top: 3px; }
.stat-hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; position: relative; z-index: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.ok { background: var(--ok-50); color: #0b7a45; }
.pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(15,157,88,.16); }
.pill.err { background: var(--danger-50); color: #b02a2e; }
.pill.err .dot { background: var(--danger); }
.pill.warn { background: var(--warn-50); color: #9a5b06; }
.pill.warn .dot { background: var(--warn); }
.pill.info { background: var(--info-50); color: #0a6aa5; }
.pill.primary { background: var(--primary-50); color: var(--primary-600); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-50); color: #0b7a45; }
.badge.err { background: var(--danger-50); color: #b02a2e; }
.badge.warn { background: var(--warn-50); color: #9a5b06; }
.badge.info { background: var(--info-50); color: #0a6aa5; }
.badge.primary { background: var(--primary-50); color: var(--primary-600); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 11px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border .14s ease, box-shadow .14s ease;
  outline: none;
}
.textarea { height: auto; min-height: 82px; padding: 9px 11px; line-height: 1.55; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 84, 235, .13);
}
.input::placeholder, .textarea::placeholder { color: #a8b0c0; }
.input.mono, .textarea.mono { font-family: var(--mono); font-size: 12.5px; }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2370788c' stroke-width='2.4'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section-title {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .6px;
  text-transform: uppercase;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
  margin-top: 2px;
}
.form-section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

.switch {
  width: 38px; height: 21px;
  border-radius: 20px;
  background: #d5dbe7;
  position: relative;
  cursor: pointer;
  transition: background .16s ease;
  flex: 0 0 38px;
  border: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.2);
  transition: transform .16s ease;
}
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(17px); }

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
}
.switch-row .label { font-size: 13.5px; }
.switch-row .desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------- 表格 ---------------- */

.table-wrap { width: 100%; overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.data thead th {
  text-align: left;
  font-weight: 550;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f3f8;
  vertical-align: middle;
  color: var(--text);
}
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:hover { background: #f8faff; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.mono, table.data td .mono { font-family: var(--mono); font-size: 12.5px; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-actions { display: flex; gap: 2px; justify-content: flex-end; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.toolbar .spacer { flex: 1; }

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
}
.pagination .spacer { flex: 1; }

.empty {
  padding: 54px 20px;
  text-align: center;
  color: var(--muted);
}
.empty svg { width: 42px; height: 42px; opacity: .35; margin-bottom: 8px; }
.empty .title { font-size: 13.5px; color: var(--text-2); margin-bottom: 3px; }
.empty .desc { font-size: 12px; }

.loading-mask {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.6);
  display: grid;
  place-items: center;
  z-index: 5;
}
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--primary-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 设备 ---------------- */

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px 13px;
  cursor: pointer;
  position: relative;
  transition: all .16s ease;
  box-shadow: var(--shadow-sm);
}
.device-card:hover {
  border-color: #c9d4ee;
  box-shadow: 0 10px 24px rgba(47,84,235,.09);
  transform: translateY(-1px);
}
.device-card.offline { opacity: .78; }
.device-card::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--ok);
  opacity: .85;
}
.device-card.offline::before { background: #c6ccd9; }

.dev-head { display: flex; align-items: center; gap: 8px; margin-bottom: 11px; }
.dev-online {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(15,157,88,.14);
  flex: 0 0 7px;
}
.device-card.offline .dev-online { background: #b6bdcb; box-shadow: 0 0 0 3px rgba(182,189,203,.18); }
.dev-name { font-weight: 620; font-size: 14px; }
.dev-uid { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.dev-actions { margin-left: auto; display: flex; gap: 1px; }

.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; margin-left: auto; }
.signal i { width: 3px; border-radius: 1px; background: #d9dfea; }
.signal i:nth-child(1) { height: 4px; }
.signal i:nth-child(2) { height: 7px; }
.signal i:nth-child(3) { height: 10px; }
.signal i:nth-child(4) { height: 13px; }
.signal i.on { background: var(--ok); }
.signal i.low { background: var(--warn); }

.dev-meta { display: flex; flex-direction: column; gap: 6px; }
.dev-meta .line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.dev-meta .k { color: var(--muted); width: 58px; flex: 0 0 58px; }
.dev-meta .v { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-tags { display: flex; gap: 5px; margin-top: 9px; flex-wrap: wrap; }

/* 设备列表（表格视图） */
.dev-list-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.dev-title { font-size: 15px; font-weight: 640; color: var(--text); }
.dev-count {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
}
.dev-count.ok {
  color: var(--ok);
  border-color: rgba(15,157,88,.35);
  background: rgba(15,157,88,.06);
}
.dev-online-label { font-size: 12.5px; color: var(--text-2); }
.dev-toolbar { padding: 12px 16px; border-bottom: 1px solid var(--line); }

.dev-table thead th { padding: 10px 16px; }
.dev-table tbody td { padding: 10px 16px; height: 52px; }
.dev-cell-main { font-weight: 560; font-size: 13px; color: var(--text); }
.dev-cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dev-unset { color: var(--muted); font-weight: 400; }
.dev-remark {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.dev-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.dev-status i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #b6bdcb;
  box-shadow: 0 0 0 3px rgba(182,189,203,.16);
}
.dev-status.on { color: var(--ok); }
.dev-status.on i { background: var(--ok); box-shadow: 0 0 0 3px rgba(15,157,88,.14); }
.dev-table .signal { margin-left: 0; }
.dev-row-actions { flex-wrap: nowrap; white-space: nowrap; }
.link-act {
  border: 0;
  background: none;
  padding: 3px 5px;
  font-size: 12.5px;
  color: var(--primary);
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
.link-act:hover { background: var(--primary-100); }
.link-act.danger { color: #d64545; }
.link-act.danger:hover { background: #fdeeee; }

/* ---------------- 抽屉 ---------------- */

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.32);
  backdrop-filter: blur(2px);
  z-index: 60;
  animation: fade .16s ease;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 94vw);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 61;
  display: flex;
  flex-direction: column;
  animation: slideIn .22s cubic-bezier(.22,.8,.3,1);
}
.drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; }

.section-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .7px;
  text-transform: uppercase;
  font-weight: 600;
  margin: 18px 0 8px;
}
.section-title:first-child { margin-top: 0; }

.kv-list { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.kv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 13px;
  border-bottom: 1px solid #f2f4f9;
  min-height: 42px;
  font-size: 13px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { color: var(--text-2); width: 108px; flex: 0 0 108px; font-size: 12.5px; }
.kv-row .v { flex: 1; min-width: 0; word-break: break-all; }
.kv-row.editable { cursor: pointer; }
.kv-row.editable:hover { background: #f8faff; }
.kv-row.editable .v::after {
  content: "编辑";
  font-size: 11px;
  color: var(--primary);
  opacity: 0;
  margin-left: 8px;
  transition: opacity .14s;
}
.kv-row.editable:hover .v::after { opacity: 1; }
.kv-row.readonly .v { color: var(--text); }

@keyframes slideIn { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.38);
  backdrop-filter: blur(3px);
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade .16s ease;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  animation: pop .2s cubic-bezier(.22,.8,.3,1);
}
.modal.wide { width: min(760px, 100%); }
.modal.narrow { width: min(420px, 100%); }
.modal-head {
  padding: 18px 20px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.modal-title { font-size: 15.5px; font-weight: 650; }
.modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 4px 20px 8px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px 18px;
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  align-items: center;
}
@keyframes pop { from { transform: scale(.97) translateY(6px); opacity: .5; } to { transform: none; opacity: 1; } }

/* ---------------- 提示 ---------------- */

.toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 11px 15px;
  min-width: 240px;
  max-width: 420px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  animation: toastIn .2s ease;
  pointer-events: auto;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast .t-title { font-weight: 600; margin-bottom: 2px; }
.toast .t-msg { color: var(--text-2); font-size: 12.5px; white-space: pre-wrap; line-height: 1.5; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- 登录 / 初始化 ---------------- */

.auth-layer {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--surface);
}
.auth-hero {
  background:
    radial-gradient(1000px 520px at 15% 10%, #3d5cff 0%, transparent 55%),
    radial-gradient(800px 500px at 90% 90%, #7a4bff 0%, transparent 58%),
    linear-gradient(160deg, #0f1a3d 0%, #1a2a63 55%, #25357a 100%);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.auth-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 30% 30%, #000 0%, transparent 75%);
}
.auth-hero h1 { font-size: 32px; line-height: 1.25; margin: 0 0 14px; font-weight: 680; letter-spacing: -.6px; position: relative; }
.auth-hero p { color: rgba(255,255,255,.72); font-size: 14px; line-height: 1.75; max-width: 420px; position: relative; }
.auth-hero .brand { padding: 0 0 40px; }
.auth-hero .brand-name { color: #fff; }
.auth-hero .brand-sub { color: rgba(255,255,255,.5); }
.auth-features { margin-top: auto; display: grid; gap: 12px; position: relative; }
.auth-feature { display: flex; gap: 11px; align-items: flex-start; font-size: 13px; color: rgba(255,255,255,.86); }
.auth-feature .ico {
  width: 26px; height: 26px; border-radius: 8px;
  background: rgba(255,255,255,.12);
  display: grid; place-items: center;
  flex: 0 0 26px;
}
.auth-feature svg { width: 14px; height: 14px; }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.auth-box { width: min(390px, 100%); }
.auth-box h2 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.3px; }
.auth-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.auth-box .field { margin-bottom: 14px; }
.auth-error {
  background: var(--danger-50);
  color: #b02a2e;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12.5px;
  margin-bottom: 12px;
}
.auth-tip {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
}

/* 初始化向导 */
.wizard-title { font-size: 21px; font-weight: 680; letter-spacing: -.3px; }
.wizard-step { font-size: 12px; color: var(--primary); font-weight: 600; letter-spacing: .5px; margin-bottom: 6px; }
.wizard-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.preset {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all .14s;
  background: var(--surface);
}
.preset:hover { border-color: var(--primary); background: var(--primary-50); }
.preset .t { font-size: 13px; font-weight: 550; }
.preset .d { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------------- 其它 ---------------- */

.alert {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--info-50);
  color: #0a5c8f;
  border: 1px solid #cfe8f8;
}
.alert.warn { background: var(--warn-50); color: #8a5406; border-color: #f3e0bf; }
.alert.danger { background: var(--danger-50); color: #a8292d; border-color: #f6cdce; }
.alert svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .14s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.channel-list { display: grid; gap: 10px; }
.channel {
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--surface);
}
.channel-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  cursor: pointer;
}
.channel-head:hover { background: var(--surface-2); }
.channel-logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--surface-3);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  flex: 0 0 32px;
}
.channel.on .channel-logo { background: var(--primary-50); color: var(--primary); }
.channel-name { font-weight: 600; font-size: 13.5px; }
.channel-desc { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.channel-body { padding: 0 14px 14px; border-top: 1px solid var(--line); display: none; }
.channel.open .channel-body { display: block; }
.channel-body .form-grid { margin-top: 12px; }
/* 渠道卡片头的开关与删除按钮：不随标题挤压，长文本用省略号 */
.channel-head .icon-btn { flex: 0 0 auto; }
.channel-head .switch { flex: 0 0 auto; }
.channel-name, .channel-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text-2);
}

.code-block {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  background: #0f172a;
  color: #c9d4f0;
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  white-space: pre;
}

.help-text { font-size: 12.5px; color: var(--text-2); line-height: 1.75; }
.help-text b { color: var(--text); font-weight: 600; }

@media (max-width: 1080px) {
  .auth-layer { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 68px; }
  .brand-text, .nav-group, .nav-item span, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; }
  .brand { justify-content: center; padding: 16px 0 10px; }
  .view { padding: 16px 14px 30px; }
  .topbar { padding: 0 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .device-grid { grid-template-columns: 1fr; }
}

/* ---------------- 登录页示意图 ---------------- */

.hero-mock {
  position: relative;
  margin: 30px 0 34px;
  padding: 16px 18px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .085);
  border: 1px solid rgba(255, 255, 255, .16);
  backdrop-filter: blur(8px);
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(3, 8, 30, .35);
}
.mock-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: rgba(255,255,255,.78);
  margin-bottom: 14px;
}
.mock-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #3ee08a;
  box-shadow: 0 0 0 3px rgba(62,224,138,.16);
}
.mock-live {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 1px;
  color: #7ef0b3;
  border: 1px solid rgba(126,240,179,.4);
  border-radius: 20px;
  padding: 1px 7px;
}
.mock-main { display: flex; align-items: flex-end; gap: 18px; }
.mock-label { font-size: 11.5px; color: rgba(255,255,255,.6); }
.mock-big { font-size: 30px; font-weight: 700; letter-spacing: -1px; line-height: 1.15; }
.mock-big span { font-size: 14px; font-weight: 500; color: rgba(255,255,255,.45); }
.mock-chart {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 38px;
}
.mock-chart i {
  width: 7px;
  border-radius: 2px;
  background: linear-gradient(180deg, #7d9bff, #3b5bfd);
  opacity: .9;
}
.mock-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.mock-grid i { display: block; font-style: normal; font-size: 10.5px; color: rgba(255,255,255,.55); }
.mock-grid b { font-size: 15px; font-weight: 650; }

/* ---------------- 2FA 二次验证 ---------------- */
.f2-setup { display: flex; gap: 22px; align-items: flex-start; }
.f2-qr {
  flex: 0 0 auto;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  line-height: 0;
}
.f2-key { flex: 1; min-width: 0; }
.f2-key .input.mono { font-size: 12px; letter-spacing: .5px; }

.f2-rc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  max-height: 320px;
  overflow-y: auto;
}
.f2-rc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.f2-rc-row span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.f2-rc-row code { font-family: var(--mono); font-size: 13.5px; font-weight: 600; color: var(--text); letter-spacing: 1px; }

@media (max-width: 640px) {
  .f2-setup { flex-direction: column; align-items: center; }
  .f2-rc-grid { grid-template-columns: 1fr; }
}

/* ---------------- 在线更新 ---------------- */
.update-btn { position: relative; }
.update-btn.has-update {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 2px 8px rgba(192, 57, 43, .28);
}
.update-btn.has-update:hover { color: #fff; background: var(--danger); filter: brightness(1.06); }
.update-dot {
  position: absolute; top: -2px; right: -2px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--danger);
  animation: updatePulse 1.9s ease-out infinite;
}
@keyframes updatePulse {
  0% { box-shadow: 0 0 0 1px var(--danger), 0 0 0 0 rgba(192, 57, 43, .5); }
  70% { box-shadow: 0 0 0 1px var(--danger), 0 0 0 8px rgba(192, 57, 43, 0); }
  100% { box-shadow: 0 0 0 1px var(--danger), 0 0 0 0 rgba(192, 57, 43, 0); }
}
.tab-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); margin-left: 6px; vertical-align: middle;
}
.update-notes {
  padding: 12px 14px;
  background: var(--surface-2, #f7f9fc);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--text-2);
  max-height: 220px;
  overflow-y: auto;
  white-space: normal;
}
.kv-list { display: flex; flex-direction: column; gap: 1px; }
.kv {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; }
/* 在线更新版本信息：紧凑小表格 */
.upd-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.upd-mini-cell { padding: 8px 11px; border-right: 1px solid var(--line); min-width: 0; }
.upd-mini-cell:last-child { border-right: none; }
.upd-mini-k { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.upd-mini-v { font-size: 13px; font-weight: 600; color: var(--text); word-break: break-all; }
@media (max-width: 480px) {
  .upd-mini-cell { padding: 7px 8px; }
  .upd-mini-v { font-size: 11.5px; }
}
.link-btn { border: none; background: none; padding: 0; color: var(--primary, #2f54eb); cursor: pointer; font-size: inherit; text-decoration: underline; }
.link-btn:hover { opacity: .8; }
.update-code .btn b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------------- H5 / 移动端适配 ---------------- */
@media (max-width: 860px) {
  .topbar { height: 54px; flex-basis: 54px; }
  .topbar-sub { display: none; }
  .view { padding: 14px 12px 26px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { flex: 0 0 auto; padding: 9px 11px; white-space: nowrap; }
  .toolbar .spacer { display: none; }
  .dev-list-head { flex-wrap: wrap; }
}

@media (max-width: 860px) {
  html, body { -webkit-text-size-adjust: 100%; }
  #app {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
  }
  /* 侧栏转为底部导航，复用已有菜单与高亮逻辑（覆盖 640-860px 的纯图标侧栏） */
  .sidebar {
    position: fixed;
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; height: auto; max-height: none;
    border-right: 0; border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
    z-index: 40;
  }
  .sidebar .brand, .sidebar-foot, .nav-group { display: none !important; }
  .nav {
    display: flex; align-items: stretch; gap: 2px;
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item {
    flex: 0 0 auto; flex-direction: column; justify-content: center;
    gap: 3px; min-width: 58px; padding: 5px 8px;
    font-size: 10.5px; border-radius: 8px;
  }
  .nav-item span { display: block !important; }
  .nav-item svg { width: 19px; height: 19px; flex-basis: 19px; }
  .nav-item.active::before { display: none; }
  .main { width: 100%; }
  .topbar { padding: 0 10px; gap: 8px; height: 52px; flex-basis: 52px; }
  .topbar-title { font-size: 14.5px; }
  .topbar-right { gap: 5px; }
  .pill {
    max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 10.5px; padding: 0 8px;
  }
  #btnUser { font-size: 0; gap: 0; padding: 7px; }
  #btnUser svg { width: 17px; height: 17px; }
  .view { padding: 10px 9px 20px; }
  .card { border-radius: 11px; }
  .card-head { padding: 13px; }
  .card-body { padding: 13px; }
  .view .grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  /* iOS 输入框获得焦点时不自动放大 */
  .view .input, .view .select, .view .textarea { font-size: 16px; }
  .view .input[style*="width"], .view .select[style*="width"] { width: 100% !important; max-width: 100%; }
  .toolbar { padding: 10px; gap: 7px; }
  .toolbar > div[style*="position:relative"] { width: 100%; }
  .dev-list-head { padding: 11px 12px; gap: 7px; }
  .dev-title { font-size: 14px; }
  .dev-online-label { font-size: 11.5px; }
  .dev-toolbar { padding: 10px 12px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.data { min-width: 560px; font-size: 12px; }
  table.data thead th, table.data tbody td { padding: 9px 10px; }
  .dev-table { min-width: 760px; }
  .ellipsis, .dev-remark { max-width: 180px; }
  .drawer { width: 100vw; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 14px; padding-right: 14px; }
  .kv-row .k { width: 88px; flex-basis: 88px; }
  .f2-setup { flex-direction: column; align-items: center; }
  .f2-qr svg { max-width: 100%; height: auto; }
  .modal-mask { padding: 10px; }
  .modal { width: 100% !important; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); border-radius: 12px; }
  .modal-foot { flex-wrap: wrap; padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); }
  .auth-panel { padding: 28px 18px calc(28px + env(safe-area-inset-bottom)); }
  .auth-box { width: 100%; }
  .auth-box input, .auth-box select, .auth-box textarea { font-size: 16px; }
  .toast-root { left: 10px; right: 10px; }
}

/* 推送模板占位符：点击复制 */
.tpl-var {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.tpl-var:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.tpl-var:active { transform: translateY(1px); }

/* 问卷入口：左侧固定浮标（仅登录后显示） */
.survey-wrap {
  position: fixed;
  left: 0;
  bottom: 12%;
  z-index: 40;
}
.survey-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 108px;
  border-radius: 0 6px 6px 0;
  background: #26b941;
  color: #fff;
  font-size: 15px;
  letter-spacing: 2px;
  writing-mode: vertical-rl;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(38, 185, 65, .28);
  transition: width .15s ease, background .15s ease;
}
.survey-tab:hover { width: 34px; background: #1fa536; color: #fff; }
.survey-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .7);
  background: rgba(17, 24, 39, .72);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  display: none;
}
.survey-wrap:hover .survey-close { display: block; }
@media (max-width: 640px) {
  .survey-tab { height: 92px; font-size: 14px; }
  .survey-wrap { bottom: 22%; }
}
