:root {
  --ant-primary: #1677ff;
  --ant-primary-hover: #4096ff;
  --ant-primary-bg: #e6f4ff;
  --ant-primary-border: #91caff;
  --ant-success: #52c41a;
  --ant-success-bg: #f6ffed;
  --ant-success-border: #b7eb8f;
  --ant-warning: #faad14;
  --ant-warning-bg: #fffbe6;
  --ant-warning-border: #ffe58f;
  --ant-error: #ff4d4f;
  --ant-error-bg: #fff2f0;
  --ant-error-border: #ffccc7;

  --bg-body: #f0f2f5;
  --bg-sider: #001529;
  --bg-sider-head: #002140;
  --bg-header: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #fafafa;
  --bg-hover: #f5f5f5;
  --bg-input: #ffffff;
  --bg-code: #141414;

  --border-color: #f0f0f0;
  --border-strong: #d9d9d9;
  --text-main: rgba(0, 0, 0, 0.88);
  --text-sec: rgba(0, 0, 0, 0.65);
  --text-muted: rgba(0, 0, 0, 0.45);
  --gauge-track: #f0f0f0;
}

[data-theme="dark"] {
  --ant-primary: #1668dc;
  --ant-primary-hover: #3c89e8;
  --ant-primary-bg: #111a2c;
  --ant-primary-border: #15325b;
  --ant-success: #49aa19;
  --ant-success-bg: #162312;
  --ant-success-border: #274916;
  --ant-warning: #d89614;
  --ant-warning-bg: #2b2111;
  --ant-warning-border: #594214;
  --ant-error: #dc4446;
  --ant-error-bg: #2c1618;
  --ant-error-border: #58181c;

  --bg-body: #0a0a0a;
  --bg-sider: #141414;
  --bg-sider-head: #1a1a1a;
  --bg-header: #141414;
  --bg-card: #191919;
  --bg-subtle: #222222;
  --bg-hover: #262626;
  --bg-input: #141414;
  --bg-code: #0d0d0d;

  --border-color: #2b2b2b;
  --border-strong: #424242;
  --text-main: rgba(255, 255, 255, 0.88);
  --text-sec: rgba(255, 255, 255, 0.65);
  --text-muted: rgba(255, 255, 255, 0.42);
  --gauge-track: #2c2c2c;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg-body);
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

/* ==================== 登录页（3x-ui 极简面板登录框） ==================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-body);
}

.login-box {
  width: 100%;
  max-width: 376px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 28px 26px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.login-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 600;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: var(--ant-primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ==================== 3x-ui 经典左导航 + 右工作区布局 ==================== */
.xui-layout {
  display: flex;
  min-height: 100vh;
}

.xui-sider {
  width: 200px;
  background: var(--bg-sider);
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: width 0.18s ease;
  z-index: 40;
}

.xui-layout.collapsed .xui-sider {
  width: 56px;
}

.sider-logo {
  height: 48px;
  background: var(--bg-sider-head);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.xui-layout.collapsed .sider-logo-text {
  display: none;
}

.sider-menu {
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
}

.menu-item {
  width: 100%;
  height: 38px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  padding: 0 12px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.menu-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.menu-item.active {
  background: var(--ant-primary);
  color: #fff;
  font-weight: 500;
}

.menu-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.xui-layout.collapsed .menu-label,
.xui-layout.collapsed .sider-foot-text {
  display: none;
}

.xui-layout.collapsed .menu-item {
  justify-content: center;
  padding: 0;
}

.sider-foot {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  overflow: hidden;
}

.xui-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.xui-header {
  height: 48px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-sec);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--ant-primary);
  border-color: var(--ant-primary);
}

.page-crumb {
  font-size: 14px;
  font-weight: 600;
}

.xui-content {
  padding: 14px 16px 32px;
  flex: 1;
}

@media (max-width: 860px) {
  .xui-sider { width: 56px; }
  .sider-logo-text, .menu-label, .sider-foot-text { display: none; }
  .menu-item { justify-content: center; padding: 0; }
}

/* ==================== Ant Design 标准栅格与面板卡片 ==================== */
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }

@media (max-width: 1080px) {
  .row-4 { grid-template-columns: repeat(2, 1fr); }
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

.x-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 12px;
}

.x-card-head {
  min-height: 42px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.x-card-title {
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.x-card-body {
  padding: 14px;
}

.x-card-body.no-pad {
  padding: 0;
}

/* ==================== 3x-ui 标志性 SVG 圆环仪表盘 ==================== */
.gauge-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.gauge-svg-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  flex-shrink: 0;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.gauge-meta {
  min-width: 0;
  flex: 1;
}

.gauge-title {
  font-size: 12.5px;
  color: var(--text-sec);
  margin-bottom: 4px;
}

.gauge-val {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 3px;
}

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

/* ==================== 3x-ui 边框键值参数表 (ant-descriptions) ==================== */
.desc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.desc-table th,
.desc-table td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.desc-table th {
  width: 136px;
  background: var(--bg-subtle);
  color: var(--text-sec);
  font-weight: 500;
  white-space: nowrap;
}

/* ==================== Ant Design 标签 (4px 直角边框，去胶囊感) ==================== */
.x-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  font-size: 12px;
  line-height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-sec);
  white-space: nowrap;
}

.x-tag-green { color: var(--ant-success); background: var(--ant-success-bg); border-color: var(--ant-success-border); }
.x-tag-blue { color: var(--ant-primary); background: var(--ant-primary-bg); border-color: var(--ant-primary-border); }
.x-tag-orange { color: var(--ant-warning); background: var(--ant-warning-bg); border-color: var(--ant-warning-border); }
.x-tag-red { color: var(--ant-error); background: var(--ant-error-bg); border-color: var(--ant-error-border); }

/* ==================== Ant Design 按钮与表单控件 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: 0.15s;
}

.btn:hover:not(:disabled) {
  color: var(--ant-primary);
  border-color: var(--ant-primary);
}

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

.btn-primary {
  background: var(--ant-primary);
  border-color: var(--ant-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--ant-primary-hover);
  border-color: var(--ant-primary-hover);
  color: #fff;
}

.btn-danger {
  color: var(--ant-error);
  border-color: var(--ant-error-border);
  background: var(--ant-error-bg);
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--ant-error);
  color: var(--ant-error);
}

.btn-sm {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.input, .select {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.input:focus, .select:focus {
  border-color: var(--ant-primary);
}

.input-sm, .select-sm {
  height: 28px;
  padding: 0 8px;
  font-size: 12.5px;
}

.form-row { margin-bottom: 12px; }
.form-label { display: block; font-size: 12.5px; color: var(--text-sec); margin-bottom: 4px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==================== Ant Design 紧凑数据表格 ==================== */
.table-wrap { overflow-x: auto; }

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

.x-table th,
.x-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.x-table th {
  background: var(--bg-subtle);
  color: var(--text-sec);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

.x-table tbody tr:hover {
  background: var(--bg-hover);
}

/* ==================== Ant Design 内联 Switch 与进度条 ==================== */
.x-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  vertical-align: middle;
  flex-shrink: 0;
}

.x-switch input { opacity: 0; width: 0; height: 0; }

.x-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(120, 120, 120, 0.38);
  border-radius: 999px;
  transition: 0.18s;
}

.x-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  transition: 0.18s;
}

.x-switch input:checked + .x-slider {
  background: var(--ant-primary);
}

.x-switch input:checked + .x-slider::before {
  transform: translateX(16px);
}

.x-switch input:disabled + .x-slider {
  opacity: 0.45;
  cursor: not-allowed;
}

.progress-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress {
  width: 110px;
  height: 6px;
  background: var(--gauge-track);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.progress-bar {
  height: 100%;
  background: var(--ant-primary);
}

.progress-bar.ok { background: var(--ant-success); }
.progress-bar.warn { background: var(--ant-warning); }
.progress-bar.err { background: var(--ant-error); }

/* ==================== Ant Design Segmented / Alert / Code ==================== */
.seg-group {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px;
  width: 100%;
}

.seg-btn {
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-sec);
  font-size: 12.5px;
  border-radius: 3px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--ant-primary);
  color: #fff;
  font-weight: 500;
}

.x-alert {
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12.5px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

.x-alert-info { background: var(--ant-primary-bg); border-color: var(--ant-primary-border); color: var(--text-main); }
.x-alert-warn { background: var(--ant-warning-bg); border-color: var(--ant-warning-border); color: var(--text-main); }
.x-alert-err { background: var(--ant-error-bg); border-color: var(--ant-error-border); color: var(--ant-error); }
.x-alert-ok { background: var(--ant-success-bg); border-color: var(--ant-success-border); color: var(--text-main); }

.mono-box {
  background: var(--bg-code);
  color: #d4d4d4;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }

.fallback-details {
  border-top: 1px solid var(--border-color);
  margin-top: 14px;
  padding-top: 12px;
}

.fallback-details summary {
  font-size: 12.5px;
  color: var(--text-sec);
  cursor: pointer;
  user-select: none;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child { border-bottom: none; }

/* ==================== Ant Design Modal & Message Toast ==================== */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-dialog.modal-lg {
  max-width: 680px;
}

.subtabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 14px;
  background: var(--bg-subtle);
  flex-wrap: wrap;
}

.subtab-btn {
  height: 38px;
  padding: 0 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-sec);
  font-size: 13px;
  cursor: pointer;
}

.subtab-btn:hover { color: var(--ant-primary); }
.subtab-btn.active {
  color: var(--ant-primary);
  border-bottom-color: var(--ant-primary);
  font-weight: 600;
  background: var(--bg-card);
}

.expand-btn {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--bg-card);
  color: var(--text-sec);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.expand-btn:hover {
  border-color: var(--ant-primary);
  color: var(--ant-primary);
}

.expand-row td {
  background: var(--bg-subtle);
  padding: 12px 16px;
}

.qr-box {
  width: 184px;
  height: 184px;
  margin: 0 auto 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #fff;
  display: grid;
  place-items: center;
}

.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.modal-desc { font-size: 13px; color: var(--text-sec); line-height: 1.55; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 120;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.18s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
