/* ============================================
   管理后台专属样式 - Admin Dashboard Styles
   基于大健康主题视觉系统扩展
   ============================================ */

/* ===== 布局系统 ===== */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--primary-800) 0%, var(--primary-900) 100%);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
}

.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-400), var(--secondary-400));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.sidebar-logo-text {
  color: white;
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-logo-sub {
  color: var(--primary-300);
  font-size: var(--font-size-xs);
  margin-top: 2px;
}

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

.sidebar-nav-section {
  margin-bottom: 20px;
}

.sidebar-nav-title {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-400);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--primary-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--font-size-sm);
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
}

.sidebar-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.sidebar-menu-item.active {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(20, 184, 166, 0.2));
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.sidebar-menu-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--secondary-400);
  border-radius: 0 4px 4px 0;
}

.sidebar-menu-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sidebar-menu-badge {
  margin-left: auto;
  background: var(--warm-500);
  color: white;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--warm-400), var(--warm-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: var(--font-size-sm);
}

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

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

.sidebar-user-role {
  color: var(--primary-400);
  font-size: 11px;
}

/* ===== 主内容区 ===== */
.main-content {
  flex: none;
  width: calc(100% - 240px);
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  box-sizing: border-box;
}

/* ===== 顶部导航栏 ===== */
.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-sm);
}

.breadcrumb-item {
  color: var(--text-secondary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-separator {
  color: var(--text-muted);
  font-size: 12px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-search {
  position: relative;
  width: 280px;
}

.topbar-search input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  background: var(--gray-50);
  transition: all var(--transition-fast);
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--primary-400);
  background: white;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

.topbar-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
}

.topbar-icon-btn:hover {
  background: var(--primary-50);
  color: var(--primary-600);
}

.topbar-notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid white;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.topbar-user:hover {
  background: var(--gray-100);
}

.topbar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-400), var(--secondary-400));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.topbar-user-info {
  text-align: right;
}

.topbar-user-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.topbar-user-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== 页面内容 ===== */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ===== 筛选栏 ===== */
.filter-bar {
  background: white;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.filter-input {
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  min-width: 140px;
  transition: all var(--transition-fast);
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.filter-select {
  padding: 7px 30px 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  background: white;
  cursor: pointer;
  appearance: none;
  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='%236B7280' stroke-width='2' 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;
}

.filter-spacer {
  flex: 1;
}

/* ===== 统计卡片网格 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== 图表卡片 ===== */
.chart-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  min-width: 0;          /* 允许在 grid 中收缩，防止被内容撑破 */
  overflow: hidden;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

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

.chart-actions {
  display: flex;
  gap: 8px;
}

.chart-tab {
  padding: 6px 14px;
  font-size: var(--font-size-xs);
  border: 1px solid var(--border-color);
  background: white;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.chart-tab:hover {
  border-color: var(--primary-300);
  color: var(--primary-600);
}

.chart-tab.active {
  background: var(--primary-500);
  border-color: var(--primary-500);
  color: white;
}

.chart-container {
  height: 300px;
  position: relative;
}

/* canvas 默认是 300px 宽的 inline 元素，会在窄 grid 列里撑破布局，
   这里强制其为块级、充满容器并限制最大宽度 */
.chart-container canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
}

/* ===== 两栏布局 ===== */
.two-col-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* 防止 grid 子项被内部内容(min-width:auto)撑破导致右侧溢出 */
.two-col-grid > * {
  min-width: 0;
}

@media (max-width: 1024px) {
  .two-col-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #F0FDF4 0%, #ECFDF5 40%, #F0FDFA 70%, #FFFBEB 100%);
}

.login-deco {
  position: absolute;
  pointer-events: none;
}

.login-deco.blob-1 {
  top: -100px;
  right: -50px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.2) 0%, transparent 70%);
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}

.login-deco.blob-2 {
  bottom: -80px;
  left: -60px;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.2) 0%, transparent 70%);
  border-radius: 50%;
  animation: float 8s ease-in-out infinite reverse;
}

.login-deco.blob-3 {
  top: 40%;
  right: 20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  animation: float 5s ease-in-out infinite;
}

.login-card {
  width: 440px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  padding: 48px 40px;
  position: relative;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

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

.login-logo-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.3);
}

.login-logo-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-logo-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.login-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form .form-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.login-input-wrap {
  position: relative;
}

.login-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
}

.login-input-wrap .form-input {
  padding-left: 42px;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.login-remember input {
  accent-color: var(--primary-500);
}

.login-forgot {
  font-size: var(--font-size-sm);
  color: var(--primary-600);
  font-weight: 500;
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: var(--font-size-base);
  font-weight: 600;
}

.login-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

.login-footer-text {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ===== 列表页表格容器 ===== */
.table-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.table-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.table-toolbar-actions {
  display: flex;
  gap: 10px;
}

.table-wrapper {
  overflow-x: auto;
}

.table-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-info {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* ===== 操作按钮组 ===== */
.action-btns {
  display: flex;
  gap: 6px;
}

.action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--primary-100);
  color: var(--primary-600);
}

.action-btn.danger:hover {
  background: #FEE2E2;
  color: var(--error);
}

/* ===== 用户信息行 ===== */
.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-cell-info .name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

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

/* ===== 权限开关组 ===== */
.permission-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.permission-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.permission-item:hover {
  background: var(--primary-50);
}

.permission-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.permission-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: white;
  box-shadow: var(--shadow-sm);
}

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

.permission-text .desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== 详情页 ===== */
.detail-header {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 24px;
}

.detail-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-400), var(--secondary-400));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--font-size-3xl);
  font-weight: 600;
  flex-shrink: 0;
}

.detail-info {
  flex: 1;
}

.detail-name {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.detail-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.detail-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.detail-meta-item .icon {
  font-size: 16px;
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  gap: 10px;
}

/* ===== 时间线 ===== */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary-500);
  z-index: 1;
}

.timeline-item.success .timeline-dot { border-color: var(--success); }
.timeline-item.warning .timeline-dot { border-color: var(--warning); }
.timeline-item.info .timeline-dot { border-color: var(--info); }

.timeline-content {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.timeline-title {
  font-weight: 500;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  margin-bottom: 4px;
}

.timeline-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.timeline-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== 智能体卡片 ===== */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.agent-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.agent-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.agent-avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.agent-avatar.green { background: linear-gradient(135deg, var(--primary-100), var(--primary-200)); }
.agent-avatar.teal { background: linear-gradient(135deg, var(--secondary-100), var(--secondary-200)); }
.agent-avatar.gold { background: linear-gradient(135deg, var(--warm-100), var(--warm-200)); }
.agent-avatar.blue { background: linear-gradient(135deg, #DBEAFE, #BFDBFE); }
.agent-avatar.purple { background: linear-gradient(135deg, #EDE9FE, #DDD6FE); }

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

.agent-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.agent-type {
  font-size: 12px;
  color: var(--text-muted);
}

.agent-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-stats {
  display: flex;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.agent-stat {
  flex: 1;
  text-align: center;
}

.agent-stat-value {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

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

/* ===== 知识库卡片 ===== */
.kb-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kb-item {
  background: white;
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border-light);
  transition: all var(--transition-fast);
}

.kb-item:hover {
  border-color: var(--primary-200);
  box-shadow: var(--shadow-sm);
}

.kb-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

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

.kb-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.kb-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.kb-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kb-progress {
  width: 120px;
  flex-shrink: 0;
}

.kb-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kb-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== 销量统计图表区 ===== */
.sales-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1024px) {
  .sales-overview {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sales-charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 1024px) {
  .sales-charts-row {
    grid-template-columns: 1fr;
  }
}

/* ===== 产品销量排行 ===== */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rank-number {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.rank-item:nth-child(1) .rank-number { background: linear-gradient(135deg, #FCD34D, #F59E0B); color: white; }
.rank-item:nth-child(2) .rank-number { background: linear-gradient(135deg, #D1D5DB, #9CA3AF); color: white; }
.rank-item:nth-child(3) .rank-number { background: linear-gradient(135deg, #F59E0B, #D97706); color: white; }
.rank-item:nth-child(n+4) .rank-number { background: var(--gray-100); color: var(--text-secondary); }

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

.rank-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-bar {
  height: 6px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.rank-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-400), var(--secondary-400));
  border-radius: var(--radius-full);
  transition: width 1s ease;
}

.rank-value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  width: 80px;
  text-align: right;
}

/* ===== 下拉菜单 ===== */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  padding: 6px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
}

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

.dropdown-item {
  padding: 8px 12px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

.dropdown-item.danger {
  color: var(--error);
}

.dropdown-item.danger:hover {
  background: #FEE2E2;
  color: var(--error);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 0;
}

/* ===== 响应式 ===== */
/* 汉堡按钮：默认（桌面端）隐藏，仅移动端显示 */
.show-mobile {
  display: none;
}

/* 侧边栏遮罩层：移动端抽屉打开时显示，点击可关闭 */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}
.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}
body.sidebar-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .sidebar {
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
  }
  
  /* 移动端显示汉堡按钮 */
  .show-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .topbar-search {
    display: none;
  }
  
  /* 顶栏右侧用户信息文本在窄屏隐藏，仅留头像节省空间 */
  .topbar-user-info {
    display: none;
  }
  
  /* 表格容器横向滚动，避免窄屏撑破布局 */
  .card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .data-table {
    width: 100%;
    min-width: 560px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .login-card {
    width: 90%;
    padding: 32px 24px;
  }
  
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .detail-header {
    flex-direction: column;
    text-align: center;
  }
  
  .detail-meta {
    justify-content: center;
  }

  /* 页头：窄屏纵向堆叠，避免长标题挤压右侧操作按钮 */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  /* 表格工具条/页脚：窄屏纵向排列，防止文字挤压换行乱位 */
  .table-toolbar,
  .table-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .table-toolbar-actions {
    flex-wrap: wrap;
  }

  /* 图表头部与 tab：允许换行，避免标题与周/月/年互相挤压 */
  .chart-header {
    flex-wrap: wrap;
    gap: 12px;
  }
  .chart-actions {
    flex-wrap: wrap;
  }

  /* 顶栏：减小内边距；面包屑超长省略，避免撑高固定高度顶栏 */
  .topbar {
    padding: 0 12px;
  }
  .topbar-left {
    min-width: 0;
  }
  .breadcrumb {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* 智能体卡片网格：手机单列，防止 minmax(300px) 窄屏挤压 */
  .agent-grid {
    grid-template-columns: 1fr;
  }

  /* 销售概览：手机两列，避免四列挤成细条 */
  .sales-overview {
    grid-template-columns: 1fr 1fr;
  }

  /* 权限项文字区允许收缩，长描述不挤压开关 */
  .permission-info {
    min-width: 0;
  }

  /* 正文/描述/元信息长串断词，避免撑破卡片 */
  .agent-desc,
  .kb-meta,
  .timeline-desc,
  .consult-record-content,
  .detail-meta-item,
  .user-cell-info .sub {
    overflow-wrap: break-word;
    word-break: break-word;
  }
}

/* ===== 机构树形结构 ===== */
.org-tree {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.org-tree-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.org-tree-item:hover {
  background: var(--primary-50);
}

.org-tree-item.active {
  background: linear-gradient(135deg, var(--primary-50), var(--secondary-50));
  border: 1px solid var(--primary-200);
}

.org-tree-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  font-size: 12px;
}

.org-tree-item.expanded .org-tree-toggle {
  transform: rotate(90deg);
}

.org-tree-icon {
  font-size: 18px;
}

.org-tree-name {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.org-tree-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.org-tree-children {
  padding-left: 32px;
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition-base);
}

.org-tree-item.expanded + .org-tree-children {
  max-height: 1000px;
}

/* ===== 详情Tab内容 ===== */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ===== 咨询记录卡片 ===== */
.consult-record {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--primary-400);
}

.consult-record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

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

.consult-record-time {
  font-size: 12px;
  color: var(--text-muted);
}

.consult-record-content {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
}

.consult-record-footer {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.consult-record-footer span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== 档案信息网格 ===== */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

@media (max-width: 768px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

.profile-section {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.profile-section-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-item {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.profile-label {
  width: 100px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

.profile-value {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  font-weight: 500;
}
