/* ============================================================
   建筑资质管理平台 - 全局样式
   Design Contract: Yonyou (用友) enterprise UI style
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Colors - Refined premium blue */
  --color-primary: #3b7eff;
  --color-primary-hover: #2f6ef0;
  --color-primary-active: #1f5ee0;
  --color-primary-bg: #eaf2ff;
  --color-primary-light: #eaf2ff;
  --color-primary-lighter: #f5f9ff;
  --color-primary-gradient: linear-gradient(135deg, #4f8cff 0%, #3b7eff 100%);

  /* Colors - Neutrals - refined */
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-surface-hover: #f7f9fc;
  --color-surface-muted: #fafbfd;
  --color-border: #ebeef2;
  --color-border-light: #f2f4f7;
  --color-border-dark: #d6dbe3;

  /* Colors - Text */
  --color-text: #1d2129;
  --color-text-secondary: #4e5969;
  --color-text-muted: #86909c;
  --color-text-disabled: #c5c9d0;

  /* Colors - Semantic */
  --color-success: #00b42a;
  --color-success-light: #e8ffea;
  --color-warning: #ff7d00;
  --color-warning-light: #fff7e8;
  --color-danger: #f53f3f;
  --color-danger-light: #ffece8;
  --color-info: #3b7eff;
  --color-info-light: #eaf2ff;

  /* Typography */
  --font-family: "Microsoft YaHei", "微软雅黑", -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-base: 14px;
  --font-size-lg: 15px;
  --font-size-xl: 17px;
  --font-size-2xl: 19px;
  --font-size-3xl: 23px;
  --font-size-4xl: 30px;

  /* 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;

  /* Radius - slightly rounded for premium feel */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --radius-full: 9999px;

  /* Shadows - refined, softer */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.08), 0 3px 6px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.06);

  /* Layout */
  --sidebar-width: 224px;
  --sidebar-collapsed-width: 60px;
  --topbar-height: 52px;
  --content-max-width: 100%;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 220ms ease;
  --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Dark Theme (Trae/VS Code inspired, low-saturation) ---------- */
[data-theme="dark"] {
  /* 主色调 - 降低饱和度，柔和蓝灰 */
  --color-primary: #5b8def;
  --color-primary-hover: #6e9af2;
  --color-primary-active: #4a7fd4;
  --color-primary-bg: #2b3548;
  --color-primary-gradient: linear-gradient(135deg, #5b8def 0%, #4a7fd4 100%);

  /* 背景层级 */
  --color-bg: #1e1f22;
  --color-surface: #25262b;
  --color-surface-hover: #2d2e34;
  --color-surface-muted: #2a2b30;
  --color-border: #3c3d42;
  --color-border-light: #323338;
  --color-border-dark: #4c4d52;

  /* 文字 - 降低亮度，不用纯白 */
  --color-text: #cccccc;
  --color-text-secondary: #9d9d9d;
  --color-text-muted: #6b6b6b;
  --color-text-disabled: #4c4d52;

  /* 语义色 light 变体 */
  --color-primary-light: #2a3448;
  --color-primary-lighter: #252c3a;

  --color-success: #58a6ff;
  --color-success-light: #1f2e25;
  --color-warning: #d29922;
  --color-warning-light: #2e2819;
  --color-danger: #f85149;
  --color-danger-light: #332020;
  --color-info: #58a6ff;
  --color-info-light: #1f2a33;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.35);
}

/* Dark theme component overrides - Trae/VS Code inspired */
[data-theme="dark"] .app-sidebar {
  background: #1e1f22;
  border-right-color: var(--color-border);
  box-shadow: none;
}

/* Logo 区域 - 暗色下去掉亮蓝渐变 */
[data-theme="dark"] .sidebar-logo {
  background: #25262b;
  box-shadow: none;
  border-bottom: 1px solid var(--color-border);
}

[data-theme="dark"] .sidebar-logo-icon {
  background: rgba(91, 141, 239, 0.2);
  color: var(--color-primary);
}

[data-theme="dark"] .sidebar-footer {
  border-top-color: var(--color-border);
}

/* 侧边栏激活项 - VS Code 风格：柔和底色 + 左侧蓝色高亮条 */
[data-theme="dark"] .sidebar-nav-item.active {
  background: #2a2d32;
  color: var(--color-text);
  border-left: 2px solid var(--color-primary);
  box-shadow: none;
}

[data-theme="dark"] .sidebar-nav-item.active svg {
  color: var(--color-primary);
}

[data-theme="dark"] .sidebar-nav-item:hover {
  background: #2a2d32;
  color: var(--color-text);
}

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

[data-theme="dark"] .sidebar-nav-section {
  color: var(--color-text-muted);
}

[data-theme="dark"] .app-topbar {
  background: #25262b;
  border-bottom-color: var(--color-border);
}

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

[data-theme="dark"] .table-container {
  border-color: var(--color-border);
  box-shadow: none;
}

[data-theme="dark"] .data-table th {
  background: #2a2d32;
  border-bottom-color: var(--color-border);
  color: var(--color-text-secondary);
}

[data-theme="dark"] .data-table td {
  border-bottom-color: var(--color-border-light);
  color: var(--color-text);
}

[data-theme="dark"] .data-table tbody tr:hover {
  background: #2a2d32;
}

[data-theme="dark"] .modal {
  background: var(--color-surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .modal-header {
  border-bottom-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

[data-theme="dark"] .modal-footer {
  border-top-color: var(--color-border);
  background: var(--color-surface);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

[data-theme="dark"] .card,
[data-theme="dark"] .panel,
[data-theme="dark"] .stat-card {
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: none;
}

[data-theme="dark"] .card:hover,
[data-theme="dark"] .stat-card:hover {
  box-shadow: none;
  border-color: var(--color-border-dark);
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .panel-header {
  border-bottom-color: var(--color-border);
  background: #2a2d32;
}

[data-theme="dark"] .card-footer {
  border-top-color: var(--color-border);
  background: #2a2d32;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
  background: #1e1f22;
  border-color: var(--color-border-dark);
  color: var(--color-text);
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.15);
}

[data-theme="dark"] .btn {
  background: #2d2e34;
  border-color: var(--color-border-dark);
  color: var(--color-text);
}

[data-theme="dark"] .btn-secondary {
  background: #2d2e34;
  color: var(--color-text-secondary);
  border-color: var(--color-border-dark);
}

[data-theme="dark"] .btn-secondary:hover {
  color: var(--color-text);
  border-color: var(--color-border-dark);
  background: #3a3b42;
}

/* 主按钮 - 暗色下不用渐变，用实色降低刺眼度 */
[data-theme="dark"] .btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

[data-theme="dark"] .btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* 筛选标签 - 暗色下去掉渐变 */
[data-theme="dark"] .filter-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
  box-shadow: none;
}

[data-theme="dark"] .filter-chip {
  background: #2d2e34;
  border-color: var(--color-border-dark);
  color: var(--color-text-secondary);
}

[data-theme="dark"] .filter-chip:hover {
  background: #3a3b42;
  border-color: var(--color-border-dark);
  color: var(--color-text);
}

/* 搜索框 - 暗色 */
[data-theme="dark"] .search-box input {
  background: #1e1f22;
  border-color: var(--color-border-dark);
  color: var(--color-text);
}

[data-theme="dark"] .search-box input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.15);
}

[data-theme="dark"] .settings-nav-item.active {
  background: #2a2d32;
  color: var(--color-primary);
  border-left: 2px solid var(--color-primary);
}

[data-theme="dark"] .settings-nav-item:hover {
  background: #2a2d32;
}

[data-theme="dark"] .setting-row {
  border-bottom-color: var(--color-border-light);
}

[data-theme="dark"] .role-card {
  border-color: var(--color-border);
}

[data-theme="dark"] .data-action-card {
  border-color: var(--color-border);
}

[data-theme="dark"] .log-table th {
  background: #2a2d32;
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .log-table td {
  border-bottom-color: var(--color-border-light);
}

[data-theme="dark"] .log-table tbody tr:hover {
  background: #2a2d32;
}

[data-theme="dark"] .topbar-icon-btn {
  color: var(--color-text-secondary);
}

[data-theme="dark"] .topbar-icon-btn:hover {
  background: var(--color-surface-hover);
}

[data-theme="dark"] .switch-slider {
  background-color: var(--color-border-dark);
}

[data-theme="dark"] .tag-muted {
  background: var(--color-surface-hover);
  color: var(--color-text-muted);
}

[data-theme="dark"] ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: transparent;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #42434a;
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #4f5059;
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ---------- App Shell Layout ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar - refined premium white with subtle depth */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #fff;
  color: var(--color-text);
  z-index: 50;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  transition: width var(--transition-base);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
}

.sidebar-logo {
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-primary-gradient);
  color: #fff;
  box-shadow: 0 1px 4px rgba(59, 126, 255, 0.25);
}

.sidebar-logo-icon {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}

.sidebar-logo-text {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: #fff;
  white-space: normal;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.3px;
  flex: 1;
  min-width: 0;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-2) 0;
  overflow-y: auto;
}

.sidebar-nav-section {
  padding: var(--space-4) var(--space-4) var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.8px;
  font-weight: 600;
  text-transform: uppercase;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 1px var(--space-2);
  padding: 0 var(--space-3);
  height: 38px;
  color: var(--color-text-secondary);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--radius-md);
  border-left: none;
}

.sidebar-nav-item:hover {
  background: var(--color-primary-lighter);
  color: var(--color-primary);
}

.sidebar-nav-item.active {
  background: var(--color-primary-gradient);
  color: #fff;
  border-left-color: transparent;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(59, 126, 255, 0.3);
}

.sidebar-nav-item.active svg {
  color: #fff;
}

.sidebar-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Main Content */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* Top Bar - refined premium */
.app-topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.topbar-icon-btn:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.topbar-icon-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

/* Theme toggle button */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--color-text-secondary);
  position: relative;
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  transition: transform 300ms ease;
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

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

.topbar-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--color-danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ========== 全站通知铃铛：数字角标 + 待办面板 ========== */
.topbar-badge.notify-badge-num {
  top: -6px;
  right: -7px;
  width: auto;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 16px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  box-sizing: border-box;
}
.notify-panel {
  position: fixed;
  width: 380px;
  max-width: calc(100vw - 16px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  padding: var(--space-3);
}
.notify-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  padding: 2px 6px 10px;
}
.notify-sec { margin-bottom: 4px; }
.notify-sec-title {
  font-size: 12px;
  color: var(--color-text-secondary);
  padding: 6px;
  border-bottom: 1px solid var(--color-border-light);
}
.notify-sec-title b { color: var(--color-danger); font-weight: 600; }
.notify-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text);
  font-size: 13px;
}
.notify-item:hover { background: var(--color-surface-hover); }
.notify-tag {
  flex: none;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-bg);
  color: var(--color-primary);
  white-space: nowrap;
}
.notify-item-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notify-days { flex: none; font-size: 12px; color: var(--color-text-secondary); white-space: nowrap; }
.notify-days.urgent { color: var(--color-danger); }
.notify-empty { padding: 10px 6px; font-size: 12.5px; color: var(--color-text-muted); }
.notify-more {
  display: block;
  text-align: center;
  font-size: 12.5px;
  color: var(--color-primary);
  text-decoration: none;
  padding: 6px 0 2px;
}

/* Page Content */
.app-content {
  flex: 1;
  padding: var(--space-5);
  width: 100%;
  min-width: 0;
}

/* ---------- Buttons - Yonyou flat style ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 0 var(--space-4);
  height: 32px;
  border-radius: 4px;
  font-size: var(--font-size-base);
  font-weight: normal;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--color-border-dark);
  white-space: nowrap;
  background: #fff;
  color: var(--color-text-secondary);
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.btn-primary {
  background: var(--color-primary-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(59, 126, 255, 0.3);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(59, 126, 255, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--color-primary-active);
  box-shadow: 0 1px 3px rgba(59, 126, 255, 0.3);
  transform: translateY(0);
}

.btn-secondary {
  background: #fff;
  color: var(--color-text-secondary);
  border-color: var(--color-border-dark);
}

.btn-secondary:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-lighter);
}

/* "我的"视图切换按钮：激活时为主色实心 */
.btn-mine.active,
.btn-mine-filter.active,
.btn-eo-filter.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* 托管周期快捷按钮 */
.period-chip {
  padding: 4px 12px;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 4px);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.period-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.period-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.period-chip:disabled {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  cursor: not-allowed;
  border-color: var(--color-border);
}

.btn-mine.active:hover {
  background: var(--color-primary-dark, #176fc4);
  border-color: var(--color-primary-dark, #176fc4);
  color: #fff;
}

.btn-danger {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: #d83915;
  border-color: #d83915;
}

.btn-warning {
  background: var(--color-warning);
  color: white;
  border-color: var(--color-warning);
}

.btn-warning:hover {
  background: #e68a00;
  border-color: #e68a00;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.btn-sm {
  padding: 0 var(--space-3);
  height: 26px;
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: 0 var(--space-5);
  height: 36px;
  font-size: var(--font-size-lg);
}

.btn-block {
  width: 100%;
}

/* ---------- Form Elements - Yonyou compact ---------- */
.form-group {
  margin-bottom: var(--space-3);
}

.form-label {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
  line-height: 1.4;
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0 var(--space-3);
  height: 32px;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: #fff;
  transition: all var(--transition-fast);
  outline: none;
  box-sizing: border-box;
}

/* 原生 select 统一大箭头（去掉浏览器默认小箭头，换自定义 SVG 大箭头） */
.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  padding-right: 32px;
  cursor: pointer;
}
.form-select:disabled,
.form-select[readonly] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b0b5be' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  cursor: not-allowed;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--color-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(45, 140, 240, 0.12);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

/* 原生日期输入空值时，浏览器按中文区域渲染「yyyy/mm/dd」占位符，
   与列表/详情的 2026-09-29 短横线格式不一致；空值时覆盖为统一占位符（审核 #15） */
input[type="date"] {
  position: relative;
}
/* 空值：隐藏原生分段占位文本，覆盖显示 YYYY-MM-DD */
input[type="date"].date-empty::-webkit-datetime-edit {
  color: transparent;
}
input[type="date"].date-empty::before {
  content: 'YYYY-MM-DD';
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: inherit;
  line-height: 1;
  pointer-events: none;
}
/* 聚焦时恢复原生分段提示，便于逐段输入 */
input[type="date"].date-empty:focus::-webkit-datetime-edit {
  color: inherit;
}
input[type="date"].date-empty:focus::before {
  display: none;
}

/* 有值且未聚焦：浏览器按区域用斜杠显示 2026/12/30，同样覆盖为短横线格式（审核 #15） */
input[type="date"].date-filled:not(:focus)::-webkit-datetime-edit {
  color: transparent;
}
input[type="date"].date-filled:not(:focus)::before {
  content: attr(data-date-text);
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text);
  font-size: inherit;
  line-height: 1;
  pointer-events: none;
}
input[type="date"].date-filled:focus::-webkit-datetime-edit {
  color: inherit;
}
input[type="date"].date-filled:focus::before {
  display: none;
}
/* 禁用/只读态覆盖文本同步为弱化色 */
input[type="date"].date-filled:disabled:not(:focus)::before,
input[type="date"].date-filled[readonly]:not(:focus)::before {
  color: var(--color-text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 64px;
  height: auto;
  padding: var(--space-2) var(--space-3);
}

/* ============================================================
   Field state — disabled / readonly 统一视觉语言
   让人一眼分辨：哪些可填、哪些不可填
   - 可写：白底 + 深边框 + 聚焦蓝光环
   - 不可写（disabled/readonly）：浅灰底 + 淡边 + 灰字 + not-allowed + 无光环 + 无 hover 反馈
   ============================================================ */
input:disabled,
input[readonly],
select:disabled,
select[readonly],
textarea:disabled,
textarea[readonly],
.form-input:disabled,
.form-input[readonly],
.form-select:disabled,
.form-select[readonly],
.form-textarea:disabled,
.form-textarea[readonly],
.ss-input[disabled],
.ss-input[readonly] {
  background: var(--color-surface-muted) !important;
  border-color: var(--color-border-light) !important;
  color: var(--color-text-muted) !important;
  cursor: not-allowed !important;
  opacity: 1 !important;
  box-shadow: none !important;
  pointer-events: auto;
}

input:disabled:hover,
input[readonly]:hover,
select:disabled:hover,
select[readonly]:hover,
textarea:disabled:hover,
textarea[readonly]:hover,
.form-input:disabled:hover,
.form-input[readonly]:hover,
.form-select:disabled:hover,
.form-select[readonly]:hover,
.form-textarea:disabled:hover,
.form-textarea[readonly]:hover,
.ss-input[disabled]:hover,
.ss-input[readonly]:hover {
  border-color: var(--color-border-light) !important;
  background: var(--color-surface-muted) !important;
}

input:disabled:focus,
input[readonly]:focus,
select:disabled:focus,
select[readonly]:focus,
textarea:disabled:focus,
textarea[readonly]:focus,
.form-input:disabled:focus,
.form-input[readonly]:focus,
.form-select:disabled:focus,
.form-select[readonly]:focus,
.form-textarea:disabled:focus,
.form-textarea[readonly]:focus,
.ss-input[disabled]:focus,
.ss-input[readonly]:focus {
  border-color: var(--color-border-light) !important;
  box-shadow: none !important;
}

/* readonly 比 disabled 略亮，加虚线边框作为"只读"标识（仍属于不可写） */
input[readonly],
select[readonly],
textarea[readonly],
.form-input[readonly],
.form-select[readonly],
.form-textarea[readonly],
.ss-input[readonly] {
  background: var(--color-surface) !important;
  border-color: var(--color-border-dark) !important;
  border-style: dashed !important;
  color: var(--color-text-secondary) !important;
}

/* 按钮禁用态 */
.btn:disabled,
.btn[disabled] {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  pointer-events: none;
}
.btn:disabled:hover,
.btn[disabled]:hover {
  transform: none !important;
  box-shadow: none !important;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-4);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ---------- Cards - refined with subtle shadow ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------- Stat Cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* 中介经营概览（v1.3.0） */
.broker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.broker-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.broker-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}
.broker-card-label {
  font-size: 13px;
  color: var(--color-text-muted);
}
.broker-card-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  margin: 6px 0 2px;
}
.broker-card-sub {
  font-size: 12px;
  color: var(--color-text-muted);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid #e8e8e8;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
}

.stat-card.primary::before { background: var(--color-primary); }
.stat-card.success::before { background: var(--color-success); }
.stat-card.warning::before { background: var(--color-warning); }
.stat-card.danger::before { background: var(--color-danger); }
.stat-card.muted::before { background: var(--color-border); }

/* 版本标记：系统设置页底部 / 登录页底部（灰色小字，不抢视觉） */
.version-stamp {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.version-stamp-login {
  position: fixed;
  bottom: var(--space-4);
  left: 0;
  right: 0;
  margin-top: 0;
  padding-top: 0;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-border-dark);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.stat-card-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.stat-card-icon.primary {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.stat-card-icon.success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.stat-card-icon.warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.stat-card-icon.danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.stat-card-icon.muted {
  background: var(--color-bg-secondary, #f0f1f3);
  color: var(--color-text-muted);
}

.stat-card-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.stat-card-foot {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
}

.stat-card-trend {
  display: flex;
  align-items: center;
  gap: 2px;
  font-weight: 500;
}

.stat-card-trend.up { color: var(--color-success); }
.stat-card-trend.down { color: var(--color-danger); }

.stat-card-foot .sub {
  color: var(--color-text-muted);
}

/* ---------- Tags / Badges - Yonyou style ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: normal;
  line-height: 20px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tag-primary {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: rgba(45, 140, 240, 0.2);
}

.tag-success {
  background: var(--color-success-light);
  color: #389e0d;
  border-color: rgba(82, 196, 26, 0.2);
}

.tag-warning {
  background: var(--color-warning-light);
  color: #d48806;
  border-color: rgba(250, 173, 20, 0.2);
}

.tag-danger {
  background: var(--color-danger-light);
  color: #cf1322;
  border-color: rgba(245, 34, 45, 0.2);
}

.tag-info {
  background: var(--color-info-light);
  color: var(--color-info);
  border-color: rgba(45, 140, 240, 0.2);
}

.tag-muted {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

/* 业务类型中性标签（审核 #13）：灰底深字，与进度/风险类彩色标签区分 */
.tag-biz {
  background: #f2f3f5;
  color: #4e5969;
  border-color: #e5e6eb;
}

/* 超级管理员角色标签（审核 #13）：金色强调，与普通账户的灰色区分 */
.tag-role-admin {
  background: #fff7e6;
  color: #ad6800;
  border-color: #ffe7ba;
}

.tag-outline {
  background: transparent;
  border: 1px solid var(--color-border-dark);
  color: var(--color-text-secondary);
}

/* ---------- Tables - refined premium ---------- */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  font-size: var(--font-size-base);
}

.data-table th {
  background: linear-gradient(180deg, var(--color-surface-muted) 0%, var(--color-surface-hover) 100%);
  text-align: left;
  padding: 12px var(--space-4);
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  border-bottom: 2px solid var(--color-primary-light);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table th.sortable:hover {
  color: var(--color-primary);
  background: linear-gradient(180deg, var(--color-primary-bg) 0%, var(--color-surface-hover) 100%);
}
.data-table th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  color: var(--color-text-muted);
  transition: transform .15s;
}
.data-table th.sort-active .sort-icon {
  color: var(--color-primary);
  font-weight: 700;
}
.data-table th.sort-active.sort-asc .sort-icon::before { content: '↑'; }
.data-table th.sort-active.sort-desc .sort-icon::before { content: '↓'; }
.data-table th:not(.sort-active) .sort-icon::before { content: '↕'; }

.data-table td {
  padding: 12px var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-secondary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--color-surface-hover);
}

/* ========== 全站表格统一规范（审核 #6）==========
   策略：短字段列（日期/类型/状态/金额/数字）nowrap + min-width；
   长文本列（标题/企业/证书名）允许自然换行；
   窄屏总宽超出时由外层容器 overflow-x:auto 承接，不再把中文压成竖排。 */

/* 任务页列表容器：全站唯一的 div.data-table 用法，窄屏横向滚动 */
div.data-table { overflow-x: auto; }

/* —— 任务管理列表 —— */
.task-table { min-width: 1040px; }
.task-table th,
.task-table td { white-space: nowrap; }
/* 勾选列：方框靠左对齐，压缩左右内边距；min-width 防止 auto 布局压缩（版面调整） */
.task-table > thead > tr > th:nth-child(1),
.task-table > tbody > tr > td:nth-child(1) {
  width: 40px;
  min-width: 40px;
  text-align: left;
  padding-left: 10px;
  padding-right: 4px;
}
/* 标题（2）、企业（3）为长文本，允许自然换行（列号含勾选列） */
.task-table td:nth-child(2),
.task-table td:nth-child(3) { white-space: normal; word-break: break-word; min-width: 120px; }
.task-table td:nth-child(4) { min-width: 88px; }
/* 截止日期带「（剩 N 天）」后缀，预留宽度 */
.task-table td:nth-child(5) { min-width: 150px; }
.task-table td:nth-child(6) { min-width: 110px; }
.task-table td:nth-child(9) { min-width: 96px; }

/* —— 任务详情：人员需求清单 —— */
.req-list-table { width: 100%; min-width: 560px; }
.req-list-table th,
.req-list-table td { white-space: nowrap; }
.req-list-table th:nth-child(3), .req-list-table td:nth-child(3),
.req-list-table th:nth-child(4), .req-list-table td:nth-child(4) { text-align: center; }
/* 已落实列内含人员胶囊，允许换行 */
.req-list-table td:nth-child(4) { white-space: normal; min-width: 160px; }

/* —— 财务账：交易流水主表 —— */
.finance-table { min-width: 980px; }
.finance-table th,
.finance-table td { white-space: nowrap; }
/* 证书（3）、持证人员（4）、所在企业（5）为长文本，允许换行 */
.finance-table td:nth-child(3),
.finance-table td:nth-child(4),
.finance-table td:nth-child(5) { white-space: normal; word-break: break-word; }

/* —— 财务汇总表：数字列不换行、右对齐 —— */
#sales-tbody td:not(:first-child),
#customer-tbody td:not(:first-child) { white-space: nowrap; text-align: right; }

/* 人员表：auto 布局；勾选列固定窄宽（审核 #11），其余列按内容自然分配 */
/* 表头放不下时允许换行（宽屏自然一行） */
.personnel-table thead th {
  white-space: normal;
  line-height: 1.25;
}
/* 标签防溢出 */
.personnel-table td .tag {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
/* 勾选列：固定 40px，方框靠左对齐并压缩左右内边距（min-width 防止任何布局下被压缩） */
.personnel-table > thead > tr > th:nth-child(1),
.personnel-table > tbody > tr > td:nth-child(1) {
  width: 40px;
  min-width: 40px;
  text-align: left;
  padding-left: 10px;
  padding-right: 4px;
}

/* 操作列：紧凑内边距；窄屏放不下时按钮换行，宽屏自然一行 */
.personnel-table > tbody > tr > td:nth-child(7) {
  padding-left: 8px;
  padding-right: 8px;
}
.personnel-table .table-actions {
  flex-wrap: wrap;
  row-gap: 2px;
}
.personnel-table .table-action-btn {
  padding-left: 3px;
  padding-right: 3px;
}

/* 证书表操作列：左压右留（末列右留白由全局末列规则统一为24px），避免宽屏下轻微溢出切按钮 */
.cert-table td:last-child {
  padding-left: 8px;
  padding-right: 24px;
}
/* 证书表单元格横向padding压缩至10px：降低表格最小宽度下限，中窄屏不横向滚动（宽屏时多余空间仍由auto布局均分，观感不变） */
.cert-table th,
.cert-table td {
  padding-left: 10px;
  padding-right: 10px;
}
/* 证书表表头允许换行：降低表格最小宽度，中窄屏下操作列不再被横向滚出可视区（与预警表同策略） */
.cert-table thead th {
  white-space: normal;
  line-height: 1.25;
}
.cert-table .table-actions {
  gap: 1px;
}
.cert-table .table-action-btn {
  padding-left: 2px;
  padding-right: 2px;
}

/* 到期预警表：固定布局，名称/企业列加宽，日期状态列定宽 */
.warning-table {
  table-layout: fixed;
  /* 窄屏保证内容不被压缩，由容器内部横向滚动承接 */
  min-width: 960px;
}

/* ========== 到期预警：主体 Tab ========== */
.subject-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-4);
  border-bottom: 2px solid var(--color-border-light);
}
.subject-tab {
  padding: 10px 20px;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  user-select: none;
}
.subject-tab:hover {
  color: var(--color-primary);
}
.subject-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}
.warning-table thead th {
  white-space: normal;
  line-height: 1.25;
}
/* 列宽：类型10 名称26 企业18 到期12 剩余12 状态12 操作10 */
.warning-table > thead > tr > th,
.warning-table > tbody > tr > td {
  width: 10%;
}
.warning-table > thead > tr > th:nth-child(2),
.warning-table > tbody > tr > td:nth-child(2) {
  width: 26%;
}
.warning-table > thead > tr > th:nth-child(3),
.warning-table > tbody > tr > td:nth-child(3) {
  width: 18%;
}
.warning-table > thead > tr > th:nth-child(4),
.warning-table > tbody > tr > td:nth-child(4),
.warning-table > thead > tr > th:nth-child(5),
.warning-table > tbody > tr > td:nth-child(5),
.warning-table > thead > tr > th:nth-child(6),
.warning-table > tbody > tr > td:nth-child(6) {
  width: 12%;
}
.warning-table td {
  word-break: break-word;
  overflow-wrap: break-word;
}
.warning-table td .tag {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.warning-table td:nth-child(4),
.warning-table td:nth-child(5) {
  white-space: nowrap;
}
.warning-table td:last-child {
  padding-left: 8px;
  padding-right: 24px;
}

/* ========== 到期预警：已处理记录表（8列，独立列宽，不复用待处理表的6列布局） ========== */
.handled-table {
  table-layout: fixed;
  min-width: 960px;
}
.handled-table thead th {
  white-space: normal;
  line-height: 1.25;
}
/* 处理时间12 预警类型10 对象18 所在企业16 处理方式10 日期14 处理人8 备注12 */
.handled-table > thead > tr > th:nth-child(1),
.handled-table > tbody > tr > td:nth-child(1) { width: 12%; }
.handled-table > thead > tr > th:nth-child(2),
.handled-table > tbody > tr > td:nth-child(2) { width: 10%; }
.handled-table > thead > tr > th:nth-child(3),
.handled-table > tbody > tr > td:nth-child(3) { width: 18%; }
.handled-table > thead > tr > th:nth-child(4),
.handled-table > tbody > tr > td:nth-child(4) { width: 16%; }
.handled-table > thead > tr > th:nth-child(5),
.handled-table > tbody > tr > td:nth-child(5) { width: 10%; }
.handled-table > thead > tr > th:nth-child(6),
.handled-table > tbody > tr > td:nth-child(6) { width: 14%; }
.handled-table > thead > tr > th:nth-child(7),
.handled-table > tbody > tr > td:nth-child(7) { width: 8%; }
.handled-table > thead > tr > th:nth-child(8),
.handled-table > tbody > tr > td:nth-child(8) { width: 12%; }
.handled-table td {
  word-break: break-word;
  overflow-wrap: break-word;
}
.handled-table td:nth-child(1),
.handled-table td:nth-child(2),
.handled-table td:nth-child(5) {
  white-space: nowrap;
}

/* 处理弹窗「预警信息」展示框 */
.warning-info-box {
  padding: var(--space-3);
  background: var(--color-surface-muted);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}
.warning-info-title {
  margin-bottom: 4px;
}
.warning-info-meta {
  color: var(--color-text-muted);
}

/* 证书表「专业」列：保证工种/专业横排显示，窄屏由容器内部滚动承接 */
.data-table th.major-cell,
.data-table td.major-cell {
  min-width: 76px;
  white-space: nowrap;
}

/* 表格内「企业/人员」跳转链接：主色 + 悬停下划线 */
.cell-company-link {
  color: var(--color-primary);
  text-decoration: none;
}
.cell-company-link:hover {
  text-decoration: underline;
}

/* 人员列表「所在企业」单元格：纵向堆叠，多企业依次另起一行 */
.company-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.company-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 5px;
  max-width: 100%;
}
.company-line .company-tag {
  margin: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.company-line .company-count {
  flex-shrink: 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.company-idle-line {
  font-size: var(--font-size-xs);
  color: var(--color-warning);
}
.company-all-idle {
  color: var(--color-warning);
}



.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* 列表表格末列统一右留白24px：与容器右缘留出呼吸空间，与左侧留白对称（后置覆盖各表的末列紧凑规则） */
.data-table th:last-child,
.data-table td:last-child {
  padding-right: 24px;
}

/* Table actions */
.table-actions {
  display: flex;
  gap: var(--space-2);
}

.table-action-btn {
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  border: none;
  line-height: 20px;
  flex-shrink: 0;
}

.table-action-btn:hover {
  background: var(--color-primary-light);
}

.table-action-btn.danger {
  color: var(--color-danger);
}

.table-action-btn.danger:hover {
  background: var(--color-danger-light);
}

/* ---------- Search & Filter Bar ---------- */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 260px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-box input {
  width: 100%;
  height: 30px;
  padding: 0 var(--space-3) 0 30px;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  background: #fff;
  transition: all var(--transition-fast);
  outline: none;
}

.search-box input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(45, 140, 240, 0.15);
}

.search-box svg {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  stroke-width: 2;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Filter Chips */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

/* 筛选分组小标题：标明本行胶囊归属（审核 #9） */
.filter-group-label {
  flex: none;
  align-self: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* ---------- Custom Dropdown (专业下拉等) ---------- */
.major-dropdown {
  background: var(--color-surface);
  color: var(--color-text);
}
.major-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text);
  transition: background 0.15s;
}
.major-option:hover {
  background: var(--color-surface-muted);
}
.major-option.primary {
  color: var(--color-primary);
}

/* Filter Chips */
.filter-chip {
  padding: 5px var(--space-3);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  line-height: 20px;
}

.filter-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-lighter);
}

.filter-chip.active {
  background: var(--color-primary-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 6px rgba(59, 126, 255, 0.3);
}

/* 筛选栏类型下拉：选中某类型后高亮输入框，提示当前有类型筛选 */
#filter-type .ss-wrap.has-value .ss-input {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-lighter);
  font-weight: 500;
}

/* 已选证书类型标签（下拉右侧，放不下自动换行） */
.filter-type-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  min-width: 0;
}
.filter-type-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 10px;
  border-radius: var(--radius-full);
  background: var(--color-primary-lighter);
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  line-height: 20px;
  user-select: none;
  white-space: nowrap;
}
.filter-type-tag-x {
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.65;
  transition: opacity var(--transition-fast);
}
.filter-type-tag-x:hover {
  opacity: 1;
}

/* 已选专业标签：绿色描边，与证书类型标签区分 */
.filter-major-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  min-width: 0;
}
.filter-major-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 10px;
  border-radius: var(--radius-full);
  background: #e8ffea;
  border: 1px solid var(--color-success);
  color: var(--color-success);
  font-size: var(--font-size-sm);
  line-height: 20px;
  user-select: none;
  white-space: nowrap;
}
.filter-major-tag-x {
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.65;
  transition: opacity var(--transition-fast);
}
.filter-major-tag-x:hover {
  opacity: 1;
}

/* 工具栏专业下拉选中态 */
.page-toolbar .ss-wrap.has-value .ss-input {
  border-color: var(--color-success);
  color: var(--color-success);
  background: #f0fdf2;
  font-weight: 500;
}
[data-theme="dark"] .filter-major-tag {
  background: rgba(88, 166, 255, 0.12);
}
[data-theme="dark"] .page-toolbar .ss-wrap.has-value .ss-input {
  background: rgba(88, 166, 255, 0.12);
}

/* ---------- Task filter row (日期+快捷+重置) ---------- */
.task-filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.task-filter-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-right: 2px;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border-light);
}

.pagination-info {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* 每页条数下拉（审核 #12） */
.pagination-size {
  margin-left: 8px;
  height: 28px;
  padding: 0 6px;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.pagination-size:hover { border-color: var(--color-primary-light); }

.pagination-controls {
  display: flex;
  gap: 2px;
}

.pagination-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 var(--space-1);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.pagination-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Modal / Dialog - premium ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(29, 33, 41, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform var(--transition-base);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.modal-close svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
  /* min-height:0 破除 flex 子项默认 min-height:auto，表单超长时仅表单区滚动，底部按钮栏吸底常显 */
  min-height: 0;
}
/* 弹窗内容超长时滚动条更明显，提示用户下方还有字段（审核 #7） */
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--color-text-disabled); border-radius: 4px; }
.modal-body:hover::-webkit-scrollbar-thumb { background: var(--color-text-muted); }

.modal-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-shrink: 0;
  background: var(--color-surface);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.modal-lg {
  max-width: 720px;
}

.modal-xl {
  max-width: 860px;
}

.modal-sm {
  max-width: 400px;
}

/* ---------- Toast / Notification ---------- */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 260px;
  transform: translateX(100%);
  opacity: 0;
  transition: all var(--transition-base);
  pointer-events: auto;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 2px;
  margin-left: var(--space-1);
  flex-shrink: 0;
}
.toast-close:hover {
  color: var(--color-text);
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.toast-icon svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.toast-icon.success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.toast-icon.error {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.toast-icon.warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.toast-icon.info {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 500;
  color: var(--color-text);
  font-size: var(--font-size-sm);
}

.toast-message {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ---------- Empty State ---------- */
.empty-state {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-3);
  color: var(--color-text-disabled);
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.25;
}

.empty-state-title {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

.empty-state-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

/* ---------- Avatar ---------- */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.avatar-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.avatar-info .name {
  color: var(--color-text);
}

.avatar-info .sub {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ---------- Dashboard Panels ---------- */
.panel-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--space-3);
}

.panel {
  background: var(--color-surface);
  border: 1px solid #e8e8e8;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.panel-header {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface-muted);
}

.panel-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.panel-more {
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.panel-more:hover {
  color: var(--color-primary-hover);
}

.panel-body {
  padding: var(--space-3) var(--space-4);
}

/* Warning List */
.warning-list {
  list-style: none;
}

.warning-list li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
  margin: 0 calc(-1 * var(--space-4));
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.warning-list li:hover {
  background: var(--color-surface-muted);
}

.warning-list li:last-child {
  border-bottom: none;
}

.warning-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.warning-dot.urgent { background: var(--color-danger); }
.warning-dot.warn { background: var(--color-warning); }
.warning-dot.notice { background: var(--color-info); }

.warning-text {
  flex: 1;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warning-days {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.warning-days.urgent { color: var(--color-danger); font-weight: 600; }
.warning-days.warn { color: var(--color-warning); font-weight: 500; }

/* ---------- Chart Placeholder ---------- */
.chart-container {
  height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: var(--space-3) 0 var(--space-6);
  position: relative;
}

.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--color-primary) 0%, #6dd0ff 100%);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative;
  transition: opacity var(--transition-fast);
  min-height: 6px;
}

.chart-bar:hover {
  opacity: 0.8;
}

.chart-bar .bar-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.chart-bar .bar-value {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

/* ---------- Customer Cards Grid ---------- */
.customer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.customer-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition-base);
}

.customer-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.customer-card-ended {
  opacity: 0.75;
  filter: saturate(0.5);
}
.customer-card-ended:hover {
  opacity: 0.85;
  filter: saturate(0.7);
}

.customer-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-2);
}

.customer-card-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.customer-card-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.customer-card-stats {
  display: flex;
  justify-content: space-around;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-light);
}

.customer-card-stat {
  text-align: center;
}

.customer-card-stat .num {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
}

.customer-card-stat .num.warning { color: var(--color-warning); }
.customer-card-stat .num.danger { color: var(--color-danger); }
.customer-card-stat .num.muted { color: var(--color-text-muted); }

.customer-card-stat .label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ---------- Warning View Tabs ---------- */
.warning-view-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  border-bottom: 2px solid var(--color-border-light);
}
.warning-view-tab {
  padding: var(--space-2) var(--space-5);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.warning-view-tab:hover { color: var(--color-text-primary); }
.warning-view-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.warning-view-tab-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}
.warning-view-tab-badge:empty { display: none; }

/* ---------- Warning Stats Cards ---------- */
.warning-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* 已处理视图是 4 张卡 */
#view-handled .warning-stats { grid-template-columns: repeat(4, 1fr); }
#view-handled .warning-stat-card { cursor: default; }

.warning-stat-card {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  text-align: center;
  border: 1px solid;
  cursor: pointer;
  transition: all var(--transition-base);
}

.warning-stat-card:hover {
  box-shadow: var(--shadow-md);
}

.warning-stat-card.danger {
  background: rgba(245, 34, 45, 0.04);
  border-color: rgba(245, 34, 45, 0.15);
}

.warning-stat-card.warning {
  background: rgba(250, 173, 20, 0.04);
  border-color: rgba(250, 173, 20, 0.15);
}

.warning-stat-card.info {
  background: rgba(45, 140, 240, 0.04);
  border-color: rgba(45, 140, 240, 0.15);
}

.warning-stat-card.notice {
  background: rgba(82, 196, 26, 0.04);
  border-color: rgba(82, 196, 26, 0.15);
}

.warning-stat-card .num {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.warning-stat-card.danger .num { color: var(--color-danger); }
.warning-stat-card.warning .num { color: var(--color-warning); }
.warning-stat-card.info .num { color: var(--color-primary); }
.warning-stat-card.notice .num { color: var(--color-success); }

.warning-stat-card .label {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
}

.warning-stat-card .sub {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ---------- Settings Layout ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-4);
}

.settings-nav {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  height: fit-content;
}

.settings-nav-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  border-left: 3px solid transparent;
}

.settings-nav-item:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.settings-nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 500;
  border-left-color: var(--color-primary);
}

.settings-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.settings-section-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.settings-section-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

/* Theme selection cards */
.theme-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.theme-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.theme-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.theme-card.active {
  border-color: var(--color-primary);
  background: var(--color-primary-lighter);
}

.theme-card.active::after {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.theme-card-preview {
  height: 64px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-3);
  display: flex;
  border: 1px solid var(--color-border);
}

.theme-card-preview .tcp-sidebar {
  width: 28%;
  height: 100%;
  flex-shrink: 0;
}

.theme-card-preview .tcp-main {
  flex: 1;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-card-preview .tcp-bar {
  height: 8px;
  border-radius: 2px;
}

.theme-card-preview .tcp-row {
  height: 6px;
  border-radius: 2px;
}

/* Light preview */
.theme-card[data-theme-val="light"] .tcp-sidebar { background: #3b7eff; }
.theme-card[data-theme-val="light"] .tcp-main { background: #f5f7fa; }
.theme-card[data-theme-val="light"] .tcp-bar { background: #d6dbe3; }
.theme-card[data-theme-val="light"] .tcp-row { background: #ebeef2; }

/* Dark preview */
.theme-card[data-theme-val="dark"] .tcp-sidebar { background: #1a1d24; }
.theme-card[data-theme-val="dark"] .tcp-main { background: #1e2129; }
.theme-card[data-theme-val="dark"] .tcp-bar { background: #3a3f4b; }
.theme-card[data-theme-val="dark"] .tcp-row { background: #2e333d; }

/* Auto preview */
.theme-card[data-theme-val="auto"] .tcp-sidebar { background: linear-gradient(135deg, #3b7eff 50%, #1a1d24 50%); }
.theme-card[data-theme-val="auto"] .tcp-main { background: linear-gradient(135deg, #f5f7fa 50%, #1e2129 50%); }
.theme-card[data-theme-val="auto"] .tcp-bar { background: linear-gradient(90deg, #d6dbe3 50%, #3a3f4b 50%); }
.theme-card[data-theme-val="auto"] .tcp-row { background: linear-gradient(90deg, #ebeef2 50%, #2e333d 50%); }

.theme-card-name {
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text);
}

.theme-card-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .broker-grid { grid-template-columns: repeat(3, 1fr); }
  .customer-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }
  .sidebar-logo-text,
  .sidebar-nav-item span:not(.sidebar-nav-icon),
  .sidebar-nav-section,
  .sidebar-user-info {
    display: none;
  }
  .sidebar-nav-item {
    justify-content: center;
    padding: var(--space-3);
  }
  .app-main {
    margin-left: var(--sidebar-collapsed-width);
  }
  .warning-stats { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .broker-grid { grid-template-columns: repeat(2, 1fr); }
  .customer-grid { grid-template-columns: 1fr; }
  .app-content { padding: var(--space-3); }
  .app-topbar { padding: 0 var(--space-3); }
  .topbar-title { font-size: var(--font-size-base); }
  .modal { max-width: 100%; }
}

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-4 { margin-top: var(--space-4); }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-success { color: var(--color-success); }
.text-primary { color: var(--color-primary); }
.w-full { width: 100%; }
.hidden { display: none; }

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

/* —— 键盘焦点可见（审核 #22-D）：仅键盘导航时显示，鼠标点击不出现 —— */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-text-disabled);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* Print */
@media print {
  .app-sidebar, .app-topbar { display: none; }
  .app-main { margin-left: 0; }
  .app-content { padding: 0; }
}

/* 预隐藏即将被自定义下拉替换的原生 select[multiple]：
   initSearchableSelect 异步执行前，空 select multiple 会渲染成 ~80px 高的列表框，
   把筛选栏撑开造成布局闪烁（FOUC）。替换后由 .ss-wrap > select 接管，始终隐藏。 */
select[multiple] {
  display: none;
}

/* ============================================================
   可搜索下拉组件 (Searchable Select)
   ============================================================ */
.ss-wrap {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

/* 原生下拉被隐藏，但保持在 DOM 里作为值持有者 */
.ss-wrap > select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

/* 可输入的主输入框 */
.ss-input {
  width: 100%;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: #fff;
  transition: all var(--transition-fast);
  outline: none;
  box-sizing: border-box;
  cursor: text;
}

.ss-input:hover {
  border-color: var(--color-primary);
}

.ss-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(45, 140, 240, 0.12);
}

.ss-input::placeholder {
  color: var(--color-text-disabled);
}

/* 右侧箭头/清除图标容器 */
.ss-trigger {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  user-select: none;
  pointer-events: auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}

.ss-trigger:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232D8CF0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* 下拉面板（挂在 body 上，用 fixed 定位避免被 overflow 裁剪） */
.ss-dropdown {
  position: fixed;
  margin-top: 0;
  background: #fff;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08), 0 3px 6px rgba(0, 0, 0, 0.04);
  max-height: 260px;
  overflow-y: auto;
  z-index: 9999;
  display: none;
}

.ss-dropdown.open {
  display: block;
}

/* 选项 */
.ss-option {
  padding: 6px 10px;
  font-size: var(--font-size-base);
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 20px;
}

.ss-option:hover,
.ss-option.hover {
  background: #F5F7FA;
}

.ss-option.selected {
  color: var(--color-primary);
  font-weight: 500;
  background: rgba(45, 140, 240, 0.06);
}

/* 分组标题（不可点） */
.ss-group-title {
  padding: 5px 10px 3px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: #FAFAFA;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: default;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 18px;
}

/* 组内选项缩进，表达层级 */
.ss-dropdown .ss-group-title ~ .ss-option {
  padding-left: 18px;
}

/* 多选模式：选项前置复选框 */
.ss-dropdown.ss-multi .ss-option {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ss-check {
  flex: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--color-border-dark);
  border-radius: 3px;
  background: var(--color-surface);
  position: relative;
  transition: all var(--transition-fast);
}
.ss-option:hover .ss-check {
  border-color: var(--color-primary);
}
.ss-option.selected .ss-check {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.ss-option.selected .ss-check::after {
  content: '';
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* 空结果提示 */
.ss-empty {
  padding: 16px 10px;
  text-align: center;
  color: var(--color-text-disabled);
  font-size: var(--font-size-sm);
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] .ss-input {
  background: #1e1f22;
  border-color: var(--color-border-dark);
  color: var(--color-text);
}

[data-theme="dark"] .ss-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.15);
}

[data-theme="dark"] .ss-dropdown {
  background: #2a2d32;
  border-color: var(--color-border-dark);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

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

[data-theme="dark"] .ss-option:hover,
[data-theme="dark"] .ss-option.hover {
  background: #3a3b42;
}

[data-theme="dark"] .ss-option.selected {
  background: rgba(91, 141, 239, 0.15);
  color: #5b8def;
}

[data-theme="dark"] .ss-empty {
  color: var(--color-text-muted);
}

[data-theme="dark"] .ss-group-title {
  background: #31333a;
  color: var(--color-text-muted);
}

/* ============================================================
   备份提醒黄条（工作台）
   ============================================================ */
.backup-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--color-warning-light);
  border: 1px solid rgba(250, 173, 20, 0.35);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.backup-bar svg {
  flex-shrink: 0;
  color: var(--color-warning);
}

.backup-bar-text {
  flex: 1;
  color: #d48806;
  line-height: 1.5;
}

.backup-bar-text strong {
  font-weight: 600;
}

[data-theme="dark"] .backup-bar-text {
  color: var(--color-warning);
}

/* ============================================================
   批量操作栏（证书管理）
   ============================================================ */
.batch-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--color-primary-lighter);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.batch-bar-text {
  flex: 1;
  color: var(--color-primary);
  font-weight: 500;
}

.data-table tbody tr.row-selected {
  background: rgba(45, 140, 240, 0.06);
}

[data-theme="dark"] .data-table tbody tr.row-selected {
  background: rgba(91, 141, 239, 0.12);
}

/* ============================================================
   证书图片（上传缩略图 + 大图查看）
   ============================================================ */
.cert-img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cert-img-thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.cert-img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}

.cert-img-thumb .cert-img-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  padding: 0;
}

.cert-img-thumb .cert-img-remove:hover {
  background: rgba(220, 38, 38, 0.9);
}

.cert-img-thumb .cert-img-zoomtip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
  pointer-events: none;
}

.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.img-lightbox img {
  max-width: 92vw;
  max-height: 80vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
