/* ===== 基础 ===== */
:root {
  --color-bg: #f5f7fa;
  --color-text: #2c3e50;
  --color-text-muted: #6b7280;
  --color-primary: #3b82f6;
  --color-danger: #ef4444;
  --color-success: #10b981;
  --color-border: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 8px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "DM Sans", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; color: #475569; }
.muted { color: var(--color-text-muted); }
.small { font-size: 12px; }
.text-green { color: var(--color-success); }
.text-red { color: var(--color-danger); }

/* ===== 顶部导航 ===== */
.top-nav {
  background: #1f2937;
  color: white;
  padding: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-right { display: flex; align-items: center; gap: 12px; }
.brand {
  color: white !important;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
}
.nav-links a {
  color: #d1d5db !important;
  margin-left: 24px;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
}
.nav-links a:hover, .nav-links a.active {
  background: #374151;
  color: white !important;
}
.nav-user { font-size: 13px; color: #cbd5e1; }
.theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}
.theme-toggle:hover { opacity: 0.7; }
.logout-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid #4b5563;
  color: #cbd5e1;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
}
.logout-btn:hover { background: #374151; }

/* ===== 容器 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  transition: opacity 0.15s var(--ease);
}

/* ===== 页头 ===== */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-head h1 { margin: 0; font-size: 22px; }
.session-head { align-items: flex-start; }
.back-link { color: #6b7280; font-size: 13px; }
.meta-row {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #4b5563;
}
.nav-arrows { display: flex; gap: 12px; }
.nav-arrows a {
  padding: 6px 14px;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151 !important;
  text-decoration: none;
}

/* ===== 搜索 ===== */
.search-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.search-form input[type=text],
.search-form select {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  background: white;
  color: var(--color-text);
}
.search-form button {
  padding: 8px 16px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* ===== 统一按钮系统 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
  transition: all 0.15s var(--ease);
  text-decoration: none !important;
}
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; }
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-primary:disabled { background: #cbd5e1; cursor: not-allowed; color: #94a3b8; }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-danger:disabled { background: #fecaca; cursor: not-allowed; }
.btn-secondary { background: white; color: #1e293b; border-color: #cbd5e1; }
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; }
.btn-ghost { background: transparent; color: #475569; border-color: transparent; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-clear {
  padding: 6px 12px;
  background: #e5e7eb;
  color: #374151;
  border-radius: 4px;
  text-decoration: none;
  font-size: 13px;
}
.btn-clear:hover { background: #d1d5db; }
.btn-icon {
  background: white;
  border: 1px solid #d1d5db;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.15s var(--ease);
}
.btn-icon:hover { background: #f9fafb; }

/* ===== 列表 ===== */
.session-list {
  background: white;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.session-row {
  display: grid;
  grid-template-columns: 28px 48px 1fr 140px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s var(--ease);
  gap: 14px;
}
.session-row:last-child { border-bottom: none; }
.session-row:hover { background: #f8fafc; }
.row-check-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  width: 28px;
  height: 28px;
}
.row-check {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}
.row-no {
  font-weight: 600;
  color: #94a3b8;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-decoration: none !important;
  transition: color 0.15s var(--ease);
}
.row-no:hover { color: var(--color-primary); }
.row-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none !important;
  color: inherit !important;
  min-width: 0;
}
.row-snippet {
  font-size: 14px;
  color: #1e293b;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}
.visitor-text::before {
  content: "💬 ";
  color: #94a3b8;
}
.row-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: #64748b;
  flex-wrap: wrap;
  align-items: center;
}
.meta-item { white-space: nowrap; }
.meta-green { color: #059669; font-weight: 600; }
.meta-red { color: #dc2626; font-weight: 600; }
.meta-done {
  background: #ecfdf5;
  color: #047857;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 11px;
}
.row-batch {
  font-size: 11px;
  color: #6d28d9;
  background: #f5f3ff;
  padding: 3px 10px;
  border-radius: 10px;
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 500;
}

/* ===== 筛选 chip ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.filter-label {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-right: 4px;
  font-weight: 500;
}
.batch-action-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  margin-left: 8px;
  border-left: 1px solid var(--color-border);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 14px;
  background: white;
  border: 1px solid var(--color-border);
  color: #475569;
  font-size: 12px;
  text-decoration: none !important;
  transition: all 0.15s var(--ease);
  font-weight: 500;
}
.chip:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}
.chip-active {
  background: var(--color-primary);
  color: white !important;
  border-color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}
.chip-count {
  background: #f1f5f9;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}
.chip-active .chip-count {
  background: rgba(255,255,255,0.25);
  color: white;
}

/* ===== 批量操作栏 ===== */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.bulk-bar[hidden] { display: none; }
.bulk-actions { display: flex; gap: 8px; }
.bulk-info { font-size: 13px; color: #4b5563; }
.bulk-info strong { color: var(--color-primary); font-weight: 600; }

/* ===== 导出下拉 ===== */
.export-group { position: relative; }
.export-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 50;
  min-width: 200px;
  overflow: hidden;
}
.export-dropdown[hidden] { display: none; }
.export-dropdown-header {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.export-option {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--color-text) !important;
  text-decoration: none !important;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.export-option:last-child { border-bottom: none; }
.export-option:hover { background: #f8fafc; }

/* ===== 表单 ===== */
.page-sub { margin: 4px 0 0; color: #6b7280; font-size: 13px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.form-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.form-row label.full { grid-column: 1 / -1; }
.form-row label.full input { width: 100%; }
.form-row input,
.form-row select,
.form-row textarea {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--color-text);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ===== 登录页 ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}
.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  width: 400px;
  max-width: 90%;
}
.login-box h1 { text-align: center; margin-bottom: 4px; }
.login-box p { text-align: center; margin-bottom: 24px; }
.login-box label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.login-box input[type=text],
.login-box input[type=password] {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.login-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] { display: none !important; }
.modal-box {
  background: white;
  padding: 28px;
  border-radius: 12px;
  width: 480px;
  max-width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-box h3 { margin: 0 0 16px; font-size: 18px; }
.modal-box label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.modal-box input,
.modal-box select {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

/* ===== 看板 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-grid-primary { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stat-grid-secondary {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: -8px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-blue { border-left-color: #3b82f6; }
.stat-green { border-left-color: #10b981; }
.stat-red { border-left-color: #ef4444; }
.stat-purple { border-left-color: #8b5cf6; }
.stat-label { color: #6b7280; font-size: 13px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }

.mini-stat {
  background: white;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mini-label { font-size: 12px; color: var(--color-text-muted); }
.mini-value { font-size: 22px; font-weight: 700; }

.dashboard-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid #e5e7eb;
}
.card-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 16px;
  margin: 0;
  color: #1e293b;
  font-weight: 600;
}

/* ===== 排行榜切换 ===== */
.rank-toggle {
  display: inline-flex;
  background: #f1f5f9;
  padding: 2px;
  border-radius: 6px;
  gap: 2px;
}
.rank-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #64748b;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s var(--ease);
}
.rank-tab:hover { color: #1e293b; }
.rank-tab.active {
  background: white;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  font-weight: 600;
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== 条形图 ===== */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 50px;
  align-items: center;
  gap: 12px;
}
.bar-label {
  font-size: 13px;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  background: #f3f4f6;
  border-radius: 4px;
  height: 28px;
  overflow: hidden;
}
.bar-fill {
  background: linear-gradient(90deg, #ef4444, #f87171);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: white;
  font-weight: 600;
  font-size: 12px;
  border-radius: 4px;
  min-width: 32px;
  transition: width 0.3s;
}
.bar-num { color: white; font-weight: 600; }
.bar-pct { text-align: right; }

/* ===== 优秀话术 ===== */
.reply-list { display: flex; flex-direction: column; gap: 10px; max-height: 500px; overflow-y: auto; }
.reply-item {
  padding: 10px;
  border-radius: 6px;
  border-left: 3px solid;
  background: #f9fafb;
}
.reply-up { border-left-color: #10b981; }
.reply-down { border-left-color: #ef4444; }
.reply-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; }
.tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.tag-up { background: #d1fae5; color: #065f46; }
.tag-down { background: #fee2e2; color: #991b1b; }
.reply-link { font-size: 11px; color: #6b7280; }
.reply-original, .reply-better {
  font-size: 13px;
  margin-top: 4px;
  color: #4b5563;
}
.reply-original span, .reply-better span { color: #1f2937; }

/* ===== 表格 ===== */
.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rank-table th, .rank-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
}
.rank-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #6b7280;
}

/* ===== 任务卡片 ===== */
.task-meta, .task-config {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: #4b5563;
  flex-wrap: wrap;
}
.status-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.status-running { background: #dbeafe; color: #1e40af; }
.status-done { background: #d1fae5; color: #065f46; }
.status-stop { background: #fed7aa; color: #9a3412; }
.status-fail { background: #fee2e2; color: #991b1b; }
.task-running { padding: 8px 0; }

/* ===== 进度条 ===== */
.progress-bar {
  position: relative;
  background: #f3f4f6;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  height: 100%;
  transition: width 0.5s ease;
  border-radius: 6px;
}
.progress-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

/* ===== 空状态 ===== */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
}

/* ===== 聊天容器 ===== */
.chat-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid #e5e7eb;
}
.bubble-row {
  display: flex;
  margin-bottom: 18px;
  align-items: flex-start;
  gap: 8px;
}
.bubble-row.visitor { justify-content: flex-start; }
.bubble-row.staff { justify-content: flex-end; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  position: relative;
  word-break: break-word;
  line-height: 1.6;
}
.bubble-visitor {
  background: #f3f4f6;
  color: #2c3e50;
  border-top-left-radius: 4px;
}
.bubble-staff {
  background: #d1fae5;
  color: #064e3b;
  border-top-right-radius: 4px;
}
.bubble-staff.labeled-down {
  background: #fee2e2;
  border: 1px solid #fca5a5;
}
.bubble-meta {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 4px;
}
.bubble-text { white-space: pre-wrap; }
.action-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
}
.btn-up, .btn-down {
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.btn-up:hover { background: #d1fae5; }
.btn-down:hover { background: #fee2e2; }
.btn-up.active { background: #10b981; color: white; border-color: #059669; }
.btn-down.active { background: #ef4444; color: white; border-color: #dc2626; }

/* ===== 点踩详情 ===== */
.down-detail {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #fca5a5;
}
.reason-tag {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  display: inline-block;
  margin-bottom: 6px;
}
.better-reply-block { margin-top: 6px; font-size: 12px; }
.better-reply-block summary { cursor: pointer; color: #3b82f6; }
.better-reply-input {
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  background: white;
  color: #1e293b;
}
.btn-save-reply {
  margin-top: 6px;
  padding: 4px 12px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.down-form {
  margin-top: 10px;
  padding: 10px;
  background: #fff7ed;
  border-radius: 6px;
  border: 1px solid #fed7aa;
}
.down-form label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 6px;
  margin-bottom: 4px;
}
.down-form select, .down-form textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  background: white;
  color: #1e293b;
}

/* ===== AI 分析总结卡片 ===== */
.ai-summary-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ai-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 14px;
  color: #0369a1;
}
.ai-summary-body {
  font-size: 13px;
  line-height: 1.7;
  color: #1e293b;
  white-space: pre-wrap;
}

/* ===== AI 轮次评价 ===== */
.ai-eval {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #cbd5e1;
}
.ai-eval-inner { font-size: 12px; line-height: 1.6; }
.rating-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
}
.rating-good { background: #dcfce7; color: #166534; }
.rating-mid { background: #fef3c7; color: #92400e; }
.rating-bad { background: #fee2e2; color: #991b1b; }
.ai-reason { color: #475569; margin-top: 2px; }
.ai-suggestion {
  color: #0369a1;
  margin-top: 4px;
  padding: 6px 8px;
  background: #f0f9ff;
  border-radius: 6px;
  border-left: 3px solid #38bdf8;
}

/* ===== 系统配置 ===== */
.reason-config-list { margin-bottom: 16px; }
.reason-config-header {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 12px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--color-text-muted);
  border-bottom: 1px solid #f1f5f9;
}
.reason-config-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}
.reason-config-row:last-child { border-bottom: none; }
.reason-add-row { display: flex; gap: 8px; }
.reason-add-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.ai-config-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.ai-config-form input {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  max-width: 480px;
}
.model-list {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 480px;
}
.model-chip {
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  color: var(--color-text);
  background: white;
  transition: all 0.1s;
  font-family: inherit;
}
.model-chip:hover { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* ===== 全局 focus ===== */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible { outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .dashboard-row { grid-template-columns: 1fr; }
  .stat-grid-primary { grid-template-columns: 1fr 1fr; }
  .session-row {
    grid-template-columns: 28px 1fr;
    grid-template-areas:
      "check main"
      ".    batch";
    row-gap: 6px;
  }
  .row-check-wrap { grid-area: check; }
  .row-main { grid-area: main; }
  .row-batch {
    grid-area: batch;
    justify-self: start;
    font-size: 10px;
  }
  .row-no { display: none; }
  .bubble { max-width: calc(100% - 56px); }
  .search-form { flex-wrap: wrap; }
  .search-form input[type=text] { width: 100%; }
  .container { padding: 16px; }
  .bulk-bar { flex-wrap: wrap; }
}

/* ===== Dark Mode（强覆盖版） ===== */
html[data-theme="dark"] {
  background-color: #0f172a !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] body {
  background-color: #0f172a !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .top-nav {
  background: #1e293b !important;
}
html[data-theme="dark"] .brand {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .nav-links a {
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .nav-links a:hover,
html[data-theme="dark"] .nav-links a.active {
  background: #334155 !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .nav-user {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .logout-btn {
  background: #334155 !important;
  color: #cbd5e1 !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .container {
  background: #0f172a !important;
}
html[data-theme="dark"] .page-head h1 {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .page-sub {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .session-list,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .mini-stat,
html[data-theme="dark"] .bulk-bar,
html[data-theme="dark"] .ai-summary-card,
html[data-theme="dark"] .chat-container {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .card h2,
html[data-theme="dark"] .page-head h1,
html[data-theme="dark"] .row-snippet {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .session-row {
  border-color: #334155 !important;
}
html[data-theme="dark"] .session-row:hover {
  background-color: #334155 !important;
}
html[data-theme="dark"] .row-meta {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .row-no {
  color: #64748b !important;
}
html[data-theme="dark"] .row-batch {
  background-color: #2e1065 !important;
  color: #c4b5fd !important;
}
html[data-theme="dark"] .meta-done {
  background-color: #064e3b !important;
  color: #6ee7b7 !important;
}
html[data-theme="dark"] input[type=text],
html[data-theme="dark"] input[type=password],
html[data-theme="dark"] input[type=number],
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .reason-add-input,
html[data-theme="dark"] .ai-config-form input {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .search-form input,
html[data-theme="dark"] .search-form select {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .filter-bar .chip {
  background-color: #1e293b !important;
  border-color: #475569 !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .chip-active {
  background-color: #60a5fa !important;
  color: #0f172a !important;
}
html[data-theme="dark"] .chip-count {
  background-color: #334155 !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .chip-active .chip-count {
  background-color: rgba(255,255,255,0.25) !important;
  color: #0f172a !important;
}
html[data-theme="dark"] .batch-action-inline {
  border-left-color: #334155 !important;
}
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-icon {
  background-color: #334155 !important;
  color: #e2e8f0 !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .btn-ghost {
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .btn-ghost:hover {
  background-color: #334155 !important;
}
html[data-theme="dark"] .btn-clear {
  background-color: #334155 !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .btn-up,
html[data-theme="dark"] .btn-down {
  background-color: #334155 !important;
  color: #e2e8f0 !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .btn-up:hover {
  background-color: #065f46 !important;
}
html[data-theme="dark"] .btn-down:hover {
  background-color: #7f1d1d !important;
}
html[data-theme="dark"] .bubble-visitor {
  background-color: #334155 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .bubble-staff {
  background-color: #064e3b !important;
  color: #d1fae5 !important;
}
html[data-theme="dark"] .bubble-staff.labeled-down {
  background-color: #7f1d1d !important;
  border-color: #ef4444 !important;
}
html[data-theme="dark"] .bubble-meta {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .down-form {
  background-color: #451a03 !important;
  border-color: #92400e !important;
}
html[data-theme="dark"] .down-form select,
html[data-theme="dark"] .down-form textarea {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] .better-reply-input {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] .reason-tag {
  background-color: #451a03 !important;
  color: #fcd34d !important;
}
html[data-theme="dark"] .down-detail {
  border-color: #dc2626 !important;
}
html[data-theme="dark"] .ai-summary-card {
  background: linear-gradient(135deg, #0c4a6e 0%, #1e3a5f 100%) !important;
  border-color: #1d4ed8 !important;
}
html[data-theme="dark"] .ai-summary-head {
  color: #7dd3fc !important;
}
html[data-theme="dark"] .ai-summary-body {
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .ai-eval {
  border-color: #475569 !important;
}
html[data-theme="dark"] .rating-good {
  background-color: #064e3b !important;
  color: #6ee7b7 !important;
}
html[data-theme="dark"] .rating-mid {
  background-color: #451a03 !important;
  color: #fcd34d !important;
}
html[data-theme="dark"] .rating-bad {
  background-color: #7f1d1d !important;
  color: #fca5a5 !important;
}
html[data-theme="dark"] .ai-reason {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .ai-suggestion {
  background-color: #0c4a6e !important;
  border-left-color: #38bdf8 !important;
  color: #bae6fd !important;
}
html[data-theme="dark"] .reply-item {
  background-color: #1e293b !important;
}
html[data-theme="dark"] .reply-original,
html[data-theme="dark"] .reply-better {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .reply-original span,
html[data-theme="dark"] .reply-better span {
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .tag-up {
  background-color: #064e3b !important;
  color: #6ee7b7 !important;
}
html[data-theme="dark"] .tag-down {
  background-color: #7f1d1d !important;
  color: #fca5a5 !important;
}
html[data-theme="dark"] .rank-table th {
  background-color: #0f172a !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .rank-table td {
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .rank-toggle {
  background-color: #334155 !important;
}
html[data-theme="dark"] .rank-tab {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .rank-tab.active {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .bar-track {
  background-color: #334155 !important;
}
html[data-theme="dark"] .bar-fill {
  background: linear-gradient(90deg, #f87171, #ef4444) !important;
}
html[data-theme="dark"] .bar-label {
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .progress-bar {
  background-color: #334155 !important;
}
html[data-theme="dark"] .progress-fill {
  background: linear-gradient(90deg, #60a5fa, #93c5fd) !important;
}
html[data-theme="dark"] .progress-text {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .status-badge.status-running {
  background-color: #1e3a8a !important;
  color: #93c5fd !important;
}
html[data-theme="dark"] .status-badge.status-done {
  background-color: #064e3b !important;
  color: #6ee7b7 !important;
}
html[data-theme="dark"] .status-badge.status-stop {
  background-color: #7c2d12 !important;
  color: #fdba74 !important;
}
html[data-theme="dark"] .status-badge.status-fail {
  background-color: #7f1d1d !important;
  color: #fca5a5 !important;
}
html[data-theme="dark"] .meta-row {
  color: #94a3b8 !important;
}
html[data-theme="dark"] code {
  background-color: #334155 !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .empty {
  color: #64748b !important;
}
html[data-theme="dark"] .login-page {
  background-color: #0f172a !important;
}
html[data-theme="dark"] .login-box {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] .login-box h1 {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .login-error {
  background-color: #451a03 !important;
  color: #fca5a5 !important;
  border-color: #991b1b !important;
}
html[data-theme="dark"] .modal-box {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] .reason-config-row,
html[data-theme="dark"] .reason-config-header {
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .export-dropdown {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] .export-option {
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] .export-option:hover {
  background-color: #334155 !important;
}
html[data-theme="dark"] .model-chip {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] .model-chip:hover {
  background-color: #60a5fa !important;
  color: #0f172a !important;
}

/* ===== 终极暗色覆盖（解决白底残留） ===== */
html[data-theme="dark"] div,
html[data-theme="dark"] section,
html[data-theme="dark"] main,
html[data-theme="dark"] article {
  background-color: transparent !important;
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .mini-stat,
html[data-theme="dark"] .session-list,
html[data-theme="dark"] .bulk-bar,
html[data-theme="dark"] .chat-container,
html[data-theme="dark"] .ai-summary-card,
html[data-theme="dark"] .reply-item,
html[data-theme="dark"] .model-chip {
  background-color: #1e293b !important;
}
html[data-theme="dark"] .search-form button,
html[data-theme="dark"] .search-form input,
html[data-theme="dark"] .search-form select {
  background-color: #0f172a !important;
}
html[data-theme="dark"] .top-nav,
html[data-theme="dark"] .login-page {
  background-color: #1e293b !important;
}
html[data-theme="dark"] html,
html[data-theme="dark"] body {
  background-color: #0f172a !important;
}

/* AI 评估展示优化 */
.ai-eval { margin-top: 10px; padding-top: 8px; border-top: 1px dashed rgba(0,0,0,0.15); }
.ai-eval-inner { font-size: 12px; line-height: 1.6; }
.ai-eval-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.rating-tag {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.rating-good { background: #dcfce7; color: #166534; }
.rating-mid { background: #fef3c7; color: #92400e; }
.rating-bad { background: #fee2e2; color: #991b1b; }
.ai-reason { color: #475569; margin-top: 4px; line-height: 1.5; }
.ai-suggestion {
  color: #0369a1;
  margin-top: 6px;
  padding: 8px 10px;
  background: #f0f9ff;
  border-radius: 6px;
  border-left: 3px solid #38bdf8;
  line-height: 1.5;
}

[data-theme="dark"] .ai-eval { border-color: #475569; }
[data-theme="dark"] .rating-good { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .rating-mid { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .rating-bad { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .ai-reason { color: #94a3b8; }
[data-theme="dark"] .ai-suggestion {
  background: #0c4a6e;
  border-color: #38bdf8;
  color: #bae6fd;
}
