/* wb2zzwg 控制台样式
 *
 * 视觉参考 new-api（Arco Design 风格）：浅灰底 + 白色卡片 + 蓝色主色 +
 * 细边框 + 小圆角，克制的层级与留白。
 *
 * 主题由 <html data-theme="light|dark"> 决定（服务端按 cookie 渲染，刷新不闪白）。
 * 所有颜色走变量，深色不靠逐个覆盖规则。
 */

:root,
[data-theme="light"] {
  --primary: #165dff;
  --primary-hover: #4080ff;
  --primary-active: #0e42d2;
  --primary-weak: #e8f3ff;
  --primary-fg: #ffffff;

  --success: #00b42a;
  --success-weak: #e8ffea;
  --warning: #ff7d00;
  --warning-weak: #fff7e8;
  --danger: #f53f3f;
  --danger-weak: #ffece8;
  --link: #165dff;

  --bg: #f7f8fa;
  --card: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-hover: #f2f3f5;
  --bg-th: #f7f8fa;

  --text-1: #1d2129;
  --text-2: #4e5969;
  --text-3: #86909c;
  --text-4: #c9cdd4;

  --border: #e5e6eb;
  --border-2: #c9cdd4;

  --radius-card: 8px;
  --radius-ctl: 4px;
  --shadow-1: 0 1px 2px rgba(29, 33, 41, 0.04);
  --shadow-2: 0 4px 10px rgba(29, 33, 41, 0.08);
  --mask: rgba(29, 33, 41, 0.45);
  --shadow-drawer: -6px 0 24px rgba(29, 33, 41, 0.12);
  --focus-ring: rgba(22, 93, 255, 0.14);
  --chart-a: #4080ff;
  --chart-b: #165dff;
}

[data-theme="dark"] {
  --primary: #4080ff;
  --primary-hover: #6aa1ff;
  --primary-active: #306fff;
  --primary-weak: #17233d;
  --primary-fg: #ffffff;

  --success: #23c343;
  --success-weak: #0d2a1a;
  --warning: #ff9a2e;
  --warning-weak: #2b1d09;
  --danger: #f76560;
  --danger-weak: #2b1214;
  --link: #4080ff;

  --bg: #17171a;
  --card: #232324;
  --bg-soft: #1d1d20;
  --bg-hover: #2e2e30;
  --bg-th: #1d1d20;

  --text-1: #f2f3f5;
  --text-2: #c9cdd4;
  --text-3: #86909c;
  --text-4: #5f6570;

  --border: #333335;
  --border-2: #48484a;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 4px 10px rgba(0, 0, 0, 0.45);
  --mask: rgba(0, 0, 0, 0.6);
  --shadow-drawer: -6px 0 24px rgba(0, 0, 0, 0.5);
  --focus-ring: rgba(64, 128, 255, 0.2);
  --chart-a: #2a63c9;
  --chart-b: #4080ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Inter, sans-serif;
  font-size: 14px;
  line-height: 1.5715;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1, h2, h3 { margin: 0; font-weight: 600; }

.muted { color: var(--text-3); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.block { display: block; width: 100%; }
.grow { flex: 1; }

/* ---------- 骨架 ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex: 0 0 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 16px;
  color: var(--text-1); font-size: 15px; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.brand:hover { color: var(--text-1); }
.logo {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: var(--radius-ctl);
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { flex: 1; overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center;
  height: 40px; padding: 0 12px;
  border-radius: var(--radius-ctl);
  color: var(--text-2); font-size: 14px;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-1); }
.nav-item.active { background: var(--primary-weak); color: var(--primary); font-weight: 500; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.who { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.topbar {
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.crumb { color: var(--text-2); font-size: 14px; }

.content { padding: 20px 24px 32px; width: 100%; max-width: 1440px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; min-height: 32px;
}
.page-head h1 { font-size: 20px; letter-spacing: -0.2px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 卡片与表格 ---------- */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-1);
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 16px; min-height: 48px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 15px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; color: var(--text-3);
  font-size: 13px; padding: 10px 16px;
  background: var(--bg-th);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1); vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-hover); }
.cell-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.empty { padding: 32px 16px; text-align: center; color: var(--text-3); }

/* ---------- 徽标 ---------- */

.badge {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: var(--radius-ctl);
  font-size: 12px; line-height: 1;
  background: var(--bg-hover); color: var(--text-2);
  border: 1px solid transparent;
}
.badge.ok { background: var(--success-weak); color: var(--success); }
.badge.off { background: var(--bg-hover); color: var(--text-3); }
.badge.warn { background: var(--warning-weak); color: var(--warning); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--border);
  background: var(--card); color: var(--text-1);
  font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-2); }
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: var(--primary-fg);
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-weak); }

.link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--link); font-size: 13px; font-family: inherit;
}
.link:hover { color: var(--primary-hover); }
.link.danger { color: var(--danger); }
.link-btn { font-size: 13px; }

.row-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.inline { display: inline; }

/* ---------- 表单 ---------- */

.form { padding: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--text-2); }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; padding-top: 4px; }

input[type="text"], input[type="number"], input[type="password"],
select, textarea {
  width: 100%; min-height: 32px; padding: 5px 10px;
  color: var(--text-1); background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { padding: 8px 10px; line-height: 1.6; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--border-2); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input::placeholder, textarea::placeholder { color: var(--text-4); }

.mini-select {
  height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-ctl);
  background: var(--card); color: var(--text-1); font-size: 13px;
}
.inline-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 16px; }
.inline-form .field { min-width: 170px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.model-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px 16px; max-height: 260px; overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-card);
  background: var(--bg-soft);
}
.model-picker label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }

.step-group { display: inline-flex; align-items: center; gap: 4px; }
.step-btn {
  width: 24px; height: 24px; line-height: 1; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-ctl);
  background: var(--card); color: var(--text-2);
  cursor: pointer; font-size: 13px;
}
.step-btn:hover { background: var(--bg-hover); border-color: var(--border-2); }
.step-val { min-width: 28px; text-align: center; font-size: 13px; color: var(--text-2); }

/* ---------- 提示 ---------- */

.alert {
  padding: 10px 14px; border-radius: var(--radius-card);
  margin-bottom: 14px; font-size: 13px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-2);
}
.alert.ok { color: var(--success); background: var(--success-weak); border-color: transparent; }
.alert.err { color: var(--danger); background: var(--danger-weak); border-color: transparent; }

.token-box {
  padding: 14px 16px; border-radius: var(--radius-card);
  background: var(--primary-weak); border: 1px solid transparent;
  margin-bottom: 16px;
}
.token-label { color: var(--primary); font-size: 13px; margin-bottom: 8px; font-weight: 500; }
.token-value {
  display: block; padding: 10px 12px;
  background: var(--card); border: 1px dashed var(--primary);
  border-radius: var(--radius-ctl);
  font-size: 14px; word-break: break-all;
}

/* ---------- 统计卡 ---------- */

.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 16px;
  box-shadow: var(--shadow-1);
}
.stat-label { color: var(--text-3); font-size: 13px; margin-bottom: 6px; }
.stat-value {
  font-size: 24px; font-weight: 600; line-height: 1.3;
  font-variant-numeric: tabular-nums; letter-spacing: -0.3px;
}
.stat-sub { color: var(--text-3); font-size: 14px; font-weight: 400; }

/* ---------- 图表 ---------- */

.chart-scroll { overflow-x: auto; }
.chart-bars {
  display: flex; align-items: flex-end; gap: 3px;
  height: 156px; padding: 16px 16px 0;
  min-width: 660px;
}
.chart-col {
  flex: 1; min-width: 26px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  height: 100%;
}
.chart-bar {
  width: 100%; max-width: 20px; min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, var(--chart-a), var(--chart-b));
}
.chart-bar:hover { opacity: .85; }
.chart-label {
  color: var(--text-3); font-size: 10px; line-height: 1;
  margin-top: 6px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 分页 ---------- */

.pager {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px 16px; border-top: 1px solid var(--border);
}

/* ---------- 抽屉 ---------- */

.drawer-mask {
  position: fixed; inset: 0; background: var(--mask);
  display: none; justify-content: flex-end; z-index: 60;
}
.drawer-mask.open { display: flex; }
.drawer-panel {
  width: min(680px, 96vw); height: 100%;
  background: var(--card); display: flex; flex-direction: column;
  box-shadow: var(--shadow-drawer); animation: drawerIn .18s ease;
}
@keyframes drawerIn { from { transform: translateX(20px); opacity: .7; } to { transform: none; opacity: 1; } }
.drawer-head {
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-close {
  border: none; background: none; cursor: pointer;
  color: var(--text-3); font-size: 20px; line-height: 1;
  padding: 4px 8px; border-radius: var(--radius-ctl);
}
.drawer-close:hover { background: var(--bg-hover); color: var(--text-1); }
.drawer-body { flex: 1; overflow-y: auto; }
.drawer-body .page-head { margin-bottom: 12px; }
.drawer-body .form-actions {
  position: sticky; bottom: 0; background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px; margin: 8px -16px -16px; z-index: 2;
}
.drawer-loading { padding: 32px; text-align: center; color: var(--text-3); }
.drawer-alert { padding: 0 20px; }
.drawer-alert .alert { margin: 12px 0 0; }

/* ---------- 登录页 ---------- */

.login-body {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-2);
}
.brand-lg { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 18px; font-weight: 600; }
.brand-lg .logo { width: 34px; height: 34px; flex: 0 0 34px; font-size: 15px; }
.login-sub { text-align: center; color: var(--text-3); font-size: 13px; margin: 8px 0 24px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { height: 36px; }
.login-foot { margin-top: 20px; color: var(--text-3); font-size: 12px; text-align: center; }