/* ============================================================
   School Admin Portal - Main Stylesheet
   Author: School Admin System
   Description: Responsive styles for the entire portal
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---------- CSS Variables (Light Mode) ---------- */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #0ea5e9;
    --accent: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --navbar-height: 64px;

    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --bg-hover: #f0f4ff;
    --border: #e2e8f0;
    --border-focus: #2563eb;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .10);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .12);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, .15);

    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: rgba(255, 255, 255, .08);
    --sidebar-active: #2563eb;
    --sidebar-border: rgba(255, 255, 255, .06);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: .22s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Dark Mode Overrides ---------- */
[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #263347;
    --bg-hover: #263347;
    --border: #334155;
    --border-focus: #60a5fa;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);

    --sidebar-bg: #0f172a;
    --sidebar-border: rgba(255, 255, 255, .04);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    transition: background var(--transition), color var(--transition);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
}

input,
select,
textarea {
    font-family: inherit;
    outline: none;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #0ea5e9 100%);
    position: relative;
    overflow: hidden;
    padding: 1rem;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(99, 102, 241, .15) 0%, transparent 50%);
    pointer-events: none;
}

.login-bg-shapes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.login-bg-shapes span {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .04);
    animation: floatShape 8s ease-in-out infinite;
}

.login-bg-shapes span:nth-child(1) {
    width: 300px;
    height: 300px;
    top: -80px;
    left: -80px;
    animation-delay: 0s;
}

.login-bg-shapes span:nth-child(2) {
    width: 200px;
    height: 200px;
    bottom: -50px;
    right: -50px;
    animation-delay: 2s;
}

.login-bg-shapes span:nth-child(3) {
    width: 150px;
    height: 150px;
    top: 50%;
    left: 80%;
    animation-delay: 4s;
}

@keyframes floatShape {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(10deg);
    }
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
    animation: fadeSlideUp .5s ease;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: #fff;
    box-shadow: 0 8px 24px rgba(37, 99, 235, .35);
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-logo p {
    font-size: .875rem;
    color: var(--text-secondary);
    margin-top: .25rem;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .4rem;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: .875rem;
    color: var(--text-muted);
    font-size: .9rem;
    transition: color var(--transition);
    pointer-events: none;
}

.form-group .input-wrapper input,
.input-wrapper input {
    width: 100%;
    padding: .75rem .875rem .75rem 2.625rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: .9375rem;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.form-group .input-wrapper input:focus,
.input-wrapper input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
    background: var(--bg-card);
}

.input-wrapper input:focus+i,
.input-wrapper:focus-within i {
    color: var(--primary);
}

.toggle-password {
    position: absolute;
    right: 1.2rem;
    background: none;
    color: var(--text-muted);
    font-size: 1rem;
    transition: all 0.3s ease;
    pointer-events: all;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    top: 0;
}

.toggle-password:hover {
    color: var(--primary);
    transform: scale(1.1);
}

/* Unified Wrapper for Auth Enhancement */
.auth-pwd-wrapper {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
}

.auth-pwd-wrapper input {
    padding-right: 45px !important;
    width: 100% !important;
}

.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    font-size: .8125rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.checkbox-label input {
    accent-color: var(--primary);
}

.forgot-link {
    color: var(--primary);
    font-weight: 500;
    transition: opacity var(--transition);
}

.forgot-link:hover {
    opacity: .75;
}

.btn-login {
    width: 100%;
    padding: .875rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
    box-shadow: 0 4px 15px rgba(37, 99, 235, .4);
    letter-spacing: .02em;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, .5);
}

.btn-login:active {
    transform: translateY(0);
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-size: .8125rem;
    color: var(--text-muted);
}

.login-footer span {
    color: var(--primary);
    font-weight: 600;
}

.error-msg {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: .625rem .875rem;
    font-size: .8125rem;
    margin-bottom: 1rem;
    display: none;
    align-items: center;
    gap: .5rem;
}

.error-msg.show {
    display: flex;
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: 10px 0 30px rgba(0, 0, 0, .08);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: var(--navbar-height);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .4);
}

.sidebar-title {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--transition), width var(--transition);
}

.sidebar-title h2 {
    font-size: .9375rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-title p {
    font-size: .7rem;
    color: var(--sidebar-text);
    margin-top: .1rem;
}

.sidebar.collapsed .sidebar-title {
    opacity: 0;
    width: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.nav-section-label {
    font-size: .65rem;
    font-weight: 700;
    color: var(--sidebar-text);
    opacity: .5;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: .75rem 1.125rem .375rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition);
}

.sidebar.collapsed .nav-section-label {
    opacity: 0;
}

.nav-item {
    margin: .125rem .5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .65rem .75rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: .875rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition), transform var(--transition);
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 8px 16px rgba(37, 99, 235, .25);
    font-weight: 700;
}

.nav-link .nav-icon {
    font-size: 1.0625rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link .nav-text {
    opacity: 1;
    transition: opacity var(--transition);
    font-size: .875rem;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: 99px;
    transition: opacity var(--transition);
}

.sidebar.collapsed .nav-badge {
    opacity: 0;
}

.sidebar-footer {
    padding: 1rem .5rem;
    border-top: 1px solid var(--sidebar-border);
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed);
}

/* ---------- Navbar ---------- */
.navbar {
    height: var(--navbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    transition: all var(--transition);
}

[data-theme="dark"] .navbar {
    background: rgba(30, 41, 59, 0.85);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 1rem;
    transition: background var(--transition), color var(--transition);
    border: 1px solid var(--border);
}

.sidebar-toggle:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.navbar-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.navbar-subtitle {
    font-size: .75rem;
    color: var(--text-muted);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.navbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: .9375rem;
    border: 1px solid var(--border);
    transition: all var(--transition);
    position: relative;
}

.navbar-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.notif-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .375rem .75rem .375rem .375rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition);
}

.admin-profile:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.admin-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .8125rem;
    font-weight: 700;
    flex-shrink: 0;
}

.admin-info {
    display: flex;
    flex-direction: column;
}

.admin-name {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-role {
    font-size: .6875rem;
    color: var(--text-muted);
}

/* ---------- Page Content ---------- */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* ============================================================
   REUSABLE COMPONENTS
   ============================================================ */

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header-left h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.page-header-left p {
    font-size: .8125rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: .375rem;
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .25rem;
}

.breadcrumb a {
    color: var(--primary);
    transition: opacity var(--transition);
}

.breadcrumb a:hover {
    opacity: .75;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .625rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 600;
    transition: all var(--transition);
    border: 1.5px solid transparent;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, .4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, .3);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, .4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, .3);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(239, 68, 68, .4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: #fff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, .3);
}

.btn-warning:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(245, 158, 11, .4);
}

.btn-sm {
    padding: .4rem .75rem;
    font-size: .8125rem;
}

.btn-icon {
    padding: .5rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), border-color var(--transition), background var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.125rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.375rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: .06;
    transform: translate(20px, -20px);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: rgba(37, 99, 235, .12);
    color: var(--primary);
}

.stat-icon.green {
    background: rgba(16, 185, 129, .12);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, .12);
    color: var(--warning);
}

.stat-icon.purple {
    background: rgba(99, 102, 241, .12);
    color: var(--accent);
}

.stat-icon.cyan {
    background: rgba(6, 182, 212, .12);
    color: var(--info);
}

.stat-icon.red {
    background: rgba(239, 68, 68, .12);
    color: var(--danger);
}

.doc-action-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.doc-action-group:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.doc-action-group .btn {
    width: 100%;
    justify-content: center;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: .125rem;
    line-height: 1;
}

.stat-change {
    font-size: .75rem;
    margin-top: .375rem;
    display: flex;
    align-items: center;
    gap: .25rem;
}

.stat-change.up {
    color: var(--success);
}

.stat-change.down {
    color: var(--danger);
}

/* Tables */
.table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}

.table-toolbar-left {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.table-toolbar-right {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: .75rem;
    color: var(--text-muted);
    font-size: .85rem;
    pointer-events: none;
}

.search-input {
    padding: .5rem .75rem .5rem 2.25rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: .875rem;
    width: 220px;
    transition: all var(--transition);
}

.search-input:focus {
    border-color: var(--border-focus);
    width: 260px;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.filter-select {
    padding: .5rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: .875rem;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.data-table th {
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

.data-table tbody tr:last-child td {
    border-bottom: none;
}

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

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .625rem;
    border-radius: 99px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .03em;
}

.badge-success {
    background: rgba(16, 185, 129, .12);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, .12);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, .12);
    color: var(--warning);
}

.badge-info {
    background: rgba(6, 182, 212, .12);
    color: var(--info);
}

.badge-primary {
    background: rgba(37, 99, 235, .12);
    color: var(--primary);
}

.badge-accent {
    background: rgba(99, 102, 241, .12);
    color: var(--accent);
}

/* Action Buttons */
.action-btns {
    display: flex;
    align-items: center;
    gap: .375rem;
}

.action-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8125rem;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.action-btn.edit {
    background: rgba(37, 99, 235, .1);
    color: var(--primary);
    border-color: rgba(37, 99, 235, .2);
}

.action-btn.delete {
    background: rgba(239, 68, 68, .1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, .2);
}

.action-btn.view {
    background: rgba(6, 182, 212, .1);
    color: var(--info);
    border-color: rgba(6, 182, 212, .2);
}

.action-btn.edit:hover {
    background: var(--primary);
    color: #fff;
}

.action-btn.delete:hover {
    background: var(--danger);
    color: #fff;
}

.action-btn.view:hover {
    background: var(--info);
    color: #fff;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .375rem;
    letter-spacing: .02em;
}

.form-control {
    width: 100%;
    padding: .6875rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: .9rem;
    transition: all var(--transition);
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
    background: var(--bg-card);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: scale(.95) translateY(20px);
    transition: transform var(--transition);
}

.modal-overlay.open .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .875rem;
    transition: all var(--transition);
    border: 1px solid var(--border);
}

.modal-close:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

/* Dashboard Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chart-card .card-header {
    padding: 1rem 1.25rem;
}

.chart-body {
    padding: 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .4;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .375rem;
}

.empty-state p {
    font-size: .875rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .625rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: .875rem 1.125rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 280px;
    max-width: 380px;
    pointer-events: all;
    animation: slideInRight .35s ease, fadeOut .35s ease 3s forwards;
    border-left: 4px solid var(--primary);
    font-size: .875rem;
    color: var(--text-primary);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast i {
    font-size: 1rem;
    flex-shrink: 0;
}

.toast.success i {
    color: var(--success);
}

.toast.error i {
    color: var(--danger);
}

.toast.warning i {
    color: var(--warning);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* Attendance Grid */
.attendance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .875rem;
}

.attendance-item {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: .875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition);
}

.attendance-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.student-att-name {
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.student-att-roll {
    font-size: .75rem;
    color: var(--text-muted);
}

.att-toggle {
    display: flex;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.att-btn {
    padding: .3rem .6rem;
    font-size: .75rem;
    font-weight: 700;
    border: none;
    background: transparent;
    color: var(--text-muted);
    transition: all .15s;
    cursor: pointer;
}

.att-btn.present.active {
    background: var(--success);
    color: #fff;
}

.att-btn.absent.active {
    background: var(--danger);
    color: #fff;
}

/* Notice Cards */
.notices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.notice-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    position: relative;
    border-top: 4px solid var(--primary);
}

.notice-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.notice-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .75rem;
}

.notice-title {
    font-size: .9625rem;
    font-weight: 700;
    color: var(--text-primary);
}

.notice-date {
    font-size: .75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .25rem;
}

.notice-desc {
    font-size: .875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Timetable */
.timetable-wrapper {
    overflow-x: auto;
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.settings-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.settings-card-header h3 {
    font-size: .9625rem;
    font-weight: 700;
}

.settings-card-body {
    padding: 1.25rem;
}

/* Toggle Switch (Dark Mode) */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-track {
    width: 48px;
    height: 26px;
    background: var(--border);
    border-radius: 99px;
    position: relative;
    transition: background .25s;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    transition: transform .25s;
}

.toggle-switch input:checked+.toggle-track {
    background: var(--primary);
}

.toggle-switch input:checked+.toggle-track::after {
    transform: translateX(22px);
}

.toggle-label {
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: .8125rem;
}

.pagination-info {
    color: var(--text-muted);
}

.pagination-btns {
    display: flex;
    gap: .375rem;
}

.page-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8125rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all var(--transition);
    cursor: pointer;
}

.page-btn:hover,
.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: .4;
    pointer-events: none;
}

/* Loader */
.loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Profile Dropdown Menu */
.profile-dropdown-container {
    position: relative;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 1002;
    overflow: hidden;
    animation: slideDown .2s ease;
}

.profile-dropdown.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--transition);
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
    text-align: left;
}

.dropdown-item i {
    font-size: 1rem;
    color: var(--text-muted);
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-item:hover i {
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

.dropdown-item.logout {
    color: var(--danger);
}

.dropdown-item.logout i {
    color: var(--danger);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Section Tabs */
.tab-nav {
    display: flex;
    gap: .25rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: .25rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    transition: all var(--transition);
    cursor: pointer;
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
}

/* Avatar Initials */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .8125rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ============================================================
   RESPONSIVE — MOBILE & TABLET (CONSOLIDATED)
   ============================================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        position: fixed;
        height: 100vh;
        z-index: 1001;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        width: 100vw !important;
        max-width: 100vw;
    }

    .navbar-title {
        font-size: .95rem;
        max-width: 140px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 768px) {
    .page-content {
        padding: 1rem;
    }

    .navbar {
        padding: 0 .75rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .charts-grid,
    .form-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .navbar-date,
    .admin-info {
        display: none;
    }
}

@media (max-width: 480px) {
    .navbar-title {
        max-width: 120px;
        font-size: .875rem;
    }

    .navbar-subtitle {
        display: none;
    }

    .navbar-btn {
        width: 32px;
        height: 32px;
        font-size: .8rem;
    }

    .sidebar-toggle {
        width: 32px;
        height: 32px;
    }

    .admin-profile {
        padding: .2rem;
        border: none;
        background: transparent;
    }

    .admin-avatar {
        width: 28px;
        height: 28px;
        font-size: .75rem;
    }

    .admin-profile i {
        display: none;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: .75rem;
        margin-bottom: 1.25rem;
    }

    .page-header h2 {
        font-size: 1.25rem;
    }

    .page-header-right {
        width: 100%;
        flex-direction: column;
    }

    .page-header-right .btn {
        width: 100%;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        max-width: 96vw;
        margin: 0.5rem;
        max-height: 94vh;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ---- Action Buttons (Common in Tables) ---- */
.action-btns {
    display: flex;
    align-items: center;
    gap: .375rem;
    flex-wrap: nowrap;
}

.action-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: .8rem;
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all var(--transition);
    cursor: pointer;
}

.action-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.action-btn.edit:hover {
    background: var(--info);
    border-color: var(--info);
}

.action-btn.delete:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* ---- Component Helpers ---- */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    border-radius: var(--radius-lg);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.page-header-right {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.info-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}

.info-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    width: 120px;
    flex-shrink: 0;
}

.portal-sidebar {
    background: var(--sidebar-bg);
}