/* ========================================================================
   WorkBuddy · 培训项目管理系统 · v20260603
   设计系统基于 DESIGN.md · 厦大蓝 #005A8F · 嘉庚红 #9E2A2B
   参考厦门大学继续教育学院官网 (cce_website) 设计语言
   ======================================================================== */

/* ===== CSS Variables ===== */
:root {
  /* Brand Colors - 厦大蓝 */
  --color-brand: #005A8F;
  --color-brand-dark: #004070;
  --color-brand-light: #E8F0F8;

  /* Accent Colors - 嘉庚红 */
  --color-accent: #9E2A2B;
  --color-accent-light: #F9E8E8;

  /* Semantic Colors */
  --color-success: #16A34A;
  --color-warning: #EA8C20;
  --color-error: #DC2626;
  --color-info: #2563EB;

  /* Soft Backgrounds (for badges, alerts, stats icons) */
  --color-success-soft: #E8F5E9;
  --color-warning-soft: #FFF3E0;
  --color-error-soft: #FEE2E2;
  --color-info-soft: #E0E7FF;

  /* Neutral Colors */
  --color-text-primary: #1B1F28;
  --color-text-secondary: #5A6573;
  --color-text-tertiary: #6B7280;
  --color-bg: #F6F8FA;
  --color-surface: #FFFFFF;
  --color-bg-subtle: #ECEFF2;
  --color-border: #E2E6EC;
  --color-border-light: #F0F2F5;

  /* Shadow Colors */
  --shadow-color-xs: rgba(0, 36, 60, 0.06);
  --shadow-color-sm: rgba(0, 36, 60, 0.08);
  --shadow-color-md: rgba(0, 36, 60, 0.10);
  --shadow-color-lg: rgba(0, 36, 60, 0.16);

  /* Shadows */
  --shadow-xs: 0 1px 2px var(--shadow-color-xs);
  --shadow-sm: 0 1px 3px var(--shadow-color-xs), 0 1px 2px var(--shadow-color-xs);
  --shadow-md: 0 4px 6px var(--shadow-color-sm), 0 2px 4px var(--shadow-color-xs);
  --shadow-lg: 0 10px 15px var(--shadow-color-md), 0 4px 6px var(--shadow-color-sm);
  --shadow-xl: 0 20px 25px var(--shadow-color-lg), 0 10px 10px var(--shadow-color-md);

  /* Typography */
  --font-sans: "PingFang SC", "Microsoft YaHei", "Inter", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;

  --text-display: clamp(28px, 5vw, 40px);
  --text-h1: clamp(22px, 3vw, 28px);
  --text-h2: clamp(18px, 2.5vw, 22px);
  --text-h3: 18px;
  --text-h4: 16px;
  --text-body: 14px;
  --text-body-lg: 16px;
  --text-small: 13px;
  --text-nano: 12px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --nav-height: 60px;
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --container-max: 1400px;
  --container-padding: 20px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* Respect user motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.6;
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--color-brand); text-decoration: none; }
a:hover { color: var(--color-brand-dark); }

/* ===== Layout ===== */
.app {
  display: flex;
  min-height: 100vh;
  padding-top: var(--nav-height);
}

/* ===== Top Navbar (F-layout) ===== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  z-index: 200;
  padding: 0 var(--container-padding);
}
.navbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.navbar-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.navbar-logo img {
  height: 32px;
  width: auto;
}
.navbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 var(--space-6);
}
.navbar-search {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 400px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0 var(--space-3);
  transition: all 150ms ease;
}
.navbar-search:focus-within {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-light);
}
.navbar-search input[type="text"] {
  background: transparent;
  border: 0;
  outline: 0;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  padding: 7px var(--space-2);
  font-size: var(--text-small);
  color: var(--color-text-primary);
}
.navbar-search input[type="text"]::placeholder {
  color: var(--color-text-tertiary);
}
.navbar-search svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-tertiary);
  flex-shrink: 0;
  margin-left: var(--space-1);
}
.navbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.navbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  cursor: pointer;
  position: relative;
  transition: all 150ms ease;
  text-decoration: none;
}
.navbar-btn:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}
.navbar-btn svg {
  width: 20px;
  height: 20px;
}
.navbar-btn .notification-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: var(--color-accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.navbar-user {
  display: flex;
  align-items: center;
  position: relative;
  margin-left: var(--space-1);
}
.navbar-user .user-avatar-btn {
  width: 34px; height: 34px;
  background: var(--color-brand-light);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
  font-weight: 600;
  font-size: var(--text-body);
  text-decoration: none;
  cursor: pointer;
  transition: all 150ms ease;
  overflow: hidden;
  flex-shrink: 0;
}
.navbar-user .user-avatar-btn:hover { background: var(--color-brand); color: white; }
.navbar-user .user-avatar-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.navbar-user .user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: var(--space-3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 200ms ease;
  z-index: 200;
}
.navbar-user:hover .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: var(--nav-height); left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--nav-height));
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 250ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* ── Sidebar Header (Toggle only) ── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
  min-height: 48px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  text-decoration: none;
  transition: opacity 150ms ease;
}
.sidebar-logo img {
  height: 36px;
  width: auto;
  display: block;
}
/* Logo 主题切换：light 模式显示深色，dark 模式显示白色 */
.logo-dark { display: none; }
html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: block; }

/* ── Sidebar Toggle ── */
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: all 150ms ease;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--color-bg); color: var(--color-text-primary); }
.sidebar-toggle-btn svg { width: 18px; height: 18px; transition: transform 250ms ease; }

/* ── Sidebar Menu (nav items, takes remaining space) ── */
.sidebar-menu {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-2);
}
.sidebar-section { margin-bottom: var(--space-4); }
.sidebar-item { margin-bottom: var(--space-1); }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--text-body);
  font-weight: 500;
  white-space: nowrap;
  transition: all 150ms ease;
  position: relative;
}
.sidebar-link span { transition: opacity 150ms ease; }
.sidebar-link:hover { background: var(--color-brand-light); color: var(--color-text-primary); }
.sidebar-link.active { background: var(--color-brand-light); color: var(--color-brand); }
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--color-brand);
  border-radius: 0 2px 2px 0;
}
.sidebar-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* Tooltip for collapsed sidebar */
.sidebar-tooltip {
  position: absolute;
  left: calc(var(--sidebar-collapsed) + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-text-primary);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
  z-index: 200;
  box-shadow: var(--shadow-md);
}
.sidebar.collapsed .sidebar-link:hover .sidebar-tooltip { opacity: 1; }

/* ── Sidebar Footer (Notif + User) ── */
.sidebar-footer {
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--color-border-light);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.sidebar-notif-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all 150ms ease;
  position: relative;
}
.sidebar-notif-btn:hover { background: var(--color-brand-light); color: var(--color-text-primary); }
.sidebar-notif-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-notif-btn .notif-label {
  font-size: var(--text-body);
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 150ms ease;
}
.sidebar-notif-btn .notification-badge {
  position: absolute;
  top: 4px; left: 22px;
  min-width: 16px; height: 16px;
  background: var(--color-accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* Sidebar User */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 150ms ease;
  position: relative;
}
.sidebar-user:hover { background: var(--color-brand-light); }
.sidebar-user .user-menu-wrapper { position: relative; }
.sidebar-user .user-avatar-btn {
  width: 36px; height: 36px;
  background: var(--color-brand-light);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
  font-weight: 600;
  font-size: var(--text-body);
  text-decoration: none;
  cursor: pointer;
  transition: all 150ms ease;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-user .user-avatar-btn:hover { background: var(--color-brand); color: white; }
.sidebar-user .user-avatar-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.sidebar-user-info {
  flex: 1;
  min-width: 0;
  transition: opacity 150ms ease;
}
.sidebar-user-name {
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: var(--text-nano);
  color: var(--color-text-tertiary);
}

/* User dropdown (在sidebar底部向上弹出) */
.sidebar-user .user-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: var(--space-3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: all 200ms ease;
  z-index: 200;
}
.sidebar-user:hover .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.user-dropdown-name {
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}
.user-dropdown-role {
  font-size: var(--text-nano);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-2);
}
.user-dropdown-dept {
  font-size: var(--text-nano);
  color: var(--color-brand);
  margin-bottom: 2px;
}
.user-dropdown-divider {
  border-top: 1px solid var(--color-border-light);
  margin: var(--space-2) 0;
}
.user-dropdown-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 150ms ease;
}
.user-dropdown-link:hover { background: var(--color-brand-light); color: var(--color-brand); }

/* ── Collapsed State ── */
.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}
.sidebar.collapsed .sidebar-logo {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-toggle-btn { margin: 4px auto; }
.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 10px 4px;
  gap: 0;
}
.sidebar.collapsed .sidebar-link span { display: none; }
.sidebar.collapsed .sidebar-link .sidebar-icon { margin: 0; }
.sidebar.collapsed .sidebar-link.active::before {
  left: -4px; width: 3px; height: 24px;
}
.sidebar.collapsed .sidebar-menu { padding: var(--space-3) 0; }
.sidebar.collapsed .sidebar-section { margin-left: 0; }
.sidebar.collapsed .sidebar-submenu-toggle { justify-content: center; padding: 10px 4px; }
.sidebar.collapsed .sidebar-submenu-toggle .chevron,
.sidebar.collapsed .sidebar-submenu-toggle > span { display: none; }
.sidebar.collapsed .sidebar-submenu-toggle > svg:not(.chevron) { margin: 0; }
.sidebar.collapsed .sidebar-submenu .sidebar-item { margin-left: 0; }
.sidebar.collapsed .sidebar-submenu .sidebar-link { justify-content: center; padding-left: 4px; }
.sidebar.collapsed .sidebar-notif-btn .notif-label { display: none; }
.sidebar.collapsed .sidebar-notif-btn { justify-content: center; padding: 8px; }
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 4px 0; }

/* Submenu */
.sidebar-submenu-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-body);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 150ms ease;
  white-space: nowrap;
}
.sidebar-submenu-toggle:hover { background: var(--color-brand-light); color: var(--color-text-primary); }
.sidebar-submenu-toggle .chevron {
  width: 14px; height: 14px;
  margin-left: auto;
  transition: transform 200ms ease;
  flex-shrink: 0;
}
.sidebar-submenu-toggle.open .chevron { transform: rotate(90deg); }
.sidebar-submenu {
  overflow: hidden;
  max-height: 0;
  transition: max-height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-submenu.open { max-height: 200px; }
.sidebar-submenu .sidebar-item { margin-left: var(--space-2); }

/* ===== Main Content ===== */
.main-content, .main {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-top: 0;
  padding: var(--space-8) var(--container-padding);
  max-width: calc(var(--container-max) + var(--sidebar-width));
  transition: margin-left 250ms cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed ~ .main-content,
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-collapsed); }
.main-content.full { margin-left: 0; } /* no sidebar */
.main.full { margin-left: 0; }

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  padding: 0 var(--container-padding);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  margin: calc(-1 * var(--space-8)) calc(-1 * var(--container-padding)) var(--space-6) calc(-1 * var(--container-padding));
  flex-wrap: wrap;
  gap: var(--space-3);
}
/* 紧邻筛选 card：兜底保障间距 */
.page-header + .card { margin-top: var(--space-6); }
.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.page-subtitle {
  font-size: var(--text-body);
  color: var(--color-text-secondary);
}

/* ===== Buttons (cce_website style) ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: var(--text-body);
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  line-height: 1.4;
  font-family: inherit;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { box-shadow: inset 0 1px 3px rgba(0,0,0,0.12); }
.btn-primary {
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0,90,143,0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-brand-dark) 0%, #003b66 100%);
  box-shadow: 0 6px 20px rgba(0,90,143,0.35);
}
.btn-secondary {
  background: transparent;
  color: var(--color-brand);
  border: 1.5px solid var(--color-brand);
}
.btn-secondary:hover { background: var(--color-brand-light); box-shadow: var(--shadow-xs); }
.btn-ghost { background: transparent; color: var(--color-text-secondary); }
.btn-ghost:hover { background: var(--color-brand-light); color: var(--color-brand); }
.btn-danger { background: var(--color-error); color: white; }
.btn-danger:hover { opacity: 0.9; box-shadow: 0 4px 12px rgba(220,38,38,0.25); }
.btn-accent {
  background: linear-gradient(135deg, var(--color-accent) 0%, #7B1F1F 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(158,42,43,0.25);
}
.btn-accent:hover { box-shadow: 0 6px 20px rgba(158,42,43,0.35); }
.btn-success { background: var(--color-success); color: white; }
.btn-success:hover { opacity: 0.9; box-shadow: 0 4px 12px rgba(16,185,129,0.25); }
.btn-outline { background: transparent; border: 1.5px solid var(--color-border); color: var(--color-text-secondary); }
.btn-outline:hover { border-color: var(--color-brand); color: var(--color-brand); background: var(--color-brand-light); }
.btn-sm { padding: 6px 14px; font-size: var(--text-small); border-radius: var(--radius-full); }
.btn-lg { padding: 14px 28px; font-size: var(--text-body-lg); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: var(--space-5);
  cursor: pointer;
  transition: box-shadow 200ms ease, border-color 200ms ease;
  margin-bottom: var(--space-4);
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--color-border); }
.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-light);
  background: transparent;
}
.card-header svg { flex-shrink: 0; }
.card-title {
  font-size: var(--text-h4);
  font-weight: 600;
  color: var(--color-text-primary);
}
.card-footer {
  padding: var(--space-4) 20px;
  border-top: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.card-body { padding: var(--space-5); }
.card-body.p-0 { padding: 0; }
.card .card-title-sm {
  font-size: var(--text-h4);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: var(--space-5);
  transition: all var(--transition-normal);
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.stat-label {
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  font-weight: 500;
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; }
.stat-icon.blue { background: var(--color-brand-light); color: var(--color-brand); }
.stat-icon.red { background: var(--color-accent-light); color: var(--color-accent); }
.stat-icon.green { background: var(--color-success-soft); color: var(--color-success); }
.stat-icon.orange { background: var(--color-warning-soft); color: var(--color-warning); }
.stat-value {
  font-size: var(--text-display);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
  margin: var(--space-2) 0;
}
.stat-change { font-size: var(--text-small); font-weight: 500; color: var(--color-text-tertiary); }
.stat-change.up { color: var(--color-success); }
.stat-change.down { color: var(--color-error); }

/* ===== Dashboard v2 ===== */
.dash-stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
}
.dash-stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.dash-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: var(--stat-gradient);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.dash-stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--stat-gradient);
  color: white;
}
.dash-stat-icon svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}
.dash-stat-body { flex: 1; min-width: 0; }
.dash-stat-label {
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: 2px;
}
.dash-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}
.dash-stat-sub {
  font-size: 12px;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.dot-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-border);
  display: inline-block;
}

/* Dashboard rows */
.dash-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.dash-row-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

/* Quick action grid */
.dash-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
.dash-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--transition-fast);
  text-align: center;
}
.dash-action-card:hover {
  border-color: var(--ac, var(--color-brand));
  box-shadow: var(--shadow-sm);
  background: var(--color-bg);
}
.dash-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dash-action-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.dash-action-label {
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-primary);
}
.dash-action-card small {
  font-size: 11px;
  color: var(--color-text-tertiary);
  line-height: 1.3;
}

/* Dash more link (卡片右上角链接) */
.dash-more-link {
  margin-left: auto;
  font-size: var(--text-small);
  font-weight: 500;
  color: var(--color-brand);
  text-decoration: none;
  white-space: nowrap;
}
.dash-more-link:hover {
  text-decoration: underline;
}

/* Dashboard compact table */
.dash-table {
  width: 100%;
  border-collapse: collapse;
}
.dash-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg);
}
.dash-table td {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-body);
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-primary);
}
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr:hover td { background: var(--color-bg); }

/* Card body overrides */
.card-body .empty-state {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--color-text-tertiary);
}
.card-body .empty-state svg {
  width: 36px;
  height: 36px;
  stroke: var(--color-border);
  fill: none;
  margin-bottom: var(--space-2);
}
.card-body .empty-state p {
  font-size: var(--text-small);
  margin: 0;
}

@media (max-width: 900px) {
  .dash-row-2col { grid-template-columns: 1fr; }
  .dash-row-3col { grid-template-columns: 1fr; }
  .dash-actions-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1200px) and (min-width: 901px) {
  .dash-row-3col { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .dash-actions-grid { grid-template-columns: 1fr 1fr; }
}
.quick-access {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.quick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  transition: all var(--transition-normal);
}
.quick-card:hover { box-shadow: var(--shadow-md); border-color: var(--color-brand); }
.quick-icon {
  width: 48px; height: 48px;
  background: var(--color-brand-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
}
.quick-icon svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.quick-title { font-size: var(--text-body); font-weight: 600; color: var(--color-text-primary); }
.quick-desc { font-size: var(--text-small); color: var(--color-text-secondary); text-align: center; }

/* ===== Search Input ===== */
.search-input { position: relative; max-width: 320px; }
.search-input input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-body);
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: all 150ms ease;
}
.search-input input:focus { outline: none; border-color: var(--color-brand); box-shadow: 0 0 0 3px rgba(0, 90, 143, 0.12); }
.search-input input::placeholder { color: var(--color-text-tertiary); }
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

/* ===== Table Cell (inline flex row) ===== */
.table-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--text-nano);
  font-weight: 500;
  white-space: nowrap;
}
.badge-brand { background: var(--color-brand-light); color: var(--color-brand); }
.badge-accent { background: var(--color-accent-light); color: var(--color-accent); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-error { background: var(--color-error-soft); color: var(--color-error); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }

/* Bootstrap compatibility badges */
.bg-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.bg-info { background: var(--color-info-soft); color: var(--color-info); }
.bg-success { background: var(--color-success-soft); color: var(--color-success); }
.bg-danger { background: var(--color-error-soft); color: var(--color-error); }
.text-dark { color: var(--color-text-primary); }

/* ===== Table (优化后，统一且唯一) ===== */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
table th {
  background: var(--color-brand-light);
  padding: 12px 20px;
  text-align: left;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}
table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-body);
  vertical-align: middle;
}
.table-cell-ellipsis {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table tr:last-child td { border-bottom: none; }
table tr:nth-child(even) { background: var(--color-bg); }
table tr:hover { background: var(--color-bg-subtle); }
.table-responsive { overflow-x: auto; }
.text-muted { color: var(--color-text-tertiary); }
small.text-muted { color: var(--color-text-tertiary); }

/* ===== Forms ===== */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}
.form-label .hint { font-weight: 400; color: var(--color-text-tertiary); }
.form-label .required { color: var(--color-accent); }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-body);
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text-primary);
  transition: all 150ms ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(0, 90, 143, 0.12);
}
input::placeholder, textarea::placeholder { color: var(--color-text-tertiary); }
textarea { min-height: 80px; resize: vertical; }
select { cursor: pointer; }
.form-control-lg { padding: 14px 18px; font-size: var(--text-body-lg); }

/* ===== Auth Page ===== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-brand-dark) 0%, var(--color-brand) 50%, #0077B5 100%);
  padding: var(--space-5);
}
.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
}
.auth-header { text-align: center; margin-bottom: var(--space-8); }
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px; height: 60px;
  background: var(--color-brand);
  color: white;
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
}
.auth-header h1 {
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
}
.auth-header p {
  font-size: var(--text-small);
  color: var(--color-text-tertiary);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.toast-msg {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-brand);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: var(--text-body);
  animation: toast-in 0.3s ease-out;
  min-width: 280px;
}
.toast-msg.success { border-left-color: var(--color-success); }
.toast-msg.error { border-left-color: var(--color-error); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  color: var(--color-text-tertiary);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin-bottom: var(--space-4);
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}
.empty-state p { font-size: var(--text-body); margin-bottom: var(--space-4); }

/* ===== Chart Container ===== */
.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.chart-container h5 {
  font-size: var(--text-h4);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

/* ===== Alert ===== */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-body);
  margin-bottom: var(--space-4);
}
.alert-success {
  background: var(--color-success-soft);
  color: var(--color-success);
  border-left: 4px solid var(--color-success);
}
.alert-danger {
  background: var(--color-error-soft);
  color: var(--color-error);
  border-left: 4px solid var(--color-error);
}
.alert-info {
  background: var(--color-brand-light);
  color: var(--color-brand);
  border-left: 4px solid var(--color-brand);
}
.alert-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border-left: 4px solid var(--color-warning);
}

/* ========================================================================
   Utility Classes — 语义化工具类
   ======================================================================== */

/* ── Grid System (row/col) ── */
.row { display: flex; flex-wrap: wrap; margin: 0 calc(var(--space-4) / -2); }
.row > * { padding: 0 calc(var(--space-4) / 2); }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }
.col-md-9 { flex: 0 0 75%; max-width: 75%; }
.col-md-8 { flex: 0 0 66.6667%; max-width: 66.6667%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-4 { flex: 0 0 33.3333%; max-width: 33.3333%; }
.col-md-3 { flex: 0 0 25%; max-width: 25%; }

/* ── Display ── */
.d-none { display: none; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-grid { display: grid; }

/* ── Flex Container ── */
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.flex-1 { flex: 1; min-width: 0; }
.flex-auto { flex: auto; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-grow-0 { flex-grow: 0; }
.flex-grow-1 { flex-grow: 1; }

/* ── Flex Alignment (简写: ai=align-items, jc=justify-content) ── */
.ai-start { align-items: flex-start; }
.ai-center { align-items: center; }
.ai-end { align-items: flex-end; }
.ai-stretch { align-items: stretch; }
.ai-baseline { align-items: baseline; }
.jc-start { justify-content: flex-start; }
.jc-center { justify-content: center; }
.jc-end { justify-content: flex-end; }
.jc-between { justify-content: space-between; }
.jc-around { justify-content: space-around; }

/* ── Backward compat long-form aliases ── */
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }

/* ── Gap (space-1=4px ~ space-6=24px, space-8=32px) ── */
.gap-0 { gap: 0; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ── Padding (p=all, px=left+right, py=top+bottom, pt/pb/pl/pr) ── */
.p-0 { padding: 0; }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }
.px-0 { padding-left: 0; padding-right: 0; }
.px-1 { padding-left: var(--space-1); padding-right: var(--space-1); }
.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-5 { padding-left: var(--space-5); padding-right: var(--space-5); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.py-0 { padding-top: 0; padding-bottom: 0; }
.py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-5 { padding-top: var(--space-5); padding-bottom: var(--space-5); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }
.pt-0 { padding-top: 0; }
.pt-1 { padding-top: var(--space-1); }
.pt-2 { padding-top: var(--space-2); }
.pt-3 { padding-top: var(--space-3); }
.pt-4 { padding-top: var(--space-4); }
.pt-5 { padding-top: var(--space-5); }
.pt-6 { padding-top: var(--space-6); }
.pb-0 { padding-bottom: 0; }
.pb-1 { padding-bottom: var(--space-1); }
.pb-2 { padding-bottom: var(--space-2); }
.pb-3 { padding-bottom: var(--space-3); }
.pb-4 { padding-bottom: var(--space-4); }
.pb-5 { padding-bottom: var(--space-5); }
.pb-6 { padding-bottom: var(--space-6); }
.pl-0 { padding-left: 0; }
.pl-1 { padding-left: var(--space-1); }
.pl-2 { padding-left: var(--space-2); }
.pl-3 { padding-left: var(--space-3); }
.pl-4 { padding-left: var(--space-4); }
.pr-0 { padding-right: 0; }
.pr-1 { padding-right: var(--space-1); }
.pr-2 { padding-right: var(--space-2); }
.pr-3 { padding-right: var(--space-3); }
.pr-4 { padding-right: var(--space-4); }

/* ── Margin ── */
.m-0 { margin: 0; }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-5 { margin: var(--space-5); }
.m-6 { margin: var(--space-6); }
.mx-auto { margin-left: auto; margin-right: auto; }
.mx-0 { margin-left: 0; margin-right: 0; }
.mx-1 { margin-left: var(--space-1); margin-right: var(--space-1); }
.mx-2 { margin-left: var(--space-2); margin-right: var(--space-2); }
.mx-3 { margin-left: var(--space-3); margin-right: var(--space-3); }
.mx-4 { margin-left: var(--space-4); margin-right: var(--space-4); }
.my-0 { margin-top: 0; margin-bottom: 0; }
.my-1 { margin-top: var(--space-1); margin-bottom: var(--space-1); }
.my-2 { margin-top: var(--space-2); margin-bottom: var(--space-2); }
.my-3 { margin-top: var(--space-3); margin-bottom: var(--space-3); }
.my-4 { margin-top: var(--space-4); margin-bottom: var(--space-4); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.ml-0 { margin-left: 0; }
.ml-1 { margin-left: var(--space-1); }
.ml-2 { margin-left: var(--space-2); }
.ml-3 { margin-left: var(--space-3); }
.ml-4 { margin-left: var(--space-4); }
.mr-0 { margin-right: 0; }
.mr-1 { margin-right: var(--space-1); }
.mr-2 { margin-right: var(--space-2); }
.mr-3 { margin-right: var(--space-3); }
.mr-4 { margin-right: var(--space-4); }

/* ── Backward compat old spacing names (keep until templates migrated) ── */
.mt-3-old { margin-top: var(--space-4); }  /* old mt-3 was 16px */
.mt-2-old { margin-top: var(--space-3); }  /* old mt-2 was 12px */
.me-2 { margin-right: var(--space-2); }
.me-3 { margin-right: var(--space-4); }
.ms-1 { margin-left: var(--space-1); }
.ms-2 { margin-left: var(--space-2); }

/* ── Typography ── */
.text-xs { font-size: var(--text-nano); }
.text-sm { font-size: var(--text-small); }
.text-body { font-size: var(--text-body); }
.text-lg { font-size: var(--text-body-lg); }
.text-h1 { font-size: var(--text-h1); font-weight: 700; }
.text-h2 { font-size: var(--text-h2); font-weight: 700; }
.text-h3 { font-size: var(--text-h3); font-weight: 600; }
.text-h4 { font-size: var(--text-h4); font-weight: 600; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-end { text-align: right; }
.text-nowrap { white-space: nowrap; }
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-normal { font-weight: 400; }
.text-medium { font-weight: 500; }
.text-semibold { font-weight: 600; }
.text-bold { font-weight: 700; }
.text-muted { color: var(--color-text-tertiary); }
.text-brand { color: var(--color-brand); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-error); }
.text-secondary { color: var(--color-text-secondary); }
.text-primary { color: var(--color-brand); }
.text-white { color: #fff; }
.text-inherit { color: inherit; }
.text-underline { text-decoration: underline; }
.text-no-underline { text-decoration: none; }
.lh-1 { line-height: 1; }
.lh-1_2 { line-height: 1.2; }
.lh-1_4 { line-height: 1.4; }
.lh-1_6 { line-height: 1.6; }

/* ── Background ── */
.bg-surface { background: var(--color-surface); }
.bg-page { background: var(--color-bg); }
.bg-subtle { background: var(--color-bg-subtle); }
.bg-brand-soft { background: var(--color-brand-light); }
.bg-accent-soft { background: var(--color-accent-light); }
.bg-success-soft { background: var(--color-success-soft); }
.bg-warning-soft { background: var(--color-warning-soft); }
.bg-error-soft { background: var(--color-error-soft); }
.bg-info-soft { background: var(--color-info-soft); }
.bg-transparent { background: transparent; }

/* ── Backward compat old background aliases ── */
.bg-white { background: var(--color-surface); }
.bg-light { background: var(--color-bg); }

/* ── Position & Overflow ── */
.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-sticky { position: sticky; }
.position-fixed { position: fixed; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-visible { overflow: visible; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.user-select-none { user-select: none; }
.pointer-events-none { pointer-events: none; }

/* ── Width & Height ── */
.w-100 { width: 100%; }
.w-auto { width: auto; }
.w-50 { width: 50%; }
.h-100 { height: 100%; }
.h-auto { height: auto; }
.min-w-0 { min-width: 0; }
.max-w-full { max-width: 100%; }

/* ── Border ── */
.border { border: 1px solid var(--color-border); }
.border-none { border: none; }
.border-top { border-top: 1px solid var(--color-border-light); }
.border-bottom { border-bottom: 1px solid var(--color-border-light); }
.border-left { border-left: 1px solid var(--color-border-light); }
.border-right { border-right: 1px solid var(--color-border-light); }
.border-brand { border-color: var(--color-brand); }
.border-error { border-color: var(--color-error); }
.border-success { border-color: var(--color-success); }

/* ── Border Radius ── */
.rounded { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.rounded-0 { border-radius: 0; }
.rounded-top-0 { border-top-left-radius: 0; border-top-right-radius: 0; }

/* ── Shadow ── */
.shadow-xs { box-shadow: var(--shadow-xs); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-none { box-shadow: none; }

/* ===== List Group (for plan history) ===== */
.list-group-item {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}
.list-group-item:last-child { border-bottom: none; }
.list-group-item strong { font-size: var(--text-body); color: var(--color-text-primary); }
.list-group-item small { font-size: var(--text-small); color: var(--color-text-tertiary); }

/* ===== Section ===== */
.section { margin-bottom: var(--space-8); }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.section-title {
  font-size: var(--text-h2);
  font-weight: 600;
  color: var(--color-text-primary);
}

/* ===== User Badge & Avatar ===== */
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
}
.user-badge:hover { background: var(--color-bg); }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--color-brand-light);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
  font-weight: 600;
  font-size: var(--text-small);
}

/* ===== Markdown Preview ===== */
.markdown-body {
  max-width: 820px;
  margin: 0 auto;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-8) var(--space-10);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-xs);
  line-height: 1.75;
  color: var(--color-text-primary);
  font-size: var(--text-body);
}
.markdown-body h1, .markdown-body h2 {
  color: var(--color-brand);
  border-bottom: 2px solid var(--color-brand-light);
  padding-bottom: var(--space-2);
  margin: var(--space-6) 0 var(--space-4);
  font-weight: 600;
}
.markdown-body h1 { font-size: var(--text-h1); }
.markdown-body h2 { font-size: var(--text-h2); border-left: 4px solid var(--color-accent); padding-left: var(--space-3); }
.markdown-body h3 { font-size: var(--text-h3); color: var(--color-text-primary); margin: var(--space-5) 0 var(--space-3); }
.markdown-body h4 { font-size: var(--text-h4); margin: var(--space-4) 0 var(--space-2); }
.markdown-body p { margin-bottom: var(--space-3); }
.markdown-body ul, .markdown-body ol { padding-left: var(--space-6); margin-bottom: var(--space-3); }
.markdown-body li { margin-bottom: var(--space-1); }
.markdown-body table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  margin: var(--space-4) 0;
  font-size: var(--text-small);
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  white-space: nowrap;
}
.markdown-body td:last-child {
  white-space: normal;
}
.markdown-body th { background: var(--color-bg); font-weight: 600; color: var(--color-text-primary); }
.markdown-body blockquote {
  border-left: 4px solid var(--color-accent);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-4) 0;
  background: var(--color-accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text-secondary);
}
.markdown-body code {
  background: var(--color-bg-subtle);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.85em;
}
.markdown-body pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.82rem;
}
.markdown-body pre code { background: none; padding: 0; color: inherit; }
.markdown-body hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-6) 0; }
.markdown-body a { color: var(--color-brand); text-decoration: underline; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); }

/* ===== Edit Page Layout (对话修改) ===== */
.edit-layout {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--color-bg);
  z-index: 100;
}
.edit-preview {
  flex: 6;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.preview-toolbar .title-area { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.preview-toolbar .title-area h4 {
  margin: 0;
  font-size: var(--text-body);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-toolbar .title-area .client-tag {
  font-size: var(--text-nano);
  color: var(--color-text-tertiary);
  background: var(--color-bg);
  padding: 2px var(--space-2);
  border-radius: 4px;
  flex-shrink: 0;
}
.preview-toolbar .actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}
.scroll-pane {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6) var(--space-8);
  background: var(--color-surface);
}
@media (max-width: 900px) {
  .edit-layout { flex-direction: column; }
  .edit-preview { max-height: 50vh; }
}

/* ===== Chat Panel ===== */
.chat-panel {
  flex: 4;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
}
.chat-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
}
.chat-panel .panel-header h5 {
  margin: 0;
  font-size: var(--text-body);
  color: var(--color-text-primary);
  font-weight: 600;
}
.chat-panel .panel-header .close-link {
  font-size: var(--text-small);
  color: var(--color-text-tertiary);
  text-decoration: none;
}
.chat-panel .panel-header .close-link:hover { color: var(--color-brand); }
.suggestion-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}
.suggestion-chip {
  font-size: var(--text-nano);
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--color-text-secondary);
  background: var(--color-brand-light);
  white-space: nowrap;
  transition: all 150ms ease;
}
.suggestion-chip:hover { border-color: var(--color-brand); color: #fff; background: var(--color-brand); }
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  line-height: 1.55;
  max-width: 92%;
  word-break: break-word;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg.user {
  align-self: flex-end;
  background: var(--color-brand);
  color: var(--color-surface);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.ai {
  align-self: flex-start;
  background: var(--color-bg);
  color: var(--color-text-primary);
  border-bottom-left-radius: 4px;
  /* 优化：增加内边距、最大宽度、阴影 */
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  max-width: 85%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.msg.ai .label { font-size: var(--text-nano); color: var(--color-text-tertiary); margin-bottom: var(--space-1); display: block; font-weight: 600; }
.msg.system {
  align-self: center;
  background: var(--color-brand-light);
  color: var(--color-brand);
  font-size: var(--text-nano);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  max-width: 100%;
  text-align: center;
}
.chat-input {
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
}
.chat-input .input-wrap {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}
.chat-input textarea {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--text-body);
  resize: none;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}
.chat-input textarea:focus { border-color: var(--color-brand); box-shadow: 0 0 0 2px rgba(0,90,143,0.12); }
.send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--color-brand);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 150ms ease;
}
.send-btn:hover:not(:disabled) { background: var(--color-brand-dark); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2.5; fill: none; }
.edit-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--color-brand);
  border-top-color: transparent;
  border-radius: 50%;
  animation: edit-spin 0.6s linear infinite;
}
@keyframes edit-spin { to { transform: rotate(360deg); } }
.thinking-box {
  background: var(--color-bg);
  border-left: 3px solid var(--color-accent);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-1);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}
/* Markdown 元素样式 */
.thinking-box h1, .thinking-box h2, .thinking-box h3 {
  margin-top: var(--space-2);
  margin-bottom: var(--space-1);
  font-weight: 600;
}
.thinking-box p {
  margin-bottom: var(--space-2);
}
.thinking-box ul, .thinking-box ol {
  padding-left: var(--space-4);
  margin-bottom: var(--space-2);
}
.thinking-box code {
  background: var(--color-bg-secondary);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}
.thinking-box pre {
  background: var(--color-bg-secondary);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: var(--space-2);
}
.empty-preview { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--color-text-tertiary); font-size: var(--text-body); }

/* ===== Model Selector ===== */
.model-selector-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border-light);
  background: var(--color-bg);
  flex-shrink: 0;
  font-size: var(--text-small);
}
.model-selector-label { color: var(--color-text-tertiary); white-space: nowrap; }
.model-selector-dropdown { position: relative; flex: 1; }
.model-selector-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--text-small);
  cursor: pointer;
  transition: all 150ms ease;
}
.model-selector-btn:hover { border-color: var(--color-brand); color: var(--color-brand); background: var(--color-brand-light); }
.model-selector-btn .chevron-down { flex-shrink: 0; transition: transform var(--transition-fast); }
.model-selector-btn .chevron-down.open { transform: rotate(180deg); }
.model-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 4px); left: 0; right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
}
.model-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--color-border-light);
}
.model-dropdown-item:last-child { border-bottom: none; }
.model-dropdown-item:hover { background: var(--color-brand-light); color: var(--color-brand); }
.model-dropdown-item.active { font-weight: 600; color: var(--color-brand); }
.model-dropdown-item .model-check { width: 16px; height: 16px; flex-shrink: 0; display: flex; align-items: center; }
.model-dropdown-item .model-check svg { width: 14px; height: 14px; }
.model-dropdown-item .model-provider { font-size: var(--text-nano); color: var(--color-text-tertiary); margin-left: auto; flex-shrink: 0; }

/* ===== Toggle Capsule (多选胶囊按钮) ===== */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.toggle-capsule {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  font-size: var(--text-small);
  font-weight: 500;
  line-height: 1.4;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  user-select: none;
}
.toggle-capsule:hover {
  background: var(--color-brand-light);
  border-color: var(--color-brand);
  color: var(--color-brand);
}
.toggle-capsule.active {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
}
.toggle-capsule.active:hover {
  background: var(--color-brand-dark);
  border-color: var(--color-brand-dark);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

/* ===== Button Group (单选圆角按钮) ===== */
.btn-group-rounded {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--color-border);
}
.btn-group-rounded .btn-option {
  padding: 5px 14px;
  font-size: var(--text-small);
  font-weight: 500;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
  border-right: 1px solid var(--color-border-light);
}
.btn-group-rounded .btn-option:last-child {
  border-right: none;
}
.btn-group-rounded .btn-option:hover {
  background: var(--color-brand-light);
  color: var(--color-brand);
}
.btn-group-rounded .btn-option.active {
  background: var(--color-brand);
  color: #fff;
}

/* ===== Loading & Skeleton ===== */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(2px);
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--color-border-light);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: edit-spin 0.8s linear infinite;
}
.skeleton {
  background: linear-gradient(90deg, var(--color-bg) 25%, var(--color-bg-subtle) 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 16px; margin-bottom: 8px; width: 100%; }
.skeleton-text.short { width: 60%; }
.skeleton-title { height: 24px; width: 40%; margin-bottom: 16px; }
.skeleton-card { height: 120px; margin-bottom: 16px; }

/* ===== Form Validation ===== */
.form-group.error input,
.form-group.error select,
.form-group.error textarea {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
}
.form-group.success input,
.form-group.success select,
.form-group.success textarea {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.12);
}
.form-error-msg {
  font-size: var(--text-nano);
  color: var(--color-error);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  animation: fadeIn 0.2s ease;
}
.form-success-msg {
  font-size: var(--text-nano);
  color: var(--color-success);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== Keyboard Navigation ===== */
:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-brand);
  color: white;
  padding: 8px 16px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 10000;
  text-decoration: none;
  font-size: var(--text-small);
  font-weight: 600;
}
.skip-link:focus {
  top: 0;
}

/* ===== Page Transition ===== */
.page-transition-enter {
  animation: pageEnter 0.3s ease-out;
}
.page-transition-exit {
  animation: pageExit 0.2s ease-in;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pageExit {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }

/* ===== Print Styles ===== */
@media print {
  .navbar, .sidebar, .toast-container,
  .chat-panel, .preview-toolbar .actions { display: none !important; }
  .main-content, .main { margin-left: 0 !important; padding: 0 !important; }
  .markdown-body { box-shadow: none !important; border: none !important; }
}
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--transition-normal); width: var(--sidebar-width); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { transform: translateX(-100%); }
  .sidebar.collapsed.open { transform: translateX(0); width: var(--sidebar-collapsed); }
  .main-content { margin-left: 0; }
  .sidebar.collapsed ~ .main-content { margin-left: 0; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-panel { width: 100%; min-width: 0; border-left: none; border-top: 1px solid var(--color-border); }
  .col-md-6 { flex: 0 0 100%; max-width: 100%; }
}

@media (max-width: 639px) {
  .stats-grid { grid-template-columns: 1fr; }
  .quick-access { grid-template-columns: repeat(2, 1fr); }
  .section-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
  table th, table td { padding: 8px 14px; }
}

/* ===== Modal / Confirm Dialog ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.2s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 400px;
  max-width: 90vw;
  animation: modalSlideIn 0.2s ease;
}
@keyframes modalSlideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5) 0;
}
.modal-title {
  font-size: var(--text-h4);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}
.modal-close-btn {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-tertiary);
  transition: all 150ms ease;
}
.modal-close-btn:hover { background: var(--color-bg); color: var(--color-text-primary); }
.modal-body {
  padding: var(--space-4) var(--space-5);
}
.modal-body p {
  margin: 0;
  font-size: var(--text-body);
  color: var(--color-text-secondary);
  line-height: 1.6;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 0 var(--space-5) var(--space-4);
}

/* ========================================================================
   Dark Mode — 通过 data-theme 属性切换
   html[data-theme="dark"] = 暗色模式，默认（无属性）= 亮色模式
   ======================================================================== */

html[data-theme="dark"] {
  --color-text-primary: #E8ECF1;
  --color-text-secondary: #9CA3AF;
  --color-text-tertiary: #7B8591;
  --color-bg: #0F1724;
  --color-surface: #1A2332;
  --color-bg-subtle: #232E3E;
  --color-border: #2D3A4C;
  --color-border-light: #253040;
  --color-brand-light: #1A3145;
  --color-accent-light: #3D1C1C;
  --color-success-soft: #163025;
  --color-warning-soft: #2D2210;
  --color-error-soft: #2D1414;
  --color-info-soft: #14203D;
  --shadow-color-xs: rgba(0, 0, 0, 0.3);
  --shadow-color-sm: rgba(0, 0, 0, 0.35);
  --shadow-color-md: rgba(0, 0, 0, 0.4);
  --shadow-color-lg: rgba(0, 0, 0, 0.5);
}

/* Dark mode: logo 切换 */
html[data-theme="dark"] .markdown-body pre {
  background: #0D1420;
  border: 1px solid var(--color-border);
}

/* 自动跟随系统偏好（用户未手动设置时） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-text-primary: #E8ECF1;
    --color-text-secondary: #9CA3AF;
    --color-text-tertiary: #7B8591;
    --color-bg: #0F1724;
    --color-surface: #1A2332;
    --color-bg-subtle: #232E3E;
    --color-border: #2D3A4C;
    --color-border-light: #253040;
    --color-brand-light: #1A3145;
    --color-accent-light: #3D1C1C;
    --color-success-soft: #163025;
    --color-warning-soft: #2D2210;
    --color-error-soft: #2D1414;
    --color-info-soft: #14203D;
    --shadow-color-xs: rgba(0, 0, 0, 0.3);
    --shadow-color-sm: rgba(0, 0, 0, 0.35);
    --shadow-color-md: rgba(0, 0, 0, 0.4);
    --shadow-color-lg: rgba(0, 0, 0, 0.5);
  }
}
