:root{
    --navy:#071b2e;
    --navy2:#0d2944;
    --blue:#0d6efd;
    --bg:#f4f7fb;
    --text:#1b2b3a;
    --muted:#6d7d90;
    --line:#e6ebf1;
    --sidebar-width:290px;
    --sidebar-link:#c9d6e2;
    --sidebar-panel:rgba(255,255,255,.05);
    --sidebar-active:rgba(255,255,255,.13);
    --sidebar-active-border:rgba(255,255,255,.18);
}

html,body{height:100%}
body{
    margin:0;
    background:var(--bg);
    color:var(--text);
    font-family:Inter,Segoe UI,Arial,sans-serif;
}

a{ text-decoration:none; }

.app-shell{min-height:100vh}
.sidebar{
    width:var(--sidebar-width);
    background:linear-gradient(180deg,var(--navy) 0%, #0b2138 36%, var(--navy2) 100%);
    color:#fff;
    position:fixed;
    top:0;
    bottom:0;
    left:0;
    overflow:hidden;
    border-right:1px solid rgba(255,255,255,.05);
    box-shadow:0 0 40px rgba(4,17,30,.18);
}
.sidebar-inner{
    height:100%;
    overflow:auto;
    padding:20px 16px 24px;
}
.sidebar-inner::-webkit-scrollbar{width:8px}
.sidebar-inner::-webkit-scrollbar-thumb{background:rgba(255,255,255,.12);border-radius:8px}
.main-area{margin-left:var(--sidebar-width);min-width:0}

.brand-panel{
    display:flex;
    align-items:center;
    gap:14px;
    padding:14px;
    border-radius:18px;
    background:linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
    border:1px solid rgba(255,255,255,.07);
}
.brand-logo-wrap{
    width:60px;
    height:60px;
    border-radius:16px;
    background:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:6px;
    box-shadow:0 8px 20px rgba(0,0,0,.14);
    flex:0 0 auto;
}
.brand-logo{max-width:100%;max-height:100%;display:block}
.brand-copy strong{display:block;color:#fff;font-size:1.05rem;line-height:1.2}
.brand-copy small{display:block;color:#9fb0c1;font-size:.82rem;margin-top:2px}

.sidebar-nav{display:flex;flex-direction:column;gap:8px}
.sidebar-link,
.nav-group-toggle,
.sidebar-sublink{
    width:100%;
    border:0;
    background:transparent;
    color:var(--sidebar-link);
}
.sidebar-link,
.nav-group-toggle{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:12px 14px;
    border-radius:14px;
    transition:all .2s ease;
}
.sidebar-link span,
.nav-group-toggle span{
    display:flex;
    align-items:center;
    gap:12px;
    font-weight:600;
}
.sidebar-link i,
.nav-group-toggle span i{
    font-size:1rem;
    width:18px;
    text-align:center;
}
.sidebar-link:hover,
.nav-group-toggle:hover,
.sidebar-sublink:hover{
    color:#fff;
    background:rgba(255,255,255,.08);
}
.sidebar-link.active{
    background:linear-gradient(90deg, rgba(255,255,255,.14), rgba(255,255,255,.08));
    color:#fff;
    border:1px solid var(--sidebar-active-border);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.05);
}
.nav-group{
    border-radius:16px;
    background:var(--sidebar-panel);
    border:1px solid transparent;
}
.nav-group.open{
    border-color:rgba(255,255,255,.07);
}
.nav-group-toggle{font-weight:700}
.nav-group-toggle .caret{
    transition:transform .2s ease;
    font-size:.9rem;
}
.nav-group-toggle:not(.collapsed) .caret{transform:rotate(180deg)}
.submenu{
    padding:0 10px 10px 10px;
    display:flex;
    flex-direction:column;
    gap:4px;
}
.sidebar-sublink{
    display:flex;
    align-items:center;
    padding:10px 14px 10px 46px;
    border-radius:12px;
    font-size:.95rem;
    position:relative;
    transition:all .2s ease;
}
.sidebar-sublink:before{
    content:"";
    width:6px;
    height:6px;
    border-radius:50%;
    background:#7fa1c4;
    position:absolute;
    left:24px;
    top:50%;
    transform:translateY(-50%);
    opacity:.75;
}
.sidebar-sublink.active{
    background:rgba(255,255,255,.12);
    color:#fff;
    font-weight:700;
}
.sidebar-sublink.active:before{background:#fff;opacity:1}

.topbar{
    background:rgba(255,255,255,.94);
    backdrop-filter:blur(10px);
    border-bottom:1px solid var(--line);
    position:sticky;
    top:0;
    z-index:20;
}
.content{max-width:1600px}
.identity-icon{
    width:44px;
    height:44px;
    border-radius:14px;
    background:#eef5ff;
    display:grid;
    place-items:center;
    color:#4d64ff;
    font-size:1.05rem;
}
.identity-title{font-weight:800;line-height:1.1}
.identity-subtitle{font-size:.92rem;color:var(--muted)}
.user-meta strong{font-size:.88rem}
.theme-toggle{
    border:1px solid var(--line);
    background:#fff;
    color:#243547;
    border-radius:12px;
    min-width:92px;
}

.card{border:0;border-radius:18px;box-shadow:0 4px 18px rgba(20,45,75,.06)}
.stat-card{overflow:hidden}
.stat-icon{width:48px;height:48px;border-radius:14px;background:#eef5ff;display:grid;place-items:center;font-size:22px;color:#0d6efd}
.page-title{font-weight:750}
.table thead th{font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:#687788;background:#f8fafc}
.btn{border-radius:10px}
.form-control,.form-select{border-radius:10px}
.modal-content{border:0;border-radius:18px}

/* Login */
.login-page{
    min-height:100vh;
    background:radial-gradient(circle at top right,#143f68 0,#071b2e 46%,#04111e 100%);
    padding:24px;
    display:flex;
    align-items:center;
    justify-content:center;
}
.login-shell{
    width:min(1240px, 100%);
    min-height:min(760px, calc(100vh - 48px));
    display:grid;
    grid-template-columns:1.1fr .9fr;
    background:rgba(255,255,255,.03);
    border:1px solid rgba(255,255,255,.08);
    border-radius:30px;
    overflow:hidden;
    box-shadow:0 28px 80px rgba(0,0,0,.24);
}
.login-showcase{
    padding:56px 56px 40px;
    color:#fff;
    background:linear-gradient(135deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
    display:flex;
    align-items:flex-start;
}
.login-showcase-content{max-width:560px}
.login-logo-panel{display:flex;align-items:center;gap:16px}
.login-hero-logo{width:180px;max-width:100%;display:block}
.eyebrow{font-size:.82rem;letter-spacing:.14em;font-weight:700;color:#c7d6ea;margin-bottom:16px}
.login-headline{font-size:2.45rem;line-height:1.15;font-weight:800;margin:0 0 16px}
.login-copy{font-size:1.02rem;line-height:1.7;color:#cfdae6;margin-bottom:22px}
.login-points{list-style:none;padding:0;margin:0;display:grid;gap:12px}
.login-points li{position:relative;padding-left:22px;color:#f2f6fb}
.login-points li:before{content:"";width:8px;height:8px;border-radius:50%;background:#77c1ff;position:absolute;left:0;top:.62rem}
.login-form-wrap{
    background:#f7f9fc;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:30px;
}
.login-card{
    max-width:450px;
    width:100%;
    border-radius:26px;
    border:1px solid rgba(7,27,46,.06);
    box-shadow:0 22px 60px rgba(10,30,60,.12);
}
.login-card-logo{height:74px;width:auto;display:block;margin-left:auto;margin-right:auto}

/* Modal scroll fix */
.modal{overflow-y:auto !important}
.modal-dialog{margin-top:1rem;margin-bottom:1rem}
.modal-dialog:not(.modal-dialog-centered){min-height:calc(100vh - 2rem)}
.modal-content{max-height:calc(100vh - 2rem);overflow:hidden;display:flex;flex-direction:column}
.modal-header{flex:0 0 auto;background:var(--bs-body-bg,#fff);z-index:3}
.modal-body{flex:1 1 auto;min-height:0;overflow-y:auto !important;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.modal-footer{flex:0 0 auto;position:sticky;bottom:0;z-index:4;background:var(--bs-body-bg,#fff);border-top:1px solid var(--bs-border-color,#dee2e6)}
.modal-content .modal-actions,
.modal-content .form-actions,
.modal-content .dialog-actions{position:sticky;bottom:0;z-index:4;background:var(--bs-body-bg,#fff)}
.modal-body select[multiple]{max-height:240px}

/* Dark mode */
html[data-bs-theme='dark'] body{background:#0c1621;color:#ecf1f8}
html[data-bs-theme='dark'] .topbar,
html[data-bs-theme='dark'] .card,
html[data-bs-theme='dark'] .theme-toggle,
html[data-bs-theme='dark'] .login-form-wrap,
html[data-bs-theme='dark'] .login-card{background:#111d2a;color:#ecf1f8}
html[data-bs-theme='dark'] .topbar{border-color:rgba(255,255,255,.06)}
html[data-bs-theme='dark'] .identity-icon{background:#152334;color:#9fc3ff}
html[data-bs-theme='dark'] .table thead th{background:#152334;color:#bfd2e6}
html[data-bs-theme='dark'] .theme-toggle{border-color:rgba(255,255,255,.08);color:#ecf1f8}
html[data-bs-theme='dark'] .login-showcase{background:linear-gradient(135deg, rgba(255,255,255,.04), rgba(255,255,255,.01))}
html[data-bs-theme='dark'] .login-form-wrap{background:#0f1a26}
html[data-bs-theme='dark'] .text-muted{color:#93a5b8 !important}

@media (max-width: 1100px){
    .login-shell{grid-template-columns:1fr}
    .login-showcase{padding:38px 30px 8px}
    .login-headline{font-size:2rem}
}

@media(max-width:900px){
    .sidebar{width:82px}
    .main-area{margin-left:82px}
    .brand-panel{justify-content:center;padding:12px}
    .brand-copy{display:none}
    .brand-logo-wrap{width:48px;height:48px;border-radius:14px}
    .sidebar-link span,
    .nav-group-toggle span{font-size:0;gap:0}
    .sidebar-link i,
    .nav-group-toggle span i{font-size:1.08rem;width:auto}
    .nav-group-toggle{justify-content:center}
    .nav-group-toggle .caret{display:none}
    .submenu{padding:0 6px 8px}
    .sidebar-sublink{padding:9px 10px 9px 10px;font-size:0;min-height:38px}
    .sidebar-sublink:before{left:50%;transform:translate(-50%,-50%)}
}

@media (max-width: 767.98px){
    .content{padding:18px !important}
    .topbar{padding-left:18px !important;padding-right:18px !important}
    .modal-dialog{margin:.5rem}
    .modal-content{max-height:calc(100vh - 1rem)}
    .login-page{padding:14px}
    .login-form-wrap{padding:16px}
    .login-card{border-radius:22px}
}
