/* ============================================================
   锦书中控支付管理系统 - 企业级后台样式
   纯原生 CSS，无外部依赖，离线可用
   配色: 主色 #2a6df4 / 成功 #52c41a / 警告 #faad14 / 危险 #f5222d
   ============================================================ */

/* ── 基础重置 ─────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #262626;
  background: #f5f7fa;
  min-height: 100vh;
}
a { color: #2a6df4; text-decoration: none; }
a:hover { color: #1a5cd4; }
ul { list-style: none; }

/* ── 整体布局: 左侧边栏 + 主区 ─────────────── */
.app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 240px;
  background: #1a2332;
  color: #c8d0dc;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
  z-index: 100;
}
.sidebar-brand {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,.08);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand .brand-logo { font-size: 20px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav .nav-group {
  padding: 10px 20px 4px;
  font-size: 12px;
  color: #5d6a80;
  letter-spacing: 1px;
}
.sidebar-nav a.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #c8d0dc;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease;
  cursor: pointer;
}
.sidebar-nav a.nav-item .nav-ico { width: 20px; text-align: center; font-size: 16px; }
.sidebar-nav a.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.nav-item.active {
  background: rgba(42,109,244,.15);
  color: #fff;
  border-left-color: #2a6df4;
}
.sidebar-foot {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: #5d6a80;
}

/* 主区 */
.main {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  transition: margin-left .25s ease;
}

/* 顶栏 */
.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .toggle-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #8c8c8c;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  margin-right: 12px;
}
.topbar .toggle-btn:hover { background: #f5f7fa; color: #262626; }
.topbar-title { font-size: 16px; font-weight: 600; color: #262626; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-right .admin-name { color: #8c8c8c; font-size: 13px; }
.topbar-right .admin-name b { color: #262626; font-weight: 600; }

/* 内容区 */
.content { padding: 24px; flex: 1; }

/* 侧边栏遮罩(移动端) */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 90;
}
body.sidebar-open .sidebar-mask { display: block; }

/* 侧边栏折叠(桌面) */
body.sidebar-collapsed .sidebar { margin-left: -240px; }
body.sidebar-collapsed .main { margin-left: 0; }

/* ── 面板切换 ─────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; }

/* ── 卡片 ─────────────────────────────────── */
.card {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  padding: 20px;
  margin-bottom: 16px;
}
.card h3 { font-size: 15px; color: #262626; margin-bottom: 14px; font-weight: 600; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card .card-head h3 { margin-bottom: 0; }
.card .card-sub { color: #8c8c8c; font-size: 12px; font-weight: normal; margin-left: 8px; }

/* ── 统计卡片(4列网格) ─────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.stat-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-card .stat-ico {
  width: 48px; height: 48px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: #fff;
  flex-shrink: 0;
}
.stat-card .stat-num { font-size: 24px; font-weight: 700; color: #262626; line-height: 1.1; }
.stat-card .stat-label { font-size: 13px; color: #8c8c8c; margin-top: 2px; }
.ico-blue { background: #2a6df4; }
.ico-green { background: #52c41a; }
.ico-orange { background: #faad14; }
.ico-red { background: #f5222d; }

/* ── 表格 ─────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  border-bottom: 1px solid #e8e8e8;
  padding: 0 12px;
  text-align: left;
  white-space: nowrap;
}
.table th {
  background: #fafafa;
  font-weight: 600;
  color: #595959;
  height: 40px;
}
.table td { height: 48px; color: #262626; }
.table tbody tr:hover td { background: #f5f7fa; }
.table .empty-cell { text-align: center; color: #8c8c8c; padding: 24px; }
.table .mono, .mono { font-family: Consolas, Menlo, monospace; font-size: 12px; }

/* ── 按钮 ─────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  text-align: center;
  background: #fff;
  color: #262626;
  border: 1px solid #d9d9d9;
  transition: all .15s ease;
  line-height: 1.4;
}
.btn:hover { color: #2a6df4; border-color: #2a6df4; }
.btn-primary { background: #2a6df4; border-color: #2a6df4; color: #fff; }
.btn-primary:hover { background: #1a5cd4; border-color: #1a5cd4; color: #fff; }
.btn-danger { background: #f5222d; border-color: #f5222d; color: #fff; }
.btn-danger:hover { background: #cf1322; border-color: #cf1322; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; }

/* ── 状态徽章 ─────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.6;
}
.badge-success { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.badge-primary { background: #e6f0ff; color: #2a6df4; border: 1px solid #91caff; }
.badge-danger  { background: #fff1f0; color: #f5222d; border: 1px solid #ffa39e; }
.badge-warning { background: #fffbe6; color: #faad14; border: 1px solid #ffe58f; }

/* ── 表单 ─────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: #595959; margin-bottom: 6px; }
.form-group .form-tip { font-size: 12px; color: #8c8c8c; margin-top: 4px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 12px; }
.form-row label { font-size: 13px; color: #595959; display: block; margin-bottom: 4px; }
.form-control {
  padding: 7px 10px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  min-width: 140px;
  color: #262626;
  background: #fff;
  transition: border-color .15s ease;
}
.form-control:focus { outline: none; border-color: #2a6df4; }
input.form-control, select.form-control { height: 34px; }
.form-inline { display: inline-flex; gap: 4px; align-items: center; }
.form-inline .form-control { min-width: 0; }

/* ── 消息提示 ─────────────────────────────── */
.msg { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.msg.success { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.msg.error { background: #fff1f0; color: #f5222d; border: 1px solid #ffa39e; }
.msg.info { background: #e6f0ff; color: #2a6df4; border: 1px solid #91caff; }

/* ── 日志框 ───────────────────────────────── */
.log-box {
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: Consolas, Menlo, monospace;
  font-size: 12px;
  padding: 12px;
  border-radius: 6px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}
.log-box .l-ERROR { color: #f48771; }
.log-box .l-WARN { color: #e2c08d; }
.log-box .l-SUCCESS { color: #89d185; }
.log-box .l-STEP { color: #7bb2f0; }
.log-line { padding: 1px 0; }

/* ── 弹窗 ─────────────────────────────────── */
.modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
}
.modal-mask.open { display: block; }
.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 720px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  z-index: 210;
  overflow: hidden;
  flex-direction: column;
}
.modal.open { display: flex; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8e8e8;
}
.modal-head h3 { font-size: 15px; margin: 0; }
.modal-close {
  background: none; border: none; font-size: 20px;
  color: #8c8c8c; cursor: pointer; line-height: 1;
  padding: 4px 8px; border-radius: 4px;
}
.modal-close:hover { background: #f5f7fa; color: #262626; }
.modal-body { padding: 20px; overflow-y: auto; }

/* ── 登录页 ───────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a2332 0%, #2a6df4 100%);
  padding: 20px;
}
.login-wrap { width: 380px; max-width: 100%; }
.login-brand {
  text-align: center;
  color: #fff;
  margin-bottom: 24px;
}
.login-brand .lb-logo { font-size: 36px; }
.login-brand .lb-title { font-size: 20px; font-weight: 700; margin-top: 8px; }
.login-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  padding: 28px 28px 20px;
}
.login-card h2 { font-size: 16px; color: #262626; margin-bottom: 20px; text-align: center; }
.login-foot { text-align: center; color: #8c8c8c; font-size: 12px; margin-top: 16px; }
.login-foot a { color: #fff; }
.login-foot a:hover { text-decoration: underline; }

/* ── 其他 ─────────────────────────────────── */
.empty { color: #8c8c8c; text-align: center; padding: 24px; }
.back { margin-bottom: 12px; display: inline-block; font-size: 13px; color: #2a6df4; text-decoration: none; }
.back:hover { text-decoration: underline; }
.qr-img { width: 60px; height: 60px; object-fit: contain; border: 1px solid #e8e8e8; border-radius: 4px; background: #fff; }
.error-box { max-width: 320px; max-height: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: #8c8c8c; font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-right { text-align: right; }
.kv-table td:first-child { background: #fafafa; font-weight: 600; color: #595959; width: 140px; }

/* ── 近7天订单趋势（纯CSS柱状图）────────────── */
.chart-row { display: flex; gap: 24px; flex-wrap: wrap; }
.chart-main { flex: 1 1 480px; min-width: 320px; }
.chart-side { flex: 0 0 260px; }
.chart-side h4 { font-size: 13px; color: #595959; margin-bottom: 12px; }
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding: 8px 4px 0; border-bottom: 1px solid #e8e8e8; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart-col-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.chart-bar { width: 12px; border-radius: 3px 3px 0 0; transition: opacity .15s ease; }
.chart-col:hover .chart-bar { opacity: .85; }
.bar-total { background: #8c8c8c; }
.bar-success { background: #2a6df4; }
.chart-label { font-size: 11px; color: #8c8c8c; margin-top: 6px; }
.chart-num { font-size: 12px; color: #595959; margin-top: 2px; }
.chart-legend { display: flex; gap: 20px; margin-top: 10px; font-size: 12px; color: #595959; }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chan-list { margin-top: 4px; }
.chan-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.chan-name { width: 56px; font-size: 13px; color: #595959; flex: none; }
.chan-bar { flex: 1; height: 12px; background: #f0f2f5; border-radius: 6px; overflow: hidden; }
.chan-fill { height: 100%; background: #2a6df4; border-radius: 6px; }
.chan-num { width: 56px; text-align: right; font-size: 13px; color: #262626; flex: none; }

/* ── 任务搜索/分页 ─────────────────────────── */
.task-filter { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.task-filter .form-control { width: 200px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #f0f0f0; }
.pager-info { font-size: 13px; color: #8c8c8c; }
.btn.disabled { opacity: .5; pointer-events: none; }

/* ── 选项卡（节点详情）────────────────────── */
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid #e8e8e8; margin-bottom: 16px; }
.tab-btn { padding: 8px 16px; font-size: 13px; color: #595959; background: transparent; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; }
.tab-btn:hover { color: #2a6df4; }
.tab-btn.active { color: #2a6df4; border-bottom-color: #2a6df4; font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.stat-mini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 8px; }
.stat-mini { background: #fafafa; border-radius: 6px; padding: 12px 14px; }
.stat-mini .sm-num { font-size: 20px; font-weight: 700; color: #262626; }
.stat-mini .sm-label { font-size: 12px; color: #8c8c8c; margin-top: 2px; }

/* ── 日志来源标记 ─────────────────────────── */
.log-src { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; margin-right: 4px; background: #f0f2f5; color: #595959; }
.log-src.admin { background: #e6f0ff; color: #2a6df4; }

/* ── 系统接口面板 ─────────────────────────── */
.api-docs { display: flex; flex-direction: column; gap: 14px; }
.api-card { background: #fff; border: 1px solid #e8e8e8; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.04); overflow: hidden; }
.api-card[open] { border-color: #d6e4ff; }
.api-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; cursor: pointer; list-style: none; user-select: none; background: #fafbfc; transition: background .15s; }
.api-head:hover { background: #f0f5ff; }
.api-head::-webkit-details-marker { display: none; }
.api-index { flex: none; width: 22px; height: 22px; border-radius: 50%; background: #2a6df4; color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.api-name { flex: 1; font-size: 14px; font-weight: 600; color: #262626; }
.api-method { flex: none; font-size: 11px; font-weight: 600; color: #fff; background: #2a6df4; border-radius: 4px; padding: 2px 8px; letter-spacing: .5px; }
.api-body { padding: 14px 16px 18px; border-top: 1px solid #f0f0f0; display: flex; flex-direction: column; gap: 16px; }
.api-desc { font-size: 13px; color: #595959; line-height: 1.7; margin: 0; }
.api-block { display: flex; flex-direction: column; gap: 8px; }
.api-block h4 { font-size: 13px; font-weight: 600; color: #262626; margin: 0; display: flex; align-items: center; gap: 8px; }
.api-caller { font-size: 12px; color: #8c8c8c; margin: 0; }
.api-url { font-family: Consolas, Menlo, monospace; font-size: 12px; color: #2a6df4; background: #f0f5ff; border-radius: 4px; padding: 4px 8px; word-break: break-all; }
.api-table { font-size: 12px; }
.api-table th { white-space: nowrap; }
.api-table td, .api-table th { padding: 8px 10px; height: auto; white-space: normal; }
.api-table-sm td { height: auto; padding: 6px 10px; }
.api-pre { margin: 0; background: #1e1e2e; color: #e8e8f0; border-radius: 6px; padding: 12px 14px; overflow-x: auto; font-size: 12px; line-height: 1.65; }
.api-pre code { font-family: Consolas, Menlo, monospace; color: inherit; background: none; padding: 0; }
.api-copy { margin-left: auto; }
.api-notes { margin: 0; padding-left: 18px; font-size: 12px; color: #595959; line-height: 1.8; }
.api-notes li { margin-bottom: 2px; }

/* ── 任务批量删除栏 ───────────────────────── */
.batch-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #f0f0f0; }
.batch-bar #selectedCount { font-size: 13px; color: #8c8c8c; }
.batch-bar .btn { flex: none; }
th input[type="checkbox"], td input[type="checkbox"] { width: 15px; height: 15px; vertical-align: middle; cursor: pointer; }
th input[type="checkbox"] { margin-right: 4px; }
.task-check { vertical-align: middle; }

/* ── 顶栏自动刷新控件 ─────────────────────── */
.auto-refresh-control { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #595959; }
.auto-refresh-control .refresh-label { display: flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.auto-refresh-control .form-control-sm { width: auto; padding: 2px 6px; font-size: 12px; height: auto; }
.refresh-countdown { font-family: Consolas, monospace; font-size: 12px; color: #2a6df4; min-width: 32px; text-align: center; }

/* ── 响应式 ───────────────────────────────── */
@media (max-width: 992px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { margin-left: -240px; }
  .main { margin-left: 0; }
  body.sidebar-open .sidebar { margin-left: 0; }
  body.sidebar-collapsed .sidebar { margin-left: -240px; }
  body.sidebar-collapsed .main { margin-left: 0; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-title { font-size: 14px; }
  .topbar-right .admin-name { display: none; }
  .modal { width: calc(100vw - 24px); }
}
