*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-2: #f6f8fa;
  --bg-3: #eaeef2;
  --bg-4: #d0d7de;
  --border: rgba(31,35,40,0.12);
  --text: #1f2328;
  --text-muted: #656d76;
  --text-sub: #424a53;
  --accent: #7c3aed;
  --accent-soft: rgba(124,58,237,0.12);
  --green: #1a7f37;
  --green-soft: rgba(26,127,55,0.12);
  --yellow: #9a6700;
  --red: #cf222e;
  --radius: 8px;
  --sidebar-w: 220px;
  --bg-card: #eaeef2;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* Layout */
.layout {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
}

.logo-icon {
  font-size: 20px;
  color: var(--accent);
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--bg-3);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bus-url {
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
  font-family: monospace;
}

.refresh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.refresh-label {
  font-size: 12px;
  color: var(--text-muted);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-4);
  border-radius: 18px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent-soft); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(14px);
  background: var(--accent);
}

.btn-cleanup {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-cleanup:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Main */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.view { display: none; padding: 28px 32px; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.view-header h1 {
  font-size: 22px;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.last-update-label {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-refresh {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-refresh:hover { background: var(--bg-4); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-card--accent {
  border-color: rgba(124,58,237,0.3);
  background: rgba(124,58,237,0.06);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 4px;
  color: var(--text);
}

.stat-label {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 500;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Section */
.section { margin-top: 8px; }

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  font-size: 11px;
  padding: 1px 8px;
  font-weight: 600;
}

/* Beacon list (dashboard) */
.beacon-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.beacon-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.beacon-card:hover {
  border-color: rgba(124,58,237,0.4);
  background: var(--bg-3);
}

.beacon-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--green);
}

.beacon-id {
  font-family: monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.beacon-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.beacon-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.beacon-tag--e2ee {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(63,185,80,0.25);
}

.beacon-tag--apps {
  background: var(--accent-soft);
  color: #a78bfa;
  border-color: rgba(124,58,237,0.3);
}

.beacon-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* Bulk action bar */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent-soft);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 12px;
  animation: fadeIn 0.15s ease;
}

.bulk-bar[hidden] { display: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: #a78bfa;
}

.bulk-actions {
  display: flex;
  gap: 8px;
}

.bulk-btn {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(124,58,237,0.4);
  background: rgba(124,58,237,0.18);
  color: #c4b5fd;
  transition: background 0.15s, border-color 0.15s;
}

.bulk-btn:hover {
  background: rgba(124,58,237,0.3);
  border-color: rgba(124,58,237,0.6);
}

.bulk-btn--danger {
  border-color: rgba(248,81,73,0.4);
  background: rgba(248,81,73,0.1);
  color: var(--red);
}

.bulk-btn--danger:hover {
  background: rgba(248,81,73,0.2);
  border-color: rgba(248,81,73,0.6);
}

.bulk-btn--ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text-muted);
}

.bulk-btn--ghost:hover {
  background: var(--bg-3);
  color: var(--text);
}

/* Custom checkbox */
.cb-wrap {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.cb-wrap input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cb-box {
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--bg-4);
  border-radius: 4px;
  background: var(--bg-3);
  display: inline-block;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.cb-wrap:hover .cb-box {
  border-color: var(--accent);
}

.cb-wrap input:checked + .cb-box {
  background: var(--accent);
  border-color: var(--accent);
}

.cb-wrap input:checked + .cb-box::after {
  content: "";
  display: block;
  width: 4px;
  height: 7px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(2px, 0px);
}

.cb-wrap input:indeterminate + .cb-box {
  background: var(--accent);
  border-color: var(--accent);
}

.cb-wrap input:indeterminate + .cb-box::after {
  content: "";
  display: block;
  width: 7px;
  height: 2px;
  background: #fff;
  margin: 4px auto 0;
}

/* Table */
.agent-table-wrap {
  overflow-x: auto;
}

.agent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.agent-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.agent-table .th-check {
  width: 40px;
  padding: 10px 12px;
}

.agent-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-sub);
  vertical-align: middle;
  white-space: nowrap;
}

.agent-table td.td-check {
  padding: 12px 12px;
  width: 40px;
}

.agent-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.agent-table tbody tr:hover td {
  background: var(--bg-2);
}

.agent-table tbody tr.row-selected td {
  background: rgba(124,58,237,0.08);
}

.agent-table tbody tr.row-selected:hover td {
  background: rgba(124,58,237,0.14);
}

.agent-table .empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  cursor: default;
}

.agent-table .empty-row:hover td { background: transparent; }

td.bot-id-cell {
  font-family: monospace;
  color: var(--text);
  font-weight: 500;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  box-shadow: 0 0 5px var(--green);
}

/* Empty state */
.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-2);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* Detail Drawer */
/* ── 抽屉遮罩 ───────────────────────────────────────────── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 40;
  animation: backdropIn 0.2s ease;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── 抽屉主体 ───────────────────────────────────────────── */
.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 96vw;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
  z-index: 50;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0.6; }
  to   { transform: translateX(0);    opacity: 1; }
}

.detail-drawer[hidden], .drawer-backdrop[hidden] { display: none; }

/* ── 抽屉头部 ───────────────────────────────────────────── */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-3);
  border-bottom: 2px solid var(--accent);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.drawer-close:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── 抽屉内容区 ─────────────────────────────────────────── */
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.drawer-body::-webkit-scrollbar { width: 5px; }
.drawer-body::-webkit-scrollbar-track { background: transparent; }
.drawer-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── 内容分组 ───────────────────────────────────────────── */
.detail-section {
  margin-bottom: 18px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 8px 14px;
  background: rgba(88, 166, 255, 0.07);
  border-bottom: 1px solid var(--border);
}

/* ── 字段行 ─────────────────────────────────────────────── */
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }

.detail-key {
  display: flex;
  align-items: center;
  min-width: 116px;
  max-width: 116px;
  padding: 9px 12px 9px 14px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.12);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  line-height: 1.4;
}

.detail-val {
  flex: 1;
  padding: 9px 14px;
  color: var(--text);
  font-size: 12px;
  word-break: break-all;
  line-height: 1.5;
}
.detail-val.td-mono {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 11.5px;
}

/* 客户端连接卡片 */
.app-conn-card {
  margin: 8px 8px 0;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
}
.app-conn-card:last-child { margin-bottom: 8px; }

.app-conn-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: nowrap;
}

.app-conn-type {
  font-size: 11px;
  font-weight: 600;
  color: #a78bfa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.app-conn-e2ee {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(63,185,80,0.25);
}

.app-conn-user {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-sub);
}

.app-conn-id {
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-conn-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
  align-items: center;
}

.app-conn-label {
  color: var(--text-muted);
  min-width: 52px;
}

.app-conn-value {
  color: var(--text);
  font-size: 11px;
}

.app-conn-card .app-peer-id {
  font-family: monospace;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 500;
}

/* 断开连接按钮 */
.conn-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.conn-disconnect-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 5px;
  border: 1px solid rgba(248, 81, 73, 0.45);
  background: rgba(248, 81, 73, 0.08);
  color: #f85149;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.conn-disconnect-btn:hover:not(:disabled) {
  background: rgba(248, 81, 73, 0.18);
  border-color: rgba(248, 81, 73, 0.7);
}

.conn-disconnect-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.conn-disconnect-btn--sm {
  padding: 2px 8px;
  font-size: 11px;
  margin-left: auto;
}

.loading-spin {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }

/* ── 用户管理 ──────────────────────────────────────── */
.stats-grid--sm {
  grid-template-columns: repeat(3, 1fr);
}

.user-filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.user-filter-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* 在线状态指示点 */
.user-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}

.user-status-dot--online {
  background: var(--green);
  box-shadow: 0 0 5px var(--green);
}

.user-status-dot--offline {
  background: var(--bg-4);
}

.user-status-text {
  font-size: 11px;
  vertical-align: middle;
  color: var(--text-muted);
}

/* 用户行高亮 */
.user-row--online td:first-child .user-status-text {
  color: var(--green);
}

/* 用户名单元格 */
.user-name-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.user-name {
  font-weight: 500;
  color: var(--text);
}

.user-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-3);
  color: var(--text-muted);
}

.user-tag--admin {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.user-tag--inactive {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
}

/* 角色徽章 */
.user-role {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--bg-3);
  color: var(--text-muted);
}

.user-role--admin {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

/* 邮箱、时间列 */
.user-email,
.user-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* Beacon 列 */
.user-beacons {
  max-width: 200px;
  white-space: normal;
}

.user-beacon-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.user-beacon-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: monospace;
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-beacon-more {
  font-size: 10px;
  color: var(--text-muted);
}

.user-beacon-none {
  color: var(--text-muted);
  font-size: 12px;
}

/* 操作列按钮 */
.user-actions {
  white-space: nowrap;
}

.user-action-btn {
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s;
}

.user-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.user-action-btn--danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.25);
}

.user-action-btn--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.22);
}

.user-action-btn--ok {
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.25);
}

.user-action-btn--ok:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.22);
}

/* 抽屉备注文字 */
.detail-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg-2);
  border-radius: 6px;
  border-left: 2px solid var(--bg-4);
  line-height: 1.5;
}

/* ── 自定义 Modal ───────────────────────────────────── */
.cm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cmFadeIn 0.15s ease;
}
.cm-backdrop[hidden] { display: none; }
@keyframes cmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.cm-dialog {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  padding: 28px 28px 22px;
  width: 360px;
  max-width: 92vw;
  text-align: center;
  animation: cmSlideUp 0.18s cubic-bezier(0.34, 1.2, 0.64, 1);
}
@keyframes cmSlideUp {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}
.cm-icon {
  font-size: 36px;
  margin-bottom: 12px;
  line-height: 1;
}
.cm-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.cm-body {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.6;
}
.cm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.cm-btn {
  flex: 1;
  max-width: 130px;
  height: 36px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.cm-btn:active { transform: scale(0.97); }
.cm-btn-cancel {
  background: var(--bg-3);
  color: var(--text-muted);
}
.cm-btn-cancel:hover { background: var(--bg-4); color: var(--text); }
.cm-btn-confirm {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.cm-btn-confirm:hover { filter: brightness(1.12); }
.cm-btn-confirm.danger {
  background: var(--red, #f85149);
  border-color: var(--red, #f85149);
}

/* ── Toast 通知 ─────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  min-width: 220px;
  max-width: 360px;
  animation: toastIn 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
  cursor: pointer;
}
@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast.toast-out {
  animation: toastOut 0.2s ease forwards;
}
@keyframes toastOut {
  to { transform: translateX(40px); opacity: 0; }
}
.toast-success { background: #1a7f37; }
.toast-error   { background: #b91c1c; }
.toast-warn    { background: #92400e; }
.toast-info    { background: #1e40af; }
.toast-icon    { font-size: 16px; flex-shrink: 0; }
.toast-msg     { flex: 1; }

/* ── 登录蒙层 ───────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.login-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.login-card {
  width: 340px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.login-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -12px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sub);
}

.login-input {
  padding: 9px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.login-input:focus {
  border-color: var(--accent);
}

.login-error {
  font-size: 12px;
  color: var(--red);
  min-height: 16px;
}

.login-btn {
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 4px;
}

.login-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Session 信息栏（侧边栏底部） ────────────────────── */
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.session-user {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.btn-logout {
  padding: 3px 10px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.btn-logout:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ── 邀请码管理 ────────────────────────────────────────── */

.invite-pie-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  width: fit-content;
}

.invite-pie {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.invite-pie-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-sub);
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pie-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 分页栏 */
.invite-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.pg-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
}
.pg-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pg-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.pg-btn:hover:not(:disabled) {
  background: var(--bg-4);
  border-color: var(--accent);
  color: var(--accent);
}
.pg-btn.pg-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.pg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pg-ellipsis {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 2px;
}
.pg-size select {
  height: 28px;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.pg-size select:focus { outline: none; border-color: var(--accent); }

.invite-pick-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.btn-pick-invite {
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn-pick-invite:hover { opacity: 0.85; }
.btn-pick-invite:active { opacity: 0.7; }

.invite-pick-result {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.invite-pick-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.invite-pick-code {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.02em;
  user-select: all;
}

.btn-copy-invite {
  padding: 4px 12px;
  background: var(--bg-4);
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-copy-invite:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-copy-invite.copied {
  color: var(--green);
  border-color: var(--green);
}

.invite-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.invite-search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: 7px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.invite-search:focus {
  border-color: var(--accent);
}

.invite-row:hover td {
  background: var(--bg-3);
}

.invite-table td {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invite-table .td-mono {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-sub);
}
.invite-code-cell {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.badge-used {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-unused {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-4);
  color: var(--text-muted);
}

/* 筛选框旁彩点 */
.filter-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.dot-unused       { background: #3fb950; }
.dot-distributed  { background: #f59e0b; }
.dot-used         { background: #7c3aed; }

/* 使用按钮（未使用行） */
.btn-use-invite {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #58a6ff;
  background: rgba(88, 166, 255, 0.1);
  color: #58a6ff;
  transition: background 0.15s, color 0.15s;
  vertical-align: middle;
}
.btn-use-invite:hover:not(:disabled) {
  background: #58a6ff;
  color: #0d1117;
}
.btn-use-invite:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 邀请码行：按状态着色左侧边框 */
.invite-row.row-unused td:first-child { border-left: 3px solid #3fb950; }
.invite-row.row-used   td:first-child { border-left: 3px solid #7c3aed; }
.invite-row.row-used   { background: rgba(124, 58, 237, 0.04); }

.badge-connected {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--green-soft);
  color: var(--green);
}

.badge-offline {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-4);
  color: var(--text-muted);
}

.pod-state-running { color: var(--green); font-weight: 600; }
.pod-state-creating,
.pod-state-initializing { color: var(--yellow); font-weight: 600; }
.pod-state-stopped,
.pod-state-error { color: var(--red); }

/* ── 申请管理 ── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  margin-left: auto;
}

/* 筛选标签栏 */
.app-filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 10px;
  width: fit-content;
}
.app-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.app-tab:hover { background: var(--bg-3); color: var(--text); }
.app-tab.active { background: var(--bg-card); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.app-tab-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-pending  { background: #f59e0b; }
.dot-approved { background: #10b981; }
.dot-rejected { background: #ef4444; }
.app-tab-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 9px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
  line-height: 18px;
  height: 18px;
  display: inline-block;
}
.app-tab-count:empty { display: none; }

/* 卡片列表 */
/* 申请管理顶部：筛选标签左贴底，饼图右 */
.app-top-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.app-top-bar .app-filter-tabs { margin-bottom: 0; }
.app-filter-tabs--bottom { align-self: flex-end; }
.app-pie-wrap { margin-bottom: 0 !important; flex-shrink: 0; }

/* 全选列 */
.app-th-check { width: 36px; text-align: center; padding: 0 4px; }
.app-th-check input[type="checkbox"] { cursor: pointer; width: 14px; height: 14px; }

/* 批量操作栏 */
.app-bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.app-bulk-count { font-size: 13px; color: var(--text-muted); margin-right: 4px; }

/* 状态标签 */
.app-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  white-space: nowrap;
}
.app-status--pending       { background: rgba(245,158,11,0.12); color: #d97706; border: 1px solid rgba(245,158,11,0.25); }
.app-status--approved      { background: rgba(16,185,129,0.1);  color: #059669; border: 1px solid rgba(16,185,129,0.25); }
.app-status--rejected      { background: rgba(239,68,68,0.1);   color: #dc2626; border: 1px solid rgba(239,68,68,0.25); }
.app-status--distributed   { background: rgba(245,158,11,0.12); color: #b45309; border: 1px solid rgba(245,158,11,0.3); }

/* 操作按钮 */
.app-actions-cell { display: flex; gap: 6px; align-items: center; }
.app-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.app-btn:active { transform: translateY(1px); }
.app-btn--approve { background: #10b981; color: #fff; }
.app-btn--approve:hover { opacity: 0.88; }
.app-btn--reject  { background: var(--bg-3); color: var(--text-muted); border: 1px solid var(--border); }
.app-btn--reject:hover  { background: rgba(239,68,68,0.1); color: #dc2626; border-color: rgba(239,68,68,0.3); }
.table-dash { color: var(--text-muted); }

/* 申请管理分页 */
#appPagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 12px; }
.page-btn {
  min-width: 30px; height: 28px; padding: 0 8px;
  border-radius: 5px; border: 1px solid var(--border);
  background: var(--bg-3); color: var(--text);
  font-size: 12px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.page-btn:hover:not(:disabled) { background: var(--bg-4); border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.page-btn.disabled, .page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-ellipsis { font-size: 12px; color: var(--text-muted); padding: 0 2px; }
.page-info { font-size: 12px; color: var(--text-muted); margin-left: 6px; }
.app-reason-cell { max-width: 260px; white-space: pre-wrap; word-break: break-all; color: var(--text-sub); font-size: 12px; line-height: 1.55; }
.app-invite-cell { vertical-align: middle; }
.app-invite-cell > span, .app-invite-cell > button { vertical-align: middle; }
.app-invite-cell > span + button { margin-left: 6px; }
.btn-copy-inline {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-3);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.btn-copy-inline:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

/* ── 系统设置视图 ─────────────────────────────────────── */
.settings-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-width: 640px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.settings-row:last-child { border-bottom: none; }
.settings-label { font-size: 13px; color: var(--text-sub); flex: 0 0 auto; }
.settings-value { font-size: 14px; font-weight: 600; color: var(--text); }
.settings-row--action .settings-input-group { display: flex; align-items: center; gap: 8px; }
.invite-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.invite-toolbar-label { font-size: 13px; color: var(--text-sub); }
.btn-approve {
  padding: 5px 14px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-approve:hover { opacity: 0.85; }
.btn-approve:disabled { opacity: 0.45; cursor: not-allowed; }

/* 兑换码池分页 */
#inviteCodesPagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 12px; }

/* 兑换码池：筛选 + 搜索 + 饼图 同一行等高 */
.ic-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 0;
  flex-wrap: wrap;
}
.ic-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.ic-bar-row .app-filter-tabs { margin-bottom: 0; }
.ic-bar-row .invite-toolbar { margin-bottom: 0; }
.ic-pie-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.ic-pie-wrap .invite-pie-wrap {
  margin-bottom: 0;
}
