/* =============================================
   Online Exam Portal – Shared Styles
   ============================================= */

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

body {
  font-family: 'Comic Neue', cursive;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ---------- Navigation ---------- */
.portal-nav {
  background: linear-gradient(135deg, #4a47a3, #667eea);
  position: sticky; top: 0; z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
}
.nav-inner {
  max-width: 1300px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; flex-wrap: wrap; gap: 10px;
}
.nav-brand {
  font-family: 'Fredoka One', cursive;
  font-size: 1.5rem; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-links a {
  color: rgba(255,255,255,.85); padding: 8px 14px;
  border-radius: 8px; font-weight: 700; font-size: .92rem;
  transition: .2s;
}
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,.18); color: #fff; }
.nav-user { display: flex; align-items: center; gap: 12px; color: #fff; }
.nav-school { font-size: .82rem; opacity: .8; }
.nav-name { font-weight: 700; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; }

@media (max-width: 768px) {
  .nav-links { display: none; width: 100%; flex-direction: column; }
  .nav-open .nav-links { display: flex; }
  .nav-toggle { display: block; }
  .nav-user .nav-school, .nav-user .nav-name { display: none; }
}

/* ---------- Profile Dropdown Menu ---------- */
.nav-profile-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-profile {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  padding: 8px 16px;
  border-radius: 24px;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  transition: .2s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-profile:hover {
  background: rgba(255,255,255,.25);
  border-color: rgba(255,255,255,.5);
}

.profile-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: scale(.95) translateY(-10px);
  transition: .2s;
  overflow: hidden;
  z-index: 1001;
}

.profile-dropdown-menu.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

.profile-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #333;
  font-weight: 600;
  font-size: .95rem;
  border-radius: 0;
  transition: .15s;
}

.profile-dropdown-menu a:hover {
  background: #f8f9fa;
  color: #4a47a3;
}

.profile-dropdown-menu hr {
  margin: 6px 0;
  border: none;
  border-top: 1px solid #e9ecef;
}

.profile-dropdown-menu i {
  font-size: 1rem;
  opacity: .8;
}

/* ---------- Containers ---------- */
.page-wrap { padding: 24px; min-height: calc(100vh - 60px); }
.container {
  max-width: 1200px; margin: 0 auto;
  background: rgba(255,255,255,.98);
  border-radius: 22px; padding: 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.container-sm { max-width: 560px; }
.container-md { max-width: 820px; }
.container-lg { max-width: 1200px; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-family: 'Fredoka One', cursive; color: #4a47a3; }
h1 { font-size: 2rem; margin-bottom: 8px; }
h2 { font-size: 1.6rem; margin-bottom: 6px; }
h3 { font-size: 1.25rem; }

.subtitle { color: #666; font-size: 1.05rem; }
.text-center { text-align: center; }
.text-muted { color: #999; }

/* ---------- Cards ---------- */
.card {
  background: #fff; border-radius: 16px;
  padding: 24px; box-shadow: 0 4px 18px rgba(0,0,0,.06);
  border: 2px solid transparent; transition: .25s;
}
.card:hover { border-color: #667eea; transform: translateY(-3px); box-shadow: 0 8px 30px rgba(0,0,0,.1); }
.card-header { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #f0f0f0; }
.card-icon { font-size: 2.2rem; margin-bottom: 10px; display: block; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: linear-gradient(145deg, #f8f9fa, #e9ecef);
  padding: 20px; border-radius: 14px; text-align: center;
  border: 2px solid transparent; transition: .25s;
}
.stat-card:hover { border-color: #667eea; transform: translateY(-3px); }
.stat-number { font-size: 2rem; font-weight: 700; color: #667eea; display: block; }
.stat-label { color: #666; font-size: .88rem; margin-top: 4px; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border: none; border-radius: 25px;
  font-size: 1rem; font-weight: 700; font-family: 'Comic Neue', cursive;
  cursor: pointer; transition: .25s; color: #fff;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,.18); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); }
.btn-success { background: linear-gradient(135deg, #4caf50, #8bc34a); }
.btn-danger  { background: linear-gradient(135deg, #f44336, #ff7043); }
.btn-warning { background: linear-gradient(135deg, #ff9800, #ffc107); color: #333; }
.btn-info    { background: linear-gradient(135deg, #00bcd4, #26c6da); }
.btn-secondary { background: linear-gradient(135deg, #78909c, #b0bec5); }
.btn-outline {
  background: transparent; border: 2px solid #667eea;
  color: #667eea;
}
.btn-outline:hover { background: #667eea; color: #fff; }

.btn-sm { padding: 8px 16px; font-size: .88rem; border-radius: 20px; }
.btn-lg { padding: 16px 36px; font-size: 1.15rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-logout { background: rgba(255,255,255,.15); }
.btn-logout:hover { background: rgba(255,255,255,.3); }

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

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-weight: 700; color: #4a47a3;
  margin-bottom: 6px; font-size: .95rem;
}
.form-control {
  width: 100%; padding: 12px 16px;
  border: 2px solid #ddd; border-radius: 12px;
  font-size: 1rem; font-family: 'Comic Neue', cursive;
  transition: .2s; background: #fff;
}
.form-control:focus { outline: none; border-color: #667eea; box-shadow: 0 0 12px rgba(102,126,234,.2); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.form-hint { font-size: .82rem; color: #999; margin-top: 4px; }
.form-error { font-size: .82rem; color: #f44336; margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 14px; box-shadow: 0 4px 18px rgba(0,0,0,.08); margin: 20px 0; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
thead th {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; padding: 14px 12px; text-align: center; font-size: .92rem;
  position: sticky; top: 0; z-index: 5;
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
tbody td { padding: 12px; border-bottom: 1px solid #e8e8e8; text-align: center; font-size: .93rem; }
tbody td:first-child { text-align: center; font-weight: 700; color: #667eea; }
tbody td:nth-child(2) { text-align: left; font-weight: 600; }
tbody tr:hover { background: rgba(102,126,234,.06); }
tbody tr:nth-child(even) { background: rgba(102,126,234,.02); }
tfoot td { padding: 12px; font-weight: 700; background: #f5f5f5; text-align: center; border-top: 3px solid #667eea; }

/* Grade badges */
.grade-badge {
  font-weight: 700; padding: 4px 14px; border-radius: 20px;
  display: inline-block; min-width: 36px; font-size: .9rem;
}
.grade-a { background: #e8f5e9; color: #2e7d32; }
.grade-b { background: #fff8e1; color: #f57f17; }
.grade-c { background: #fff3e0; color: #ef6c00; }
.grade-d { background: #fbe9e7; color: #d84315; }
.grade-f { background: #ffebee; color: #c62828; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 3px solid #e0e0e0; }
.tab-btn {
  padding: 12px 22px; border: none; background: none;
  font-family: 'Comic Neue', cursive; font-weight: 700;
  font-size: 1rem; color: #999; cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -3px; transition: .2s;
}
.tab-btn:hover { color: #667eea; }
.tab-btn.active { color: #667eea; border-bottom-color: #667eea; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 2000; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 20px; padding: 32px;
  max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: #999; transition: .2s;
}
.modal-close:hover { color: #f44336; }

/* ---------- Alert / Empty ---------- */
.alert {
  padding: 16px 20px; border-radius: 12px; margin-bottom: 16px;
  font-weight: 600;
}
.alert-info    { background: #e3f2fd; color: #1565c0; }
.alert-success { background: #e8f5e9; color: #2e7d32; }
.alert-warning { background: #fff8e1; color: #f57f17; }
.alert-danger  { background: #ffebee; color: #c62828; }

.empty-state { text-align: center; padding: 50px 20px; color: #bbb; }
.empty-state i { font-size: 3.5rem; margin-bottom: 16px; display: block; }
.empty-state h3 { color: #999; margin-bottom: 8px; }

/* ---------- Timer ---------- */
.timer-bar {
  position: fixed; top: 60px; left: 0; right: 0;
  background: #fff; padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0,0,0,.1); z-index: 999;
}
.timer-display {
  font-family: 'Fredoka One', cursive; font-size: 1.6rem;
  color: #4a47a3;
}
.timer-display.warning { color: #ff9800; }
.timer-display.danger  { color: #f44336; animation: pulse .5s infinite alternate; }

@keyframes pulse { to { opacity: .5; } }

.timer-progress {
  height: 6px; background: #e0e0e0; border-radius: 3px;
  overflow: hidden; flex: 1; margin: 0 20px;
}
.timer-progress-bar {
  height: 100%; background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 3px; transition: width 1s linear;
}

/* ---------- Question ---------- */
.question-card {
  background: #fff; border-radius: 16px; padding: 28px;
  margin-bottom: 20px; box-shadow: 0 3px 14px rgba(0,0,0,.06);
  border-left: 5px solid #667eea;
}
.question-card.active { border-left-color: #ff9800; }
.question-number { font-family: 'Fredoka One', cursive; color: #667eea; font-size: 1.1rem; }
.question-text { font-size: 1.08rem; margin: 12px 0 18px; line-height: 1.6; }
.question-marks { font-size: .82rem; color: #999; }

.option-group { display: flex; flex-direction: column; gap: 10px; }
.option-label {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border: 2px solid #e0e0e0;
  border-radius: 12px; cursor: pointer; transition: .2s;
}
.option-label:hover { border-color: #667eea; background: rgba(102,126,234,.04); }
.option-label input[type="radio"] { accent-color: #667eea; width: 18px; height: 18px; }
.option-label.selected { border-color: #667eea; background: rgba(102,126,234,.08); }

/* ---------- Exam Cards ---------- */
.exam-card {
  background: #fff; border-radius: 16px; padding: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06); border: 2px solid #e8e8e8;
  transition: .25s; display: flex; flex-direction: column;
}
.exam-card:hover { border-color: #667eea; transform: translateY(-3px); }
.exam-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.exam-card-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.3rem;
}
.exam-card-meta { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; font-size: .88rem; color: #666; }
.exam-card-meta span { display: flex; align-items: center; gap: 5px; }
.exam-card-footer { margin-top: auto; padding-top: 14px; border-top: 2px solid #f0f0f0; }

/* ---------- Section Builder ---------- */
.section-builder {
  border: 2px dashed #d0d0d0; border-radius: 16px;
  padding: 24px; margin-bottom: 24px; background: #fafbff;
}
.section-builder-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #e8e8e8;
}
.question-item {
  background: #fff; border: 1px solid #e0e0e0; border-radius: 12px;
  padding: 16px; margin-bottom: 12px;
}

/* ---------- File Upload ---------- */
.file-drop {
  border: 3px dashed #b0bec5; border-radius: 16px;
  padding: 40px; text-align: center; cursor: pointer;
  transition: .25s; background: #fafafa;
}
.file-drop:hover, .file-drop.dragover { border-color: #667eea; background: rgba(102,126,234,.04); }
.file-drop i { font-size: 3rem; color: #b0bec5; margin-bottom: 12px; }
.file-drop p { color: #999; }

/* ---------- Signature ---------- */
.signature-preview {
  width: 220px; height: 110px; border: 2px dashed #d0d0d0;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #fafafa;
}
.signature-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Report ---------- */
.report-card {
  max-width: 800px; margin: 0 auto; background: #fff;
  border: 2px solid #667eea; border-radius: 6px; padding: 0;
}
.report-header {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; padding: 24px; text-align: center;
}
.report-body { padding: 28px; }
.report-table { width: 100%; border-collapse: collapse; margin: 16px 0; min-width: 0; table-layout: auto; }
.report-table th, .report-table td { border: 1px solid #ccc; padding: 10px 12px; }
.report-table th { background: #f0f4ff; color: #4a47a3; white-space: nowrap; }
.report-footer { padding: 24px; border-top: 2px solid #e0e0e0; }
.report-signatures { display: flex; justify-content: space-around; margin-top: 30px; flex-wrap: wrap; gap: 16px; }
.report-sig-block { text-align: center; }
.report-sig-block img { max-width: 160px; max-height: 70px; margin-bottom: 4px; }
.report-sig-line { width: 180px; border-top: 1px solid #333; padding-top: 4px; font-size: .85rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  padding: 14px 24px; border-radius: 12px;
  color: #fff; font-weight: 700; font-family: 'Comic Neue', cursive;
  z-index: 9999; transform: translateX(120%); transition: .3s;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast-show { transform: translateX(0); }
.toast-info    { background: #667eea; }
.toast-success { background: #4caf50; }
.toast-error   { background: #f44336; }
.toast-warning { background: #ff9800; color: #333; }

/* ---------- Loading ---------- */
.loader {
  display: inline-block; width: 40px; height: 40px;
  border: 4px solid #e0e0e0; border-top-color: #667eea;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; flex-direction: column; gap: 16px; color: #999;
}

/* ---------- Landing page ---------- */
.hero {
  text-align: center; padding: 60px 24px;
  background: rgba(255,255,255,.98); border-radius: 22px;
  margin-bottom: 30px; box-shadow: 0 20px 60px rgba(0,0,0,.12);
}
.hero h1 { font-size: 2.6rem; margin-bottom: 12px; }
.hero p { font-size: 1.2rem; color: #666; max-width: 600px; margin: 0 auto 28px; }
.hero-emoji { font-size: 4rem; margin-bottom: 16px; display: block; }

.features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px; margin: 30px 0;
}
.feature-card {
  background: #fff; border-radius: 16px; padding: 28px;
  text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,.06);
  transition: .25s;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: 0 8px 30px rgba(0,0,0,.1); }
.feature-card i { font-size: 2.4rem; color: #667eea; margin-bottom: 12px; }
.feature-card h3 { margin-bottom: 8px; }
.feature-card p { color: #666; font-size: .92rem; }

/* ---------- Utility ---------- */
.mt-1 { margin-top: 8px; }  .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.p-2 { padding: 16px; } .p-3 { padding: 24px; }
.d-flex { display: flex; } .flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }
.hidden { display: none !important; }
.w-100 { width: 100%; }
.badge {
  display: inline-block; padding: 4px 12px;
  border-radius: 20px; font-size: .8rem; font-weight: 700;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff8e1; color: #f57f17; }
.badge-danger  { background: #ffebee; color: #c62828; }
.badge-info    { background: #e3f2fd; color: #1565c0; }

.divider { height: 2px; background: #e8e8e8; margin: 24px 0; border: none; }

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .portal-nav, .timer-bar, .btn, .no-print { display: none !important; }
  .container { box-shadow: none; border-radius: 0; padding: 16px; }
  .page-wrap { padding: 0; }
  .report-card { border: 1px solid #000; }
}

/* ---------- Notification Cards ---------- */
.notification-card { transition: .25s; }
.notification-unread { background: #f0f4ff; border-left-width: 5px !important; }
.notification-unread::after {
  content: ''; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #f44336; position: absolute;
  top: 12px; right: 12px;
}
.notification-card { position: relative; }

/* ---------- Module Cards ---------- */
.module-card {
  background: #fff; border-radius: 16px;
  box-shadow: 0 4px 18px rgba(0,0,0,.06);
  border: 2px solid #e8e8e8; overflow: hidden;
  transition: .25s;
}
.module-card:hover { border-color: #667eea; }
.module-header {
  background: linear-gradient(135deg, #f8f9ff, #eef1ff);
  padding: 20px 24px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  border-bottom: 2px solid #e8e8e8;
}
.module-week-badge {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; font-family: 'Fredoka One', cursive;
  padding: 8px 18px; border-radius: 25px; font-size: .92rem;
  white-space: nowrap;
}
.module-summary {
  padding: 16px 24px; background: #fffbf0;
  border-bottom: 1px solid #f0e8d0;
}
.module-summary h4 { color: #ff9800; margin-bottom: 6px; font-size: .95rem; }
.module-summary p { color: #666; font-size: .92rem; line-height: 1.6; white-space: pre-line; }

/* ---------- Materials List ---------- */
.materials-list { padding: 8px 0; }
.material-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid #f0f0f0;
  transition: .2s; flex-wrap: wrap; gap: 8px;
}
.material-item:last-child { border-bottom: none; }
.material-item:hover { background: rgba(102,126,234,.03); }

/* ---------- Discussion Forum ---------- */
.topic-card { transition: .2s; }
.topic-card:hover { border-color: #667eea; transform: translateY(-2px); }
.topic-reply-count {
  background: #e3f2fd; color: #1565c0;
  padding: 6px 14px; border-radius: 20px;
  font-size: .85rem; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}

.forum-post {
  background: #fff; border-radius: 14px; padding: 20px;
  margin-bottom: 12px; border: 2px solid #e8e8e8;
  transition: .2s;
}
.forum-post:hover { border-color: #c8d0ff; }
.forum-post-answer { border-color: #4caf50; background: #f9fff9; }
.forum-post-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.forum-post-body {
  color: #444; font-size: .95rem; line-height: 1.7;
}

.forum-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.1rem;
  flex-shrink: 0;
}

.forum-points-badge {
  font-size: 2.2rem; font-weight: 700; color: #ff9800;
  font-family: 'Fredoka One', cursive;
}

/* ---------- Responsive ---------- */

/* Medium screens / tablets */
@media (max-width: 768px) {
  .container { padding: 20px; border-radius: 16px; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
  .hero h1 { font-size: 1.8rem; }
  .hero { padding: 36px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .btn-group { flex-direction: column; }
  .btn-lg { padding: 14px 28px; font-size: 1.05rem; }

  /* Tabs - horizontal scroll on small screens */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 0; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; padding: 10px 16px; font-size: .9rem; flex-shrink: 0; }

  /* Grids stack more on mobile */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

  /* Page wrappers */
  .page-wrap { padding: 16px; }

  /* Timer bar on mobile */
  .timer-bar { flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
  .timer-display { font-size: 1.3rem; }
  .timer-progress { margin: 0 12px; min-width: 0; }

  /* Report card */
  .report-card { border-radius: 4px; }
  .report-body { padding: 20px; }
  .report-header { padding: 18px; }
  .report-header h1 { font-size: 1.3rem; }
  .report-table th, .report-table td { padding: 8px 6px; font-size: .85rem; }
  .report-signatures { flex-direction: column; gap: 24px; align-items: center; }
  .report-sig-line { width: 160px; }
  .report-footer { padding: 18px; }

  /* Section builder for exam creation */
  .section-builder { padding: 16px; }
  .section-builder-header { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* File upload */
  .file-drop { padding: 24px; }
  .file-drop i { font-size: 2.2rem; }

  /* Question cards */
  .question-card { padding: 20px; }

  /* Modal */
  .modal { padding: 24px; margin: 10px; border-radius: 16px; }

  /* Exam cards */
  .exam-card { padding: 18px; }
  .exam-card-header { gap: 10px; }
  .exam-card-icon { width: 42px; height: 42px; font-size: 1.1rem; }

  /* Module cards */
  .module-header { padding: 16px; }
  .module-summary { padding: 12px 16px; }
  .material-item { padding: 12px 16px; }

  /* Forum */
  .forum-post { padding: 16px; }
  .forum-post-header { flex-direction: column; align-items: flex-start; }

  /* Feature cards on landing */
  .features-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
  .feature-card { padding: 20px; }
  .feature-card i { font-size: 2rem; }
}

/* Small screens / phones */
@media (max-width: 480px) {
  .container { padding: 14px; border-radius: 14px; }
  .page-wrap { padding: 10px; }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }
  .subtitle { font-size: .92rem; }

  /* Stats use full-width single column under 480 */
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .stat-number { font-size: 1.6rem; }

  /* Buttons */
  .btn { padding: 10px 18px; font-size: .92rem; }
  .btn-sm { padding: 7px 12px; font-size: .82rem; }
  .btn-lg { padding: 12px 22px; font-size: 1rem; }
  .btn-group { gap: 8px; }

  /* Forms */
  .form-control { padding: 10px 12px; font-size: .95rem; }
  .form-group label { font-size: .9rem; }

  /* Tabs */
  .tab-btn { padding: 8px 12px; font-size: .85rem; }

  /* Cards */
  .card { padding: 16px; border-radius: 14px; }

  /* Tables — allow smaller min-width */
  table { min-width: 600px; }
  thead th { padding: 10px 8px; font-size: .82rem; }
  tbody td { padding: 8px 6px; font-size: .82rem; }

  /* Report */
  .report-body { padding: 14px; }
  .report-header { padding: 14px; }

  /* Grids always single col on very small */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Features */
  .features-grid { grid-template-columns: 1fr; }

  /* Notification badge positioning */
  .notification-unread::after { top: 8px; right: 8px; }

  /* Hero */
  .hero { padding: 24px 12px; border-radius: 16px; }
  .hero h1 { font-size: 1.5rem; }
  .hero p { font-size: 1rem; }
  .hero-emoji { font-size: 3rem; }

  /* Timer bar */
  .timer-bar { top: 56px; font-size: .85rem; }
  .timer-display { font-size: 1.1rem; }

  /* Empty state */
  .empty-state { padding: 30px 14px; }
  .empty-state i { font-size: 2.6rem; }

  /* Forum */
  .forum-avatar { width: 32px; height: 32px; font-size: .9rem; }
  .forum-points-badge { font-size: 1.6rem; }
  .topic-reply-count { padding: 4px 10px; font-size: .8rem; }

  /* Module cards */
  .module-week-badge { padding: 6px 14px; font-size: .82rem; }
  .module-header { padding: 14px; }
  .module-summary { padding: 10px 14px; }

  /* Exam builder sections */
  .section-builder { padding: 12px; }
  .question-item { padding: 12px; }

  /* Alert */
  .alert { padding: 12px 14px; font-size: .9rem; }

  /* Toast */
  .toast { left: 10px; right: 10px; bottom: 10px; text-align: center; }

  /* Signature preview on teacher profile */
  .signature-preview { width: 180px; height: 90px; }
}

/* Extra small screens */
@media (max-width: 360px) {
  .container { padding: 10px; border-radius: 12px; }
  .page-wrap { padding: 6px; }
  h1 { font-size: 1.2rem; }
  .btn { padding: 8px 14px; font-size: .85rem; }
  .stats-grid { gap: 8px; }
  .stat-number { font-size: 1.4rem; }
  .tab-btn { padding: 6px 10px; font-size: .8rem; }
  .nav-brand { font-size: 1.2rem; }

  /* Tables even tighter */
  table { min-width: 500px; }
  thead th { padding: 8px 4px; font-size: .78rem; }
  tbody td { padding: 6px 4px; font-size: .78rem; }
}
