/* ── RESET & VARIABLES ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0f14;
  --surface:   #13161e;
  --surface2:  #1a1e28;
  --border:    #252a38;
  --accent:    #4f8ef7;
  --accent2:   #7c5cfc;
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --text:      #e8eaf0;
  --text2:     #8b93a7;
  --text3:     #555f74;
  --sidebar-w: 220px;
  --panel-w:   320px;
  --font:      'DM Sans', sans-serif;
  --mono:      'DM Mono', monospace;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
}

/* ── SCROLLBAR ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── SIDEBAR ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  flex-shrink: 0;
}
.logo-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.logo-sub  { font-size: 9px; color: var(--text3); letter-spacing: 1px; font-family: var(--mono); }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(79,142,247,.12); color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }

.btn-generate {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .3px;
  transition: opacity .15s;
}
.btn-generate:hover { opacity: .85; }

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text3);
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
  transition: color .15s;
}
.nav-item-footer:hover { color: var(--text2); }

/* ── MAIN ──────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOPBAR ────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  width: 260px;
}
.search-wrap svg { opacity: .4; flex-shrink: 0; }
.search-input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: 13px; width: 100%;
}
.search-input::placeholder { color: var(--text3); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 32px; height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text2);
  position: relative;
  transition: all .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.notif-dot {
  width: 6px; height: 6px;
  background: var(--danger);
  border-radius: 50%;
  position: absolute;
  top: 4px; right: 4px;
}
.topbar-label { font-size: 12px; color: var(--text3); padding: 0 4px; }
.avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

/* ── PAGES ─────────────────────────────────────────────────────── */
.page-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.page { display: none; }
.page.active { display: block; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.page-header p  { color: var(--text2); font-size: 13px; }

/* ── UPLOAD PAGE ───────────────────────────────────────────────── */
.upload-card {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
  margin-bottom: 20px;
}
.upload-card:hover, .upload-card.drag {
  border-color: var(--accent);
  background: rgba(79,142,247,.04);
}
.upload-icon {
  width: 56px; height: 56px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  color: var(--accent);
}
.upload-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.upload-sub { color: var(--text2); font-size: 13px; line-height: 1.6; margin-bottom: 20px; }
.upload-btns { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.btn-primary {
  padding: 9px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }

.btn-outline {
  padding: 9px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ── VALIDATION ────────────────────────────────────────────────── */
.validation-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.validation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.val-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}
.status-badge {
  font-size: 10px;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(79,142,247,.15);
  color: var(--accent);
  letter-spacing: .5px;
}
.status-badge.done { background: rgba(34,197,94,.15); color: var(--success); }

.progress-row { margin-bottom: 16px; }
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text2);
}
.progress-track {
  height: 4px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px;
  transition: width .4s ease;
}

.val-checks { display: flex; gap: 12px; flex-wrap: wrap; }
.val-check {
  flex: 1;
  min-width: 160px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.check-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.check-icon.success { background: rgba(34,197,94,.2); color: var(--success); }
.check-icon.pending { background: rgba(139,147,167,.1); color: var(--text3); }
.check-icon.done    { background: rgba(34,197,94,.2); color: var(--success); }
.check-title { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.check-sub   { font-size: 11px; color: var(--text2); }

/* ── PREVIEW TABLE ─────────────────────────────────────────────── */
.preview-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.preview-title { font-size: 13px; font-weight: 600; }
.preview-sub   { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── DASHBOARD ─────────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color .2s;
}
.metric-card:hover { border-color: var(--accent); }
.metric-card.danger  { border-left: 3px solid var(--danger); }
.metric-card.warning { border-left: 3px solid var(--warning); }
.metric-card.success { border-left: 3px solid var(--success); }
.metric-label { font-size: 11px; color: var(--text3); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 8px; }
.metric-val   { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.metric-sub   { font-size: 11px; color: var(--text2); }

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 14px; }

/* ── TABLE ─────────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.filter-sel {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table thead tr {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .8px;
  color: var(--text3);
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

.risk-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
}
.risk-badge.High   { background: rgba(239,68,68,.15);  color: var(--danger);  }
.risk-badge.Medium { background: rgba(245,158,11,.15); color: var(--warning); }
.risk-badge.Low    { background: rgba(34,197,94,.15);  color: var(--success); }

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  margin-right: 4px;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

/* ── STUDENT GRID ──────────────────────────────────────────────── */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.student-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .2s, transform .2s;
}
.student-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.sc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.sc-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.sc-id   { font-size: 10px; color: var(--text3); font-family: var(--mono); }
.sc-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.sc-stat { text-align: center; }
.sc-stat-val { font-size: 16px; font-weight: 700; }
.sc-stat-lbl { font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.sc-actions { display: flex; gap: 6px; }
.sc-btn {
  flex: 1;
  padding: 6px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  transition: all .15s;
}
.sc-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── INSIGHTS PAGE ─────────────────────────────────────────────── */
.insight-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text2);
}
.insight-empty p { margin: 12px 0 20px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 14px; }
.report-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.report-section h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent);
}
.report-section p { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* ── AI PANEL ──────────────────────────────────────────────────── */
.ai-panel {
  width: var(--panel-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ai-name { font-size: 13px; font-weight: 600; }
.ai-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: .5px;
  font-family: var(--mono);
}
.status-dot {
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg { max-width: 88%; }
.chat-msg.ai   { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }
.chat-msg p {
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.6;
}
.chat-msg.ai   p { background: var(--surface2); color: var(--text2); border-radius: 2px 10px 10px 10px; }
.chat-msg.user p { background: var(--accent);   color: white;       border-radius: 10px 2px 10px 10px; }
.chat-msg.loading p { color: var(--text3); }

.quick-actions { padding: 0 16px 12px; flex-shrink: 0; }
.quick-label { font-size: 9px; color: var(--text3); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px; font-family: var(--mono); }
.quick-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
}
.quick-btn:hover { border-color: var(--accent); color: var(--accent); }

.chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text3); }
.chat-send {
  width: 34px; height: 34px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}
.chat-send:hover { opacity: .85; }

.ai-insight-box {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-insight-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ai-insight-text { font-size: 11px; color: var(--text2); line-height: 1.5; }

/* ── MODAL ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: none;
  place-items: center;
  z-index: 100;
}
.modal-overlay.open { display: grid; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: fadeUp .2s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  background: var(--surface2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
}
.modal-close:hover { color: var(--text); }
.modal-body { font-size: 13px; color: var(--text2); line-height: 1.7; white-space: pre-wrap; }
.modal-tone-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tone-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
}
.tone-btn.active, .tone-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(79,142,247,.08); }

/* ── TOAST ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: all .3s;
  z-index: 200;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── FAB ───────────────────────────────────────────────────────── */
.fab { display: none; }

/* ── EMPTY STATE ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state svg { margin-bottom: 12px; opacity: .3; }
.empty-state p { font-size: 13px; }

/* ── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .ai-panel { display: none; }
  .fab { display: grid; place-items: center; position: fixed; bottom: 20px; right: 20px; width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg,var(--accent),var(--accent2)); border: none; cursor: pointer; box-shadow: var(--shadow); z-index: 50; }
}
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2,1fr); }
  .charts-row   { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .sidebar { display: none; }
  .metrics-grid { grid-template-columns: repeat(2,1fr); }
}