/* ============ Design Tokens ============ */
:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-alt: #FAFBFC;
  --primary: #1677FF;
  --primary-hover: #4096FF;
  --primary-active: #0958D9;
  --primary-tint: #E6F4FF;
  --success: #52C41A;
  --warning: #FAAD14;
  --error: #FF4D4F;

  --text: rgba(0, 0, 0, 0.88);
  --text-secondary: rgba(0, 0, 0, 0.65);
  --text-muted: rgba(0, 0, 0, 0.45);

  --border: #E8E8E8;
  --border-strong: #D9D9D9;
  --divider: #F0F0F0;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-drawer: -6px 0 18px rgba(0, 0, 0, 0.10);

  --sidebar-w: 208px;
  --topbar-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ Loading overlay ============ */
.loading-overlay {
  position: fixed; inset: 0; background: var(--surface);
  z-index: 1000; display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 16px;
}
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--primary-tint);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-muted); font-size: 14px; }
.loading-error { color: var(--error); font-size: 14px; max-width: 420px; text-align: center; line-height: 1.7; }

/* ============ App layout ============ */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
  z-index: 50;
}
.sidebar-brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 20px; border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.sidebar-brand .sb-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.sidebar-nav { padding: 12px 12px; flex: 1; }
.nav-section { font-size: 12px; color: var(--text-muted); padding: 8px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 4px;
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-secondary); font-size: 14px;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.active { background: var(--primary-tint); color: var(--primary); font-weight: 500; }
.nav-item .nav-ico { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.sidebar-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}

/* Main */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; height: 100%; }

/* Top bar */
.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; position: sticky; top: 0; z-index: 40;
  flex-shrink: 0;
}
.topbar-title { font-size: 20px; font-weight: 600; color: var(--text); white-space: nowrap; }
/* 顶栏搜索框已移除（已迁到设备管理 filter 区） */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.status-dot.offline { background: var(--error); }
.topbar-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.admin { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--border); }
.admin-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-tint); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.admin-name { font-size: 14px; color: var(--text); line-height: 1.2; }
.admin-role { font-size: 12px; color: var(--text-muted); line-height: 1.2; }

/* Content */
.content { flex: 1; overflow: auto; min-height: 0; padding: 0; position: relative; }
.page-wrap { padding: 20px; }

/* ============ Stat cards ============ */
.stat-grid {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 12px; margin-bottom: 12px;
}
.stat-card {
  position: relative; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; overflow: hidden; cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent, var(--primary));
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card.active { border-color: var(--primary); background: var(--primary-tint); }
.stat-card .num { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--num-color, var(--text)); letter-spacing: -0.5px; }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============ Filter bar ============ */
.filter-card {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px;
}
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  justify-content: flex-start;  /* 左对齐 */
}
.filter-divider {
  width: 1px; height: 32px;
  background: #e4e7ed;
  margin: 0 4px;
  align-self: center;
}
.filter-actions { display: flex; gap: 8px; align-items: center; }
.filter-actions .btn { display: inline-flex; align-items: center; gap: 4px; }
.filter-actions .ico {
  display: inline-block;
  font-size: 13px;
  line-height: 1;
  transition: transform 0.6s ease;
}
.filter-actions .btn-primary:hover .ico { transform: rotate(360deg); }
.filter-item { display: flex; flex-direction: column; gap: 5px; }
.filter-item.grow { flex: 1 1 0; min-width: 200px; max-width: 400px; }
.filter-item label { font-size: 13px; color: var(--text-muted); }
.filter-item select, .filter-item input {
  height: 32px; padding: 0 10px; min-width: 140px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface); color: var(--text);
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.filter-item input { width: 100%; }
.filter-item.grow input { min-width: 0; }
.filter-item select:focus, .filter-item input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.result-count { font-size: 13px; color: var(--text-muted); align-self: flex-end; padding-bottom: 8px; }

/* ============ Buttons ============ */
.btn {
  height: 32px; padding: 0 14px; border-radius: var(--radius-sm);
  font-size: 14px; cursor: pointer; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s; white-space: nowrap; user-select: none;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); border-color: var(--primary-active); }
.btn-default { background: var(--surface); color: var(--text-secondary); border-color: var(--border-strong); }
.btn-default:hover { color: var(--primary); border-color: var(--primary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ Login ============ */
.login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #f0f5ff 0%, #e6efff 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.login-overlay.hidden { display: none; }
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo {
  width: 56px; height: 56px;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
  margin: 0 auto 16px;
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.3);
}
.login-title { font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text-muted); }
.login-field { margin-bottom: 16px; }
.login-field label {
  display: block; font-size: 13px; color: var(--text-secondary);
  margin-bottom: 6px; font-weight: 500;
}
.login-field input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px; color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}
.login-field input::placeholder { color: #c0c4cc; }
.login-error {
  color: #f56c6c; font-size: 13px; line-height: 1.5;
  margin-bottom: 12px; min-height: 0;
  padding: 0;
  transition: min-height 0.2s, padding 0.2s;
}
.login-error.show {
  background: #fef0f0; border: 1px solid #fde2e2;
  border-radius: var(--radius); padding: 8px 12px;
  min-height: 18px;
  margin-bottom: 16px;
}
.login-submit {
  width: 100%; padding: 11px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.login-submit:hover { background: var(--primary-hover); }
.login-submit:active { transform: scale(0.99); }
.login-submit:disabled { background: #a0cfff; cursor: not-allowed; }
.login-tip {
  text-align: center; font-size: 12px;
  color: var(--text-muted); margin-top: 16px;
}
.logout-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 16px; padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  transition: color 0.2s, background 0.2s;
  display: flex; align-items: center;
}
.logout-btn:hover { color: var(--primary); background: var(--primary-tint); }

/* ============ Institution search highlight ============ */
/* 搜索命中的机构：高亮显示（蓝色文字 + 浅蓝背景） */
.inst-name-hit {
  color: #1677FF !important;
  font-weight: 600;
  background: #E6F4FF;
  padding: 2px 6px;
  border-radius: 4px;
  margin: -2px 0;
}
tr[data-search-hit="1"] {
  background: #F0F7FF !important;
}
tr[data-search-hit="1"]:hover {
  background: #E6F4FF !important;
}
.link-btn {
  background: none; border: none; padding: 3px 6px; cursor: pointer;
  color: var(--primary); font-size: 14px; border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.app-item.disabled {
  background: #f5f5f5 !important;
  color: #c0c4cc !important;
  cursor: not-allowed;
  border-color: #ebeef5 !important;
  box-shadow: none !important;
}
.app-item.disabled:hover {
  background: #f5f5f5 !important;
  border-color: #ebeef5 !important;
  color: #c0c4cc !important;
}
.lock-hint {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.6;
}
.action-btn-sm {
  font-size: 12px;
  padding: 2px 8px;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-weight: 500;
}
.action-btn-sm:hover {
  background: #fff;
  color: var(--primary-active);
  border-color: var(--primary-active);
  box-shadow: 0 1px 2px rgba(22, 119, 255, 0.15);
}
.action-btn-sm:active {
  background: var(--primary-tint);
  color: var(--primary-active);
  border-color: var(--primary-active);
}
.link-btn:hover { background: var(--primary-tint); }
.link-btn + .link-btn { margin-left: 4px; }

/* ============ Table ============ */
.table-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.table-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
  height: 48px;
}
.table-card-title { font-size: 16px; font-weight: 600; color: var(--text); }
.table-card-sub { font-size: 14px; color: var(--text-muted); }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface-alt); }
th {
  text-align: left; padding: 10px 14px; font-size: 14px; font-weight: 600;
  color: var(--text-secondary); border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
  background: var(--surface-alt);
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--primary); }
.sub-table thead th { position: static; }
td {
  padding: 9px 14px; border-bottom: 1px solid var(--divider);
  font-size: 15px; color: var(--text); vertical-align: middle;
}
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: #F7FAFF; }
tbody tr:last-child td { border-bottom: none; }
.nowrap { white-space: nowrap; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; color: var(--text-secondary); }
.cell-link { color: var(--primary); cursor: pointer; font-weight: 500; }
.cell-link:hover { text-decoration: underline; }
.apps-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.empty { color: var(--text-muted); }
.empty-row { text-align: center; padding: 48px 0; color: var(--text-muted); font-size: 14px; }
.strong { font-weight: 600; color: var(--text); }
.muted { color: var(--text-muted); font-size: 13px; }
.addr-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }

/* ============ Institution tree ============ */
.inst-name { display: inline-flex; align-items: center; gap: 6px; }
.inst-name .tree-indent { display: inline-block; width: 20px; height: 1px; flex-shrink: 0; }
.inst-name .tree-toggle {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 8px;
  color: #909399;
  background: #F2F3F5;
  border: 1px solid #E4E7ED;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.inst-name .tree-toggle::before {
  /* 扩大的不可见点击热区 */
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 12px;
}
.inst-name .tree-toggle:hover {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--primary);
}
.inst-name .tree-toggle:active {
  transform: scale(0.92);
}
.inst-name .tree-arrow {
  display: inline-block;
  font-size: 22px;
  line-height: 1;
  font-weight: 500;
  transform: rotate(90deg);    /* 展开时：箭头朝下 */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.inst-name .tree-toggle.collapsed .tree-arrow {
  transform: rotate(0deg);    /* 折叠时：箭头朝右 */
}
.inst-name .tree-spacer {
  display: inline-block;
  width: 32px; height: 32px; flex-shrink: 0;
  cursor: default;
}
.inst-name .level-tag {
  height: 18px; padding: 0 6px; font-size: 11px; font-weight: 500;
  background: #F5F5F5; color: var(--text-muted); border-color: #E8E8E8;
}
.inst-row td { border-bottom: 1px solid var(--divider); }
.inst-row.level-1 td { background: #FAFBFC; }
.inst-row.level-2 td { background: #fff; }
.inst-row.level-3 td { background: #fff; }
.inst-row.level-4 td { background: #fff; }

/* ============ Tags ============ */
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 4px; font-size: 12px; line-height: 1; font-weight: 500;
  white-space: nowrap; border: 1px solid transparent;
}
.tag-default { background: #FAFAFA; color: var(--text-secondary); border-color: var(--border-strong); }
.tag-success { background: #F6FFED; color: #389E0D; border-color: #B7EB8F; }
.tag-error { background: #FFF1F0; color: #CF1322; border-color: #FFA39E; }
.tag-primary { background: #E6F4FF; color: #0958D9; border-color: #91CAFF; }
.tag-warning { background: #FFFBE6; color: #D48806; border-color: #FFE58F; }

/* ============ Pagination ============ */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 16px 4px;
}
.pagination { display: flex; gap: 6px; align-items: center; }
.pagination button {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: 14px; color: var(--text-secondary);
  transition: all 0.15s;
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination .page-info { font-size: 13px; color: var(--text-muted); margin: 0 8px; }
.pagination-info {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.pagination-info .result-divider { color: var(--border-strong); }

/* ============ Drawer (detail) ============ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  z-index: 300; opacity: 0; visibility: hidden; transition: opacity 0.25s;
}
.drawer-overlay.show { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 720px; max-width: 94vw;
  background: var(--surface); z-index: 301; display: flex; flex-direction: column;
  box-shadow: var(--shadow-drawer); transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer-overlay.show .drawer { transform: translateX(0); }
.drawer-resize-handle {
  position: absolute; left: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize;
  background: transparent; z-index: 10; transition: background 0.15s;
}
.drawer-resize-handle:hover, .drawer-resize-handle.resizing { background: rgba(22, 119, 255, 0.35); }
body.drawer-resizing { user-select: none; }
body.drawer-resizing .drawer { transition: none; }
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.drawer-header h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.drawer-close {
  width: 32px; height: 32px; border: none; background: none; cursor: pointer;
  font-size: 20px; color: var(--text-muted); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.drawer-close:hover { background: var(--surface-alt); color: var(--text); }
.drawer-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

/* ============ Detail sections ============ */
.detail-section { margin-bottom: 22px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section h4 {
  font-size: 13px; color: var(--text-secondary); font-weight: 600;
  margin-bottom: 10px; padding-left: 9px; position: relative;
}
.detail-section h4::before {
  content: ''; position: absolute; left: 0; top: 2px; bottom: 2px;
  width: 3px; border-radius: 2px; background: var(--primary);
}
.detail-section h4 .section-action {
  display: inline-flex; align-items: center; margin-left: 12px;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.detail-item {
  display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--divider);
}
.detail-item .dk { color: var(--text-muted); min-width: 76px; font-size: 13px; flex-shrink: 0; }
.detail-item .dv { font-weight: 500; font-size: 13px; color: var(--text); word-break: break-all; }
.detail-item .dv.copyable { color: var(--primary); cursor: pointer; }
.detail-item .dv.copyable:hover { text-decoration: underline; }

/* ============ App chips (in device detail) ============ */
.detail-item.app-row { grid-column: 1 / -1; align-items: flex-start; padding: 12px 0; }
.app-list { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; align-items: center; }
.app-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  background: #F0F7FF; color: #1677FF;
  border: 1px solid #DCE9FF;
  border-radius: 14px;
  font-size: 13px; font-weight: 500; line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}
.app-chip:hover { background: #E0EFFF; border-color: #B3D4FF; }
.app-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #1677FF; flex-shrink: 0;
}
.app-empty {
  color: var(--text-muted); font-size: 13px; font-style: italic;
}
.sub-table { width: 100%; margin-top: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.sub-table th { padding: 8px 12px; font-size: 12px; }
.sub-table td { padding: 8px 12px; font-size: 12px; }

/* ============ Pager (机构详情页设备列表分页) ============ */
/* UI 布局：
   - 左侧：分页导航按钮（首页/上一页/页码/下一页/末页）—— 左对齐
   - 右侧：分页信息"共 X 条 · 第 X/X 页" —— 右对齐
   - 整体：justify-content: space-between，两端对齐
   - 固定每页 20 条（性能优化后不再支持切换 pageSize）
   - 移动端自适应（flex-wrap + 居中） */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  margin-top: 12px; padding: 10px 12px;
  background: #FAFBFC; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary);
}
.pager-left { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-right { display: flex; align-items: center; }
.pager-info {
  font-size: 13px; color: var(--text-secondary);
  padding: 0 4px;
}
.pager-info b { color: var(--text); font-weight: 600; }
.pager-btn, .pager-page {
  height: 28px; min-width: 28px; padding: 0 8px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface);
  font-size: 12px; color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s; margin: 0 1px;
}
.pager-btn:hover:not(:disabled), .pager-page:hover { border-color: var(--primary); color: var(--primary); }
.pager-page.active {
  background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600;
}
.pager-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pager-pages { display: inline-flex; align-items: center; gap: 1px; }
.pager-ellipsis { padding: 0 4px; color: var(--text-muted); font-size: 12px; }

/* 移动端适配：分页条换行后居中，按钮组和信息上下堆叠 */
@media (max-width: 640px) {
  .pager { justify-content: center; gap: 6px; }
  .pager-left, .pager-right { width: 100%; justify-content: center; }
  .pager-info { text-align: center; }
}

/* ============ Action bar (inside drawer) ============ */
.action-bar { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.action-btn {
  height: 34px; padding: 0 16px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
  font-size: 14px; color: var(--text-secondary); transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 5px;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); }
.action-btn.danger:hover { border-color: var(--error); color: var(--error); }
.action-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.action-btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ App modal ============ */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  z-index: 400; justify-content: center; align-items: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 520px;
  max-width: 92vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 10;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { cursor: pointer; font-size: 22px; color: var(--text-muted); background: none; border: none; line-height: 1; }
.modal-body { padding: 20px 24px; }
.app-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0; }
.app-item {
  padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; transition: all 0.15s;
}
.app-item:hover { border-color: var(--primary); color: var(--primary); }
.app-item.selected { border-color: var(--primary); background: var(--primary-tint); color: var(--primary); }

/* ============ App modal: 设备/机构管理应用权限弹窗专用宽度 ============ */
/* 通用 .modal 宽度 520px 对 20+ 应用项太挤；单独为 #appModal 加宽到 640px，
   并配合 .app-group .app-list 适当加大行间距，让分类区块更易浏览 */
#appModal .modal { width: 640px; }
#appModal .modal-body { padding: 20px 28px; }
#appModal .app-group { padding: 14px 16px; }
#appModal .app-group .app-list { gap: 8px; }
#appModal .app-item { padding: 7px 16px; font-size: 13px; }

/* ============ App modal: 按平台分组的应用分类区块 ============ */
/* 应用管理弹窗（设备/机构）按 App 端 / PC 端 分类展示，区块间用分组标题 + 计数 + 提示区分 */
.app-group {
  margin: 12px 0 16px;
  padding: 12px 14px;
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.app-group:first-of-type { margin-top: 4px; }
.app-group:last-of-type { margin-bottom: 8px; }
.app-group-title {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
  font-size: 13px; line-height: 1.4;
}
.app-group-label {
  font-weight: 600; color: var(--text);
  padding: 2px 10px; border-radius: 10px;
  background: var(--primary-tint); color: var(--primary);
  font-size: 12px;
}
.app-group[data-group="pc"] .app-group-label {
  background: #FFF4E6; color: #D46B08;
}
.app-group-count {
  font-size: 12px; color: var(--text-muted);
  font-weight: 500;
}
.app-group-hint {
  font-size: 11px; color: var(--text-muted);
  margin-left: auto;
  opacity: 0.85;
}
.app-group .app-list {
  padding: 0;
  gap: 6px;
}

/* ============ Confirm dialog ============ */
.confirm-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  z-index: 500; justify-content: center; align-items: center;
}
.confirm-overlay.show { display: flex; }
.confirm-box {
  background: var(--surface); border-radius: var(--radius-lg); padding: 24px;
  width: 420px; max-width: 92vw; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.confirm-box h3 { margin-bottom: 8px; font-size: 16px; }
.confirm-box p { color: var(--text-secondary); margin-bottom: 20px; font-size: 14px; line-height: 1.6; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  padding: 9px 20px; border-radius: var(--radius-sm); font-size: 14px; z-index: 600;
  transition: transform 0.3s; color: #fff; background: #333; box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

/* ============ Back to top ============ */
.back-to-top {
  position: fixed; right: 24px; bottom: 24px; width: 70px; height: 70px;
  border-radius: 50%; background: #fff; border: 2px solid var(--primary);
  box-shadow: 0 4px 14px rgba(22, 119, 255, 0.25); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); font-size: 26px; font-weight: 700;
  opacity: 0; visibility: hidden;
  transform: translateY(10px); transition: all 0.2s; z-index: 60;
}
.back-to-top:hover { background: var(--primary); color: #fff; box-shadow: 0 6px 20px rgba(22, 119, 255, 0.4); transform: translateY(0) scale(1.05); }
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .page-wrap { padding: 16px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .detail-grid { grid-template-columns: 1fr; }
}
