/* ============================================
   文档理解与多源数据融合系统 - Design System
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap');

/* ============ CSS Variables ============ */
:root {
  /* Primary Palette */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  /* Accent */
  --accent-400: #a78bfa;
  --accent-500: #8b5cf6;
  --accent-600: #7c3aed;

  /* Success */
  --success-400: #4ade80;
  --success-500: #22c55e;
  --success-600: #16a34a;

  /* Warning */
  --warning-400: #fbbf24;
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  /* Error */
  --error-400: #f87171;
  --error-500: #ef4444;
  --error-600: #dc2626;

  /* Neutral */
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;
  --neutral-950: #020617;

  /* Surface */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-inverse: #0f172a;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.15);
  --border-accent: rgba(59, 130, 246, 0.3);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(59, 130, 246, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 20%, rgba(139, 92, 246, 0.06), transparent),
    radial-gradient(ellipse 50% 50% at 50% 80%, rgba(34, 197, 94, 0.04), transparent);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--primary-400);
  text-decoration: none;
}

a:hover {
  color: var(--primary-300);
}

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

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

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

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============ Layout ============ */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ============ Sidebar ============ */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--border-subtle);
  transition: width var(--transition-base);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

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

.nav-section {
  margin-bottom: 24px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary-500);
  border-radius: 0 3px 3px 0;
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.nav-item-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary-400);
  font-size: 11px;
  font-weight: 600;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success-500);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}

.status-dot.offline {
  background: var(--error-500);
  animation: none;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

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

/* Header */
.main-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  min-width: 0;
}

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

.breadcrumb .separator {
  opacity: 0.4;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-btn.header-menu-btn {
  display: none;
}

.header-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.header-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

/* Content Area */
.content-area {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
  min-width: 0;
}

/* ============ Page / Section ============ */
.page {
  display: none;
  min-width: 0;
}

.page.active {
  display: block;
  animation: fadeInPage 0.3s ease;
}

@keyframes fadeInPage {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ============ Cards ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-lg);
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 22px;
}

.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
}

/* ============ Stat Cards (Dashboard) ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--stat-color, var(--primary-500)), transparent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

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

.stat-card:hover::after {
  opacity: 1;
}

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

.stat-icon.blue {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
}

.stat-icon.green {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success-400);
}

.stat-icon.purple {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-400);
}

.stat-icon.amber {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning-400);
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-change {
  font-size: 11px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.positive {
  color: var(--success-400);
}

.stat-change.negative {
  color: var(--error-400);
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: white;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error-400);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-success {
  background: linear-gradient(135deg, var(--success-600), var(--success-500));
  color: white;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.btn-icon:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 14px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============ Upload Zone ============ */
.upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary-400);
  background: rgba(59, 130, 246, 0.04);
}

.upload-zone.drag-over {
  border-style: solid;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.upload-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.upload-desc {
  font-size: 13px;
  color: var(--text-tertiary);
}

.upload-desc strong {
  color: var(--primary-400);
}

.upload-formats {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.format-badge {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

/* ============ File List ============ */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  min-width: 0;
}

.file-item:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-default);
}

.file-type-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.file-type-icon.docx {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
}

.file-type-icon.xlsx {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success-400);
}

.file-type-icon.md {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-400);
}

.file-type-icon.txt {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning-400);
}

.file-type-icon.pdf {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error-400);
}

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

.file-name {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.file-item:hover .file-actions {
  opacity: 1;
}

/* ============ Status Badge ============ */
.status-badge {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning-400);
}

.status-badge.processing {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
}

.status-badge.completed {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success-400);
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error-400);
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Processing animation */
.status-badge.processing::before {
  animation: pulse-dot 1s infinite;
}

/* ============ Table ============ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.data-table tr:hover td {
  background: var(--bg-glass);
}

/* ============ Forms ============ */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-textarea-multiline-hint {
  min-height: 132px;
  line-height: 1.5;
}

.form-textarea-multiline-hint::placeholder {
  line-height: 1.5;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ============ Grid Layouts ============ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.grid-2>*,
.grid-3>* {
  min-width: 0;
}

/* ============ Chat / AI Assistant ============ */
.assistant-chat-card {
  display: flex;
  flex-direction: column;
  min-height: 640px;
  overflow: hidden;
}

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--header-height) - 150px);
  max-height: 700px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  display: flex;
  gap: 12px;
  max-width: 80%;
  animation: msgIn 0.3s ease;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

.chat-msg.assistant .chat-avatar {
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
}

.chat-msg.user .chat-avatar {
  background: rgba(255, 255, 255, 0.1);
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  line-height: 1.6;
}

.chat-msg.assistant .chat-bubble {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
}

.chat-msg.user .chat-bubble {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.chat-input-area {
  padding: 16px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: 13.5px;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
}

.chat-input:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.chat-send-btn.stop-mode {
  background: linear-gradient(135deg, var(--error-500), var(--error-600));
  font-size: 14px;
}

.chat-send-btn.stop-mode:hover {
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

/* ============ Extracted Data View ============ */
.extracted-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.extracted-item {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
}

.extracted-field {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.extracted-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

.extracted-confidence {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.confidence-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border-subtle);
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--success-500);
  transition: width var(--transition-slow);
}

/* ============ Modal ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

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

.modal {
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(7, 11, 18, 0.68);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.busy-overlay.active {
  opacity: 1;
  visibility: visible;
}

.busy-dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 28px 24px;
  border-radius: var(--radius-xl);
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.busy-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.busy-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

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

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  animation: toastIn 0.3s ease;
  font-size: 13px;
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

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

.toast.success .toast-icon {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success-400);
}

.toast.error .toast-icon {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error-400);
}

.toast.info .toast-icon {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
}

.toast.warning .toast-icon {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning-400);
}

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 320px;
  margin: 0 auto 20px;
}

/* ============ Loading ============ */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-default);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-glass) 25%, var(--bg-glass-hover) 50%, var(--bg-glass) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

/* ============ Progress Bar ============ */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-subtle);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary-500), var(--accent-500));
  transition: width var(--transition-slow);
}

/* ============ Template Workflow ============ */
.workflow-steps {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  padding: 10px 14px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.18);
  overflow-x: auto;
}

.workflow-step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 160px;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border-default);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  transition: all var(--transition-base);
}

.workflow-step.active {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
  color: #ffffff;
  border-color: rgba(37, 99, 235, 0.3);
}

.workflow-step.done {
  background: linear-gradient(135deg, var(--success-600), var(--success-500));
  color: #ffffff;
  border-color: rgba(22, 163, 74, 0.3);
}

.workflow-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.workflow-step-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-step.active .workflow-step-num {
  background: rgba(255, 255, 255, 0.96);
  color: var(--primary-700);
  border-color: rgba(255, 255, 255, 0.4);
}

.workflow-step.done .workflow-step-num {
  background: rgba(255, 255, 255, 0.96);
  color: var(--success-600);
  border-color: rgba(255, 255, 255, 0.4);
}

.workflow-connector {
  flex: 1;
  height: 4px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.7), rgba(148, 163, 184, 0.22));
  min-width: 44px;
  border-radius: var(--radius-full);
}

.workflow-connector.done {
  background: linear-gradient(90deg, var(--success-600), var(--success-400));
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .main-header {
    padding: 0 20px;
  }

  .content-area {
    padding: 22px 20px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .section-header {
    align-items: flex-start;
  }

  .card-header {
    align-items: flex-start;
  }

  .file-actions {
    opacity: 1;
  }

  .detail-panel {
    width: min(100vw, 480px);
  }
}

@media (max-width: 920px) {
  .format-chart-body {
    grid-template-columns: 1fr;
  }

  .format-chart-hero {
    align-items: stretch;
  }

  .format-chart-spotlight {
    max-width: none;
  }

  .format-chart-legend-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .format-chart-legend-main,
  .format-chart-legend-metrics {
    width: 100%;
  }

  .format-chart-legend-metrics {
    justify-content: space-between;
  }

  .format-chart-legend-value {
    font-size: 18px;
  }
}

@media (max-width: 720px), (pointer: coarse) and (max-width: 900px) {
  :root {
    --header-height: 60px;
  }

  body.sidebar-open,
  body.detail-panel-open,
  body.modal-open {
    overflow: hidden;
  }

  .format-chart-panel {
    padding: 16px;
  }

  .format-donut-aura {
    width: 164px;
    height: 164px;
  }

  .format-donut-chart {
    width: 138px;
    height: 138px;
  }

  .format-donut-hole {
    width: 78px;
    height: 78px;
  }

  .format-donut-total {
    font-size: 24px;
  }

  .workflow-steps {
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    border: none;
    background: transparent;
  }

  .workflow-step {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  .workflow-step:last-child {
    flex-basis: 100%;
  }

  .workflow-step-label {
    white-space: normal;
  }

  .workflow-connector {
    display: none;
  }

  .sidebar {
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    padding: 0 16px;
  }

  .sidebar-nav {
    padding: 12px 10px 18px;
  }

  .nav-section {
    margin-bottom: 18px;
  }

  .sidebar-footer {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .main-content {
    margin-left: 0;
  }

  .main-header {
    padding: 0 16px;
    gap: 12px;
  }

  .header-btn.header-menu-btn {
    display: inline-flex;
  }

  .header-btn {
    width: 36px;
    height: 36px;
  }

  .page-title {
    font-size: 16px;
    line-height: 1.25;
  }

  .content-area {
    padding: 16px 14px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }

  .stat-card {
    padding: 16px;
    gap: 12px;
  }

  .stat-value {
    font-size: 24px;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 18px;
  }

  .section-title {
    font-size: 18px;
  }

  .section-desc {
    font-size: 12px;
  }

  .btn-group,
  .section-header .btn-group {
    width: 100%;
  }

  .card {
    border-radius: 16px;
  }

  .card-header {
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .card-body {
    padding: 16px;
  }

  .card-footer {
    padding: 14px 16px;
  }

  .upload-zone {
    padding: 28px 16px;
  }

  .upload-icon {
    font-size: 40px;
    margin-bottom: 12px;
  }

  .upload-title {
    font-size: 15px;
  }

  .upload-desc {
    font-size: 12px;
  }

  .file-item {
    align-items: flex-start;
    padding: 14px;
    gap: 12px;
  }

  .file-type-icon {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  .file-name {
    white-space: normal;
    word-break: break-word;
  }

  .file-meta,
  .task-detail-row {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .file-actions {
    opacity: 1;
    align-self: stretch;
    justify-content: flex-end;
  }

  .checkbox-item {
    align-items: flex-start;
    padding: 12px;
  }

  .form-label {
    line-height: 1.45;
  }

  .form-label .btn {
    margin-top: 8px;
    margin-left: 0 !important;
  }

  .form-input,
  .form-select,
  .form-textarea,
  .chat-input {
    font-size: 16px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 0;
    border: none;
    background: transparent;
  }

  .tab {
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    text-align: center;
  }

  .guide-step {
    align-items: flex-start;
    padding: 12px 14px;
  }

  .guide-step:hover {
    transform: none;
  }

  .format-chart-topline,
  .format-chart-legend-head {
    align-items: flex-start;
  }

  .format-chart-legend-metrics {
    width: 100%;
    justify-content: space-between;
  }

  .format-chart-legend-meta {
    white-space: normal;
  }

  .assistant-chat-card {
    min-height: auto;
  }

  .chat-container {
    height: auto;
    max-height: none;
    min-height: 460px;
  }

  .chat-messages {
    padding: 16px;
    max-height: none;
    gap: 12px;
  }

  .chat-msg {
    max-width: 100%;
  }

  .chat-avatar {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .chat-bubble {
    padding: 12px 14px;
    font-size: 13px;
  }

  .chat-input-area {
    padding: 12px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .knowledge-search-input {
    max-width: none;
    width: 100%;
  }

  .empty-state {
    padding: 40px 16px;
  }

  .empty-state-icon {
    font-size: 44px;
  }

  .empty-state-title {
    font-size: 15px;
  }

  .empty-state-desc {
    margin-bottom: 16px;
  }

  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .modal {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border-radius: 18px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .modal-header {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .modal-body {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .modal-footer {
    padding-top: 14px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

/* ============ Document Detail Panel ============ */
.detail-panel {
  position: fixed;
  top: 0;
  right: -500px;
  width: 480px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: right var(--transition-base);
  box-shadow: var(--shadow-xl);
}

.detail-panel.open {
  right: 0;
}

.detail-panel-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

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

/* ============ Tag / Chip ============ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* ============ Checkbox / Select Items ============ */
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.checkbox-item:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-default);
}

.checkbox-item.selected {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
}

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

/* ============ Tabs ============ */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.tab {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
  font-weight: 600;
}

/* ============ Guide Steps ============ */
.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.guide-step:hover {
  background: rgba(59, 130, 246, 0.06);
  border-color: rgba(59, 130, 246, 0.2);
  transform: translateX(4px);
}

.guide-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-600), var(--accent-500));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.guide-step-content {
  flex: 1;
}

.guide-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.guide-step-desc {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ============ Tip Banner ============ */
.tip-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  font-size: 13px;
  color: var(--primary-300);
  animation: fadeInPage 0.3s ease;
}

.tip-icon {
  font-size: 18px;
  flex-shrink: 0;
}

/* ============ Format Statistics ============ */
.format-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.format-stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.format-stat-item:hover {
  border-color: var(--border-default);
  background: var(--bg-glass-hover);
}

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

.format-stat-icon.docx {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-400);
}

.format-stat-icon.xlsx {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success-400);
}

.format-stat-icon.md {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-400);
}

.format-stat-icon.txt {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning-400);
}

.format-stat-info {
  flex: 1;
}

.format-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.format-stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.format-chart-panel {
  padding: 18px;
}

.format-chart-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
}

.format-chart-topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.format-chart-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.format-chart-summary {
  font-size: 12px;
  color: var(--text-tertiary);
}

.format-chart-body {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(0, 1.1fr);
  gap: 20px;
  align-items: center;
  flex: 1;
}

.format-chart-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.format-donut-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.format-donut-aura {
  position: absolute;
  inset: 50%;
  width: 188px;
  height: 188px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(96, 165, 250, 0.18), rgba(96, 165, 250, 0.02) 60%, transparent 72%);
  filter: blur(4px);
  opacity: 0.92;
  animation: formatAuraPulse 2.8s linear infinite;
}

.format-donut-chart {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 18px 30px rgba(15, 23, 42, 0.16),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  animation: formatDonutEnter 720ms linear both;
}

.format-donut-hole {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.14);
  text-align: center;
}

.format-donut-total {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.format-donut-label {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.format-chart-spotlight {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 240px;
  padding: 10px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  animation: formatSpotlightIn 520ms linear both;
}

.format-chart-spotlight-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06);
}

.format-chart-spotlight-text {
  text-wrap: pretty;
}

.format-chart-legend {
  display: grid;
  gap: 12px;
}

.format-chart-legend-item {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  animation: formatLegendItemIn 520ms linear both;
  animation-delay: var(--legend-delay, 0ms);
}

.format-chart-legend-item.is-empty {
  opacity: 0.64;
}

.format-chart-legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.format-chart-legend-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.format-chart-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
}

.format-chart-legend-copy {
  min-width: 0;
  flex: 1;
}

.format-chart-legend-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.format-chart-legend-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.format-chart-legend-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  flex-shrink: 0;
}

.format-chart-legend-metrics {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.format-chart-legend-bar {
  height: 8px;
  border-radius: var(--radius-full);
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
}

.format-chart-legend-fill {
  height: 100%;
  border-radius: inherit;
  min-width: 0;
  transform-origin: left center;
  transform: scaleX(0);
  animation: formatLegendBarGrow 760ms linear forwards;
  animation-delay: var(--legend-delay, 0ms);
}

.format-chart-legend-percent {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.format-chart-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}

.format-chart-empty-icon {
  font-size: 28px;
}

.format-chart-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.format-chart-empty-desc {
  max-width: 220px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-tertiary);
}

@keyframes formatDonutEnter {
  0% {
    opacity: 0;
    transform: rotate(-72deg) scale(0.92);
  }

  100% {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

@keyframes formatLegendItemIn {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes formatLegendBarGrow {
  0% {
    transform: scaleX(0);
  }

  100% {
    transform: scaleX(1);
  }
}

@keyframes formatSpotlightIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes formatAuraPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.96);
    opacity: 0.76;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.02);
    opacity: 0.98;
  }
}



/* ============ Error / Delete Button ============ */
.btn-error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error-400);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-error:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
}

/* ============ Task Detail Row ============ */
.task-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.task-metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.task-metric.accuracy {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success-400);
}

.task-metric.time {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-400);
}

.task-metric.risk-high {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error-400);
}

.task-metric.risk-medium {
  background: rgba(245, 158, 11, 0.14);
  color: var(--warning-400);
}

.task-metric.risk-low {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success-400);
}

.task-metric.repair {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
}

/* ============ Knowledge Base ============ */
.knowledge-search-input {
  max-width: 260px;
}

.knowledge-entity-item {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.knowledge-entity-item.active {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.12);
}

.knowledge-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.knowledge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-400);
  font-size: 11px;
  font-weight: 600;
}

.knowledge-summary {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(14, 165, 233, 0.05));
  border: 1px solid rgba(59, 130, 246, 0.14);
}

.knowledge-scroll-region {
  max-height: min(58vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
}

.knowledge-detail-scroll {
  display: flex;
  flex-direction: column;
}

.knowledge-scroll-region::-webkit-scrollbar {
  width: 8px;
}

.knowledge-scroll-region::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 999px;
}

.knowledge-scroll-region::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

.knowledge-answer-box {
  min-height: 140px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border-default);
}

.knowledge-recommendation-card {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border-default);
  margin-bottom: 12px;
}

.knowledge-recommendation-card:last-child {
  margin-bottom: 0;
}

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

  .guide-steps {
    gap: 8px;
  }

  .knowledge-search-input {
    max-width: none;
  }

  .knowledge-scroll-region {
    max-height: 420px;
  }
}

@media (max-width: 720px), (pointer: coarse) and (max-width: 900px) {
  .knowledge-scroll-region {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .detail-panel {
    width: 100vw;
    right: -100vw;
  }

  .detail-panel-header {
    padding: 0 16px;
  }

  .detail-panel-body {
    padding: 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 540px) {
  .header-right {
    gap: 8px;
  }

  .page-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .btn,
  .btn-sm,
  .btn-lg {
    width: 100%;
  }

  .section-header .btn,
  .card-header .btn,
  .file-actions .btn,
  .tabs .tab,
  .header-btn,
  .chat-send-btn {
    width: auto;
  }

  .file-item {
    flex-wrap: wrap;
  }

  .file-actions {
    width: 100%;
  }

  .chat-input-area {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-send-btn {
    width: 100%;
    height: 44px;
  }

  .knowledge-answer-box {
    min-height: 120px;
  }
}

/* ============ Utils ============ */
.text-muted {
  color: var(--text-tertiary);
}

.text-sm {
  font-size: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-6 {
  margin-top: 24px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-6 {
  margin-bottom: 24px;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.justify-between {
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}

.hidden {
  display: none !important;
}
