/* ========== 全局重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
*:focus { outline: none; }

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.6;
}

#app {
  display: flex;
  min-height: 100vh;
}

/* ========== 侧边栏 ========== */
.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  border-bottom: 1px solid var(--gray-200);
}

.logo-icon { font-size: 22px; }
.logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.user-name { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.user-role { font-size: 12px; color: var(--gray-400); }

/* ========== 主内容区 ========== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title { font-size: 18px; font-weight: 600; color: var(--gray-800); }
.current-date { font-size: 13px; color: var(--gray-400); }

.page-container {
  padding: 24px;
  flex: 1;
}

/* ========== 通用组件 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-outline {
  background: #fff;
  color: var(--gray-600);
  border-color: var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-light); }

.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.btn-link.warning { color: var(--warning); }

/* 卡片 */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 20px; }

/* 表格 */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 12px 16px;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tr:hover td { background: var(--gray-50); }

.table-actions { display: flex; gap: 8px; white-space: nowrap; }

/* 搜索栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 36px;
  min-width: 240px;
}

.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 13px;
  background: transparent;
  color: var(--gray-800);
}

.search-box .search-icon { color: var(--gray-400); font-size: 14px; }

.filter-select {
  height: 36px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  background: #fff;
  color: var(--gray-700);
  cursor: pointer;
}

.toolbar-spacer { flex: 1; }

/* 标签 / 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: #92400e; }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-cyan { background: var(--info-light); color: var(--info); }

/* ========== 仪表盘 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  padding: 20px;
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: var(--success-light); }
.stat-icon.yellow { background: var(--warning-light); }
.stat-icon.cyan { background: var(--info-light); }

.stat-label { font-size: 13px; color: var(--gray-500); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-800); }
.stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* 管道图 */
.pipeline-bar {
  display: flex;
  align-items: center;
  gap: 0;
  height: 32px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.pipeline-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  font-weight: 600;
  transition: flex 0.3s ease;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.pipeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-600);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* 待办列表 */
.todo-list { list-style: none; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.todo-item:last-child { border-bottom: none; }

.todo-priority {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.todo-priority.high { background: var(--danger); }
.todo-priority.medium { background: var(--warning); }
.todo-priority.low { background: var(--gray-300); }

.todo-content { flex: 1; min-width: 0; }
.todo-title { font-size: 13px; color: var(--gray-800); }
.todo-meta { font-size: 12px; color: var(--gray-400); }

/* 活动时间线 */
.timeline { list-style: none; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 5px;
}
.timeline-content { flex: 1; }
.timeline-text { font-size: 13px; color: var(--gray-700); }
.timeline-time { font-size: 12px; color: var(--gray-400); }

/* ========== 模态框 ========== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 560px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

.modal.modal-lg { width: 800px; }
.modal.modal-sm { width: 400px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 600; color: var(--gray-800); }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-400);
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-600); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-label .required { color: var(--danger); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 36px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 12px;
  resize: vertical;
}

.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 240px;
  border-left: 3px solid var(--gray-300);
  animation: slideInRight 0.2s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--primary); }

.toast-icon { font-size: 16px; }

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

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; }
.empty-state .empty-hint { font-size: 12px; margin-top: 4px; }

/* ========== 看板 ========== */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  flex: 0 0 260px;
  background: var(--gray-100);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.kanban-column-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.kanban-column-body {
  padding: 0 8px 8px;
  overflow-y: auto;
  flex: 1;
}

.kanban-card {
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid var(--gray-200);
  transition: box-shadow 0.15s ease;
}

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

.kanban-card-title { font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 6px; }
.kanban-card-meta { font-size: 12px; color: var(--gray-400); }
.kanban-card-amount { font-size: 14px; font-weight: 700; color: var(--primary); margin-top: 4px; }

/* ========== 客户详情 ========== */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 16px;
}

.detail-tab {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.detail-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}

.detail-info-item {
  display: flex;
  flex-direction: column;
}

.detail-info-label { font-size: 12px; color: var(--gray-400); margin-bottom: 2px; }
.detail-info-value { font-size: 14px; color: var(--gray-800); }

/* ========== 导入导出区 ========== */
.import-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.import-zone:hover { border-color: var(--primary); }

.import-zone .import-icon { font-size: 36px; margin-bottom: 8px; }
.import-zone .import-text { font-size: 14px; color: var(--gray-600); }
.import-zone .import-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ========== 分页 ========== */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  font-size: 13px;
  color: var(--gray-500);
}

.pagination .btn { padding: 4px 10px; font-size: 13px; }

/* ========== 视图切换Tab ========== */
.view-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-tab {
  padding: 7px 16px;
  font-size: 13px;
  background: #fff;
  color: var(--gray-500);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-tab:first-child { border-right: 1px solid var(--gray-300); }
.view-tab:hover { background: var(--gray-50); }
.view-tab.active { background: var(--primary); color: #fff; }

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.view-tab.active .tab-badge { background: rgba(255,255,255,0.3); }

/* ========== 标签Chip ========== */
.tag-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
  margin-right: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
}

.tag-more {
  display: inline-block;
  font-size: 12px;
  color: var(--gray-400);
  margin-left: 2px;
}

/* ========== 批量操作栏 ========== */
.batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid #bfdbfe;
}

.batch-info { font-size: 13px; color: var(--gray-700); }
.batch-info strong { color: var(--primary-dark); }
.batch-actions { display: flex; gap: 8px; align-items: center; }

/* ========== 标签选择器（表单内） ========== */
.tag-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  min-height: 42px;
}

.tag-option {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 13px;
  background: var(--gray-100);
  color: var(--gray-500);
  cursor: pointer;
  border: 1px solid var(--gray-200);
  transition: all 0.15s ease;
  user-select: none;
}

.tag-option:hover { border-color: var(--primary); color: var(--primary); }

.tag-option.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tag-option.add-tag {
  background: #fff;
  border-style: dashed;
  color: var(--gray-400);
}

.tag-option.add-tag:hover { color: var(--primary); border-color: var(--primary); }

/* ========== 表格复选框列 ========== */
table th:first-child:has(input[type="checkbox"]),
table td:first-child:has(input[type="checkbox"]) {
  width: 36px;
  text-align: center;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .detail-info-grid { grid-template-columns: 1fr; }
}

/* ========== 通知铃铛 ========== */
.bell-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  display: flex;
  align-items: center;
}
.bell-btn:hover { background: var(--gray-100); }
.bell-icon { font-size: 18px; }
.bell-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ========== 销售漏斗 ========== */
.funnel-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  transition: background 0.15s ease;
  border-radius: 4px;
}

.funnel-row:hover {
  background: var(--gray-50);
}

.funnel-stage-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  font-size: 13px;
}

.funnel-stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.funnel-bar-wrapper {
  flex: 1;
  min-width: 0;
}

.funnel-bar {
  height: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  transition: width 0.3s ease;
  min-width: 40px;
}

.funnel-bar-count {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.funnel-stage-amount {
  min-width: 100px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}

.funnel-stage-percent {
  min-width: 50px;
  text-align: right;
  font-size: 12px;
  color: var(--gray-400);
}

/* 漏斗明细项 */
.funnel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.funnel-item:hover {
  border-color: var(--primary);
}

/* ========== 权限提示栏 ========== */
.permission-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 12px;
}

.permission-bar.manager {
  background: var(--primary-light);
}

.permission-bar.sales {
  background: var(--warning-light);
}

/* ========== 视图切换按钮组 ========== */
.view-btn-group {
  display: flex;
  gap: 0;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  overflow: hidden;
}

.view-btn {
  padding: 7px 14px;
  font-size: 13px;
  background: #fff;
  color: var(--gray-500);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn:not(:last-child) {
  border-right: 1px solid var(--gray-300);
}

.view-btn:hover {
  background: var(--gray-50);
}

.view-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ========== 颜色选择器 ========== */
.color-pick {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid var(--gray-300);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.color-pick.selected {
  border-color: var(--primary);
  border-width: 2px;
}

/* ========== 角色Badge ========== */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.role-badge-icon {
  font-size: 13px;
  line-height: 1;
}

/* 角色颜色变体 */
.role-badge.super_admin {
  background: #dc262615;
  color: #dc2626;
  border: 1px solid #dc262633;
}

.role-badge.sales_manager {
  background: #2563eb15;
  color: #2563eb;
  border: 1px solid #2563eb33;
}

.role-badge.sales {
  background: #16a34a15;
  color: #16a34a;
  border: 1px solid #16a34a33;
}

.role-badge.marketing {
  background: #f59e0b15;
  color: #b45309;
  border: 1px solid #f59e0b33;
}

.role-badge.service {
  background: #0891b215;
  color: #0891b2;
  border: 1px solid #0891b233;
}

.role-badge.employee {
  background: #94a3b815;
  color: #64748b;
  border: 1px solid #94a3b833;
}

/* ========== 角色选择器 ========== */
.role-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.role-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  background: #fff;
  font-size: 12px;
  transition: all 0.15s ease;
}

.role-option:hover {
  border-color: var(--primary);
  background: var(--gray-50);
}

.role-option.active {
  font-weight: 600;
}

.role-option input[type="radio"] {
  accent-color: var(--primary);
  margin: 0;
}

.role-option-icon {
  font-size: 14px;
  line-height: 1;
}

/* ========== 权限提示栏增强 ========== */
.permission-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 12px;
}

.permission-bar.manager {
  background: var(--primary-light);
}

.permission-bar.sales {
  background: var(--warning-light);
}

.permission-bar.service {
  background: #0891b215;
  border: 1px solid #0891b233;
}

.permission-bar.marketing {
  background: #f59e0b15;
  border: 1px solid #f59e0b33;
}

.permission-bar.employee {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
}

/* ========== 权限列表 ========== */
.permission-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.permission-list li {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 12px;
  color: var(--gray-600);
}

.permission-list li::before {
  content: "\2713";
  color: var(--success);
  margin-right: 4px;
  font-size: 11px;
}

/* ========== 无权限空状态 ========== */
.no-permission-state {
  text-align: center;
  padding: 60px 20px;
}

.no-permission-state .no-perm-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.no-permission-state .no-perm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.no-permission-state .no-perm-desc {
  font-size: 13px;
  color: var(--gray-400);
  line-height: 1.6;
  max-width: 360px;
  margin: 0 auto;
}

.no-permission-state .no-perm-hint {
  display: inline-block;
  margin-top: 16px;
  padding: 6px 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  font-size: 12px;
  color: var(--gray-500);
}

/* ========== 侧边栏用户角色标识 ========== */
.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
  margin-left: 4px;
}

/* ========== 看板：Tab切换 + 日期筛选 ========== */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dashboard-tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: var(--radius-md);
}

.dashboard-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.dashboard-tab:hover {
  color: var(--gray-800);
  background: rgba(255, 255, 255, 0.6);
}

.dashboard-tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.dashboard-tab .tab-icon {
  font-size: 15px;
}

.period-filter {
  display: flex;
  gap: 2px;
  background: var(--gray-100);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.period-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.2s ease;
}

.period-btn:hover {
  color: var(--gray-800);
}

.period-btn.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.dashboard-content {
  animation: fadeIn 0.2s ease;
}

/* ========== 销售排名列表 ========== */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.ranking-item:hover {
  background: var(--gray-100);
}

.ranking-medal {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
  font-weight: 700;
  color: var(--gray-500);
}

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

.ranking-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
}

.ranking-bar-wrap {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.ranking-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.ranking-amount {
  text-align: right;
  flex-shrink: 0;
  min-width: 80px;
}

.ranking-money {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.ranking-count {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ========== 商机阶段分布 ========== */
.stage-bar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stage-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.stage-bar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-700);
  font-weight: 500;
}

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

.stage-bar-count {
  color: var(--gray-400);
}

.stage-bar-track {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.stage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}

/* ========== 目标完成率进度条 ========== */
.goal-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-progress-bar {
  height: 24px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.goal-progress-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
  min-width: 2px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.goal-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--gray-600);
}

/* ========== 渠道获客对比 ========== */
.channel-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.channel-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.channel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.channel-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.channel-count {
  font-size: 12px;
  color: var(--gray-400);
}

.channel-bar-track {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.channel-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.channel-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--gray-500);
}

.channel-meta strong {
  color: var(--gray-700);
}

.channel-conv-track {
  height: 4px;
  background: var(--gray-100);
  border-radius: 2px;
  overflow: hidden;
}

.channel-conv-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
  min-width: 1px;
}

/* ========== 工单类型统计 ========== */
.type-stat-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.type-stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.type-stat-name {
  font-size: 13px;
  color: var(--gray-700);
  width: 80px;
  flex-shrink: 0;
}

.type-stat-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.type-stat-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.type-stat-count {
  font-size: 12px;
  color: var(--gray-500);
  width: 50px;
  text-align: right;
  flex-shrink: 0;
}

.type-stat-rate {
  font-size: 13px;
  font-weight: 600;
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

/* ========== 优先级统计 ========== */
.priority-stat-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.priority-stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

.priority-badge-sm {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  width: 40px;
  justify-content: center;
  flex-shrink: 0;
}

.priority-stat-total {
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 500;
}

.priority-stat-resolved {
  font-size: 12px;
  color: var(--gray-400);
  flex: 1;
}

.priority-stat-rate {
  font-size: 14px;
  font-weight: 700;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 管理后台 ========== */
.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-200);
}

.admin-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}

/* 角色分布 */
.role-distribution {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.role-dist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.role-dist-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.role-dist-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 2px 2px 0;
  transition: width 0.3s ease;
  opacity: 0.6;
}

/* 规则概览网格 */
.rules-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.rule-overview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

.rule-overview-item .rule-label {
  font-size: 13px;
  color: var(--gray-500);
}

.rule-overview-item .rule-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

/* 权限矩阵 */
.perm-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.perm-matrix-table th,
.perm-matrix-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
}

.perm-matrix-table th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 12px;
  color: var(--gray-600);
}

.perm-group-row td {
  background: var(--gray-50);
  padding: 6px 12px;
  border-bottom: 1px solid var(--gray-200);
}

.perm-matrix-table tbody tr:hover {
  background: var(--primary-light);
}

/* 角色说明卡片 */
.role-desc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.role-desc-card {
  padding: 14px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

/* 规则表单 */
.rules-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.rule-form-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-form-item .form-input {
  width: 80px;
}

/* 日志列表 */
.log-list {
  display: flex;
  flex-direction: column;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.15s;
}

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

.log-item:hover {
  background: var(--gray-50);
}

.log-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.log-content {
  flex: 1;
  min-width: 0;
}

.log-title {
  font-size: 13px;
  color: var(--gray-700);
}

.log-detail {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}

.log-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* 响应式 */
@media (max-width: 1024px) {
  .role-distribution,
  .rules-overview-grid,
  .role-desc-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .rules-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .role-distribution,
  .rules-overview-grid,
  .role-desc-grid {
    grid-template-columns: 1fr;
  }
  .perm-matrix-table {
    font-size: 12px;
  }
}

/* ========== 登录页面 ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 50%, #f8fafc 100%);
}

.login-card {
  width: 400px;
  max-width: 90vw;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

/* ========== 退出登录按钮 ========== */
.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== 动画 ========== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
