html, body {
    height: 100%;
    margin: 0;
}

body {
    background-color: #f4f6f8;
    color: #17202a;
    font-size: 0.95rem;
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

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

.sidebar {
    width: 260px;
    background: #16202a;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    box-shadow: 6px 0 24px rgba(16, 24, 40, 0.12);
}

.sidebar-brand {
    padding: 0.5rem 0.5rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sidebar-link {
    color: rgba(255,255,255,0.88);
    text-decoration: none;
    padding: 0.7rem 0.9rem;
    border-radius: 0.45rem;
    display: flex;
    align-items: center;
    transition: all 0.2s ease-in-out;
}

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

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #d9e0e7;
    padding: 1rem 1.5rem;
}

.topbar-actions {
    align-items: center;
    display: flex;
    gap: 0.65rem;
}

.topbar-user {
    border-right: 1px solid #d9e0e7;
    line-height: 1.2;
    margin-right: 0.15rem;
    padding-right: 0.85rem;
}

.page-content {
    padding: 1.5rem;
}

/* =========================
   SIDEBAR GROUPS
========================= */
.sidebar-group-title {
    color: rgba(255,255,255,0.55);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.5rem 0.9rem;
}

.sidebar-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-submenu {
    margin: 0.25rem 0 0.75rem;
    padding-left: 0.5rem;
}

.sidebar-sublink {
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    padding: 0.6rem 0.9rem 0.6rem 1.5rem;
    border-radius: 0.4rem;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    transition: all 0.2s ease-in-out;
}

    .sidebar-sublink:hover {
        background-color: rgba(255,255,255,0.08);
        color: #fff;
    }

.sidebar-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.sidebar-link[aria-expanded="false"] .bi-chevron-down {
    transform: rotate(0deg);
}

/* =========================
   AUTH PAGES (LOGIN)
========================= */
.public-shell {
    min-height: 100vh;
    background-color: #f4f6f8;
}

.public-content {
    min-height: 100vh;
}

/* Centered login wrapper */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* 🔥 SMALLER LOGIN CARD */
.auth-card-wrapper {
    max-width: 320px; /* reduced from 420 */
    width: 100%;
}

/* Optional tighter card spacing */
.auth-page .card {
    border-radius: 0.9rem;
}

.auth-page .card-body {
    padding: 1.5rem !important;
}

/* =========================
   GLOBAL UI
========================= */
.card {
    border: 1px solid #dde4ec;
    border-radius: 0.5rem;
    box-shadow: 0 10px 22px rgba(16, 24, 40, 0.06) !important;
}

.form-control,
.form-select {
    border-color: #cbd5df;
    border-radius: 0.4rem;
}

.btn {
    border-radius: 0.4rem;
    font-weight: 600;
}

.btn-primary {
    background-color: #1d4f91;
    border-color: #1d4f91;
}

.btn-primary:hover {
    background-color: #173f75;
    border-color: #173f75;
}

.btn-icon {
    align-items: center;
    border: 1px solid #cbd5df;
    color: #435365;
    display: inline-flex;
    height: 2rem;
    justify-content: center;
    padding: 0;
    width: 2rem;
}

.page-heading {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.metric-card {
    background: #fff;
    border: 1px solid #dde4ec;
    border-radius: 0.5rem;
    box-shadow: 0 10px 22px rgba(16, 24, 40, 0.06);
    min-height: 112px;
    padding: 1rem;
}

.metric-label {
    color: #5e6b78;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-value {
    color: #15202b;
    font-size: 1.65rem;
    font-weight: 750;
    margin-top: 0.35rem;
}

.metric-value.expense {
    color: #9f2d20;
}

.metric-note {
    color: #6b7785;
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

.section-tabs {
    background: #fff;
    border: 1px solid #dde4ec;
    border-radius: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.35rem;
}

.section-tab {
    border-radius: 0.35rem;
    color: #435365;
    font-weight: 700;
    padding: 0.55rem 0.8rem;
    text-decoration: none;
}

.section-tab:hover {
    background: #eef3f8;
    color: #16202a;
}

.section-tab.active {
    background: #1d4f91;
    color: #fff;
}

.empty-state {
    background: #f8fafc;
    border: 1px dashed #cbd5df;
    border-radius: 0.5rem;
    color: #667789;
    padding: 2rem;
    text-align: center;
}

.role-check-grid {
    display: grid;
    gap: 0.45rem;
}

.role-check-grid-inline {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.role-check {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #dde4ec;
    border-radius: 0.4rem;
    display: flex;
    gap: 0.45rem;
    margin: 0;
    padding: 0.45rem 0.6rem;
}

.table {
    color: #1f2a37;
}

.table thead th {
    background: #f7f9fb;
    color: #52606d;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.user-management-table .clickable-row {
    cursor: pointer;
}

.user-management-table .clickable-row:hover td {
    background: #f8fafc;
}

.user-avatar {
    align-items: center;
    background: linear-gradient(135deg, #16202a, #1d4f91);
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.select2-container--default .select2-selection--multiple {
    border-color: #cbd5df;
    border-radius: 0.4rem;
    min-height: 38px;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* =========================
   CHART
========================= */
.chart-container {
    position: relative;
    width: 100%;
    height: 35vh;
    padding-top: 10px;
}

    .chart-container canvas {
        width: 100% !important;
        height: 100% !important;
    }

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 991.98px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .topbar {
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .topbar-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .topbar-user {
        display: none;
    }
}


/* =========================
   REPORTS
========================= */
.report-page .table th,
.report-page .table td {
    vertical-align: middle;
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .sidebar-footer,
    .report-toolbar,
    .alert,
    .d-print-none {
        display: none !important;
    }

    .page-content,
    .main-content {
        padding: 0 !important;
        margin: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}
