:root{
    --sidebar-width-expanded: 280px;
    --sidebar-width-collapsed: 92px;
    --app-bg-1: #03101f;
    --app-bg-2: #021426;
    --panel-bg: rgba(10, 23, 42, 0.82);
    --panel-border: rgba(110, 164, 255, 0.16);
    --text-main: #f5f7fb;
    --text-soft: #9aa7bd;
    --accent: #3ddc97;
    --accent-2: #60a5fa;
}

html, body {
    min-height: 100%;
}

body.app-body{
    margin: 0;
    color: var(--text-main);
    background:
        radial-gradient(circle at top right, rgba(24, 117, 87, 0.24), transparent 26%),
        radial-gradient(circle at left center, rgba(13, 77, 149, 0.18), transparent 24%),
        linear-gradient(90deg, var(--app-bg-1), var(--app-bg-2));
    font-family: "Segoe UI", Tahoma, sans-serif;
    overflow-x: hidden;
}

/* Sidebar */
.app-sidebar{
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: var(--sidebar-width-collapsed);
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 16px 16px;
    background: linear-gradient(180deg, rgba(8, 20, 38, 0.97), rgba(5, 15, 30, 0.98));
    border-right: 1px solid rgba(80, 129, 255, 0.18);
    box-shadow: 8px 0 30px rgba(0,0,0,0.25);
    transition: width .25s ease, transform .25s ease;
    overflow: hidden;
}

.app-sidebar:hover{
    width: var(--sidebar-width-expanded);
}

.sidebar-brand{
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    min-height: 56px;
    flex-shrink: 0;
}

.brand-badge{
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.6rem;
    color: #07251a;
    background: linear-gradient(135deg, #8bf3b4, #72f0d2);
    box-shadow: 0 8px 25px rgba(61,220,151,.28);
}

.brand-copy{
    min-width: 0;
    opacity: 0;
    transform: translateX(-8px);
    transition: .2s ease;
    white-space: nowrap;
}

.app-sidebar:hover .brand-copy{
    opacity: 1;
    transform: translateX(0);
}

.brand-title{
    font-size: 1.05rem;
    font-weight: 700;
    color: #f8fbff;
    line-height: 1.15;
}

.brand-subtitle{
    font-size: .78rem;
    color: var(--text-soft);
    margin-top: 2px;
}

.sidebar-user{
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(120, 152, 255, 0.14);
    border-radius: 22px;
    padding: 16px;
    margin-bottom: 18px;
    min-height: 104px;
    opacity: 0;
    transition: .2s ease;
    overflow: hidden;
    flex-shrink: 0;
}

.app-sidebar:hover .sidebar-user{
    opacity: 1;
}

.sidebar-user-name{
    font-size: .95rem;
    font-weight: 700;
    color: #f2f6fb;
    margin-bottom: 6px;
}

.sidebar-user-role{
    font-size: .8rem;
    color: var(--text-soft);
}

/* This is the important fix */
.sidebar-nav{
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
    padding-bottom: 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(110,164,255,.35) transparent;
}

.sidebar-nav::-webkit-scrollbar{
    width: 8px;
}

.sidebar-nav::-webkit-scrollbar-track{
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb{
    background: rgba(110,164,255,.28);
    border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover{
    background: rgba(110,164,255,.45);
}

.sidebar-link{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #dbe6f3;
    text-decoration: none;
    border-radius: 20px;
    padding: 14px 14px;
    min-height: 58px;
    border: 1px solid transparent;
    transition: .2s ease;
    flex-shrink: 0;
}

.sidebar-link:hover{
    color: #fff;
    background: rgba(70, 110, 180, 0.12);
    border-color: rgba(87, 145, 255, 0.18);
}

.sidebar-link.active{
    background: linear-gradient(135deg, rgba(19, 74, 57, 0.72), rgba(18, 44, 76, 0.82));
    border-color: rgba(61, 220, 151, 0.24);
    box-shadow: inset 0 0 0 1px rgba(61,220,151,.08);
}

.sidebar-link-left{
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.sidebar-link-left i{
    min-width: 22px;
    font-size: 1.25rem;
    text-align: center;
}

.sidebar-link-left span:last-child{
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-8px);
    transition: .2s ease;
}

.app-sidebar:hover .sidebar-link-left span:last-child{
    opacity: 1;
    transform: translateX(0);
}

/* Footer now really stays at bottom */
.sidebar-footer{
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 14px;
    margin-top: 12px;
    opacity: 0;
    transition: .2s ease;
}

.app-sidebar:hover .sidebar-footer{
    opacity: 1;
}

.sidebar-mini-link{
    color: var(--text-soft);
    text-decoration: none;
    font-size: .92rem;
    white-space: nowrap;
}

.sidebar-mini-link:hover{
    color: #fff;
}

/* Main area */
.app-main{
    margin-left: var(--sidebar-width-collapsed);
    min-height: 100vh;
    transition: margin-left .25s ease;
    padding: 24px 24px 32px;
}

@media (min-width: 992px){
    .app-sidebar:hover ~ .app-main,
    body:has(.app-sidebar:hover) .app-main{
        margin-left: var(--sidebar-width-expanded);
    }
}

/* Topbar */
.topbar{
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    padding: 20px 24px;
    margin-bottom: 26px;
    box-shadow: 0 14px 35px rgba(0,0,0,.18);
}

.topbar-title{
    margin: 0 0 6px;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
}

.topbar-subtitle{
    color: var(--text-soft);
    font-size: 1rem;
}

.topbar-right{
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar-user{
    text-align: right;
}

.topbar-user-name{
    font-weight: 700;
    color: #fff;
}

.topbar-user-role{
    color: var(--text-soft);
    font-size: .9rem;
}

.status-pill{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #86efac;
    background: rgba(30, 90, 60, 0.28);
    border: 1px solid rgba(61,220,151,.26);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: .92rem;
    white-space: nowrap;
}

/* Panels */
.hero-panel,
.section-card{
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    padding: 24px;
    box-shadow: 0 14px 35px rgba(0,0,0,.16);
}

.hero-panel{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.hero-kicker,
.section-label{
    font-size: .86rem;
    color: var(--text-soft);
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.hero-title{
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.hero-subtitle{
    color: var(--text-soft);
    font-size: 1rem;
}

/* Forms */
.form-control,
.form-select{
    min-height: 50px;
    border-radius: 18px;
    border: 1px solid rgba(120, 155, 255, 0.16);
    background: rgba(255,255,255,0.96);
}

.form-label{
    color: #dfe8f6;
    font-weight: 500;
    margin-bottom: 8px;
}

/* Tables */
.tactical-table{
    --bs-table-bg: transparent;
    --bs-table-color: #e8eef9;
    --bs-table-border-color: rgba(255,255,255,0.08);
}

.tactical-table thead th{
    color: #ffffff;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
}

.tactical-table tbody td{
    color: #d9e6f4;
    vertical-align: middle;
}

.tactical-table tbody tr:hover{
    background: rgba(255,255,255,0.03);
}

/* Mobile */
.sidebar-toggle-mobile{
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1055;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 14px;
    display: none;
    place-items: center;
    color: #fff;
    background: rgba(8, 22, 40, 0.92);
    box-shadow: 0 10px 30px rgba(0,0,0,.24);
}

.sidebar-overlay{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: .2s ease;
}

@media (max-width: 991.98px){
    .sidebar-toggle-mobile{
        display: grid;
    }

    .app-sidebar{
        width: var(--sidebar-width-expanded);
        transform: translateX(-100%);
        overflow-y: auto;
    }

    .app-sidebar:hover{
        width: var(--sidebar-width-expanded);
    }

    .brand-copy,
    .sidebar-user,
    .sidebar-link-left span:last-child,
    .sidebar-footer{
        opacity: 1 !important;
        transform: none !important;
    }

    body.sidebar-open .app-sidebar{
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay{
        opacity: 1;
        visibility: visible;
    }

    .app-main{
        margin-left: 0;
        padding: 72px 16px 24px;
    }

    .topbar{
        padding: 18px;
        border-radius: 22px;
    }

    .topbar-title{
        font-size: 1.45rem;
    }

    .hero-panel,
    .section-card{
        padding: 18px;
        border-radius: 22px;
    }
}