/* =============================================================================
   MNAQ School Management System — modern light theme
   ============================================================================= */
:root {
  --bg: #F3F5FA; --surface: #FFFFFF; --surface-2: #F6F7FB; --border: #ECEEF5;
  --text: #1C2033; --text-muted: #8A8FA3;
  --green-900: #0B3D26; --green-700: #12805C; --green-600: #16A34A; --green-100: #E3F7EC;
  --gold: #F59E0B; --gold-dark: #B45309; --gold-100: #FEF3E0;
  --blue: #3B82F6; --blue-dark: #1D4ED8; --blue-100: #E8F0FE;
  --purple: #7C5CFC; --purple-dark: #5B3FE0; --purple-100: #F1EDFF;
  --danger: #E4483F; --danger-100: #FDEBEA;
  --shadow: 0 1px 2px rgba(20,20,43,0.04), 0 12px 28px -14px rgba(20,20,43,0.12);
}
[data-theme="dark"] {
  --bg: #0D1117; --surface: #151B26; --surface-2: #1B2230; --border: #262E3D;
  --text: #EDF1F7; --text-muted: #8D97AB;
  --green-900: #062718; --green-700: #22A876; --green-600: #34C98A; --green-100: #16332A;
  --gold: #F0B429; --gold-dark: #F5C94E; --gold-100: #3A2D12;
  --blue: #5B9DF9; --blue-dark: #8AB8FB; --blue-100: #16233A;
  --purple: #9A85FF; --purple-dark: #B4A4FF; --purple-100: #241F3D;
  --danger: #F0685F; --danger-100: #3A1E1C;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 28px -14px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; font-size: 14px; }
h1,h2,h3 { font-family: 'Amiri', serif; }
input, select, textarea, button { font-family: inherit; }
::placeholder { color: var(--text-muted); opacity: .7; }

/* ------------------------------- Utility ------------------------------- */
.muted { color: var(--text-muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }

/* -------------------------------- Buttons -------------------------------- */
.btn { border: none; border-radius: 10px; padding: 9px 15px; font-size: 13px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-900); }
.btn-gold { background: var(--gold); color: #201603; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.icon-btn { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-only { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text-muted); }
.icon-only:hover { background: var(--surface-2); color: var(--text); }
.link-btn { background: none; border: none; color: var(--green-700); font-weight: 700; cursor: pointer; text-decoration: none; font-size: 13px; }

/* --------------------------------- Shell --------------------------------- */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 246px; background: var(--surface); border-right: 1px solid var(--border); height: 100%; display: flex; flex-direction: column; z-index: 30; flex-shrink: 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; }
.brand-name { font-family: 'Amiri', serif; font-weight: 800; font-size: 16.5px; line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: var(--text-muted); font-weight: 600; }
.sidebar-nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: 12px; border: none; background: transparent; color: var(--text-muted); font-size: 13.3px; font-weight: 600; cursor: pointer; text-align: left; width: 100%; white-space: nowrap; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-active { background: var(--green-700) !important; color: #fff !important; box-shadow: 0 6px 16px -6px rgba(18,128,92,0.55); }
.nav-icon { width: 18px; text-align: center; }

.sidebar-cta { margin: 14px; padding: 18px; border-radius: 16px; background: linear-gradient(160deg, var(--green-700), var(--green-900)); color: #fff; position: relative; overflow: hidden; }
.sidebar-cta-icon { font-size: 22px; margin-bottom: 8px; }
.sidebar-cta-title { font-weight: 800; font-size: 13.5px; }
.sidebar-cta-sub { font-size: 11.5px; opacity: .85; margin-top: 3px; line-height: 1.4; }
.sidebar-cta-btn { margin-top: 12px; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.3); color: #fff; width: 100%; justify-content: center; }
.sidebar-cta-btn:hover { background: rgba(255,255,255,0.26); }

.main-col { flex: 1; min-width: 0; height: 100%; overflow-y: auto; overflow-x: hidden; scrollbar-color: var(--border) transparent; }
.sidebar { scrollbar-color: var(--border) transparent; }
.main-col::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 9px; }
.main-col::-webkit-scrollbar-track, .sidebar::-webkit-scrollbar-track { background: transparent; }
.main-col::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
.main-col::-webkit-scrollbar-thumb:hover, .sidebar::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; gap: 16px; }
.crumb { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-title { font-weight: 800; font-size: 17px; font-family: 'Amiri', serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; width: 280px; color: var(--text-muted); font-size: 13px; flex-shrink: 1; }
.topbar-search input { border: none; background: none; padding: 0; width: 100%; font-size: 13px; }
.bell-wrap { position: relative; }
.bell-dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.user-block { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 12px; flex-shrink: 0; }
.user-block:hover { background: var(--surface-2); }
.user-chip { width: 34px; height: 34px; border-radius: 50%; background: var(--green-700); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; flex-shrink: 0; }
.user-name-role { display: flex; flex-direction: column; line-height: 1.25; white-space: nowrap; }
.user-name-role .un { font-size: 12.5px; font-weight: 700; }
.user-name-role .ur { font-size: 10.5px; color: var(--text-muted); }
.page-content { padding: 22px 24px; max-width: 1400px; margin: 0 auto; }
.page-loading { padding: 60px; text-align: center; color: var(--text-muted); }
.greeting-sub { font-size: 13px; color: var(--text-muted); margin: -8px 0 16px; }

#mobile-scrim { display: none; position: fixed; inset: 0; background: rgba(20,20,43,0.45); z-index: 25; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; top: 0; height: 100vh; transition: left .2s ease; }
  .sidebar.mobile-open { left: 0; }
  .topbar-search { display: none; }
  #mobile-scrim.active { display: block; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
  .crumb { display: none; }
  .page-title { font-size: 15px; }
  .user-name-role { display: none; }
  .user-block { padding: 2px; gap: 0; }
  .page-content { padding: 14px 12px; }
}
@media (max-width: 400px) {
  .bell-wrap { display: none; }
}

/* --------------------------------- Grids --------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); gap: 14px; margin-bottom: 4px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-top: 14px; }
.grid-3 { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 14px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(230px,1fr)); gap: 14px; }

/* -------------------------------- Stat card -------------------------------- */
.stat-card { padding: 18px 18px 0; display: flex; flex-direction: column; gap: 10px; overflow: hidden; position: relative; }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--green-100); color: var(--green-700); display: grid; place-items: center; font-size: 18px; }
.stat-icon-gold { background: var(--gold-100); color: var(--gold-dark); }
.stat-icon-blue { background: var(--blue-100); color: var(--blue-dark); }
.stat-icon-purple { background: var(--purple-100); color: var(--purple-dark); }
.stat-value { font-size: 21px; font-weight: 800; font-family: 'Amiri', serif; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.stat-sub { font-size: 11.5px; color: var(--text-muted); }
.stat-bar { height: 4px; margin: 12px -18px 0; background: var(--green-600); border-radius: 0; }
.stat-bar-gold { background: var(--gold); }
.stat-bar-blue { background: var(--blue); }
.stat-bar-purple { background: var(--purple); }

/* -------------------------------- Chart card -------------------------------- */
.chart-card { padding: 18px; }
.chart-title { font-weight: 700; margin-bottom: 12px; font-size: 14px; }
.chart-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* -------------------------------- Donut legend -------------------------------- */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-legend { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.donut-legend-row { display: flex; align-items: center; gap: 10px; }
.donut-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-text { flex: 1; }
.donut-legend-label { font-size: 12.5px; font-weight: 700; }
.donut-legend-sub { font-size: 11px; color: var(--text-muted); }
.donut-legend-pct { font-size: 14px; font-weight: 800; font-family: 'Amiri', serif; }
.donut-total-box { border: 1px dashed var(--border); border-radius: 12px; padding: 10px 14px; text-align: center; margin-top: 4px; }

/* -------------------------------- Activity feed -------------------------------- */
.activity-item { display: flex; gap: 11px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.activity-title { font-size: 12.8px; font-weight: 700; }
.activity-sub { font-size: 11.3px; color: var(--text-muted); margin-top: 1px; }
.activity-time { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }

/* -------------------------------- Circular progress -------------------------------- */
.progress-ring { width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; margin: 4px auto; }
.progress-ring-inner { width: 98px; height: 98px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; box-shadow: inset 0 0 0 1px var(--border); }
.progress-ring-pct { font-size: 19px; font-weight: 800; font-family: 'Amiri', serif; }
.progress-ring-label { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.fee-summary-row { display: flex; justify-content: space-between; font-size: 12px; padding: 6px 0; }

/* -------------------------------- Quick actions -------------------------------- */
.quick-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-action-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; border-radius: 14px; background: var(--surface-2); cursor: pointer; border: 1px solid var(--border); text-align: left; }
.quick-action-btn:hover { border-color: var(--green-700); }
.quick-action-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; }
.quick-action-label { font-size: 12px; font-weight: 700; }

/* --------------------------------- Toolbar --------------------------------- */
.toolbar { padding: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search-box { position: relative; flex: 1 1 220px; }
.search-box input { width: 100%; padding: 9px 11px; }
.tab-row { display: flex; gap: 8px; margin: 14px 0; }

/* ---------------------------------- Forms ---------------------------------- */
input, select, textarea { padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13.5px; outline: none; width: 100%; }
textarea { resize: vertical; min-height: 70px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.field-label { font-weight: 600; color: var(--text); }
.field-label em { color: var(--danger); font-style: normal; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-grid-2 { grid-template-columns: 1fr; } }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); }

/* --------------------------------- Table --------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th { text-align: left; padding: 9px 12px; color: var(--text-muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody td { padding: 10px 12px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: var(--surface-2); }
.table-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 10px 4px 2px; font-size: 12px; color: var(--text-muted); }
.row-actions { display: flex; gap: 6px; }

/* --------------------------------- Badges --------------------------------- */
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: .2px; display: inline-block; }
.badge-green { background: var(--green-100); color: var(--green-700); }
.badge-gold { background: var(--gold-100); color: var(--gold-dark); }
.badge-red { background: var(--danger-100); color: var(--danger); }
.badge-gray { background: var(--surface-2); color: var(--text-muted); }

/* -------------------------------- Empty state -------------------------------- */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 20px; color: var(--text-muted); text-align: center; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; font-size: 24px; }
.empty-title { font-weight: 700; color: var(--text); }
.empty-msg { font-size: 13px; max-width: 320px; }

/* --------------------------------- Modals --------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,20,43,0.35); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 200; padding: 16px; }
.modal-card { background: var(--surface); border-radius: 18px; padding: 22px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow); border: 1px solid var(--border); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-title { font-weight: 800; font-size: 16px; font-family: 'Amiri', serif; }
.confirm-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; font-size: 18px; }
.confirm-warn { background: var(--gold-100); color: var(--gold-dark); }
.confirm-danger { background: var(--danger-100); color: var(--danger); }

/* -------------------------------- Toasts -------------------------------- */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 8px; min-width: 260px; padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600; background: var(--green-100); color: var(--green-700); border: 1px solid var(--border); animation: slideIn .25s ease; }
.toast-error { background: var(--danger-100); color: var(--danger); }
.toast-out { opacity: 0; transform: translateX(12px); transition: all .2s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px);} to { opacity: 1; transform: none; } }

/* -------------------------------- Avatar chip -------------------------------- */
.avatar-chip { width: 32px; height: 32px; border-radius: 9px; background: var(--green-100); color: var(--green-700); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.avatar-chip-lg { width: 54px; height: 54px; border-radius: 14px; font-size: 16px; }

/* ---------------------------------- Lists ---------------------------------- */
.list-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.list-row:last-child { border-bottom: none; }

/* -------------------------------- Class card -------------------------------- */
.class-card { padding: 16px; }
.class-name { font-weight: 800; font-size: 15px; margin-top: 10px; font-family: 'Amiri', serif; }
.class-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.class-meta { display: flex; justify-content: space-between; margin-top: 14px; font-size: 12.5px; }
.progress-track { height: 6px; background: var(--surface-2); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green-600); }

/* --------------------------------- Profile --------------------------------- */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; font-size: 13px; }
.profile-k { color: var(--text-muted); font-size: 11px; }
.profile-v { font-weight: 600; }

/* --------------------------------- Receipt --------------------------------- */
.receipt-head { text-align: center; border-bottom: 2px dashed var(--border); padding-bottom: 14px; }
.receipt-body { padding: 14px 2px; font-size: 13px; display: flex; flex-direction: column; gap: 7px; }
.receipt-row { display: flex; justify-content: space-between; }
.receipt-footer { border-top: 2px dashed var(--border); padding-top: 10px; text-align: center; font-size: 11px; color: var(--text-muted); }

/* -------------------------------- Reports -------------------------------- */
.report-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.report-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--green-100); color: var(--green-700); display: grid; place-items: center; font-size: 17px; }
.report-label { font-weight: 700; font-size: 14px; }

/* --------------------------------- Roles UI --------------------------------- */
.role-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.perm-group-label { font-size: 11.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 6px; }
.perm-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 5px 8px; border-radius: 7px; background: var(--surface-2); }

/* ---------------------------------- Login ---------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1100px 500px at 15% -10%, var(--green-100), transparent), radial-gradient(900px 500px at 110% 110%, var(--gold-100), transparent), var(--bg); }
.login-card { display: flex; width: 100%; max-width: 880px; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
.login-side { flex: 1; min-width: 280px; background: linear-gradient(160deg, var(--green-900), var(--green-700)); padding: 44px 36px; color: #fff; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-side-bg { position: absolute; inset: 0; opacity: .12; background: linear-gradient(180deg, transparent 60%, var(--gold) 100%); }
.login-side-top, .login-side-bottom { position: relative; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-crest { width: 44px; height: 44px; border-radius: 13px; background: rgba(255,255,255,.12); display: grid; place-items: center; border: 1px solid rgba(255,255,255,.25); }
.login-brand-name { font-family: 'Amiri', serif; font-weight: 700; font-size: 20px; letter-spacing: .5px; }
.login-school-name { margin-top: 30px; font-family: 'Amiri', serif; font-size: 26px; line-height: 1.35; }
.login-tagline { margin-top: 10px; font-size: 13px; opacity: .85; }
.login-side-bottom { display: flex; gap: 8px; font-size: 12px; opacity: .85; }
.login-form-side { flex: 1.15; min-width: 320px; background: var(--surface); padding: 44px 40px; }
.login-heading { font-family: 'Amiri', serif; font-size: 22px; font-weight: 700; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-form { margin-top: 26px; display: flex; flex-direction: column; gap: 16px; }
.login-error { display: flex; gap: 8px; align-items: center; background: var(--danger-100); color: var(--danger); padding: 9px 12px; border-radius: 9px; font-size: 12.5px; font-weight: 600; }
.login-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.login-row a { color: var(--green-700); font-weight: 600; text-decoration: none; }
.login-demo { margin-top: 22px; padding: 12px; border-radius: 11px; background: var(--surface-2); font-size: 11.5px; color: var(--text-muted); border: 1px solid var(--border); }
@media (max-width: 700px) { .login-card { flex-direction: column; } }

/* ---------------------------------- Print ---------------------------------- */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: fixed; top: 0; left: 0; width: 100%; }
}