/* CBA 全局样式：深色顶栏 + 浅色内容区（复用 dsh 原生组件视觉基调） */
:root {
  --brand: #1f6feb;
  --danger: #d1242f;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --muted: #646a73;
  --nav-bg: #101828;
  --nav-text: #98a2b3;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* 顶栏（内容区顶部，浅色；品牌移入左侧栏） */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 52px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

/* 登录/改密卡片 */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 28px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
}
.auth-card h1 { font-size: 20px; margin-bottom: 24px; text-align: center; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}
.field input:focus { border-color: var(--brand); }
.btn {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.error-box {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fdecec;
  color: var(--danger);
  border-radius: 6px;
  font-size: 13px;
  display: none;
}
.error-box.show { display: block; }

/* 页面容器 */
.page { padding: 24px; }

/* ===== 左侧栏布局（M5 多级菜单） ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--nav-bg);
}
.sidebar .brand {
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.side-nav { padding: 10px 0; flex: 1; }
.nav-group { margin-bottom: 4px; }
.nav-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  color: #c0c7d1;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.nav-group-head:hover { color: #fff; }
.nav-caret { font-size: 10px; color: #7a8494; }
.nav-items { display: flex; flex-direction: column; }
.nav-group.collapsed .nav-items { display: none; }
.sidebar .nav-item {
  display: block;
  padding: 8px 20px 8px 44px;
  color: var(--nav-text);
  text-decoration: none;
  font-size: 14px;
}
.sidebar .nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.sidebar .nav-item.active { color: #fff; background: var(--brand); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.userbox { display: flex; align-items: center; gap: 12px; }
.userbox .username { color: var(--text); font-size: 14px; font-weight: 500; }
.link-btn {
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.link-btn:hover { color: var(--brand); }

/* ===== 卡片与工具条 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h3 { font-size: 16px; }
.card-title { font-size: 15px; margin-bottom: 12px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
  min-width: 200px;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); }
.updated { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }

/* ===== KPI ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.kpi-value { font-size: 24px; font-weight: 600; }
.kpi-unit { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.kpi-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ===== 数据表格 ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.data-table th { color: var(--muted); font-weight: 500; background: #fafbfc; }
.data-table tbody tr:hover { background: #f7f9fc; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--brand); }
.data-table tr.clickable { cursor: pointer; }
.cell-link { color: var(--brand); text-decoration: none; }
.cell-link:hover { text-decoration: underline; }

/* ===== 配额进度条 ===== */
.quota { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.quota .bar { flex: 1; height: 6px; background: #eceff3; border-radius: 3px; overflow: hidden; }
.quota .fill { height: 100%; border-radius: 3px; }
.quota .fill.ok { background: #2ea043; }
.quota .fill.warn { background: #d29922; }
.quota .fill.danger { background: var(--danger); }
.quota-text { font-size: 12px; color: var(--muted); min-width: 34px; text-align: right; }
.quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 4px 0 8px;
}
.quota-cell .quota-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.quota-cell .quota { min-width: 0; }

/* ===== 状态徽章 ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; line-height: 18px; }
.badge.ok { background: #e6f4ea; color: #1a7f37; }
.badge.warn { background: #fff8e1; color: #9a6700; }
.badge.gray { background: #eef1f4; color: #57606a; }

/* ===== 分页 ===== */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; font-size: 13px; }

/* ===== 状态/空态框 ===== */
.state-box {
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.state-box.error { border-color: #f0c1c3; background: #fdecec; color: var(--danger); }
.state-box.warn { border-color: #f0dfa9; background: #fff8e1; color: #9a6700; }

/* ===== 财务管理（M11） ===== */
.cred-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cred-row input { flex: 1; min-width: 0; }
.check-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }

/* ===== 键值信息 ===== */
.kv { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.kv > div { display: flex; gap: 12px; }
.kv .muted { min-width: 80px; }

/* ===== Toast ===== */
#toast-box {
  position: fixed;
  top: 64px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast { padding: 10px 16px; border-radius: 8px; font-size: 13px; color: #fff; box-shadow: 0 4px 12px rgba(16, 24, 40, 0.12); }
.toast.success { background: #2ea043; }
.toast.error { background: var(--danger); }

/* ===== 小号按钮 ===== */
.btn-sm { width: auto; height: 32px; padding: 0 14px; font-size: 13px; }

/* ===== 危险操作（M3） ===== */
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b01f28; }
.btn-plain { background: #eef1f4; color: var(--text); }
.btn-plain:hover { background: #e2e6eb; }
.badge.danger { background: #fdecec; color: var(--danger); }
.ops-cell { display: flex; gap: 6px; }
.ops-cell .btn { height: 26px; padding: 0 10px; font-size: 12px; }

/* ===== 确认弹窗（M3） ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  overflow-y: auto;
  z-index: 900;
}
.modal {
  width: 440px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border-radius: 10px;
  padding: 20px 24px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.2);
  margin: auto;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.modal-body { font-size: 13px; color: var(--text); margin-bottom: 8px; line-height: 1.7; }
.modal-body input {
  width: 100%;
  height: 36px;
  margin-top: 12px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.modal-body input:focus { border-color: var(--brand); }
.modal-detail { margin-top: 6px; font-size: 12px; color: var(--text); }
.modal-detail.muted { color: var(--muted); }
.modal-hint { min-height: 16px; margin-top: 8px; font-size: 12px; color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal-actions .btn { width: auto; height: 36px; padding: 0 18px; font-size: 13px; }

/* ===== 筛选条（审计页，M3） ===== */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input[type="datetime-local"] {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--brand); }
.filter-bar label { font-size: 13px; color: var(--muted); }
/* M6 订单/资产筛选条：文本与数字输入、自定义时间区间 */
.filter-bar input[type="text"], .filter-bar input[type="number"] {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
  min-width: 200px;
}
.filter-bar input.w-sm { min-width: 96px; width: 110px; }
.filter-bar .range-custom { display: flex; align-items: center; gap: 8px; }
/* CSS display 会覆盖 [hidden]，需显式声明（自定义时间区间默认隐藏） */
.filter-bar .range-custom[hidden] { display: none; }
.filter-bar .check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.filter-bar .check input { min-width: 0; width: auto; height: auto; }
.num, td.num { text-align: right; }
.search-hint { margin-top: 8px; font-size: 13px; }
.candidate-box { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.block-actions { margin-top: 12px; align-items: center; }
.audit-error { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 文件浏览页（M4） ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 0 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.breadcrumb .crumb-link { color: var(--brand); text-decoration: none; cursor: pointer; }
.breadcrumb .crumb-link:hover { text-decoration: underline; }
.breadcrumb .crumb-sep { color: var(--muted); }
.breadcrumb .crumb-current { color: var(--text); font-weight: 500; }
.files-name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.files-type { min-width: 44px; }
.modal-wide { width: 720px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-top: 12px; }
.run-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.run-row .btn { height: 34px; padding: 0 16px; font-size: 13px; }
.shell-exit.danger { color: var(--danger); }
.preview-box {
  max-height: 420px;
  overflow: auto;
  margin: 8px 0 4px;
  padding: 12px;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== 产品管理（M5） ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; color: var(--muted); }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
  font-family: inherit;
  resize: vertical;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--brand); }
.form-field.form-full { grid-column: 1 / -1; }
/* CSS display 会覆盖 [hidden]，需显式声明（W7 R4：扣款 / 扣除表单「实际类型」仅类型为「其它」时显示） */
.form-field[hidden] { display: none; }
.form-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.form-section-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.gift-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr 80px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.gift-row select, .gift-row input {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
}
.gift-row select:focus, .gift-row input:focus { border-color: var(--brand); }
.gift-row .btn { height: 32px; padding: 0; font-size: 14px; }
.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  min-height: 36px;
}
.chip-input:focus-within { border-color: var(--brand); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #eef4ff;
  color: var(--brand);
  border-radius: 10px;
  font-size: 12px;
}
.chip button {
  border: none;
  background: none;
  color: var(--brand);
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}
.chip button:hover { color: var(--danger); }

/* ===== 部署管理（M7） ===== */
.badge.info { background: #e7f0ff; color: #1f6feb; }
.badge.orange { background: #fff1e5; color: #bc4c00; }
.deploy-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.deploy-steps { display: flex; flex-direction: column; gap: 8px; }
.deploy-step { border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.deploy-step > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
}
.deploy-step > summary::-webkit-details-marker { display: none; }
.deploy-step > summary .step-idx { color: var(--muted); min-width: 18px; }
.deploy-step > summary .step-name { font-weight: 500; }
.deploy-step > summary .step-caret { margin-left: auto; color: var(--muted); }
.deploy-step[open] > summary { border-bottom: 1px solid var(--border); }
.deploy-step.step-active > summary { background: #fff8e1; }
.deploy-step.step-failed > summary { background: #fdecec; }
.step-seg { padding: 10px 12px 14px; }
.step-seg-item + .step-seg-item { margin-top: 12px; }
.step-seg-item .seg-title { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.step-seg-item .preview-box { max-height: 260px; margin: 0; }
.stars { color: #f5a623; letter-spacing: 2px; }
.stars .off { color: #d0d7de; }
.conf-wrap { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.conf-bar { display: inline-block; width: 140px; height: 8px; background: #eef1f4; border-radius: 4px; overflow: hidden; }
.conf-bar > span { display: block; height: 100%; background: #1a7f37; }
.conf-bar.warn > span { background: #9a6700; }
.conf-bar.danger > span { background: var(--danger); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-cell { padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fafbfc; }
.stat-cell .stat-label { font-size: 12px; color: var(--muted); }
.stat-cell .stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.run-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.score-form { display: flex; flex-direction: column; gap: 10px; }
.score-stars { display: flex; gap: 6px; font-size: 26px; color: #d0d7de; }
.score-stars .star {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  line-height: 1;
}
.score-stars .star.on { color: #f5a623; }
.score-form textarea {
  width: 100%;
  min-height: 80px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: vertical;
}
.score-form textarea:focus { border-color: var(--brand); }

/* ===== 人工干预（M8） ===== */
.intervene-actions { margin-top: 4px; }
.check-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.modal-body .check-line input[type="checkbox"] {
  width: auto;
  height: auto;
  margin: 0;
  cursor: pointer;
}
#ov-services { margin-top: 8px; }
#ov-services .data-table td { white-space: normal; padding: 6px 8px; }
.modal-body #ov-services input,
.modal-body #ov-services select {
  width: 100%;
  height: 30px;
  margin: 0;
  padding: 0 8px;
  font-size: 12px;
}
.modal-body #ov-services select { cursor: pointer; }
.modal-body #ov-services .ov-del { width: auto; height: 30px; padding: 0 10px; font-size: 12px; }
#ov-add { margin-top: 10px; }
.modal-body .ov-text {
  display: block;
  width: 100%;
  min-height: 160px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
  outline: none;
  resize: vertical;
}
.modal-body .ov-text:focus { border-color: var(--brand); }
.ov-count { font-variant-numeric: tabular-nums; }

/* ===== 会员档位（M12 / W5） ===== */
.block-sub { margin: 12px 0 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.tier-note { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ===== 钱包：兑换码管理 + 客服二维码（M16 / W6） ===== */
.mono, td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.5px; }
/* 生成成功弹窗的全码一次性展示（等宽、可选中、可换行） */
.code-full {
  margin: 4px 0 10px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg-soft, rgba(0, 0, 0, 0.03));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  letter-spacing: 1px;
  word-break: break-all;
  user-select: all;
}
.qr-layout { display: flex; gap: 24px; align-items: flex-start; margin-top: 10px; flex-wrap: wrap; }
.qr-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 240px;
  height: 240px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.qr-preview img { width: 100%; height: 100%; object-fit: contain; }
.qr-meta { display: flex; flex-direction: column; gap: 10px; max-width: 460px; font-size: 12px; }

/* ===== 钱包扣款与积分扣除（M17 / W7，ui §18） ===== */
.warn-box {
  margin: 4px 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-left-width: 4px;
  border-radius: 8px;
  background: #fdecec;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.7;
}
.warn-box .warn-line { font-weight: 600; }
.warn-dynamic { margin-bottom: 10px; font-size: 12px; color: var(--danger); }
.card-subtitle { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.lots-block { margin-top: 10px; }
.lots-head { font-size: 13px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.lots-block .table { margin-bottom: 6px; }
.sub-table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.sub-table th, .sub-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.sub-table th { color: var(--muted); font-weight: 500; }
.wallet-detail-row > td { background: #fafbfc; }
