:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-color: #94a3b8;
    --sidebar-active-bg: #2563eb;
    --sidebar-active-color: #ffffff;
    --topbar-height: 64px;
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: #334155;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Sidebar Styling */
#sidebar-wrapper {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.05);
    transition: left 0.25s ease-in-out;
}

#sidebar-wrapper .sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(0, 0, 0, 0.2);
}

#sidebar-wrapper .sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.nav-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0.75rem 1.5rem 0.25rem;
    font-weight: 700;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.25rem;
    color: var(--sidebar-color);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-link i {
    width: 24px;
    font-size: 1rem;
    margin-right: 0.75rem;
    text-align: center;
}

.sidebar-link:hover {
    color: #f8fafc;
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
    color: var(--sidebar-active-color);
    background-color: rgba(37, 99, 235, 0.15);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-dropdown .sidebar-link {
    padding-left: 3rem;
    font-size: 0.83rem;
}

/* ── Content & Topbar ── */
#wrapper {
    min-height: 100vh;
}

/* page-content-wrapper is a normal block element.
   margin-left pushes it past the fixed sidebar.
   It naturally fills 100% of remaining viewport width. */
#page-content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--topbar-height);
    transition: margin-left 0.25s ease-in-out;
}

/* Topbar is fixed, anchored between sidebar right-edge and viewport right */
.topbar {
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1030;
    box-sizing: border-box;
    transition: left 0.25s ease-in-out;
}

.main-content {
    flex-grow: 1;
    padding: 1.75rem;
    min-width: 0;
}

/* ── Desktop: Toggle collapses sidebar, content expands to fill full width ── */
body.sidebar-collapsed #sidebar-wrapper {
    left: calc(-1 * var(--sidebar-width));
}
body.sidebar-collapsed #page-content-wrapper {
    margin-left: 0;
}
body.sidebar-collapsed .topbar {
    left: 0;
}

/* ── Mobile (≤991px): sidebar hidden by default, overlays when shown ── */
@media (max-width: 991.98px) {

    /* Sidebar hidden off-screen by default */
    #sidebar-wrapper {
        left: calc(-1 * var(--sidebar-width));
        z-index: 1050;
    }

    /* Content always full width on mobile — sidebar overlays, never pushes */
    #page-content-wrapper {
        margin-left: 0;
    }

    /* Topbar always full width on mobile */
    .topbar {
        left: 0;
    }

    /* Clicking hamburger on mobile SHOWS the sidebar (sidebar-collapsed = open on mobile) */
    body.sidebar-collapsed #sidebar-wrapper {
        left: 0;
    }
    body.sidebar-collapsed #page-content-wrapper {
        margin-left: 0; /* content stays full width, sidebar overlays */
    }
    body.sidebar-collapsed .topbar {
        left: 0;
    }

    /* Dim overlay behind sidebar when open on mobile */
    body.sidebar-collapsed::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1045;
        transition: opacity 0.25s;
    }
}

.card {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    background-color: var(--card-bg);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0.75rem 0.75rem 0 0 !important;
}

.card-body {
    padding: 1.25rem;
}

/* Stat Cards */
.stat-card {
    border-left: 4px solid var(--primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

/* Tables */
.table {
    margin-bottom: 0;
    font-size: 0.88rem;
}

.table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    font-weight: 600;
    padding: 0.35em 0.65em;
    border-radius: 6px;
    font-size: 0.75rem;
}

.badge-draft { background-color: #e2e8f0; color: #475569; }
.badge-pending { background-color: #fef3c7; color: #92400e; }
.badge-approved { background-color: #d1fae5; color: #065f46; }
.badge-rejected { background-color: #fee2e2; color: #991b1b; }
.badge-active { background-color: #dcfce7; color: #166534; }
.badge-inactive { background-color: #f1f5f9; color: #64748b; }
.badge-paid { background-color: #d1fae5; color: #065f46; }
.badge-due { background-color: #fee2e2; color: #991b1b; }
.badge-partial { background-color: #e0e7ff; color: #3730a3; }

/* Buttons */
.btn {
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.45rem 0.9rem;
    transition: all 0.2s;
}

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

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

/* ==========================================================================
   Select2 Bootstrap 5 Integration Polish
   ========================================================================== */
.select2-container {
    display: block;
    width: 100% !important;
}

.select2-container--bootstrap-5 .select2-selection {
    border-color: #cbd5e1;
    color: #334155;
    font-size: 0.875rem;
    min-height: 38px;
    border-radius: 0.375rem;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.select2-container--bootstrap-5 .select2-selection--single {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-color: #cbd5e1;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    z-index: 1065;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-search {
    padding: 0.5rem;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field {
    border-radius: 0.375rem;
    border-color: #cbd5e1;
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.15rem rgba(37, 99, 235, 0.18);
}

.select2-container--bootstrap-5 .select2-results__options {
    max-height: 240px;
}

.select2-container--bootstrap-5 .select2-results__option {
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
    color: #1e293b;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: var(--primary);
    color: #ffffff;
}

.select2-container--bootstrap-5 .select2-results__option--selected {
    background-color: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

/* Small Select2 (.form-select-sm) */
.select2-container--bootstrap-5 .select2--small .select2-selection,
.select2-container--bootstrap-5.select2-container--small .select2-selection {
    min-height: 31px;
    font-size: 0.8rem;
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
    border-radius: 0.3rem;
}

.select2-container--bootstrap-5 .select2--small .select2-selection__rendered,
.select2-container--bootstrap-5.select2-container--small .select2-selection__rendered {
    line-height: 1.6;
}

/* Modal compatibility */
.modal .select2-container {
    z-index: 1060;
}



