html,
body {
    font-size: 16px;
    height: 100%;
    margin: 0;
    padding: 0;
    max-width: 100%;
    box-sizing: border-box;
    font-family: var(--font-body);
}

/* ===============================
   APP SHELL — DESKTOP SIDEBAR
   =============================== */

.app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: var(--brand);
    border-right: none;
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow: hidden;
}

.app-topbar {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    height: 52px;
    background: #ffffff;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

@media (max-width: 991px) {
    .app-topbar {
        left: 0;
    }
}

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

@media (min-width: 992px) {
    .app-main {
        margin-left: 240px;
    }
}

/* ===============================
   SIDEBAR BRAND
   =============================== */

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-brand-logo,
.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
}

.sidebar-brand-name {
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.3px;
}

/* ===============================
   SIDEBAR NAV SCROLL AREA
   =============================== */

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

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

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 4px 6px 8px;
}

/* ===============================
   SIDEBAR FOOTER
   =============================== */

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    background: rgba(0,0,0,0.15);
}

.sidebar-footer .dropdown {
    width: 100%;
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    text-decoration: none;
    text-align: left;
}

.sidebar-footer-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}

.sidebar-footer-btn .sidebar-footer-icon {
    width: 26px;
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-footer-btn:hover .sidebar-footer-icon {
    color: rgba(255,255,255,0.9);
}

.sidebar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.25);
}


/* ===============================
   TOP BAR ELEMENTS
   =============================== */

.topbar-toggle,
.sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #ffc107;
    border: none;
    color: #000;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.18s ease;
    margin-right: 10px;
    flex-shrink: 0;
}

.topbar-toggle:hover,
.sidebar-toggle-btn:hover {
    background: #ffca2c;
    color: #000;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: 0.1px;
}

/* Permanent Dashboard button in topbar */
.topbar-dash-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border-radius: 9px;
    background: #ffc107;
    color: #000;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.topbar-dash-btn:hover,
.topbar-dash-btn.active {
    background: #ffca2c;
    color: #000;
}

/* Restyle topbar action buttons for white background */
.app-topbar .btn-outline-light {
    --bs-btn-color: #374151;
    --bs-btn-border-color: #d1d5db;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}

.app-topbar .btn-light {
    --bs-btn-bg: var(--brand);
    --bs-btn-color: #fff;
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-hover);
    --bs-btn-hover-border-color: var(--brand-hover);
    --bs-btn-hover-color: #fff;
}

/* ===============================
   MOBILE PAGE SUB-BAR
   (action tabs below topbar on mobile)
   =============================== */

.page-subbar {
    background: var(--brand);
    padding: 0 8px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.page-subbar:empty {
    display: none !important;
}

.page-subbar::-webkit-scrollbar {
    display: none;
}

/* topbar-tab inside sub-bar gets slightly bigger touch target */
.page-subbar .topbar-tab {
    padding: 6px 14px;
    font-size: 0.83rem;
    flex-shrink: 0;
}


/* ===============================
   OFFCANVAS SIDEBAR MOBILE
   =============================== */

.offcanvas.offcanvas-start {
    width: 260px;
    background: var(--brand) !important;
}

/* ===============================
   TOPBAR ACTIONS / TABS
   =============================== */

.topbar-actions {
    flex-shrink: 0;
}


.topbar-tab {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.topbar-tab:hover {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
}

.topbar-tab.active {
    background: rgba(255,255,255,0.18);
    color: #ffffff;
}

/* ===============================
   SIDEBAR MENU — NAV CARDS
   =============================== */

.sidebar-menu {
    display: grid;
    gap: 2px;
    padding: 4px 0;
}

.nav-card,
.nav-group summary.nav-card {
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.2px;
    padding: 9px 10px;
    min-height: 42px;

    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.75);

    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    text-decoration: none !important;
}

.nav-card:hover,
.nav-group summary.nav-card:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}

.nav-card-active {
    background: rgba(255,255,255,0.15) !important;
    color: #ffffff !important;
}

.nav-card .icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: rgba(255,255,255,0.5);
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.nav-card:hover .icon,
.nav-card-active .icon,
.nav-group summary.nav-card:hover .icon {
    color: rgba(255,255,255,0.9);
}

.nav-card .label {
    font-size: 1.05rem;
    font-weight: 600;
    font-family: var(--font-body);
}

.nav-group summary {
    list-style: none;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-card .caret {
    margin-left: auto;
    font-size: 11px;
    color: rgba(255,255,255,0.3);
    transition: transform 0.22s ease;
}

.nav-group[open] .caret {
    transform: rotate(90deg);
}

.child-links {
    list-style: none;
    margin: 2px 0 4px;
    padding-left: 2rem;

    max-height: 0;
    overflow: hidden;
    opacity: 0;

    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.nav-group[open] .child-links {
    max-height: 500px;
    opacity: 1;
}

.child-links li a {
    display: block;
    padding: 5px 6px;
    font-size: 0.97rem;
    font-weight: 500;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.child-links li a:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}

/* Remove underlines from all sidebar links */
.app-sidebar a,
.app-sidebar a:hover,
.app-sidebar summary,
.app-sidebar summary:hover,
.offcanvas a,
.offcanvas a:hover,
.offcanvas summary,
.offcanvas summary:hover {
    text-decoration: none !important;
}

/* ===============================
   SIDEBAR DROPDOWN MENUS
   =============================== */

.sidebar-footer .dropdown-menu,
.sidebar-nav .dropdown-menu {
    min-width: 220px;
    border-radius: 10px;
    border: 1px solid rgba(0,9,61,0.1);
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    animation: dropdownLift 0.15s ease-out;
}

.sidebar-footer .dropdown-item,
.sidebar-nav .dropdown-item {
    color: var(--brand);
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 2px 6px;
    width: calc(100% - 12px);
    font-size: 0.875rem;
    transition: background 0.15s ease;
}

.sidebar-footer .dropdown-item:hover,
.sidebar-nav .dropdown-item:hover {
    background: var(--brand-light, #eef2ff);
    color: var(--brand);
}

.sidebar-footer .dropdown-item small {
    font-size: 0.75rem;
    color: #64748b;
}

@keyframes dropdownLift {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ===============================
   SIDEBAR POS CTA BUTTON
   =============================== */

.sidebar-pos-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    margin: 4px 0 10px;
    border-radius: 10px;
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #ffffff !important;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none !important;
    box-shadow: 0 2px 10px rgba(22, 163, 74, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    letter-spacing: 0.1px;
}

.sidebar-pos-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.5);
    color: #ffffff !important;
}

.sidebar-pos-btn i {
    font-size: 1rem;
}

/* ===============================
   SEGMENTED NAV (minimal right-aligned pills)
   =============================== */

.nav-seg-group {
    display: inline-flex;
    gap: 2px;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
}

.nav-seg {
    display: inline-flex;
    align-items: center;
    padding: 5px 13px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

.nav-seg:hover {
    background: rgba(0,0,0,0.05);
    color: #1e293b;
}

.nav-seg.active {
    background: #ffffff;
    color: var(--brand);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}


/* ===============================
   SIDEBAR COLLAPSE TOGGLE
   =============================== */

/* ===============================
   COLLAPSE BAR (top strip)
   =============================== */

.sidebar-collapse-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 7px;
    background: #ffc107;
    color: #000;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: #ffca2c;
    color: #000;
}

.sidebar-collapse-btn .collapse-icon {
    transition: transform 0.25s ease;
}

/* ===============================
   COLLAPSED STATE  (body class)
   =============================== */

body.sidebar-collapsed .app-sidebar {
    width: 64px;
    overflow: visible;
}

body.sidebar-collapsed .app-topbar {
    left: 64px;
}

body.sidebar-collapsed .app-main {
    margin-left: 64px;
}

/* Hide text, caret, badges */
body.sidebar-collapsed .sidebar-brand-name,
body.sidebar-collapsed .nav-card .label,
body.sidebar-collapsed .nav-card .caret,
body.sidebar-collapsed .sidebar-footer-btn > span,
body.sidebar-collapsed .sidebar-footer-btn > .badge,
body.sidebar-collapsed .sidebar-pos-btn > span {
    display: none !important;
}

/* Hide child link lists even if details is [open] */
body.sidebar-collapsed .child-links {
    display: none !important;
}

/* Center everything */
body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 14px 0 12px;
}

body.sidebar-collapsed .nav-card,
body.sidebar-collapsed .nav-group summary.nav-card {
    justify-content: center;
    padding: 10px 0;
}

body.sidebar-collapsed .nav-card .icon {
    width: 28px;
    margin: 0;
}

body.sidebar-collapsed .sidebar-footer-btn {
    justify-content: center;
    padding: 9px 0;
}

body.sidebar-collapsed .sidebar-pos-btn {
    padding: 11px 0;
    justify-content: center;
}

/* Collapse bar: center the button when collapsed */
body.sidebar-collapsed .sidebar-collapse-bar {
    justify-content: center;
    padding: 6px 0;
}

/* Flip the collapse arrow when collapsed */
body.sidebar-collapsed .sidebar-collapse-btn .collapse-icon {
    transform: rotate(180deg);
}
