:root {
    color-scheme: light;
    --white: #ffffff;
    --page: #f8f7f9;
    --page-start: #fbfafc;
    --page-middle: #f7f5f8;
    --page-end: #f3f1f4;
    --claret: #8a0f73;
    --claret-bright: #9b167f;
    --claret-action: #95127b;
    --claret-action-end: #7c1069;
    --claret-deep: #741060;
    --claret-soft: #f3e8f1;
    --claret-mist: #fbf7fa;
    --gold: #c7a32a;
    --gold-soft: #f6f1df;
    --gold-muted: #eee6c8;
    --gold-text: #67551a;
    --green: #3f7d58;
    --green-soft: #e8f4ed;
    --amber: #d97706;
    --amber-soft: #fff7e6;
    --danger: #ad343e;
    --danger-soft: #fff5f5;
    --ink: #211a25;
    --body-copy: #46404b;
    --muted: #67616c;
    --line: #e4dfe6;
    --surface: #ffffff;
    --surface-soft: rgba(255, 255, 255, 0.92);
    --surface-muted: #faf8fb;
    --surface-disabled: #f1edf2;
    --radius-control: 12px;
    --radius-card: 18px;
    --radius-feature: 24px;
    --shadow-card: 0 1px 1px rgba(36, 27, 42, 0.035), 0 18px 48px rgba(49, 35, 54, 0.075);
    --shadow-subtle: 0 10px 28px rgba(49, 35, 54, 0.055);
    --shadow-raised: 0 1px 1px rgba(36, 27, 42, 0.04), 0 30px 78px rgba(49, 35, 54, 0.12);
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background: linear-gradient(180deg, var(--page-start) 0%, var(--page-middle) 52%, var(--page-end) 100%) !important;
    background-attachment: fixed;
    color: var(--ink);
    line-height: 1.45;
}

body::before {
    position: fixed;
    z-index: 0;
    inset: 0;
    background-image:
        linear-gradient(rgba(138, 15, 115, 0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(138, 15, 115, 0.012) 1px, transparent 1px);
    background-size: 40px 40px;
    content: "";
    pointer-events: none;
}

body > * {
    position: relative;
    z-index: 1;
}

a {
    color: var(--claret);
}

a:hover {
    color: var(--claret-deep);
}

.main-header {
    min-height: 76px;
    background: rgba(255, 255, 255, 0.9) !important;
    border-bottom: 1px solid rgba(228, 223, 230, 0.86);
    box-shadow: 0 8px 24px rgba(49, 35, 54, 0.045);
    backdrop-filter: blur(18px);
}

.main-header .navbar-brand {
    color: var(--ink) !important;
    font-weight: 900;
}

.main-header .navbar-brand:hover {
    color: var(--claret) !important;
}

.main-header .navbar-brand img {
    filter: none !important;
    height: 52px;
    max-width: 52px;
    object-fit: contain;
}

.main-header .navbar-brand span {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    border-left: 1px solid var(--line);
    padding-left: 14px;
    color: var(--claret);
}

.user-menu .dropdown-toggle {
    color: var(--ink);
    font-weight: 800;
}

.user-menu .dropdown-toggle:hover {
    color: var(--claret);
}

.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.app-switcher {
    position: relative;
}

.app-switcher-toggle {
    min-height: 42px;
    display: inline-grid;
    grid-template-columns: 26px auto;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    border: 1px solid #ead5e7;
    border-radius: 999px;
    background: var(--surface);
    color: var(--claret);
    font-weight: 950;
    box-shadow: 0 8px 20px rgba(49, 35, 54, 0.045);
}

.app-switcher-toggle img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.app-switcher-toggle[aria-expanded="true"] {
    background: var(--claret-mist);
    border-color: rgba(138, 15, 115, 0.28);
}

.app-switcher-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1050;
    width: min(82vw, 310px);
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(228, 223, 230, 0.95);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-raised);
    backdrop-filter: blur(16px);
}

.app-switcher-panel[hidden] {
    display: none !important;
}

.app-switcher-link {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--body-copy);
    font-weight: 900;
    text-decoration: none;
}

.app-switcher-link:hover,
.app-switcher-link:focus {
    background: var(--claret-mist);
    color: var(--claret);
}

.app-switcher-link.active {
    background: var(--gold-soft);
    border-color: var(--gold-muted);
    color: var(--gold-text);
}

.app-switcher-link img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: contain;
}

.app-switcher-link strong,
.app-switcher-link small {
    display: block;
    line-height: 1.18;
}

.app-switcher-link small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
}

.dropdown-menu {
    border: 1px solid rgba(228, 223, 230, 0.92);
    border-radius: var(--radius-control);
    box-shadow: var(--shadow-card);
}

.dropdown-header {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.dropdown-item {
    border-radius: 10px;
    color: var(--body-copy);
    font-weight: 800;
    margin: 2px 6px;
    width: auto;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--claret-mist);
    color: var(--claret);
}

.dropdown-item.active,
.dropdown-item:active {
    background: var(--claret);
    color: var(--white);
}

.sidebar {
    top: 76px;
    background: rgba(255, 255, 255, 0.84);
    border-right: 1px solid rgba(228, 223, 230, 0.92);
    box-shadow: 12px 0 34px rgba(49, 35, 54, 0.035);
    backdrop-filter: blur(16px);
}

.sidebar-head {
    display: none;
}

.sidebar-nav .nav-link {
    min-height: 48px;
    margin: 0 0.75rem;
    padding: 0.75rem 0.9rem;
    border-left: 0;
    border-radius: var(--radius-control);
    color: var(--body-copy);
    font-weight: 800;
}

.sidebar-nav .nav-link:hover {
    background: var(--claret-mist);
    border-left-color: transparent;
    color: var(--claret);
}

.sidebar-nav .nav-link.active {
    background: var(--claret);
    border-left-color: transparent;
    color: var(--white);
    box-shadow: 0 10px 22px rgba(138, 15, 115, 0.2);
}

.sidebar-section {
    color: var(--muted);
    font-weight: 900;
    letter-spacing: 0;
}

.main-content {
    padding: 2rem;
}

.main-footer {
    background: rgba(255, 255, 255, 0.82);
    border-top: 1px solid rgba(228, 223, 230, 0.92);
    color: var(--muted);
    backdrop-filter: blur(16px);
}

.footer-link,
.footer-link:hover {
    color: var(--claret);
}

.card {
    background: var(--surface-soft);
    border: 1px solid rgba(228, 223, 230, 0.92);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
}

.btn,
button,
.form-control,
.form-select {
    border-radius: var(--radius-control);
}

.btn-primary {
    background: linear-gradient(135deg, var(--claret-action), var(--claret-action-end)) !important;
    border-color: transparent !important;
    box-shadow: 0 12px 26px rgba(138, 15, 115, 0.18);
    font-weight: 900;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: linear-gradient(135deg, var(--claret-bright), var(--claret-deep)) !important;
    border-color: transparent !important;
}

.btn-outline-primary {
    background: var(--surface);
    border-color: #ead5e7 !important;
    color: var(--claret) !important;
    font-weight: 850;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background: var(--claret-mist) !important;
    border-color: rgba(138, 15, 115, 0.28) !important;
    color: var(--claret) !important;
}

.form-control,
.form-select,
.input-group-text {
    border-color: var(--line);
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(138, 15, 115, 0.42);
    box-shadow: 0 0 0 4px rgba(138, 15, 115, 0.1);
}

.form-check-input:checked {
    background-color: var(--claret);
    border-color: var(--claret);
}

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

.table thead {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--line);
}

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

.badge.bg-primary {
    background: var(--claret) !important;
}

.alert {
    border: 1px solid transparent;
    border-radius: var(--radius-control);
}

.auth-page {
    min-height: 100vh;
    display: grid !important;
    place-items: center;
    padding: 24px;
    font-family: Inter, "Segoe UI Variable", Aptos, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}

.auth-page .login-container {
    max-width: 450px;
    padding: 0;
}

.auth-page .login-card,
.auth-page .invite-card,
.auth-page .reset-card,
.auth-page .auth-card {
    width: min(100%, 470px);
    background: var(--surface-soft) !important;
    border: 1px solid rgba(228, 223, 230, 0.92);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    padding: 30px;
}

.auth-page .login-card {
    text-align: center;
}

.auth-page .login-card::before,
.auth-page .invite-card::before,
.auth-page .reset-card::before,
.auth-page .auth-card::before {
    display: block;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--claret), var(--gold));
    content: "";
}

.auth-page .login-header {
    background: transparent !important;
    border-bottom: 0 !important;
    padding: 0;
}

.auth-page .logo-container {
    width: 112px;
    height: auto;
    margin: 0 auto 22px;
    padding: 10px;
    background: var(--white) !important;
    border: 1px solid rgba(228, 223, 230, 0.95);
    border-radius: 24px;
    box-shadow: var(--shadow-subtle) !important;
}

.auth-page .logo-container img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.auth-page .login-title,
.auth-page h1 {
    color: var(--ink);
    font-size: clamp(2rem, 4vw, 2.55rem);
    font-weight: 900;
    line-height: 1.12;
    letter-spacing: 0;
    margin: 0 0 8px;
}

.auth-page .login-subtitle,
.auth-page .text-muted {
    color: var(--muted) !important;
    font-weight: 850;
}

.auth-page .auth-logo {
    width: 76px;
    height: 76px;
    padding: 9px;
    background: var(--white);
    border: 1px solid rgba(228, 223, 230, 0.95);
    border-radius: 18px;
    box-shadow: var(--shadow-subtle);
    object-fit: contain;
}

.auth-page .login-body {
    padding: 0;
}

.auth-page .login-body form {
    display: grid;
    gap: 18px;
    margin-top: 26px;
    text-align: left;
}

.auth-page .input-group {
    display: block;
}

.auth-page .input-group-text {
    display: none;
}

.auth-page .input-group .form-control {
    width: 100%;
    border-left: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.auth-page .login-footer {
    display: none;
}

.auth-page .btn-login {
    min-height: 50px;
    background: linear-gradient(135deg, var(--claret-action), var(--claret-action-end)) !important;
    border-radius: var(--radius-control);
    box-shadow: 0 12px 26px rgba(138, 15, 115, 0.18);
}

.auth-page .btn-login:hover {
    background: linear-gradient(135deg, var(--claret-bright), var(--claret-deep)) !important;
}

.auth-page .btn-primary {
    background: linear-gradient(135deg, var(--claret-action), var(--claret-action-end)) !important;
    border: 0;
    border-radius: var(--radius-control);
    box-shadow: 0 12px 26px rgba(138, 15, 115, 0.18);
    font-weight: 850;
    min-height: 46px;
}

.auth-page .btn-primary:hover,
.auth-page .btn-primary:focus {
    background: linear-gradient(135deg, var(--claret-bright), var(--claret-deep)) !important;
}

.auth-page .demo-button {
    border-color: #ead5e7;
    background: var(--surface);
}

.auth-page .demo-button:hover,
.auth-page .demo-button:focus,
.auth-page .demo-button.active {
    background: var(--claret-mist);
    border-color: rgba(138, 15, 115, 0.28);
}

.auth-page .demo-icon {
    background: var(--claret-soft);
    color: var(--claret);
}

@media (max-width: 768px) {
    .main-header {
        min-height: 64px;
    }

    .main-header .d-flex.justify-content-between {
        gap: 8px;
    }

    .main-header .container-fluid {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .main-header .navbar-brand {
        flex: 0 0 auto;
        min-width: 0;
    }

    .main-header .navbar-brand img {
        height: 42px;
        max-width: 42px;
        margin-right: 0;
    }

    .header-actions {
        flex: 0 0 auto;
        gap: 7px;
    }

    .app-switcher-toggle {
        grid-template-columns: 24px;
        padding: 7px 9px;
    }

    .app-switcher-toggle span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .app-switcher-toggle img {
        width: 24px;
        height: 24px;
    }

    .app-switcher-panel {
        position: fixed;
        top: 72px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        border-radius: 16px;
    }

    .mobile-menu-toggle {
        min-height: 42px;
        display: inline-grid !important;
        grid-template-columns: 18px auto;
        gap: 8px;
        align-items: center;
        padding: 8px 12px;
        border: 1px solid #ead5e7;
        border-radius: 999px;
        background: var(--surface);
        color: var(--claret);
        font-size: 1rem;
        font-weight: 950;
    }

    .mobile-menu-toggle i {
        font-size: 1.1rem;
        line-height: 1;
    }

    .mobile-menu-toggle span {
        display: inline;
    }

    .main-header .navbar-brand span {
        display: none;
    }

    .main-content {
        padding: 18px 14px 45px;
    }

    .user-menu .dropdown-toggle {
        gap: 0.25rem;
    }

    .user-menu .dropdown-toggle span {
        display: none;
    }

    .sidebar {
        top: 0;
        right: auto;
        bottom: 0;
        left: 0;
        z-index: 1045;
        width: min(88vw, 360px);
        padding: 0 16px 18px;
        border-right: 1px solid rgba(138, 15, 115, 0.22);
        background: #fff;
        box-shadow: 28px 0 72px rgba(33, 26, 37, 0.34);
        transform: translateX(-105%);
        overflow-y: auto;
    }

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

    .sidebar-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0 -16px 8px;
        padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
        background: linear-gradient(135deg, var(--claret-action), var(--claret-action-end));
        color: #fff;
    }

    .sidebar-head strong {
        color: #fff;
        font-size: 1.42rem;
    }

    .sidebar-close {
        width: 44px;
        min-height: 44px;
        display: inline-grid;
        place-items: center;
        border: 1px solid rgba(255, 255, 255, 0.32);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.14);
        color: #fff;
        padding: 0;
    }

    .sidebar-nav .nav-link {
        width: 100%;
        min-height: 48px;
        justify-content: flex-start;
        margin: 0 0 10px;
        padding: 11px 14px;
        border: 1px solid rgba(138, 15, 115, 0.18);
        border-left-width: 1px;
        border-radius: 14px;
        background: #fff;
        color: var(--claret);
        font-size: 1.04rem;
        line-height: 1.1;
        box-shadow: 0 8px 20px rgba(49, 35, 54, 0.05);
        white-space: normal;
    }

    .sidebar-section {
        padding: 10px 2px 7px;
        color: var(--muted);
        font-size: 0.76rem;
        font-weight: 950;
        letter-spacing: 0;
    }

    .sidebar-scrim {
        position: fixed;
        z-index: 1040;
        inset: 0;
        display: block;
        border: 0;
        background: rgba(33, 26, 37, 0.52);
        backdrop-filter: blur(2px);
    }

    .sidebar-scrim[hidden] {
        display: none !important;
    }

    .menu-open {
        overflow: hidden;
    }
}

@media (max-width: 576px) {
    .auth-page {
        align-content: start;
        padding: 12px;
        place-items: start center;
    }

    .auth-page .login-card {
        padding: 20px 18px 18px;
    }

    .auth-page .invite-card,
    .auth-page .reset-card,
    .auth-page .auth-card {
        padding: 22px 18px;
    }

    .auth-page .logo-container {
        width: 92px;
        border-radius: 20px;
        margin-bottom: 14px;
    }

    .auth-page .login-title,
    .auth-page h1 {
        font-size: 1.55rem;
        line-height: 1.08;
        margin-bottom: 4px;
    }

    .auth-page .login-body form {
        gap: 10px;
        margin-top: 14px;
    }

    .auth-page .login-body .mb-3 {
        margin-bottom: 0.55rem !important;
    }

    .auth-page .login-body .mb-4 {
        margin-bottom: 0.85rem !important;
    }

    .auth-page .form-label {
        margin-bottom: 0.35rem;
    }

    .auth-page .form-control {
        min-height: 44px;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

    .auth-page .btn-login {
        min-height: 46px;
    }
}
