/* =============================================================================
 * ds-spec.css —— 把 web-tms 现有界面「对齐」到《蓝桥运营平台 · 产品设计规范 v1.0》
 * -----------------------------------------------------------------------------
 * 做法：不重写 20 个页面（它们只依赖 app.css 的类名），而是在 app.css 之后加载
 *       本覆盖层，把所有视觉量改为引用 design-system/tokens.css 的 --ds-* 令牌。
 * 主题：<html data-theme="dark|light">（默认 dark，跟随系统偏好）
 * 密度：<html data-density="standard|compact">
 * ========================================================================== */

/* ---------- 0. 旧变量 → 令牌 ---------- */
:root {
  --brand: var(--ds-accent);
  --brand-dark: var(--ds-accent-active);
  --sidebar: var(--ds-surface-0);
  --sidebar-2: var(--ds-surface-0);
  --bg: var(--ds-surface-1);
  --card: var(--ds-surface-2);
  --line: var(--ds-border);
  --text: var(--ds-text-primary);
  --muted: var(--ds-text-secondary);
  --green: var(--ds-success);
  --red: var(--ds-danger);
  --orange: var(--ds-warning);
  --cyan: var(--ds-info);
  --purple: var(--ds-chart-6, var(--ds-accent-text));
  --radius: var(--ds-radius-md);
  --shadow: none;
}

html { background: var(--ds-surface-1); }
body {
  background: var(--ds-surface-1);
  color: var(--ds-text-primary);
  font-size: var(--ds-fs-body);
  line-height: 1.5;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

/* 数字必须等宽（规范 2.5 / 7.1） */
.ds-num, .num, .stat-value, .bar-value, .kv .v, .table td.ta-right,
.money, td[data-num] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.table td, .table th { font-variant-numeric: tabular-nums; }

/* 滚动条（深色下不刺眼） */
* { scrollbar-width: thin; scrollbar-color: var(--ds-border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--ds-border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* 焦点环（规范 5.1 / 8：禁止无替代的 outline:none） */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-focus);
  border-color: var(--ds-accent);
  border-radius: var(--ds-radius-sm);
}

/* ---------- 1. 应用外壳（规范 3.1） ---------- */
#app { background: var(--ds-surface-1); }
.sidebar {
  width: var(--ds-sidenav-w); flex: 0 0 var(--ds-sidenav-w);
  background: var(--ds-surface-0);
  border-right: 1px solid var(--ds-border);
  color: var(--ds-text-secondary);
}
.brand { padding: var(--ds-space-5) var(--ds-space-6); gap: var(--ds-space-4); border-bottom: 1px solid var(--ds-border-subtle); }
.brand .logo, .login-brand .logo {
  width: 28px; height: 28px; border-radius: var(--ds-radius-md);
  background: var(--ds-accent); color: #fff; font-size: 14px; font-weight: 600;
}
.brand-txt strong { font-size: var(--ds-fs-widget); color: var(--ds-text-primary); letter-spacing: 0; }
.brand-txt span { font-size: var(--ds-fs-micro); color: var(--ds-text-muted); }
.nav { padding: var(--ds-space-2) var(--ds-space-2) var(--ds-space-8); }
.nav-group { color: var(--ds-text-muted); font-size: var(--ds-fs-micro); letter-spacing: .5px; padding: var(--ds-space-5) var(--ds-space-5) var(--ds-space-2); }
.nav-item {
  height: 32px; padding: 0 var(--ds-space-4); margin: 0; border-radius: var(--ds-radius-sm);
  color: var(--ds-text-secondary); font-size: var(--ds-fs-body); gap: var(--ds-space-4);
}
.nav-item:hover { background: var(--ds-surface-2); color: var(--ds-text-primary); }
.nav-item.active {
  background: var(--ds-accent-subtle); color: var(--ds-text-primary);
  box-shadow: inset 2px 0 0 var(--ds-accent); font-weight: 600;
}
.nav-icon { width: 14px; opacity: .9; }

.topbar {
  height: var(--ds-topbar-h); background: var(--ds-surface-0);
  border-bottom: 1px solid var(--ds-border); padding: 0 var(--ds-space-6);
}
.crumbs { font-size: var(--ds-fs-section); font-weight: 600; color: var(--ds-text-primary); line-height: 1.2; }
.top-link { color: var(--ds-text-secondary); font-size: var(--ds-fs-dense); padding: var(--ds-space-1) var(--ds-space-4); border-radius: var(--ds-radius-sm); }
.top-link:hover { background: var(--ds-surface-2); color: var(--ds-text-primary); }
.backend { font-size: var(--ds-fs-dense); padding: 2px var(--ds-space-4); border-radius: var(--ds-radius-pill); }
.backend-live { background: var(--ds-success-subtle); color: var(--ds-success-text); }
.backend-live i { background: var(--ds-success); box-shadow: none; }
.backend-offline { background: var(--ds-warning-subtle); color: var(--ds-warning-text); }
.backend-offline i { background: var(--ds-warning); }
.user { border-left: 1px solid var(--ds-border); padding-left: var(--ds-space-5); gap: var(--ds-space-4); }
.avatar { width: 24px; height: 24px; background: var(--ds-accent-subtle); color: var(--ds-accent-text); font-size: var(--ds-fs-dense); }
.user-meta strong { font-size: var(--ds-fs-body); color: var(--ds-text-primary); }
.user-meta span { font-size: var(--ds-fs-micro); color: var(--ds-text-muted); }
.content { padding: var(--ds-space-8) var(--ds-space-8) var(--ds-space-10); max-width: 1680px; }

/* ---------- 2. Widget / 卡片（规范 1.1、2.6：静态卡片不加阴影，靠 1px 边框） ---------- */
.card {
  background: var(--ds-surface-2); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md); box-shadow: none; margin-bottom: var(--ds-space-8);
}
.card-hd { padding: var(--ds-space-5) var(--ds-space-6); border-bottom: 1px solid var(--ds-border); }
.card-hd h3 { font-size: var(--ds-fs-widget); font-weight: 600; color: var(--ds-text-primary); }
.card-bd { padding: var(--ds-space-6); }
.card-extra { gap: var(--ds-space-4); }
.divider { background: var(--ds-border); }
.hint { color: var(--ds-text-muted); font-size: var(--ds-fs-dense); }

/* ---------- 3. KPI 卡（规范 4.7） ---------- */
.stats { gap: var(--ds-space-5); margin-bottom: var(--ds-space-8); }
.stat {
  background: var(--ds-surface-3); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md); box-shadow: none; padding: var(--ds-space-6);
}
.stat-label { color: var(--ds-text-secondary); font-size: var(--ds-fs-dense); }
.stat-value { font-size: 26px; font-weight: 600; line-height: 1.2; letter-spacing: -.3px; margin: var(--ds-space-2) 0; }
.stat-sub { color: var(--ds-text-muted); font-size: var(--ds-fs-dense); }
.stat-blue .stat-value, .stat-green .stat-value, .stat-orange .stat-value, .stat-red .stat-value { color: var(--ds-text-primary); }
.stat-blue { border-top: 2px solid var(--ds-accent); }
.stat-green { border-top: 2px solid var(--ds-success); }
.stat-orange { border-top: 2px solid var(--ds-warning); }
.stat-red { border-top: 2px solid var(--ds-danger); }

/* ---------- 4. 按钮（规范 4.1：默认 28，sm 24，圆角 3，无位移） ---------- */
.btn {
  height: var(--ds-control-h); padding: 0 var(--ds-space-5);
  border-radius: var(--ds-radius-sm); border: 1px solid transparent;
  font-size: var(--ds-fs-body); font-weight: 600; line-height: 1;
  transition: background-color 120ms cubic-bezier(.4, 0, .2, 1), border-color 120ms;
}
.btn-sm { height: var(--ds-control-h-sm); padding: 0 var(--ds-space-4); font-size: var(--ds-fs-dense); }
.btn:active { transform: none; }
.btn-primary { background: var(--ds-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ds-accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--ds-accent-active); }
.btn-default { background: var(--ds-surface-3); border-color: var(--ds-border-strong); color: var(--ds-text-primary); }
.btn-default:hover:not(:disabled) { background: var(--ds-surface-4); color: var(--ds-text-primary); border-color: var(--ds-border-strong); }
.btn-danger { background: var(--ds-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--ds-danger-hover); }
.btn-success { background: var(--ds-success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--ds-success-hover); }
.btn-link { background: transparent; border: none; color: var(--ds-accent-text); height: auto; padding: 2px var(--ds-space-2); font-weight: 400; }
.btn-link:hover { color: var(--ds-accent-hover); text-decoration: underline; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 5. 输入类（规范 4.2：28px、surface-4 底、圆角 3、聚焦 2px 环） ---------- */
.input, select.input, textarea.input, .field input, .field select, .field textarea {
  height: var(--ds-control-h); padding: 0 10px;
  background: var(--ds-surface-4); color: var(--ds-text-primary);
  border: 1px solid var(--ds-border-strong); border-radius: var(--ds-radius-sm);
  font-size: var(--ds-fs-body);
}
textarea.input, textarea { height: auto; min-height: 72px; padding: var(--ds-space-4) 10px; line-height: 1.5; }
select.input { padding-right: var(--ds-space-5); }
.input::placeholder { color: var(--ds-text-muted); }
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--ds-accent);
  background: var(--ds-surface-4); box-shadow: 0 0 0 2px var(--ds-accent-ring);
}
.input:disabled, .input[readonly] { opacity: .55; cursor: not-allowed; }
.field-label, .filter-label { color: var(--ds-text-secondary); font-size: var(--ds-fs-dense); }
.field-hint { color: var(--ds-text-muted); font-size: var(--ds-fs-micro); }
.form-item { gap: var(--ds-space-2); }
.form-grid { gap: var(--ds-space-5) var(--ds-space-6); }
.form-actions { gap: var(--ds-space-4); }
.form-err { color: var(--ds-danger-text); font-size: var(--ds-fs-dense); }
.login-card { background: var(--ds-surface-2); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-3); }
.login-form input { background: var(--ds-surface-4); border-color: var(--ds-border-strong); color: var(--ds-text-primary); height: var(--ds-control-h-lg); border-radius: var(--ds-radius-sm); }
.login-form label, .login-brand p, .login-hint { color: var(--ds-text-secondary); }
.login-err { color: var(--ds-danger-text); }
.login-wrap { background: var(--ds-surface-1); }
.login-brand h1 { color: var(--ds-text-primary); font-size: var(--ds-fs-section); }

/* ---------- 6. FilterBar（规范 4.8） ---------- */
.filters {
  background: var(--ds-surface-1); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-sm); padding: var(--ds-space-4) var(--ds-space-5);
  gap: var(--ds-space-5); margin-bottom: var(--ds-space-5);
}
.filter-item { gap: var(--ds-space-1); }
.filter-actions { gap: var(--ds-space-4); }
.toolbar { gap: var(--ds-space-4); margin-bottom: var(--ds-space-5); }

/* ---------- 7. DataGrid（规范 4.5：本系统第一组件） ---------- */
.table-wrap {
  background: var(--ds-surface-2); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md); box-shadow: none; overflow: auto;
}
.table { font-size: var(--ds-fs-dense); border-collapse: collapse; }
.table th {
  height: var(--ds-row-h-header); padding: 0 var(--ds-space-4);
  background: var(--ds-surface-2); color: var(--ds-text-secondary);
  font-size: var(--ds-fs-dense); font-weight: 600; line-height: var(--ds-row-h-header);
  border-bottom: 1px solid var(--ds-border); position: sticky; top: 0; z-index: 2;
}
.table td {
  height: var(--ds-row-h); padding: 0 var(--ds-space-4);
  color: var(--ds-text-primary); font-size: var(--ds-fs-dense);
  border-bottom: 1px solid var(--ds-border-subtle); line-height: var(--ds-row-h);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--ds-surface-3); }
.table tbody tr.row-click { cursor: pointer; }
.table tbody tr.selected, .table tbody tr:has(input:checked) {
  background: var(--ds-accent-subtle); box-shadow: inset 2px 0 0 var(--ds-accent);
}
.table.compact th, .table.compact td { padding: 0 var(--ds-space-3); }
.table .ta-right, .table td.ta-right { text-align: right; }
.table .ta-center { text-align: center; }
table caption, .table caption { color: var(--ds-text-muted); font-size: var(--ds-fs-dense); }
.pager {
  background: var(--ds-surface-2); color: var(--ds-text-secondary);
  font-size: var(--ds-fs-dense); padding: var(--ds-space-3) var(--ds-space-5);
  border-top: 1px solid var(--ds-border);
}
.pager-btns { gap: var(--ds-space-2); }
.empty { color: var(--ds-text-muted); font-size: var(--ds-fs-body); padding: var(--ds-space-9) 0; }
.loading { color: var(--ds-text-secondary); }
.spinner { border-color: var(--ds-border-strong); border-top-color: var(--ds-accent); }

/* ---------- 8. Tag / 状态（规范 4.3：20px、12% tint、圆角 2、色+文字） ---------- */
.tag {
  height: 20px; line-height: 18px; padding: 0 var(--ds-space-3);
  border-radius: var(--ds-radius-xs); font-size: var(--ds-fs-dense); font-weight: 500;
  border: 1px solid transparent; display: inline-block; white-space: nowrap;
}
.tag-gray { background: var(--ds-surface-4); color: var(--ds-text-secondary); border-color: var(--ds-border); }
.tag-blue { background: var(--ds-accent-subtle); color: var(--ds-accent-text); border-color: var(--ds-accent-border); }
.tag-cyan { background: var(--ds-info-subtle); color: var(--ds-info-text); border-color: var(--ds-accent-border); }
.tag-green { background: var(--ds-success-subtle); color: var(--ds-success-text); border-color: rgba(61,204,145,.35); }
.tag-orange { background: var(--ds-warning-subtle); color: var(--ds-warning-text); border-color: rgba(251,179,96,.35); }
.tag-red { background: var(--ds-danger-subtle); color: var(--ds-danger-text); border-color: rgba(250,153,156,.35); }
.tag-purple { background: var(--ds-accent-subtle); color: var(--ds-accent-text); border-color: var(--ds-accent-border); }
.chip { background: var(--ds-surface-4); color: var(--ds-text-secondary); border-radius: var(--ds-radius-xs); font-size: var(--ds-fs-dense); }
.chip-on { background: var(--ds-accent-subtle); color: var(--ds-accent-text); }

/* ---------- 9. Tabs / 分页导航（规范 4.6） ---------- */
.tabs { border-bottom: 1px solid var(--ds-border); gap: 0; margin-bottom: var(--ds-space-5); }
.tab { height: 36px; padding: 0 var(--ds-space-6); color: var(--ds-text-secondary); font-size: var(--ds-fs-body); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--ds-text-primary); background: var(--ds-surface-2); }
.tab.active { color: var(--ds-text-primary); border-bottom-color: var(--ds-accent); font-weight: 600; background: transparent; }

/* ---------- 10. 弹层（规范 4.4：Dialog surface-2 圆角 6 + shadow-3） ---------- */
.modal-mask { background: var(--ds-scrim); }
.modal {
  background: var(--ds-surface-2); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-3);
}
.modal-hd { border-bottom: 1px solid var(--ds-border); padding: var(--ds-space-5) var(--ds-space-6); }
.modal-hd h3 { font-size: var(--ds-fs-section); color: var(--ds-text-primary); }
.modal-x { color: var(--ds-text-secondary); }
.modal-x:hover { color: var(--ds-text-primary); }
.modal-bd { padding: var(--ds-space-6); }
.modal-ft { border-top: 1px solid var(--ds-border); padding: var(--ds-space-4) var(--ds-space-6); gap: var(--ds-space-4); }
.toast-wrap { top: var(--ds-space-5); right: var(--ds-space-5); gap: var(--ds-space-4); }
.toast {
  background: var(--ds-surface-3); color: var(--ds-text-primary);
  border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md);
  box-shadow: var(--ds-shadow-3); font-size: var(--ds-fs-body); padding: var(--ds-space-4) var(--ds-space-5);
}
.toast-success { background: var(--ds-surface-3); border-left: 3px solid var(--ds-success); }
.toast-error { background: var(--ds-surface-3); border-left: 3px solid var(--ds-danger); }
.toast-warn { background: var(--ds-surface-3); border-left: 3px solid var(--ds-warning); }

/* ---------- 11. 数据可视化（规范 6：单色实填充，不用渐变） ---------- */
.bars { gap: var(--ds-space-3); }
.bar-row { grid-template-columns: 88px 1fr 76px; font-size: var(--ds-fs-dense); gap: var(--ds-space-4); }
.bar-label { color: var(--ds-text-secondary); }
.bar-track { background: var(--ds-surface-4); border-radius: var(--ds-radius-sm); height: 6px; }
.bar-fill, .fill-green, .fill-orange, .fill-red {
  background: var(--ds-chart-1); border-radius: var(--ds-radius-sm);
}
.fill-green { background: var(--ds-chart-2); }
.fill-orange { background: var(--ds-chart-3); }
.fill-red { background: var(--ds-chart-5, var(--ds-danger)); }
.bar-value { color: var(--ds-text-primary); }
.spark > span { background: var(--ds-chart-1); border-radius: var(--ds-radius-xs) var(--ds-radius-xs) 0 0; }

/* ---------- 12. 详情：描述列表 / 时间线（规范 4.7） ---------- */
.kv { font-size: var(--ds-fs-body); gap: var(--ds-space-3) var(--ds-space-5); grid-template-columns: 96px 1fr; }
.kv .k { color: var(--ds-text-muted); font-size: var(--ds-fs-dense); text-align: right; }
.kv .v { color: var(--ds-text-primary); }
.timeline::before { background: var(--ds-surface-4); width: 2px; }
.tl-item::before { background: var(--ds-surface-4); box-shadow: none; border-color: var(--ds-surface-2); }
.tl-item.done::before { background: var(--ds-accent); box-shadow: 0 0 0 1px var(--ds-accent); }
.tl-title { font-size: var(--ds-fs-body); color: var(--ds-text-primary); }
.tl-meta { color: var(--ds-text-muted); font-size: var(--ds-fs-dense); }
.photos { gap: var(--ds-space-4); }
.photo { width: 88px; height: 88px; border-radius: var(--ds-radius-sm); background: var(--ds-surface-4); border: 1px dashed var(--ds-border-strong); color: var(--ds-text-muted); }

/* ---------- 13. 列表/地图等辅助组件 ---------- */
.list { background: var(--ds-surface-2); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); }
.list-item { border-bottom: 1px solid var(--ds-border-subtle); }
.list-item:hover { background: var(--ds-surface-3); }
.list-item.active { background: var(--ds-accent-subtle); box-shadow: inset 2px 0 0 var(--ds-accent); }
.list-title { font-size: var(--ds-fs-body); color: var(--ds-text-primary); }
.list-sub { font-size: var(--ds-fs-dense); color: var(--ds-text-muted); }
.map-box { background: var(--ds-surface-2); border-color: var(--ds-border); border-radius: var(--ds-radius-md); }
.map-dot { color: var(--ds-text-secondary); font-size: var(--ds-fs-micro); }
.map-dot i { background: var(--ds-accent); box-shadow: none; }
.map-legend { background: var(--ds-surface-3); border-color: var(--ds-border); color: var(--ds-text-secondary); }
.hint, .backend, .stat-sub { font-variant-numeric: tabular-nums; }
select.input option { background: var(--ds-surface-3); color: var(--ds-text-primary); }

/* ---------- 14. 密度（规范 9.2：紧凑 28px 行 / 24px 控件 / 字号 12） ---------- */
[data-density="compact"] .table td { height: var(--ds-row-h-compact); line-height: var(--ds-row-h-compact); }
[data-density="compact"] .table th { height: 28px; line-height: 28px; }
[data-density="compact"] .btn { height: var(--ds-control-h-sm); padding: 0 var(--ds-space-4); font-size: var(--ds-fs-dense); }
[data-density="compact"] .input, [data-density="compact"] select.input { height: var(--ds-control-h-sm); }
[data-density="compact"] .card-bd { padding: var(--ds-space-5); }
[data-density="compact"] .content { padding: var(--ds-space-6); }
[data-density="compact"] .stat { padding: var(--ds-space-5); }
[data-density="compact"] .stat-value { font-size: 22px; }

/* ---------- 15. 打印（规范 9.1：强制浅色 + 去背景 + 1px 表格线） ---------- */
@media print {
  html, body { background: #fff !important; color: #111 !important; }
  .sidebar, .topbar, .toolbar, .filters, .pager, .toast-wrap, .modal-mask { display: none !important; }
  .card, .table-wrap { border: 1px solid #999 !important; box-shadow: none !important; background: #fff !important; }
  .table th, .table td { border: 1px solid #999 !important; color: #111 !important; background: #fff !important; }
  .tag { border: 1px solid #999 !important; color: #111 !important; background: #fff !important; }
}

/* =============================================================================
 * 17. 工作台：低门槛可视化（规范 §6 + 《低门槛可视化补章》）
 * -----------------------------------------------------------------------------
 * 面向「看板的使用者是经营者本人」的场景：
 *   标题即结论、数值直标、绿=进账 红=欠款、只有一条平均线。
 *   看板不跟随密度切换（远看要清楚），因此这里用固定 px 高度。
 * ========================================================================== */
.dash-range { display: flex; align-items: center; gap: var(--ds-space-4); margin-bottom: var(--ds-space-6); flex-wrap: wrap; }
.dash-range-btn {
  height: 32px; padding: 0 var(--ds-space-6);
  background: var(--ds-surface-3); border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-radius-sm); color: var(--ds-text-secondary);
  font-size: var(--ds-fs-body); font-weight: 600; cursor: pointer;
  transition: background-color 120ms cubic-bezier(.4, 0, .2, 1);
}
.dash-range-btn:hover { background: var(--ds-surface-4); color: var(--ds-text-primary); }
.dash-range-btn.on { background: var(--ds-accent-subtle); border-color: var(--ds-accent-border); color: var(--ds-accent-text); }
.dash-range-custom { display: inline-flex; align-items: center; gap: var(--ds-space-3); margin-left: var(--ds-space-2); }

/* 一句话结论（规范 7.4：先说结果，再给细节） */
.dash-say {
  display: flex; flex-direction: column; gap: var(--ds-space-3);
  padding: var(--ds-space-7) var(--ds-space-8); margin-bottom: var(--ds-space-6);
  background: var(--ds-surface-2); border: 1px solid var(--ds-border);
  border-left: 3px solid var(--ds-accent); border-radius: var(--ds-radius-md);
}
.dash-say-txt { font-size: 20px; line-height: 1.5; color: var(--ds-text-primary); }
.dash-say-txt b { font-weight: 600; font-variant-numeric: tabular-nums; padding: 0 2px; }
.dash-say-txt b.bad { color: var(--ds-danger-text); }
.dash-say-meta { font-size: var(--ds-fs-dense); color: var(--ds-text-muted); font-variant-numeric: tabular-nums; }
.dash-say-bad { border-left-color: var(--ds-danger); }

/* 四张白话卡（规范 2.6：静态卡不加阴影） */
.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--ds-space-5); margin-bottom: var(--ds-space-6); }
.dash-kpi {
  background: var(--ds-surface-3); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md); padding: var(--ds-space-6) var(--ds-space-6) var(--ds-space-5); min-width: 0;
}
.dash-kpi-label { font-size: var(--ds-fs-body); color: var(--ds-text-secondary); }
.dash-kpi-value {
  margin-top: var(--ds-space-3); font-size: 34px; line-height: 1.1; font-weight: 600;
  letter-spacing: -.5px; color: var(--ds-text-primary);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-kpi-unit { font-size: var(--ds-fs-widget); font-weight: 400; color: var(--ds-text-muted); margin-left: 4px; }
.dash-kpi-sub { margin-top: var(--ds-space-3); font-size: var(--ds-fs-dense); color: var(--ds-text-muted); font-variant-numeric: tabular-nums; }
.dash-kpi-bad { border-left: 2px solid var(--ds-danger); }
.dash-kpi-bad .dash-kpi-value { color: var(--ds-danger-text); }
.dash-kpi-good { border-left: 2px solid var(--ds-success); }
.dash-kpi-good .dash-kpi-value { color: var(--ds-success-text); }

/* 版面栅格 */
.dash-grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--ds-space-5); align-items: start; }
.dash-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--ds-space-5); align-items: start; }
.dash-grid-main .card, .dash-grid-2 .card { margin-bottom: var(--ds-space-5); }
/* 「等你办的事」2×2 排布：四块等高，卡片高度和左边的图接近，不留大片空白 */
.dash-todos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ds-space-3); }
.dash-todos .dash-todo { margin-bottom: 0; }
.dash-chart-info { font-size: var(--ds-fs-dense); color: var(--ds-text-secondary); font-variant-numeric: tabular-nums; min-height: 18px; }
.dash-concl { font-size: var(--ds-fs-body); color: var(--ds-text-secondary); margin-bottom: var(--ds-space-6); line-height: 1.5; }

/* 柱状图：直标数值 + 一条平均虚线（规范 6：禁渐变、禁 3D、禁双轴） */
.dash-chart { position: relative; padding-top: 20px; }
.dash-cols { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--ds-space-2); }
.dash-col { flex: 1 1 0; min-width: 0; max-width: 64px; display: flex; flex-direction: column; align-items: center; outline: none; cursor: default; }
.dash-col-track { position: relative; width: 100%; height: 140px; display: flex; align-items: flex-end; }
.dash-col-bar {
  width: 100%; background: var(--ds-chart-2);
  border-radius: var(--ds-radius-xs) var(--ds-radius-xs) 0 0;
  transition: background-color 120ms cubic-bezier(.4, 0, .2, 1);
}
.dash-col-val {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: var(--ds-fs-micro); color: var(--ds-text-secondary);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.dash-col-day { height: 24px; line-height: 24px; font-size: var(--ds-fs-micro); color: var(--ds-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-col:hover .dash-col-bar, .dash-col.on .dash-col-bar { background: var(--ds-chart-1); }
.dash-col:hover .dash-col-val, .dash-col.on .dash-col-val { color: var(--ds-text-primary); font-weight: 600; }
.dash-col:focus-visible { box-shadow: var(--ds-shadow-focus); border-radius: var(--ds-radius-sm); }
.dash-avg { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--ds-border-strong); pointer-events: none; }
.dash-avg-label {
  position: absolute; right: 0; top: -9px; padding: 0 var(--ds-space-2);
  background: var(--ds-surface-2); font-size: var(--ds-fs-micro);
  color: var(--ds-text-muted); font-variant-numeric: tabular-nums;
}
.dash-legend { margin-top: var(--ds-space-5); font-size: var(--ds-fs-dense); color: var(--ds-text-muted); }

/* 排行榜（横向条 + 直标金额）：欠款红、业务量蓝 */
.dash-rank { display: flex; flex-direction: column; gap: var(--ds-space-1); }
.dash-rank-row {
  display: grid; grid-template-columns: minmax(64px, 1.05fr) minmax(48px, 1.3fr) auto auto;
  align-items: center; gap: var(--ds-space-4);
  padding: var(--ds-space-3) var(--ds-space-2); min-width: 0;
  border-bottom: 1px solid var(--ds-border-subtle);
  text-decoration: none; color: inherit;
}
.dash-rank-row:last-child { border-bottom: none; }
a.dash-rank-row:hover { background: var(--ds-surface-3); }
.dash-rank-name { font-size: var(--ds-fs-body); color: var(--ds-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-rank-bar { height: 10px; background: var(--ds-surface-4); border-radius: var(--ds-radius-xs); overflow: hidden; }
.dash-rank-bar i { display: block; height: 100%; border-radius: var(--ds-radius-xs); }
.dash-rank-bar i.fill-bad { background: var(--ds-danger); }
.dash-rank-bar i.fill-ok { background: var(--ds-chart-1); }
.dash-rank-val { font-size: var(--ds-fs-body); font-weight: 600; color: var(--ds-text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.dash-rank-sub { font-size: var(--ds-fs-micro); color: var(--ds-text-muted); white-space: nowrap; text-align: right; min-width: 48px; }
.dash-more { display: block; margin-top: var(--ds-space-3); font-size: var(--ds-fs-dense); color: var(--ds-accent-text); text-decoration: none; }
.dash-more:hover { text-decoration: underline; }

/* 等你办的事：大数字 + 白话（0 件时变成「已经办完」） */
.dash-todo {
  display: block; padding: var(--ds-space-5) var(--ds-space-6); margin-bottom: var(--ds-space-3);
  background: var(--ds-surface-3); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md); text-decoration: none; color: inherit;
  transition: background-color 120ms cubic-bezier(.4, 0, .2, 1);
}
.dash-todo:hover { background: var(--ds-surface-4); }
.dash-todo:last-child { margin-bottom: 0; }
.dash-todo-num { display: block; font-size: 30px; font-weight: 600; line-height: 1.1; color: var(--ds-text-primary); font-variant-numeric: tabular-nums; }
.dash-todo-txt { display: block; margin-top: 2px; font-size: var(--ds-fs-body); color: var(--ds-text-secondary); }
.dash-todo-go { display: block; margin-top: var(--ds-space-3); font-size: var(--ds-fs-dense); font-weight: 600; color: var(--ds-accent-text); }
.dash-todo.done { background: transparent; border-style: dashed; }
.dash-todo.done .dash-todo-num { font-size: 22px; color: var(--ds-text-disabled); }

/* 空态（规范 4.7：现状 + 下一步动作） */
.dash-empty { padding: var(--ds-space-8) 0; text-align: center; }
.dash-empty-t { font-size: var(--ds-fs-widget); font-weight: 600; color: var(--ds-text-primary); }
.dash-empty-s { font-size: var(--ds-fs-dense); color: var(--ds-text-muted); margin: var(--ds-space-3) 0 var(--ds-space-5); }

/* 页脚：数据来源 */
.dash-foot { display: flex; align-items: center; gap: var(--ds-space-3); flex-wrap: wrap; padding-top: var(--ds-space-2); font-size: var(--ds-fs-micro); color: var(--ds-text-muted); }
.dash-foot-link { background: none; border: none; padding: 0; font-size: var(--ds-fs-micro); color: var(--ds-accent-text); text-decoration: underline; cursor: pointer; }
.dash-foot-warn { color: var(--ds-warning-text); }

@media (max-width: 1400px) {
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .dash-grid-main, .dash-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .dash-kpi-value { font-size: 28px; }
  .dash-say-txt { font-size: 17px; }
}
@media print {
  .dash-range { display: none !important; }
}

/* ---------- 18. 主题/密度切换按钮（Topbar） ---------- */
.ds-prefs { display: inline-flex; gap: var(--ds-space-2); align-items: center; }
.ds-prefs button {
  height: 24px; min-width: 24px; padding: 0 var(--ds-space-3);
  background: transparent; color: var(--ds-text-secondary);
  border: 1px solid var(--ds-border); border-radius: var(--ds-radius-sm);
  font-size: var(--ds-fs-dense); cursor: pointer;
}
.ds-prefs button:hover { background: var(--ds-surface-3); color: var(--ds-text-primary); }
.ds-prefs button[aria-pressed="true"] { background: var(--ds-accent-subtle); color: var(--ds-accent-text); border-color: var(--ds-accent-border); }

/* ---------- 20. 窄屏外壳（≤860）：侧栏变顶部导航条 ----------
 * app.css 里有同样的断点，但本覆盖层把 .sidebar 固定成 220px sticky 后失效了：
 * 390 宽时侧栏仍占 220px、顶栏元素被挤成每行一个字。这里按令牌重写一遍。 */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--ds-border);
  }
  .nav { display: flex; gap: var(--ds-space-2); padding: var(--ds-space-2); overflow-x: auto; }
  .nav-group { display: none; }
  .nav-item { flex: 0 0 auto; white-space: nowrap; }
  .topbar {
    height: auto; min-height: var(--ds-topbar-h);
    flex-wrap: wrap; gap: var(--ds-space-3);
    padding: var(--ds-space-3) var(--ds-space-4);
  }
  .top-actions { flex-wrap: wrap; gap: var(--ds-space-3); }
  .user { border-left: 0; padding-left: 0; }
  .content { padding: var(--ds-space-4); }
}
/* ---------- 21. 列表选择（表头三态 + 批量条） ---------- */
.sel-cb {
  width: 15px; height: 15px; margin: 0; vertical-align: middle;
  accent-color: var(--ds-accent); cursor: pointer;
}
.sel-cb:disabled { opacity: .4; cursor: not-allowed; }
.selbar {
  display: flex; align-items: center; gap: var(--ds-space-3); flex-wrap: wrap;
  padding: 2px var(--ds-space-3); border-radius: var(--ds-radius-sm);
}
.selbar.on {
  background: var(--ds-accent-subtle);
  box-shadow: inset 0 0 0 1px var(--ds-accent-border);
}
.selbar-info {
  font-size: var(--ds-fs-dense); color: var(--ds-text-primary);
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.selbar .btn { height: 24px; }