/* ============ 国慧电气 OA 统一设计系统 v6 ============
   Minimal enterprise SaaS · 兼容现有 HTML / class */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-subtle: #f9fafb;
  --border: #e5e7eb;
  --border-light: #eef0f3;
  --text: #172033;
  --text-secondary: #526071;
  --text-muted: #8792a2;
  --primary: #3568a8;
  --primary-hover: #2d5b94;
  --primary-dark: #244b7b;
  --primary-light: #eef4fa;
  --secondary: #5d7fa8;
  --secondary-light: #f2f6fa;
  --accent: #8a6d3b;
  --accent-light: #faf7f0;
  --success: #3f7d63;
  --success-light: #eef7f2;
  --warning: #99702f;
  --warning-light: #fbf6ea;
  --danger: #b65353;
  --danger-light: #fbf0f0;
  --info: #4d749b;
  --info-light: #eff5fa;
  --sidebar-bg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(23, 32, 51, .04);
  --shadow: 0 1px 2px rgba(23, 32, 51, .05), 0 4px 14px rgba(23, 32, 51, .035);
  --shadow-md: 0 10px 28px rgba(23, 32, 51, .10);
  --shadow-lg: 0 20px 50px rgba(23, 32, 51, .16);
  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --control-sm: 32px;
  --control: 36px;
  --control-lg: 40px;
  --transition: .18s ease;
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { min-height: 100vh; display: flex; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
img, svg { max-width: 100%; }
::selection { background: #dbe8f5; color: var(--text); }
:focus { outline: none; }
:focus-visible { outline: 2px solid rgba(53, 104, 168, .72); outline-offset: 2px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfd5dd; border: 2px solid transparent; border-radius: 8px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #aeb7c3; border: 2px solid transparent; background-clip: padding-box; }

/* ---------- 应用壳层 / Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width, 288px); min-width: var(--sidebar-width, 288px); height: 100vh; position: sticky; top: 0; z-index: 60;
  display: flex; flex-direction: column; overflow: hidden; color: var(--text-secondary);
  background: var(--sidebar-bg); border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 22px 20px 18px; border-bottom: 1px solid var(--border-light); }
.sidebar .brand .logo { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.sidebar .brand .logo svg { width: 20px; height: 20px; flex: none; color: var(--primary); fill: none !important; stroke: currentColor; stroke-width: 2; }
.sidebar .brand .sub { margin-top: 4px; color: var(--text-muted); font-size: 11px; }
.sidebar .menu { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.sidebar .menu-group-label { padding: 14px 10px 6px; color: #9aa3af; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sidebar .menu-group-label:first-child { padding-top: 4px; }
.sidebar .menu-item {
  min-height: 40px; display: flex; align-items: center; gap: 10px; margin: 2px 0; padding: 9px 10px;
  border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text-secondary);
  cursor: pointer; user-select: none; font-size: 13.5px; transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.sidebar .menu-item:hover { color: var(--text); background: var(--surface-subtle); border-color: var(--border-light); }
.sidebar .menu-item.active { color: var(--primary-dark); background: var(--primary-light); border-color: #dce8f4; font-weight: 600; }
.sidebar .menu-item .mi-icon { width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); }
.sidebar .menu-item .mi-icon svg { width: 18px; height: 18px; }
.sidebar .menu-item.active .mi-icon { color: var(--primary); }
.sidebar .menu-item .mi-badge { min-width: 20px; margin-left: auto; padding: 1px 7px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 700; text-align: center; }
.sidebar .menu-tree-root { width: 100%; text-align: left; background: transparent; }
.sidebar .menu-tree-heading { display: flex; align-items: center; }
.sidebar .menu-tree-heading .menu-tree-root { min-width: 0; flex: 1; }
.sidebar .menu-tree-add { flex: none; width: 30px; height: 30px; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--primary); font-size: 20px; cursor: pointer; }
.sidebar .menu-tree-add:hover { background: var(--primary-light); }
.sidebar .sidebar-resizer { position: absolute; z-index: 2; right: 0; top: 0; bottom: 0; width: 7px; cursor: col-resize; touch-action: none; }
.sidebar .sidebar-resizer:hover, .sidebar .sidebar-resizer:focus-visible { background: var(--primary-light); }
.sidebar .menu-tree-count { margin-left: auto; border-radius: 999px; padding: 1px 7px; font-size: 11px; background: var(--primary-light); color: var(--primary-dark); }
.sidebar .menu-tree { margin: 2px 0 8px 10px; }
.sidebar .menu-tree-cat, .sidebar .menu-tree-product { width: 100%; display: flex; align-items: center; gap: 7px; min-height: 32px; padding: 5px 6px; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--text-secondary); text-align: left; cursor: pointer; font-size: 12px; }
.sidebar .menu-tree-cat:hover, .sidebar .menu-tree-product:hover { background: var(--primary-light); color: var(--primary-dark); }
.sidebar .menu-tree-chevron { width: 12px; flex: none; font-size: 17px; line-height: 1; color: var(--text-muted); transition: transform var(--transition); }
.sidebar .menu-tree-cat[aria-expanded="true"] .menu-tree-chevron { transform: rotate(90deg); }
.sidebar .menu-tree-index { color: var(--primary); font-size: 11px; font-weight: 700; }
.sidebar .menu-tree-name, .sidebar .menu-tree-product { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .menu-tree-product { display: block; padding-left: 33px; }
.sidebar .menu-tree-products { padding: 2px 0 4px; }
.sidebar .menu-tree-empty { display: block; padding: 7px; font-size: 12px; color: var(--text-muted); }
.sidebar .menu-tree [hidden], .sidebar .menu-tree-count[hidden], .sidebar .menu-tree[hidden] { display: none; }
.sidebar .foot { padding: 14px 18px; border-top: 1px solid var(--border-light); color: var(--text-muted); font-size: 11px; background: var(--surface-subtle); }
.sidebar .foot .user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; color: var(--text-secondary); font-size: 12px; }
.sidebar .foot #sidebar-user { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .foot .user-row a { flex: none; white-space: nowrap; }
.sidebar .foot #sidebar-version { min-height: 17px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sidebar .foot a:hover { color: var(--primary) !important; }

.main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.main-topbar {
  min-height: 66px; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 32px; background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--border); backdrop-filter: blur(10px);
}
.main-topbar .tb-title { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 16px; font-weight: 700; }
.main-topbar .tb-title svg { width: 18px; height: 18px; color: var(--primary); }
.main-topbar .tb-sub { margin-top: 1px; color: var(--text-muted); font-size: 12px; }
.main-content { width: 100%; max-width: 1560px; flex: 1; padding: 24px 32px 40px; }

.mobile-menu-btn {
  width: 40px; height: 40px; flex: none; display: none; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-secondary); cursor: pointer;
}
.mobile-menu-btn:hover { color: var(--primary); background: var(--primary-light); border-color: #ccdcec; }
.mobile-menu-btn svg { width: 20px; height: 20px; }
.sidebar-overlay { position: fixed; inset: 0; z-index: 50; display: none; background: rgba(23, 32, 51, .38); opacity: 0; transition: opacity var(--transition); backdrop-filter: blur(2px); }

/* ---------- 卡片 / 标题 / 工具栏 ---------- */
.card { margin-bottom: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card h2 { margin-bottom: 14px; color: var(--text); font-size: 15px; font-weight: 650; }
.toolbar { position: relative; z-index: 4; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar h2 { position: relative; z-index: 5; margin: 0; }
.toolbar .btn { position: relative; z-index: 5; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 20px; line-height: 1.3; font-weight: 700; }
.page-description { margin-top: 4px; color: var(--text-muted); font-size: 13px; }
.breadcrumb { display: flex; gap: 6px; margin-bottom: 8px; color: var(--text-muted); font-size: 12px; }

/* ---------- 按钮 ---------- */
.btn {
  min-height: var(--control); display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 15px;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--surface); color: var(--text-secondary);
  font-size: 13px; font-weight: 600; line-height: 1.25; white-space: nowrap; cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.btn svg { width: 16px; height: 16px; flex: none; }
.ui-icon-auto { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; flex: none; color: currentColor; }
.ui-icon-auto svg { width: 16px; height: 16px; }
.tb-title > .ui-icon-auto, .dc-label > .ui-icon-auto { margin-right: 2px; }
.btn:hover { background: var(--surface-subtle); border-color: var(--border); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 1px 2px rgba(36, 75, 123, .16); }
.btn-primary:hover { color: #fff; background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-success { color: #fff; background: var(--success); border-color: var(--success); }
.btn-success:hover { color: #fff; background: #356d56; border-color: #356d56; }
.btn-outline, .btn-secondary { color: var(--text-secondary); background: var(--surface); border-color: #d7dce3; }
.btn-outline:hover, .btn-secondary:hover { color: var(--primary-dark); background: var(--primary-light); border-color: #bdcfe2; }
.btn-ghost { color: var(--text-secondary); background: transparent; border-color: transparent; }
.btn-ghost:hover { color: var(--primary); background: var(--primary-light); }
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { color: #fff; background: #a24747; border-color: #a24747; }
.btn-warn { color: #fff; background: var(--warning); border-color: var(--warning); }
.btn-warn:hover { color: #fff; background: #856027; border-color: #856027; }
.btn-icon { width: var(--control); padding: 0; }
.btn-sm { min-height: var(--control-sm); padding: 5px 11px; font-size: 12px; }
.btn-link { color: var(--primary); }

.version-badge { padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.version-badge.clickable { cursor: pointer; }
.version-badge.clickable:hover { color: var(--primary); background: var(--primary-light); border-color: #c9d9ea; }

/* ---------- 表单 ---------- */
input[type=text], input[type=password], input[type=number], input[type=search], input[type=email], input[type=date], select, textarea {
  min-height: var(--control); max-width: 100%; padding: 7px 11px; border: 1px solid #d7dce3; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px; transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a1a9b4; }
input:hover, select:hover, textarea:hover { border-color: #b7c0cb; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(53, 104, 168, .12); }
input:disabled, select:disabled, textarea:disabled { background: #f2f3f5; color: var(--text-muted); cursor: not-allowed; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
label { color: var(--text-secondary); font-size: 12.5px; font-weight: 500; }
.form-field { display: grid; gap: 6px; }
.form-help { color: var(--text-muted); font-size: 12px; }
.form-error { color: var(--danger); font-size: 12px; }
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius); background: var(--surface-subtle); }

/* ---------- 数据表 ---------- */
.table-scroll { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.sheet-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.sheet-table th { position: sticky; top: 0; z-index: 2; padding: 9px 10px; border-bottom: 1px solid var(--border); background: #f7f8fa; color: #596577; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-align: left; white-space: nowrap; }
.sheet-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-light); color: var(--text); vertical-align: middle; }
.sheet-table tbody tr:last-child td { border-bottom: 0; }
.sheet-table tbody tr { transition: background var(--transition); }
.sheet-table tbody tr:nth-child(even) { background: #fcfcfd; }
.sheet-table tbody tr:hover td { background: #f3f7fb; }
.sheet-table td.num, .sheet-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-table .sheet-empty { padding: 40px 20px; background: transparent !important; color: var(--text-muted); font-size: 13px; text-align: center; }
.sheet-table tbody tr td:first-child { border-left: 3px solid transparent; }
.sheet-table tbody tr.auto td:first-child, tr.auto td:first-child { border-left-color: var(--success); }
.sheet-table tbody tr.review td:first-child, tr.review td:first-child { border-left-color: var(--warning); }
.sheet-table tbody tr.unmatched td:first-child, tr.unmatched td:first-child { border-left-color: var(--danger); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 14px; color: var(--text-muted); font-size: 12px; }

/* ---------- 徽章 / 提示 / 状态 ---------- */
.badge, .role-tag, .status-tag, .perm-tag, .db-badge, .chg-tag { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.badge { padding: 3px 9px; border: 1px solid transparent; font-size: 11.5px; }
.badge.ok { color: var(--success); background: var(--success-light); border-color: #cfe4d8; }
.badge.warn { color: var(--warning); background: var(--warning-light); border-color: #eadcbf; }
.badge.err { color: var(--danger); background: var(--danger-light); border-color: #ebcece; }
.badge.info { color: var(--info); background: var(--info-light); border-color: #d1e0ec; }
.alert { padding: 11px 13px; border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-sm); background: var(--surface-subtle); color: var(--text-secondary); font-size: 13px; }
.alert-info { border-left-color: var(--info); background: var(--info-light); }
.alert-success { border-left-color: var(--success); background: var(--success-light); }
.alert-warning { border-left-color: var(--warning); background: var(--warning-light); }
.alert-danger { border-left-color: var(--danger); background: var(--danger-light); }
.state, .empty-state, .loading-state, .error-state, .no-permission-state { display: grid; place-items: center; gap: 8px; min-height: 160px; padding: 28px; color: var(--text-muted); text-align: center; }
.state-title { color: var(--text); font-size: 14px; font-weight: 650; }
.state-icon { width: 36px; height: 36px; color: #a8b1bd; }
.error-state { color: var(--danger); }
.loading-state::before { width: 20px; height: 20px; content: ""; border: 2px solid #d8dee6; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.summary { margin-bottom: 12px; padding: 10px 13px; border: 1px solid #d8e5f1; border-radius: var(--radius-sm); background: var(--primary-light); color: var(--primary-dark); font-size: 13px; }

/* ---------- 步骤 / 仪表盘 ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 16px; }
.step { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted); font-size: 13px; }
.step.active { color: var(--primary-dark); background: var(--primary-light); border-color: #c9d9ea; font-weight: 600; }
.step.done { color: var(--success); border-color: #cfe4d8; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.dash-card { position: relative; padding: 18px 20px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); }
.dash-card::after { display: none; }
.dash-card:hover { border-color: #d3d9e1; box-shadow: var(--shadow); transform: translateY(-1px); }
.dash-card .dc-label { margin-bottom: 8px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.dash-card .dc-value { color: var(--text); font-size: 28px; font-weight: 720; line-height: 1.15; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.dash-card .dc-sub { margin-top: 6px; color: var(--text-muted); font-size: 12px; }
.dash-card.dc-accent, .dash-card.dc-green, .dash-card.dc-purple { border-top-color: var(--border); }
.dash-card.dc-accent .dc-value, .dash-card.dc-green .dc-value, .dash-card.dc-purple .dc-value { color: var(--text); }
.dash-link { cursor: pointer; }

/* ---------- 匹配 / Picker / 编辑 ---------- */
tr.nc td { background: #f7f8fa !important; color: var(--text-muted); }
tr.nc td:first-child { border-left-color: var(--text-muted); }
tr.nc .spec-cell b, tr.nc .refs { color: var(--text-muted); text-decoration: line-through; }
.cand-detail { margin-top: 4px; color: var(--text-secondary); font-size: 12px; line-height: 1.55; }
.cand-detail .score { color: var(--primary); font-weight: 600; }
.cand-detail .hits { color: var(--warning); }
.refs { max-width: 200px; word-break: break-all; }
.spec-cell { max-width: 230px; }
.muted { color: var(--text-muted); font-size: 12px; }
.picker { position: relative; }
.picker-input { width: 100%; min-width: 300px; cursor: pointer; }
.picker-input.nc { color: var(--text-muted); background: #f5f6f7; }
.picker-pop, .cell-picker-pop { z-index: 80; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-elevated); box-shadow: var(--shadow-md); }
.picker-pop { position: absolute; top: calc(100% + 5px); right: 0; left: 0; max-height: 400px; }
.picker-search, .cell-picker-pop .cp-search { padding: 8px; border-bottom: 1px solid var(--border-light); }
.picker-search input, .cell-picker-pop .cp-search input { width: 100%; }
.picker-list, .cell-picker-pop .cp-list { flex: 1; overflow-y: auto; }
.picker-item, .cell-picker-pop .cp-item { padding: 8px 12px; border-bottom: 1px solid var(--border-light); cursor: pointer; }
.picker-item:hover, .cell-picker-pop .cp-item:hover { background: var(--primary-light); }
.picker-item .pi-code, .cell-picker-pop .cp-item .cp-code { color: var(--primary); font-size: 13px; font-weight: 600; }
.picker-item .pi-full, .cell-picker-pop .cp-item .cp-full { margin-top: 2px; color: var(--text-secondary); font-size: 12px; }
.picker-item .pi-meta, .cell-picker-pop .cp-item .cp-meta { margin-top: 1px; color: var(--text-muted); font-size: 11px; }
.picker-item .pi-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10px; }
.tag-mem { color: var(--info); background: var(--info-light); }
.tag-auto { color: var(--success); background: var(--success-light); }
.tag-review { color: var(--warning); background: var(--warning-light); }
.tag-sel { color: var(--danger); background: var(--danger-light); }
.picker-empty, .cell-picker-pop .cp-empty { padding: 20px; color: var(--text-muted); font-size: 13px; text-align: center; }
.picker-foot { padding: 6px 12px; border-top: 1px solid var(--border-light); background: var(--surface-subtle); color: var(--text-muted); font-size: 11px; }
.sel-box { margin-top: 6px; padding: 8px 10px; border: 1px solid #cfe4d8; border-radius: var(--radius-sm); background: var(--success-light); }
.btn-nc { padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--warning); font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.btn-nc:hover { background: var(--warning-light); border-color: #dfcca7; }
.btn-nc.on { color: #fff; background: var(--text-muted); border-color: var(--text-muted); }
.cell-input { width: 100%; padding: 6px 8px; border: 0; border-radius: var(--radius-xs); background: transparent; font-size: 13px; }
.cell-input:focus { background: #fffdf4; box-shadow: inset 0 0 0 2px var(--primary); }
.sheet-table td.cell-code, .sheet-table td.cell-fullname { cursor: pointer; }
.sheet-table td.cell-code:hover, .sheet-table td.cell-fullname:hover { background: var(--primary-light); }
.sheet-table td.cell-code .cell-input { color: var(--primary); font-weight: 600; cursor: pointer; }
.sheet-table td.cell-generated { background: var(--danger-light); }
.row-check { width: 16px; height: 16px; margin: 6px; accent-color: var(--primary); cursor: pointer; }
.cell-picker-pop { position: fixed; width: 440px; max-height: 340px; }
.cell-picker-pop .cp-clear { padding: 7px 12px; border-top: 1px solid var(--border-light); color: var(--danger); font-size: 12px; cursor: pointer; }
.cell-picker-pop .cp-clear:hover { background: var(--danger-light); }

/* ---------- 记录 / 用户 / 结果 ---------- */
.vh-chg { padding: 3px 0; color: var(--text-secondary); font-size: 12px; }
.chg-tag { margin-right: 6px; padding: 1px 7px; font-size: 10px; }
.chg-add .chg-tag { color: var(--success); background: var(--success-light); }
.chg-del .chg-tag { color: var(--danger); background: var(--danger-light); }
.chg-mod .chg-tag { color: var(--warning); background: var(--warning-light); }
.chg-field { margin: 2px 0; color: var(--text-secondary); font-size: 12px; }
.chg-label { margin-right: 6px; color: var(--text-muted); }
.chg-before { padding: 0 5px; border-radius: 4px; color: var(--danger); background: var(--danger-light); text-decoration: line-through; }
.chg-arrow { margin: 0 6px; color: var(--text-muted); }
.chg-after { padding: 0 5px; border-radius: 4px; color: var(--success); background: var(--success-light); font-weight: 600; }
.user-table td { padding: 10px; }
.role-tag, .status-tag { padding: 2px 9px; font-size: 11px; }
.role-admin { color: var(--danger); background: var(--danger-light); }
.role-user { color: var(--primary); background: var(--primary-light); }
.status-on { color: var(--success); background: var(--success-light); }
.status-off { color: var(--text-muted); background: #f0f2f4; }
.perm-check { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-subtle); font-size: 13px; cursor: pointer; }
.perm-check:hover { border-color: #bdcfe2; }
.perm-check:has(input:checked) { color: var(--primary-dark); background: var(--primary-light); border-color: #bdcfe2; }
.perm-check input { margin: 0; accent-color: var(--primary); }
.perm-tag { margin: 1px 2px; padding: 1px 7px; color: var(--primary); background: var(--primary-light); font-size: 10px; }
.perm-tag.all { color: var(--danger); background: var(--danger-light); }
.result-box { padding: 30px; text-align: center; }
.result-box .ok-icon { color: var(--success); font-size: 42px; line-height: 1; }
.result-box .fname { margin: 12px 0; color: var(--success); font-size: 16px; font-weight: 600; word-break: break-all; }
.result-meta { margin-bottom: 20px; color: var(--text-secondary); font-size: 13px; }

/* ---------- Modal / Toast / 上传 ---------- */
.modal-mask { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(23, 32, 51, .42); backdrop-filter: blur(3px); animation: maskIn .18s ease; }
.modal-box { width: 460px; max-width: 100%; max-height: min(88vh, 760px); overflow-y: auto; padding: 22px 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-elevated); box-shadow: var(--shadow-lg); animation: boxIn .2s cubic-bezier(.16, 1, .3, 1); }
.modal-box h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; color: var(--text); font-size: 16px; font-weight: 680; }
.modal-box h3 svg { width: 18px; height: 18px; color: var(--primary); }
.modal-box label { display: block; margin: 12px 0 5px; }
.modal-box input, .modal-box select, .modal-box textarea { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border-light); }
@keyframes maskIn { from { opacity: 0; } }
@keyframes boxIn { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.toast { position: fixed; top: 18px; right: 18px; z-index: 9999; max-width: min(440px, calc(100vw - 32px)); padding: 11px 15px; border: 1px solid #344052; border-radius: var(--radius); background: #253043; color: #fff; box-shadow: var(--shadow-md); opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity var(--transition), transform var(--transition); font-size: 13px; }
.toast.show { opacity: .98; transform: none; }
.toast.err { border-color: #a24747; background: var(--danger); }
.db-badge { margin-left: 6px; padding: 1px 7px; background: #f0f2f4; color: var(--text-secondary); font-size: 10px; vertical-align: middle; }
.db-badge.ok { color: var(--success); background: var(--success-light); }
.db-badge.bad { color: var(--danger); background: var(--danger-light); }
.btn-reload:disabled { opacity: .6; cursor: not-allowed; }
.dropzone { padding: 34px 20px; border: 1.5px dashed #c7ced7; border-radius: var(--radius); background: var(--surface-subtle); text-align: center; cursor: pointer; transition: border-color var(--transition), background var(--transition); }
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }
.dropzone.dragover { border-style: solid; }
.dropzone .dz-text { color: var(--text-secondary); font-size: 14px; }
.dropzone .dz-hint { margin-top: 6px; color: var(--text-muted); font-size: 12px; }

/* ---------- 工具 ---------- */
.hidden { display: none !important; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warn { color: var(--warning); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; gap: 8px; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1199px) {
  .main-topbar { padding-right: 24px; padding-left: 24px; }
  .main-content { padding-right: 24px; padding-left: 24px; }
}
@media (max-width: 767px) {
  body { display: block; }
  body.drawer-open { overflow: hidden; }
  .sidebar {
    width: min(84vw, 300px); min-width: 0; height: 100dvh; position: fixed; top: 0; bottom: 0; left: 0;
    box-shadow: var(--shadow-lg); transform: translateX(-102%); visibility: hidden;
    transition: transform .22s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .22s;
  }
  .sidebar .sidebar-resizer { display: none; }
  body.drawer-open .sidebar { transform: translateX(0); visibility: visible; transition-delay: 0s; }
  .sidebar-overlay { display: block; visibility: hidden; }
  body.drawer-open .sidebar-overlay { visibility: visible; opacity: 1; }
  .sidebar .brand { padding: 18px 16px 14px; }
  .sidebar .menu { padding: 8px 10px 16px; }
  .sidebar .menu-item { min-height: 44px; padding: 10px 11px; }
  .sidebar .foot { padding: 14px 16px max(14px, env(safe-area-inset-bottom)); }
  .main { min-height: 100vh; }
  .main-topbar { min-height: 60px; justify-content: flex-start; padding: 10px 16px; }
  .main-topbar > :last-child:not(:first-child) { margin-left: auto; }
  .mobile-menu-btn { display: inline-flex; }
  .main-content { padding: 16px 16px 28px; }
  .card { padding: 16px; }
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .table-scroll, .card { overflow-x: auto; }
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal-box { width: 100% !important; max-width: 100% !important; max-height: 88dvh; padding: 20px 16px max(18px, env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 16px 16px 0 0; }
  .modal-actions { position: sticky; bottom: 0; margin-right: -16px; margin-left: -16px; padding: 14px 16px max(4px, env(safe-area-inset-bottom)); background: var(--surface); }
  .modal-actions .btn { min-height: 44px; }
  .picker-input { min-width: 240px; }
}
@media (max-width: 520px) {
  .main-topbar .tb-sub { display: none; }
  .main-topbar .tb-title { font-size: 15px; }
  .dash-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; }
  .toolbar .btn { flex: 1 1 auto; min-height: 44px; }
  .steps { overflow-x: auto; }
  .step { min-width: 150px; }
  .toast { top: 12px; right: 12px; left: 12px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .dash-card:hover { transform: none; }
}
