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

:root {
  --bg: #f8fafc;
  --bg-alt: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;

  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-glow: rgba(79,70,229,0.15);
  --accent-gold: #d97706;
  --accent-teal: #0d9488;
  --accent-rose: #e11d48;
  --accent-violet: #9333ea;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --grade-a: #10b981;
  --grade-b: #6366f1;
  --grade-c: #f59e0b;
  --grade-d: #f97316;
  --grade-e: #ef4444;
  --grade-g: #6b7280;
  --grade-t: #9ca3af;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.05);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== HEADER ===== */
.header {
  position: relative;
  padding: 80px 0 60px;
  overflow: hidden;
  text-align: center;
}

.header-bg {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99,102,241,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 100%, rgba(168,85,247,0.1) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 90% 50%, rgba(20,184,166,0.08) 0%, transparent 60%);
  z-index: 0;
}

.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 40px,
    rgba(0,0,0,0.03) 40px, rgba(0,0,0,0.03) 41px
  ),
  repeating-linear-gradient(
    90deg, transparent, transparent 80px,
    rgba(0,0,0,0.03) 80px, rgba(0,0,0,0.03) 81px
  );
  z-index: 0;
}

.header-content { position: relative; z-index: 1; }

.header-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), var(--accent-violet));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 6px 20px;
  border-radius: 100px;
  margin-bottom: 20px;
  box-shadow: 0 0 20px var(--primary-glow);
}

.header-title {
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 900;
  background: linear-gradient(135deg, var(--text) 30%, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  line-height: 1.15;
}

.header-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-weight: 400;
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-menu {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 40px;
}

.meta-item {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* ===== SECTIONS ===== */
.section { padding: 60px 0; }
.section-alt { background: var(--bg-alt); }

.section-title {
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  text-align: center;
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 36px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-accent, var(--primary));
}

.stat-icon {
  font-size: 28px;
  margin-bottom: 10px;
  display: block;
}

.stat-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== CHART CARDS ===== */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.donut-card { display: flex; flex-direction: column; align-items: center; }
.donut-card canvas { max-width: 280px; }

@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ===== TOP STUDENTS ===== */
.top-students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.student-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform 0.2s, border-color 0.2s;
}

.student-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
}

.student-rank {
  font-size: 18px;
  font-weight: 900;
  min-width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rank-1 { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #cd7c3c, #b45309); color: #fff; }
.rank-other { background: var(--surface-3); color: var(--text-secondary); font-size: 14px; }

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

.student-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-class {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.student-score {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent-gold);
}

.student-score-label {
  font-size: 10px;
  color: var(--text-muted);
}

.student-grades {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-input, .filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 10px 16px;
  outline: none;
  transition: border-color 0.2s;
}

.filter-input { flex: 1; min-width: 200px; }
.filter-select { min-width: 160px; cursor: pointer; }

.filter-input:focus, .filter-select:focus {
  border-color: var(--primary);
}

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.data-table tbody tr {
  background: var(--surface);
  transition: background 0.15s;
}

.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Grade badges */
.grade-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  margin: 2px;
}

.gr-ap { background: rgba(16,185,129,0.15); color: #059669; }
.gr-a  { background: rgba(16,185,129,0.15); color: #10b981; }
.gr-am { background: rgba(16,185,129,0.15); color: #34d399; }
.gr-bp { background: rgba(99,102,241,0.15); color: #4338ca; }
.gr-b  { background: rgba(99,102,241,0.15); color: #6366f1; }
.gr-cp { background: rgba(245,158,11,0.15); color: #b45309; }
.gr-c  { background: rgba(245,158,11,0.15); color: #d97706; }
.gr-d  { background: rgba(249,115,22,0.15); color: #c2410c; }
.gr-e  { background: rgba(239,68,68,0.15); color: #b91c1c; }
.gr-g  { background: rgba(107,114,128,0.15); color: #374151; }
.gr-t  { background: rgba(55,65,81,0.15); color: #1f2937; }

/* Category badges */
.cat-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.cat-cemerlang  { background: rgba(16,185,129,0.15); color: #059669; border: 1px solid rgba(16,185,129,0.3); }
.cat-kepujian   { background: rgba(99,102,241,0.15); color: #4f46e5; border: 1px solid rgba(99,102,241,0.3); }
.cat-memuaskan  { background: rgba(245,158,11,0.15); color: #b45309; border: 1px solid rgba(245,158,11,0.3); }
.cat-lemah      { background: rgba(239,68,68,0.15); color: #b91c1c; border: 1px solid rgba(239,68,68,0.3); }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 12px;
}

.table-footer {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: right;
}

/* ===== FOOTER ===== */
.footer {
  padding: 40px 0;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== NAVIGATION MENU ===== */
.nav-menu {
  background: var(--surface);
  border-top: 1px solid rgba(255,255,255,0.05);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 10px;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--primary); color: white; }
.view-hidden { display: none !important; }

/* ===== ANALISIS KESELURUHAN (MODERN UI) ===== */
.ak-header-modern {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.ak-title-block h3 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
.ak-title-block p {
  font-size: 13px;
  color: var(--text-secondary);
}
.ak-gps-block {
  display: flex;
  gap: 16px;
}
.ak-gps-card {
  background: var(--bg);
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ak-gps-card.highlight {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}
.ak-gps-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; margin-bottom: 4px; }
.ak-gps-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1; }
.highlight .ak-gps-value { color: #10b981; }

.modern-table-wrapper {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}
.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.modern-table th {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 700;
  padding: 14px 10px;
  text-align: center;
  border-bottom: 2px solid var(--border);
}
.modern-table th.nowrap-col {
  white-space: nowrap;
}
.modern-table td {
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.modern-table .col-subject {
  white-space: normal !important;
  word-wrap: break-word;
  text-align: left !important;
  line-height: 1.4;
  min-width: 150px;
  max-width: 250px;
}
.modern-table tbody tr:hover {
  background: var(--surface-2);
}
.modern-table tfoot td {
  background: var(--surface-3);
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
}
.modern-table .cell-val { font-weight: 800; font-size: 14px; }
.modern-table .cell-pct { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* Table Columns Highlighting */
.modern-table th.col-a, .modern-table td.col-a { background: rgba(16, 185, 129, 0.08); }
.modern-table th.col-b, .modern-table td.col-b { background: rgba(99, 102, 241, 0.08); }
.modern-table th.col-c, .modern-table td.col-c { background: rgba(245, 158, 11, 0.08); }
.modern-table th.col-d, .modern-table td.col-d,
.modern-table th.col-e, .modern-table td.col-e { background: rgba(249, 115, 22, 0.08); }
.modern-table th.col-lulus, .modern-table td.col-lulus { background: rgba(16, 185, 129, 0.15); color: #059669; }
.modern-table th.col-g, .modern-table td.col-g,
.modern-table th.col-t, .modern-table td.col-t { background: rgba(244, 63, 94, 0.08); }
.modern-table th.col-gpmp, .modern-table td.col-gpmp { background: var(--surface-3); font-weight: 800; font-size: 15px; }

.ak-rumusan-section { margin-top: 32px; }
.rumusan-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 16px; padding-left: 8px; border-left: 4px solid var(--primary); }
.rumusan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.rum-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}
.rum-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.rum-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.4; }
.rum-bottom { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.rum-val { font-size: 24px; font-weight: 800; color: var(--text); }
.rum-pct { font-size: 13px; font-weight: 600; color: var(--text-muted); padding: 2px 8px; background: var(--bg); border-radius: 20px; }
.rum-card.success .rum-val { color: #10b981; }
.rum-card.success .rum-pct { background: rgba(16,185,129,0.1); color: #10b981; }
.rum-card.danger .rum-val { color: #f43f5e; }
.rum-card.danger .rum-pct { background: rgba(244,63,94,0.1); color: #f43f5e; }

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stat-card, .chart-card, .student-card {
  animation: fadeUp 0.4s ease both;
}
