/* ── DAR E ARQAM School MS v6 — Design System ── */
:root {
  --primary:       #1d4ed8;   /* blue-700 (portal primary) */
  --primary-dark:  #1e40af;   /* blue-800 */
  --primary-light: #dbeafe;   /* blue tint */
  --secondary:     #0d9488;   /* teal (gradient end) */
  --secondary-dark:#0f766e;
  --gradient:      linear-gradient(135deg,#1e40af 0%,#0d9488 100%);
  --gradient-deep: linear-gradient(160deg,#1e3a8a 0%,#1e40af 45%,#0d9488 100%);
  --success:       #059669;
  --danger:        #dc2626;
  --warning:       #d97706;
  --info:          #2563eb;
  --dark:          #0f172a;
  --gray-900:      #0f172a;   /* cool slate neutrals */
  --gray-800:      #1e293b;
  --gray-700:      #334155;
  --gray-600:      #475569;
  --gray-500:      #64748b;
  --gray-400:      #94a3b8;
  --gray-300:      #cbd5e1;
  --gray-200:      #e2e8f0;
  --gray-100:      #f1f5f9;
  --gray-50:       #f8fafc;
  --white:         #ffffff;
  --teal-sidebar:  #1e3a8a;   /* gradient start (var name kept) */
  --sidebar-w:     260px;
  --header-h:      60px;
  --radius:        10px;
  --radius-lg:     14px;
  --shadow-sm:     0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow:        0 4px 14px rgba(15,23,42,.08);
  --shadow-lg:     0 12px 34px rgba(15,23,42,.16);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition:    .2s ease;
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { font-size:15px; }
body { font-family:var(--font); background:var(--white); color:var(--gray-900); min-height:100vh; }

/* ── TYPOGRAPHY ── */
h1{font-size:1.6rem}h2{font-size:1.35rem}h3{font-size:1.15rem}h4{font-size:1rem}
h1,h2,h3,h4{font-weight:700;line-height:1.3;color:var(--gray-900)}
p{line-height:1.6;color:var(--gray-700)}
a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}
small{font-size:.8rem;color:var(--gray-500)}

/* ── LAYOUT ── */
#app { display:flex; min-height:100vh; }

/* ── SIDEBAR ── */
#sidebar {
  width:var(--sidebar-w); background:var(--gradient-deep); color:var(--white);
  display:flex; flex-direction:column; position:fixed; top:0; left:0;
  height:100vh; height:100dvh; z-index:200; transition:transform var(--transition);
  overflow:hidden;
}
#sidebar.collapsed { transform:translateX(-100%); }
.sidebar-logo {
  padding:20px 20px 16px; border-bottom:1px solid rgba(255,255,255,.08);
  display:flex; align-items:center; gap:10px; flex-shrink:0;
}
.sidebar-logo .school-icon { font-size:1.6rem; }
.sidebar-logo .school-info { overflow:hidden; }
.sidebar-logo .school-name { font-size:.95rem; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sidebar-logo .school-branch { font-size:.72rem; color:var(--gray-400); }
.sidebar-nav { flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:10px 0; }
.sidebar-nav::-webkit-scrollbar { width:4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background:rgba(255,255,255,.15); border-radius:4px; }
.nav-section { padding:14px 16px 4px; font-size:.68rem; font-weight:600; color:var(--gray-500); text-transform:uppercase; letter-spacing:.08em; }
.nav-item {
  display:flex; align-items:center; gap:10px; padding:9px 20px;
  cursor:pointer; border-radius:0; transition:background var(--transition);
  font-size:.88rem; color:var(--gray-300); border-left:3px solid transparent;
  white-space:nowrap;
}
.nav-item:hover { background:rgba(255,255,255,.06); color:var(--white); }
.nav-item.active { background:rgba(255,255,255,.18); color:var(--white); border-left-color:#ffffff; }
.nav-item .nav-icon { font-size:1rem; width:20px; text-align:center; flex-shrink:0; }
.nav-badge { margin-left:auto; background:var(--danger); color:var(--white); font-size:.65rem; padding:1px 6px; border-radius:10px; }
.sidebar-footer { padding:12px 16px; border-top:1px solid rgba(255,255,255,.08); font-size:.78rem; color:var(--gray-500); flex-shrink:0; }
.sidebar-user { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.sidebar-user .user-avatar { width:32px; height:32px; border-radius:50%; background:var(--primary); display:flex; align-items:center; justify-content:center; font-size:.8rem; font-weight:700; color:var(--white); flex-shrink:0; }
.sidebar-user .user-info .user-name { font-size:.82rem; font-weight:600; color:var(--gray-200); }
.sidebar-user .user-info .user-role { font-size:.7rem; color:var(--gray-500); text-transform:capitalize; }
#btn-logout { width:100%; background:rgba(220,38,38,.15); color:#fca5a5; border:none; padding:7px; border-radius:var(--radius); cursor:pointer; font-size:.8rem; transition:background var(--transition); }
#btn-logout:hover { background:rgba(220,38,38,.3); }

/* ── MAIN CONTENT ── */
#main { margin-left:var(--sidebar-w); flex:1; display:flex; flex-direction:column; min-height:100vh; transition:margin-left var(--transition); }
#main.expanded { margin-left:0; }

/* ── TOPBAR ── */
#topbar {
  height:var(--header-h); background:var(--white); border-bottom:1px solid var(--gray-200);
  display:flex; align-items:center; padding:0 24px; gap:16px; position:sticky;
  top:0; z-index:100; box-shadow:var(--shadow-sm);
}
#btn-menu-toggle { display:none; background:none; border:none; font-size:1.2rem; cursor:pointer; color:var(--gray-600); padding:6px; border-radius:var(--radius); }
#btn-menu-toggle:hover { background:var(--gray-100); }
#topbar-title { font-size:1rem; font-weight:600; color:var(--gray-800); flex:1; }
.topbar-actions { display:flex; align-items:center; gap:8px; }
.topbar-clock { font-size:.82rem; color:var(--gray-500); font-variant-numeric:tabular-nums; }
.topbar-pin-btn { background:none; border:1px solid var(--gray-300); padding:5px 12px; border-radius:var(--radius); cursor:pointer; font-size:.8rem; color:var(--gray-600); }
.topbar-pin-btn:hover { background:var(--gray-100); }

/* ── PAGE CONTENT ── */
#content { flex:1; padding:24px; overflow-x:hidden; }

/* ── CARDS & CONTAINERS ── */
.page-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; flex-wrap:wrap; gap:12px; }
.page-header h2 { margin:0; }
.card { background:var(--white); border-radius:var(--radius-lg); padding:24px; box-shadow:var(--shadow-sm); border:1px solid var(--gray-200); }
.card-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:18px; padding-bottom:14px; border-bottom:1px solid var(--gray-200); }
.card-header h3 { margin:0; font-size:1rem; }
.card-footer { margin-top:18px; padding-top:14px; border-top:1px solid var(--gray-200); display:flex; gap:8px; flex-wrap:wrap; }

/* ── STAT CARDS ── */
.stats-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:16px; margin-bottom:24px; }
.stat-card { background:var(--white); border-radius:var(--radius-lg); padding:20px 22px; box-shadow:var(--shadow-sm); border:1px solid var(--gray-200); display:flex; align-items:center; gap:16px; }
.stat-icon { width:50px; height:50px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:1.4rem; flex-shrink:0; }
.stat-icon.blue   { background:#dbeafe; }
.stat-icon.green  { background:#f0fdf4; }
.stat-icon.amber  { background:#fffbeb; }
.stat-icon.red    { background:#fef2f2; }
.stat-icon.purple { background:#faf5ff; }
.stat-icon.cyan   { background:#ccfbf1; }
.stat-info .stat-val  { font-size:1.6rem; font-weight:800; line-height:1.1; color:var(--gray-900); }
.stat-info .stat-lbl  { font-size:.78rem; color:var(--gray-500); margin-top:2px; }
.stat-info .stat-sub  { font-size:.75rem; color:var(--gray-400); margin-top:3px; }

/* ── GRID LAYOUTS ── */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:20px; }
.grid-4 { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }
@media(max-width:900px){.grid-2,.grid-3,.grid-4{grid-template-columns:1fr;}}

/* ── FILTER BAR ── */
.filter-bar { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:18px; padding:14px 18px; background:var(--gray-50); border-radius:var(--radius); border:1px solid var(--gray-200); align-items:flex-end; }
.filter-bar label { font-size:.78rem; font-weight:600; color:var(--gray-600); margin-bottom:4px; display:block; }
.filter-group { display:flex; flex-direction:column; }
.filter-bar select, .filter-bar input { padding:7px 10px; border:1px solid var(--gray-300); border-radius:var(--radius); font-size:.85rem; background:var(--white); min-width:140px; outline:none; }
.filter-bar select:focus,.filter-bar input:focus { border-color:var(--primary); box-shadow:0 0 0 2px rgba(29,78,216,.15); }

/* ── BUTTONS ── */
.btn { display:inline-flex; align-items:center; gap:6px; padding:8px 16px; border-radius:var(--radius); font-size:.85rem; font-weight:600; cursor:pointer; border:none; transition:all var(--transition); white-space:nowrap; line-height:1; }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btn-primary { background:var(--gradient); color:var(--white); }
.btn-primary:hover:not(:disabled) { background:var(--primary-dark); }
.btn-success { background:var(--success); color:var(--white); }
.btn-success:hover:not(:disabled) { background:#15803d; }
.btn-danger  { background:var(--danger);  color:var(--white); }
.btn-danger:hover:not(:disabled)  { background:#b91c1c; }
.btn-warning { background:var(--secondary); color:var(--white); }
.btn-warning:hover:not(:disabled) { background:#d97706; }
.btn-info    { background:var(--info); color:var(--white); }
.btn-info:hover:not(:disabled)    { background:#0e7490; }
.btn-outline { background:transparent; border:1px solid var(--gray-300); color:var(--gray-700); }
.btn-outline:hover:not(:disabled) { background:var(--gray-100); }
.btn-sm { padding:5px 11px; font-size:.78rem; }
.btn-lg { padding:11px 22px; font-size:.95rem; }
.btn-icon { padding:7px; border-radius:var(--radius); background:none; border:none; cursor:pointer; color:var(--gray-600); font-size:1rem; transition:all var(--transition); }
.btn-icon:hover { background:var(--gray-100); color:var(--gray-900); }
.btn-icon.danger:hover { background:#fef2f2; color:var(--danger); }

/* ── FORMS ── */
.form-row { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:16px; margin-bottom:4px; }
.form-group { display:flex; flex-direction:column; margin-bottom:14px; }
.form-group label { font-size:.8rem; font-weight:600; color:var(--gray-700); margin-bottom:5px; }
.form-group label .req { color:var(--danger); margin-left:2px; }
.form-control {
  padding:9px 12px; border:1.5px solid var(--gray-300); border-radius:var(--radius);
  font-size:.88rem; background:var(--white); transition:border-color var(--transition);
  width:100%; outline:none; font-family:var(--font);
}
.form-control:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(29,78,216,.13); }
.form-control.error { border-color:var(--danger); }
.form-error { font-size:.75rem; color:var(--danger); margin-top:4px; }
.form-hint  { font-size:.75rem; color:var(--gray-400); margin-top:4px; }
textarea.form-control { resize:vertical; min-height:80px; }
select.form-control { cursor:pointer; }

/* ── TABLES ── */
.table-wrapper { overflow-x:auto; border-radius:var(--radius); border:1px solid var(--gray-200); }
table { width:100%; border-collapse:collapse; font-size:.85rem; }
thead tr { background:var(--gray-50); border-bottom:2px solid var(--gray-200); }
thead th { padding:11px 14px; text-align:left; font-size:.75rem; font-weight:700; color:var(--gray-500); text-transform:uppercase; letter-spacing:.05em; white-space:nowrap; }
tbody tr { border-bottom:1px solid var(--gray-100); transition:background var(--transition); }
tbody tr:hover { background:var(--gray-50); }
tbody tr:last-child { border-bottom:none; }
tbody td { padding:11px 14px; color:var(--gray-700); vertical-align:middle; }
.table-actions { display:flex; gap:4px; }

/* ── BADGES ── */
.badge { display:inline-flex; align-items:center; gap:4px; padding:3px 9px; border-radius:20px; font-size:.72rem; font-weight:600; white-space:nowrap; }
.badge-success  { background:#dcfce7; color:#166534; }
.badge-danger   { background:#fee2e2; color:#991b1b; }
.badge-warning  { background:#fef3c7; color:#92400e; }
.badge-info     { background:#cffafe; color:#164e63; }
.badge-primary  { background:#dbeafe; color:#1e40af; }
.badge-gray     { background:var(--gray-100); color:var(--gray-600); }
.badge-purple   { background:#f5f3ff; color:#5b21b6; }

/* ── MODALS ── */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:1000;
  display:flex; align-items:center; justify-content:center; padding:20px;
  opacity:0; pointer-events:none; transition:opacity var(--transition);
}
.modal-overlay.active { opacity:1; pointer-events:all; }
.modal {
  background:var(--white); border-radius:var(--radius-lg); width:100%; max-height:90vh;
  overflow:hidden; display:flex; flex-direction:column;
  transform:scale(.95); transition:transform var(--transition); box-shadow:var(--shadow-lg);
}
.modal-overlay.active .modal { transform:scale(1); }
.modal-sm { max-width:440px; }
.modal-md { max-width:620px; }
.modal-lg { max-width:820px; }
.modal-xl { max-width:1050px; }
.modal-header { padding:18px 22px; border-bottom:1px solid var(--gray-200); display:flex; align-items:center; justify-content:space-between; flex-shrink:0; }
.modal-header h3 { font-size:1rem; margin:0; }
.modal-close { background:none; border:none; font-size:1.3rem; cursor:pointer; color:var(--gray-400); line-height:1; padding:4px; border-radius:6px; }
.modal-close:hover { background:var(--gray-100); color:var(--gray-700); }
.modal-body { padding:22px; overflow-y:auto; flex:1; }
.modal-footer { padding:14px 22px; border-top:1px solid var(--gray-200); display:flex; gap:10px; justify-content:flex-end; flex-shrink:0; }

/* ── TOAST NOTIFICATIONS ── */
#toast-container { position:fixed; bottom:24px; right:24px; z-index:9999; display:flex; flex-direction:column; gap:8px; }
.toast {
  background:var(--gray-900); color:var(--white); padding:12px 18px;
  border-radius:var(--radius); font-size:.85rem; box-shadow:var(--shadow-lg);
  display:flex; align-items:center; gap:10px; max-width:360px;
  animation:toastIn .3s ease; border-left:4px solid var(--primary);
}
.toast.success { border-left-color:var(--success); }
.toast.error   { border-left-color:var(--danger); }
.toast.warning { border-left-color:var(--secondary); }
@keyframes toastIn { from{opacity:0;transform:translateX(40px)} to{opacity:1;transform:translateX(0)} }

/* ── LOADING / SPINNER ── */
.spinner { display:inline-block; width:18px; height:18px; border:2.5px solid rgba(255,255,255,.3); border-top-color:#fff; border-radius:50%; animation:spin .6s linear infinite; }
.spinner-dark { border-color:rgba(0,0,0,.1); border-top-color:var(--primary); }
@keyframes spin { to{transform:rotate(360deg)} }
.loading-overlay { position:absolute; inset:0; background:rgba(255,255,255,.7); display:flex; align-items:center; justify-content:center; z-index:10; border-radius:inherit; }
.skeleton { background:linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%); background-size:200% 100%; animation:shimmer 1.2s infinite; border-radius:4px; }
@keyframes shimmer { to{background-position:-200% 0} }

/* ── ATTENDANCE CELLS ── */
.att-cell { padding:4px; }
.att-btn { padding:4px 8px; border:1.5px solid var(--gray-300); border-radius:6px; cursor:pointer; font-size:.75rem; font-weight:600; background:var(--white); transition:all .15s; }
.att-btn.P { background:#dcfce7; border-color:#16a34a; color:#166534; }
.att-btn.A { background:#fee2e2; border-color:#dc2626; color:#991b1b; }
.att-btn.L { background:#fef3c7; border-color:#d97706; color:#92400e; }
.att-btn.Lt{ background:#cffafe; border-color:#0891b2; color:#164e63; }

/* ── MARKS INPUT TABLE ── */
.marks-table input[type=number] { width:70px; padding:5px 7px; border:1.5px solid var(--gray-300); border-radius:6px; font-size:.85rem; text-align:center; }
.marks-table input[type=number]:focus { border-color:var(--primary); outline:none; }
.marks-table input.invalid { border-color:var(--danger); background:#fff5f5; }
.grade-cell { font-weight:700; }
.grade-A\+ { color:#7c3aed; }
.grade-A   { color:#16a34a; }
.grade-B   { color:#0891b2; }
.grade-C   { color:#d97706; }
.grade-D   { color:#ea580c; }
.grade-E   { color:#b45309; }
.grade-F   { color:#dc2626; }

/* ── PIN LOCK ── */
#pin-lock {
  position:fixed; inset:0; background:rgba(17,24,39,.95); z-index:9998;
  display:flex; align-items:center; justify-content:center;
}
.pin-card { background:var(--white); border-radius:var(--radius-lg); padding:36px; width:320px; text-align:center; }
.pin-card h3 { margin-bottom:6px; }
.pin-card p  { color:var(--gray-500); font-size:.85rem; margin-bottom:20px; }
.pin-dots { display:flex; justify-content:center; gap:10px; margin-bottom:20px; }
.pin-dot { width:14px; height:14px; border-radius:50%; border:2px solid var(--gray-300); transition:all .15s; }
.pin-dot.filled { background:var(--primary); border-color:var(--primary); }
.pin-pad { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.pin-key { padding:14px; border:1.5px solid var(--gray-200); border-radius:var(--radius); cursor:pointer; font-size:1.1rem; font-weight:700; background:var(--white); transition:all .15s; }
.pin-key:hover { background:var(--primary); color:var(--white); border-color:var(--primary); }
.pin-key.clear  { color:var(--danger); }
.pin-key.submit { background:var(--primary); color:var(--white); border-color:var(--primary); }

/* ── LOGIN ── */
#login-screen {
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(160deg,#1e3a8a 0%,#1e40af 40%,#0d9488 100%); padding:20px;
}
.login-card { background:var(--white); border-radius:var(--radius-lg); padding:40px 36px; width:100%; max-width:420px; box-shadow:0 20px 60px rgba(0,0,0,.35); }
.login-logo { text-align:center; margin-bottom:24px; }
.login-logo .logo-icon { font-size:2.8rem; display:block; margin-bottom:8px; }
.login-logo h2 { font-size:1.3rem; margin-bottom:4px; }
.login-logo p { color:var(--gray-500); font-size:.82rem; }
.login-footer { text-align:center; margin-top:20px; font-size:.72rem; color:var(--gray-400); }

/* ── VOUCHER PRINT STYLES ── */
@media print {
  * { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  body > *:not(#voucher-print-frame) { display:none !important; }
  #voucher-print-frame { display:block !important; }
}
.voucher-wrap {
  font-family:'Arial',sans-serif; width:100%; max-width:800px; margin:0 auto;
  display:grid; grid-template-columns:1fr 1fr 1fr; gap:0; border:2px solid #222;
}
.voucher-copy { border-right:1px dashed #999; padding:14px; }
.voucher-copy:last-child { border-right:none; }
.voucher-school-name { font-size:11px; font-weight:800; text-align:center; text-transform:uppercase; margin-bottom:2px; }
.voucher-branch { font-size:9px; text-align:center; color:#444; margin-bottom:8px; }
.voucher-copy-label { text-align:center; font-size:9px; font-weight:700; color:#fff; background:#222; padding:2px 0; margin-bottom:8px; letter-spacing:.1em; }
.voucher-field { display:flex; justify-content:space-between; font-size:9px; margin-bottom:3px; border-bottom:1px solid #eee; padding-bottom:2px; }
.voucher-field .lbl { color:#555; font-weight:600; }
.voucher-field .val { font-weight:700; text-align:right; max-width:55%; word-break:break-word; }
.voucher-amount { margin-top:8px; padding:6px; background:#f5f5f5; border-radius:4px; text-align:center; }
.voucher-amount .amount-val { font-size:15px; font-weight:800; }
.voucher-amount .amount-lbl { font-size:8px; color:#666; }
.voucher-footer { margin-top:8px; font-size:8px; color:#666; border-top:1px solid #ddd; padding-top:5px; text-align:center; }
.voucher-sig { margin-top:16px; border-top:1px solid #999; padding-top:4px; font-size:8px; text-align:center; color:#666; }

/* ── RESULT CARD PRINT ── */
.result-card-print { font-family:'Arial',sans-serif; padding:20px; max-width:750px; margin:0 auto; }
.rc-header { text-align:center; border-bottom:2px solid #222; padding-bottom:12px; margin-bottom:12px; }
.rc-header h2 { font-size:16px; text-transform:uppercase; }
.rc-header p  { font-size:11px; color:#444; }
.rc-student-info { display:grid; grid-template-columns:1fr 1fr; gap:4px; font-size:11px; margin-bottom:12px; }
.rc-student-info div { display:flex; gap:6px; }
.rc-student-info .lbl { font-weight:700; min-width:90px; }
.rc-table { width:100%; border-collapse:collapse; font-size:11px; margin-bottom:14px; }
.rc-table th,.rc-table td { border:1px solid #ccc; padding:5px 8px; text-align:center; }
.rc-table th { background:#f0f0f0; font-weight:700; }
.rc-table .subject-col { text-align:left; font-weight:600; }
.rc-total { background:#f9f9f9; font-weight:700; }
.rc-footer { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-top:20px; }
.rc-sig { border-top:1px solid #999; padding-top:4px; text-align:center; font-size:10px; color:#555; }

/* ── MISC UI ── */
.empty-state { text-align:center; padding:60px 20px; color:var(--gray-400); }
.empty-state .empty-icon { font-size:3rem; margin-bottom:12px; display:block; }
.empty-state p { margin-bottom:16px; }
.section-divider { border:none; border-top:1px solid var(--gray-200); margin:20px 0; }
.text-center { text-align:center; }
.text-right  { text-align:right; }
.text-muted  { color:var(--gray-400); }
.text-success{ color:var(--success); }
.text-danger { color:var(--danger); }
.text-warning{ color:var(--warning); }
.text-primary{ color:var(--primary); }
.fw-700 { font-weight:700; }
.mt-4 { margin-top:4px; }
.mt-8 { margin-top:8px; }
.mt-16{ margin-top:16px; }
.mb-16{ margin-bottom:16px; }
.gap-8 { gap:8px; }
.flex  { display:flex; }
.flex-1{ flex:1; }
.items-center{ align-items:center; }
.justify-between{ justify-content:space-between; }
.flex-wrap{ flex-wrap:wrap; }
.hidden { display:none !important; }
.role-badge { display:inline-block; padding:2px 8px; border-radius:12px; font-size:.72rem; font-weight:700; text-transform:capitalize; }
.role-principal  { background:#fef3c7; color:#92400e; }
.role-management { background:#ede9fe; color:#5b21b6; }
.role-admin      { background:#cffafe; color:#164e63; }
.role-teacher    { background:#dcfce7; color:#166534; }

/* ── RESPONSIVE ── */
@media(max-width:768px){
  :root{ --sidebar-w:0px; }
  #sidebar { transform:translateX(-100%); width:260px; }
  #sidebar.open { transform:translateX(0); }
  #main { margin-left:0; }
  #content { padding:16px; }
  .stats-grid { grid-template-columns:1fr 1fr; }
  .filter-bar { flex-direction:column; }
  .filter-bar select,.filter-bar input { min-width:100%; }
  .modal-xl,.modal-lg { max-width:100%; }
}
@media(max-width:480px){
  .stats-grid { grid-template-columns:1fr; }
  .btn { font-size:.8rem; padding:7px 12px; }
}

/* ============================================================================
   PHASE 6 — Mobile responsiveness, tap-overlay, PWA polish
   Developed by ZAIN AFZAL · Powered by ZUX DIGITAL SERVICES
   ============================================================================ */

/* New pages (promotion, audit, lecture videos, etc.) use .table-wrap — make it
   scroll horizontally on small screens just like .table-wrapper. */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; border-radius:var(--radius); }
.table-wrapper { -webkit-overflow-scrolling:touch; }

/* Dark backdrop shown behind the off-canvas sidebar on mobile */
#sidebar-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.45);
  opacity:0; pointer-events:none; transition:opacity .25s ease; z-index:90;
}
#sidebar-overlay.show{ opacity:1; pointer-events:auto; }
#sidebar{ z-index:100; }

/* ---- Tablet / phone ---- */
@media (max-width:768px){
  #topbar{ position:sticky; top:0; z-index:80; padding:10px 12px; gap:8px; }
  #btn-menu-toggle{
    display:inline-flex; align-items:center; justify-content:center;
    width:42px; height:42px; font-size:1.4rem; border:none; background:transparent;
    border-radius:10px; cursor:pointer; color:var(--gray-800);
  }
  #btn-menu-toggle:active{ background:var(--gray-100); }
  #topbar-title{ font-size:1rem; }
  .topbar-actions{ gap:6px; }
  .topbar-clock{ display:none; }                 /* save space on small screens */

  #content{ padding:14px; }

  /* Tables: only genuinely-wide tables scroll; narrow ones fill the screen */
  .table-wrapper table, .table-wrap table{ width:max-content; min-width:100%; }

  /* Touch-friendly controls */
  .btn{ min-height:42px; }
  .btn-sm{ min-height:34px; }
  .btn-icon{ min-width:38px; min-height:38px; }
  .form-control,select.form-control,input.form-control,textarea.form-control{
    font-size:16px;                               /* 16px stops iOS auto-zoom on focus */
    min-height:44px;
  }
  .nav-item{ padding:12px 16px; }                 /* bigger tap target */

  /* Modals fill the screen comfortably */
  .modal{ width:96vw; max-width:96vw; max-height:92vh; overflow-y:auto; }
  .modal-sm{ max-width:96vw; }

  /* Stat cards: two per row */
  .stats-grid{ grid-template-columns:1fr 1fr; gap:10px; }
}

/* ---- Small phones ---- */
@media (max-width:480px){
  #topbar-title{ font-size:.92rem; }
  .stats-grid{ grid-template-columns:1fr; }
  .card{ padding:14px; }
  .card-header h3{ font-size:1rem; }
  .btn{ padding:9px 14px; }
  /* Buttons that sit in a row wrap instead of overflowing */
  .card-footer,.table-actions{ flex-wrap:wrap; }
}

/* Respect devices with a notch (PWA standalone) */
@media (display-mode:standalone){
  #topbar{ padding-top:calc(10px + env(safe-area-inset-top)); }
}


/* ============================================================================
   WARM TEAL & AMBER — theme polish (selected by Zain). One-file restyle.
   Developed by ZAIN AFZAL · Powered by ZUX DIGITAL SERVICES
   ============================================================================ */
.nav-section{ color:rgba(255,255,255,.45); }
.sidebar-logo{ border-bottom-color:rgba(255,255,255,.12); }
.sidebar-user .user-info .user-role{ color:rgba(255,255,255,.5); }
.sidebar-user .user-info .user-name{ color:#e7f5f1; }

/* Softer, lifting cards */
.card{ transition:box-shadow .2s ease, transform .2s ease; }
.card:hover{ box-shadow:var(--shadow); }
.stat-card{ transition:transform .15s ease, box-shadow .2s ease; }
.stat-card:hover{ transform:translateY(-2px); box-shadow:var(--shadow); }
.stat-icon{ border-radius:13px; }

/* Buttons: subtle press */
.btn{ transition:all .15s ease; }
.btn:active:not(:disabled){ transform:translateY(1px); }

/* Tables: teal header, soft zebra, teal hover */
thead tr{ background:var(--primary-light); border-bottom:2px solid #bfdbfe; }
thead th{ color:#1e40af; }
tbody tr:nth-child(even){ background:#f8fafc; }
tbody tr:hover{ background:var(--primary-light); }

/* Topbar pin button on-theme */
.topbar-pin-btn{ border-color:var(--primary-light); color:var(--primary-dark); }
.topbar-pin-btn:hover{ background:var(--primary-light); }

/* Login card gets a teal cap + amber underline on the title */
.login-card{ border-top:4px solid var(--primary); }
.login-logo h2{ color:var(--teal-sidebar); }
.login-logo h2::after{ content:""; display:block; width:46px; height:3px; background:var(--secondary); border-radius:2px; margin:8px auto 0; }

/* Section labels / dividers warm */
.section-divider{ border-top-color:var(--gray-200); }


/* ============================================================================
   MOBILE LAYOUT FIXES (Zain feedback) — filters stack full-width, no empty space
   ============================================================================ */
@media (max-width:768px){
  /* Filter bars: stack full-width and LEFT-aligned (was squashed to the right) */
  .filter-bar{ flex-direction:column; align-items:stretch; padding:12px 14px; gap:12px; }
  .filter-bar .filter-group{ width:100%; }
  .filter-bar label{ text-align:left; }
  .filter-bar select,
  .filter-bar input,
  .filter-bar textarea{ width:100% !important; min-width:0; }
  .filter-bar .btn{ width:100%; justify-content:center; }

  /* Two-column [results | side-panel] grids collapse to one column */
  [style*="grid-template-columns:1fr 280px"],
  [style*="grid-template-columns: 1fr 280px"],
  [style*="grid-template-columns:1fr 320px"],
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns:1fr 300px"]{ grid-template-columns:1fr !important; }

  /* Any sticky side panel shouldn't stick on mobile */
  [style*="position:sticky"]{ position:static !important; }

  /* Tables scroll smoothly inside their own wrapper, not the whole page */
  .table-wrapper, .table-wrap{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
}


/* ============================================================================
   PARENT-PORTAL THEME (blue -> teal gradient, white workspace)
   Developed by ZAIN AFZAL · Powered by ZUX DIGITAL SERVICES
   ============================================================================ */
.card, .stat-card{ border:1px solid var(--gray-200); }
.login-card{ border-top:4px solid #1e40af; }
.login-logo h2{ color:#1e3a8a; }
/* active nav uses a soft white wash on the gradient */
.nav-item.active{ box-shadow:inset 3px 0 0 #ffffff; }
.btn-primary:hover:not(:disabled){ filter:brightness(1.06); }


/* ============================================================================
   MOBILE POLISH v2 (Zain) — form single-column, button rows wrap, title clamp
   Developed by ZAIN AFZAL · Powered by ZUX DIGITAL SERVICES
   ============================================================================ */
@media (max-width:768px){
  /* Forms: always ONE column on phones (no squished side-by-side fields) */
  .form-row{ grid-template-columns:1fr !important; gap:12px; }

  /* Long page titles don't push the topbar actions off-screen */
  #topbar-title{
    flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  }

  /* EVERY row of buttons wraps instead of overflowing / getting cut */
  .card-header, .card-footer, .table-actions, .btn-group,
  .card-actions, .filter-actions, .toolbar, .page-actions{
    flex-wrap:wrap !important;
  }
  /* Card header: title on top, its action buttons drop to next line neatly */
  .card-header{ gap:10px; align-items:flex-start; }
  .card-header .card-actions .btn,
  .card-header .btn{ flex:0 0 auto; }

  /* Tables a touch smaller so more fits before scrolling */
  .table-wrapper table, .table-wrap table{ font-size:.82rem; }
  th, td{ padding:8px 10px; }

  /* Pagination controls centre + wrap */
  .pagination{ flex-wrap:wrap; justify-content:center; }
}

@media (max-width:480px){
  /* Action button groups: each button grows to share the row evenly */
  .table-actions .btn, .table-actions .btn-icon{ flex:1 1 auto; }
  .card-header h3{ width:100%; }
}


/* ============================================================================
   MOBILE OVERFLOW FIX — admin panel no longer scrolls sideways on phones
   ============================================================================ */
/* MOBILE OVERFLOW FIX — main column must shrink to the screen; wide tables scroll inside their own box */
#main, #content { min-width:0; max-width:100%; }
#content > * { max-width:100%; }
.card, .filter-bar, .table-wrapper, .table-wrap { min-width:0; max-width:100%; }
@media (max-width:768px){
  #main { width:100%; }
  .page-header { flex-wrap:wrap; gap:10px; }
  .page-header > div { flex-wrap:wrap; }
  .table-wrapper, .table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
}

/* ============================================================================
   PHONE APP BAR (admin panel installed on the Principal's phone)
   ============================================================================ */
#mbar{ display:none; }
@media (max-width:768px){
  #mbar{
    display:grid; grid-template-columns:repeat(5,1fr); position:fixed; left:0; right:0; bottom:0; z-index:85;
    background:#fff; border-top:1px solid var(--gray-200); padding:5px 4px calc(5px + env(safe-area-inset-bottom));
    box-shadow:0 -6px 20px -12px rgba(15,23,42,.25);
  }
  #mbar button{ position:relative; display:flex; flex-direction:column; align-items:center; gap:2px; padding:6px 0; border:0; background:none;
    font:inherit; font-size:11px; font-weight:700; color:var(--gray-500); border-radius:12px; cursor:pointer; }
  #mbar button svg{ width:22px; height:22px; }
  #mbar button.on{ color:var(--primary); background:var(--primary-light); }
  #mbar .mb-badge{ position:absolute; top:2px; left:calc(50% + 6px); min-width:18px; height:18px; padding:0 5px; border-radius:9px;
    background:#dc2626; color:#fff; font-size:10.5px; line-height:18px; font-weight:800; }
  #content{ padding-bottom:calc(84px + env(safe-area-inset-bottom)); }
  #toast-container{ bottom:calc(78px + env(safe-area-inset-bottom)) !important; }
}
@media print{ #mbar{ display:none !important; } }

/* Principal Report tables scroll sideways on phones instead of spilling out */
@media (max-width:768px){
  #content .pr-sec{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
}

/* ── iPhone fix: date / time boxes were wider than the screen and their text was centred ── */
input[type="date"],input[type="time"],input[type="datetime-local"],input[type="month"],input[type="week"]{
  -webkit-appearance:none; appearance:none; display:block; min-width:0; max-width:100%; text-align:left; background-color:var(--white);
}
input[type="date"].form-control,input[type="time"].form-control,input[type="datetime-local"].form-control,input[type="month"].form-control{ width:100%; }
input::-webkit-date-and-time-value{ text-align:left; min-height:1.5em; }
.form-group,.form-row > *{ min-width:0; }
