:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e8e8e8;
  --border-strong: #d4d4d4;
  --divider: #f1f1f1;
  --text: #171717;
  --text-2: #525252;
  --text-3: #a3a3a3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-tint: #eef2ff;
  --accent-soft: #e0e7ff;
  --emerald: #10b981;
  --emerald-tint: #d1fae5;
  --amber: #f59e0b;
  --amber-tint: #fef3c7;
  --rose: #f43f5e;
  --rose-tint: #ffe4e6;
  --sky: #0ea5e9;
  --sky-tint: #e0f2fe;
  --violet: #8b5cf6;
  --violet-tint: #ede9fe;
  --slate: #64748b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Cleaner scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #a3a3a3; }

/* Avatar palette */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-weight: 600; flex-shrink: 0; font-size: 13px; }
.avatar.indigo { background: var(--accent-tint); color: var(--accent); }
.avatar.emerald { background: var(--emerald-tint); color: var(--emerald); }
.avatar.amber { background: var(--amber-tint); color: #b45309; }
.avatar.rose { background: var(--rose-tint); color: #be123c; }
.avatar.sky { background: var(--sky-tint); color: #0369a1; }
.avatar.violet { background: var(--violet-tint); color: #6d28d9; }

/* Subject colored chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.chip-indigo { background: var(--accent-tint); color: var(--accent); }
.chip-emerald { background: var(--emerald-tint); color: #047857; }
.chip-amber { background: var(--amber-tint); color: #b45309; }
.chip-rose { background: var(--rose-tint); color: #be123c; }
.chip-sky { background: var(--sky-tint); color: #0369a1; }
.chip-violet { background: var(--violet-tint); color: #6d28d9; }
.chip-slate { background: #f1f5f9; color: #475569; }
.chip-success { background: #dcfce7; color: #166534; }
.chip-warning { background: var(--amber-tint); color: #b45309; }
.chip-danger { background: #fee2e2; color: #b91c1c; }
.chip-neutral { background: #f5f5f5; color: var(--text-2); }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.card-hover { transition: border-color 120ms ease, transform 120ms ease; }
.card-hover:hover { border-color: var(--border-strong); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 14px; cursor: pointer; transition: all 120ms ease; border: 1px solid transparent; white-space: nowrap; line-height: 1; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm svg { width: 14px; height: 14px; }
.btn > span { white-space: nowrap; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: #fafafa; border-color: #a3a3a3; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #f5f5f5; color: var(--text); }
.btn-danger { background: #fff; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Input */
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: all 120ms ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.textarea { resize: vertical; min-height: 96px; }
.input-label { font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; display: block; }

/* Sidebar */
.sidebar { width: 240px; background: #fff; border-right: 1px solid var(--border); height: 100vh; position: fixed; top: 0; left: 0; display: flex; flex-direction: column; z-index: 30; }
.sidebar-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--divider); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px; }
.sidebar-section { padding: 12px 12px 4px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 7px; color: var(--text-2); font-size: 14px; cursor: pointer; transition: all 100ms ease; text-decoration: none; }
.nav-item:hover { background: #f5f5f5; color: var(--text); }
.nav-item.active { background: var(--accent-tint); color: var(--accent); font-weight: 500; }
.nav-item.active svg { color: var(--accent); }
.nav-item svg { color: var(--text-3); width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover svg { color: var(--text-2); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--divider); }

/* Topbar */
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.topbar-breadcrumb { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; }
.topbar-breadcrumb .crumb-sep { color: var(--text-3); }
.topbar-breadcrumb .crumb-current { color: var(--text); font-weight: 500; }

/* Main layout */
.layout { padding-left: 240px; min-height: 100vh; }
.page { max-width: 1280px; margin: 0 auto; padding: 28px 32px 64px; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); margin: 0 0 4px; }
.page-subtitle { color: var(--text-2); margin: 0 0 24px; font-size: 14px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 12px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 11px 14px; background: #fafafa; border-bottom: 1px solid var(--border); color: var(--text-2); font-weight: 500; font-size: 13px; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--divider); color: var(--text); }
.table tbody tr:hover { background: #fafafa; }
.table tbody tr:last-child td { border-bottom: 0; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 15, 15, 0.4); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 100; animation: fadeIn 150ms ease; }
.modal { background: #fff; border-radius: 16px; padding: 24px; max-width: 520px; width: 90%; max-height: 85vh; overflow-y: auto; animation: scaleIn 150ms ease; }
.modal-lg { max-width: 720px; }
.modal h3 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1a1a1a; color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; max-width: 360px; display: flex; gap: 10px; align-items: flex-start; box-shadow: 0 8px 24px rgba(0,0,0,0.18); animation: slideIn 200ms ease; }
.toast.success { background: #047857; }
.toast.error { background: #b91c1c; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes typing { 0% { opacity: 0.3; } 50% { opacity: 1; } 100% { opacity: 0.3; } }

.shimmer { background: linear-gradient(90deg, #f5f5f5 0px, #ebebeb 200px, #f5f5f5 400px); background-size: 800px 100%; animation: shimmer 1.4s infinite linear; }
.spin { animation: spin 1s linear infinite; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }

/* AI chat */
.chat-window { display: flex; flex-direction: column; height: calc(100vh - 60px - 56px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px 32px; }
.chat-msg { display: flex; gap: 12px; margin-bottom: 24px; max-width: 760px; }
.chat-msg .msg-avatar { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.chat-msg .msg-avatar.user { background: #f5f5f5; color: var(--text); }
.chat-msg .msg-avatar.ai { background: #1a1a1a; color: #fff; }
.chat-msg .msg-body { flex: 1; padding-top: 2px; }
.chat-msg .msg-author { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.chat-msg .msg-content { color: var(--text); font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.chat-input-bar { padding: 16px 32px 24px; background: var(--bg); }
.chat-input-wrap { max-width: 760px; margin: 0 auto; position: relative; }
.chat-input { width: 100%; padding: 14px 52px 14px 16px; border: 1px solid var(--border-strong); border-radius: 14px; font-size: 14px; background: #fff; resize: none; min-height: 52px; max-height: 200px; }
.chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.chat-send { position: absolute; right: 8px; bottom: 8px; width: 36px; height: 36px; background: var(--accent); border: none; border-radius: 8px; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.chat-send:disabled { background: #d4d4d4; cursor: not-allowed; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0 0; }
.chat-suggestion { padding: 8px 14px; background: #fff; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 13px; color: var(--text-2); transition: all 120ms ease; }
.chat-suggestion:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span { width: 6px; height: 6px; background: var(--text-3); border-radius: 50%; animation: typing 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

/* File drop zone */
.dropzone { border: 2px dashed var(--border-strong); border-radius: 14px; padding: 48px 24px; text-align: center; transition: all 150ms ease; cursor: pointer; background: #fafafa; }
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-tint); }
.dropzone-icon { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--text-3); }
.dropzone:hover .dropzone-icon { color: var(--accent); }

/* Stat card */
.stat-card { padding: 18px 20px; }
.stat-card .stat-label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); line-height: 1.1; }
.stat-card .stat-delta { font-size: 12px; margin-top: 6px; display: inline-flex; align-items: center; gap: 3px; }
.stat-card .stat-delta.up { color: #047857; }
.stat-card .stat-delta.down { color: #b91c1c; }
.stat-card .stat-delta.flat { color: var(--text-3); }

/* Heatmap (custom div grid) */
.heatmap { display: grid; gap: 4px; }
.heatmap-cell { aspect-ratio: 1; border-radius: 4px; background: #f1f5f9; transition: transform 100ms ease; }
.heatmap-cell:hover { transform: scale(1.15); }

/* Quiz attempt navigator */
.q-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.q-nav-btn { aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--border); background: #fff; font-size: 13px; cursor: pointer; transition: all 120ms ease; color: var(--text-2); }
.q-nav-btn:hover { border-color: var(--accent); }
.q-nav-btn.answered { background: var(--accent-tint); border-color: var(--accent-soft); color: var(--accent); font-weight: 500; }
.q-nav-btn.current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Progress bar/ring */
.progress-bar { height: 6px; background: #f1f1f1; border-radius: 999px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width 300ms ease; }

/* Severity colors */
.severity-high { color: #b91c1c; background: #fee2e2; }
.severity-medium { color: #b45309; background: var(--amber-tint); }
.severity-low { color: #475569; background: #f1f5f9; }

/* Responsive-ish */
@media (max-width: 1024px) {
  .page { padding: 20px; }
  .topbar { padding: 0 20px; }
}

/* Utility classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; }
.text-xs { font-size: 12px; } .text-sm { font-size: 13px; } .text-base { font-size: 14px; } .text-lg { font-size: 16px; } .text-xl { font-size: 18px; } .text-2xl { font-size: 22px; } .text-3xl { font-size: 28px; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; }
.text-text-2 { color: var(--text-2); } .text-text-3 { color: var(--text-3); } .text-accent { color: var(--accent); } .text-emerald { color: #047857; } .text-rose { color: #be123c; } .text-amber { color: #b45309; }
.p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; }
.w-full { width: 100%; }
.rounded { border-radius: 8px; }
.rounded-lg { border-radius: 12px; }
.border { border: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.cursor-pointer { cursor: pointer; }
.hidden { display: none; }
.relative { position: relative; }
.absolute { position: absolute; }
.overflow-hidden { overflow: hidden; }
