:root {
  /* Light SaaS palette */
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --violet: #7c3aed;
  --violet-50: #f5f3ff;
  --violet-100: #ede9fe;
  --cyan: #06b6d4;
  --cyan-50: #ecfeff;
  --cyan-100: #cffafe;
  --amber: #f59e0b;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --emerald: #10b981;
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --rose: #f43f5e;

  /* Neutrals */
  --bg: #f8fafc;
  --bg-gradient: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Typography */
  --font-display: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-body: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Layout */
  --header-height: 4rem;
  --radius: 1rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 4px 12px rgba(37, 99, 235, 0.08), 0 12px 32px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background: var(--bg-gradient);
  min-height: 100vh;
}

/* Top navigation */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  font-family: var(--font-display);
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-family: var(--font-display);
}

.brand-tagline {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a,
.nav-links button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}

.nav-links a:hover,
.nav-links button:hover {
  background: #f1f5f9;
  color: var(--text);
}

.nav-links a.active {
  background: var(--primary-50);
  color: var(--primary);
}

.nav-links a svg,
.nav-links button svg {
  width: 18px;
  height: 18px;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  font-size: 14px;
}

.logout-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Main layout */
.main-content {
  padding-top: var(--header-height);
  min-height: 100vh;
}

.page-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 32px;
}

/* Typography */
h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0 0 1rem;
  line-height: 1.25;
  color: var(--text);
  font-weight: 700;
}

h1 { font-size: 28px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

p {
  margin: 0 0 1rem;
  color: var(--text-secondary);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

/* Page header */
.page-header {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.page-header::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  width: 320px;
  height: 100%;
  background: radial-gradient(circle at 80% 50%, rgba(37, 99, 235, 0.08) 0%, transparent 60%);
  /* 这层只是装饰。不写这行，它会盖住标题栏右边的按钮，点击全被它吃掉。 */
  pointer-events: none;
}

.page-title h1 {
  font-size: 28px;
  margin: 0 0 6px;
}

.page-title p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
}

.page-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  transition: all 0.25s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--cyan) 100%);
}

/* Forms */
form { margin: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  align-items: end;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* 没写 type 的 input 默认就是 text，但**属性选择器不认默认值**——
   `input[type="text"]` 匹配不到 `<input name="username">`，那个框会掉回
   浏览器原生样式，和旁边的密码框长得完全不一样。
   真出过：管理员登录页的用户名框比密码框窄一圈、边框颜色也不同（2026-09-04）。
   仓库里当时有 11 个这样的框，分布在登录页、对话筛选页和模型配置页。
   所以这里把「没写 type」也一并算进来，以后再漏写也不会长歪。 */
input:not([type]),
input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input::placeholder { color: var(--muted); }

/* Buttons */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
  text-decoration: none;
}

button.secondary,
.btn.secondary {
  background: #fff;
  color: var(--text-secondary);
  border-color: var(--border);
}

button.secondary:hover,
.btn.secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: var(--shadow);
}

button.danger,
.btn.danger,
.btn-danger {
  background: #fff;
  color: var(--rose);
  border-color: #fecdd3;
}

button.danger:hover,
.btn.danger:hover,
.btn-danger:hover {
  background: #fff1f2;
  box-shadow: 0 6px 16px rgba(244, 63, 94, 0.18);
}

button.small,
.btn.small {
  padding: 6px 12px;
  font-size: 13px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.bulk-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.selection-cell {
  width: 44px;
  text-align: center;
}

.selection-cell input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--surface-hover); }

td a { font-weight: 500; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  /* 徽标内部不许断行。窄列里「1 条失败」曾被拆成三行，像出了故障。 */
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.ready,
.badge.completed,
.badge.knowledge {
  background: var(--emerald-50);
  color: #059669;
  border-color: #a7f3d0;
}

.badge.uploaded,
.badge.parsing,
.badge.indexing,
.badge.pending,
.badge.processing,
.badge.received {
  background: var(--amber-50);
  color: #d97706;
  border-color: #fde68a;
}

.badge.failed,
.badge.error,
.badge.general_fallback {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.badge.disabled {
  background: #f1f5f9;
  color: var(--muted);
  border-color: var(--border);
}

/* Status */
.status-ok {
  color: var(--emerald);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-ok::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
}

.status-error {
  color: var(--rose);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-error::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rose);
}

/* Alerts */
[role="alert"] {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  margin-bottom: 16px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.chat-paste-hint,
.chat-image-feedback,
.chat-image-name {
  color: var(--muted);
  font-size: 13px;
}

.chat-paste-hint {
  margin: 6px 0 0;
}

.chat-image-feedback {
  min-height: 20px;
  margin-top: 6px;
}

.chat-image-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 460px;
  margin: 8px 0 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
}

.chat-image-preview[hidden] {
  display: none;
}

.chat-image-preview img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface);
}

.chat-image-preview p {
  margin: 4px 0 8px;
}

.chat-stream-stage {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.chat-turn p {
  white-space: pre-wrap;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  transition: all 0.25s ease;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 22px;
}

.kpi-icon.blue { background: var(--primary-50); }
.kpi-icon.violet { background: var(--violet-50); }
.kpi-icon.cyan { background: var(--cyan-50); }
.kpi-icon.amber { background: var(--amber-50); }

.kpi-content { flex: 1; min-width: 0; }

.kpi-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-mono);
}

.kpi-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.kpi-change {
  font-size: 12px;
  color: var(--muted);
}

/* Highlight metrics */
.highlight-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.highlight-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.highlight-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.highlight-card.blue::before {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.highlight-card.violet::before {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.highlight-info h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 10px;
  font-weight: 500;
}

.highlight-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.highlight-value span {
  font-size: 18px;
  font-weight: 600;
}

.highlight-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.highlight-visual {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 36px;
  position: relative;
  z-index: 1;
}

.highlight-visual.blue {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.highlight-visual.violet {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
}

/* Chart */
.chart-wrapper {
  position: relative;
  height: 320px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-header h2 {
  font-size: 18px;
  margin: 0;
}

.chart-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Document cards */
.document-list { display: grid; gap: 12px; }

.document-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  transition: all 0.2s ease;
}

.document-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.document-card-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.document-icon {
  width: 44px;
  height: 44px;
  background: var(--primary-50);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.document-info { min-width: 0; }

.document-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-title a { color: inherit; }

.document-meta {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.document-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Version cards */
.version-list { display: grid; gap: 12px; }

.version-card {
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--border);
}

.version-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

/* Conversation detail */
.message-block {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

.message-block h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 16px;
}

.citation-grid { display: grid; gap: 12px; }

/* Job cards */
.job-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  border-left: 4px solid var(--rose);
}

.job-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.job-id {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

/* System status */
.status-list { display: grid; gap: 10px; }

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.status-item:hover {
  border-color: var(--border-strong);
  background: #fff;
}

.status-item dt {
  font-weight: 500;
  color: var(--text-secondary);
}

.status-item dd { margin: 0; }

/* Upload area */
.upload-area {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  background: var(--surface-hover);
  transition: all 0.2s ease;
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-50);
}

.upload-area input[type="file"] {
  display: block;
  margin: 0 auto 12px;
  max-width: 320px;
}

.upload-area p {
  color: var(--muted);
  margin: 0 0 16px;
}

/* Login page */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg-gradient);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow), 0 25px 50px -12px rgba(37, 99, 235, 0.15);
  padding: 40px;
}

.login-card .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-card .logo-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 100%);
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #fff;
  font-weight: 700;
}

.login-card .logo-text {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card h1 {
  text-align: center;
  font-size: 22px;
  margin-bottom: 6px;
}

.login-card .tagline {
  text-align: center;
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 14px;
}

/* 表单用 grid 排，字段之间的间距由 gap 统一给。
   靠 label 的 margin-bottom 撑的话，两个字段之间只有 6px，挤在一起。 */
.login-card form {
  display: grid;
  gap: 18px;
}

.login-card label {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0;
}

/* 输入框做大一点：这是要输密码的页面，框太小容易点不准。
   字号 16px 还有个作用——iOS 上小于 16px 的输入框在聚焦时会把整页放大。 */
.login-card input {
  margin-top: 7px;
  padding: 12px 14px;
  font-size: 16px;
}

.login-card button {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 15px;
}

/* Question list */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.question-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.question-item span {
  color: var(--text);
  font-weight: 500;
}

/* Layout variants */
.dashboard-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}

.dashboard-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  align-self: start;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  height: fit-content;
}

.filter-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--text);
}

.filter-title svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.filter-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.filter-actions button {
  width: 100%;
}

.field { margin-bottom: 16px; }

.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.mini-bar {
  width: 14px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--primary) 0%, var(--cyan) 100%);
  opacity: 0.8;
}

.header-illustration {
  width: 140px;
  height: 80px;
  position: relative;
  z-index: 1;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}

/* Responsive */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .highlight-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-sidebar { position: static; }
  .nav-links { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .header-illustration { display: none; }
  .page-container { padding: 20px 16px; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .top-nav { padding: 0 16px; }
}

/* ── 对话留档 ─────────────────────────────────────────────
   列表一行一段对话，详情一轮一轮铺开。为什么这么改见模板里的注释。 */

.filter-hint {
  margin: -8px 0 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.cell-time,
.cell-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-subject { min-width: 260px; }

/* 参与模式有高低顺序，颜色跟着往上走：灰 → 琥珀 → 青 → 蓝 → 紫。
   靠颜色深浅一眼看出这一段推到了哪儿，不用逐个读字母。 */
.badge.level-none { background: #f1f5f9; color: #64748b; }
.badge.level-P { background: var(--amber-100); color: #b45309; }
.badge.level-A { background: var(--cyan-100); color: #0e7490; }
.badge.level-C { background: var(--primary-100); color: var(--primary-600); }
.badge.level-I { background: var(--violet-100); color: #6d28d9; }

.record-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
}

.record-stats label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.record-stats p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.record-meta,
.record-anchor {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.7;
}

.turn-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.turn-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.turn-card-failed { border-color: var(--rose); }

.turn-card-head,
.turn-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 16px;
  background: var(--surface-hover);
}

.turn-card-head { border-bottom: 1px solid var(--border); }

.turn-card-foot {
  border-top: 1px solid var(--border);
  justify-content: flex-start;
  gap: 20px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.turn-card-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.turn-speaker {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.turn-speaker + .turn-speaker { border-top: 1px dashed var(--border); }

/* 裸模型那一份。底色压一点，是为了扫一眼就分得出哪份出自本系统、
   哪份是学生自己去问的——两份挨在一起，分不出来这页就没法当证据用。 */
.turn-speaker-direct { background: rgba(0, 0, 0, 0.02); }

.turn-speaker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.turn-bot { color: var(--primary); }

.turn-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-body);
  color: var(--text);
}

/* 判断依据和挑动作的理由。缩进 + 左边一条竖线，
   把「它自己的解释」和「它说给学生的话」分开，避免看串。 */
.turn-why {
  margin: 0;
  padding: 8px 12px;
  background: var(--surface-hover);
  border-left: 2px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.turn-why b { color: var(--text); }

.turn-empty {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.turn-details {
  padding: 0 16px 14px;
  border-top: 1px dashed var(--border);
}

/* 这里原来只是一行灰字，看不出能点。做成一个明确的控件。 */
.turn-details summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
}

.turn-details summary:hover {
  border-color: var(--primary);
  background: var(--primary-50);
}

.record-stats p small {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.turn-details h4 {
  margin: 12px 0 6px;
  font-size: 13px;
  color: var(--text);
}

.turn-citation {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}

/* 一格里放好几个徽标时，让它们横着排、放不下再换行，
   而不是各占一行把表格撑得老高。 */
.cell-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* 进详情的入口。原来只有问题文字是个链接，看不出能点，
   结果有人以为详情页根本没做出来。 */
.row-open {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.row-open:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  text-decoration: none;
}

/* 表格里的徽标去掉圆点、收紧内边距，让一格里的几个能排成一行，
   而不是各占一行把行高撑到三倍。 */
.cell-badges .badge {
  padding: 3px 8px;
  gap: 0;
}

.cell-badges .badge::before { display: none; }

/* ---------------------------------------------------------------------------
   教师试用页的后台流水栏
   左边是对话，右边是「它是怎么走的」。只有 /admin/chat 有这一栏，学生页面没有：
   流水里带着参考解，那就是这道题的答案。
   --------------------------------------------------------------------------- */

.chat-workbench {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* 窄屏上并排会把两边都挤到没法读，改成上下堆叠。 */
@media (max-width: 1100px) {
  .chat-workbench {
    grid-template-columns: 1fr;
  }

  /* 上下堆叠时不钉住：钉住的那一栏会盖在对话上面。 */
  .trace-panel {
    position: static;
  }
}

.trace-panel {
  padding: 0;
  overflow: hidden;
  /* **钉在屏幕上**：对话往下长、页面往下滚时，这一栏跟着留在眼前。
     2026-09-13 之前它只在页面顶上占一屏高，对话一长，往下看对话时它就滚出去了，
     想看「这句对应的系统动作」得滚回顶上再在里面拖。
     流水本身比一屏长得多，自己在里面滚。 */
  position: sticky;
  top: calc(var(--header-height) + 16px);
  max-height: calc(100vh - var(--header-height) - 32px);
  display: flex;
  flex-direction: column;
}

.side-tabs {
  display: flex;
  gap: 4px;
}

.side-tab {
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.side-tab.is-active {
  background: var(--primary-50);
  border-color: var(--primary-100);
  color: var(--primary-600);
}

/* 对话里每一轮学生那句话旁边的「第 N 轮 · 看它怎么走的」。 */
.turn-jump {
  margin-left: 8px;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary-600);
  font-size: 11px;
  cursor: pointer;
}

.turn-jump:hover {
  border-color: var(--primary);
}

/* 全局按钮悬停会上浮、加蓝色阴影。这几个是小标签和文字链接，浮起来很怪。 */
.turn-jump:hover,
.side-tab:hover,
.trace-round-locate:hover {
  transform: none;
  box-shadow: none;
}

/* 跳过去之后闪一下，一眼看出落在哪。 */
.is-flash {
  animation: trace-flash 1.6s ease-out;
}

@keyframes trace-flash {
  0% { box-shadow: 0 0 0 3px var(--amber-100); background-color: var(--amber-50); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.trace-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}

.trace-header h2 {
  margin: 0;
  font-size: 16px;
  font-family: var(--font-display);
}

.trace-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.trace-body {
  padding: 14px 18px 20px;
  overflow-y: auto;
  flex: 1;
  /* 点「第 N 轮」时按这一轮的 offsetTop 滚动，offsetTop 要相对这一栏算。 */
  position: relative;
}

/* 每一轮是一个能折起来的块。新的一轮来了，旧的自动折起来。 */
.trace-round {
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
}

.trace-round-title {
  cursor: pointer;
  list-style: none;
  margin: 0 0 8px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-round-title::-webkit-details-marker {
  display: none;
}

.trace-round-title::before {
  content: "▸ ";
  color: var(--muted);
}

.trace-round[open] > .trace-round-title::before {
  content: "▾ ";
}

.trace-round-locate {
  margin: 0 0 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--primary-600);
  font-size: 12px;
  cursor: pointer;
}

/* ---- 解题进度 ---- */

.progress-directions {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 12px;
}

.progress-steps {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.progress-step {
  position: relative;
  padding: 8px 10px 8px 30px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.progress-mark {
  position: absolute;
  left: 10px;
  top: 8px;
  color: var(--muted);
}

.progress-step.is-done {
  background: var(--emerald-50);
  border-color: var(--emerald-100);
}

.progress-step.is-done .progress-mark {
  color: var(--emerald);
}

.progress-step.is-current {
  background: var(--primary-50);
  border-color: var(--primary-100);
}

.progress-step.is-current .progress-mark {
  color: var(--primary-600);
}

.progress-step.is-todo .progress-title {
  color: var(--text-secondary);
  font-weight: 500;
}

.progress-evidence,
.progress-hint {
  margin: 4px 0 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.progress-evidence {
  color: var(--text);
}

.progress-note {
  font-size: 13px;
  color: var(--emerald);
  font-weight: 600;
}

.progress-heading {
  font-size: 14px;
  margin: 8px 0 8px;
}

.progress-knowledge {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.progress-knowledge > summary {
  cursor: pointer;
  font-weight: 600;
}

.trace-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface);
}

.trace-step summary {
  cursor: pointer;
  padding: 9px 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  list-style: none;
}

.trace-step summary::-webkit-details-marker {
  display: none;
}

.trace-step summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 10px;
}

.trace-step[open] > summary::before {
  content: "▾";
}

.trace-step-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* 折起来的时候，一行字要能说明这一步干了什么——展开才看得懂就失去意义了。 */
.trace-step-gist {
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-step-body {
  padding: 2px 12px 12px 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.trace-field {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

.trace-field:last-child {
  border-bottom: none;
}

.trace-field dt {
  color: var(--muted);
}

.trace-field dd {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 引号里的是学生原话或模型原话，和我们自己算出来的数字要看得出区别。 */
.trace-quote {
  font-style: normal;
  color: var(--text);
  background: var(--amber-50);
  border-radius: 4px;
  padding: 1px 4px;
}

.trace-step-failed {
  border-color: var(--rose);
}

.trace-step-failed .trace-step-name {
  color: var(--rose);
}

.trace-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--primary-50);
  color: var(--primary-600);
  margin-right: 4px;
}

.trace-chip-muted {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------------------
   每一轮下面那块「这一轮本该怎么答」
   教师看着右边的流水，发现哪一步不对，当场写下来。写过的一直显示着——
   看不见的话，同一个毛病会被写第二遍第三遍，复盘时分不出是三次观察
   还是一件事写了三回。
   --------------------------------------------------------------------------- */

.turn-notes {
  margin: 2px 0 16px 0;
  padding-left: 10px;
  border-left: 2px solid var(--amber-100);
}

.turn-note {
  margin: 0 0 5px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.turn-note-step {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--amber-50);
  color: var(--amber);
  font-size: 11px;
  font-weight: 600;
}

/* 收起来的时候只是一行小字，不跟对话抢地方；要写的时候点开才展开。 */
.turn-note-form > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  list-style: none;
  padding: 2px 0;
}

.turn-note-form > summary::-webkit-details-marker {
  display: none;
}

.turn-note-form > summary::before {
  content: "✎ ";
}

.turn-note-form[open] > summary {
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.turn-note-form form {
  display: grid;
  gap: 6px;
  max-width: 34rem;
}

.turn-note-form label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.turn-note-form select,
.turn-note-form textarea {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.turn-note-form button {
  justify-self: start;
}

/* 「问模型」那一格里的原文：提示词、模型原始回复。再折一层，点开才看。
   原文要原样显示（换行、缩进都保留），而且不许把整栏撑宽。 */
.trace-fold > summary {
  cursor: pointer;
  color: var(--primary-600);
  font-size: 12px;
}

.trace-raw {
  margin: 6px 0 0;
  padding: 8px 10px;
  max-height: 22rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
