html, body {
    height: 100%;
    overflow: hidden;
    margin: 0;
}

/* Sticky footer: main wrapper fills viewport and uses flex */
#main-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Page layout - grows to fill and is flex column so footer sticks at bottom */
.page-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* Header already fixed/sticky; padding-bottom so content doesn't sit under fixed footer */
.body-wrapper {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom: 52px;
}

/* Main container */
.fullscreen-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Form layout */
.form-scroll-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Sticky program header */
.program-header {
    position: sticky;
    top: 80px;
    /* navbar height */
    z-index: 1070;
    background: #fff;
}

/* ONLY this scrolls */
.program-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 10px;
}

/* Footer fixed at bottom of screen (same as header sticks at top) */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    flex-shrink: 0;
    z-index: 1030;
    background: #fff;
    border-top: 1px solid #ddd;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.08);
}

/* Vertical layout: align footer with content area (same width as topbar) */
@media (min-width: 1300px) {
    [data-layout="vertical"] footer {
        width: calc(100% - 270px);
        left: 270px;
        right: auto;
    }

    [data-layout="vertical"] body[data-sidebartype="mini-sidebar"] footer {
        width: calc(100% - 87px);
        left: 87px;
    }
}

.dataTables_wrapper table thead th:first-child {
    border-top-left-radius: 9px;
}

.dataTables_wrapper table thead th:last-child {
    border-top-right-radius: 9px;
}

.dataTables_wrapper table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 9px;
}

.dataTables_wrapper table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 9px;
}

/* DataTables: keep Length (Show entries) + Filter (Search) in one row */
.dataTables_wrapper .dataTables_length {
    float: left;
}
.dataTables_wrapper .dataTables_filter {
    float: right;
    text-align: right;
}
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    margin-bottom: 0;
}
/* Clear floats so table doesn't jump up */
.dataTables_wrapper > .row:first-child::after,
.dataTables_wrapper > .row.dt-row:first-child::after {
    content: "";
    display: block;
    clear: both;
}

/* DataTables: mobile – center Length + Filter, then pagination */
@media (max-width: 767.98px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: center;
    }
    .dataTables_wrapper .dataTables_filter {
        margin-top: 0.5rem;
    }
    .dataTables_wrapper .row:first-child,
    .dataTables_wrapper .row.dt-row:first-child {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .dataTables_wrapper .dataTables_length label,
    .dataTables_wrapper .dataTables_filter label {
        justify-content: center;
    }
    .dataTables_wrapper .dataTables_paginate {
        margin-top: 1.0rem;
        margin-bottom: 1.0rem;
        padding: 0.15rem 0;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1px;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.15rem 0.28rem;
        margin: 0;
        font-size: 0.75rem;
        min-width: 1.5rem;
        min-height: 1.5rem;
        line-height: 1.3;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button.previous,
    .dataTables_wrapper .dataTables_paginate .paginate_button.next {
        padding: 0.15rem 0.25rem;
    }
    .dataTables_wrapper .dataTables_paginate span {
        margin-top: 0.35rem;
        margin-bottom: 0.35rem;
    }
}

/* Sidebar: keep SimpleBar vertical scrollbar visible all the time (no fade after 2–3 sec) */
.left-sidebar .scroll-sidebar .simplebar-track.simplebar-vertical {
    opacity: 1;
    visibility: visible;
}

.left-sidebar .scroll-sidebar .simplebar-scrollbar:before {
    opacity: 0.5 !important;
    transition: none !important;
}

/* Amount formatting with tabular numbers for proper alignment */
body {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum"; 
}

.text-end {
    text-align: right !important;
}

/* Dark mode: pages that set light gray body inline still follow Bootstrap theme */
[data-bs-theme="dark"] body,
[data-bs-theme="dark"] body.link-sidebar {
    background-color: var(--bs-body-bg) !important;
}

[data-bs-theme="dark"] .body-wrapper {
    background-color: transparent;
}

[data-bs-theme="dark"] input[readonly],
[data-bs-theme="dark"] textarea[readonly],
[data-bs-theme="dark"] select[readonly] {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

/* Company logo: transparent PNG — dark-logo on light UI, light-logo on dark UI */
.brand-logo {
    padding: 12px 14px;
    min-height: 80px;
}

.brand-logo .logo-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    line-height: 0;
}

.brand-logo .sidebar-company-logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 70px;
    object-fit: contain;
    object-position: center center;
}

/* Theme-aware logos (works on load after company change, not only on theme toggle) */
[data-bs-theme="dark"] .brand-logo .dark-logo.sidebar-company-logo,
[data-bs-theme="dark"] .logo-img .dark-logo.sidebar-company-logo {
    display: none !important;
}

[data-bs-theme="dark"] .brand-logo .light-logo.sidebar-company-logo,
[data-bs-theme="dark"] .logo-img .light-logo.sidebar-company-logo {
    display: block !important;
}

[data-bs-theme="light"] .brand-logo .light-logo.sidebar-company-logo,
[data-bs-theme="light"] .logo-img .light-logo.sidebar-company-logo {
    display: none !important;
}

[data-bs-theme="light"] .brand-logo .dark-logo.sidebar-company-logo,
[data-bs-theme="light"] .logo-img .dark-logo.sidebar-company-logo {
    display: block !important;
}

/* Single logo file (no _inverse.png): lighten for dark sidebar */
[data-bs-theme="dark"] .sidebar-company-logo--mono {
    filter: brightness(0) invert(1);
}

/* Empty nav-small-cap (template section divider) — hide dots in collapsed sidebar */
body[data-sidebartype="mini-sidebar"] .nav-small-cap {
    display: none !important;
}

/* Collapsed sidebar: template uses .logo-img { width:40px; overflow:hidden } — scale logo instead of clipping */
[data-layout="vertical"] body[data-sidebartype="mini-sidebar"] .brand-logo .logo-img,
body[data-sidebartype="mini-sidebar"] .brand-logo .logo-img {
    width: 100% !important;
    max-width: 75px;
    overflow: visible !important;
}

[data-layout="vertical"] body[data-sidebartype="mini-sidebar"] .brand-logo .sidebar-company-logo,
body[data-sidebartype="mini-sidebar"] .brand-logo .sidebar-company-logo {
    width: 100%;
    max-width: 100%;
    max-height: 38px;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    object-position: center center;
}

[data-layout="vertical"] body[data-sidebartype="mini-sidebar"] .brand-logo,
body[data-sidebartype="mini-sidebar"] .brand-logo {
    min-height: 52px;
    padding: 8px 6px;
    overflow: hidden;
}

[data-layout="vertical"] body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .brand-logo .logo-img,
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .brand-logo .logo-img {
    max-width: 100%;
}

[data-layout="vertical"] body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .brand-logo .sidebar-company-logo,
body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .brand-logo .sidebar-company-logo {
    max-height: 70px;
}

/* Nested report submenu: Outside Jobwork under Report */
[data-layout="vertical"] .sidebar-nav ul.first-level ul.second-level {
    padding-left: 0;
    margin-left: 0;
}

[data-layout="vertical"] .sidebar-nav ul.first-level ul.second-level.in {
    display: block;
}

[data-layout="vertical"] .sidebar-nav ul.first-level ul.second-level .sidebar-item > .sidebar-link {
    padding: 8px 10px 8px 28px;
    gap: 15px;
}

[data-layout="vertical"] .sidebar-nav ul.first-level > .sidebar-item > a.sidebar-link.has-arrow {
    padding: 8px 10px;
    padding-right: 30px;
    gap: 15px;
}

/* Expand chevron (>) on nested submenu before click */

[data-layout="vertical"] .sidebar-nav ul.first-level > .sidebar-item > a.sidebar-link.has-arrow::after {
    display: block;
    content: "";
    position: absolute;
    width: 7px;
    height: 7px;
    border-width: 1px 0 0 1px;
    border-style: solid;
    border-color: var(--bs-dark-text-emphasis);
    right: 12px;
    top: 50%;
    margin-top: 0;
    transform: rotate(135deg) translate(0, -50%);
    transform-origin: top;
    transition: all 0.3s ease-out;
}

[data-layout="vertical"] .sidebar-nav ul.first-level > .sidebar-item > a.sidebar-link.has-arrow:hover::after {
    border-color: var(--bs-primary);
}

[data-layout="vertical"] .sidebar-nav ul.first-level > .sidebar-item.selected > a.sidebar-link.has-arrow::after,
[data-layout="vertical"] .sidebar-nav ul.first-level > .sidebar-item > a.sidebar-link.has-arrow.active::after {
    border-color: var(--bs-primary);
    transform: rotate(-135deg) translate(0, -50%);
}

[data-layout="vertical"] body[data-sidebartype="mini-sidebar"] .left-sidebar:hover .sidebar-nav ul.first-level > .sidebar-item > a.sidebar-link.has-arrow::after {
    display: block;
}
