:root {
    --primary: #0d6efd;
    --primary-dark: #084298;
    --primary-soft: #e8f1ff;
    --surface: #ffffff;
    --body: #f5f8fc;
    --text: #162033;
    --muted: #6c7a91;
    --border: #dfe7f3;
    --sidebar-width: 280px;
    --topbar-height: 72px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Prompt", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--body);
}

a {
    text-decoration: none;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    width: var(--sidebar-width);
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: transform .2s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-height);
    padding: 0 22px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    overflow: hidden;
    color: #fff;
    background: var(--primary);
    border-radius: 8px;
    box-shadow: 0 12px 24px rgba(13, 110, 253, .22);
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-text {
    display: grid;
    min-width: 0;
    line-height: 1.15;
    font-weight: 700;
}

.brand-text span,
.brand-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-text small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
    padding: 16px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: #3c4659;
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
}

.nav-link i {
    width: 20px;
    color: #718198;
    text-align: center;
}

.nav-text {
    min-width: 0;
    flex: 1;
}

.nav-badge {
    margin-left: auto;
    font-size: 11px;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.nav-link:hover i,
.nav-link.active i {
    color: var(--primary);
}

.nav-parent {
    justify-content: space-between;
}

.nav-parent span {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-arrow {
    width: auto !important;
    font-size: 11px;
    transition: transform .2s ease;
}

.nav-parent:not(.collapsed) .nav-arrow {
    transform: rotate(180deg);
}

.submenu {
    display: grid;
    gap: 2px;
    margin: 2px 0 6px 18px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.submenu-link {
    min-height: 36px;
    padding-block: 8px;
}

.app-main {
    min-height: 100vh;
    padding-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: var(--topbar-height);
    padding: 12px 24px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.topbar-title {
    margin: 0;
    overflow: hidden;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.icon-btn:hover {
    color: var(--primary);
    border-color: #b9d3ff;
    background: var(--primary-soft);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 320px;
    padding: 6px 8px 6px 6px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--primary-soft);
}

.user-meta {
    display: grid;
    min-width: 0;
    text-align: left;
}

.user-name,
.user-position {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-name {
    font-weight: 600;
}

.user-position {
    color: var(--muted);
    font-size: 12px;
}

.dropdown-caret {
    color: var(--muted);
    font-size: 12px;
}

.app-content {
    min-height: calc(100vh - var(--topbar-height));
    padding: 24px;
}

.page-panel {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 220px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.page-panel-icon {
    display: grid;
    width: 64px;
    height: 64px;
    flex: 0 0 64px;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 8px;
    font-size: 24px;
}

.page-panel h2 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 700;
}

.page-panel p {
    margin: 0;
    color: var(--muted);
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(13, 110, 253, .12), rgba(255, 255, 255, 0) 36%),
        var(--body);
}

.login-card {
    width: min(100%, 440px);
    padding: 30px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(22, 32, 51, .08);
}

.login-logo {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    overflow: hidden;
    margin-bottom: 18px;
    color: #fff;
    background: var(--primary);
    border-radius: 8px;
    font-size: 22px;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.form-label {
    font-weight: 600;
}

.form-control,
.form-select {
    min-height: 42px;
    border-color: var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: #8bbcff;
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .14);
}

.badge {
    border-radius: 999px;
    font-weight: 600;
}

.content-card {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.page-actions h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.action-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
}

.table-avatar {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--primary-soft);
}

.avatar-preview {
    display: grid;
    width: 96px;
    height: 96px;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--primary-soft);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.csv-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.csv-fields code {
    display: block;
    padding: 8px 10px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-radius: 8px;
}

.csv-help {
    font-size: 10pt;
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.dashboard-hero h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
}

.dashboard-hero p {
    max-width: 720px;
    margin: 0;
    color: var(--muted);
}

.dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.metric-icon {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    place-items: center;
    border-radius: 8px;
    font-size: 18px;
}

.metric-label,
.metric-sub {
    color: var(--muted);
}

.metric-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}

.chart-box {
    height: 300px;
}

.chart-box-wide {
    height: 320px;
}

.table-responsive,
.dataTables_wrapper {
    width: 100%;
}

.sidebar-backdrop {
    display: none;
}

body.sidebar-collapsed .sidebar {
    transform: translateX(calc(var(--sidebar-width) * -1));
}

body.sidebar-collapsed .app-main {
    padding-left: 0;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(calc(var(--sidebar-width) * -1));
    }

    .app-main {
        padding-left: 0;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1025;
        display: block;
        background: rgba(15, 23, 42, .38);
    }

    .topbar {
        padding-inline: 16px;
    }

    .app-content {
        padding: 16px;
    }
}

@media (max-width: 575.98px) {
    .user-menu {
        max-width: 58px;
    }

    .user-meta,
    .dropdown-caret {
        display: none;
    }

    .page-panel {
        align-items: flex-start;
        flex-direction: column;
        padding: 22px;
    }

    .login-card {
        padding: 24px;
    }

    .filter-grid,
    .csv-fields {
        grid-template-columns: 1fr;
    }

    .page-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-actions {
        justify-content: flex-start;
    }
}
