:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --text: #172033;
    --muted: #728096;
    --line: #e6ebf2;
    --primary: #6558f5;
    --primary-soft: #eeecff;
    --success: #20b486;
    --warning: #f5a524;
    --danger: #ef5b5b;
    --sidebar: #15213a;
    --sidebar-text: #d9e2f2;
    --shadow: 0 14px 40px rgba(35, 48, 74, .08);
}

[data-theme="dark"] {
    --bg: #0d1628;
    --panel: #142039;
    --panel-2: #192743;
    --text: #f2f6ff;
    --muted: #9aa9c2;
    --line: #263753;
    --primary-soft: rgba(101, 88, 245, .18);
    --sidebar: #0a1222;
    --shadow: 0 14px 40px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: flex; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: 270px;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    color: var(--sidebar-text);
    background:
        radial-gradient(circle at 10% 10%, rgba(101, 88, 245, .28), transparent 34%),
        linear-gradient(180deg, var(--sidebar), #0f1930);
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 26px; }
.brand-mark {
    width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center;
    background: linear-gradient(135deg, #7d6cff, #38c9b8); color: #fff; font-size: 1.35rem;
    box-shadow: 0 10px 30px rgba(101, 88, 245, .35);
}
.brand strong { display: block; color: #fff; font-size: 1.25rem; letter-spacing: .2px; }
.brand small { display: block; color: #93a4c1; font-size: .78rem; }
.sidebar-nav { overflow-y: auto; padding-right: 4px; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 12px; min-height: 46px; margin-bottom: 5px; padding: 10px 13px;
    color: #aebbd2; border-radius: 14px; transition: .2s ease;
}
.sidebar-nav .nav-link i { width: 22px; font-size: 1.05rem; }
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active {
    color: #fff; background: rgba(255,255,255,.10); transform: translateX(2px);
}
.nav-heading { margin: 20px 12px 8px; color: #647693; font-size: .69rem; font-weight: 800; letter-spacing: .13em; }
.sidebar-footer { margin-top: auto; padding-top: 18px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.08); }
.avatar { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 13px; background: #6558f5; color: #fff; font-weight: 800; }
.user-chip-text { min-width: 0; }
.user-chip-text strong, .user-chip-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-text strong { color: #fff; font-size: .9rem; }
.user-chip-text small { color: #8fa1bd; font-size: .74rem; }

.app-main { width: calc(100% - 270px); margin-left: 270px; min-height: 100vh; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020; min-height: 86px; display: flex; align-items: center; gap: 14px;
    padding: 16px 28px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(16px);
}
.page-kicker { color: var(--primary); font-size: .67rem; font-weight: 900; letter-spacing: .15em; }
.page-title { margin: 2px 0 0; color: var(--text); font-size: 1.42rem; font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon { width: 42px; height: 42px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); }
.btn-icon:hover { background: var(--panel-2); color: var(--primary); }
.app-content { padding: 26px 28px 42px; }
.app-content-inner { width: 100%; max-width: 1540px; margin: 0 auto; }

.card-panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px; margin-bottom: 18px; }
.toolbar .form-control, .toolbar .form-select { min-height: 42px; border-radius: 13px; }
.toolbar-search { flex: 1 1 260px; max-width: 420px; }
.stat-card { position: relative; overflow: hidden; height: 100%; padding: 20px; }
.stat-card::after { content: ""; position: absolute; width: 100px; height: 100px; right: -32px; bottom: -38px; border-radius: 50%; background: var(--primary-soft); }
.stat-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; background: var(--primary-soft); color: var(--primary); font-size: 1.2rem; }
.stat-label { margin-top: 16px; color: var(--muted); font-size: .83rem; font-weight: 700; }
.stat-value { margin-top: 3px; font-size: 1.65rem; font-weight: 850; }
.stat-note { margin-top: 4px; color: var(--muted); font-size: .76rem; }
.section-card { padding: 18px; }
.section-title { margin: 0; font-size: 1rem; font-weight: 800; }
.section-subtitle { margin-top: 3px; color: var(--muted); font-size: .79rem; }

.table-responsive { border-radius: 18px; }
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); margin-bottom: 0; }
.table thead th { padding: 13px 14px; color: var(--muted); background: var(--panel-2); border-bottom-color: var(--line); font-size: .72rem; text-transform: uppercase; letter-spacing: .045em; white-space: nowrap; }
.table tbody td { padding: 13px 14px; border-bottom-color: var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 30%, transparent); }
.table-empty { padding: 42px !important; text-align: center; color: var(--muted); }

.badge-soft { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.badge-soft-primary { color: #5d4fe0; background: #eeecff; }
.badge-soft-success { color: #148263; background: #ddf7ee; }
.badge-soft-warning { color: #9c6713; background: #fff2d8; }
.badge-soft-danger { color: #b23d3d; background: #ffe3e3; }
.badge-soft-muted { color: #637188; background: #edf1f6; }
[data-theme="dark"] .badge-soft-primary { color: #b9b0ff; background: rgba(101,88,245,.18); }
[data-theme="dark"] .badge-soft-success { color: #65e0b9; background: rgba(32,180,134,.16); }
[data-theme="dark"] .badge-soft-warning { color: #ffd17e; background: rgba(245,165,36,.15); }
[data-theme="dark"] .badge-soft-danger { color: #ff9c9c; background: rgba(239,91,91,.16); }
[data-theme="dark"] .badge-soft-muted { color: #adbad0; background: rgba(255,255,255,.08); }

.form-control, .form-select, .form-check-input {
    color: var(--text); background-color: var(--panel); border-color: var(--line);
}
.form-control:focus, .form-select:focus { color: var(--text); background-color: var(--panel); border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(101,88,245,.13); }
.form-control::placeholder { color: var(--muted); opacity: .8; }
.form-label { color: var(--muted); font-size: .78rem; font-weight: 750; }
.offcanvas, .modal-content { color: var(--text); background: var(--panel); border-color: var(--line); }
.offcanvas-header, .modal-header, .modal-footer { border-color: var(--line); }
.offcanvas.offcanvas-end { width: min(560px, 100%); }
.btn-close { filter: none; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

.pagination-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.pagination { margin: 0; }
.page-link { color: var(--text); background: var(--panel); border-color: var(--line); }
.page-link:hover, .page-link:focus { color: var(--primary); background: var(--panel-2); border-color: var(--line); box-shadow: none; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

.empty-state { padding: 46px 24px; text-align: center; color: var(--muted); }
.empty-state i { display: block; margin-bottom: 12px; color: var(--primary); font-size: 2.4rem; }
.empty-state h2 { color: var(--text); font-size: 1.2rem; }
.loading-skeleton { min-height: 110px; display: grid; place-items: center; color: var(--muted); }

.login-body {
    min-height: 100vh;
    background:
      radial-gradient(circle at 10% 15%, rgba(101,88,245,.23), transparent 30%),
      radial-gradient(circle at 90% 85%, rgba(56,201,184,.22), transparent 30%),
      #f6f8fc;
}
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 460px); padding: 34px; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 24px; }
.login-logo .brand-mark { width: 54px; height: 54px; }
.login-logo h1 { margin: 0; font-size: 1.55rem; font-weight: 850; }
.login-logo p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }
.login-help { margin-top: 18px; color: var(--muted); text-align: center; font-size: .78rem; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 1035; background: rgba(5,12,24,.58); }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .app-main { width: 100%; margin-left: 0; }
    .app-topbar { padding: 14px 16px; }
    .app-content { padding: 18px 14px 32px; }
}

@media (max-width: 575.98px) {
    .page-kicker { display: none; }
    .page-title { font-size: 1.12rem; }
    .topbar-actions .btn-outline-danger { width: 42px; padding: 0 !important; font-size: 0; }
    .topbar-actions .btn-outline-danger i { margin: 0 !important; font-size: 1rem; }
    .toolbar > * { width: 100%; max-width: none; }
    .pagination-wrap { align-items: flex-start; flex-direction: column; }
}
