:root{
    --sidebar-w: 290px;
    --topbar-h: 68px;
    --bg: #f4f7fb;
    --panel: #ffffff;
    --border: #e8edf4;
    --text: #1f2937;
    --muted: #6b7280;
    --brand1: #0f172a;
    --brand2: #1d4ed8;
    --shadow: 0 18px 40px rgba(15, 23, 42, .08);
    --surface-2: #f8fafc;
    --table-head: #f8fafc;
    --sidebar-bg: #ffffff;
}

html[data-theme="light"]{
    --bg: #f4f7fb;
    --panel: #ffffff;
    --border: #e8edf4;
    --text: #1f2937;
    --muted: #6b7280;
    --brand1: #0f172a;
    --brand2: #1d4ed8;
    --shadow: 0 18px 40px rgba(15, 23, 42, .08);
    --surface-2: #f8fafc;
    --table-head: #f8fafc;
    --sidebar-bg: #ffffff;
}

html[data-theme="blue"]{
    --bg: #eaf1ff;
    --panel: #ffffff;
    --border: #dbe7ff;
    --text: #0f172a;
    --muted: #516074;
    --brand1: #0f172a;
    --brand2: #1d4ed8;
    --shadow: 0 18px 40px rgba(15, 78, 216, .10);
    --surface-2: #f6f9ff;
    --table-head: #eff5ff;
    --sidebar-bg: #ffffff;
}

html[data-theme="dark"]{
    --bg: #0b1220;
    --panel: #111827;
    --border: #243041;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --brand1: #020617;
    --brand2: #1e293b;
    --shadow: 0 18px 40px rgba(0, 0, 0, .35);
    --surface-2: #0f172a;
    --table-head: #0f172a;
    --sidebar-bg: #0b1220;
}

*{
    box-sizing:border-box;
}

html,
body{
    height:100%;
}

body{
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a{
    text-decoration:none;
}

.app-shell{
    min-height:100vh;
}

.app-topbar{
    min-height: var(--topbar-h);
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    box-shadow: var(--shadow);
    z-index: 1030;
}

.app-sidebar-desktop{
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
    box-shadow: 8px 0 28px rgba(15, 23, 42, .03);
}

.app-sidebar{
    background: var(--sidebar-bg);
    color: var(--text);
}

.app-main{
    margin-left: var(--sidebar-w);
    min-height: calc(100vh - var(--topbar-h));
}

.sidebar-inner{
    min-height: 100%;
    display:flex;
    flex-direction:column;
}

.sidebar-brand{
    display:flex;
    align-items:center;
    gap:.85rem;
}

.sidebar-logo{
    width:48px;
    height:48px;
    border-radius:16px;
    display:grid;
    place-items:center;
    color:#fff;
    font-weight:800;
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    box-shadow: var(--shadow);
}

.app-nav-link{
    border-radius: 14px;
    color: var(--text);
    padding: .82rem 1rem;
    font-weight: 600;
    transition: .15s ease;
}

.app-nav-link:hover,
.app-nav-link.active{
    background: rgba(29, 78, 216, .10);
    color: #1745a8;
}

html[data-theme="dark"] .app-nav-link:hover,
html[data-theme="dark"] .app-nav-link.active{
    background: rgba(96, 165, 250, .12);
    color: #93c5fd;
}

.sidebar-footer{
    margin-top:auto;
    border-top:1px solid var(--border);
}

.panel{
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.panel-header{
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border);
}

.panel-body{
    padding: 1.1rem;
}

.stat-card{
    border: none;
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow:hidden;
    background: linear-gradient(135deg, var(--panel), var(--surface-2));
}

.stat-label{
    color: var(--muted);
    font-size: .9rem;
}

.stat-value{
    font-size: clamp(1.45rem, 4vw, 2.1rem);
    font-weight: 800;
    line-height:1.1;
}

.badge-soft{
    background: rgba(29, 78, 216, .10);
    color: #1649b8;
    border: 1px solid rgba(29, 78, 216, .12);
}

.filter-bar{
    display:grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap:.8rem;
}

.table{
    color: var(--text);
}

.table thead th{
    background: var(--table-head);
    color: var(--text);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.table > :not(caption) > * > *{
    vertical-align: middle;
    background-color: transparent;
}

.table-actions{
    display:flex;
    gap:.45rem;
    flex-wrap: wrap;
}

.btn{
    border-radius: 14px;
    font-weight: 600;
}

.form-control,
.form-select{
    border-radius: 14px;
    padding: .8rem 1rem;
    background-color: var(--panel);
    color: var(--text);
    border-color: var(--border);
}

.form-control:focus,
.form-select:focus{
    box-shadow: 0 0 0 .2rem rgba(29,78,216,.12);
    border-color: rgba(29,78,216,.35);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select{
    background-color: #0f172a;
    color: #e5e7eb;
}

html[data-theme="dark"] .form-control::placeholder{
    color: #94a3b8;
}

.login-main{
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    background:
      radial-gradient(circle at top left, rgba(29,78,216,.14), transparent 30%),
      radial-gradient(circle at bottom right, rgba(15,23,42,.10), transparent 28%),
      linear-gradient(180deg, #f8fbff, #edf3fb);
}

html[data-theme="dark"] .login-main{
    background:
      radial-gradient(circle at top left, rgba(59,130,246,.14), transparent 30%),
      radial-gradient(circle at bottom right, rgba(15,23,42,.45), transparent 28%),
      linear-gradient(180deg, #020617, #111827);
}

.login-card{
    max-width: 440px;
    width:100%;
    background: var(--panel);
    border:1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
    overflow:hidden;
}

.login-hero{
    padding:1.4rem 1.4rem 1rem;
    background: linear-gradient(135deg, var(--brand1), var(--brand2));
    color:#fff;
}

.login-body{
    padding: 1.4rem;
}

.text-muted-2{
    color: var(--muted);
}

.content-title{
    font-size: clamp(1.2rem, 2vw, 1.7rem);
    font-weight: 800;
    margin:0;
}

.mobile-hide{
    display: initial;
}

.theme-switcher{
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.theme-btn.active{
    background: #fff !important;
    color: #000 !important;
    border-color: #fff !important;
}

html[data-theme="dark"] .theme-btn.active{
    background: #e5e7eb !important;
    color: #000 !important;
    border-color: #e5e7eb !important;
}

.alert{
    background: var(--panel);
    color: var(--text);
    border-color: var(--border);
}

@media (max-width: 991.98px){
    .app-main{
        margin-left:0;
    }
    .filter-bar{
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px){
    .container-fluid.py-3.py-lg-4{
        padding-left: .75rem;
        padding-right: .75rem;
    }

    .panel-body{
        padding: .9rem;
    }

    .filter-bar{
        grid-template-columns: 1fr;
    }

    .mobile-hide{
        display:none !important;
    }

    .theme-switcher .btn{
        font-size: .75rem;
        padding: .25rem .55rem;
    }

    .table-mobile-stack thead{
        display:none;
    }

    .table-mobile-stack,
    .table-mobile-stack tbody,
    .table-mobile-stack tr,
    .table-mobile-stack td{
        display:block;
        width:100%;
    }

    .table-mobile-stack tr{
        background: var(--panel);
        border:1px solid var(--border);
        border-radius:18px;
        margin-bottom:.9rem;
        overflow:hidden;
        box-shadow: var(--shadow);
    }

    .table-mobile-stack td{
        display:flex;
        justify-content:space-between;
        gap:1rem;
        padding:.8rem .9rem;
        border:0 !important;
        border-bottom:1px solid var(--border) !important;
        text-align:right;
        align-items:center;
        background: transparent;
    }

    .table-mobile-stack td:last-child{
        border-bottom:0 !important;
    }

    .table-mobile-stack td::before{
        content: attr(data-label);
        font-weight:700;
        text-align:left;
        color: var(--muted);
        max-width:48%;
    }

    .table-actions{
        justify-content:flex-end;
    }
}