/* ================================================================
   PAMS Design System v2 — Corporate Steel · Engineering Blue
   COMAU brand style: cool grays, #2563eb accent, Inter type
   ================================================================ */

/* ─── Typography: Inter (all UI) + JetBrains Mono (data) ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* ── Corporate Steel · Engineering Blue Palette ── */
  --ds-bg: #f3f5f8;
  --ds-surface: #ffffff;
  --ds-surface-2: #f1f4f8;
  --ds-border: #dbe1e8;
  --ds-border-strong: #c3cdd9;
  --ds-text: #1f2a37;
  --ds-text-secondary: #52606d;
  --ds-text-muted: #8b98a5;
  --bs-body-color: var(--ds-text);
  --bs-body-color-rgb: 31,42,55;
  --ds-nav-bg: #1f2937;
  --ds-nav-border: rgba(255,255,255,0.06);
  --ds-nav-glow: rgba(37,99,235,0.10);

  /* ── Accent & Action ── */
  --ds-accent: #2563eb;
  --ds-accent-soft: rgba(37,99,235,0.09);
  --ds-accent-bright: #3b82f6;
  --ds-copper: #1d4ed8;
  --ds-copper-soft: rgba(29,78,216,0.10);
  --ds-primary: #2563eb;
  --ds-primary-soft: #eff4ff;
  --ds-primary-hover: #1d4ed8;
  --ds-success: #16a34a;
  --ds-success-soft: #f0fdf4;
  --ds-danger: #dc2626;
  --ds-danger-soft: #fef2f2;
  --ds-warning: #d97706;
  --ds-info: #0284c7;

  /* ── Shapes & Depth ── */
  --ds-radius: 8px;
  --ds-radius-sm: 6px;
  --ds-radius-lg: 10px;
  --ds-shadow: 0 1px 2px rgba(31,41,55,0.05), 0 2px 8px rgba(31,41,55,0.05);
  --ds-shadow-sm: 0 1px 2px rgba(31,41,55,0.04);
  --ds-shadow-lg: 0 4px 24px rgba(31,41,55,0.08);
  --ds-shadow-glow: 0 0 16px rgba(37,99,235,0.10);

  /* ── Typography Tokens ── */
  --ds-font-heading: 'Inter','Segoe UI','Microsoft YaHei',sans-serif;
  --ds-font-body: 'Inter',-apple-system,'Segoe UI','Microsoft YaHei',sans-serif;
  --ds-font-mono: 'JetBrains Mono',monospace;

  /* ── Viewport / Safe Area ── */
  --real-vh: 1vh;           /* JS overrides; 100dvh fallback */
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ── Motion ── */
  --ds-ease-out: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ds-ease-in: cubic-bezier(0.4, 0, 0.2, 1);
  --ds-duration-fast: 0.12s;
  --ds-duration-normal: 0.2s;
  --ds-duration-slow: 0.35s;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; }

/* ─── Body ─── */
html, body {
  overflow-x: hidden;
}
body {
  margin: 0; padding: 0;
  background: var(--ds-bg);
  font-family: var(--ds-font-body);
  color: var(--ds-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ─── Scrollbar: Cool refined ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3cdd9; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #b6c2cf; }

/* ─── Selection ─── */
::selection { background: rgba(37,99,235,0.15); color: var(--ds-text); }

/* ════════════════════════════════════════════════════════════════
   Navigation — Dark steel with blue accent glow
   ════════════════════════════════════════════════════════════════ */
.nav-ds {
  display: flex; align-items: center;
  height: 48px; padding: 0 22px;
  background: var(--ds-nav-bg);
  border-bottom: 1px solid var(--ds-nav-border);
  box-shadow: 0 1px 0 var(--ds-nav-glow);
  position: relative; z-index: 10;
  backdrop-filter: blur(12px);
}
.nav-ds::after {
  content: ''; position: absolute; bottom: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(37,99,235,0.15), transparent);
  pointer-events: none;
}
.nav-ds-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  font-family: var(--ds-font-heading);
  font-weight: 700; font-size: 0.95rem; letter-spacing: 0.5px;
  color: #e0e0e0;
  transition: color 0.15s;
}
.nav-ds-brand:hover { color: #fff; }
.nav-ds-brand img { height: 28px; opacity: 1; }
.nav-ds-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-ds .btn-outline-light {
  border-color: rgba(255,255,255,0.10); color: #a0a0a0;
  font-size: 0.78rem; font-weight: 600; padding: 3px 16px; border-radius: 8px;
  transition: all 0.15s;
}
.nav-ds .btn-outline-light:hover {
  background: rgba(255,255,255,0.06); color: #fff;
  border-color: rgba(255,255,255,0.20);
}
.nav-ds .btn-primary {
  font-size: 0.78rem; font-weight: 600; padding: 3px 16px; border-radius: 8px;
}
.nav-ds .nav-link-light {
  color: #a0a0a0; font-size: 0.78rem; font-weight: 500;
  text-decoration: none; padding: 3px 12px; border-radius: 8px;
  transition: all 0.12s;
}
.nav-ds .nav-link-light:hover { color: #fff; background: rgba(255,255,255,0.06); }

/* ─── 顶部功能模块菜单（全站 nav-ds 复用，静态占位 #moduleMenu 由 navmenu.js 渲染）─── */
.nav-ds .nav-ds-menu {
  display: flex; align-items: center; gap: 2px;
  flex: 1; min-width: 0; padding: 0 12px;
  overflow-x: auto; scrollbar-width: none;
}
.nav-ds .nav-ds-menu::-webkit-scrollbar { display: none; }
.nav-ds .nav-ds-menu .nav-ds-menu-link {
  color: #a0a0a0; font-size: 0.78rem; font-weight: 500;
  text-decoration: none; padding: 5px 12px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap; transition: all 0.12s;
  border: 1px solid transparent;
}
.nav-ds .nav-ds-menu .nav-ds-menu-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-ds .nav-ds-menu .nav-ds-menu-link.on {
  color: #fff; background: rgba(255,255,255,0.10); font-weight: 600;
}
.nav-ds .nav-ds-menu .nav-ds-menu-link.on::after {
  content: ''; display: block; height: 2px; border-radius: 2px;
  background: var(--ds-accent); margin-top: 2px;
}

/* ════════════════════════════════════════════════════════════════
   Surface components
   ════════════════════════════════════════════════════════════════ */
.panel-ds {
  background: var(--ds-surface);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow);
}

/* ─── Card with top accent bar ─── */
.card-ds {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
}
.card-ds::before {
  content: ''; position: absolute; top: 0; left: 12px; right: 12px;
  height: 3px;
  background: var(--ds-primary);
  border-radius: 0 0 3px 3px;
  opacity: 0;
  transition: opacity 0.2s;
}
.card-ds:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); transform: translateY(-1px); }
.card-ds:hover::before { opacity: 1; }
.card-ds-header {
  font-family: var(--ds-font-heading);
  font-weight: 600; font-size: 0.8rem;
  border-bottom: 1px solid var(--ds-border);
  padding: 12px 16px;
}
.card-ds-body { padding: 16px; }

/* ════════════════════════════════════════════════════════════════
   统一别名 — 旧 HTML 类名对齐设计系统
   全站主容器使用裸 .panel，操作列/小按钮也散落，此处统一
   ════════════════════════════════════════════════════════════════ */

/* 通用 hover 背景 token（冷灰），用于表格行/列表项 hover */
:root { --ds-bg-hover: #f4f7fa; }

/* 主内容容器 .panel —— 对齐 .panel-ds，全站 10 处自动升级 */
.panel {
  background: var(--ds-surface);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow);
}

/* 操作列统一宽度（兼容两种历史类名） */
.table .action-col,
.table .action-column { width: 1%; white-space: nowrap; }

/* 小号操作按钮 .btn-xs —— Bootstrap 5 无此 class，统一定义
   让全站散落的 btn-xs（原靠 py-0/px-1/内联 font-size 现拼）获得一致尺寸 */
.btn-xs {
  padding: 1px 7px;
  font-size: 0.72rem;
  line-height: 1.5;
  border-radius: 6px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

/* ─── Glass card (for dashboard hero stats) ─── */
.glass-ds {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--ds-radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* ════════════════════════════════════════════════════════════════
   Tree Navigation
   ════════════════════════════════════════════════════════════════ */
.tree-ds ul {
  list-style-type: none;
  padding-left: 8px;
  margin-top: 1px;
  font-size: 0.82rem;
}
.tree-ds .tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.12s, border-color 0.12s;
  border: 1px solid transparent;
  background-color: var(--ds-surface);
  height: 28px;
}
.tree-ds .tree-node:hover {
  background-color: #f4f7fa;
  border-color: var(--ds-border);
}
.tree-ds .tree-node.selected {
  background-color: var(--ds-primary-soft);
  border-color: var(--ds-primary);
  border-left: 3px solid var(--ds-primary);
  box-shadow: 0 0 0 1px rgba(37,99,235,0.10);
}
.tree-ds .tree-node.selected .node-text {
  font-weight: 600;
  color: var(--ds-primary);
}
.tree-ds .node-text-container {
  flex-grow: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  height: 100%;
  cursor: pointer;
  min-width: 0;
}
.tree-ds .node-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
  font-family: var(--ds-font-body);
}

/* Hierarchy-based styling */
.tree-ds .tree-node.project .node-text { font-size: 0.92rem; font-weight: 700; color: var(--ds-text); }
.tree-ds .tree-node.line .node-text    { font-size: 0.86rem; font-weight: 600; color: var(--ds-text); }
.tree-ds .tree-node.ca .node-text      { font-size: 0.82rem; font-weight: 500; color: var(--ds-text-secondary); }
.tree-ds .tree-node.station .node-text  { font-size: 0.80rem; font-weight: 400; color: var(--ds-text-secondary); }

.tree-ds .collapse-icon {
  cursor: pointer;
  color: var(--ds-text-muted);
  font-size: 0.68rem;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.tree-ds .collapse-icon:hover { color: var(--ds-text-secondary); }

/* ════════════════════════════════════════════════════════════════
   Tables
   ════════════════════════════════════════════════════════════════ */
.table-ds thead th {
  font-family: var(--ds-font-heading);
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--ds-text-secondary);
  background: var(--ds-surface-2) !important;
  padding: 8px 12px !important;
  white-space: nowrap;
  border-bottom: 1px solid var(--ds-border) !important;
}
.table-ds tbody td {
  font-size: 0.8rem; vertical-align: middle;
  padding: 7px 12px !important;
  border-color: #e8edf3 !important;
}
.table-ds-hover tbody tr { transition: background 0.1s; }
.table-ds-hover tbody tr:hover { background: #f4f7fa !important; }

/* ════════════════════════════════════════════════════════════════
   Toolbar
   ════════════════════════════════════════════════════════════════ */
.toolbar-ds {
  background: var(--ds-surface-2); padding: 8px 14px;
  border-radius: var(--ds-radius-sm);
  border: 1px solid var(--ds-border);
  margin-bottom: 12px;
}

/* ════════════════════════════════════════════════════════════════
   Typography
   ════════════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6, .h-ds {
  font-family: var(--ds-font-heading);
  font-weight: 700; letter-spacing: -0.02em;
}
.text-muted-ds { color: var(--ds-text-secondary); }
.text-mono-ds { font-family: var(--ds-font-mono); }

/* ════════════════════════════════════════════════════════════════
   Attachments — Unified file link styling
   ════════════════════════════════════════════════════════════════ */
.attachments-ds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.attachment-link-ds {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 6px;
  font-family: var(--ds-font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ds-primary);
  text-decoration: none;
  transition: all 0.15s ease;
}
.attachment-link-ds:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--ds-primary-hover);
  text-decoration: none;
}
.attachment-icon-ds {
  font-size: 0.7rem;
  opacity: 0.8;
}
.attachment-count-ds {
  font-family: var(--ds-font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ds-text-secondary);
}

/* ─── Buttons ─── */
.btn-ds-sm { font-weight: 600; letter-spacing: 0.3px; border-radius: 8px; padding: 4px 14px; font-size: 0.78rem; }
.form-ds-sm { font-size: 0.8rem; border-radius: 8px; }

/* ─── Bootstrap theme overrides ─── */
.btn-primary {
  background-color: var(--ds-primary);
  border-color: var(--ds-primary);
  font-weight: 600;
  border-radius: 8px;
  transition: background-color 0.15s, transform 0.12s;
}
.btn-primary:hover { background-color: var(--ds-primary-hover); border-color: var(--ds-primary-hover); }
.btn-primary:active { transform: scale(0.97); }

.btn-outline-primary {
  color: var(--ds-primary);
  border-color: var(--ds-primary);
  border-radius: 8px;
  font-weight: 600;
}
.btn-outline-primary:hover { background-color: var(--ds-primary); border-color: var(--ds-primary); }

.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--ds-border-strong);
  font-size: 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--ds-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
.form-control::placeholder { color: var(--ds-text-muted); }
.form-label { font-weight: 600; color: var(--ds-text-secondary); font-size: 0.8rem; margin-bottom: 4px; }

/* ─── Pagination / badge refinements ─── */
.badge-ds { font-weight: 600; letter-spacing: 0.3px; border-radius: 6px; padding: 2px 8px; font-size: 0.72rem; }

/* ─── List group refinements ─── */
.list-group-ds .list-group-item {
  border-color: var(--ds-border);
  padding: 8px 14px;
  font-size: 0.85rem;
  transition: background 0.12s;
}
.list-group-ds .list-group-item:hover { background: #f4f7fa; }
.list-group-ds .list-group-item.active {
  background: var(--ds-primary-soft);
  border-color: var(--ds-primary);
  color: var(--ds-primary);
  font-weight: 700;
}

/* ─── Utils ─── */
.text-wrap-break { white-space: normal !important; word-wrap: break-word !important; word-break: break-all !important; }

/* ════════════════════════════════════════════════════════════════
   Animations — Precision motion system
   ════════════════════════════════════════════════════════════════ */

/* Fade-up entrance */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-fade-up { animation: fadeUp 0.35s ease-out both; }

/* Fade-in */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.anim-fade-in { animation: fadeIn 0.3s ease-out both; }

/* Slide-up with more travel */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-slide-up { animation: slideUp 0.4s ease-out both; }

/* Scale-in pop */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
.anim-scale-in { animation: scaleIn 0.25s ease-out both; }

/* Counter number tick */
@keyframes tickUp {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

/* Pulse glow for status indicators */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(37,99,235,0); }
}
.anim-pulse-glow { animation: pulseGlow 2s ease-in-out infinite; }

/* Shimmer loading */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.anim-shimmer {
  background: linear-gradient(90deg, #e8edf3 25%, #f1f4f8 50%, #e8edf3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ════════════════════════════════════════════════════════════════
   Skeleton Loading Components
   ════════════════════════════════════════════════════════════════ */

/* Skeleton base */
.skeleton {
  background: linear-gradient(90deg, #e8edf3 25%, #f1f4f8 50%, #e8edf3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--ds-radius-sm);
}

/* Skeleton text lines */
.skeleton-text {
  height: 18px;
  margin-bottom: 8px;
}
.skeleton-text-sm {
  height: 14px;
  margin-bottom: 6px;
}
.skeleton-text-lg {
  height: 24px;
  margin-bottom: 12px;
}

/* Skeleton avatar */
.skeleton-avatar {
  border-radius: 50%;
}
.skeleton-avatar-sm { width: 32px; height: 32px; }
.skeleton-avatar-md { width: 48px; height: 48px; }
.skeleton-avatar-lg { width: 64px; height: 64px; }

/* Skeleton card */
.skeleton-card {
  border-radius: var(--ds-radius);
  padding: 16px;
}

/* Skeleton image placeholder */
.skeleton-img {
  aspect-ratio: 16/9;
  border-radius: var(--ds-radius-sm);
}

/* Skeleton button */
.skeleton-btn {
  height: 36px;
  border-radius: 8px;
}

/* Skeleton badge */
.skeleton-badge {
  height: 20px;
  width: 60px;
  border-radius: 4px;
}

/* Skeleton table row */
.skeleton-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ds-border);
}
.skeleton-row:last-child { border-bottom: none; }

/* Loading overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* Loading spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--ds-border);
  border-top-color: var(--ds-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ════════════════════════════════════════════════════════════════
   Toast Notifications — 操作反馈
   ════════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-ds {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--ds-radius-sm);
  box-shadow: var(--ds-shadow-lg);
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  animation: slideInRight 0.3s ease-out;
  border-left: 4px solid;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100px);
  }
}

.toast-ds.toast-exit {
  animation: slideOutRight 0.3s ease-in forwards;
}

.toast-ds-success {
  background: var(--ds-success-soft);
  border-left-color: var(--ds-success);
  color: #166534;
}

.toast-ds-error {
  background: var(--ds-danger-soft);
  border-left-color: var(--ds-danger);
  color: #991b1b;
}

.toast-ds-warning {
  background: #fef3c7;
  border-left-color: var(--ds-warning);
  color: #92400e;
}

.toast-ds-info {
  background: #e0f2fe;
  border-left-color: var(--ds-info);
  color: #075985;
}

.toast-ds .toast-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.toast-ds .toast-message {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
}

/* ─── Stagger helpers (applied via inline style delay) ─── */
/* .anim-fade-up with inline style="animation-delay: 0.1s" etc. */

/* ════════════════════════════════════════════════════════════════
   Accessibility — 焦点样式优化
   ════════════════════════════════════════════════════════════════ */

/* 统一焦点环样式 */
*:focus-visible {
  outline: 2px solid var(--ds-primary);
  outline-offset: 2px;
}

/* 移除默认焦点样式 */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* 跳过链接 - 视障用户快速导航 */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--ds-primary);
  color: white;
  padding: 12px 24px;
  z-index: 10000;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--ds-radius-sm) 0;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--ds-accent);
  outline-offset: 2px;
}

/* 屏幕阅读器专用 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ════════════════════════════════════════════════════════════════
   Background Texture — Subtle dot-grid pattern
   ════════════════════════════════════════════════════════════════ */
.bg-grid-ds {
  background-image:
    radial-gradient(circle, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}
.bg-grid-ds-light {
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ════════════════════════════════════════════════════════════════
   Dark Mode — 深色模式支持
   ════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  :root {
    --ds-bg: #14161a;
    --ds-surface: #1a1d23;
    --ds-surface-2: #232733;
    --ds-border: #2a303b;
    --ds-border-strong: #3a4150;
    --ds-text: #e5e9f0;
    --ds-text-secondary: #a3adbd;
    --ds-text-muted: #6b7686;
    --bs-body-color-rgb: 229,233,240;
    --ds-nav-bg: #0f1720;
    --ds-nav-border: rgba(255,255,255,0.08);
    --ds-nav-glow: rgba(37,99,235,0.15);
    --ds-accent: #3b82f6;
    --ds-accent-soft: rgba(59,130,246,0.15);
    --ds-accent-bright: #60a5fa;
    --ds-copper: #3b82f6;
    --ds-copper-soft: rgba(59,130,246,0.15);
    --ds-primary: #3b82f6;
    --ds-primary-soft: #1e3a5f;
    --ds-primary-hover: #60a5fa;
    --ds-success: #22c55e;
    --ds-success-soft: #14532d;
    --ds-danger: #ef4444;
    --ds-danger-soft: #450a0a;
    --ds-warning: #f59e0b;
    --ds-info: #38bdf8;
    --ds-bg-hover: #232733;
    --ds-surface-hover: #232733;
  }
}

/* 手动深色模式切换 */
[data-theme="dark"] {
  --ds-bg: #14161a;
  --ds-surface: #1a1d23;
  --ds-surface-2: #232733;
  --ds-border: #2a303b;
  --ds-border-strong: #3a4150;
  --ds-text: #e5e9f0;
  --ds-text-secondary: #a3adbd;
  --ds-text-muted: #6b7686;
  --bs-body-color-rgb: 229,233,240;
  --ds-nav-bg: #0f1720;
  --ds-nav-border: rgba(255,255,255,0.08);
  --ds-nav-glow: rgba(37,99,235,0.15);
  --ds-accent: #3b82f6;
  --ds-accent-soft: rgba(59,130,246,0.15);
  --ds-accent-bright: #60a5fa;
  --ds-copper: #3b82f6;
  --ds-copper-soft: rgba(59,130,246,0.15);
  --ds-primary: #3b82f6;
  --ds-primary-soft: #1e3a5f;
  --ds-primary-hover: #60a5fa;
  --ds-success: #22c55e;
  --ds-success-soft: #14532d;
  --ds-danger: #ef4444;
  --ds-danger-soft: #450a0a;
  --ds-warning: #f59e0b;
  --ds-info: #38bdf8;
  --ds-bg-hover: #232733;
  --ds-surface-hover: #232733;
}

[data-theme="dark"] body,
[data-theme="dark"] .panel,
[data-theme="dark"] .card {
  background-color: var(--ds-surface);
  color: var(--ds-text);
}

[data-theme="dark"] .table {
  color: var(--ds-text);
}

[data-theme="dark"] .table thead th {
  background-color: var(--ds-surface-hover) !important;
}

[data-theme="dark"] .table tbody tr:hover {
  background-color: var(--ds-surface-hover) !important;
}

[data-theme="dark"] .nav-ds {
  background-color: var(--ds-nav-bg);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: var(--ds-surface);
  border-color: var(--ds-border-strong);
  color: var(--ds-text);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: var(--ds-surface);
  border-color: var(--ds-primary);
}

/* 深色模式下常用 Bootstrap 工具类跟随 DS 变量（避免黑底深字不可读） */
[data-theme="dark"] .text-dark { color: var(--ds-text) !important; }
[data-theme="dark"] .text-secondary { color: var(--ds-text-secondary) !important; }
[data-theme="dark"] .text-muted { color: var(--ds-text-muted) !important; }
[data-theme="dark"] .text-body { color: var(--ds-text) !important; }
[data-theme="dark"] .bg-white { background-color: var(--ds-surface) !important; }
[data-theme="dark"] .bg-light { background-color: var(--ds-surface-2) !important; }
[data-theme="dark"] .modal-content { background-color: var(--ds-surface); color: var(--ds-text); }

/* 亮色模式 Bootstrap 文字工具类统一跟随 DS token（暗色 token 自适应，色相与工程蓝一致） */
.text-dark, .text-body { color: var(--ds-text) !important; }
.text-secondary, .text-body-secondary { color: var(--ds-text-secondary) !important; }
.text-muted { color: var(--ds-text-muted) !important; }
.text-primary { color: var(--ds-accent) !important; }
.text-success { color: var(--ds-success) !important; }
.text-danger { color: var(--ds-danger) !important; }
.text-warning { color: var(--ds-warning) !important; }
.text-info { color: var(--ds-info) !important; }

/* 深色模式切换按钮 */
.theme-toggle {
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--ds-border);
  background: var(--ds-surface);
  color: var(--ds-text);
  transition: all 0.2s;
}

.theme-toggle:hover {
  background: var(--ds-surface-hover);
  border-color: var(--ds-primary);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }

[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* nav-ds 钢灰导航上的主题切换按钮（浅色模式下也用半透明底适配深色导航） */
.nav-ds .theme-toggle {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
  color: #e5e7eb;
}
.nav-ds .theme-toggle:hover {
  background: rgba(255,255,255,0.16);
  border-color: var(--ds-accent-bright);
}

/* ════════════════════════════════════════════════════════════════
   Empty State — 空状态友好提示
   ════════════════════════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--ds-text-muted);
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ds-text-secondary);
  margin-bottom: 8px;
}

.empty-state-description {
  font-size: 0.85rem;
  max-width: 320px;
  line-height: 1.5;
}

/* 表格空状态 — 继承 .empty-state 居中布局，用于 <td colspan> 内 */
.table-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  color: var(--ds-text-muted);
}
.table-empty-state .empty-state-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.4;
}
.table-empty-state .empty-state-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ds-text-secondary);
  margin-bottom: 4px;
}
.table-empty-state .empty-state-description {
  font-size: 0.78rem;
  max-width: 260px;
  line-height: 1.45;
}

/* ════════════════════════════════════════════════════════════════
   Button Enhancements — 按钮增强
   ════════════════════════════════════════════════════════════════ */

/* 危险操作按钮增强 */
.btn-danger {
  transition: all 0.15s ease;
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-danger:active {
  transform: translateY(0);
}

/* 成功操作按钮增强 */
.btn-success {
  transition: all 0.15s ease;
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

/* 主操作按钮增强 */
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}

/* ════════════════════════════════════════════════════════════════
   Table Enhancements — 表格增强
   ════════════════════════════════════════════════════════════════ */

/* 表格行悬停效果 —— 统一暖灰 hover，去掉 scale（宽表抖动）*/
.table-hover tbody tr {
  transition: background-color 0.12s;
}

.table-hover tbody tr:hover {
  background-color: var(--ds-bg-hover) !important;
}
/* 数值列 hover 蓝色提示(仅作用于 td, 避开 Bootstrap --bs-table-hover-bg 覆盖) */
.table-hover tbody tr:hover td.num, .table-hover tbody tr:hover .num-cell {
  background-color: var(--ds-accent-soft) !important;
}

/* 表格行选中效果 */
.table tbody tr.selected {
  background-color: var(--ds-primary-soft) !important;
}

/* 表格操作列 */
.table .action-column {
  width: 100px;
  text-align: right;
}

/* 表格单元格省略号 */
.table td.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════════
   Form Validation — 表单验证增强
   ════════════════════════════════════════════════════════════════ */

/* 输入框验证状态 */
.form-control.is-valid {
  border-color: var(--ds-success);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23059669' d='M2.3 6.73L.6 4.53c-.4-.4-.4-1.04 0-1.44l1.06-1.06c.4-.4 1.04-.4 1.44 0l1.06 1.06 3.18-3.18c.4-.4 1.04-.4 1.44 0l1.06 1.06c.4.4.4 1.04 0 1.44L6.73 4.93c-.4.4-1.04.4-1.44 0z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}

.form-control.is-invalid {
  border-color: var(--ds-danger);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3e%3cpath fill='%23dc2626' d='M4.07 1a3 3 0 0 0-3 3v5a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3zM3 4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4z'/%3e%3cpath fill='%23dc2626' d='M6.657 6.657a.5.5 0 0 1 .707 0L9.05 8.343a.5.5 0 0 1-.707.707L8.657 8.364a.5.5 0 0 1 0-.707zm-2.829 2.829a.5.5 0 0 1-.707 0L1.95 7.829a.5.5 0 0 1 0-.707l1.414-1.414a.5.5 0 1 1 .707.707L3.05 7.122a.5.5 0 0 1 0 .707z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}

/* 验证提示文本 */
.invalid-feedback,
.valid-feedback {
  font-size: 0.78rem;
  margin-top: 4px;
}

/* 输入组验证 */
.input-group .form-control.is-invalid ~ .input-group-text {
  border-color: var(--ds-danger);
}

/* 实时验证动画 */
.form-control.validating {
  animation: pulse-border 0.8s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--ds-primary); }
  50% { border-color: var(--ds-accent); }
}

/* 必填字段标记 */
.required-label::after {
  content: ' *';
  color: var(--ds-danger);
  font-weight: bold;
}

/* ════════════════════════════════════════════════════════════════
   Pagination — 分页组件
   ════════════════════════════════════════════════════════════════ */

.pagination-ds {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.pagination-ds .page-item {
  margin: 0 2px;
}

.pagination-ds .page-link {
  border-radius: 8px;
  border: 1px solid var(--ds-border);
  color: var(--ds-text-secondary);
  font-weight: 500;
  padding: 6px 12px;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.pagination-ds .page-link:hover {
  background-color: var(--ds-primary-soft);
  border-color: var(--ds-primary);
  color: var(--ds-primary);
}

.pagination-ds .page-item.active .page-link {
  background-color: var(--ds-primary);
  border-color: var(--ds-primary);
  color: white;
  font-weight: 700;
}

.pagination-ds .page-item.disabled .page-link {
  color: var(--ds-text-muted);
  background-color: transparent;
  border-color: var(--ds-border);
  cursor: not-allowed;
  opacity: 0.6;
}

/* 分页信息 */
.pagination-info {
  font-size: 0.85rem;
  color: var(--ds-text-secondary);
  padding: 0 16px;
}

/* 分页大小选择 */
.pagination-size-select {
  width: auto;
  font-size: 0.85rem;
  padding: 4px 8px;
}

/* ════════════════════════════════════════════════════════════════
   Performance — 性能优化相关
   ════════════════════════════════════════════════════════════════ */

/* 虚拟滚动容器 */
.virtual-scroll-container {
  overflow-y: auto;
  will-change: transform;
}

/* 懒加载占位符 */
.lazy-placeholder {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--ds-radius-sm);
}

/* 防抖/节流指示器 */
.performance-indicator {
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 20px;
  font-size: 0.75rem;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
}

.performance-indicator.show {
  opacity: 1;
}

/* 缓存状态指示器 */
.cache-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--ds-text-muted);
}

.cache-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ds-success);
}

.cache-indicator.stale .dot {
  background: var(--ds-warning);
}

.cache-indicator.loading .dot {
  background: var(--ds-info);
  animation: pulse 1s infinite;
}

/* ════════════════════════════════════════════════════════════════
   Confirm Dialog — 确认对话框
   ════════════════════════════════════════════════════════════════ */

.confirm-dialog-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.confirm-dialog-icon.danger { color: var(--ds-danger); }
.confirm-dialog-icon.warning { color: var(--ds-warning); }
.confirm-dialog-icon.info { color: var(--ds-info); }
.confirm-dialog-icon.success { color: var(--ds-success); }

.confirm-dialog-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-dialog-message {
  font-size: 0.9rem;
  color: var(--ds-text-secondary);
  margin-bottom: 24px;
}

/* ════════════════════════════════════════════════════════════════
   Drag & Drop — 拖拽排序
   ════════════════════════════════════════════════════════════════ */

/* 拖拽项 */
.draggable {
  cursor: grab;
  user-select: none;
}

.draggable:active {
  cursor: grabbing;
}

/* 拖拽中的项 */
.dragging {
  opacity: 0.5;
  background-color: var(--ds-primary-soft);
  border: 2px dashed var(--ds-primary);
}

/* 拖拽占位符 */
.drag-placeholder {
  background-color: var(--ds-accent-soft);
  border: 2px dashed var(--ds-accent);
  border-radius: var(--ds-radius-sm);
  min-height: 50px;
  margin: 8px 0;
}

/* 拖拽排序容器 */
.sortable-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sortable-item {
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.sortable-item:hover {
  z-index: 1;
}

/* 拖拽手柄 */
.drag-handle {
  cursor: grab;
  color: var(--ds-text-muted);
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s;
}

.drag-handle:hover {
  color: var(--ds-primary);
}

.drag-handle:active {
  cursor: grabbing;
}

/* ════════════════════════════════════════════════════════════════
   Fullscreen — 全屏模式
   ════════════════════════════════════════════════════════════════ */

/* 全屏按钮 (右下角上移, 避免遮住矩阵网格底部滚动条角) */
.fullscreen-btn {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ds-primary);
  color: white;
  border: none;
  box-shadow: var(--ds-shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 1050;
  transition: all 0.2s;
}

.fullscreen-btn:hover {
  transform: scale(1.1);
  background: var(--ds-primary-hover);
}

/* 全屏容器 */
.fullscreen-container {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  z-index: 9999 !important;
  padding: 20px !important;
  background: var(--ds-bg) !important;
  overflow: auto !important;
}

/* 全屏模式下的导航栏 */
.fullscreen-mode .nav-ds {
  display: none;
}

/* Bootstrap modal-fullscreen 移动端修正：防止底部导航条遮挡 */
.modal-fullscreen {
  height: 100dvh !important;
}

/* ════════════════════════════════════════════════════════════════
   Keyboard Shortcuts Panel — 快捷键提示面板
   ════════════════════════════════════════════════════════════════ */

.shortcuts-toggle {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  box-shadow: var(--ds-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1040;
  transition: all 0.2s;
}

.shortcuts-toggle:hover {
  border-color: var(--ds-primary);
  color: var(--ds-primary);
}

.shortcuts-panel {
  position: fixed;
  bottom: 70px;
  left: 20px;
  width: 320px;
  max-height: 400px;
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow-lg);
  z-index: 1040;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.2s;
}

.shortcuts-panel.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.shortcuts-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ds-border);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shortcuts-panel-body {
  padding: 12px 16px;
  max-height: 340px;
  overflow-y: auto;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--ds-border);
}

.shortcut-item:last-child {
  border-bottom: none;
}

.shortcut-keys {
  display: flex;
  gap: 4px;
}

.shortcut-key {
  background: var(--ds-bg);
  border: 1px solid var(--ds-border-strong);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-family: var(--ds-font-mono);
  font-weight: 600;
}

.shortcut-desc {
  color: var(--ds-text-secondary);
  font-size: 0.85rem;
}

/* ════════════════════════════════════════════════════════════════
   Print Styles — 打印样式
   ════════════════════════════════════════════════════════════════ */

@media print {
  /* 隐藏非打印元素 */
  .no-print,
  .nav-ds,
  .sidebar,
  .btn,
  .shortcuts-toggle,
  .fullscreen-btn,
  .toast-container,
  .skip-link,
  .pagination-ds,
  .action-column,
  .filter-bar,
  .toolbar {
    display: none !important;
  }

  /* 打印背景 */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 页面设置 */
  @page {
    size: A4 landscape;
    margin: 1cm;
  }

  /* 打印容器 */
  .print-only {
    display: block !important;
  }

  .print-header {
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
    margin-bottom: 20px;
  }

  .print-footer {
    border-top: 1px solid #ccc;
    padding-top: 10px;
    margin-top: 20px;
    font-size: 0.8rem;
    color: #666;
  }

  /* 表格打印优化 */
  .table {
    font-size: 0.75rem;
    border-collapse: collapse;
    width: 100%;
  }

  .table th,
  .table td {
    border: 1px solid #333;
    padding: 4px 8px;
  }

  .table th {
    background: #f0f0f0 !important;
  }

  /* 分页 */
  .page-break {
    page-break-before: always;
  }

  .no-break {
    page-break-inside: avoid;
  }
}

/* 打印时显示的元素 */
.print-only {
  display: none;
}

/* ════════════════════════════════════════════════════════════════
   Lazy Loading — 图片懒加载
   ════════════════════════════════════════════════════════════════ */

img[data-src] {
  opacity: 0;
  transition: opacity 0.3s ease;
}

img.loaded,
img[data-src].loaded {
  opacity: 1;
}

/* 懒加载占位符背景 */
.lazy-image-placeholder {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ════════════════════════════════════════════════════════════════
   Progress Indicator — 进度指示器
   ════════════════════════════════════════════════════════════════ */

.progress-thin {
  height: 4px;
  border-radius: 2px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--ds-border);
  color: var(--ds-text-muted);
  transition: all 0.2s;
}

.progress-step.active .progress-step-dot {
  background: var(--ds-primary);
  color: white;
}

.progress-step.completed .progress-step-dot {
  background: var(--ds-success);
  color: white;
}

.progress-step-line {
  flex: 1;
  height: 2px;
  background: var(--ds-border);
}

.progress-step.completed + .progress-step .progress-step-line,
.progress-step.completed .progress-step-line {
  background: var(--ds-success);
}

/* ════════════════════════════════════════════════════════════════
   Tags & Chips — 标签和芯片
   ════════════════════════════════════════════════════════════════ */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--ds-primary-soft);
  color: var(--ds-primary);
  transition: all 0.15s;
}

.tag:hover {
  background: var(--ds-primary);
  color: white;
}

.tag-remove {
  cursor: pointer;
  opacity: 0.7;
  font-size: 0.9rem;
  margin-left: 2px;
}

.tag-remove:hover {
  opacity: 1;
}

/* 可删除的标签 */
.tag.removable {
  padding-right: 6px;
}

/* ════════════════════════════════════════════════════════════════
   Enhanced Table — 增强数据表格
   ════════════════════════════════════════════════════════════════ */

/* 表格容器 */
.table-container {
  background: var(--ds-surface);
  border-radius: var(--ds-radius);
  overflow: hidden;
  border: 1px solid var(--ds-border);
}

/* 表头固定 */
.table-fixed-header {
  overflow-y: auto;
  max-height: 500px;
}

.table-fixed-header thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ds-surface);
}

/* 表格排序 */
.table-sortable th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.table-sortable th:hover {
  background: var(--ds-bg-hover);
}

.table-sortable th .sort-icon {
  margin-left: 4px;
  opacity: 0.4;
  font-size: 0.7rem;
}

.table-sortable th.sorted .sort-icon {
  opacity: 1;
  color: var(--ds-primary);
}

.table-sortable th.sorted.asc .sort-icon::after {
  content: '▲';
}

.table-sortable th.sorted.desc .sort-icon::after {
  content: '▼';
}

/* 表格行选中 */
.table-selectable tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.table-selectable tbody tr:hover {
  background: var(--ds-bg-hover);
}

.table-selectable tbody tr.selected {
  background: var(--ds-primary-soft);
}

.table-selectable tbody tr.selected:hover {
  background: var(--ds-primary-soft);
}

/* 表格工具栏 */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ds-border);
  background: var(--ds-bg);
  flex-wrap: wrap;
  gap: 8px;
}

.table-toolbar-left,
.table-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 列宽控制 */
.col-width-xs { width: 60px; }
.col-width-sm { width: 100px; }
.col-width-md { width: 150px; }
.col-width-lg { width: 200px; }
.col-width-xl { width: 300px; }

/* 空状态 */
.table-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ds-text-muted);
}

.table-empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
}

.table-empty-state h4 {
  margin-bottom: 8px;
  font-weight: 600;
}

.table-empty-state p {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* 加载状态 */
.table-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

/* 斑马纹 */
.table-striped tbody tr:nth-of-type(odd) {
  background: var(--ds-bg);
}

/* 紧凑型表格 */
.table-compact th,
.table-compact td {
  padding: 6px 12px;
  font-size: 0.85rem;
}

/* 响应式表格 */
.table-responsive-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ════════════════════════════════════════════════════════════════
   Form Builder — 表单生成器
   ════════════════════════════════════════════════════════════════ */

/* 动态表单容器 */
.dynamic-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  gap: 16px;
}

.form-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr !important; }
}

/* 表单项 */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ds-text);
}

.form-field .required::after {
  content: ' *';
  color: var(--ds-danger);
}

/* 输入组 */
.input-group-ds {
  display: flex;
  align-items: center;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-group-ds:focus-within {
  border-color: var(--ds-primary);
  box-shadow: 0 0 0 3px var(--ds-primary-soft);
}

.input-group-ds .input-prefix,
.input-group-ds .input-suffix {
  padding: 0 12px;
  background: var(--ds-bg);
  color: var(--ds-text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

.input-group-ds input {
  border: none;
  flex: 1;
  padding: 10px 12px;
  font-size: 0.9rem;
  outline: none;
  min-width: 0;
}

/* 计数器输入 */
.input-counter {
  position: relative;
}

.input-counter input {
  padding-right: 50px;
}

.input-counter::after {
  content: attr(data-count);
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--ds-text-muted);
}

/* 滑块 */
.slider-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-field input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--ds-border);
  outline: none;
  -webkit-appearance: none;
}

.slider-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ds-primary);
  cursor: pointer;
  box-shadow: var(--ds-shadow);
}

.slider-value {
  font-weight: 600;
  color: var(--ds-primary);
}

/* 颜色选择器 */
.color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-picker input[type="color"] {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--ds-radius-sm);
  cursor: pointer;
  padding: 0;
}

.color-picker input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-picker input[type="color"]::-webkit-color-swatch {
  border-radius: 4px;
  border: none;
}

/* 开关 */
.switch-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--ds-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--ds-shadow-sm);
  transition: transform 0.2s;
}

.switch.active {
  background: var(--ds-primary);
}

.switch.active::after {
  transform: translateX(20px);
}

.switch-label {
  font-size: 0.9rem;
  color: var(--ds-text-secondary);
}

/* 表单验证状态 */
.form-field.error input,
.form-field.error select,
.form-field.error textarea {
  border-color: var(--ds-danger);
}

.form-field.success input,
.form-field.success select,
.form-field.success textarea {
  border-color: var(--ds-success);
}

.form-field .error-message {
  font-size: 0.75rem;
  color: var(--ds-danger);
}

.form-field .hint {
  font-size: 0.75rem;
  color: var(--ds-text-muted);
}

/* ==========================================
   19. 移动端响应式覆写
   ========================================== */
@media (max-width: 768px) {
  :root {
    --ds-radius: 8px;
    --ds-shadow: 0 1px 3px rgba(0,0,0,0.04);
    --ds-shadow-sm: 0 1px 2px rgba(0,0,0,0.02);
    --ds-shadow-lg: 0 2px 12px rgba(0,0,0,0.06);
  }
}

/* 触摸目标最小值 (HP 建议 44px) */
@media (max-width: 992px) {
  .nav-ds .btn, .nav-admin .btn,
  .btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .nav-ds .btn-sm, .btn-sm { min-height: 36px; }
  .form-control, .form-select { min-height: 40px; font-size: 16px !important; }
  select, input, textarea { font-size: 16px !important; }
}

/* 手机隐藏/全宽辅助 */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .w-100-mobile { width: 100% !important; }
}

/* 导航栏手机版 */
@media (max-width: 768px) {
  /* 两行布局：第一行 品牌+右侧按钮；第二行 功能模块菜单独占一行横向滚动。
     单行 flex 下 #moduleMenu 会被品牌/右侧按钮挤压到 20px 左右，9 个板块链接
     全部溢出视口外（body overflow-x:hidden 还堵死页面横滚），无法进入板块。 */
  .nav-ds { flex-wrap: wrap; height: auto; padding: 4px 12px 6px; row-gap: 4px; }
  .nav-ds-brand, .nav-ds-right { min-height: 40px; }
  .nav-ds-brand span {
    max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 0.82rem;
  }
  .nav-ds-right .btn { padding: 3px 10px; font-size: 0.72rem; }
  .nav-ds .nav-ds-menu {
    flex: 0 0 100%; order: 3; max-width: 100%;
    padding: 2px 0 0;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .nav-ds .nav-ds-menu .nav-ds-menu-link { flex-shrink: 0; }
}

/* 极小屏（320-375px）导航栏进一步压缩 */
@media (max-width: 575.98px) {
  .nav-ds-brand span { max-width: 100px; font-size: 0.75rem; }
  .nav-ds-right .btn { padding: 2px 6px; font-size: 0.68rem; }
}

/* 标签页横向滚动（手机端） */
@media (max-width: 768px) {
  .nav.nav-tabs { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav.nav-tabs::-webkit-scrollbar { display: none; }
  .nav.nav-tabs .nav-item { flex-shrink: 0; }
  .nav.nav-tabs .nav-link { padding: 8px 12px; font-size: 0.78rem; white-space: nowrap; }
}


/* ════════════════════════════════════════════════════════════════
   ═══ PRECISION WORKSHOP 2.0 — 精密车间 2.0 升级包 ═══
   追加内容，不覆盖已有选择器。所有新 class 以 -v2 后缀或全新类名命名。
   ════════════════════════════════════════════════════════════════ */

/* ───── 2.0 色彩令牌 ───── */
:root {
  --ds-warm-bg: #f3f5f8;
  --ds-warm-surface: #ffffff;
  --ds-copper: #1d4ed8;
  --ds-copper-soft: rgba(29,78,216,0.10);
  --ds-amber-glow: 0 0 20px rgba(37,99,235,0.10);
  --ds-teal-glow: 0 0 20px rgba(37,99,235,0.06);
}

/* ───── 精密仪表卡片 — 顶部发光蓝条 ───── */
.card-instrument {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.25s var(--ds-ease-out), transform 0.25s var(--ds-ease-out);
}
.card-instrument::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ds-accent), var(--ds-copper));
  opacity: 0.6;
  transition: opacity 0.3s, height 0.3s;
}
.card-instrument:hover {
  box-shadow: var(--ds-shadow-lg), var(--ds-amber-glow);
  transform: translateY(-2px);
}
.card-instrument:hover::before {
  opacity: 1;
  height: 4px;
}
.card-instrument-header {
  font-family: var(--ds-font-heading);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 14px 18px 10px;
  color: var(--ds-text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-instrument-body {
  padding: 0 18px 14px;
  font-size: 0.85rem;
  color: var(--ds-text-secondary);
}

/* ───── 数据统计卡片 ───── */
.stat-ds {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  padding: 18px 16px;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.stat-ds:hover {
  box-shadow: var(--ds-shadow-lg);
  transform: translateY(-1px);
}
.stat-ds-value {
  font-family: var(--ds-font-heading);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 2px;
}
.stat-ds-label {
  font-size: 0.78rem;
  color: var(--ds-text-muted);
  font-weight: 500;
}
.stat-ds-icon {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 1.6rem;
  opacity: 0.15;
}
.stat-ds-accent { color: var(--ds-accent); }
.stat-ds-teal { color: var(--ds-primary); }
.stat-ds-success { color: var(--ds-success); }
.stat-ds-danger { color: var(--ds-danger); }

/* ───── 导航栏活跃指示器 ───── */
.nav-ds .nav-link-light.active-page {
  color: #fff;
  background: rgba(37,99,235,0.16);
  position: relative;
}
.nav-ds .nav-link-light.active-page::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--ds-accent);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(37,99,235,0.4);
}

/* ───── 铜色点缀 ───── */
.text-copper { color: var(--ds-copper); }
.bg-copper-soft { background: var(--ds-copper-soft); }
.border-copper { border-color: var(--ds-copper); }
.btn-copper {
  background: var(--ds-copper);
  border-color: var(--ds-copper);
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.15s;
}
.btn-copper:hover {
  background: #1e40af;
  border-color: #1e40af;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(29,78,216,0.3);
}

/* ───── 新徽章系统 ───── */
.badge-amber {
  background: rgba(37,99,235,0.10);
  color: #2563eb;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 0.72rem;
}
.badge-teal {
  background: rgba(2,132,199,0.10);
  color: #0284c7;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 0.72rem;
}
.badge-copper {
  background: rgba(100,116,139,0.10);
  color: #475569;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 0.72rem;
}
[data-theme="dark"] .badge-amber {
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
}
[data-theme="dark"] .badge-teal {
  background: rgba(2,132,199,0.15);
  color: #38bdf8;
}
[data-theme="dark"] .badge-copper {
  background: rgba(100,116,139,0.15);
  color: #94a3b8;
}

/* ───── 实时状态指示灯 ───── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-green { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.status-dot-red { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.status-dot-amber { background: var(--ds-accent); box-shadow: 0 0 6px rgba(37,99,235,0.4); }
.status-dot-gray { background: #a1a1aa; }
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.status-dot-pulse { animation: statusPulse 2s ease-in-out infinite; }

/* ───── 进阶入场动画 ───── */
@keyframes fadeUpScale {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.anim-fade-up-scale { animation: fadeUpScale 0.4s var(--ds-ease-out) both; }

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
.anim-slide-in-left { animation: slideInLeft 0.3s ease-out both; }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.anim-slide-in-right { animation: slideInRight 0.3s ease-out both; }

/* ───── 数据行悬停增强 ───── */
.tr-ds-hover tbody tr {
  transition: background 0.15s, transform 0.15s;
  cursor: default;
}
.tr-ds-hover tbody tr:hover {
  background: rgba(37,99,235,0.03);
  transform: scale(1.003);
}

/* ───── 数据单元格中的等宽数字 ───── */
.td-mono {
  font-family: var(--ds-font-mono);
  font-size: 0.82rem;
  letter-spacing: -0.01em;
}

/* ───── 精密网格线 ───── */
.table-ds-grid thead th {
  border-right: 1px solid rgba(195,205,217,0.3);
}
.table-ds-grid thead th:last-child { border-right: none; }
.table-ds-grid tbody td {
  border-right: 1px solid rgba(219,225,232,0.5);
}
.table-ds-grid tbody td:last-child { border-right: none; }

/* ───── 工具条增强 ───── */
.toolbar-ds-v2 {
  background: var(--ds-surface);
  padding: 10px 16px;
  border-radius: var(--ds-radius);
  border: 1px solid var(--ds-border);
  box-shadow: var(--ds-shadow-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ───── 面板标题装饰线 ───── */
.section-heading-ds {
  font-family: var(--ds-font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ds-text);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.section-heading-ds::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--ds-border), transparent);
}
.section-heading-ds .heading-icon {
  font-size: 1.1rem;
}

/* ───── 标签栏增强 ───── */
.nav-tabs-ds .nav-link {
  font-weight: 600;
  color: var(--ds-text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: 0.82rem;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tabs-ds .nav-link:hover {
  color: var(--ds-primary);
  border-bottom-color: var(--ds-border-strong);
}
.nav-tabs-ds .nav-link.active {
  color: var(--ds-primary);
  border-bottom-color: var(--ds-primary);
  background: transparent;
}

/* ───── 表单行间距 ───── */
.form-row-ds {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* ───── 空状态增强 ───── */
.empty-state-v2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}
.empty-state-v2-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state-v2-title {
  font-family: var(--ds-font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ds-text-secondary);
  margin-bottom: 6px;
}
.empty-state-v2-desc {
  font-size: 0.85rem;
  color: var(--ds-text-muted);
  max-width: 300px;
  line-height: 1.5;
}

/* ───── 深色模式控制室增强 ───── */
[data-theme="dark"] .card-instrument {
  border-color: #2a303b;
  background: #1a1d23;
}
[data-theme="dark"] .card-instrument:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), 0 0 20px rgba(37,99,235,0.10);
}
[data-theme="dark"] .stat-ds {
  background: #1a1d23;
  border-color: #2a303b;
}
[data-theme="dark"] .badge-amber {
  background: rgba(59,130,246,0.12);
  color: #60a5fa;
}
[data-theme="dark"] .badge-copper {
  background: rgba(100,116,139,0.10);
  color: #94a3b8;
}
[data-theme="dark"] .toolbar-ds-v2 {
  background: #1a1d23;
  border-color: #2a303b;
}

/* ───── 移动端 scrollbar 隐藏辅助 ───── */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar { display: none; }

/* ───── 模块卡片网格 ───── */
.module-grid-v2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 20px;
}
@media (max-width: 767.98px) {
  .module-grid-v2 { grid-template-columns: 1fr; gap: 14px; }
}

/* ───── 页面过渡容器 ───── */
.page-transition {
  animation: fadeUpScale 0.35s var(--ds-ease-out) both;
}

/* ───── 仪表盘 hero 区域装饰线 ───── */
.hero-accent-line {
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--ds-accent), var(--ds-copper));
  border-radius: 3px;
  margin-bottom: 12px;
}

/* ───── 小提示 / 辅助文字 ───── */
.hint-ds {
  font-size: 0.75rem;
  color: var(--ds-text-muted);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════════════════
   Dark 2.0 — 暗色下前景/背景一致性（表格/按钮/列表/标签页/组件）
   规则置尾：同特异性后加载者胜，[data-theme] 前缀特异性高于页面内单类
   ════════════════════════════════════════════════════════════════ */

/* ─── 表格：深色底 + 亮色前景 + 深边框 ─── */
[data-theme="dark"] .table {
  --bs-table-bg: var(--ds-surface);
  --bs-table-color: var(--ds-text);
  --bs-table-border-color: var(--ds-border);
  --bs-table-striped-bg: var(--ds-surface-2);
  --bs-table-striped-color: var(--ds-text);
  --bs-table-hover-bg: var(--ds-surface-hover);
  --bs-table-hover-color: var(--ds-text);
  background-color: var(--ds-surface);
  color: var(--ds-text);
}
[data-theme="dark"] .table thead th {
  background-color: var(--ds-surface-2) !important;
  color: var(--ds-text-secondary);
  border-color: var(--ds-border) !important;
}
[data-theme="dark"] .table td,
[data-theme="dark"] .table th,
[data-theme="dark"] tbody td,
[data-theme="dark"] thead th { border-color: var(--ds-border) !important; }
[data-theme="dark"] .table-ds { background-color: var(--ds-surface); }
[data-theme="dark"] .table-ds tbody td { border-color: var(--ds-border) !important; }
[data-theme="dark"] .table-ds-hover tbody tr:hover { background: var(--ds-surface-hover) !important; }
[data-theme="dark"] .table-light { background-color: var(--ds-surface-2); color: var(--ds-text); }

/* ─── 按钮：outline-dark/outline-secondary/btn-dark/btn-light/btn-secondary 统一 ─── */
[data-theme="dark"] .btn-outline-secondary {
  color: var(--ds-text-secondary);
  border-color: var(--ds-border-strong);
}
[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--ds-surface-hover);
  color: var(--ds-text);
  border-color: var(--ds-primary);
}
[data-theme="dark"] .btn-outline-dark {
  color: var(--ds-text-secondary);
  border-color: var(--ds-border-strong);
}
[data-theme="dark"] .btn-outline-dark:hover {
  background: var(--ds-surface-hover);
  color: var(--ds-text);
  border-color: var(--ds-text-muted);
}
[data-theme="dark"] .btn-dark {
  background-color: var(--ds-surface-2);
  border-color: var(--ds-border-strong);
  color: var(--ds-text);
}
[data-theme="dark"] .btn-dark:hover {
  background-color: var(--ds-surface-hover);
  border-color: var(--ds-primary);
  color: var(--ds-text);
}
[data-theme="dark"] .btn-light {
  background-color: var(--ds-surface-2);
  border-color: var(--ds-border-strong);
  color: var(--ds-text);
}
[data-theme="dark"] .btn-light:hover {
  background-color: var(--ds-surface-hover);
  color: var(--ds-text);
}
[data-theme="dark"] .btn-secondary {
  background-color: #4b5563;
  border-color: #4b5563;
  color: #f3f4f6;
}
[data-theme="dark"] .btn-secondary:hover {
  background-color: #5b6573;
  border-color: #5b6573;
  color: #fff;
}

/* ─── 背景/文字工具类补全 ─── */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-light { color: var(--ds-text); }
[data-theme="dark"] .bg-dark {
  background-color: var(--ds-nav-bg) !important;
  color: var(--ds-text);
}

/* ─── 列表组 ─── */
[data-theme="dark"] .list-group-item {
  background-color: var(--ds-surface);
  color: var(--ds-text);
  border-color: var(--ds-border);
}
[data-theme="dark"] .list-group-item:hover { background-color: var(--ds-surface-hover); }
[data-theme="dark"] .list-group-ds .list-group-item:hover { background: var(--ds-surface-hover); }

/* ─── 标签页 nav-tabs ─── */
[data-theme="dark"] .nav-tabs { border-bottom-color: var(--ds-border); }
[data-theme="dark"] .nav-tabs .nav-link { color: var(--ds-text-secondary); }
[data-theme="dark"] .nav-tabs .nav-link:hover { color: var(--ds-primary); border-color: var(--ds-border); }
[data-theme="dark"] .nav-tabs .nav-link.active {
  color: var(--ds-primary);
  background-color: var(--ds-surface);
  border-color: var(--ds-border) var(--ds-border) var(--ds-surface);
}

/* ─── 下拉菜单 ─── */
[data-theme="dark"] .dropdown-menu {
  background-color: var(--ds-surface);
  border-color: var(--ds-border-strong);
}
[data-theme="dark"] .dropdown-menu .dropdown-item { color: var(--ds-text); }
[data-theme="dark"] .dropdown-menu .dropdown-item:hover,
[data-theme="dark"] .dropdown-menu .dropdown-item.active {
  background-color: var(--ds-surface-hover);
  color: var(--ds-text);
}
[data-theme="dark"] .dropdown-divider { border-color: var(--ds-border); }

/* ─── 模态框 / 卡片 ─── */
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--ds-border); }
[data-theme="dark"] .modal-header.text-white { color: #fff; }
[data-theme="dark"] .card { background-color: var(--ds-surface); border-color: var(--ds-border); color: var(--ds-text); }
[data-theme="dark"] .card-header { background-color: var(--ds-surface-2); border-color: var(--ds-border); color: var(--ds-text); }

/* ─── 页面通用组件（gantt/projects/review） ─── */
[data-theme="dark"] .tree-node { border-bottom-color: var(--ds-border); }
[data-theme="dark"] .tree-node:hover { background: var(--ds-surface-hover) !important; }
[data-theme="dark"] .tree-node.selected { background: var(--ds-surface-2) !important; outline-color: var(--ds-border-strong); }
[data-theme="dark"] .tree-progress-bar { background: var(--ds-surface-2); }
[data-theme="dark"] .tree-stats-badge { background: var(--ds-surface-2); color: var(--ds-text-secondary); }
[data-theme="dark"] .stage-chip { border-color: var(--ds-border-strong); color: var(--ds-text-secondary); background: var(--ds-surface); }
[data-theme="dark"] .stage-chip:hover { background: var(--ds-surface-hover); border-color: var(--ds-primary); }
[data-theme="dark"] .stage-chip.active { background: var(--ds-nav-bg); border-color: var(--ds-nav-bg); color: #fff; }
[data-theme="dark"] .deadline-overdue { background: var(--ds-danger-soft); color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .deadline-near { background: #3a2f14; color: #fcd34d; border-color: #78350f; }
[data-theme="dark"] .metric-amber { background: #3a2f14; }
[data-theme="dark"] .notif-panel,
[data-theme="dark"] .upload-floating-panel { background: var(--ds-surface); border-color: var(--ds-border-strong); }

/* ─── JS 行内浅背景孪生（属性选择器，仅暗色生效） ─── */
[data-theme="dark"] tr[style*="background:#f8f9fa"],
[data-theme="dark"] tr[style*="background:#fafafa"],
[data-theme="dark"] textarea[style*="background:#f8f9fa"] { background: var(--ds-surface-2) !important; }
[data-theme="dark"] td[style*="background:#fffbe6"] { background: #3a2f14 !important; }
[data-theme="dark"] tr[style*="background:#fffbf0"],
[data-theme="dark"] tr[style*="background-color:#fffbf0"] { background: #3a2f14 !important; }
[data-theme="dark"] mark[style*="background:#ffd54f"] { background: #7a5a00 !important; color: var(--ds-text) !important; }
[data-theme="dark"] #appLoadingOverlay { background: var(--ds-bg) !important; }
[data-theme="dark"] #quillEditor { background: var(--ds-surface) !important; color: var(--ds-text); }

/* ─── gantt 自定义工具栏按钮（inline #f0efed） ─── */
[data-theme="dark"] button[style*="background:#f0efed"] { background: var(--ds-surface-2) !important; color: var(--ds-text-secondary) !important; }
[data-theme="dark"] button[style*="background:#f0efed"]:hover { background: var(--ds-surface-hover) !important; color: var(--ds-text) !important; }

/* ─── gantt 网格 / 今日 / 周末列 ─── */
[data-theme="dark"] .gantt-grid .grid-cell { border-right-color: var(--ds-border); }
[data-theme="dark"] .gantt-grid .grid-cell.weekend { background: var(--ds-surface-2); }
[data-theme="dark"] .gantt-grid .grid-cell.today { background: var(--ds-primary-soft); border-right-color: var(--ds-primary); }

/* ─── gantt 日期行 / 行悬停 / 父行 / 详情面板 / 头部 ─── */
[data-theme="dark"] .gantt-day-row { border-bottom-color: var(--ds-border); }
[data-theme="dark"] .gantt-day-row .day-cell { color: var(--ds-text-muted); border-right-color: var(--ds-border); }
[data-theme="dark"] .gantt-day-row .day-cell.weekend { background: var(--ds-surface-2); color: var(--ds-text-muted); }
[data-theme="dark"] .gantt-day-row .day-cell.today { background: var(--ds-primary-soft); color: var(--ds-primary); }
[data-theme="dark"] .gantt-row { border-bottom-color: var(--ds-border); }
[data-theme="dark"] .gantt-row:hover { background: var(--ds-surface-hover); }
[data-theme="dark"] .gantt-row.parent-row { background: var(--ds-surface-2); }
[data-theme="dark"] #detailPanel { background: var(--ds-surface-2); border-top-color: var(--ds-border); }
[data-theme="dark"] .gantt-header { border-bottom-color: var(--ds-border); }
[data-theme="dark"] .gantt-month-row { border-bottom-color: var(--ds-border); }
[data-theme="dark"] .gantt-month-row .month-cell { color: var(--ds-text-secondary); border-right-color: var(--ds-border); }
[data-theme="dark"] .detail-section .field label { color: var(--ds-text-muted); }
[data-theme="dark"] .detail-section .field .value { color: var(--ds-text); }
[data-theme="dark"] .detail-section .section-title { color: var(--ds-text-muted); }

/* ─── 通知面板 / nav-pills 悬停 ─── */
[data-theme="dark"] .notif-item:hover { background: var(--ds-surface-hover) !important; }
[data-theme="dark"] .nav-pills .nav-link { color: var(--ds-text-secondary); }
[data-theme="dark"] .nav-pills .nav-link:hover { background: var(--ds-surface-hover) !important; color: var(--ds-text); }

/* ─── 暗色：模态关闭按钮（Bootstrap 默认黑 X，暗底隐形 → 反相变白） ─── */
[data-theme="dark"] .btn-close:not(.btn-close-white) { filter: invert(1) grayscale(100%) brightness(200%); }

/* ─── 暗色：outline 主按钮提亮（#0d6efd 暗底偏黑，用亮蓝） ─── */
[data-theme="dark"] .btn-outline-primary { color: #93c5fd; border-color: var(--ds-primary); }
[data-theme="dark"] .btn-outline-primary:hover,
[data-theme="dark"] .btn-outline-primary:focus { background: var(--ds-primary); border-color: var(--ds-primary); color: #fff; }

/* ─── 暗色：分页（Bootstrap .page-link 默认白底） ─── */
[data-theme="dark"] .pagination-ds .page-link { background-color: var(--ds-surface); }
[data-theme="dark"] .pagination-ds .page-link:hover { background-color: var(--ds-surface-hover); }

/* ─── 暗色：alert 浅粉底 → 暗色调（与 deadline/近逾期同族） ─── */
[data-theme="dark"] .alert-danger { background-color: #3b1517; border-color: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .alert-warning { background-color: #3a2f14; border-color: #78350f; color: #fcd34d; }
[data-theme="dark"] .alert-secondary { background-color: var(--ds-surface-2); border-color: var(--ds-border-strong); color: var(--ds-text-secondary); }

/* ─── 暗色：nav-tabs 悬停浅灰条 → 深底 hover ─── */
[data-theme="dark"] .nav-tabs .nav-link:hover { background-color: var(--ds-surface-hover); }

/* ─── 物料分类统计卡底色（projects L5127 兜底 var(--ds-card-bg,#f8f9fa) → var 间接随主题翻转） ─── */
:root { --ds-card-bg: var(--ds-surface-2); }

/* ─── 暗色：issues 时间线 hover / gantt entity-tag / gantt 图例 / projects 分类 tab hover ─── */
[data-theme="dark"] .timeline-box:hover { background-color: var(--ds-surface-hover); }
[data-theme="dark"] .tree-node .entity-tag { background: var(--ds-surface-2); color: var(--ds-text-secondary); }
[data-theme="dark"] .gantt-legend { border-top-color: var(--ds-border); color: var(--ds-text-muted); }
[data-theme="dark"] .category-tab:hover { background-color: var(--ds-surface-hover); border-color: var(--ds-border-strong); }

/* ─── 暗色：JS 生成的浅色内联样式（hover 后 this.style.background、区段标签分隔线） ─── */
[data-theme="dark"] label[style*="background:#f4f7fa"] { background: var(--ds-surface-hover) !important; }
[data-theme="dark"] div[style*="border-bottom:1px solid #e3e8ef"] { border-bottom-color: var(--ds-border) !important; color: var(--ds-text-muted) !important; }

/* ─── 暗色：form-select 下拉箭头（Bootstrap 默认深色 chevron 暗底隐形 → 亮色） ─── */
[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* ════════════════════════════════════════════════════════════════
   Industrial Console · 工业控制台风格 (2026-08, 工程蓝基础上深化)
   车间 SCADA 质感: 等宽数字 / 状态灯 / 编号面板 / 表格高密度
   ════════════════════════════════════════════════════════════════ */
:root {
  --ind-mono: 'JetBrains Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
  --ind-led-ok: #22c55e;
  --ind-led-warn: #f59e0b;
  --ind-led-err: #ef4444;
  --ind-grid: rgba(31,41,55,0.04);
}
[data-theme="dark"] { --ind-grid: rgba(148,163,184,0.05); }

/* ─── 全站数字等宽(工业表盘感) ─── */
body, .table, .ag-cell, .stat, .metric, .badge, .btn, .form-control, .form-select {
  font-variant-numeric: tabular-nums;
}
.ag-cell, .stat b, .stat .num {
  font-feature-settings: 'tnum';
}

/* ─── 蓝图网格背景(暗色模式微妙工业感) ─── */
[data-theme="dark"] body {
  background-image:
    linear-gradient(var(--ind-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--ind-grid) 1px, transparent 1px);
  background-size: 26px 26px;
}

/* ─── 工业面板卡: 细边框 + 左上编号角标 + 顶部分隔亮线 ─── */
.ind-panel {
  position: relative;
  border: 1px solid var(--ds-border);
  border-radius: 6px;
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-sm);
  overflow: hidden;
}
.ind-panel::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ds-accent), transparent 65%);
  pointer-events: none;
}
.ind-panel[data-tag]::before {
  content: attr(data-tag);
  position: absolute; top: 0; left: 0;
  font-family: var(--ind-mono);
  font-size: 10px; letter-spacing: 0.1em;
  color: var(--ds-accent);
  background: var(--ds-accent-soft);
  padding: 2px 8px;
  border-radius: 0 0 6px 0;
  border-right: 1px solid var(--ds-border);
  border-bottom: 1px solid var(--ds-border);
  z-index: 1;
}
.ind-panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--ds-border);
  background: var(--ds-surface-2);
  font-size: 0.8rem; font-weight: 600;
  color: var(--ds-text-secondary);
  letter-spacing: 0.03em;
}
.ind-panel-body { padding: 12px 14px; }

/* ─── 状态灯 (设备运行状态) ─── */
.ind-led {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ds-text-muted);
  box-shadow: 0 0 0 3px rgba(148,163,184,0.12);
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.ind-led.ok {
  background: var(--ind-led-ok);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.15), 0 0 8px rgba(34,197,94,0.35);
}
.ind-led.warn {
  background: var(--ind-led-warn);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15), 0 0 8px rgba(245,158,11,0.35);
}
.ind-led.err {
  background: var(--ind-led-err);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15), 0 0 8px rgba(239,68,68,0.35);
}
.ind-led.off { background: #64748b; box-shadow: 0 0 0 3px rgba(100,116,139,0.12); opacity: .55; }
.ind-led.info { background: var(--ds-info); box-shadow: 0 0 0 3px rgba(2,132,199,0.15), 0 0 8px rgba(2,132,199,0.30); }

/* ─── 表格工业化: 深表头 + 密度 + 等宽数字列 ─── */
.table thead th {
  background: var(--ds-surface-2);
  font-size: 0.75rem;
  letter-spacing: 0.045em;
  color: var(--ds-text-secondary);
  border-bottom: 2px solid var(--ds-border-strong);
  white-space: nowrap;
  font-weight: 600;
}
/* 语义色表头例外: 保留 Bootstrap table-warning/table-light 原色 */
.table thead.table-warning th, .table-warning thead th { background: var(--ds-warning); color: #fff; border-bottom-color: var(--ds-warning); }
.table thead.table-light th, .table-light thead th { background: var(--ds-surface-2); color: var(--ds-text); }
.table td.num, td.num, .num-cell {  text-align: right;
  font-family: var(--ind-mono);
  font-size: 0.86em;
}

/* ─── 导航下缘工程亮线(控制台感) ─── */
.nav-ds { border-bottom-color: rgba(37,99,235,0.35); }
[data-theme="dark"] .nav-ds { border-bottom-color: rgba(96,165,250,0.30); }

/* ─── 工业级状态徽章 ─── */
.badge-ind {
  font-family: var(--ind-mono);
  letter-spacing: 0.06em;
  border-radius: 3px;
  font-size: 0.7rem;
  padding: 2px 8px;
  border: 1px solid currentColor;
  opacity: .9;
}

/* ─── 等宽大数字(统计卡/仪表值) ─── */
.ind-bignum {
  font-family: var(--ind-mono);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--ds-text);
  font-variant-numeric: tabular-nums;
}
.ind-bignum small { font-size: 0.65em; color: var(--ds-text-muted); font-weight: 500; }
