/* ════════════════════════════════════════════════════════
   CFJ-LINK 管理后台 — 通用组件（依赖 tokens.css）
   卡片 / 按钮 / 输入 / 表格 / 徽章 / 统计卡 / 页头 / 抽屉 等。
   类名与既有页面（provider / database / customers / rbac）保持兼容。
   ════════════════════════════════════════════════════════ */

/* ── 页头（页面标题 + 图标 + 副标题） ── */
.page { display: block; }
.page-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: var(--sp-lg);
}
.page-head-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent);
}
.page-title { font-size: var(--fs-2xl); font-weight: var(--fw-bold); color: var(--text); letter-spacing: -.01em; }
.page-sub   { margin: 3px 0 0; font-size: var(--fs-md); color: var(--text-2); }

/* ── 卡片 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-md);
}
.card--error { border-color: var(--danger); border-left: 4px solid var(--danger); }
.card--empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 48px var(--sp-lg); }
.empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--bg-2); color: var(--muted);
}
.card-title { font-size: var(--fs-lg); font-weight: var(--fw-semi); color: var(--text); margin: 0; }
.card-sub   { font-size: var(--fs-sm); color: var(--text-2); margin: 4px 0 14px; line-height: var(--lh-snug); }
.card-sub.small { font-size: var(--fs-xs); color: var(--muted); }
.card-header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.card-title-group { display: inline-flex; align-items: center; gap: 9px; }
.card-title-icon  { display: inline-flex; color: var(--accent); }

/* ── 统计卡网格（Stripe 式） ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-md) var(--sp-md) 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
}
.stat-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: 10.5px; font-weight: var(--fw-semi);
}
.stat-badge--idle    { background: var(--bg-2); color: var(--muted); }
.stat-badge--neutral { background: var(--accent-soft); color: var(--accent-deep); }
.stat-badge--ok      { background: var(--safe-bg); color: var(--safe-deep); }
.stat-badge--warn    { background: var(--warn-bg); color: var(--warn-deep); }
.stat-badge--down    { background: var(--danger-bg); color: var(--danger-deep); }
.stat-value { font-size: var(--fs-3xl); font-weight: var(--fw-bold); color: var(--text); line-height: 1.05; letter-spacing: -.02em; }
.stat-label { margin-top: 6px; font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--text); }
.stat-hint  { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); }

/* ── 仪表盘两列（系统信息 + 快捷操作） ── */
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-md); }
@media (max-width: 768px) { .dash-cols { grid-template-columns: 1fr; } }

.spec-list { margin: 0; display: flex; flex-direction: column; }
.spec-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.spec-row:last-child { border-bottom: 0; }
.spec-key { font-size: var(--fs-sm); color: var(--text-2); margin: 0; }
.spec-val { margin: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); text-align: right; word-break: break-word; }

.quick-links { display: flex; flex-direction: column; gap: 8px; }
.quick-link {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: var(--fs-md); font-weight: var(--fw-medium);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.quick-link:hover { background: var(--accent-soft); border-color: var(--accent); text-decoration: none; transform: translateX(2px); }
.quick-link-icon { display: inline-flex; color: var(--accent); }
.quick-link-text { flex: 1; }
.quick-link-arrow { display: inline-flex; color: var(--muted); }
.quick-link:hover .quick-link-arrow { color: var(--accent); }

/* ── 空状态行（如「无待确认订单」） ── */
.empty-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 28px 0; color: var(--safe-deep); font-size: var(--fs-md); font-weight: var(--fw-medium);
}
.empty-row-icon { display: inline-flex; color: var(--safe); }

/* ── 仪表盘：订单状态徽章组 ── */
.muted-line { color: var(--muted); font-size: var(--fs-sm); padding: 18px 0; text-align: center; }
.status-badges { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.status-chip-label { color: var(--text-2); }
.status-chip-count { font-weight: var(--fw-bold); color: var(--text); }
.status-chip--ok    { border-color: var(--safe);   background: var(--safe-bg); }
.status-chip--ok    .status-chip-count { color: var(--safe-deep); }
.status-chip--warn  { border-color: var(--warn);   background: var(--warn-bg); }
.status-chip--warn  .status-chip-count { color: var(--warn-deep); }
.status-chip--down  { border-color: var(--danger); background: var(--danger-bg); }
.status-chip--down  .status-chip-count { color: var(--danger-deep); }
.status-chip--idle  { background: var(--bg-2); }

/* ── 仪表盘：近 7 日营收迷你柱状图 ── */
.spark-wrap { min-height: 120px; }
.spark-svg { width: 100%; }
.spark-svg svg { display: block; }
.spark-caption { margin-top: 6px; text-align: right; color: var(--muted); }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: var(--fs-md); font-weight: var(--fw-semi); cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform .05s, opacity var(--transition-fast);
  margin-right: 6px;
}
.btn:last-child { margin-right: 0; }
.btn:hover:not(:disabled) { background: var(--accent-deep); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--secondary { background: var(--surface); color: var(--accent); border-color: var(--border-strong); }
.btn--secondary:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.btn--ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: var(--danger-deep); }
.btn--small  { padding: 5px 11px; font-size: var(--fs-sm); }
.btn--icon .btn-ico { display: inline-flex; align-items: center; }

/* ── 输入 ── */
.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: var(--fs-md); font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}
.input.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.input-row { margin-bottom: 14px; }
.input-label { display: block; font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 6px; font-weight: var(--fw-medium); }
.textarea { font-family: var(--font-mono); font-size: var(--fs-sm); resize: vertical; }

/* ── 表格 ── */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg-2); font-weight: var(--fw-semi); color: var(--text-2); font-size: var(--fs-xs); letter-spacing: .3px; }
.table tbody tr:hover { background: var(--surface-2); }

/* ── Toast ── */
.toast-root { position: fixed; top: calc(var(--topbar-h) + 14px); right: 20px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: var(--radius); background: var(--text); color: #fff;
  font-size: var(--fs-sm); font-weight: var(--fw-medium); box-shadow: var(--shadow-lg);
  animation: toast-in .25s var(--ease-out); pointer-events: auto; max-width: 380px;
}
.toast--success { background: var(--safe-deep); }
.toast--error   { background: var(--danger-deep); }
.toast--warn    { background: var(--warn-deep); }
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── KV / 字段 ── */
.kv-grid { display: grid; grid-template-columns: 200px 1fr; gap: 10px 16px; font-size: var(--fs-sm); align-items: center; }
.kv-grid dt { color: var(--muted); }
.kv-grid dd { margin: 0; color: var(--text); word-break: break-all; }

/* ── 徽章 ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: var(--fw-semi); background: var(--bg-2); color: var(--text-2);
}
.badge--active { background: var(--accent); color: #fff; }
.badge--ok     { background: var(--safe-bg); color: var(--safe-deep); }
.badge--warn   { background: var(--warn-bg); color: var(--warn-deep); }
.badge--error  { background: var(--danger-bg); color: var(--danger-deep); }
.badge--info   { background: var(--info-bg); color: var(--info); }   /* KYC 人工审核（蓝） */
.small-pad     { padding: 1px 6px; font-size: 10px; margin-left: 4px; }

/* ════════════════════════════════════════════════════════
   供应商页
   ════════════════════════════════════════════════════════ */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-md); margin-top: 8px; }
.provider-card { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: var(--sp-md); background: var(--surface-2); transition: border-color var(--transition-fast), background var(--transition-fast); }
.provider-card--active { border-color: var(--accent); background: var(--accent-soft); }
.provider-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.provider-card-name { font-size: var(--fs-lg); font-weight: var(--fw-semi); color: var(--text); }
.provider-card-desc { font-size: var(--fs-sm); color: var(--text-2); margin: 0 0 14px; min-height: 36px; }

.cred-section { padding: var(--sp-md) 0; border-top: 1px dashed var(--border); }
.cred-section:first-of-type { border-top: 0; }
.cred-section-title { font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--text); margin: 0 0 12px; }
.cred-actions { margin-top: 8px; }
.cred-result { margin-top: 12px; }

/* 代理商管理页：行操作 / 详情操作 / 复制邀请码按钮 */
.agent-row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.agent-detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: var(--sp-md); }
.agent-copy-btn { margin-left: 8px; vertical-align: middle; }
.agent-edit { margin-top: var(--sp-md); border-top: 1px dashed var(--border); }

.switch-group { display: inline-flex; gap: 8px; }
.btn--toggle { background: var(--surface); color: var(--accent); border: 1px solid var(--border-strong); }
.btn--toggle.active { background: var(--accent); color: #fff; cursor: default; border-color: var(--accent); }
.btn--toggle:disabled { opacity: .6; }
.result-box { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 3px solid var(--border-strong); }
.result-box--ok    { background: var(--safe-bg); border-left-color: var(--safe); }
.result-box--error { background: var(--danger-bg); border-left-color: var(--danger); }
.result-msg { margin: 8px 0 4px; font-size: var(--fs-sm); color: var(--text); line-height: 1.5; }
.pre-block { background: #0F1320; color: #9DE7B8; padding: 12px; border-radius: var(--radius-sm); font-size: var(--fs-xs); max-height: 240px; overflow: auto; margin: 6px 0 0; font-family: var(--font-mono); }

/* ════════════════════════════════════════════════════════
   数据库浏览页
   ────────────────────────────────────────────────────────
   双视图设计：
     桌面（>860px）  = 左侧表清单 + 右侧宽表格（信息密度优先）
     手机（≤860px）  = 顶部表选择器 + 卡片列表（纵向阅读，零横向滚动）
   ════════════════════════════════════════════════════════ */
.db-layout { display: grid; grid-template-columns: 260px 1fr; gap: var(--sp-md); min-height: 70vh; align-items: start; }
.db-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; box-shadow: var(--shadow-sm); max-height: 78vh; overflow-y: auto; position: sticky; top: calc(var(--topbar-h) + var(--safe-top) + var(--sp-md)); }
.db-sidebar-title { margin: 0 0 8px; font-size: var(--fs-md); color: var(--text-2); }
.db-table-list { list-style: none; margin: 0; padding: 0; }
.db-table-item { padding: 8px 10px; cursor: pointer; border-radius: var(--radius-sm); margin-bottom: 2px; transition: background var(--transition-fast); }
.db-table-item:hover { background: var(--surface-2); }
.db-table-item.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.db-table-item.readonly .db-table-name { color: var(--muted); }
.db-table-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.db-table-row-count { margin-top: 2px; }

/* 备注行：说明文字靠左，行数角标靠右，不再拼成「7 行 · xxx」一句 */
.db-table-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 2px; color: var(--muted); }
.db-table-hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-table-count { flex-shrink: 0; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: 0 6px; line-height: 1.7; }

/* 恢复凭据明文：等宽、可选中、带边框区分，便于抄写 */
.recovery-creds { margin-top: 10px; padding: 12px; border: 1px dashed var(--accent); border-radius: var(--radius); background: var(--accent-soft); }
.recovery-line { margin: 6px 0; word-break: break-all; user-select: all; font-size: var(--fs-sm); color: var(--text); }

/* 移动端表选择器开关：桌面隐藏 */
.db-picker-toggle { display: none; }

/* min-width:0 关键：grid 轨道默认 min-width:auto 会被宽表撑破，导致整页横向溢出且
   .data-table-wrap 的 overflow-x 失效。设为 0 让轨道可收缩，宽表在 wrap 内部横向滚动。 */
.db-main { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-md); box-shadow: var(--shadow-sm); }
.db-panel { display: flex; flex-direction: column; gap: 12px; }

/* ── 工具栏：说明在左，操作在右；窄屏自动换行 ── */
.db-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.db-toolbar-head { min-width: 0; flex: 1 1 240px; }
.db-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.db-table-title { font-size: var(--fs-lg); font-weight: var(--fw-semi); color: var(--text); margin-right: 10px; }
.db-hint { margin-left: 8px; }

/* 筛选框：≥16px 防 iOS 聚焦自动放大 */
.db-search { flex: 1 1 160px; min-width: 140px; max-width: 260px; padding: 6px 11px; font-size: 16px; }
.db-filter-note { margin-bottom: 8px; color: var(--text-2); }

/* 视图切换分段控件 */
.db-view-toggle { display: inline-flex; padding: 2px; gap: 2px; background: var(--bg-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.db-view-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.db-view-btn:hover { color: var(--text); }
.db-view-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }

/* ── 表格视图：受限滚动视口，宽表横/纵向都在卡片内部滚动，配合 sticky 表头不溢出页面 ── */
.data-table-wrap { overflow: auto; max-height: 68vh; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th { position: sticky; top: 0; z-index: 1; background: var(--bg-2); padding: 9px 10px; text-align: left; font-weight: var(--fw-semi); color: var(--text-2); font-size: var(--fs-xs); border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; max-width: 320px; }
.data-table tbody tr:hover { background: var(--surface-2); }
.col-type { display: block; font-weight: 400; color: var(--muted); margin-top: 1px; }
.actions-col { white-space: nowrap; text-align: right; }
.encrypted-cell { color: var(--warn-deep); }

/* ── 卡片视图：手机上替代宽表格，字段纵向排列，无需左右滑动 ── */
.db-card-list { display: flex; flex-direction: column; gap: 10px; }
.db-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.db-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.db-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.db-card-title { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.db-card-name { font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--text); word-break: break-word; }
.db-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.db-card-actions .btn { margin-right: 0; }

/* 字段行：左标签右值，窄屏时标签在上、值在下，保证长值不被挤压 */
.db-card-body { padding: 4px 13px; display: flex; flex-direction: column; }
.db-field {
  display: grid; grid-template-columns: minmax(88px, 34%) 1fr; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border); align-items: baseline;
}
.db-field:last-child { border-bottom: 0; }
.db-field-k { font-size: var(--fs-xs); color: var(--muted); font-weight: var(--fw-medium); }
.db-field-v { font-size: var(--fs-sm); color: var(--text); min-width: 0; word-break: break-word; }

/* 折叠字段：默认收起，展开后显示 */
.db-field--more { display: none; }
.db-card.expanded .db-field--more { display: grid; }

.db-card-more {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  padding: 9px; border: 0; border-top: 1px solid var(--border); cursor: pointer;
  background: var(--surface-2); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.db-card-more:hover { background: var(--bg-2); color: var(--accent); }
.db-card-more .btn-ico { display: inline-flex; transition: transform var(--transition-fast); }
.db-card-more[aria-expanded="true"] .btn-ico { transform: rotate(180deg); }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.pager-info { text-align: center; }

/* ── 抽屉 ── */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(11, 22, 48, .45); z-index: var(--z-drawer); display: flex; justify-content: flex-end; animation: fade .15s; }
.drawer { width: min(560px, 100vw); background: var(--surface); height: 100vh; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; animation: slide .2s var(--ease-out); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.drawer-head h3 { margin: 0; font-size: var(--fs-lg); }
.drawer-close { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); flex-shrink: 0; padding: 4px; }
.drawer-body { padding: 16px 18px; flex: 1; }
/* 底部操作条常驻：手机上表单很长时不用滚到底才能保存 */
.drawer-foot {
  padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2);
  text-align: right; position: sticky; bottom: 0;
  padding-bottom: calc(12px + var(--safe-bottom));
}

/* ════════════════════════════════════════════════════════
   响应式 · 数据库页（≤1024px）
   2026-11-12：原先这里还有一个 ≤980px 的块设 .db-layout 为两列网格，
   但下一块（≤860px，现已并入 1024）紧接着把 .db-layout 改成 display:block
   —— display:block 之后 grid-template-columns 完全失效，那段是死规则，已删。
   ════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════
   响应式 · 窄屏（≤1024px）
   表清单收进可折叠选择器，数据区占满整宽。
   2026-11-12 由 ≤860px 并入 1024 档，与 js/pages/database.js 的
   NARROW_PX 同步（原先 860–1024 之间会出现「折叠选择器 + 表格视图」混合态）。
   ════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .db-picker-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; margin-bottom: 10px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius); box-shadow: var(--shadow-xs);
    color: var(--text); font-size: var(--fs-md); font-weight: var(--fw-semi);
    font-family: inherit; cursor: pointer; min-height: var(--tap);
    transition: border-color var(--transition-fast);
  }
  .db-picker-toggle:active { border-color: var(--accent); }
  .db-picker-toggle .btn-ico { display: inline-flex; color: var(--muted); flex-shrink: 0; }
  .db-picker-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 表清单：默认折叠，展开时显示 */
  .db-layout { display: block; }
  .db-sidebar {
    display: none; position: static; max-height: 52vh;
    margin-bottom: 10px; border-radius: var(--radius);
  }
  .db-layout.picker-open .db-sidebar { display: block; animation: db-drop .18s var(--ease-out); }
  @keyframes db-drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

  /* 表项加大点击区，满足 44px 最小触控目标 */
  .db-table-item { padding: 12px 12px; min-height: var(--tap); }
  .db-table-meta { line-height: 1.4; }

  .db-main { padding: 12px; border-radius: var(--radius); }
  .db-toolbar { gap: 10px; }
  .db-toolbar-head { flex: 1 1 100%; }
  .db-toolbar-actions { flex: 1 1 100%; }
  /* 筛选框与按钮同排铺满，按钮不缩到难点 */
  .db-search { flex: 1 1 120px; max-width: none; }
  .db-toolbar-actions .btn { flex-shrink: 0; }

  /* 表格视图在窄屏仍可横向滚动（用户主动选择时的兜底），
     但整页不溢出：滚动被限制在 wrap 内部。 */
  .data-table-wrap { max-height: 62vh; }
  .data-table td { max-width: 220px; }

  /* 卡片字段：窄屏改为标签在上、值在下，长值独占整行不被挤压 */
  .db-field { grid-template-columns: 1fr; gap: 3px; padding: 9px 0; }
  .db-card-body { padding: 2px 12px; }
  .db-card-head { padding: 11px 12px; }

  /* 抽屉改全屏：手机上半屏抽屉的表单几乎没法用 */
  .drawer { width: 100vw; }
  .drawer-body { padding: 14px 14px calc(14px + var(--safe-bottom)); }
  .drawer-foot { display: flex; gap: 10px; justify-content: space-between; }
  .drawer-foot .btn { flex: 1; margin-right: 0; min-height: var(--tap); }
  /* 表单控件 ≥16px 防 iOS 聚焦自动放大 */
  .drawer-field, .drawer .input, .drawer .textarea { font-size: 16px; }
}

/* ════════════════════════════════════════════════════════
   响应式 · 超窄屏（≤420px）
   ════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .db-toolbar-actions { gap: 6px; }
  .db-search { flex: 1 1 100%; }
  .db-card-actions .btn--small { padding: 7px 9px; }
  .pager { gap: 8px; }
  .pager .btn--small { padding: 7px 10px; }
}

/* ── 通用（原移动端规则） ── */
@media (max-width: 768px) {
  .kv-grid { grid-template-columns: 1fr; }
  .card { padding: var(--sp-md); }
}

/*══ WORKBENCH-START ══*/
/* 仪表盘工作台（B 批 · 2026-10-19）
   规则：① 只新增 .wb-* 类，不覆盖 .card/.stat-card/.status-chip/.quick-link 等既有组件；
         ② 需要微调既有组件在工作台里的表现时，一律用 `.wb-grid …` 作用域包住（只影响首页）；
         ③ 禁 !important；④ 不定义/改写 VI 令牌（颜色圆角字号一律 var(--…)，只有大数字的
         展示级字号用字面量，因为 tokens 里没有 56px 这一档 —— 属老板批准的"VI 先放宽"。 */
.wb-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--sp-md); align-items: stretch; }
.wb-grid > .card { margin-bottom: 0; display: flex; flex-direction: column; min-width: 0; }
/* SVG 带 viewBox 就有 640px 的【内在宽度】，网格/弹性子项默认 min-width:auto 会被它撑住
   → 430px 屏整页横向溢出（2026-10-19 真机截图实测）。必须显式允许收缩。 */
.wb-card { min-width: 0; }   /* 基类兜底：卡片哪天挪出 .wb-grid 也不会被图表撑破 */
.wb-grid .spark-wrap { min-width: 0; }
.wb-svg { display: block; width: 100%; max-width: 100%; }
.wb-col-4  { grid-column: span 4; }
.wb-col-6  { grid-column: span 6; }
.wb-col-8  { grid-column: span 8; }
.wb-col-12 { grid-column: span 12; }

.wb-stamp { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }
.wb-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.wb-card-right { display: inline-flex; align-items: center; gap: 8px; }
.wb-card-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; min-width: 0; }
.wb-section { font-size: var(--fs-xs); font-weight: var(--fw-semi); letter-spacing: .1em;
              color: var(--muted); text-transform: uppercase; }

.wb-card--hero { border-radius: var(--radius-xl);
                 background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 58%, var(--accent-soft) 100%);
                 box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .7); }
.wb-hero-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.wb-hero-delta { display: inline-flex; align-items: center; gap: 8px; }
.wb-hero-delta-note { font-size: var(--fs-xs); color: var(--muted); }
.wb-hero-unit { font-size: var(--fs-sm); color: var(--muted); }
.wb-hero-hint { font-size: var(--fs-sm); color: var(--text-2); }

.wb-figure { font-size: 24px; font-weight: var(--fw-bold); line-height: 1;
             letter-spacing: -.03em; color: var(--text); font-variant-numeric: tabular-nums; }
.wb-figure--xl { font-size: clamp(38px, 4.2vw, 56px); }
.wb-figure--lg { font-size: clamp(28px, 2.4vw, 36px); }
.wb-figure--md { font-size: 24px; }
.wb-figure--sm { font-size: 19px; }

.wb-metric { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--border); }
.wb-metric:first-child { border-top: 0; padding-top: 0; }
.wb-metric-label { font-size: var(--fs-sm); color: var(--muted); }
.wb-metric-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.wb-metric-hint { font-size: var(--fs-xs); color: var(--muted); }

.wb-pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px;
           border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: var(--fw-semi); }
.wb-pill--up   { background: var(--safe-bg);   color: var(--safe-deep); }
.wb-pill--down { background: var(--danger-bg); color: var(--danger-deep); }
.wb-pill--flat { background: var(--bg-2);      color: var(--muted); }
.wb-pill--new  { background: var(--accent-soft); color: var(--accent-deep); }
.wb-pill-arrow { display: inline-flex; align-items: center; }

.wb-empty { display: flex; flex-direction: column; align-items: center; gap: 8px;
            padding: 26px 12px; color: var(--muted); font-size: var(--fs-sm); }
.wb-empty-icon { display: inline-flex; align-items: center; justify-content: center;
                 width: 40px; height: 40px; border-radius: 50%; background: var(--bg-2); color: var(--muted); }

.wb-seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border);
          border-radius: var(--radius); background: var(--bg-2); }
.wb-seg-btn { height: 28px; padding: 0 13px; border: 0; background: transparent; cursor: pointer;
              border-radius: var(--radius-sm); color: var(--text-2);
              font-size: var(--fs-sm); font-weight: var(--fw-semi);
              transition: background var(--transition-fast), color var(--transition-fast); }
.wb-seg-btn.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

.wb-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.wb-area { stroke: none; }
.wb-axis { stroke: var(--border); stroke-width: 1; stroke-dasharray: 1 5; }
.wb-dot  { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.wb-bar  { fill: var(--accent-soft); stroke: var(--accent); stroke-width: .75; }
.wb-bar--now { fill: var(--accent); }
.wb-svg text.ax { font-size: 10.5px; fill: var(--muted); font-family: var(--font-mono); }
.wb-svg text.ay { font-size: 10px;   fill: var(--muted); font-family: var(--font-mono); }

.wb-grid .quick-links { flex-direction: row; flex-wrap: wrap; }
.wb-grid .quick-links > .quick-link { flex: 1 1 200px; }

/* 活动泳道（C 批 · 真实审计日志）：auto-fit 横排，宽屏几条一行、窄屏自动塌成一列。
   min(280px,100%) 的下限是【必要】的：minmax(280px,1fr) 在容器窄于 280px 时会硬撑出横向溢出，
   而 430px 屏减去页面与卡片内距后正好落到这个边界附近（同类事故见上方 SVG 内在宽度注释）。
   行内只排 actor_type / action / target_type / UTC 时刻，明细字段一概不来首页。 */
.wb-act-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 0 22px; }
.wb-act-row { display: flex; align-items: baseline; gap: 8px; min-width: 0;
              padding: 8px 0; border-top: 1px solid var(--border); }
.wb-act-row--snap::before { content: ""; flex: none; align-self: center; width: 5px; height: 5px;
                            border-radius: 50%; background: var(--accent); }
.wb-act-actor { flex: none; font-size: var(--fs-xs); color: var(--muted);
                text-transform: uppercase; letter-spacing: .06em; }
.wb-act-action { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); color: var(--text);
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-act-meta { flex: none; font-size: var(--fs-xs); color: var(--muted); }
.wb-act-time { flex: none; font-size: var(--fs-xs); color: var(--muted); }
.wb-act-count { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }
.wb-pill-text { line-height: 1; }
.wb-empty-text { text-align: center; }

@media (max-width: 1280px) {
  .wb-col-8 { grid-column: span 12; }
  .wb-col-4 { grid-column: span 6; }
}
@media (max-width: 768px) {
  .wb-grid { grid-template-columns: 1fr; gap: var(--sp-sm); }
  .wb-col-4, .wb-col-8, .wb-col-12 { grid-column: auto; }
  .wb-figure--xl { font-size: 34px; }
}
/* 减弱动效：工作台自己的过渡一律归零（既有的 WAAPI 总闸在 motion.js/css 里，不重复实现） */
@media (prefers-reduced-motion: reduce) {
  .wb-seg-btn { transition: none; }
  .wb-grid > .card { transition: none; }
}
/*══ WORKBENCH-END ══*/
/* ── SQUIRCLE 连续曲率圆角（2026-11-12）────────────────────────
   border-radius 画正圆弧：直线→圆弧接点曲率突变 = 「方中带圆」割裂感。
   corner-shape: squircle 画超椭圆（G2 连续），曲率平滑，同样 radius 更「鼓」，
   接近 iOS / Apple 硬件圆角。后台信息密度高，squircle 让密集卡片不显生硬。
   @supports 包裹：Chrome 139+ 支持，Safari / Firefox 未实现 → 自动降级为圆弧。
   排除 999px 胶囊与 50% 圆形（squircle 正圆会变方圆形）。
   :where() 零特异度：不覆盖任何已有 border-radius 声明。 */
@supports (corner-shape: squircle) {
  :where(
    .page-head-icon,
    .card,
    .stat-card,
    .stat-icon,
    .quick-link,
    .btn,
    .input,
    .textarea,
    .select,
    .toast,
    .provider-card,
    .result-box,
    .pre-block,
    .db-sidebar,
    .db-table-item,
    .db-table-count,
    .recovery-creds,
    .db-main,
    .db-view-toggle,
    .db-view-btn,
    .data-table-wrap,
    .db-card,
    .wb-card--hero,
    .wb-seg,
    .wb-seg-btn,
    .icon-btn,
    .nav-item,
    .onboard-banner,
    .offline-card,
    .offline-card button,
    .ops-order-row,
    .cust-kyc-banner,
    .db-group-toggle,
    .copyable,
    .diag-card,
    .data-table-wrap::-webkit-scrollbar-thumb,
    .drawer-body::-webkit-scrollbar-thumb
  ) {
    corner-shape: squircle;
  }
}
