:root {
  --bg: #eef1f7;
  --surface: #ffffff;
  --border: #e2e7f0;
  --text: #1f2733;
  --muted: #7a8699;
  --accent: #2f6bff;
  --accent-dark: #1d47c2;
  --danger: #dc4437;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(23, 43, 99, .08), 0 4px 16px rgba(23, 43, 99, .05);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #233a6e, #1b2d59);
  color: #fff;
  flex: none;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 34px; height: 34px; flex: none;
  object-fit: cover; border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .3);
}
.title { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.subtitle { font-size: 11px; opacity: .66; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; flex: none; align-items: center; }
.trash-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 99px;
  background: #fbbf24;
  color: #3b2600;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}
.trash-badge[hidden] { display: none; }

/* ---------------- 布局 ---------------- */
.layout { flex: 1; display: flex; min-height: 0; }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  width: 264px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
  font-weight: 600;
}
.search {
  margin: 0 14px 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  font-size: 13px;
  background: #f7f9fc;
}
.search:focus { border-color: var(--accent); background: #fff; }
.project-list { flex: 1; overflow-y: auto; padding: 4px 8px 10px; }

/* ---- 项目树：项目可折叠，下面缩进挂接入单位 ---- */
.side-acts { display: flex; gap: 6px; padding: 0 14px 8px; }
.side-acts .btn { flex: 1; padding: 6px 8px; font-size: 12px; }
.site-group { margin-bottom: 4px; }
.site-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}
.site-head:hover { background: #f2f6ff; }
.site-group.current > .site-head { color: var(--accent-dark); }
.site-caret {
  flex: none;
  width: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #8792a6;
  transition: transform .15s ease;
}
.site-group.open > .site-head .site-caret { transform: rotate(90deg); }
.site-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-count {
  flex: none;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: #f1f4f9;
  border-radius: 99px;
  padding: 1px 7px;
}
.site-edit {
  flex: none;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 5px;
  opacity: .4;
}
.site-head:hover .site-edit { opacity: 1; }
.site-edit:hover { background: #e6eeff; color: var(--accent); }
.site-units { display: none; padding-left: 14px; }
.site-group.open > .site-units { display: block; }
.site-empty { padding: 8px 12px; font-size: 12px; color: var(--muted); }
.site-units .project-item { padding: 8px 10px; font-size: 13px; }

.project-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.project-item:hover { background: #f2f6ff; }
.project-item.active {
  background: #eef3ff;
  border-color: #c9d8ff;
  color: var(--accent-dark);
}
.project-item .p-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-item .p-count {
  flex: none;
  font-size: 11px;
  color: var(--muted);
  background: #f1f4f9;
  border-radius: 99px;
  padding: 1px 8px;
}
.project-item.active .p-count { background: #dce7ff; color: var(--accent-dark); }
.side-foot {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

/* ---------------- 主区域 ---------------- */
main { flex: 1; overflow: auto; padding: 20px 24px; min-width: 0; }

.proj-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.proj-title h2 { margin: 0 0 4px; font-size: 20px; }
.proj-title .meta { color: var(--muted); font-size: 12px; }
.crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}
.crumb-label { color: var(--muted); }
.crumb-site { font-weight: 600; color: var(--accent-dark); }
.crumb-uid {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  background: #eef3ff;
  color: var(--accent-dark);
  cursor: pointer;
}
.crumb-sep { color: #b9c3d4; }
.crumb-unit { color: var(--muted); }
.proj-actions { display: flex; gap: 8px; flex: none; flex-wrap: wrap; }

.proj-note {
  margin: 14px 0 0;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: #4b5568;
  font-size: 13px;
}

/* 类型过滤 chips */
.chips { display: flex; gap: 8px; margin: 16px 0 10px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 12.5px;
  color: #42506a;
  user-select: none;
}
.chip:hover { border-color: #b9c6de; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { font-size: 11px; opacity: .75; }
.chip-search { margin-left: auto; }

/* ---------------- 表格 ---------------- */
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafd;
}
.type-tag { font-size: 12px; padding: 2px 10px; border-radius: 99px; font-weight: 600; }
.section-head .cnt { font-size: 12px; color: var(--muted); }
.section table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid #eef1f7; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fbfcfe; position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: #f6f9ff; }
tbody tr:last-child td { border-bottom: none; }
.d-name { font-weight: 600; }
.d-model { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; }
.copyable { cursor: copy; }
.copyable:hover { color: var(--accent); }
.muted { color: var(--muted); }
.row-actions { white-space: nowrap; }
.icon-btn {
  border: 1px solid transparent;
  background: none;
  border-radius: 6px;
  padding: 3px 5px;
  cursor: pointer;
  font-size: 12.5px;
  color: #5b6a85;
  line-height: 1.4;
}
.icon-btn:hover { background: #eef3ff; color: var(--accent); }
.icon-btn.del:hover { background: #fdeeed; color: var(--danger); }

/* 空状态 */
.empty {
  border: 2px dashed #cfd8e6;
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255,255,255,.6);
}
.empty h3 { color: #46536b; margin: 0 0 6px; }
.hero { max-width: 640px; margin: 8vh auto 0; text-align: center; color: var(--muted); }
.hero h2 { color: #2b3a57; }
.hero .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 30px 34px;
  text-align: left;
}
.hero li { margin: 8px 0; line-height: 1.7; }

/* ---------------- 按钮 ---------------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.btn:hover { border-color: #b9c6de; background: #f7f9fd; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.28); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.18); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fdeeed; border-color: #f3c2bd; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }

/* ---------------- 类型标签色 ---------------- */
.t-uit { color: #2563eb; background: #e8f0ff; }
.t-terminal { color: #7c3aed; background: #f1eaff; }
.t-robot { color: #4338ca; background: #e0e7ff; }
.t-efire { color: #b45309; background: #fef3c7; }
.t-pressure { color: #0f766e; background: #ccfbf1; }
.t-level { color: #1d4ed8; background: #dbeafe; }
.t-dvr { color: #c26a00; background: #fff2df; }
.t-camera { color: #158a3f; background: #e3f6ea; }
.t-aibox { color: #0e7490; background: #e0f2fe; }

/* ---------------- 弹窗 ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 50;
  animation: fade .14s ease;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 600px;
  max-width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: pop .16s ease;
}
.modal-head { padding: 16px 20px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-sep {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
}
.form-sep::before { content: ''; width: 3px; height: 13px; border-radius: 2px; background: var(--accent); }
/* 国标 28181 提示条 */
.gb-hint {
  padding: 8px 10px; border: 1px dashed #d8e2f5; border-radius: 8px;
  background: #f6f9ff; font-size: 12px; line-height: 1.7; color: #4b5568;
}
.gb-hint .gb-ok { color: #1d47c2; }
.gb-hint .gb-warn { color: #b45309; }
/* 字段下方的浅色说明（RTSP 流 ID 等） */
.field-tip { margin-top: 5px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.field-tip .tip-ok { color: #1d47c2; }
.field-tip .tip-warn { color: #b45309; }
/* 算法功能多选 */
.algo-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.algo-item {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px 5px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: #fbfcfe; font-size: 12.5px; color: #3b4a63; cursor: pointer;
  user-select: none;
}
.algo-item:hover { border-color: #b9caf0; background: #f5f9ff; }
.algo-item input { margin: 0; accent-color: var(--accent); cursor: pointer; }
.algo-item:has(input:checked) { border-color: #9db8f0; background: #eef4ff; color: #1d47c2; }
.algo-item.on { border-color: #9db8f0; background: #eef4ff; color: #1d47c2; }
/* 分组标题右侧的计数（如「3 / 16 路」） */
.sep-note { margin-left: 8px; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.sep-note.warn { color: #b45309; }
.link-btn.danger { color: var(--danger); }
/* RTSP 流编辑卡片（一台算法盒子最多 16 路） */
.stream-wrap { display: block; }
.stream-list { display: flex; flex-direction: column; gap: 8px; }
.stream-empty {
  padding: 12px; border: 1px dashed #d8e2f5; border-radius: 8px;
  background: #f8fbff; font-size: 12.5px; color: #5b6a85; line-height: 1.7;
}
.stream-card { border: 1px solid var(--border); border-radius: 9px; background: #fbfcfe; overflow: hidden; }
.stream-card.open { background: #fff; }
.stream-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; background: #f4f7fe;
}
.stream-card.open .stream-head { border-bottom: 1px solid var(--border); }
.stream-no {
  flex: none; width: 20px; height: 20px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.stream-title {
  font-size: 13px; font-weight: 600; color: #334155;
  max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stream-sid {
  font-size: 11.5px; color: #2f4b8f; background: #eef4ff;
  border: 1px solid #dbe6fb; border-radius: 5px; padding: 1px 6px; white-space: nowrap;
}
.stream-acts { margin-left: auto; display: inline-flex; gap: 10px; }
.stream-body { padding: 10px 12px 12px; }
.stream-add { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.stream-hint { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.field label { display: block; font-size: 12.5px; color: #4b5568; margin-bottom: 5px; }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: #fbfcfe;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); background: #fff; }
.field textarea { resize: vertical; min-height: 64px; }
.field.invalid input { border-color: var(--danger); background: #fff6f5; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 38px; }
/* 密码显示切换：纯眼睛图标（睁眼 = 点击显示，划线眼 = 点击隐藏） */
.pw-eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0;
  border: none; background: none; color: var(--muted);
  cursor: pointer; border-radius: 6px; line-height: 0;
}
.pw-eye:hover { background: #eef3ff; color: var(--accent); }
.pw-eye svg { display: block; }
.pw-line { display: flex; gap: 8px; align-items: center; }
.pw-line select { width: 220px; flex: none; }
.pw-line .pw-wrap { flex: 1; }

/* 回收站 */
.trash-total { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.trash-tip {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #dbe6fb;
  border-radius: 10px;
  background: #f6f9ff;
  color: #42506a;
  font-size: 12.5px;
  line-height: 1.7;
}
.trash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
}
.trash-main { flex: 1; min-width: 0; }
.trash-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: #25324a;
  font-size: 13.5px;
  font-weight: 600;
}
.trash-kind {
  padding: 2px 8px;
  border-radius: 99px;
  background: #eef3ff;
  color: #1d47c2;
  font-size: 11px;
  font-weight: 600;
}
.trash-meta { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.trash-hint {
  margin-top: 6px;
  padding: 5px 8px;
  border: 1px solid #edd6a4;
  border-radius: 7px;
  background: #fff9ea;
  color: #b45309;
  font-size: 11.5px;
  line-height: 1.6;
}
.trash-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex: none; flex-wrap: wrap; }
.trash-actions .btn.small { padding: 5px 10px; }
.trash-target {
  max-width: 190px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  outline: none;
}
.trash-target:focus { border-color: var(--accent); }
.trash-warn { color: var(--danger); font-size: 12px; }
.trash-empty {
  padding: 40px 16px;
  border: 2px dashed #cfd8e6;
  border-radius: 10px;
  text-align: center;
  color: var(--muted);
}
.trash-empty-ico { font-size: 30px; }
.trash-empty h3 { margin: 10px 0 5px; color: #46536b; }

/* 密码本 */
.vault-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.vault-bar .search { flex: 1; margin: 0; }
.vault-table {
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.vault-table table { width: 100%; border-collapse: collapse; }
.vault-table th { position: sticky; top: 0; }
.vault-empty {
  border: 2px dashed #cfd8e6;
  border-radius: 10px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}
.vault-tip { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* 选择摄像头设备：RTSP 流的「待选设备」列表 */
.cam-pick-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cam-pick-bar .search { flex: 1; margin: 0; }
.cam-pick-bar .muted { font-size: 12px; white-space: nowrap; }
.cam-pick-list {
  max-height: 380px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px; background: #fbfcff;
}
.cam-pick-group + .cam-pick-group { margin-top: 8px; }
.cam-pick-gname {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 4px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.cam-pick-cur {
  font-weight: 400; font-size: 11px; color: var(--accent);
  background: rgba(47, 107, 255, .1); border-radius: 20px; padding: 1px 8px;
}
.cam-pick-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 1px solid transparent; background: var(--surface); border-radius: 8px;
  padding: 9px 10px; margin-bottom: 4px; cursor: pointer;
  font: inherit; color: inherit;
}
.cam-pick-item:hover { border-color: var(--accent); background: #f2f6ff; }
.cam-pick-name {
  font-weight: 600; flex: 0 0 auto; max-width: 46%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cam-pick-meta { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.cam-pick-loc {
  margin-left: auto; font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cam-pick-empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.8; }
.cam-pick-tip { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.7; }

.err-tip { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* ---------------- 型号规格 / 可输入下拉框 ---------------- */
.field label.label-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link-btn {
  border: none; background: none; padding: 0;
  color: var(--accent); font-size: 11.5px; font-family: inherit;
  cursor: pointer; white-space: nowrap;
}
.link-btn:hover { text-decoration: underline; }
.label-acts { display: inline-flex; align-items: center; gap: 10px; }
/* RTSP 地址很长，表格里截断显示，悬停看全文、点击复制 */
.rtsp-cell { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 20 位长编码（SIP 用户名 / SIM 卡 ICCID）分两行显示，避免把整张表撑宽 */
.gb-cell { width: 104px; line-height: 1.5; white-space: nowrap; }
/* RTSP 流 ID：等宽小字 + 下方算法标签 */
.rtsp-id-cell { min-width: 168px; }
.rtsp-id { font-size: 11.5px; line-height: 1.5; white-space: nowrap; letter-spacing: -0.1px; }
.sid-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.sid-line + .sid-line { margin-top: 3px; }
.cam-count-cell { min-width: 132px; }
.stream-num { font-size: 11.5px; font-weight: 600; color: #1d47c2; }
.stream-num.warn { color: #b45309; }
.stream-cam { font-size: 12px; color: #4b5568; margin: 2px 0 3px; line-height: 1.5; }
.streams-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 12px; }
.algo-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.algo-chip {
  font-size: 10.5px; line-height: 1.5; padding: 0 4px; border-radius: 4px;
  background: #eef4ff; border: 1px solid #dbe6fb; color: #2f4b8f; white-space: nowrap;
}
.algo-none { margin-top: 4px; font-size: 10.5px; color: #b45309; }
/* 项目头部显示项目 ID */
.proj-uid { font-weight: 600; color: #334155; }
/* 表格里的等宽内容（IP/掩码/网关/编码）略收小，给宽表腾空间 */
td.mono { font-size: 12px; }
/* 列多的分组（如 AI 算法盒子）需要横向滚动时，操作列固定在右侧始终可点 */
td.row-actions, thead th:last-child { position: sticky; right: 0; }
td.row-actions { background: #fff; box-shadow: -8px 0 8px -6px rgba(15, 23, 42, 0.12); }
thead th:last-child { background: #fbfcfe; z-index: 2; box-shadow: -8px 0 8px -6px rgba(15, 23, 42, 0.10); }
tbody tr:hover td.row-actions { background: #f6f9ff; }
.combo { position: relative; }
.combo input { padding-right: 30px; }
.combo-arrow {
  position: absolute; right: 1px; top: 1px; bottom: 1px; width: 28px;
  border: none; border-left: 1px solid var(--border); background: #f4f7fe;
  color: #5b6b86; font-size: 11px; line-height: 1; cursor: pointer;
  border-radius: 0 7px 7px 0;
}
.combo-arrow:hover { background: #e9f0ff; color: var(--accent); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  max-height: 230px; overflow-y: auto; padding: 4px;
  background: #fff; border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 10px 26px rgba(23, 43, 99, .16);
}
.combo-list[hidden] { display: none; }
.combo-list.up { top: auto; bottom: calc(100% + 4px); }
.combo-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 9px; border-radius: 6px; font-size: 13px; cursor: pointer;
  font-family: Consolas, "Courier New", monospace;
}
.combo-item .ci-name {
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.combo-item .ci-note {
  margin-left: auto; flex: none; max-width: 52%;
  color: var(--muted); font-family: "Microsoft YaHei", system-ui, sans-serif;
  font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.combo-item:hover, .combo-item.active { background: #eef3ff; color: var(--accent-dark); }
.combo-empty { padding: 9px; color: var(--muted); font-size: 12px; }
.combo-manage {
  margin-top: 4px; padding: 7px 9px; border-top: 1px dashed var(--border);
  color: var(--accent); font-size: 12.5px; cursor: pointer; border-radius: 6px;
}
.combo-manage:hover { background: #eef3ff; }
.overlay.stacked { z-index: 60; }
.modal-sub { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.usage-tag {
  display: inline-block; padding: 1px 8px; border-radius: 99px;
  background: #eef3ff; color: #1d47c2; font-size: 11.5px;
}

/* 型号规格：按设备类型分组的两级列表 */
.model-tree {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.mg + .mg { border-top: 1px solid var(--border); }
.mg-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: #f7f9fd;
  cursor: pointer; user-select: none;
}
.mg-head:hover { background: #eef3ff; }
.mg-head.collapsed { background: #fbfcfe; }
.mg-caret { width: 12px; color: #7b8aa3; font-size: 9px; text-align: center; line-height: 1; }
.mg-label { font-weight: 600; color: #2b3a55; font-size: 13px; }
.mg-count {
  min-width: 18px; padding: 0 6px; height: 17px; line-height: 17px;
  text-align: center; border-radius: 99px;
  background: #e6edf9; color: #5b6b86; font-size: 11px;
}
.mg-add { margin-left: auto; opacity: .7; }
.mg-head:hover .mg-add { opacity: 1; }
.mg-body { padding: 2px 10px 8px; }
.mg-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) minmax(0, 1.4fr) 74px auto;
  gap: 10px; align-items: center;
  padding: 6px 0; border-top: 1px dashed #eef1f7;
  font-size: 13px;
}
.mg-body .mg-row:first-child { border-top: none; }
.mg-name {
  font-size: 13px; color: #1f2d45;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mg-note {
  color: #6b7a92; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mg-acts { display: flex; gap: 4px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.mg-empty { padding: 8px 0 4px; color: var(--muted); font-size: 12px; }
.mg-hint {
  margin: 6px 0 2px; padding: 6px 8px; border-radius: 6px;
  background: #fff8ec; color: #96601a; font-size: 12px;
}
.mg-assign {
  height: 24px; padding: 0 4px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text); font: inherit; font-size: 11.5px; outline: none;
  max-width: 96px;
}
.mg-assign:focus { border-color: var(--accent); }

/* ---------------- IP 地址管理器 ---------------- */
.ipam-head .ipam-proj { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.ipam-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.ipam-pool {
  flex: 1;
  min-width: 200px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}
.ipam-pool:focus { border-color: var(--accent); background: #fff; }
.ipam-project { flex: 0 1 240px; min-width: 190px; }
.ipam-dev-search { margin-bottom: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); background: var(--surface); }

.ipam-summary {
  background: #f8fafd;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.ipam-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: #42506a; }
.ipam-stat b { font-size: 14px; }
.ipam-stat.free b { color: #158a3f; }
.ipam-stat.used b { color: #1d4ed8; }
.ipam-stat.conflict b { color: var(--danger); }
.ipam-stat.gateway b { color: #b45309; }
.ipam-meta { margin-top: 5px; font-size: 12px; color: var(--muted); }
.ipam-note { margin-top: 4px; font-size: 12px; color: #67748e; }

.ipam-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.ipam-toolbar .search { flex: 1; max-width: 320px; margin: 0; }
.ipam-legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); margin-left: auto; flex-wrap: wrap; }
.ipam-legend span { display: inline-flex; align-items: center; gap: 4px; }
.lg { width: 9px; height: 9px; border-radius: 3px; display: inline-block; border: 1px solid transparent; }
.lg.free { background: #fff; border-color: #cfd8e6; }
.lg.used { background: #e3efff; border-color: #9cc3f0; }
.lg.conflict { background: #ffe3df; border-color: #eda49b; }
.lg.gateway { background: #fff3d6; border-color: #e8c98c; }

.ipam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 7px;
  max-height: 44vh;
  min-height: 120px;
  overflow: auto;
  padding: 2px 4px 2px 2px;
  align-content: start;
}
.ip-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  background: #fbfcfe;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  overflow: hidden;
}
.ip-tile:hover { border-color: #b9c6de; }
.ip-tile .ip-num { font-family: Consolas, "Courier New", monospace; font-size: 12px; font-weight: 600; color: #334155; white-space: nowrap; }
.ip-tile .ip-meta { font-size: 11px; color: var(--muted); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ip-tile.free:hover { border-color: var(--accent); background: #f2f6ff; box-shadow: 0 0 0 2px rgba(47,107,255,.08); }
.ip-tile.used { background: #eef6ff; border-color: #c4dcf7; }
.ip-tile.used .ip-num { color: #1d4ed8; }
.ip-tile.used:hover { border-color: #7fb3ea; }
.ip-tile.conflict { background: #fff1ef; border-color: #f0b7b0; }
.ip-tile.conflict .ip-num { color: #c0392b; }
.ip-tile.gateway { background: #fff9ea; border-color: #edd6a4; cursor: default; }
.ip-tile.gateway .ip-num { color: #a16207; }

.ipam-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); min-height: 28px; }

.ipam-empty {
  grid-column: 1 / -1;
  border: 2px dashed #cfd8e6;
  border-radius: 10px;
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
}
.ipam-empty h3 { margin: 8px 0 6px; color: #46536b; }
.ipam-empty .btn { margin-top: 12px; }
.ipam-empty-ico { font-size: 26px; }
.ipam-empty.small { padding: 22px; }

.ipam-assign-ip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f6f9ff;
  border: 1px solid #dbe6fb;
  border-radius: 10px;
  margin-bottom: 12px;
}
.ipam-assign-ip .ip-num { font-family: Consolas, "Courier New", monospace; font-size: 20px; font-weight: 700; color: #1d47c2; }
.ipam-badge { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; }
.ipam-badge.free { background: #e3f6ea; color: #158a3f; }
.ipam-badge.used { background: #e3efff; color: #1d4ed8; }
.ipam-badge.conflict { background: #fde8e6; color: #c0392b; }
.ipam-current { padding: 8px 10px; background: #fbfcfe; border: 1px solid var(--border); border-radius: 8px; }
.ipam-current.warn { color: #b45309; background: #fff9ea; border-color: #edd6a4; }
.ipam-tip { font-size: 12px; color: var(--muted); line-height: 1.7; }
.ipam-tip b { color: #42506a; }

.ipam-uses { display: flex; flex-direction: column; gap: 8px; }
.ipam-use {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
}
.ipam-use-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ipam-use-actions { display: flex; gap: 6px; flex: none; }
.sub-overlay { z-index: 60; background: rgba(15, 23, 42, .35); }
.ipam-foot { align-items: center; }
.ipam-foot .btn { flex: none; white-space: nowrap; }
.ipam-foot-tip { font-size: 11.5px; color: var(--muted); margin-right: auto; line-height: 1.5; }

/* ---------------- 提示 ---------------- */
#toast-root { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #223047;
  color: #fff;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  animation: pop .16s ease;
}
.toast.err { background: #b3382c; }
.toast.warn { background: #a86b14; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c8d2e2; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #aab7cd; background-clip: content-box; }

/* ---------------- 服务已停止 ---------------- */
.svc-stopped {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.svc-card {
  width: 100%; max-width: 430px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px 28px;
  box-shadow: var(--shadow);
}
.svc-ico {
  width: 44px; height: 44px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: #e3f6ea; color: #158a3f;
  font-size: 22px; font-weight: 700;
}
.svc-card h2 { margin: 0 0 10px; font-size: 18px; }
.svc-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.9; }

/* ---------------- 在线升级 ---------------- */
.upg-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.upg-cur { font-size: 14px; color: var(--text); }
.upg-cur b { font-family: Consolas, "Courier New", monospace; font-size: 15px; }
.upg-cur b.upg-on { color: var(--accent-dark); }
.upg-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }
.upg-import { display: flex; gap: 10px; align-items: stretch; margin-top: 14px; }
.upg-pick {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border: 1px dashed #c3cfe6; border-radius: 8px;
  background: #f7f9fd; cursor: pointer;
  font-size: 13px; color: var(--muted);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.upg-pick:hover { border-color: var(--accent); background: #f1f6ff; }
.upg-pick-ico { flex: none; font-size: 16px; }
.upg-import .btn { flex: none; }
.upg-tip {
  margin-top: 10px; padding: 10px 12px;
  background: #f7f9fd; border-radius: 8px;
  font-size: 12px; line-height: 1.8; color: var(--muted);
}
.upg-list-title { margin: 16px 0 8px; font-size: 13px; font-weight: 600; }
.upg-empty {
  padding: 18px; text-align: center;
  font-size: 12.5px; color: var(--muted);
  background: #f7f9fd; border-radius: 8px;
}
.upg-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 8px;
}
.upg-item.active { border-color: #c9d8ff; background: #f6f9ff; }
.upg-item-main { min-width: 0; }
.upg-item-title { display: flex; align-items: center; gap: 8px; }
.upg-ver { font-family: Consolas, "Courier New", monospace; font-weight: 600; }
.upg-name { font-size: 13px; color: var(--text); }
.upg-badge {
  font-size: 11px; padding: 1px 7px; border-radius: 99px;
  background: #dce7ff; color: var(--accent-dark);
}
.upg-item-meta { margin-top: 3px; font-size: 12px; color: var(--muted); }
.upg-item-acts { flex: none; display: flex; gap: 6px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; max-height: 220px; border-right: none; border-bottom: 1px solid var(--border); }
  .subtitle { display: none; }
  .trash-item { flex-direction: column; align-items: stretch; }
  .trash-actions { justify-content: flex-end; }
  .mg-row { grid-template-columns: minmax(0, 1fr) auto; }
  .mg-note, .mg-usage { display: none; }
}

/* ---------------- 用户与角色 ---------------- */
[hidden] { display: none !important; }

.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px; border-radius: 99px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .26);
  color: #fff; font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.user-chip:hover { background: rgba(255, 255, 255, .2); }
.user-chip__name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip__role {
  font-size: 10.5px; padding: 1px 6px; border-radius: 99px;
  background: rgba(255, 255, 255, .2); color: #fff; white-space: nowrap;
}
.user-chip__role.is-admin { background: #fbbf24; color: #3b2600; font-weight: 600; }

.role-badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
  background: #eef1f7; color: #4b5568; border: 1px solid var(--border);
}
.role-badge.is-admin { background: #fff4d6; color: #8a5a00; border-color: #f3d99a; }

.user-tip {
  font-size: 12.5px; line-height: 1.75; color: #4b5568;
  background: #f5f8ff; border: 1px solid #dbe4fb; border-radius: 8px;
  padding: 9px 12px; margin-bottom: 12px;
}
.user-total { font-size: 12px; font-weight: 400; color: var(--muted); }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 9px; background: #fff;
}
.user-row:hover { border-color: #cdd8ee; background: #fcfdff; }
.user-main { min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.user-meta b { color: #4b5568; }
.user-acts { display: flex; gap: 6px; flex: none; }
.user-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 99px;
  background: #eef1f7; color: #67748e; font-weight: 500;
}
.user-warn { color: #b45309; }

.acct-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; background: #fafbfe; }
.acct-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.acct-meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.acct-perms { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.perm-chip {
  font-size: 11.5px; padding: 3px 8px; border-radius: 99px;
  background: #eef3ff; color: #2f5bd0; border: 1px solid #d8e2ff;
}
.acct-warn { margin-top: 10px; font-size: 12px; color: #b45309; }

/* ---------------- 页签与角色权限 ---------------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab {
  border: none; background: none; padding: 8px 14px; font-size: 13.5px;
  color: #67748e; cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.is-on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.role-perms { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.perm-title { font-size: 12.5px; font-weight: 600; color: #4b5568; margin: 16px 0 8px; }
.perm-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; background: #fafbfe; }
.perm-group__title { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.perm-item { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.perm-item input { margin-top: 2px; flex: none; }
.perm-item__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.perm-item__label { font-size: 13px; color: var(--text); }
.perm-item__desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
@media (max-width: 760px) { .perm-groups { grid-template-columns: 1fr; } }
