
/*!
 * Bontroff SchoolOS — Complete Shared Application Stylesheet
 * File: assets/css/app.css
 * Framework: Bootstrap 5.3
 * Theme: Red SaaS Pro
 * Features:
 * - Responsive application layout
 * - Sidebar and nested dropdown navigation
 * - Mobile sidebar overlay
 * - Light and dark themes
 * - Dashboard and analytics
 * - Forms, tables, cards and buttons
 * - Learners, staff, academics and CBC
 * - Attendance, assessments and results
 * - Finance, invoices, payments and statements
 * - Library, documents and communications
 * - Settings, permissions and audit logs
 * - Print and PDF layouts
 */

/* =========================================================
   1. THEME VARIABLES
   ========================================================= */

:root {
    color-scheme: light;

    --school-red: #b42332;
    --school-red-dark: #891b27;
    --school-red-soft: #fff0f1;
    --school-red-border: #f3c8cd;

    --school-ink: #242936;
    --school-muted: #737b8c;
    --school-bg: #f5f6fa;
    --school-border: #e8eaf0;
    --school-sidebar: #ffffff;
    --school-card: #ffffff;

    --school-green: #198754;
    --school-green-soft: #e9f7ef;
    --school-blue: #0d6efd;
    --school-blue-soft: #eaf2ff;
    --school-orange: #f28c28;
    --school-orange-soft: #fff4e8;
    --school-purple: #7952b3;
    --school-purple-soft: #f2ebfc;
    --school-cyan: #0f9fb5;
    --school-cyan-soft: #e5f8fb;
    --school-yellow: #f5c542;
    --school-yellow-soft: #fff9df;
    --school-danger: #dc3545;

    --school-radius: 14px;
    --school-radius-sm: 9px;
    --school-radius-lg: 20px;

    --school-sidebar-width: 258px;
    --school-sidebar-collapsed-width: 76px;
    --school-topbar-height: 68px;

    --school-shadow: 0 5px 20px rgba(35, 42, 58, .055);
    --school-shadow-lg: 0 15px 45px rgba(35, 42, 58, .12);

    --school-transition: 180ms ease;

    /* Compatibility variables */
    --app-bg: var(--school-bg);
    --surface: var(--school-card);
    --surface-muted: #f8f9fc;
    --text-primary: var(--school-ink);
    --text-secondary: var(--school-muted);
    --border-color: var(--school-border);
    --input-bg: var(--school-card);
    --table-header-bg: #f7f8fb;
    --hover-bg: #f8f0f1;
    --shadow-color: rgba(35, 42, 58, .08);
    --brand-red: var(--school-red);
    --brand-red-dark: var(--school-red-dark);

    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--text-primary);
    --bs-border-color: var(--border-color);
    --bs-primary: var(--school-red);
    --bs-primary-rgb: 180, 35, 50;
    --bs-link-color: var(--school-red);
    --bs-link-hover-color: var(--school-red-dark);
}

/* =========================================================
   2. DARK THEME
   ========================================================= */

html[data-theme="dark"],
body[data-theme="dark"],
html.dark-mode,
body.dark-mode,
.dark-mode {
    color-scheme: dark;

    --school-red: #f16b78;
    --school-red-dark: #ff929c;
    --school-red-soft: #3a2026;
    --school-red-border: #68313a;

    --school-ink: #edf0f7;
    --school-muted: #a4adbd;
    --school-bg: #11141b;
    --school-border: #303644;
    --school-sidebar: #191e28;
    --school-card: #1b202b;

    --school-green: #48c78e;
    --school-green-soft: #18372c;
    --school-blue: #6ea8fe;
    --school-blue-soft: #1d2e49;
    --school-orange: #ffad60;
    --school-orange-soft: #402c1e;
    --school-purple: #bd9af5;
    --school-purple-soft: #30233f;
    --school-cyan: #67d5e5;
    --school-cyan-soft: #17353a;
    --school-yellow: #ffdc73;
    --school-yellow-soft: #3c351c;
    --school-danger: #ff7885;

    --school-shadow: 0 5px 20px rgba(0, 0, 0, .18);
    --school-shadow-lg: 0 15px 45px rgba(0, 0, 0, .35);

    --app-bg: var(--school-bg);
    --surface: var(--school-card);
    --surface-muted: #202633;
    --text-primary: var(--school-ink);
    --text-secondary: var(--school-muted);
    --border-color: var(--school-border);
    --input-bg: #202633;
    --table-header-bg: #222936;
    --hover-bg: #30242a;
    --shadow-color: rgba(0, 0, 0, .2);
    --brand-red: var(--school-red);
    --brand-red-dark: var(--school-red-dark);

    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--text-primary);
    --bs-border-color: var(--border-color);
    --bs-primary: var(--school-red);
    --bs-primary-rgb: 241, 107, 120;
    --bs-link-color: var(--school-red);
    --bs-link-hover-color: var(--school-red-dark);
}

/* =========================================================
   3. RESET AND GLOBAL ELEMENTS
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 90px;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--app-bg);
    color: var(--text-primary);
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--school-transition),
                color var(--school-transition);
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

img {
    height: auto;
}

a {
    color: var(--school-red);
    text-decoration: none;
    transition: color var(--school-transition);
}

a:hover {
    color: var(--school-red-dark);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    transition: background-color var(--school-transition),
                border-color var(--school-transition),
                color var(--school-transition),
                box-shadow var(--school-transition);
}

:focus-visible {
    outline: 3px solid rgba(180, 35, 50, .35);
    outline-offset: 2px;
}

::selection {
    color: #fff;
    background: var(--school-red);
}

hr {
    border-color: var(--border-color);
    opacity: 1;
}

small,
.small {
    color: inherit;
}

.text-muted,
.text-secondary {
    color: var(--text-secondary) !important;
}

.text-primary {
    color: var(--school-red) !important;
}

.bg-primary {
    background-color: var(--school-red) !important;
}

.border {
    border-color: var(--border-color) !important;
}

.shadow-sm {
    box-shadow: var(--school-shadow) !important;
}

.min-width-0 {
    min-width: 0 !important;
}

.text-break {
    overflow-wrap: anywhere;
}

.cursor-pointer {
    cursor: pointer;
}

.w-fit {
    width: fit-content;
}

/* =========================================================
   4. APPLICATION SHELL
   Supports actual layout.php class names.
   ========================================================= */

.school-app,
.app-shell,
.app-layout {
    min-height: 100vh;
    background: var(--app-bg);
}

.school-main,
.app-main,
.main-wrapper,
.schoolos-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--school-sidebar-width);
    transition: margin-left var(--school-transition);
}

.school-content,
.app-content,
.main-content,
.pos-content,
.schoolos-content {
    flex: 1 0 auto;
    width: 100%;
    min-width: 0;
    padding: 24px;
}

.school-content > :first-child,
.app-content > :first-child,
.main-content > :first-child,
.schoolos-content > :first-child {
    margin-top: 0;
}

.school-content > :last-child,
.app-content > :last-child,
.main-content > :last-child,
.schoolos-content > :last-child {
    margin-bottom: 0;
}

.container-fluid {
    width: 100%;
}

.container-fluid.school-container {
    padding-right: 0;
    padding-left: 0;
}

.content-wrapper {
    width: 100%;
    max-width: 1800px;
    margin-right: auto;
    margin-left: auto;
}

.module-container {
    width: 100%;
    min-width: 0;
}

.module-section {
    margin-bottom: 24px;
}

/* =========================================================
   5. SIDEBAR
   ========================================================= */

.school-sidebar,
.app-sidebar,
.sidebar {
    position: fixed;
    z-index: 1040;
    top: 0;
    bottom: 0;
    left: 0;

    display: flex;
    flex-direction: column;

    width: var(--school-sidebar-width);
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;

    overflow-x: hidden;
    overflow-y: auto;

    color: var(--text-primary);
    background: var(--school-sidebar);
    border-right: 1px solid var(--border-color);

    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;

    transition: transform var(--school-transition),
                width var(--school-transition),
                background-color var(--school-transition);
}

.school-sidebar::-webkit-scrollbar,
.app-sidebar::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.school-sidebar::-webkit-scrollbar-thumb,
.app-sidebar::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.school-brand,
.sidebar-brand,
.app-brand {
    position: sticky;
    top: 0;
    z-index: 2;

    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 11px;

    min-height: 74px;
    padding: 16px 18px;

    color: var(--text-primary);
    background: var(--school-sidebar);
    border-bottom: 1px solid var(--border-color);
}

.school-brand:hover,
.sidebar-brand:hover,
.app-brand:hover {
    color: var(--text-primary);
}

.school-brand img,
.sidebar-brand img,
.app-brand img,
.brand-logo {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 10px;
}

.brand-name,
.school-brand-name {
    display: block;
    overflow: hidden;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-subtitle {
    display: block;
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 11px;
}

.sidebar-body {
    flex: 1;
    padding: 12px 10px 20px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-section,
.nav-section {
    min-width: 0;
    margin: 5px 0;
}

.sidebar-section-label,
.nav-section-label,
.sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    width: 100%;
    padding: 11px 12px 7px;

    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .09em;
    line-height: 1.4;
    text-transform: uppercase;
}

button.sidebar-section-label,
button.nav-section-label {
    text-align: left;
    cursor: pointer;
    background: transparent;
    border: 0;
}

.sidebar-section-label:hover,
.nav-section-label:hover {
    color: var(--school-red);
}

.sidebar-section-label .section-chevron,
.nav-section-label .section-chevron {
    flex-shrink: 0;
    transition: transform var(--school-transition);
}

.sidebar-section-label[aria-expanded="true"] .section-chevron,
.nav-section-label[aria-expanded="true"] .section-chevron {
    transform: rotate(180deg);
}

/* Actual sidebar.php dropdown controls */

.sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;

    width: 100%;
    min-height: 40px;
    padding: 10px 12px;

    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 9px;

    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    line-height: 1.4;
    text-align: left;
    text-transform: uppercase;

    cursor: pointer;
}

.sidebar-section-toggle:hover {
    color: var(--school-red);
    background: var(--hover-bg);
}

.sidebar-section-toggle[aria-expanded="true"] {
    color: var(--school-red);
}

.sidebar-section-toggle .section-chevron,
.sidebar-section-toggle i {
    flex-shrink: 0;
    transition: transform var(--school-transition);
}

.sidebar-section-toggle[aria-expanded="true"] .section-chevron {
    transform: rotate(180deg);
}

/* Sidebar dropdown content */

.sidebar-section-items,
.sidebar-submenu,
.nav-section-items,
.sidebar-section-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.sidebar-section-content {
    padding: 3px 0 5px;
}

.sidebar-section-items[hidden],
.sidebar-submenu[hidden],
.nav-section-items[hidden],
.sidebar-section-content[hidden] {
    display: none !important;
}

/* Sidebar links */

.sidebar-link,
.sidebar-nav a,
.app-sidebar .nav-link,
.school-sidebar .nav-link {
    position: relative;

    display: flex;
    align-items: center;
    gap: 11px;

    min-width: 0;
    min-height: 42px;
    padding: 10px 12px;

    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;

    border-radius: 9px;

    transition: color var(--school-transition),
                background-color var(--school-transition);
}

.sidebar-link i,
.sidebar-link > svg,
.sidebar-link .nav-icon,
.sidebar-nav a i,
.app-sidebar .nav-link i,
.school-sidebar .nav-link i {
    display: inline-flex;
    flex: 0 0 20px;
    align-items: center;
    justify-content: center;
    width: 20px;
    min-width: 20px;
    font-size: 16px;
}

.sidebar-link .link-label,
.sidebar-link .nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-link:hover,
.sidebar-nav a:hover,
.app-sidebar .nav-link:hover,
.school-sidebar .nav-link:hover {
    color: var(--school-red);
    background: var(--hover-bg);
}

.sidebar-link.active,
.sidebar-nav a.active,
.app-sidebar .nav-link.active,
.school-sidebar .nav-link.active,
.sidebar-link[aria-current="page"] {
    color: var(--school-red);
    font-weight: 700;
    background: var(--school-red-soft);
}

.sidebar-link.active::before,
.sidebar-nav a.active::before,
.sidebar-link[aria-current="page"]::before {
    position: absolute;
    top: 9px;
    bottom: 9px;
    left: 0;
    width: 3px;
    content: "";
    background: var(--school-red);
    border-radius: 0 4px 4px 0;
}

.sidebar-section-content .sidebar-link {
    min-height: 39px;
    padding: 9px 12px 9px 20px;
    font-size: 12px;
}

.sidebar-section-content .sidebar-link.active,
.sidebar-section-content .sidebar-link[aria-current="page"] {
    color: var(--school-red);
    background: var(--school-red-soft);
    font-weight: 700;
}

.sidebar-badge,
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    padding: 2px 6px;
    margin-left: auto;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    background: var(--school-red);
    border-radius: 20px;
}

.sidebar-divider {
    height: 1px;
    margin: 12px 10px;
    background: var(--border-color);
}

.sidebar-user,
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 14px;
    background: var(--school-sidebar);
    border-top: 1px solid var(--border-color);
}

.sidebar-user-avatar,
.user-avatar,
.profile-avatar {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: var(--school-red);
    font-weight: 800;
    background: var(--school-red-soft);
    border-radius: 50%;
}

.sidebar-user-name {
    overflow: hidden;
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    color: var(--text-secondary);
    font-size: 11px;
}

/* =========================================================
   6. COLLAPSED SIDEBAR
   ========================================================= */

body.sidebar-collapsed .school-sidebar,
body.sidebar-collapsed .app-sidebar,
body.sidebar-collapsed .sidebar {
    width: var(--school-sidebar-collapsed-width);
}

body.sidebar-collapsed .school-main,
body.sidebar-collapsed .app-main,
body.sidebar-collapsed .main-wrapper,
body.sidebar-collapsed .schoolos-main {
    margin-left: var(--school-sidebar-collapsed-width);
}

body.sidebar-collapsed .school-brand .brand-name,
body.sidebar-collapsed .school-brand .brand-subtitle,
body.sidebar-collapsed .sidebar-brand .brand-name,
body.sidebar-collapsed .sidebar-section-label .section-title,
body.sidebar-collapsed .sidebar-link .link-label,
body.sidebar-collapsed .sidebar-user .sidebar-user-info {
    display: none;
}

body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-section-toggle {
    justify-content: center;
    padding-right: 5px;
    padding-left: 5px;
    font-size: 0;
}

body.sidebar-collapsed .sidebar-section-toggle .section-chevron {
    display: none;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding-right: 5px;
    padding-left: 5px;
}

body.sidebar-collapsed .sidebar-link i {
    flex-basis: 22px;
}

/* Keep hidden dropdowns hidden when sidebar is collapsed */

body.sidebar-collapsed .sidebar-section-items,
body.sidebar-collapsed .sidebar-section-content {
    display: flex;
}

body.sidebar-collapsed .sidebar-section-items[hidden],
body.sidebar-collapsed .sidebar-section-content[hidden] {
    display: none !important;
}

body.sidebar-collapsed .sidebar-section-content .sidebar-link .link-label {
    display: none;
}

/* =========================================================
   7. MOBILE SIDEBAR AND OVERLAY
   ========================================================= */

.sidebar-overlay,
.school-sidebar-overlay,
.app-sidebar-overlay {
    position: fixed;
    z-index: 1035;
    inset: 0;
    visibility: hidden;
    background: rgba(10, 14, 23, .55);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--school-transition),
                visibility var(--school-transition);
}

.sidebar-overlay.show,
.sidebar-overlay.active,
.sidebar-overlay.is-visible,
.school-sidebar-overlay.show,
.app-sidebar-overlay.show {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 991.98px) {
    .school-sidebar,
    .app-sidebar,
    .sidebar {
        width: min(var(--school-sidebar-width), 88vw);
        max-width: 88vw;
        transform: translateX(-105%);
    }

    .school-sidebar.is-open,
    .school-sidebar.show,
    .school-sidebar.active,
    .app-sidebar.is-open,
    .app-sidebar.show,
    .sidebar.is-open,
    .sidebar.show,
    .sidebar.active,
    body.sidebar-open .school-sidebar,
    body.sidebar-open .app-sidebar,
    body.sidebar-open .sidebar,
    body.school-sidebar-open .school-sidebar {
        transform: translateX(0);
    }

    .school-main,
    .app-main,
    .main-wrapper,
    .schoolos-main {
        width: 100%;
        margin-left: 0 !important;
    }

    body.sidebar-collapsed .school-sidebar,
    body.sidebar-collapsed .app-sidebar,
    body.sidebar-collapsed .sidebar {
        width: min(var(--school-sidebar-width), 88vw);
    }

    body.sidebar-collapsed .school-brand .brand-name,
    body.sidebar-collapsed .school-brand .brand-subtitle,
    body.sidebar-collapsed .sidebar-section-label .section-title,
    body.sidebar-collapsed .sidebar-link .link-label {
        display: initial;
    }

    body.sidebar-collapsed .sidebar-link {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .sidebar-section-toggle {
        justify-content: space-between;
        font-size: 10px;
    }

    body.sidebar-collapsed .sidebar-section-toggle .section-chevron {
        display: inline-block;
    }

    body.sidebar-collapsed .sidebar-section-content .sidebar-link .link-label {
        display: inline;
    }

    body.school-sidebar-open,
    body.sidebar-open {
        overflow: hidden;
    }
}

/* =========================================================
   8. TOPBAR
   ========================================================= */

.school-topbar,
.app-topbar,
.topbar,
.main-header {
    position: sticky;
    z-index: 1020;
    top: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    min-height: var(--school-topbar-height);
    padding: 12px 24px;

    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.topbar-left,
.topbar-right,
.header-actions,
.school-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
}

.topbar-subtitle {
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: 12px;
}

.sidebar-toggle,
.topbar-icon-button,
.theme-toggle,
.notification-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
}

.sidebar-toggle:hover,
.topbar-icon-button:hover,
.theme-toggle:hover,
.notification-toggle:hover {
    color: var(--school-red);
    background: var(--hover-bg);
    border-color: var(--school-red-border);
}

.topbar .dropdown-menu,
.school-topbar .dropdown-menu,
.app-topbar .dropdown-menu {
    color: var(--text-primary);
    background: var(--surface);
    border-color: var(--border-color);
    box-shadow: var(--school-shadow-lg);
}

.topbar .dropdown-item,
.school-topbar .dropdown-item,
.app-topbar .dropdown-item {
    color: var(--text-primary);
}

.topbar .dropdown-item:hover,
.school-topbar .dropdown-item:hover,
.app-topbar .dropdown-item:hover {
    color: var(--school-red);
    background: var(--hover-bg);
}

/* =========================================================
   9. THEME TOGGLE
   ========================================================= */

.theme-toggle {
    gap: 9px;
    min-height: 40px;
    padding: 8px 13px;
    font-size: 13px;
    font-weight: 600;
}

.theme-toggle i {
    font-size: 16px;
}

#themeToggle,
#schoolSidebarThemeToggle {
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

#themeToggle:hover,
#schoolSidebarThemeToggle:hover {
    color: var(--school-red);
    background: var(--hover-bg);
    border-color: var(--school-red);
}

/* =========================================================
   10. PAGE HEADERS AND BREADCRUMBS
   ========================================================= */

.page-header,
.module-header,
.content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-heading,
.module-heading {
    min-width: 0;
}

.page-title,
.module-title,
.content-title {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(21px, 2vw, 27px);
    font-weight: 800;
    letter-spacing: -.035em;
    line-height: 1.3;
}

.page-subtitle,
.module-subtitle,
.content-subtitle {
    margin: 7px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.page-actions,
.module-actions,
.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 18px;
    padding: 0;
    font-size: 12px;
}

.breadcrumb-item,
.breadcrumb-item.active {
    color: var(--text-secondary);
}

.breadcrumb-item a {
    color: var(--school-red);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-secondary);
}

.page-description {
    margin-bottom: 18px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* =========================================================
   11. CARDS AND PANELS
   ========================================================= */

.card,
.school-card,
.module-card,
.panel,
.widget-card {
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
    box-shadow: var(--school-shadow);
}

.card {
    overflow: hidden;
}

.card-header,
.card-footer,
.panel-header,
.panel-footer {
    color: var(--text-primary);
    background: var(--surface);
    border-color: var(--border-color);
}

.card-header,
.panel-header {
    padding: 16px 20px;
    font-weight: 700;
}

.card-body,
.panel-body {
    padding: 20px;
}

.card-footer,
.panel-footer {
    padding: 13px 20px;
}

.card-title,
.panel-title {
    margin: 0;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 800;
}

.card-subtitle {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 12px;
}

.card-hover {
    transition: transform var(--school-transition),
                box-shadow var(--school-transition),
                border-color var(--school-transition);
}

.card-hover:hover {
    border-color: var(--school-red-border);
    box-shadow: var(--school-shadow-lg);
    transform: translateY(-2px);
}

.card + .card {
    margin-top: 0;
}

.section-title {
    margin: 0 0 15px;
    font-size: 16px;
    font-weight: 800;
}

.section-subtitle {
    margin: -8px 0 18px;
    color: var(--text-secondary);
    font-size: 12px;
}

.card .table {
    margin-bottom: 0;
}

/* =========================================================
   12. DASHBOARD KPI CARDS
   ========================================================= */

.dashboard-grid,
.kpi-grid,
.stats-grid,
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.kpi-card,
.stat-card,
.dashboard-stat-card {
    position: relative;
    min-width: 0;
    min-height: 125px;
    padding: 19px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
    box-shadow: var(--school-shadow);
    transition: transform var(--school-transition),
                box-shadow var(--school-transition);
}

.kpi-card:hover,
.stat-card:hover,
.dashboard-stat-card:hover {
    box-shadow: var(--school-shadow-lg);
    transform: translateY(-2px);
}

.kpi-top,
.stat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.kpi-label,
.stat-label,
.dashboard-stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}

.kpi-value,
.stat-value,
.dashboard-stat-value {
    display: block;
    margin-top: 9px;
    color: var(--text-primary);
    font-size: clamp(22px, 2vw, 29px);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -.04em;
    overflow-wrap: anywhere;
}

.kpi-description,
.stat-description {
    display: block;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 11px;
}

.kpi-icon,
.stat-icon,
.dashboard-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    color: var(--school-red);
    background: var(--school-red-soft);
    border-radius: 12px;
    font-size: 19px;
}

.kpi-icon.green,
.stat-icon.green {
    color: var(--school-green);
    background: var(--school-green-soft);
}

.kpi-icon.blue,
.stat-icon.blue {
    color: var(--school-blue);
    background: var(--school-blue-soft);
}

.kpi-icon.orange,
.stat-icon.orange {
    color: var(--school-orange);
    background: var(--school-orange-soft);
}

.kpi-icon.purple,
.stat-icon.purple {
    color: var(--school-purple);
    background: var(--school-purple-soft);
}

.kpi-icon.cyan,
.stat-icon.cyan {
    color: var(--school-cyan);
    background: var(--school-cyan-soft);
}

.kpi-trend,
.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 9px;
    font-size: 11px;
    font-weight: 700;
}

.kpi-trend.positive,
.stat-trend.positive {
    color: var(--school-green);
}

.kpi-trend.negative,
.stat-trend.negative {
    color: var(--school-danger);
}

/* =========================================================
   13. DASHBOARD GRIDS AND ANALYTICS
   ========================================================= */

.dashboard-layout,
.analytics-grid,
.dashboard-panels {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.dashboard-col-12,
.analytics-full {
    grid-column: span 12;
}

.dashboard-col-8,
.analytics-wide {
    grid-column: span 8;
}

.dashboard-col-6,
.analytics-half {
    grid-column: span 6;
}

.dashboard-col-4,
.analytics-narrow {
    grid-column: span 4;
}

.chart-container,
.chart-wrapper,
.analytics-chart {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 260px;
}

.chart-container canvas,
.chart-wrapper canvas,
.analytics-chart canvas {
    max-width: 100%;
}

.dashboard-list {
    display: flex;
    flex-direction: column;
}

.dashboard-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-list-item:last-child {
    border-bottom: 0;
}

.dashboard-list-label {
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
}

.dashboard-list-meta {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 11px;
}

.analytics-card,
.module-analytics-card {
    min-width: 0;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
    box-shadow: var(--school-shadow);
}

.analytics-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.analytics-card-title {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
}

.analytics-card-description {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 11px;
}

/* =========================================================
   14. BUTTONS
   ========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 37px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    border-radius: 9px;
    transition: color var(--school-transition),
                background-color var(--school-transition),
                border-color var(--school-transition),
                box-shadow var(--school-transition),
                transform var(--school-transition);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--school-red);
    --bs-btn-border-color: var(--school-red);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--school-red-dark);
    --bs-btn-hover-border-color: var(--school-red-dark);
    --bs-btn-active-bg: var(--school-red-dark);
    --bs-btn-active-border-color: var(--school-red-dark);
    --bs-btn-disabled-bg: var(--school-red);
    --bs-btn-disabled-border-color: var(--school-red);
}

.btn-outline-primary {
    --bs-btn-color: var(--school-red);
    --bs-btn-border-color: var(--school-red);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--school-red);
    --bs-btn-hover-border-color: var(--school-red);
}

.btn-success {
    --bs-btn-bg: var(--school-green);
    --bs-btn-border-color: var(--school-green);
}

.btn-light {
    --bs-btn-color: var(--text-primary);
    --bs-btn-bg: var(--surface-muted);
    --bs-btn-border-color: var(--border-color);
    --bs-btn-hover-color: var(--text-primary);
    --bs-btn-hover-bg: var(--hover-bg);
    --bs-btn-hover-border-color: var(--border-color);
}

.btn-outline-secondary {
    --bs-btn-color: var(--text-secondary);
    --bs-btn-border-color: var(--border-color);
    --bs-btn-hover-color: var(--text-primary);
    --bs-btn-hover-bg: var(--surface-muted);
    --bs-btn-hover-border-color: var(--border-color);
}

.btn-outline-danger {
    --bs-btn-color: var(--school-danger);
    --bs-btn-border-color: var(--school-danger);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--school-danger);
    --bs-btn-hover-border-color: var(--school-danger);
}

.btn-sm {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 11px;
    border-radius: 7px;
}

.btn-lg {
    min-height: 45px;
    padding: 11px 18px;
    font-size: 14px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn:disabled,
.btn.disabled {
    cursor: not-allowed;
    opacity: .55;
}

/* =========================================================
   15. FORMS AND INPUTS
   ========================================================= */

.form-label,
label.form-label {
    display: inline-block;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
}

.form-control,
.form-select,
.input-group-text {
    min-height: 40px;
    color: var(--text-primary);
    background-color: var(--input-bg);
    border-color: var(--border-color);
    border-radius: 9px;
    font-size: 13px;
}

.form-control,
.form-select {
    padding: 9px 12px;
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: .75;
}

.form-control:focus,
.form-select:focus {
    color: var(--text-primary);
    background-color: var(--input-bg);
    border-color: var(--school-red);
    box-shadow: 0 0 0 3px rgba(180, 35, 50, .11);
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
    color: var(--text-secondary);
    background-color: var(--surface-muted);
    opacity: .85;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-text,
.help-text,
.field-hint {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 11px;
}

.form-check-input {
    background-color: var(--input-bg);
    border-color: var(--border-color);
}

.form-check-input:checked {
    background-color: var(--school-red);
    border-color: var(--school-red);
}

.form-check-input:focus {
    border-color: var(--school-red);
    box-shadow: 0 0 0 3px rgba(180, 35, 50, .12);
}

.form-check-label {
    color: var(--text-primary);
    font-size: 12px;
}

.input-group .form-control,
.input-group .form-select,
.input-group .input-group-text {
    border-radius: 9px;
}

.input-group > :not(:first-child) {
    margin-left: 0;
}

.input-group > :not(:first-child):not(.dropdown-menu) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group > :not(:last-child):not(.dropdown-toggle) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.required,
.required-field {
    color: var(--school-danger);
}

.form-section {
    padding: 20px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
}

.form-section-title {
    margin: 0 0 5px;
    font-size: 15px;
    font-weight: 800;
}

.form-section-description {
    margin-bottom: 18px;
    color: var(--text-secondary);
    font-size: 12px;
}

.form-actions,
.form-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    padding-top: 18px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* =========================================================
   16. SEARCH, FILTERS AND TOOLBARS
   ========================================================= */

.table-toolbar,
.module-toolbar,
.filter-toolbar,
.search-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}

.toolbar-left,
.toolbar-right,
.filter-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.search-box {
    position: relative;
    min-width: 220px;
    max-width: 100%;
}

.search-box .form-control {
    padding-left: 38px;
}

.search-box .search-icon {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 13px;
    color: var(--text-secondary);
    transform: translateY(-50%);
}

.filter-panel {
    padding: 18px;
    margin-bottom: 18px;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
}

.filter-panel .row {
    row-gap: 12px;
}

/* =========================================================
   17. TABLES
   ========================================================= */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}

.table {
    width: 100%;
    margin-bottom: 0;
    color: var(--text-primary);
    vertical-align: middle;
    border-color: var(--border-color);
    font-size: 12px;
}

.table > :not(caption) > * > * {
    padding: 12px 13px;
    color: var(--text-primary);
    background-color: transparent;
    border-bottom-color: var(--border-color);
    box-shadow: none;
}

.table > thead > tr > th,
.table thead th {
    color: var(--text-secondary);
    background: var(--table-header-bg);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table > tbody > tr {
    transition: background-color var(--school-transition);
}

.table > tbody > tr:hover > * {
    background-color: var(--hover-bg);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    color: var(--text-primary);
    background-color: var(--surface-muted);
    --bs-table-bg-type: var(--surface-muted);
}

.table-striped > tbody > tr:nth-of-type(odd):hover > * {
    background-color: var(--hover-bg);
}

.table-bordered > :not(caption) > * {
    border-width: 1px 0;
}

.table-bordered > :not(caption) > * > * {
    border-width: 0 1px;
}

.table-light,
.table-light > *,
.table-light th,
.table-light td {
    --bs-table-bg: var(--table-header-bg);
    --bs-table-color: var(--text-primary);
    color: var(--text-primary) !important;
    background-color: var(--table-header-bg) !important;
}

.table a {
    font-weight: 600;
}

.table-actions,
.action-buttons {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    white-space: nowrap;
}

.table-actions .btn,
.action-buttons .btn {
    min-width: 30px;
}

.table-empty,
.empty-state {
    padding: 38px 20px !important;
    color: var(--text-secondary);
    text-align: center;
}

.table-empty i,
.empty-state i {
    display: block;
    margin-bottom: 10px;
    font-size: 28px;
    opacity: .7;
}

.data-table-card {
    overflow: hidden;
}

.data-table-card .card-body {
    padding: 0;
}

.data-table-card .table-toolbar {
    padding: 18px 20px 0;
}

.table tfoot th,
.table tfoot td {
    font-weight: 800;
    background: var(--surface-muted);
}

/* =========================================================
   18. STATUS BADGES
   ========================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 8px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.3;
    white-space: nowrap;
    border-radius: 6px;
}

.badge-soft,
.status-badge {
    color: var(--text-secondary);
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
}

.badge-primary,
.badge.bg-primary,
.status-active,
.status-paid,
.status-approved,
.status-completed,
.status-success {
    color: var(--school-green);
    background: var(--school-green-soft) !important;
}

.badge-danger,
.badge.bg-danger,
.status-inactive,
.status-unpaid,
.status-overdue,
.status-rejected,
.status-failed,
.status-expired {
    color: var(--school-danger);
    background: var(--school-red-soft) !important;
}

.badge-warning,
.badge.bg-warning,
.status-pending,
.status-processing,
.status-draft {
    color: #996000;
    background: var(--school-yellow-soft) !important;
}

.badge-info,
.badge.bg-info,
.status-open,
.status-in-progress,
.status-submitted {
    color: var(--school-blue);
    background: var(--school-blue-soft) !important;
}

.badge-secondary,
.badge.bg-secondary,
.status-closed,
.status-cancelled,
.status-withdrawn {
    color: var(--text-secondary);
    background: var(--surface-muted) !important;
}

.status-transferred,
.status-graduated {
    color: var(--school-purple);
    background: var(--school-purple-soft);
}

/* =========================================================
   19. PAGINATION
   ========================================================= */

.pagination {
    gap: 4px;
    margin-bottom: 0;
}

.page-link {
    min-width: 34px;
    min-height: 34px;
    padding: 7px 10px;
    color: var(--text-primary);
    text-align: center;
    background: var(--surface);
    border-color: var(--border-color);
    border-radius: 7px !important;
    font-size: 12px;
}

.page-link:hover {
    color: var(--school-red);
    background: var(--hover-bg);
    border-color: var(--school-red-border);
}

.page-item.active .page-link {
    color: #fff;
    background: var(--school-red);
    border-color: var(--school-red);
}

.page-item.disabled .page-link {
    color: var(--text-secondary);
    background: var(--surface-muted);
    border-color: var(--border-color);
}

/* =========================================================
   20. ALERTS AND FLASH MESSAGES
   ========================================================= */

.alert {
    padding: 13px 16px;
    margin-bottom: 18px;
    border-radius: 10px;
    font-size: 12px;
}

.alert-success {
    color: var(--school-green);
    background: var(--school-green-soft);
    border-color: rgba(25, 135, 84, .22);
}

.alert-danger {
    color: var(--school-danger);
    background: var(--school-red-soft);
    border-color: var(--school-red-border);
}

.alert-warning {
    color: #996000;
    background: var(--school-yellow-soft);
    border-color: rgba(245, 197, 66, .35);
}

.alert-info {
    color: var(--school-blue);
    background: var(--school-blue-soft);
    border-color: rgba(13, 110, 253, .2);
}

html[data-theme="dark"] .alert .btn-close,
body[data-theme="dark"] .alert .btn-close,
.dark-mode .alert .btn-close {
    filter: invert(1) grayscale(100%);
}

.flash-message {
    padding: 13px 16px;
    margin-bottom: 18px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--school-red);
    border-radius: 9px;
    background: var(--surface);
}

/* =========================================================
   21. MODALS, POPOVERS AND DROPDOWNS
   ========================================================= */

.modal-content {
    overflow: hidden;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
    box-shadow: var(--school-shadow-lg);
}

.modal-header,
.modal-footer {
    background: var(--surface);
    border-color: var(--border-color);
}

.modal-header {
    padding: 18px 22px;
}

.modal-title {
    font-size: 17px;
    font-weight: 800;
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    padding: 15px 22px;
}

.dropdown-menu,
.popover {
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--school-shadow-lg);
}

.dropdown-header {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.dropdown-item {
    padding: 8px 13px;
    color: var(--text-primary);
    font-size: 12px;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: var(--school-red);
    background: var(--hover-bg);
}

.dropdown-item.active,
.dropdown-item:active {
    color: #fff;
    background: var(--school-red);
}

.dropdown-divider {
    border-color: var(--border-color);
}

.popover-header {
    color: var(--text-primary);
    background: var(--surface-muted);
    border-color: var(--border-color);
}

.popover-body {
    color: var(--text-primary);
}

/* =========================================================
   22. TABS AND NAVIGATION
   ========================================================= */

.nav-tabs {
    gap: 4px;
    border-bottom-color: var(--border-color);
}

.nav-tabs .nav-link {
    padding: 10px 14px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
    border-radius: 8px 8px 0 0;
}

.nav-tabs .nav-link:hover {
    color: var(--school-red);
    border-color: var(--border-color) var(--border-color) transparent;
}

.nav-tabs .nav-link.active {
    color: var(--school-red);
    background: var(--surface);
    border-color: var(--border-color) var(--border-color) var(--surface);
}

.nav-pills {
    gap: 6px;
}

.nav-pills .nav-link {
    padding: 8px 13px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    border-radius: 8px;
}

.nav-pills .nav-link.active {
    color: #fff;
    background: var(--school-red);
}

.tab-content {
    padding-top: 18px;
}

/* =========================================================
   23. FINANCE MODULE
   ========================================================= */

.finance-summary,
.fee-summary,
.payment-summary,
.invoice-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    margin-bottom: 22px;
}

.finance-stat,
.fee-stat,
.payment-stat {
    padding: 17px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
    box-shadow: var(--school-shadow);
}

.finance-stat-label,
.fee-stat-label,
.payment-stat-label {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.finance-stat-value,
.fee-stat-value,
.payment-stat-value {
    display: block;
    margin-top: 7px;
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.money,
.currency,
.amount {
    font-variant-numeric: tabular-nums;
}

.amount-positive,
.balance-credit {
    color: var(--school-green) !important;
}

.amount-negative,
.balance-arrears {
    color: var(--school-danger) !important;
}

.invoice-total,
.payment-total,
.statement-total {
    font-size: 18px;
    font-weight: 800;
}

.invoice-document,
.fee-statement,
.payment-receipt {
    padding: 24px;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
}

.invoice-heading,
.receipt-heading {
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
}

.invoice-number,
.receipt-number {
    color: var(--school-red);
    font-size: 18px;
    font-weight: 800;
}

.invoice-meta,
.receipt-meta {
    color: var(--text-secondary);
    font-size: 12px;
}

.finance-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* =========================================================
   24. LEARNERS, ADMISSIONS AND GUARDIANS
   ========================================================= */

.learner-profile,
.staff-profile,
.person-profile {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
}

.learner-avatar,
.staff-avatar,
.person-avatar {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    color: var(--school-red);
    background: var(--school-red-soft);
    border-radius: 16px;
    font-size: 25px;
    font-weight: 800;
}

.person-name,
.learner-name,
.staff-name {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
}

.person-meta,
.learner-meta,
.staff-meta {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 12px;
}

.profile-details,
.learner-details,
.staff-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.detail-item {
    min-width: 0;
}

.detail-label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.detail-value {
    display: block;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.admission-stepper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
}

.admission-step {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.admission-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 50%;
}

.admission-step.active .admission-step-number,
.admission-step.completed .admission-step-number {
    color: #fff;
    background: var(--school-red);
    border-color: var(--school-red);
}

.admission-step.active,
.admission-step.completed {
    color: var(--school-red);
}

/* =========================================================
   25. ACADEMICS, CBC GRADES, CLASSES AND SUBJECTS
   ========================================================= */

.academic-card,
.grade-card,
.class-card,
.subject-card {
    min-width: 0;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
    box-shadow: var(--school-shadow);
}

.grade-code,
.class-code,
.subject-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 36px;
    padding: 6px 10px;
    color: var(--school-red);
    background: var(--school-red-soft);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
}

.grade-name,
.class-name,
.subject-name {
    margin: 12px 0 5px;
    font-size: 15px;
    font-weight: 800;
}

.grade-meta,
.class-meta,
.subject-meta {
    color: var(--text-secondary);
    font-size: 11px;
}

.class-capacity {
    height: 7px;
    margin-top: 12px;
    overflow: hidden;
    background: var(--surface-muted);
    border-radius: 20px;
}

.class-capacity-bar {
    height: 100%;
    background: var(--school-red);
    border-radius: inherit;
}

.class-capacity-bar.success {
    background: var(--school-green);
}

.class-capacity-bar.warning {
    background: var(--school-orange);
}

.timetable-grid {
    width: 100%;
    min-width: 700px;
    border-collapse: separate;
    border-spacing: 4px;
}

.timetable-grid th {
    padding: 11px;
    color: var(--text-secondary);
    background: var(--table-header-bg);
    border-radius: 7px;
    font-size: 11px;
    text-align: center;
}

.timetable-grid td {
    min-width: 100px;
    padding: 7px;
    vertical-align: top;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 7px;
}

.timetable-entry {
    padding: 9px;
    color: var(--school-red);
    background: var(--school-red-soft);
    border-left: 3px solid var(--school-red);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.timetable-entry .teacher,
.timetable-entry .room {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
}

/* =========================================================
   26. ATTENDANCE
   ========================================================= */

.attendance-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.attendance-stat {
    padding: 15px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 11px;
}

.attendance-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 800;
}

.attendance-stat-label {
    color: var(--text-secondary);
    font-size: 11px;
}

.attendance-present {
    color: var(--school-green);
}

.attendance-absent {
    color: var(--school-danger);
}

.attendance-late {
    color: var(--school-orange);
}

.attendance-excused {
    color: var(--school-blue);
}

.attendance-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    padding: 4px 7px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
}

.attendance-mark.present {
    color: var(--school-green);
    background: var(--school-green-soft);
}

.attendance-mark.absent {
    color: var(--school-danger);
    background: var(--school-red-soft);
}

.attendance-mark.late {
    color: #996000;
    background: var(--school-yellow-soft);
}

.attendance-mark.excused {
    color: var(--school-blue);
    background: var(--school-blue-soft);
}

/* =========================================================
   27. ASSESSMENTS AND RESULTS
   ========================================================= */

.result-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.result-stat {
    padding: 17px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 11px;
}

.result-score {
    font-size: 22px;
    font-weight: 800;
}

.result-grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 5px 8px;
    color: var(--school-purple);
    background: var(--school-purple-soft);
    border-radius: 6px;
    font-weight: 800;
}

.progress {
    height: 8px;
    overflow: hidden;
    background: var(--surface-muted);
    border-radius: 20px;
}

.progress-bar {
    background: var(--school-red);
}

.progress-bar.bg-success {
    background: var(--school-green) !important;
}

.progress-bar.bg-warning {
    background: var(--school-orange) !important;
}

/* =========================================================
   28. LIBRARY AND INVENTORY
   ========================================================= */

.book-card,
.inventory-card,
.resource-card {
    height: 100%;
    padding: 17px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
    box-shadow: var(--school-shadow);
}

.book-cover,
.resource-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 130px;
    margin-bottom: 15px;
    color: var(--school-red);
    background: var(--school-red-soft);
    border-radius: 9px;
    font-size: 36px;
}

.book-title,
.resource-title {
    margin: 0 0 5px;
    font-size: 14px;
    font-weight: 800;
}

.book-author,
.resource-meta {
    color: var(--text-secondary);
    font-size: 11px;
}

.stock-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
}

.stock-indicator::before {
    width: 7px;
    height: 7px;
    content: "";
    background: currentColor;
    border-radius: 50%;
}

.stock-indicator.in-stock {
    color: var(--school-green);
}

.stock-indicator.low-stock {
    color: var(--school-orange);
}

.stock-indicator.out-of-stock {
    color: var(--school-danger);
}

/* =========================================================
   29. MEDICAL INFORMATION AND DISCIPLINE
   ========================================================= */

.medical-alert,
.health-alert {
    padding: 15px;
    color: var(--school-danger);
    background: var(--school-red-soft);
    border: 1px solid var(--school-red-border);
    border-radius: 10px;
}

.medical-note,
.health-note,
.discipline-note {
    padding: 15px;
    margin-bottom: 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.medical-note-date,
.health-note-date,
.discipline-note-date {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 11px;
}

.medical-note-title,
.health-note-title,
.discipline-note-title {
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 800;
}

/* =========================================================
   30. COMMUNICATIONS AND NOTIFICATIONS
   ========================================================= */

.announcement-card,
.message-card,
.notification-card {
    padding: 17px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 11px;
}

.announcement-title,
.message-title,
.notification-title {
    margin: 0 0 7px;
    font-size: 14px;
    font-weight: 800;
}

.announcement-meta,
.message-meta,
.notification-meta {
    margin-bottom: 9px;
    color: var(--text-secondary);
    font-size: 11px;
}

.message-unread,
.notification-unread {
    background: var(--school-red-soft);
    border-left: 3px solid var(--school-red);
}

.notification-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

/* =========================================================
   31. DOCUMENTS AND FILE UPLOADS
   ========================================================= */

.document-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.document-item,
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 9px;
}

.document-icon,
.file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    color: var(--school-red);
    background: var(--school-red-soft);
    border-radius: 9px;
    font-size: 17px;
}

.document-name,
.file-name {
    overflow-wrap: anywhere;
    font-size: 12px;
    font-weight: 700;
}

.document-meta,
.file-meta {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 10px;
}

.upload-zone {
    padding: 30px 18px;
    text-align: center;
    background: var(--surface-muted);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
}

.upload-zone:hover {
    border-color: var(--school-red);
}

.upload-zone-icon {
    margin-bottom: 10px;
    color: var(--school-red);
    font-size: 28px;
}

/* =========================================================
   32. SETTINGS AND PERMISSIONS
   ========================================================= */

.settings-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.settings-nav {
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--school-radius);
}

.settings-nav a,
.settings-nav button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.settings-nav a:hover,
.settings-nav button:hover,
.settings-nav a.active,
.settings-nav button.active {
    color: var(--school-red);
    background: var(--school-red-soft);
}

.permission-group {
    padding: 17px;
    margin-bottom: 15px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.permission-group-title {
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 800;
}

.permission-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

/* =========================================================
   33. TIMELINES AND AUDIT LOGS
   ========================================================= */

.timeline {
    position: relative;
    padding-left: 25px;
}

.timeline::before {
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 7px;
    width: 2px;
    content: "";
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding: 0 0 22px 12px;
}

.timeline-item::before {
    position: absolute;
    top: 4px;
    left: -22px;
    width: 12px;
    height: 12px;
    content: "";
    background: var(--school-red);
    border: 3px solid var(--school-red-soft);
    border-radius: 50%;
}

.timeline-title {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 800;
}

.timeline-meta {
    margin-bottom: 7px;
    color: var(--text-secondary);
    font-size: 11px;
}

.timeline-description {
    color: var(--text-secondary);
    font-size: 12px;
}

.audit-action {
    display: inline-flex;
    padding: 4px 7px;
    color: var(--school-blue);
    background: var(--school-blue-soft);
    border-radius: 5px;
    font-size: 10px;
    font-weight: 800;
}

/* =========================================================
   34. FOOTER
   ========================================================= */

.school-footer,
.app-footer,
.main-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    padding: 15px 24px;
    margin-top: auto;
    color: var(--text-secondary);
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    font-size: 11px;
}

.school-footer a,
.app-footer a,
.main-footer a {
    color: var(--school-red);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

/* =========================================================
   35. EMPTY STATES AND LOADING
   ========================================================= */

.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 30px;
    text-align: center;
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    margin-bottom: 15px;
    color: var(--school-red);
    background: var(--school-red-soft);
    border-radius: 18px;
    font-size: 25px;
}

.empty-state-title {
    margin: 0 0 7px;
    font-size: 16px;
    font-weight: 800;
}

.empty-state-description {
    max-width: 420px;
    margin-bottom: 17px;
    color: var(--text-secondary);
    font-size: 12px;
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-muted) 25%,
        var(--border-color) 50%,
        var(--surface-muted) 75%
    );
    background-size: 200% 100%;
    border-radius: 7px;
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top-color: var(--school-red);
    border-radius: 50%;
    animation: school-spin .8s linear infinite;
}

@keyframes school-spin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================
   36. PRINT AND PDF
   ========================================================= */

.print-only {
    display: none !important;
}

@media print {
    @page {
        size: auto;
        margin: 12mm;
    }

    html,
    body {
        min-height: auto !important;
        color: #000 !important;
        background: #fff !important;
        font-size: 10pt;
    }

    .school-sidebar,
    .app-sidebar,
    .sidebar,
    .school-topbar,
    .app-topbar,
    .topbar,
    .main-header,
    .school-footer,
    .app-footer,
    .main-footer,
    .sidebar-overlay,
    .page-actions,
    .module-actions,
    .table-toolbar,
    .filter-toolbar,
    .no-print,
    .btn,
    .pagination {
        display: none !important;
    }

    .school-main,
    .app-main,
    .main-wrapper,
    .schoolos-main {
        display: block !important;
        width: 100% !important;
        min-height: auto !important;
        margin: 0 !important;
    }

    .school-content,
    .app-content,
    .main-content,
    .pos-content,
    .schoolos-content {
        padding: 0 !important;
        margin: 0 !important;
    }

    .card,
    .school-card,
    .module-card,
    .panel,
    .invoice-document,
    .payment-receipt,
    .fee-statement {
        color: #000 !important;
        background: #fff !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .card-header,
    .card-footer,
    .table > thead > tr > th,
    .table > tbody > tr > td {
        color: #000 !important;
        background: #fff !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .table {
        width: 100% !important;
        font-size: 9pt;
    }

    .table > :not(caption) > * > * {
        padding: 5px !important;
        color: #000 !important;
        background: #fff !important;
        border-color: #ccc !important;
    }

    a {
        color: #000 !important;
        text-decoration: none !important;
    }

    .print-only {
        display: block !important;
    }

    .page-header,
    .module-header {
        margin-bottom: 12px;
    }

    .page-title,
    .module-title {
        color: #000 !important;
        font-size: 18pt;
    }

    .badge,
    .status-badge {
        color: #000 !important;
        background: #fff !important;
        border: 1px solid #ccc !important;
    }

    .dashboard-grid,
    .kpi-grid,
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-container,
    .chart-wrapper {
        break-inside: avoid;
    }
}

/* =========================================================
   37. DARK MODE — BOOTSTRAP COMPATIBILITY
   ========================================================= */

html[data-theme="dark"] .card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .popover,
body[data-theme="dark"] .card,
body[data-theme="dark"] .modal-content,
body[data-theme="dark"] .dropdown-menu,
body[data-theme="dark"] .popover,
.dark-mode .card,
.dark-mode .modal-content,
.dark-mode .dropdown-menu,
.dark-mode .popover {
    color: var(--text-primary);
    background-color: var(--surface);
    border-color: var(--border-color);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text,
body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select,
body[data-theme="dark"] .input-group-text,
.dark-mode .form-control,
.dark-mode .form-select,
.dark-mode .input-group-text {
    color: var(--text-primary);
    background-color: var(--input-bg);
    border-color: var(--border-color);
}

html[data-theme="dark"] .table,
body[data-theme="dark"] .table,
.dark-mode .table {
    --bs-table-color: var(--text-primary);
    --bs-table-bg: var(--surface);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-striped-bg: var(--surface-muted);
    --bs-table-hover-color: var(--text-primary);
    --bs-table-hover-bg: var(--hover-bg);
}

html[data-theme="dark"] .list-group-item,
body[data-theme="dark"] .list-group-item,
.dark-mode .list-group-item {
    color: var(--text-primary);
    background-color: var(--surface);
    border-color: var(--border-color);
}

html[data-theme="dark"] .accordion,
body[data-theme="dark"] .accordion,
.dark-mode .accordion {
    --bs-accordion-color: var(--text-primary);
    --bs-accordion-bg: var(--surface);
    --bs-accordion-border-color: var(--border-color);
    --bs-accordion-btn-color: var(--text-primary);
    --bs-accordion-btn-bg: var(--surface);
    --bs-accordion-active-color: var(--school-red);
    --bs-accordion-active-bg: var(--school-red-soft);
}

html[data-theme="dark"] .text-dark,
body[data-theme="dark"] .text-dark,
.dark-mode .text-dark {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .bg-white,
body[data-theme="dark"] .bg-white,
.dark-mode .bg-white {
    color: var(--text-primary) !important;
    background-color: var(--surface) !important;
}

html[data-theme="dark"] .border-light,
body[data-theme="dark"] .border-light,
.dark-mode .border-light {
    border-color: var(--border-color) !important;
}

/* =========================================================
   38. UTILITY CLASSES
   ========================================================= */

.visually-hidden-focusable:not(:focus):not(:focus-within) {
    clip: rect(0, 0, 0, 0) !important;
}

.rounded-school {
    border-radius: var(--school-radius) !important;
}

.surface {
    color: var(--text-primary);
    background: var(--surface);
}

.surface-muted {
    color: var(--text-primary);
    background: var(--surface-muted);
}

.border-school {
    border: 1px solid var(--border-color) !important;
}

.text-school-red {
    color: var(--school-red) !important;
}

.bg-school-red-soft {
    color: var(--school-red);
    background: var(--school-red-soft) !important;
}

.text-school-green {
    color: var(--school-green) !important;
}

.text-school-orange {
    color: var(--school-orange) !important;
}

.text-school-blue {
    color: var(--school-blue) !important;
}

.text-school-purple {
    color: var(--school-purple) !important;
}

.gap-1 {
    gap: 4px !important;
}

.gap-2 {
    gap: 8px !important;
}

.gap-3 {
    gap: 12px !important;
}

.gap-4 {
    gap: 16px !important;
}

.gap-5 {
    gap: 24px !important;
}

/* =========================================================
   39. RESPONSIVE LAYOUT
   ========================================================= */

@media (max-width: 1399.98px) {
    .dashboard-grid,
    .kpi-grid,
    .stats-grid,
    .dashboard-stats,
    .finance-summary,
    .fee-summary,
    .payment-summary,
    .invoice-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-col-8,
    .analytics-wide {
        grid-column: span 7;
    }

    .dashboard-col-4,
    .analytics-narrow {
        grid-column: span 5;
    }
}

@media (max-width: 1199.98px) {
    .school-content,
    .app-content,
    .main-content,
    .pos-content,
    .schoolos-content {
        padding: 20px;
    }

    .dashboard-grid,
    .kpi-grid,
    .stats-grid,
    .dashboard-stats,
    .finance-summary,
    .fee-summary,
    .payment-summary,
    .invoice-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-col-8,
    .dashboard-col-6,
    .dashboard-col-4,
    .analytics-wide,
    .analytics-half,
    .analytics-narrow {
        grid-column: span 6;
    }

    .permission-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .school-topbar,
    .app-topbar,
    .topbar,
    .main-header {
        padding-right: 18px;
        padding-left: 18px;
    }

    .page-header,
    .module-header,
    .content-header {
        gap: 12px;
    }

    .dashboard-layout,
    .analytics-grid,
    .dashboard-panels {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .dashboard-col-12,
    .dashboard-col-8,
    .dashboard-col-6,
    .dashboard-col-4,
    .analytics-full,
    .analytics-wide,
    .analytics-half,
    .analytics-narrow {
        grid-column: span 6;
    }

    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    .settings-nav a,
    .settings-nav button {
        width: auto;
    }

    .profile-details,
    .learner-details,
    .staff-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .school-content,
    .app-content,
    .main-content,
    .pos-content,
    .schoolos-content {
        padding: 20px;
    }
}

@media (max-width: 767.98px) {
    body {
        font-size: 13px;
    }

    .school-content,
    .app-content,
    .main-content,
    .pos-content,
    .schoolos-content {
        padding: 15px;
    }

    .school-topbar,
    .app-topbar,
    .topbar,
    .main-header {
        min-height: 60px;
        gap: 9px;
        padding: 10px 14px;
    }

    .topbar-title {
        font-size: 14px;
    }

    .topbar-subtitle {
        font-size: 10px;
    }

    .topbar-left,
    .topbar-right,
    .header-actions {
        gap: 7px;
    }

    .topbar-icon-button,
    .theme-toggle,
    .notification-toggle,
    .sidebar-toggle {
        width: 36px;
        height: 36px;
    }

    .page-header,
    .module-header,
    .content-header {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 18px;
    }

    .page-actions,
    .module-actions {
        width: 100%;
    }

    .page-actions .btn,
    .module-actions .btn {
        flex: 0 0 auto;
    }

    .page-title,
    .module-title,
    .content-title {
        font-size: 22px;
    }

    .card-body,
    .panel-body {
        padding: 15px;
    }

    .card-header,
    .panel-header {
        padding: 13px 15px;
    }

    .dashboard-grid,
    .kpi-grid,
    .stats-grid,
    .dashboard-stats,
    .finance-summary,
    .fee-summary,
    .payment-summary,
    .invoice-summary,
    .attendance-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
    }

    .kpi-card,
    .stat-card,
    .dashboard-stat-card {
        min-height: 110px;
        padding: 14px;
    }

    .kpi-value,
    .stat-value,
    .dashboard-stat-value {
        font-size: 22px;
    }

    .kpi-icon,
    .stat-icon,
    .dashboard-stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .dashboard-layout,
    .analytics-grid,
    .dashboard-panels {
        grid-template-columns: minmax(0, 1fr);
        gap: 15px;
    }

    .dashboard-col-12,
    .dashboard-col-8,
    .dashboard-col-6,
    .dashboard-col-4,
    .analytics-full,
    .analytics-wide,
    .analytics-half,
    .analytics-narrow {
        grid-column: 1;
    }

    .table-toolbar,
    .module-toolbar,
    .filter-toolbar,
    .search-toolbar {
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right,
    .filter-actions {
        width: 100%;
    }

    .search-box {
        width: 100%;
        min-width: 0;
    }

    .table > :not(caption) > * > * {
        padding: 10px;
    }

    .table {
        font-size: 11px;
    }

    .form-section {
        padding: 15px;
    }

    .finance-stat-value,
    .fee-stat-value,
    .payment-stat-value {
        font-size: 19px;
    }

    .learner-profile,
    .staff-profile,
    .person-profile {
        gap: 13px;
        padding: 15px;
    }

    .learner-avatar,
    .staff-avatar,
    .person-avatar {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }

    .person-name,
    .learner-name,
    .staff-name {
        font-size: 16px;
    }

    .school-footer,
    .app-footer,
    .main-footer {
        align-items: flex-start;
        padding: 13px 15px;
    }

    .result-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-container,
    .chart-wrapper,
    .analytics-chart {
        min-height: 220px;
    }
}

@media (max-width: 479.98px) {
    .school-content,
    .app-content,
    .main-content,
    .pos-content,
    .schoolos-content {
        padding: 12px;
    }

    .dashboard-grid,
    .kpi-grid,
    .stats-grid,
    .dashboard-stats,
    .finance-summary,
    .fee-summary,
    .payment-summary,
    .invoice-summary,
    .attendance-summary,
    .result-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .kpi-card,
    .stat-card,
    .dashboard-stat-card {
        min-height: 0;
    }

    .kpi-top,
    .stat-card-top {
        align-items: center;
    }

    .page-title,
    .module-title,
    .content-title {
        font-size: 20px;
    }

    .page-actions .btn,
    .module-actions .btn {
        flex: 1 1 auto;
    }

    .btn {
        padding: 8px 10px;
        font-size: 11px;
    }

    .profile-details,
    .learner-details,
    .staff-details,
    .permission-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .learner-profile,
    .staff-profile,
    .person-profile {
        flex-direction: column;
    }

    .form-actions,
    .form-footer {
        justify-content: stretch;
    }

    .form-actions .btn,
    .form-footer .btn {
        flex: 1 1 auto;
    }

    .settings-nav a,
    .settings-nav button {
        flex: 1 1 100%;
    }

    .school-footer,
    .app-footer,
    .main-footer {
        flex-direction: column;
        gap: 5px;
    }
}

/* =========================================================
   40. ACCESSIBILITY AND REDUCED MOTION
   ========================================================= */

.sidebar-section-toggle:focus-visible,
.sidebar-link:focus-visible,
.theme-toggle:focus-visible {
    outline: 3px solid rgba(180, 35, 50, .3);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
/* Theme Toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: max-content;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 8px;
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

.theme-toggle i {
    flex-shrink: 0;
    font-size: 15px;
}

.theme-toggle .theme-label {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tablet and mobile */
@media (max-width: 767.98px) {
    .theme-toggle {
        width: 38px;
        height: 38px;
        min-width: 38px;
        padding: 0;
        gap: 0;
    }

    .theme-toggle .theme-label {
        display: none !important;
    }
}