:root {
    --bg-app: #16181c;
    --bg-sidebar: #111317;
    --bg-panel: #1d2127;
    --bg-hover: #262c35;
    --text-main: #e7e7e7;
    --text-muted: #97a0ad;
    --line: #2d3440;
    --fire: #ff7a18;
    --fire-red: #d9472f;
    --fire-blue: #2d86d9;
}

body {
    background: radial-gradient(circle at 15% 15%, rgba(255, 122, 24, 0.08), transparent 40%), radial-gradient(circle at 85% 10%, rgba(45, 134, 217, 0.1), transparent 40%), var(--bg-app);
    color: var(--text-main);
}

.text-muted {
    color: #c3ccd8 !important;
}

.portal-login {
    min-height: 100vh;
}

.portal-login .card,
.portal-login .card .form-label,
.portal-login .card .text-muted {
    color: #ffffff !important;
}

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

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

.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #101216 0%, #0e1115 100%);
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(6, 9, 14, 0.58);
    backdrop-filter: blur(1px);
    z-index: 1045;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.brand-logo {
    width: 82%;
    margin: 0 auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.login-logo {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

.brand-subtitle {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.sidebar-nav .nav-link {
    color: #d5dae2;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    min-height: 2.35rem;
    padding: 0.5rem 0.65rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nav-group {
    margin-bottom: 0;
}

.nav-group-header {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
}

.nav-link-main {
    flex: 1;
    margin-bottom: 0;
    min-height: 2.35rem;
    padding: 0.5rem 0.65rem;
}

.nav-link-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-link-main > span,
.nav-link-toggle > span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-group-caret {
    color: #d5dae2;
    border-radius: 0.5rem;
    width: 2.35rem;
    min-width: 2.35rem;
    min-height: 2.35rem;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

.nav-group-caret:hover {
    color: #fff;
    background-color: var(--bg-hover);
}

.nav-group-caret .bi,
.nav-link-toggle .bi-chevron-down {
    transition: transform 0.18s ease;
    width: 1rem;
    text-align: center;
}

.nav-group-caret.collapsed .bi,
.nav-link-toggle.collapsed .bi-chevron-down {
    transform: rotate(-90deg);
}

.nav-submenu {
    margin-left: 1.1rem;
    margin-top: 0.15rem;
    border-left: 1px solid #2b3340;
    padding-left: 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nav-sub-link {
    font-size: 0.93rem;
    color: #c6ceda;
    min-height: 2.1rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background-color: var(--bg-hover);
    color: #fff;
}

.topbar {
    border-bottom: 1px solid var(--line);
    background-color: rgba(18, 21, 26, 0.75);
    backdrop-filter: blur(4px);
}

.topbar h1 {
    color: #ffffff;
}

.panel-dark {
    background-color: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 0.85rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    top: -50px;
    right: -20px;
    background: linear-gradient(120deg, rgba(255, 122, 24, 0.25), rgba(217, 71, 47, 0.15));
}

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

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
}

.btn-fire {
    background: linear-gradient(135deg, var(--fire), var(--fire-red));
    color: #fff;
    border: none;
}

.btn-fire:hover {
    color: #fff;
    filter: brightness(1.06);
}

.form-control,
.form-select,
.input-group-text {
    background-color: #171b21;
    color: #ffffff;
    border-color: #394250;
}

.form-control::placeholder {
    color: #ced6e2;
    opacity: 1;
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 122, 24, 0.18);
    border-color: var(--fire);
    background-color: #1a1f27;
    color: #fff;
}

.form-control:disabled,
.form-select:disabled,
.form-check-input:disabled {
    background-color: #2a2f38 !important;
    border-color: #3d4654 !important;
    color: #9ea8b6 !important;
    opacity: 1;
    cursor: not-allowed;
}

.ts-wrapper.disabled .ts-control {
    background-color: #2a2f38 !important;
    border-color: #3d4654 !important;
    color: #9ea8b6 !important;
    opacity: 1;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: rgba(255, 122, 24, 0.08);
    --bs-table-border-color: #303846;
}

.modal-content {
    border-radius: 0.85rem;
}

body.inline-create-open #entityModal .modal-content {
    filter: brightness(0.62) saturate(0.9);
    transition: filter 0.15s ease;
}

body.nested-inline-create-open #inlineCreateModal .modal-content {
    filter: brightness(0.62) saturate(0.9);
    transition: filter 0.15s ease;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
    background-color: #171b21;
    border-color: #394250;
    color: #fff;
}

.ts-wrapper.single .ts-control input,
.ts-wrapper.multi .ts-control input {
    color: #fff;
}

.ts-dropdown {
    background-color: #1a1f27;
    border-color: #394250;
    color: #e7e7e7;
}

.ts-dropdown .option.active {
    background-color: rgba(255, 122, 24, 0.18);
    color: #fff;
}

.form-section-title {
    margin-top: 0.3rem;
    margin-bottom: 0.35rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--line);
    color: #ffd0a7;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.portal-loading {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 10, 14, 0.76);
    backdrop-filter: blur(1px);
}

.portal-loading-box {
    min-width: 340px;
    max-width: 82vw;
    border: 1px solid #3a4658;
    border-radius: 0.75rem;
    background: linear-gradient(180deg, #141a22 0%, #10161d 100%);
    box-shadow: 0 0 0 1px rgba(255, 122, 24, 0.15), 0 16px 40px rgba(0, 0, 0, 0.45);
    padding: 1rem 1rem 0.9rem;
}

.portal-loading-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 122, 24, 0.2);
    border-top-color: #ff7a18;
    animation: portal-spin 0.8s linear infinite;
    margin-bottom: 0.6rem;
}

.portal-loading-title {
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    color: #8db4d8;
    margin-bottom: 0.35rem;
}

.portal-loading-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.84rem;
    color: #f5f7fb;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #2f3a4a;
    border-radius: 0.45rem;
    padding: 0.45rem 0.55rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes portal-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 992px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

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

    .content {
        width: 100%;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 1030;
    }
}
