:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --sidebar: #111827;
  --sidebar-hover: #1f2937;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: #f5f7fa;
  color: var(--text);
  font-size: 14px;
}

.layout { display: flex; height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--sidebar);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-logo {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  letter-spacing: .5px;
}

.brand-title { font-size: 14px; font-weight: 600; }
.brand-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.menu { flex: 1; overflow-y: auto; padding: 12px 0; }

.menu-group {
  padding: 14px 18px 6px;
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .6px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: #d1d5db;
  cursor: pointer;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}

.menu-item:hover { background: var(--sidebar-hover); color: #fff; }

.menu-item.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--primary);
  font-weight: 600;
}

.mi-icon { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.db-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.06);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 12px;
  color: #d1d5db;
  cursor: pointer;
}

.db-badge:hover { background: rgba(255,255,255,.1); }

.db-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  flex: 0 0 8px;
}
.db-badge.error .dot { background: var(--danger); }

/* ---------- 主区域 ---------- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  flex: 0 0 58px;
}

.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* 当前数据库环境标签: 测试库(蓝) / 正式库(橙红, 醒目提示) */
.env-tag {
  font-size: 11.5px;
  color: #0369a1;
  background: #e0f2fe;
  padding: 4px 9px;
  border-radius: 20px;
  font-weight: 600;
}
.env-tag.prod {
  color: #b91c1c;
  background: #fee2e2;
}

.content { flex: 1; overflow-y: auto; padding: 20px 22px; }

.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- 通用组件 ---------- */
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.card-title {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- 统计卡片 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }

.stat {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  border-left: 3px solid var(--primary);
}
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat.c-green { border-left-color: var(--success); }
.stat.c-orange { border-left-color: var(--warn); }
.stat.c-blue { border-left-color: #0ea5e9; }

/* ---------- 表格 ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.input {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 13px;
  outline: none;
  min-width: 220px;
}
.input:focus { border-color: var(--primary); }

.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }

th {
  background: #f8fafc;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }

td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr:hover { background: #f8fafc; }

.empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- 状态标签 ---------- */
.badge {
  display: inline-block;
  padding: 2.5px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ---------- 配置页 ---------- */
.env-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }

.env-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.env-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.env-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.env-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.env-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.env-desc { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }

.env-rows { font-size: 12.5px; margin-bottom: 16px; }
.env-row { display: flex; padding: 5px 0; border-bottom: 1px dashed #f1f5f9; }
.env-row:last-child { border-bottom: none; }
.env-row .k { width: 68px; color: var(--muted); flex: 0 0 68px; }
.env-row .v { font-family: Consolas, Menlo, monospace; color: #334155; word-break: break-all; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: #1f2937;
  color: #fff;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---------- 日志表 ---------- */
.log-table td { white-space: normal; font-size: 12.5px; }
.log-table .msg { font-family: Consolas, Menlo, monospace; }

/* ---------- 弹窗 ---------- */
.modal-mask, .modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: #fff;
  border-radius: 12px;
  width: 520px; max-width: 92vw;
  max-height: 88vh; overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600;
}
.modal-close {
  border: none; background: none; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--muted);
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.form-section-title {
  font-size: 12px; font-weight: 600; color: var(--primary);
  letter-spacing: .3px; margin: 18px 0 10px; padding-left: 9px;
  border-left: 3px solid var(--primary);
}
.form-section-title:first-child { margin-top: 0; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--border); background: #fafbfc;
}

.form-row {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px;
}
.form-row:last-child { margin-bottom: 0; }
.form-row > label {
  width: 120px; flex: 0 0 120px; color: var(--text); font-size: 13px;
  text-align: right; line-height: 1.3; font-weight: 500;
}
.form-row > div, .form-row > select, .form-row > input { flex: 1; font-size: 13px; }
.form-row .input {
  min-width: 0; width: 100%; height: 38px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-row .input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-row .input[readonly] { background: #f8fafc; color: var(--muted); cursor: not-allowed; }

.btn-log { background: #f1f5f9; color: #334155; border: 1px solid var(--border); }
.btn-log:hover { background: #e2e8f0; }

.btn-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; }

/* 提现审核-通过按钮 */
.btn-approve { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.btn-approve:hover { background: #bbf7d0; }

/* 限电活动详情 */
.limit-detail-box { display: flex; flex-direction: column; gap: 14px; padding: 8px 4px; }
.kv-table { border-collapse: collapse; width: 100%; max-width: 520px; }
.kv-table td { border: 1px solid #e2e8f0; padding: 8px 12px; font-size: 13.5px; }
.kv-table td:first-child { width: 130px; color: #64748b; background: #f8fafc; font-weight: 600; }

.user-tag { font-size: 13px; color: #475569; background: #f1f5f9; padding: 4px 10px; border-radius: 20px; }

/* ---------- 登录遮罩 ---------- */
.login-mask {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.login-box {
  width: 340px; max-width: 90vw;
  background: #fff; border-radius: 14px;
  padding: 34px 30px; box-shadow: 0 24px 60px rgba(0,0,0,.35);
  text-align: center;
}
.login-brand {
  width: 54px; height: 54px; border-radius: 12px; margin: 0 auto 14px;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 20px;
  display: flex; align-items: center; justify-content: center; letter-spacing: 1px;
}
.login-title { font-size: 18px; font-weight: 700; color: #0f172a; }
.login-sub { font-size: 13px; color: var(--muted); margin: 6px 0 22px; }
.login-input { width: 100%; min-width: 0; margin-bottom: 12px; }
.login-btn { width: 100%; padding: 10px; font-size: 14px; }
.login-msg { font-size: 12.5px; color: #dc2626; margin-top: 12px; min-height: 16px; }

/* ---------- 角色菜单配置 ---------- */
.menu-cfg-group { margin-bottom: 16px; }
.menu-cfg-group-title { font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 8px; }
.menu-cfg-item {
  display: inline-flex; align-items: center; gap: 5px;
  margin: 0 14px 8px 0; font-size: 13px; color: #475569; cursor: pointer;
}

