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

:root {
  --navy:       #0d2a5e;
  --navy-dark:  #091d42;
  --navy-light: #1a3c7e;
  --blue:       #1565c0;
  --blue-light: #1976d2;
  --gold:       #f9a825;
  --gold-light: #fdd835;
  --green:      #27ae60;
  --red:        #e74c3c;
  --orange:     #f39c12;
  --white:      #ffffff;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-300:   #cbd5e1;
  --gray-500:   #64748b;
  --gray-700:   #334155;
  --gray-900:   #0f172a;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow:     0 4px 16px rgba(0,0,0,.12);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.16);
  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  20px;
  --transition: .2s ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Cairo', 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--gray-900);
  background: var(--gray-50);
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ============================================================
   Utilities
   ============================================================ */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.page-container { padding-top: 40px; padding-bottom: 60px; }
.text-center { text-align: center; }
.text-bold { font-weight: 700; }
.text-muted { color: var(--gray-500); }
.text-mono { font-family: 'Courier New', monospace; font-size: 13px; }

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, var(--blue) 100%);
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  position: sticky; top: 0; z-index: 100;
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 70px;
}
.navbar-brand { display: flex; align-items: center; gap: 12px; }
.navbar-logo { width: 44px; height: 44px; object-fit: contain; }
.navbar-title { display: flex; flex-direction: column; }
.brand-main { color: var(--white); font-size: 17px; font-weight: 700; line-height: 1.2; }
.brand-sub { color: rgba(255,255,255,.65); font-size: 11px; font-weight: 400; }

.navbar-links { display: flex; gap: 4px; }
.nav-link {
  color: rgba(255,255,255,.85);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  transition: var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.15);
  color: var(--white);
}
.nav-admin {
  background: rgba(249,168,37,.15);
  border: 1px solid rgba(249,168,37,.3);
  color: var(--gold-light);
}
.nav-admin:hover { background: rgba(249,168,37,.28); color: var(--gold-light); }

.nav-toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 8px;
}
.nav-toggle span {
  display: block; width: 24px; height: 2px;
  background: var(--white); border-radius: 2px; transition: var(--transition);
}
.nav-mobile {
  display: none; flex-direction: column;
  background: var(--navy-dark); padding: 12px 20px; gap: 2px;
}
.nav-mobile a {
  color: rgba(255,255,255,.85); padding: 10px 12px;
  border-radius: var(--radius-sm); display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; transition: var(--transition);
}
.nav-mobile a:hover { background: rgba(255,255,255,.1); color: var(--white); }
.nav-mobile.open { display: flex; }

/* ============================================================
   Flash Messages
   ============================================================ */
.flash-container { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 200; width: min(560px, 92vw); }
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); margin-bottom: 8px;
  animation: slideDown .3s ease;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-close { margin-right: auto; background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; color: inherit; opacity: .7; }
.alert-close:hover { opacity: 1; }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative; min-height: 480px;
  display: flex; align-items: center;
  background: linear-gradient(145deg, var(--navy-dark) 0%, var(--navy) 50%, var(--blue) 100%);
  overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-overlay { position: absolute; inset: 0; background: rgba(9,29,66,.35); }
.hero-content { position: relative; text-align: center; padding: 60px 20px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(249,168,37,.2); border: 1px solid rgba(249,168,37,.4);
  color: var(--gold-light); padding: 6px 16px; border-radius: 50px;
  font-size: 13px; font-weight: 600; margin-bottom: 20px;
}
.hero-title { color: var(--white); font-size: clamp(22px, 5vw, 38px); font-weight: 900; margin-bottom: 12px; }
.hero-subtitle { color: rgba(255,255,255,.75); font-size: 16px; margin-bottom: 36px; }

.search-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 36px 40px; max-width: 640px; margin: 0 auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.search-label { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 12px; }
.search-input-wrap { display: flex; gap: 10px; }
.search-input {
  flex: 1; padding: 14px 18px; border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 17px; font-family: inherit;
  direction: ltr; text-align: center; letter-spacing: 2px;
  transition: var(--transition); outline: none;
}
.search-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,101,192,.15); }
.search-btn {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--navy) 100%);
  color: var(--white); border: none; border-radius: var(--radius-sm);
  padding: 14px 28px; font-size: 16px; font-weight: 700; font-family: inherit;
  cursor: pointer; white-space: nowrap; transition: var(--transition);
}
.search-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.search-btn:active { transform: translateY(0); }
.search-hint { margin-top: 12px; font-size: 13px; color: var(--gray-500); }
.search-hint strong { color: var(--navy); }

/* ============================================================
   Stats
   ============================================================ */
.stats-section { padding: 48px 0; background: var(--white); border-bottom: 1px solid var(--gray-200); }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.stat-card {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 24px 20px;
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 20px; flex-shrink: 0;
}
.stat-icon.success { background: linear-gradient(135deg, #1b8042, var(--green)); }
.stat-icon.danger  { background: linear-gradient(135deg, #b71c1c, var(--red)); }
.stat-icon.warning { background: linear-gradient(135deg, #b57c00, var(--orange)); }
.stat-number { font-size: 28px; font-weight: 900; color: var(--navy); line-height: 1; }
.stat-label  { font-size: 13px; color: var(--gray-500); margin-top: 4px; font-weight: 600; }

/* ============================================================
   How To
   ============================================================ */
.howto-section { padding: 60px 0; }
.section-title { text-align: center; font-size: 26px; font-weight: 900; color: var(--navy); margin-bottom: 36px; }
.section-title::after { content: ''; display: block; width: 60px; height: 4px; background: var(--gold); border-radius: 2px; margin: 12px auto 0; }
.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.step-card {
  text-align: center; padding: 32px 24px; background: var(--white);
  border-radius: var(--radius); border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm); transition: var(--transition);
}
.step-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.step-num {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue-light) 100%);
  color: var(--white); font-size: 22px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.step-card h3 { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.step-card p { font-size: 14px; color: var(--gray-500); line-height: 1.7; }

/* ============================================================
   Back Button
   ============================================================ */
.back-btn {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--navy); font-weight: 600; font-size: 14px;
  padding: 8px 16px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); background: var(--white);
  margin-bottom: 24px; transition: var(--transition);
}
.back-btn:hover { background: var(--gray-100); box-shadow: var(--shadow-sm); }

/* ============================================================
   Result Page
   ============================================================ */
.result-header-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 32px 36px; border-radius: var(--radius-lg);
  margin-bottom: 24px; color: var(--white); gap: 20px;
}
.result-pass   { background: linear-gradient(135deg, #1a5e35, var(--green)); }
.result-fail   { background: linear-gradient(135deg, #9a1c1c, var(--red)); }
.result-second { background: linear-gradient(135deg, #8a5a00, var(--orange)); }

.result-status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.2); padding: 6px 16px;
  border-radius: 50px; font-size: 14px; font-weight: 700;
  margin-bottom: 12px;
}
.result-name { font-size: clamp(18px,4vw,28px); font-weight: 900; margin-bottom: 8px; }
.result-seat { font-size: 14px; opacity: .85; }
.result-score-circle {
  text-align: center; background: rgba(255,255,255,.15);
  border-radius: var(--radius); padding: 20px 28px; flex-shrink: 0;
}
.score-big { font-size: 36px; font-weight: 900; line-height: 1; }
.score-label { font-size: 12px; opacity: .8; margin-top: 4px; }

.info-card, .grades-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.card-title::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }
.info-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.info-item { display: flex; gap: 12px; align-items: flex-start; }
.info-icon { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,var(--navy),var(--blue-light)); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.info-label { font-size: 12px; color: var(--gray-500); font-weight: 600; }
.info-value { font-size: 15px; color: var(--navy); font-weight: 700; margin-top: 2px; }

/* ============================================================
   Grades Table
   ============================================================ */
.table-wrap { overflow-x: auto; }
.grades-table { width: 100%; border-collapse: collapse; }
.grades-table thead th {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: var(--white); padding: 14px 16px; font-size: 14px; font-weight: 700;
  white-space: nowrap;
}
.grades-table thead th:first-child { border-radius: 0 0 0 var(--radius-sm); }
.grades-table thead th:last-child  { border-radius: 0 0 var(--radius-sm) 0; }
.grades-table tbody tr { border-bottom: 1px solid var(--gray-100); }
.grades-table tbody tr:hover { background: var(--gray-50); }
.grades-table td { padding: 14px 16px; font-size: 14px; }
.subject-name { font-weight: 600; color: var(--navy); }
.grade-bar-wrap { display: flex; align-items: center; gap: 10px; }
.grade-bar { height: 8px; background: linear-gradient(90deg, var(--blue), var(--navy)); border-radius: 4px; transition: width .6s ease; min-width: 4px; }
.grade-val { font-size: 15px; font-weight: 700; color: var(--navy); min-width: 28px; }

.total-row td { background: var(--gray-100); font-weight: 700; padding: 16px; border-top: 2px solid var(--gray-200); }
.percentage-row td { background: var(--navy); color: var(--white); font-weight: 700; padding: 14px; }
.percentage-val { font-size: 20px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 50px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-pass   { background: #d4edda; color: #155724; }
.badge-fail   { background: #f8d7da; color: #721c24; }
.badge-second { background: #fff3cd; color: #856404; }

.result-actions { display: flex; gap: 12px; margin-top: 8px; }

/* ============================================================
   Top Students
   ============================================================ */
.page-header { text-align: center; margin-bottom: 40px; }
.page-title { font-size: clamp(22px,4vw,32px); font-weight: 900; color: var(--navy); display: flex; align-items: center; gap: 10px; justify-content: center; }
.page-subtitle { color: var(--gray-500); font-size: 15px; margin-top: 8px; }

.top-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.top-card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--gray-200); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: var(--transition); position: relative;
}
.top-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); }
.rank-gold   { border-top: 4px solid #f9a825; }
.rank-silver { border-top: 4px solid #b0bec5; }
.rank-bronze { border-top: 4px solid #a0522d; }
.rank-normal { border-top: 4px solid var(--blue-light); }

.rank-badge {
  position: absolute; top: 16px; left: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900;
}
.rank-gold   .rank-badge { background: #fff8e1; color: #f57f17; }
.rank-silver .rank-badge { background: #eceff1; color: #546e7a; }
.rank-bronze .rank-badge { background: #efebe9; color: #6d4c41; }
.rank-normal .rank-badge { background: var(--gray-100); color: var(--navy); font-size: 14px; }

.top-card-body { padding: 24px 20px 20px; }
.top-name { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 8px; padding-top: 28px; }
.top-meta { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.top-meta span { font-size: 12px; color: var(--gray-500); display: flex; align-items: center; gap: 6px; }
.top-scores { display: flex; align-items: center; gap: 16px; background: var(--gray-50); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 16px; }
.top-score-item { text-align: center; flex: 1; }
.top-score-val { font-size: 22px; font-weight: 900; color: var(--navy); }
.top-score-lbl { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.top-score-sep { width: 1px; height: 40px; background: var(--gray-200); }
.top-detail-btn {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: linear-gradient(135deg, var(--navy), var(--blue-light));
  color: var(--white); padding: 10px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; transition: var(--transition);
}
.top-detail-btn:hover { opacity: .9; }

/* ============================================================
   Admin Login
   ============================================================ */
.admin-login-page {
  min-height: calc(100vh - 140px);
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.login-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 48px 44px; width: min(480px, 100%);
  box-shadow: var(--shadow-lg); border: 1px solid var(--gray-200);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-dark), var(--blue-light));
  color: var(--white); font-size: 28px;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.login-header h1 { font-size: 22px; font-weight: 900; color: var(--navy); margin-bottom: 6px; }
.login-header p  { font-size: 14px; color: var(--gray-500); }
.login-hint { margin-top: 20px; font-size: 13px; color: var(--gray-500); text-align: center; background: var(--gray-50); border-radius: var(--radius-sm); padding: 12px; }
.login-hint strong { color: var(--navy); }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 20px; }
.form-group label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--gray-700); margin-bottom: 8px; }
.form-control {
  width: 100%; padding: 12px 16px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 15px; font-family: inherit;
  color: var(--gray-900); background: var(--white); outline: none;
  transition: var(--transition);
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
.form-control[readonly] { background: var(--gray-100); color: var(--gray-500); cursor: not-allowed; }
.password-wrap { position: relative; }
.toggle-pwd {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--gray-500); font-size: 14px;
}
.btn-full { width: 100%; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; font-family: inherit;
  border: none; cursor: pointer; transition: var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-primary  { background: linear-gradient(135deg, var(--navy), var(--blue-light)); color: var(--white); }
.btn-success  { background: linear-gradient(135deg, #1b8042, var(--green)); color: var(--white); }
.btn-info     { background: linear-gradient(135deg, #01579b, #039be5); color: var(--white); }
.btn-danger   { background: linear-gradient(135deg, #9a1c1c, var(--red)); color: var(--white); }
.btn-outline-danger { background: none; border: 1.5px solid var(--red); color: var(--red); }
.btn-outline-danger:hover { background: var(--red); color: var(--white); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-print { background: var(--navy); color: var(--white); }

/* ============================================================
   Admin Dashboard
   ============================================================ */
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.admin-stats { margin-bottom: 24px; }
.admin-actions { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.admin-search-wrap { margin-bottom: 16px; }

.table-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table thead th {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: var(--white); padding: 14px 16px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.admin-table tbody tr { border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.admin-table tbody tr:hover { background: var(--gray-50); }
.admin-table td { padding: 13px 16px; }
.actions-cell { display: flex; gap: 6px; }
.action-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; font-size: 13px; transition: var(--transition);
}
.action-btn.edit   { background: #e3f2fd; color: var(--blue); }
.action-btn.edit:hover   { background: var(--blue); color: var(--white); }
.action-btn.delete { background: #ffeef0; color: var(--red); }
.action-btn.delete:hover { background: var(--red); color: var(--white); }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 36px 32px; max-width: 400px; width: 100%; text-align: center;
  box-shadow: var(--shadow-lg);
}
.modal-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 24px; }
.modal-icon.danger { background: #ffeef0; color: var(--red); }
.modal-box h3 { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 10px; }
.modal-box p  { font-size: 14px; color: var(--gray-500); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ============================================================
   Student Form
   ============================================================ */
.form-page-header { margin-bottom: 28px; }
.form-card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--gray-200); padding: 32px 36px;
  box-shadow: var(--shadow-sm);
}
.form-section { margin-bottom: 28px; }
.form-section-title { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 20px; display: flex; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--gray-200); }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 16px; }
.grades-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 14px; }
.grade-form-item label { font-size: 13px; }
.grade-input { text-align: center; font-size: 17px; font-weight: 700; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }

.total-preview {
  display: flex; gap: 24px; background: var(--gray-50);
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 14px 20px; margin-top: 16px; flex-wrap: wrap;
}
.total-preview-item { font-size: 14px; color: var(--gray-700); }
.total-preview-item strong { font-size: 16px; color: var(--navy); }

/* ============================================================
   Import Page
   ============================================================ */
.import-info {
  background: #e8f4fd; border: 1px solid #bee3f8; border-radius: var(--radius);
  padding: 24px; margin-bottom: 28px;
}
.import-info h3 { color: var(--navy); font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.import-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--white); border-radius: var(--radius-sm); overflow: hidden; }
.import-table th { background: var(--navy); color: var(--white); padding: 10px 14px; text-align: right; }
.import-table td { padding: 9px 14px; border-bottom: 1px solid var(--gray-100); }
.import-notes { margin-top: 14px; }
.import-notes ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.import-notes li { font-size: 13px; color: var(--gray-700); display: flex; align-items: center; gap: 6px; }
.text-success { color: var(--green); }

.file-upload-area {
  border: 2px dashed var(--gray-300); border-radius: var(--radius);
  padding: 48px 32px; text-align: center; cursor: pointer;
  transition: var(--transition); position: relative;
}
.file-upload-area:hover, .file-upload-area.drag-over {
  border-color: var(--blue); background: #e8f4fd;
}
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-upload-icon { font-size: 48px; color: var(--blue-light); margin-bottom: 12px; }
.file-upload-text { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.file-upload-hint { font-size: 13px; color: var(--gray-500); }

.file-preview {
  display: flex; align-items: center; gap: 12px;
  background: #f0faf4; border: 1px solid #c3e6cb; border-radius: var(--radius-sm);
  padding: 14px 18px; margin-bottom: 16px;
}
.file-preview i { font-size: 24px; color: var(--green); }
.file-preview span { flex: 1; font-size: 14px; font-weight: 600; color: var(--navy); }
.clear-file { background: none; border: none; cursor: pointer; color: var(--gray-500); font-size: 16px; }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state { text-align: center; padding: 80px 20px; color: var(--gray-500); }
.empty-state i { font-size: 56px; margin-bottom: 16px; color: var(--gray-300); display: block; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: rgba(255,255,255,.8); margin-top: auto; padding-top: 48px;
}
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; margin-bottom: 32px; }
.footer-col h4 { color: var(--white); font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.footer-col p  { font-size: 13px; line-height: 1.8; margin-bottom: 6px; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.footer-col ul li a { font-size: 13px; color: rgba(255,255,255,.7); transition: var(--transition); }
.footer-col ul li a:hover { color: var(--white); }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding: 16px 0; text-align: center; font-size: 13px; color: rgba(255,255,255,.5);
}

/* ============================================================
   Print
   ============================================================ */
@media print {
  .navbar, .footer, .result-actions, .back-btn, .flash-container { display: none !important; }
  .result-header-card, .info-card, .grades-card { box-shadow: none; }
  body { background: white; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .steps-grid  { grid-template-columns: 1fr; }
  .info-grid   { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .navbar-links { display: none; }
  .nav-toggle { display: flex; }
  .search-card { padding: 24px 20px; }
  .search-input-wrap { flex-direction: column; }
  .search-btn { justify-content: center; }
  .hero { min-height: 360px; }
  .stats-grid { grid-template-columns: repeat(2,1fr); gap: 12px; }
  .stat-card { padding: 16px 14px; }
  .stat-number { font-size: 22px; }
  .result-header-card { flex-direction: column; text-align: center; padding: 24px; }
  .info-grid { grid-template-columns: 1fr; }
  .grades-table thead { font-size: 12px; }
  .grades-table td { padding: 10px 10px; font-size: 13px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .login-card { padding: 32px 24px; }
  .form-card { padding: 24px 20px; }
  .result-actions { flex-wrap: wrap; }
  .admin-actions { flex-wrap: wrap; }
  .total-preview { flex-direction: column; gap: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Site Gate (Login Page for Students)
   ============================================================ */
.site-gate-body {
  background: linear-gradient(145deg, var(--navy-dark) 0%, var(--navy) 55%, var(--blue) 100%);
  min-height: 100vh; display: flex; flex-direction: column;
  font-family: 'Cairo', sans-serif;
}
.gate-header {
  background: rgba(0,0,0,.25);
  border-bottom: 1px solid rgba(255,255,255,.1);
  padding: 14px 0;
}
.gate-header-inner {
  display: flex; align-items: center; justify-content: space-between;
}
.gate-brand {
  color: rgba(255,255,255,.85); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.gate-brand i { color: var(--gold-light); }
.gate-year {
  background: rgba(249,168,37,.2); border: 1px solid rgba(249,168,37,.35);
  color: var(--gold-light); padding: 4px 14px; border-radius: 50px;
  font-size: 13px; font-weight: 700;
}
.gate-main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.gate-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 48px 44px; width: min(480px, 100%);
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
  position: relative;
}
.gate-icon-wrap {
  position: relative; width: 88px; margin: 0 auto 24px;
}
.gate-icon {
  width: 88px; height: 88px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-dark), var(--blue-light));
  color: var(--white); font-size: 34px;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
  box-shadow: 0 8px 24px rgba(13,42,94,.35);
}
.gate-icon-ring {
  position: absolute; inset: -6px;
  border: 2px solid rgba(21,101,192,.2); border-radius: 50%;
  animation: ringPulse 2.5s ease-in-out infinite;
}
@keyframes ringPulse {
  0%,100% { transform: scale(1); opacity: .5; }
  50%      { transform: scale(1.08); opacity: 1; }
}
.gate-title {
  text-align: center; font-size: 22px; font-weight: 900; color: var(--navy);
  margin-bottom: 8px;
}
.gate-subtitle {
  text-align: center; font-size: 14px; color: var(--gray-500);
  margin-bottom: 28px; line-height: 1.7;
}
.gate-subtitle strong { color: var(--navy); }
.gate-error {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius-sm);
  padding: 12px 16px; color: #991b1b; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; margin-bottom: 20px;
}
.gate-form { display: flex; flex-direction: column; gap: 18px; }
.gate-field label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 700; color: var(--gray-700); margin-bottom: 8px;
}
.gate-input {
  width: 100%; padding: 13px 16px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 15px; font-family: inherit;
  color: var(--gray-900); outline: none; transition: var(--transition);
}
.gate-input:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,101,192,.12);
}
.gate-pwd-wrap { position: relative; }
.gate-pwd-toggle {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--gray-500);
  font-size: 15px; padding: 4px;
}
.gate-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue-light) 100%);
  color: var(--white); border: none; border-radius: var(--radius-sm);
  padding: 14px; font-size: 16px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: var(--transition); margin-top: 4px;
}
.gate-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(13,42,94,.3); }
.gate-note {
  margin-top: 24px; background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 12px; color: var(--gray-500); display: flex; gap: 8px; line-height: 1.6;
}
.gate-footer {
  text-align: center; padding: 20px;
  font-size: 12px; color: rgba(255,255,255,.4);
}

/* ============================================================
   Pending / Not-Corrected State
   ============================================================ */
.badge-pending { background: #f0f0f0; color: #555; }
.result-pending { background: linear-gradient(135deg, #4a5568, #718096); }
.stat-icon.pending { background: linear-gradient(135deg, #4a5568, #718096); }

.grade-pending-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f7f7f7; border: 1px solid var(--gray-300);
  color: var(--gray-500); padding: 4px 12px; border-radius: 50px;
  font-size: 12px; font-weight: 600;
}

/* Grade form pending state */
.grade-input-row { display: flex; gap: 8px; align-items: center; }
.grade-input-row .grade-input { flex: 1; }
.pending-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--radius-sm); border: 1.5px solid var(--gray-300);
  background: var(--white); color: var(--gray-500);
  cursor: pointer; font-size: 13px; display: flex;
  align-items: center; justify-content: center;
  transition: var(--transition);
}
.pending-btn:hover  { border-color: var(--orange); color: var(--orange); }
.pending-btn.active { background: #fff3cd; border-color: var(--orange); color: var(--orange); }

.grade-form-item.is-pending .grade-input {
  background: #fffbf0; border-color: #fde68a; color: var(--gray-500);
}
.pending-label {
  font-size: 11px; color: var(--orange); font-weight: 700;
  margin-top: 4px; display: flex; align-items: center; gap: 4px;
}
.pending-legend {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 400; color: var(--gray-500);
  margin-right: auto;
}
.pending-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--orange); flex-shrink: 0;
}

/* Seat edit note */
.seat-edit-note {
  margin-top: 6px; background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 12px; color: #92400e; display: flex; align-items: center; gap: 6px;
}

/* ============================================================
   Admin Settings Page
   ============================================================ */
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 24px; margin-top: 8px;
}
.settings-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.settings-card-header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px;
}
.settings-card-header.site-header  { background: linear-gradient(135deg,#e8f4fd,#dbeafe); }
.settings-card-header.admin-header { background: linear-gradient(135deg,#fef3c7,#fde68a); }
.settings-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
  background: var(--navy); color: var(--white);
}
.settings-card-header h2 { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.settings-card-header p  { font-size: 13px; color: var(--gray-500); }
.settings-current {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 24px; background: var(--gray-50);
  border-top: 1px solid var(--gray-200); border-bottom: 1px solid var(--gray-200);
  font-size: 13px; color: var(--gray-700);
}
.settings-current strong { color: var(--navy); }
.settings-warning {
  margin: 12px 24px 0; background: #fff3cd; border: 1px solid #fde68a;
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 12px; color: #92400e; display: flex; align-items: center; gap: 8px;
}
.settings-form { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 4px; }

/* Table footer */
.table-footer {
  padding: 12px 16px; background: var(--gray-50);
  border-top: 1px solid var(--gray-200); font-size: 13px;
  color: var(--gray-500); text-align: left;
}
.table-footer strong { color: var(--navy); }

@media (max-width: 860px) {
  .settings-grid { grid-template-columns: 1fr; }
}

