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

/* =========================================================================
   QS-Exams Unified Premium Dashboard Style Sheet
   Brand: Navy Blue (#00008B) + Red (#FF0000) | Version 2.0 Enhanced
   ========================================================================= */

:root {
    /* Brand & Role Colors */
    --primary: #00008b;
    --primary-dark: #00005a;
    --primary-light: #2020a8;
    --accent: #ff0000;
    --accent-dark: #dc2626;
    --success: #10b981;
    --warning: #F59E0B;
    --warning-dark: #D97706;
    --danger: #ef4444;
    --info: #3b82f6;
    --purple: #00008b;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --bg-light: #f1f5f9;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    
    /* Global Spacing Grid System */
    --space-xs: 8px;    /* Micro spacings, badges, inner items */
    --space-sm: 16px;   /* Small margins, list gap, input padding */
    --space-md: 24px;   /* Main grid gaps, card padding, sections margin */
    --space-lg: 32px;   /* Topbar margins, content main bounds */
    
    /* Modern Premium Border Radius System */
    --radius: 12px;     /* Core panels, KPI cards, large modals */
    --radius-sm: 8px;   /* Inputs, buttons, status badges, small elements */

    /* Global Shadows */
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    
    /* Layout Dimensions */
    --sidebar-width: 270px;
    
    /* Gradient Palettes */
    --grad-primary: linear-gradient(135deg, #00008b 0%, #00005a 100%);
    --grad-accent: linear-gradient(135deg, #ff0000 0%, #dc2626 100%);
    --grad-success: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --grad-warning: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    --grad-info: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
    --grad-purple: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    --grad-hero: linear-gradient(135deg, #00005a 0%, #00008b 50%, #2020a8 100%);
    
    /* Dashboard Variables default fallback */
    --role-primary: #00008b;
    --role-accent: #00005a;
    --role-grad: linear-gradient(135deg, #00008b, #00005a);
    --role-grad-hero: linear-gradient(135deg, #00005a, #00008b 50%, #2020a8);
    --gradient-primary: var(--grad-primary);
    --gradient-accent: var(--grad-accent);
    --gradient-hero: var(--grad-hero);
    --card-bg: var(--bg-card);
}

/* Base Body Font Reset (Accessiblity Standard) */
body {
    font-family: 'Inter', 'Open Sans', 'Lato', -apple-system, sans-serif !important;
    background-color: var(--bg-light);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
}

/* Role Specific Dashboard Theming */
body.role-institute_admin,
body.role-instructor,
body.role-student,
body.role-superadmin {
    --role-primary: #00008b;
    --role-accent: #00005a;
    --role-grad: linear-gradient(135deg, #00008b, #00005a);
    --role-grad-hero: linear-gradient(135deg, #00005a, #00008b 50%, #2020a8);
}

/* User & Operator Role Badges */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.role-badge.r-superadmin {
    background: rgba(139, 92, 246, 0.12);
    color: #2020a8;
    border: 1px solid rgba(139, 92, 246, 0.25);
}
.role-badge.r-institute {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}
.role-badge.r-instructor {
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.15);
}
.role-badge.r-student {
    background: rgba(244, 145, 74, 0.08);
    color: #ff0000;
    border: 1px solid rgba(244, 145, 74, 0.15);
}

/* =========================================================================
   Sidebar Layout & Navigation Node
   ========================================================================= */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--role-grad, var(--grad-primary));
    color: #fff;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.1);
}
.sidebar-brand {
    padding: 25px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 90px;
    flex-shrink: 0;
    gap: 14px;
}
.sidebar-logo-img {
    height: 36px;
    width: 36px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.sidebar-brand-text {
    line-height: 1.2;
}
.sidebar-brand-text strong {
    display: block;
    font-size: 1.05rem;
    font-weight: 850;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.sidebar-brand-text span {
    font-size: 0.65rem;
    font-weight: 700;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-user {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.15);
    margin: 15px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.sidebar-avatar, .sidebar-avatar-fallback {
    width: 42px;
    height: 42px;
    border-radius: 50% !important; /* Forces perfect circle for avatars */
    flex-shrink: 0;
}
.sidebar-avatar {
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}
.sidebar-avatar-fallback {
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
}
.sidebar-user-text {
    line-height: 1.3;
}
.sidebar-user-text strong {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
}
.sidebar-user-text span {
    font-size: 0.72rem;
    opacity: 0.6;
    font-weight: 500;
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
}
.sidebar-section-label {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.3);
    margin: 18px 0 8px 12px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
}
.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
.sidebar-link.active {
    background: #fff;
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.sidebar-link .nav-icon {
    width: 20px;
    font-size: 1rem;
    text-align: center;
    opacity: 0.8;
}
.sidebar-link.active .nav-icon {
    color: var(--primary);
    opacity: 1;
}
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.sidebar-footer a:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}
.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    margin: 8px 12px 2px 12px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    user-select: none;
}
.sidebar-section-header:hover {
    background: rgba(255, 255, 255, 0.08);
}
.sidebar-section-title {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.6);
}
.sidebar-section-header.active .sidebar-section-title {
    color: #fff;
}
.sidebar-section-header i.chevron {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    transition: transform 0.3s ease;
}
.sidebar-section-header.active i.chevron {
    transform: rotate(180deg);
    color: #fff;
}
.sidebar-submenu {
    display: none;
    flex-direction: column;
    padding-left: 8px;
    margin-bottom: 5px;
}
.sidebar-submenu.show {
    display: flex;
    animation: fadeInDown 0.3s ease-out forwards;
}

/* =========================================================================
   Topbar sticky grid standard
   ========================================================================= */

.topbar {
    height: 72px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}
.topbar-title-section {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}
.topbar-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-title i {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 139, 0.08);
    color: var(--role-primary, var(--primary));
    border-radius: var(--radius-sm);
    font-size: 1rem;
    flex-shrink: 0;
}
.topbar-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}
.sidebar-toggle-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: #f1f5f9;
    color: var(--text-dark);
    border: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}
.sidebar-toggle-btn:hover {
    background: #e2e8f0;
}

/* =========================================================================
   Main Dashboard Layout Grid
   ========================================================================= */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}
.content-area {
    padding: var(--space-md) var(--space-lg);
    flex: 1;
    background: var(--bg-light);
    max-width: 1600px;
}

/* Top Dashboard Banner Widget */
.dash-hero {
    background: var(--role-grad-hero, var(--grad-hero));
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-lg);
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-bottom: var(--space-md);
    min-height: 140px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
}
.dash-hero::before {
    content: '';
    position: absolute;
    right: -40px;
    bottom: -40px;
    width: 220px;
    height: 220px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50% !important; /* Clean circle overlay */
}
.dash-hero::after {
    content: '';
    position: absolute;
    right: 120px;
    top: -50px;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 50% !important;
}
.dash-hero-inner {
    flex: 1;
    position: relative;
    z-index: 1;
}
.dash-hero-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.7rem;
    font-weight: 800;
    margin: 0 0 6px;
    letter-spacing: -0.5px;
}
.dash-hero-sub {
    font-size: 0.9rem;
    opacity: 0.82;
    margin: 0;
}
.dash-hero-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.dash-hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
}

/* =========================================================================
   KPI Metrics Cards grid
   ========================================================================= */

.kpi-grid {
    display: grid;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-6 { grid-template-columns: repeat(6, 1fr); }

.kpi-card {
    background: #fff;
    border-radius: var(--radius);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.kpi-card::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--kpi-color, var(--primary));
}
.kpi-card:hover {
    text-decoration: none;
    color: inherit;
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}
.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    background: var(--kpi-bg, rgba(91, 33, 182, 0.1));
    color: var(--kpi-color, var(--primary));
}
.kpi-info {
    flex: 1;
    min-width: 0;
}
.kpi-value {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1;
}
.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.kpi-trend {
    font-size: 0.72rem;
    margin-top: 2px;
    font-weight: 600;
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

.kpi-value[data-count] {
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

/* =========================================================================
   Standard dashboard cards & panels
   ========================================================================= */

.card,
.panel-card,
.data-table-card {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    background: #fff !important;
    margin-bottom: var(--space-md);
    overflow: hidden;
}
.card-header,
.panel-card-header,
.data-table-header {
    background: linear-gradient(135deg, #f8faff, #fff) !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 14px 20px !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h6,
.panel-card-header h6,
.data-table-header h6 {
    margin: 0;
    font-weight: 700;
    color: var(--text-dark);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
}
.card-body,
.panel-card-body,
.data-table-body,
.dash-panel-body {
    padding: var(--space-md);
}

.dash-panel-body-flush {
    padding: 0;
}

/* KPI Panels */
.dash-panel {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: var(--space-md);
}
.dash-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #f0f4ff, #fff);
}
.dash-panel-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.94rem;
    color: var(--text-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dash-panel-title i {
    color: var(--role-accent, var(--accent));
}

/* =========================================================================
   Styled Dashboard Grid Tables (Desk & Mob layouts)
   ========================================================================= */

.dash-table, .table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.dash-table thead th, .table thead th {
    background: #f0f4ff;
    padding: 12px var(--space-sm);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.dash-table tbody td, .table tbody td {
    padding: 12px var(--space-sm);
    font-size: 0.84rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.dash-table tbody tr:last-child td, .table tbody tr:last-child td {
    border-bottom: none;
}
.dash-table tbody tr:hover, .table tbody tr:hover {
    background: #f0f4ff;
}

/* =========================================================================
   Responsive Flex Control buttons
   ========================================================================= */

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.qa-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}
.qa-btn-primary {
    background: var(--role-grad, var(--grad-primary));
    color: #fff;
    box-shadow: 0 4px 14px rgba(91, 33, 182, 0.25);
}
.qa-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(91, 33, 182, 0.35);
    color: #fff;
}
.qa-btn-accent {
    background: var(--grad-accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(255, 107, 53, 0.25);
}
.qa-btn-accent:hover {
    transform: translateY(-2px);
    color: #fff;
}
.qa-btn-outline {
    background: #f8fafc;
    border-color: var(--border);
    color: var(--text-dark);
}
.qa-btn-outline:hover {
    background: var(--bg-light);
    border-color: var(--text-muted);
    color: var(--text-dark);
}
.qa-btn-success { background: var(--grad-success); color: #fff; }
.qa-btn-warning { background: var(--grad-warning); color: #fff; }
.qa-btn-info { background: var(--grad-info); color: #fff; }
.qa-btn-purple { background: var(--grad-purple); color: #fff; }
.qa-btn-danger { background: linear-gradient(135deg, #dc2626, #ff0000); color: #fff; }

.btn-primary-custom {
    background: var(--grad-primary);
    color: #fff !important;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-weight: 700;
    font-size: 0.88rem;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(91,33,182,0.3);
    color: #fff !important;
}

/* Micro Action Buttons in Tables */
.action-btn {
    min-width: 28px;
    min-height: 28px;
    width: auto;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    text-decoration: none !important;
}
.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.action-btn-primary { background: rgba(0, 0, 139, 0.08); color: var(--primary); }
.action-btn-success { background: rgba(16, 185, 129, 0.1); color: #059669; }
.action-btn-warning { background: rgba(245, 158, 11, 0.1); color: #D97706; }
.action-btn-danger  { background: rgba(239,  68,  68, 0.1); color: #dc2626; }
.action-btn-info    { background: rgba( 14, 165, 233, 0.1); color: #0284c7; }
.action-btn i { font-size: 0.95rem; }

.action-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* =========================================================================
   Accessibility-compliant high contrast status badges
   ========================================================================= */

.status-badge, .badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
}
.status-active, .status-pass, .badge-active {
    background: #f0fdf4;
    color: #15803d; /* Darkened for accessibility WCAG AA compliance */
    border: 1px solid #bbf7d0;
}
.status-pending, .badge-pending {
    background: #fffbeb;
    color: #a16207;
    border: 1px solid #fde68a;
}
.status-inactive {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
}
.status-fail {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.status-live {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    animation: pulse-badge 2s infinite;
}

/* =========================================================================
   Interactive Forms Elements
   ========================================================================= */

.form-control, .form-select {
    border-radius: var(--radius-sm) !important;
    padding: 10px 14px;
    border: 1.5px solid var(--border) !important;
    transition: all 0.2s;
    font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(0, 0, 139, 0.1) !important;
    outline: none;
}
.form-control-sm, .form-select-sm {
    height: 36px !important;
    border-radius: var(--radius-sm) !important;
    padding: 0 14px !important;
    font-size: 0.82rem !important;
    border: 1.5px solid var(--border) !important;
    background-color: #f8fafc !important;
}
.form-control-sm:focus, .form-select-sm:focus {
    background-color: #fff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(0, 0, 139, 0.1) !important;
}

/* =========================================================================
   Modals & dialog cards design
   ========================================================================= */

.modal-content {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    background: linear-gradient(135deg, var(--role-primary), var(--role-accent));
    color: #fff;
    border-bottom: none;
    padding: 20px 24px;
}
.modal-header .modal-title {
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
}
.modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    border-top: 1px solid #f1f5f9;
    padding: 16px 24px;
    background: #f8fafc;
}

/* Alerts panel */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.alert-success { background: #ecfdf5 !important; color: #065f46 !important; border-left: 4px solid #10b981 !important; }
.alert-danger  { background: #fef2f2 !important; color: #991b1b !important; border-left: 4px solid #ef4444 !important; }
.alert-warning { background: #fffbeb !important; color: #92400e !important; border-left: 4px solid #F59E0B !important; }
.alert-info    { background: #eff6ff !important; color: #1e40af !important; border-left: 4px solid #3b82f6 !important; }
.alert .btn-close { opacity: 0.6; }

/* =========================================================================
   Filter topbar & widget components
   ========================================================================= */

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.filter-search-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 280px;
}
.filter-search-wrap i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
    pointer-events: none;
}
.filter-search-wrap input[type=text], .filter-bar input[type=text] {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 34px;
    font-size: 13px;
    outline: none;
    background: #fff;
    transition: border-color 0.2s;
}
.filter-search-wrap input[type=text]:focus, .filter-bar input[type=text]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.08);
}
.filter-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 13px;
    background: #fff;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    height: 40px;
}
.filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.08);
}
.filter-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

/* =========================================================================
   Interactive grid components & templates
   ========================================================================= */

.exam-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    position: relative;
    overflow: hidden;
}
.exam-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}
.exam-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--grad-primary);
}

.btn-accent {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    background: var(--grad-accent);
    color: #78350f;
    border: none;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(251, 191, 36, 0.3);
    white-space: nowrap;
}
.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(251, 191, 36, 0.4);
    color: #451a03;
    text-decoration: none;
}

/* Active Se seating list */
.ac-list-item {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}
.ac-list-item:hover {
    background: #f0f4ff;
}
.ac-list-index {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 139, 0.1);
    color: var(--primary);
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ac-list-meta span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-weight: 500;
}
.ac-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

/* =========================================================================
   General helper nodes
   ========================================================================= */

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.18s;
}
.icon-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* =========================================================================
   PHASE 1: PREMIUM UI UPGRADES (Glassmorphism & animations)
   ========================================================================= */

.glass-panel {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    border-radius: var(--radius) !important;
}

.depth-shadow {
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1), 
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

.accent-glow-amber {
    box-shadow: 0 10px 30px -10px rgba(245, 158, 11, 0.4);
}

.accent-glow-purple {
    box-shadow: 0 10px 30px -10px rgba(91, 33, 182, 0.3);
}

.ai-pulse-ring {
    position: relative;
    overflow: hidden;
}

.ai-pulse-ring::after {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    z-index: -1;
    filter: blur(8px);
    opacity: 0.4;
    animation: ai-pulse 3s infinite ease-in-out;
}

@keyframes ai-pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.02); opacity: 0.6; }
}

.reveal-card {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.reveal-card.visible {
    opacity: 1;
    transform: translateY(0);
}

/* AI FEATURED BUTTONS */
.btn-ai {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 18px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 700;
    text-decoration: none; border: none; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer; color: white !important; box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    position: relative; overflow: hidden;
}
.btn-ai:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.25); filter: brightness(1.1); }
.btn-ai i { font-size: 1rem; }

/* 1. Results Analysis (Oceanic Blue/Purple) */
.btn-ai-insight { background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%); }

/* 2. Question Refinement (Amber/Deep Orange) */
.btn-ai-refine { background: linear-gradient(135deg, #FF0000 0%, #ea580c 100%); }

/* 3. Paper Suggestion (Emerald/Bright Green) */
.btn-ai-blueprint { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }

/* 4. Dashboard Briefing (Royal Purple/Magenta) */
.btn-ai-brief {
    background: linear-gradient(135deg, #2020a8 0%, #db2777 100%);
    padding: 4px 12px; font-size: 0.72rem;
}

/* INSTITUTE ADMIN AI BUTTONS (Emerald/Teal Theme) */
.btn-ai-audit { background: linear-gradient(135deg, #10b981 0%, #064e3b 100%); }
.btn-ai-forensic { background: linear-gradient(135deg, #14b8a6 0%, #0f172a 100%); }
.btn-ai-strategy {
    background: linear-gradient(135deg, #bef264 0%, #16a34a 100%);
    color: #064e3b !important;
}

/* Enhanced Glow & Precision */
.btn-ai {
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}
.btn-ai-audit { box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
.btn-ai-forensic { box-shadow: 0 4px 15px rgba(20, 184, 166, 0.3); }
.btn-ai-strategy { box-shadow: 0 4px 15px rgba(163, 230, 53, 0.3); }

/* AI Sparkle Icon Animation */
@keyframes sparkle-spin {
    0% { transform: rotate(0deg) scale(1); opacity: 0.8; }
    50% { transform: rotate(180deg) scale(1.2); opacity: 1; }
    100% { transform: rotate(360deg) scale(1); opacity: 0.8; }
}
.fa-sparkles.anim {
    animation: sparkle-spin 3s infinite linear;
}

/* =========================================================================
   Mobile-First Layout Responsiveness Media Node
   ========================================================================= */

@media (max-width: 1200px) {
    .kpi-grid-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
    .dash-grid-6-6, .dash-grid-7-5, .dash-grid-8-4 { grid-template-columns: 1fr; }
    .dash-grid-4-4-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 992px) {
    .main-content { margin-left: 0 !important; }
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,0.2); }
    .sidebar-toggle-btn { display: flex !important; }
}

@media (max-width: 900px) {
    .kpi-grid-3, .kpi-grid-4, .kpi-grid-6 { grid-template-columns: repeat(2, 1fr); }
    .kpi-grid[style*="repeat(5"] { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 768px) {
    .content-area { padding: var(--space-sm) !important; }
    .kpi-grid { gap: var(--space-sm); }
    .topbar { height: 64px; padding: 0 var(--space-sm); }
    .topbar-actions { gap: 6px !important; }
    .topbar-btn { width: 34px !important; height: 34px !important; }
}

@media (max-width: 640px) {
    .dash-hero { flex-direction: column; gap: 16px; align-items: flex-start; text-align: left; }
    .dash-hero::before, .dash-hero::after { display: none; } /* Hide heavy float shapes to save mobile space */
    .dash-hero-actions, .ac-list-actions { width: 100%; }
    .ac-list-item { flex-wrap: wrap; gap: 12px; padding: 16px; }
    .ac-list-actions { justify-content: flex-end; }
}

@media (max-width: 480px) {
    .kpi-grid-3 { grid-template-columns: 1fr; }
    .kpi-grid-4, .kpi-grid-6 { grid-template-columns: 1fr; }
}

/* =========================================================================
   Global Print Media Hacks & AI floating element cleanup
   ========================================================================= */

@media print {
    #globalLoader, #sidebar, .no-print, .sidebar, .sidebar-backdrop, .topbar {
        display: none !important;
        visibility: hidden !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .content-area {
        padding: 0 !important;
        background: none !important;
    }
    #aiFab, #aiChat, .ai-fab, .ai-chat-window, 
    #qs-assistant-fab, #qs-assistant-window, 
    .qs-assistant-fab, .qs-assistant-window,
    #aiInsightModal, .ai-insight-card,
    .no-print, [class*="ai-chat"], [id*="aiChat"], [class*="qs-assistant"], [id*="qs-assistant"],
    .qsa-toggle, .qsa-container, [class*="qsa-"] {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}
