:root {
    --app-primary: #1b3a5b;
    --app-primary-2: #24507a;
    --app-accent: #c9a227;
    --app-bg: #f4f6f9;
}

body {
    background: var(--app-bg);
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
}

.app-topbar {
    background: linear-gradient(90deg, var(--app-primary), var(--app-primary-2));
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}

.app-topbar .navbar-brand { color: #fff; }
.app-topbar .navbar-brand i { color: var(--app-accent); }

.app-main { min-height: calc(100vh - 56px); }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--app-accent);
}

.page-header h1 { font-size: 1.35rem; margin: 0; color: var(--app-primary); }

.card { border: none; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }

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

.table thead th { background: var(--app-primary); color: #fff; white-space: nowrap; }
.table-hover tbody tr:hover { background: #eef3f8; }

.required label::after,
label.required::after { content: " *"; color: #dc3545; }

/* Loading overlay */
.app-loading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1080;
}

/* Toast alert host */
.app-alert-host {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 1090;
    width: 340px;
    max-width: 90vw;
}

/* Login */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--app-primary), #0d1f30);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}

.login-card .brand {
    text-align: center;
    margin-bottom: 1.25rem;
    color: var(--app-primary);
}

.login-card .brand i { color: var(--app-accent); font-size: 2rem; }


/* ===== Vertical sidebar layout ===== */
.app-topbar { position: sticky; top: 0; z-index: 1030; min-height: 52px; }

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - 52px);
}

.app-sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: #ffffff;
    border-right: 1px solid #e3e7ee;
    overflow-y: auto;
    max-height: calc(100vh - 52px);
    position: sticky;
    top: 52px;
}

.app-sidebar .accordion { --bs-accordion-border-width: 0; }

/* Top-level direct link (Dashboard) */
.app-sidebar-link {
    display: flex;
    align-items: center;
    padding: .6rem 1rem;
    color: var(--app-primary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid #f0f2f6;
}
.app-sidebar-link:hover { background: #eef3f8; color: var(--app-primary-2); }

/* Group heading buttons */
.app-menu-group { border-bottom: 1px solid #f0f2f6; }
.app-menu-head {
    display: flex;
    align-items: center;
    width: 100%;
    padding: .6rem 1rem;
    background: transparent;
    border: 0;
    color: var(--app-primary);
    font-weight: 600;
    text-align: left;
}
.app-menu-head:hover { background: #eef3f8; }
.app-menu-head .bi-chevron-down { transition: transform .2s ease; font-size: .8rem; }
.app-menu-head:not(.collapsed) { background: #eef3f8; }
.app-menu-head:not(.collapsed) .bi-chevron-down { transform: rotate(180deg); }

/* Sub links */
.app-sidebar-sublink {
    display: block;
    padding: .45rem 1rem .45rem 2.5rem;
    color: #33415c;
    text-decoration: none;
    font-size: .9rem;
}
.app-sidebar-sublink:hover { background: #f4f6f9; color: var(--app-primary); }
.app-sidebar-sublink.active,
.app-sidebar-link.active {
    background: var(--app-primary);
    color: #fff;
    border-left: 3px solid var(--app-accent);
}

.app-sidebar-header {
    padding: .5rem 1rem .25rem;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #8a94a6;
    font-weight: 700;
}

.app-main { flex: 1 1 auto; min-width: 0; }

/* Mobile: sidebar slides over content */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: 52px;
        left: 0;
        bottom: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 2px 0 8px rgba(0,0,0,.15);
    }
    .app-sidebar.open { transform: translateX(0); }
}
