/* ============================================================
   APP PREPROCESS — DESIGN SYSTEM
   Dark Mode Premium · Glassmorphism · Micro-animations
   ============================================================ */

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

/* ---------- CSS Variables ---------- */
:root {
  /* Background */
  --bg-primary:     #0a0a0f;
  --bg-secondary:   #111118;
  --bg-tertiary:    #1a1a2e;
  --bg-elevated:    #1e1e30;
  --surface:        #111118;

  /* Glass */
  --glass-bg:       rgba(255, 255, 255, 0.03);
  --glass-border:   rgba(255, 255, 255, 0.06);
  --glass-hover:    rgba(255, 255, 255, 0.08);

  /* Text */
  --text-primary:   #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted:     #555568;
  --text-inverse:   #0a0a0f;

  /* Accent */
  --accent:         #6c5ce7;
  --accent-light:   #a29bfe;
  --accent-dark:    #5a4bd1;
  --accent-glow:    rgba(108, 92, 231, 0.25);
  --accent-gradient: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);

  /* Status */
  --success:        #00d68f;
  --success-bg:     rgba(0, 214, 143, 0.1);
  --warning:        #ffc107;
  --warning-bg:     rgba(255, 193, 7, 0.1);
  --danger:         #ff6b6b;
  --danger-bg:      rgba(255, 107, 107, 0.1);
  --info:           #54a0ff;
  --info-bg:        rgba(84, 160, 255, 0.1);

  /* Method colors */
  --method-auto:     #00d2d3;
  --method-claude:   #d4a0ff;
  --method-mathpix:  #54a0ff;
  --method-datalab:  #00d68f;
  --method-fitz:     #ffc107;
  --method-mistral:  #ff9f43;

  /* Borders & Shadows */
  --border:         rgba(255, 255, 255, 0.06);
  --border-hover:   rgba(255, 255, 255, 0.12);
  --shadow-sm:      0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md:      0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg:      0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow:    0 0 30px var(--accent-glow);

  /* Radius */
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      20px;
  --radius-full:    9999px;

  /* Spacing */
  --space-xs:       4px;
  --space-sm:       8px;
  --space-md:       16px;
  --space-lg:       24px;
  --space-xl:       32px;
  --space-2xl:      48px;
  --space-3xl:      64px;

  /* Layout */
  --sidebar-width:  260px;
  --header-height:  64px;

  /* Transitions */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Accent Color Variants (dark base) ---------- */
[data-accent="rose"] {
  --accent:          #e879a0;
  --accent-light:    #f4a7c3;
  --accent-dark:     #c4547a;
  --accent-glow:     rgba(232, 121, 160, 0.25);
  --accent-gradient: linear-gradient(135deg, #e879a0 0%, #f4a7c3 100%);
  --shadow-glow:     0 0 30px rgba(232, 121, 160, 0.2);
}
[data-accent="blue"] {
  --accent:          #4a9eff;
  --accent-light:    #81c5ff;
  --accent-dark:     #2f7de1;
  --accent-glow:     rgba(74, 158, 255, 0.25);
  --accent-gradient: linear-gradient(135deg, #4a9eff 0%, #81c5ff 100%);
  --shadow-glow:     0 0 30px rgba(74, 158, 255, 0.2);
}
[data-accent="green"] {
  --accent:          #1dd1a1;
  --accent-light:    #55efc4;
  --accent-dark:     #00a67c;
  --accent-glow:     rgba(29, 209, 161, 0.25);
  --accent-gradient: linear-gradient(135deg, #1dd1a1 0%, #55efc4 100%);
  --shadow-glow:     0 0 30px rgba(29, 209, 161, 0.2);
}
[data-accent="peach"] {
  --accent:          #ff9f7f;
  --accent-light:    #ffbead;
  --accent-dark:     #e07455;
  --accent-glow:     rgba(255, 159, 127, 0.25);
  --accent-gradient: linear-gradient(135deg, #ff9f7f 0%, #ffbead 100%);
  --shadow-glow:     0 0 30px rgba(255, 159, 127, 0.2);
}

/* Light mode overrides for each accent */
[data-theme="light"][data-accent="rose"] {
  --accent:          #db2777;
  --accent-light:    #be185d;
  --accent-dark:     #9d174d;
  --accent-glow:     rgba(219, 39, 119, 0.12);
  --accent-gradient: linear-gradient(135deg, #db2777 0%, #f472b6 100%);
  --shadow-glow:     0 0 20px rgba(219, 39, 119, 0.2);
}
[data-theme="light"][data-accent="blue"] {
  --accent:          #3b82f6;
  --accent-light:    #1d4ed8;
  --accent-dark:     #1e40af;
  --accent-glow:     rgba(59, 130, 246, 0.12);
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
  --shadow-glow:     0 0 20px rgba(59, 130, 246, 0.2);
}
[data-theme="light"][data-accent="green"] {
  --accent:          #10b981;
  --accent-light:    #059669;
  --accent-dark:     #047857;
  --accent-glow:     rgba(16, 185, 129, 0.12);
  --accent-gradient: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  --shadow-glow:     0 0 20px rgba(16, 185, 129, 0.2);
}
[data-theme="light"][data-accent="peach"] {
  --accent:          #f97316;
  --accent-light:    #ea580c;
  --accent-dark:     #c2410c;
  --accent-glow:     rgba(249, 115, 22, 0.12);
  --accent-gradient: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
  --shadow-glow:     0 0 20px rgba(249, 115, 22, 0.2);
}

/* Color picker swatches */
.accent-swatches {
  display: flex;
  align-items: center;
  gap: 5px;
}
.accent-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 120ms ease, border-color 120ms ease;
  flex-shrink: 0;
}
.accent-swatch:hover { transform: scale(1.25); }
.accent-swatch.active {
  border-color: var(--text-primary);
  transform: scale(1.15);
}

/* ---------- Light Theme Overrides ---------- */
[data-theme="light"] {
  --bg-primary:     #f8fafc;
  --bg-secondary:   #ffffff;
  --bg-tertiary:    #f1f5f9;
  --bg-elevated:    #ffffff;
  --surface:        #ffffff;

  --glass-bg:       rgba(0, 0, 0, 0.02);
  --glass-border:   rgba(0, 0, 0, 0.08);
  --glass-hover:    rgba(0, 0, 0, 0.04);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  --accent:         #6366f1;
  --accent-light:   #4f46e5;
  --accent-dark:    #4338ca;
  --accent-glow:    rgba(99, 102, 241, 0.12);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);

  --border:         rgba(0, 0, 0, 0.08);
  --border-hover:   rgba(0, 0, 0, 0.16);
  --shadow-sm:      0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md:      0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg:      0 8px 40px rgba(0, 0, 0, 0.12);
  --shadow-glow:    0 0 20px rgba(99, 102, 241, 0.2);
}

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

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

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

/* Subtle grid pattern on body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.015) 1px, transparent 0);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Ambient glow */
body::after {
  content: '';
  position: fixed;
  top: -30%;
  left: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--text-primary);
}

/* ---------- Layout: Sidebar + Content ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-smooth);
}

.sidebar-logo {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  box-shadow: var(--shadow-glow);
}

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-logo .logo-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--accent-glow);
  color: var(--accent-light);
  border-radius: var(--radius-full);
  font-weight: 600;
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: var(--space-md) var(--space-md) var(--space-sm);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
  text-decoration: none;
}

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

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent-light);
}

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

.nav-link .nav-icon {
  font-size: 18px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-link .nav-icon svg {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-fast);
}

.nav-link:hover .nav-icon svg {
  transform: scale(1.15);
}

.nav-link.active .nav-icon svg {
  stroke: var(--accent-light);
}

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Logout Button --- */
.logout-btn {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.logout-btn:active {
  transform: translateY(0) scale(0.96);
}

.logout-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}


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

/* --- Page Header --- */
.page-header {
  padding: var(--space-xl) var(--space-2xl);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* --- Page Body --- */
.page-body {
  flex: 1;
  padding: var(--space-2xl);
}

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

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  white-space: nowrap;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::after {
  opacity: 0.05;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
  transform: translateY(-1px);
}

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

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

.btn-success {
  background: linear-gradient(135deg, #00d68f 0%, #00b894 100%);
  color: white;
  box-shadow: 0 2px 12px rgba(0, 214, 143, 0.25);
}

.btn-danger {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  color: white;
  box-shadow: 0 2px 12px rgba(255, 107, 107, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--glass-hover);
}

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

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ---------- Inputs ---------- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.input-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--transition-fast);
  outline: none;
  width: 100%;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-auto     { background: rgba(0,210,211,0.15);   color: var(--method-auto); }
.badge-claude   { background: rgba(212,160,255,0.15); color: var(--method-claude); }
.badge-mathpix  { background: rgba(84,160,255,0.15);  color: var(--method-mathpix); }
.badge-datalab  { background: rgba(0,214,143,0.15);   color: var(--method-datalab); }
.badge-fitz     { background: rgba(255,193,7,0.15);   color: var(--method-fitz); }
.badge-mistral  { background: rgba(255,159,67,0.15);  color: var(--method-mistral); }
.badge-pdf      { background: rgba(255,107,107,0.15); color: var(--danger); }
.badge-xlsx     { background: rgba(0,214,143,0.15);   color: var(--success); }

/* ---------- Drag & Drop Zone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-3xl) var(--space-2xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  background: var(--glass-bg);
}

.dropzone::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-xl);
  padding: 2px;
  background: conic-gradient(
    from 0deg,
    transparent 0%,
    var(--accent) 10%,
    transparent 20%,
    transparent 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--transition-base);
  animation: rotate-border 3s linear infinite;
}

.dropzone:hover::before,
.dropzone.dragover::before {
  opacity: 1;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: transparent;
  background: rgba(108, 92, 231, 0.05);
}

.dropzone.dragover {
  transform: scale(1.01);
}

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

.dropzone-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  transition: transform var(--transition-spring);
}

.dropzone:hover .dropzone-icon,
.dropzone.dragover .dropzone-icon {
  transform: translateY(-5px) scale(1.1);
}

.dropzone-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.dropzone-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.dropzone-subtitle span {
  color: var(--accent-light);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- File Preview List ---------- */
.file-preview-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  animation: slideIn var(--transition-base) ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.file-preview-item .file-icon {
  font-size: 20px;
  flex-shrink: 0;
}

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

.file-preview-item .file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview-item .file-size {
  font-size: 12px;
  color: var(--text-muted);
}

.file-preview-item .file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.file-preview-item .file-remove:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ---------- Progress Bar ---------- */
.progress-container {
  margin-top: var(--space-lg);
  display: none;
}

.progress-container.active {
  display: block;
}

.progress-bar-wrapper {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width var(--transition-smooth);
  position: relative;
}

.progress-bar.indeterminate {
  width: 30% !important;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-sm);
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Data Table ---------- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

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

.data-table tbody td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

.table-actions {
  display: flex;
  gap: var(--space-sm);
}

/* ---------- Method Cards (Selection) ---------- */
.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

.method-card {
  background: var(--glass-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-base);
  position: relative;
}

.method-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.method-card.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: var(--shadow-glow);
}

.method-card .method-icon {
  font-size: 32px;
  margin-bottom: var(--space-sm);
}

.method-card .method-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.method-card .method-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.method-card .method-check {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.method-card.selected .method-check {
  display: flex;
}

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: var(--space-2xl);
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  position: relative;
}

.stepper-circle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.stepper-step.active .stepper-circle {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: 0 0 15px var(--accent-glow);
}

.stepper-step.completed .stepper-circle {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.stepper-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.stepper-step.active .stepper-label {
  color: var(--text-primary);
}

.stepper-step.completed .stepper-label {
  color: var(--success);
}

.stepper-line {
  width: 60px;
  height: 2px;
  background: var(--border);
  margin: 0 var(--space-md);
  transition: background var(--transition-base);
}

.stepper-line.completed {
  background: var(--success);
}

/* ---------- Step Panels ---------- */
.step-panel {
  display: none;
  animation: fadeIn var(--transition-base) ease-out;
}

.step-panel.active {
  display: block;
}

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

/* ---------- Rules List ---------- */
.rule-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: slideIn var(--transition-base) ease-out;
}

.rule-item .rule-pages {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.rule-item .rule-arrow {
  color: var(--text-muted);
}

.rule-item .rule-method {
  flex: 1;
}

/* ---------- Results Timeline ---------- */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.result-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.result-title {
  font-size: 16px;
  font-weight: 600;
}

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

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.result-pages {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.result-page-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  transition: all var(--transition-fast);
}

.result-page-link:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

/* ---------- Split Pane (Viewer) ---------- */
.split-container {
  display: flex;
  height: calc(100vh - var(--header-height) - 130px);
  gap: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.split-pane {
  overflow: auto;
  background: var(--bg-secondary);
}

.split-pane-left {
  flex: 1;
  min-width: 200px;
}

.split-pane-right {
  flex: 1;
  min-width: 200px;
  border-left: 1px solid var(--border);
  padding: var(--space-lg);
}

.split-handle {
  width: 6px;
  cursor: col-resize;
  background: var(--border);
  transition: background var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}

.split-handle:hover,
.split-handle.dragging {
  background: var(--accent);
}

.split-handle::after {
  content: '⋮';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 14px;
}

.split-pane-left iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Markdown rendered content */
.markdown-body {
  line-height: 1.7;
  font-size: 15px;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.markdown-body h1 { font-size: 24px; }
.markdown-body h2 { font-size: 20px; }
.markdown-body h3 { font-size: 17px; }

.markdown-body p {
  margin-bottom: 1em;
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.markdown-body code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.markdown-body pre {
  background: var(--bg-tertiary);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 1em;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
}

.markdown-body th, .markdown-body td {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-body th {
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 13px;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

/* ---------- Viewer Toolbar ---------- */
.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.viewer-toolbar .toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.viewer-toolbar .toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.viewer-toolbar .toolbar-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: 10000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  min-width: 300px;
  max-width: 450px;
  pointer-events: all;
  animation: toastIn var(--transition-smooth) ease-out;
  font-size: 14px;
}

.toast.toast-out {
  animation: toastOut var(--transition-base) ease-in forwards;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--info); }

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

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

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

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
  }
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state .empty-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.empty-state .empty-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto;
}

/* ---------- Loading Spinner ---------- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

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

/* ---------- Skeleton Loader ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

/* ---------- Page Transition ---------- */
.page-enter {
  animation: pageEnter var(--transition-smooth) ease-out;
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideStripe {
  from { background-position: 0 0; }
  to   { background-position: 32px 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

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

  .page-body {
    padding: var(--space-lg);
  }

  .split-container {
    flex-direction: column;
    height: auto;
  }

  .split-pane-left {
    height: 60vh !important;
    min-height: 450px !important;
    flex: none !important;
    width: 100% !important;
  }

  .split-pane-right {
    min-height: 400px !important;
    flex: none !important;
    width: 100% !important;
  }

  .split-handle {
    width: 100%;
    height: 6px;
    cursor: row-resize;
  }

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

  .stepper {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .stepper-line {
    width: 2px;
    height: 20px;
    margin: 0;
  }

  /* Mobile menu toggle */
  .mobile-menu-btn {
    display: flex !important;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn {
    display: none !important;
  }
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent);
  color: white;
}

/* ---------- Focus Visible ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Utilities ---------- */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm        { gap: var(--space-sm); }
.gap-md        { gap: var(--space-md); }
.gap-lg        { gap: var(--space-lg); }
.mt-md         { margin-top: var(--space-md); }
.mt-lg         { margin-top: var(--space-lg); }
.mt-xl         { margin-top: var(--space-xl); }
.mb-md         { margin-bottom: var(--space-md); }
.text-center   { text-align: center; }
.text-muted    { color: var(--text-secondary); }
.text-sm       { font-size: 13px; }
.font-semibold { font-weight: 600; }
.w-full        { width: 100%; }
.hidden        { display: none !important; }

/* ---------- Segmented Control (Toggle Glissant) ---------- */
.segmented-control-wrapper {
  display: inline-flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px;
  position: relative;
  gap: 4px;
  user-select: none;
  backdrop-filter: blur(10px);
}

.segmented-control-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}

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

.segmented-control-btn.active {
  color: #ffffff;
  background: var(--accent-gradient);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.segmented-control-btn .count-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-weight: 700;
}

.segmented-control-btn.active .count-badge {
  background: rgba(255, 255, 255, 0.25);
}

/* ---------- Section Header Bars ---------- */
.section-divider-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-xl) 0 var(--space-lg) 0;
  padding-bottom: var(--space-xs);
  position: relative;
}

.section-divider-bar .section-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.section-divider-bar.indexed-bar .section-title {
  color: #10B981;
}

.section-divider-bar.non-indexed-bar .section-title {
  color: var(--text-secondary);
}

.section-divider-bar .section-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: var(--radius-full);
}

.section-divider-bar.indexed-bar .section-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.section-divider-bar.non-indexed-bar .section-badge {
  background: var(--glass-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.section-divider-bar .section-line {
  flex: 1;
  height: 2px;
  border-radius: var(--radius-full);
}

.section-divider-bar.indexed-bar .section-line {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.4) 0%, rgba(16, 185, 129, 0.05) 100%);
}

.section-divider-bar.non-indexed-bar .section-line {
  background: linear-gradient(90deg, var(--border-hover) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.empty-section-notice {
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--glass-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}

