:root {
    --teal: #3a99ac;
    --teal-dark: #2c7a89;
    --aqua: #83beb7;
    --mint: #e9f5f3;
    --gray-100: #f5f6fb;
    --gray-200: #e4e7f2;
    --gray-800: #1c2433;
    --gray-600: #4b5566;
    --ink-900: #151b2d;
    --ink-700: #46536a;
    --paper: #f7f8fc;
    --mist: #e1e6f4;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    background: var(--gray-100);
    color: var(--gray-800);
}

body[data-theme="dark"] {
    --gray-100: #0f1420;
    --gray-200: #1b2435;
    --gray-800: #eef2ff;
    --gray-600: #b9c3db;
    --ink-900: #f5f7ff;
    --ink-700: #c8d0e6;
    --paper: #151c2b;
    --mist: #212a3f;
    color: var(--gray-800);
}

.page-loader {
    position: fixed;
    inset: 0;
    background: rgba(247, 251, 251, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 9999;
}

body[data-theme="dark"] .page-loader {
    background: rgba(15, 20, 32, 0.75);
}

.page-loader-visible {
    opacity: 1;
    pointer-events: all;
}

.page-loader-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(22, 35, 43, 0.08);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 12px 28px rgba(18, 32, 40, 0.12);
}

body[data-theme="dark"] .page-loader-card {
    background: rgba(21, 28, 43, 0.92);
    border-color: rgba(200, 208, 230, 0.12);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.page-loader-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--teal-dark);
    animation: loaderPulse 0.9s ease-in-out infinite;
}

.page-loader-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.page-loader-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes loaderPulse {
    0%,
    100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    50% {
        transform: scale(1);
        opacity: 1;
    }
}

.auth-body {
    min-height: 100vh;
    background: linear-gradient(120deg, var(--teal) 0%, var(--aqua) 100%);
    padding: 2rem;
}

.auth-body .card.card-outline.card-primary {
    border-top: 3px solid var(--teal);
}

.auth-body .btn-primary {
    border: 1px solid var(--teal-dark);
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    color: #fff;
    font-weight: 600;
}

.auth-body .btn-primary:hover,
.auth-body .btn-primary:focus {
    border-color: #276c7a;
    background: linear-gradient(135deg, #338798, #276c7a);
    color: #fff;
}

.auth-body .btn-outline-secondary,
.auth-body .btn-outline-primary {
    border-color: var(--teal);
    color: var(--teal-dark);
    background: color-mix(in srgb, var(--aqua) 12%, #ffffff);
    font-weight: 600;
}

.auth-body .btn-outline-secondary:hover,
.auth-body .btn-outline-secondary:focus,
.auth-body .btn-outline-primary:hover,
.auth-body .btn-outline-primary:focus {
    border-color: var(--teal-dark);
    color: #fff;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
}

.auth-body .form-control:focus,
.auth-body .custom-select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 0.2rem rgba(58, 153, 172, 0.24);
}

.auth-body .custom-control-input:checked ~ .custom-control-label::before {
    border-color: var(--teal-dark);
    background-color: var(--teal);
}

.auth-body a:not(.btn):focus-visible {
    outline: 2px solid rgba(58, 153, 172, 0.35);
    outline-offset: 2px;
    border-radius: 3px;
}

body[data-theme="dark"].auth-body {
    background: linear-gradient(120deg, #12182a 0%, #1b2440 100%);
}

body[data-theme="dark"].auth-body .card.card-outline.card-primary {
    border-top-color: #54aebf;
}

body[data-theme="dark"].auth-body .btn-primary {
    border-color: #2f8595;
    background: linear-gradient(135deg, #54aebf, #2f8595);
}

body[data-theme="dark"].auth-body .btn-primary:hover,
body[data-theme="dark"].auth-body .btn-primary:focus {
    border-color: #2a7684;
    background: linear-gradient(135deg, #459dad, #2a7684);
}

body[data-theme="dark"].auth-body .btn-outline-secondary,
body[data-theme="dark"].auth-body .btn-outline-primary {
    border-color: #4b6f78;
    color: #d7eef2;
    background: color-mix(in srgb, var(--teal) 18%, #151c2b);
}

body[data-theme="dark"].auth-body .btn-outline-secondary:hover,
body[data-theme="dark"].auth-body .btn-outline-secondary:focus,
body[data-theme="dark"].auth-body .btn-outline-primary:hover,
body[data-theme="dark"].auth-body .btn-outline-primary:focus {
    border-color: #6ea8b2;
    color: #f5fdff;
    background: linear-gradient(135deg, #459dad, #2a7684);
}

body[data-theme="dark"].auth-body .link {
    color: #9fd9d1;
}

body[data-theme="dark"].auth-body .link:hover {
    color: #c6ece6;
}

.auth-form h1 {
    margin-bottom: 0.2rem;
}

.auth-description {
    margin-top: 0;
    color: var(--gray-600);
}

.auth-brand {
    line-height: 0;
}

.auth-logo {
    height: 34px;
    width: auto;
    max-width: 260px;
    display: block;
}

.auth-logo-dark {
    display: none;
}

body[data-theme="dark"] .auth-logo-dark {
    display: block;
}

body[data-theme="dark"] .auth-logo-light {
    display: none;
}

.auth-messages {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.auth-message {
    background: var(--mint);
    color: var(--gray-800);
    padding: 0.5rem 0.8rem;
    border-radius: 5px;
    margin-bottom: 0.6rem;
}

.app-toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 3000;
}

.app-toast {
    min-width: 280px;
    color: #fff;
    border: 0;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.app-toast.show,
.app-toast.showing {
    opacity: 1;
    transform: translateY(0);
}

.app-toast-success {
    background: linear-gradient(135deg, #24986a, #1f7f59);
}

.app-toast-error {
    background: linear-gradient(135deg, #d64557, #b93546);
}

.app-toast-warning {
    background: linear-gradient(135deg, #e2a304, #c78900);
    color: #1b1b1b;
}

.app-toast-info {
    background: linear-gradient(135deg, #3a99ac, #2c7a89);
}

.app-toast-icon {
    margin-right: 0.55rem;
    opacity: 0.95;
}

.app-toast .close {
    text-shadow: none;
    opacity: 0.85;
}

.app-toast .close:hover {
    opacity: 1;
}

.app-toast-close {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.link {
    color: var(--teal-dark);
    font-weight: 500;
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.auth-alt {
    margin-top: 1rem;
    color: var(--gray-600);
    font-size: 0.95rem;
}

.topbar-action {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(22, 35, 43, 0.18);
    background: rgba(255, 255, 255, 0.95);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-900);
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.topbar-action:hover,
.topbar-action:focus {
    background: white;
    border-color: rgba(22, 35, 43, 0.32);
    transform: translateY(-1px);
}

.admin-link i {
    font-size: 18px;
    line-height: 1;
}

.theme-toggle {
    cursor: pointer;
    padding: 0;
}

.theme-toggle i {
    font-size: 20px;
    line-height: 1;
}

.theme-icon-moon {
    display: block;
}

.theme-icon-sun {
    display: none;
}

body[data-theme="dark"] .topbar-action {
    background: rgba(21, 28, 43, 0.9);
    border-color: rgba(200, 208, 230, 0.28);
    color: var(--gray-800);
}

body[data-theme="dark"] .theme-icon-moon {
    display: none;
}

body[data-theme="dark"] .theme-icon-sun {
    display: block;
}

.topbar-profile {
    border: 1px solid rgba(22, 35, 43, 0.15);
    border-radius: 999px;
    height: 42px;
    min-width: 42px;
    padding: 4px 10px 4px 4px !important;
    background: rgba(255, 255, 255, 0.95);
    gap: 8px;
    text-decoration: none;
}

.topbar-profile:hover,
.topbar-profile:focus {
    background: white;
    border-color: rgba(22, 35, 43, 0.3);
}

body[data-theme="dark"] .topbar-profile {
    background: rgba(21, 28, 43, 0.9);
    border-color: rgba(200, 208, 230, 0.28);
}

.user-menu {
    position: relative;
}

.avatar-button img,
.avatar-button span {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--mint);
    color: var(--teal-dark);
    font-weight: 600;
    font-size: 0.9rem;
}

body[data-theme="dark"] .avatar-button img,
body[data-theme="dark"] .avatar-button span {
    background: #23304a;
    color: #dbe4ff;
}

.avatar-button-dropdown {
    overflow: visible;
}

.user-menu-caret {
    font-size: 11px;
    opacity: 0.8;
}

.user-menu-dropdown {
    right: 0;
    left: auto;
    min-width: 240px;
    border-radius: 10px;
    border: 1px solid rgba(22, 35, 43, 0.12);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
    padding: 0.6rem;
    z-index: 1050;
    backdrop-filter: blur(6px);
}

.user-menu-dropdown.show {
    display: block;
}

.user-menu-dropdown .dropdown-item {
    color: var(--gray-800);
    font-weight: 500;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-menu-dropdown .dropdown-item:hover,
.user-menu-dropdown .dropdown-item:focus {
    background: rgba(58, 153, 172, 0.12);
    color: var(--ink-900);
}

.user-menu-header {
    border: 1px solid rgba(22, 35, 43, 0.08);
    border-radius: 6px;
    padding: 0.65rem 0.55rem;
    margin-bottom: 0.3rem;
    background: rgba(247, 248, 252, 0.8);
}

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

.user-email {
    margin: 0.2rem 0 0;
    line-height: 1.25;
    font-weight: 500;
    color: var(--gray-600);
}

.user-menu-dropdown .user-menu-logout {
    background: rgba(244, 113, 127, 0.12);
    color: #d64557;
    font-weight: 600;
}

.user-menu-dropdown .user-menu-logout:hover,
.user-menu-dropdown .user-menu-logout:focus {
    background: rgba(244, 113, 127, 0.2);
    color: #c83749;
}

body[data-theme="dark"] .user-menu-dropdown {
    background: #1b2435;
    border: 1px solid rgba(200, 208, 230, 0.16);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

body[data-theme="dark"] .user-menu-header {
    border-color: rgba(200, 208, 230, 0.12);
    background: rgba(20, 27, 42, 0.6);
}

body[data-theme="dark"] .user-menu-dropdown .dropdown-item {
    color: var(--gray-800);
}

body[data-theme="dark"] .user-menu-dropdown .dropdown-item:hover,
body[data-theme="dark"] .user-menu-dropdown .dropdown-item:focus {
    background: rgba(58, 153, 172, 0.18);
    color: var(--gray-800);
}

body[data-theme="dark"] .user-menu-dropdown .user-menu-logout {
    background: rgba(244, 113, 127, 0.18);
    color: #ffd1d6;
}

body[data-theme="dark"] .user-menu-dropdown .user-menu-logout:hover,
body[data-theme="dark"] .user-menu-dropdown .user-menu-logout:focus {
    background: rgba(244, 113, 127, 0.28);
    color: #fff;
}

.profile-page {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    color: var(--ink-900);
}

.profile-tab {
    border: none;
    background: transparent;
    color: var(--ink-700);
}

.profile-tab.active {
    color: #fff;
    background: linear-gradient(120deg, var(--teal-dark), var(--teal));
}

.profile-tab-panels {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.profile-tab-panel {
    display: none;
}

.profile-tab-panel.active {
    display: block;
}

.profile-avatar-large {
    width: 72px;
    height: 72px;
    border-radius: 11px;
    background: linear-gradient(160deg, var(--mint), var(--aqua));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--teal-dark);
    overflow: hidden;
}

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

.profile-avatar-highlight {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.profile-muted {
    margin: 0;
    color: var(--ink-700);
    font-size: 0.85rem;
}

.profile-security-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--ink-700);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.profile-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.profile-avatar-field {
    display: none;
}

.profile-cropper-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 2000;
}

.profile-cropper-modal[hidden] {
    display: none;
}

.profile-cropper-dialog {
    background: white;
    border-radius: 12px;
    width: min(720px, 100%);
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 0.9rem;
}

.profile-cropper-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.profile-cropper-header h4 {
    margin: 0 0 0.3rem;
}

.profile-cropper-header p {
    margin: 0;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.profile-cropper-close {
    border: none;
    background: var(--gray-200);
    color: var(--gray-600);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    cursor: pointer;
}

.profile-cropper-body {
    border-radius: 9px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    background: var(--gray-100);
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-cropper-body img {
    max-width: 100%;
    display: block;
}

.profile-cropper-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
}

body[data-theme="dark"] .main-header {
    background-color: #101726;
    border-bottom: 1px solid rgba(200, 208, 230, 0.12);
}

body[data-theme="dark"] .main-sidebar {
    background-color: #0c1321;
}

body[data-theme="dark"] .brand-link {
    border-bottom: 1px solid rgba(200, 208, 230, 0.12);
    color: var(--gray-800);
}

body[data-theme="dark"] .content-wrapper {
    background-color: #0f1420;
}

body[data-theme="dark"] .card {
    background-color: #141b2a;
    border: 1px solid rgba(200, 208, 230, 0.12);
    color: var(--gray-800);
}

body[data-theme="dark"] .card-header,
body[data-theme="dark"] .card-footer {
    border-color: rgba(200, 208, 230, 0.12);
}

body[data-theme="dark"] .nav-sidebar .nav-link {
    color: #c8d0e6;
}

body[data-theme="dark"] .nav-sidebar .nav-link.active {
    background: linear-gradient(120deg, #3a99ac, #2c7a89);
    color: #fff;
}

body[data-theme="dark"] .nav-sidebar .nav-link:hover {
    background: rgba(58, 153, 172, 0.16);
    color: #eef2ff;
}

body[data-theme="dark"] .breadcrumb-item,
body[data-theme="dark"] .breadcrumb-item a,
body[data-theme="dark"] .content-header h1,
body[data-theme="dark"] .text-muted,
body[data-theme="dark"] label {
    color: var(--gray-800) !important;
}

body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-control-file,
body[data-theme="dark"] .custom-select {
    background-color: #1b2435;
    border-color: rgba(200, 208, 230, 0.22);
    color: var(--gray-800);
}

body[data-theme="dark"] .form-control:focus,
body[data-theme="dark"] .custom-select:focus {
    border-color: #3a99ac;
    box-shadow: 0 0 0 0.2rem rgba(58, 153, 172, 0.25);
}

body[data-theme="dark"] .btn-default {
    background-color: #1b2435;
    border-color: rgba(200, 208, 230, 0.22);
    color: var(--gray-800);
}

body[data-theme="dark"] .btn-default:hover {
    background-color: #23304a;
    color: #fff;
}

body[data-theme="dark"] .small-box {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

body[data-theme="dark"] .small-box .icon {
    opacity: 0.2;
}

body[data-theme="dark"] .login-page .card {
    background-color: #141b2a;
}

body[data-theme="dark"] .content-header h1,
body[data-theme="dark"] .card-title {
    font-weight: 600;
    letter-spacing: 0.01em;
}

body[data-theme="dark"] .card-body {
    line-height: 1.55;
}

body[data-theme="dark"] .nav-sidebar .nav-link p {
    letter-spacing: 0.01em;
}

body[data-theme="dark"] .login-page .card-body {
    padding: 1.35rem 1.3rem;
}

@media (max-width: 768px) {
    .content-header {
        padding: 0.65rem 0.5rem;
    }

    .content-header .breadcrumb {
        float: none !important;
        margin-top: 0.35rem;
        margin-bottom: 0;
        font-size: 0.86rem;
    }

    .topbar-action,
    .topbar-profile {
        width: 38px;
        height: 38px;
        min-width: 38px;
    }

    .topbar-profile {
        padding: 3px 8px 3px 3px !important;
    }

    .avatar-button img,
    .avatar-button span {
        width: 30px;
        height: 30px;
    }

    .user-menu-dropdown {
        min-width: 220px;
        right: 0;
    }

    body[data-theme="dark"] .content-wrapper {
        background-color: #0d1320;
    }

    body[data-theme="dark"] .card {
        border-color: rgba(200, 208, 230, 0.16);
    }

    body[data-theme="dark"] .card-body {
        padding: 1rem;
    }

    body[data-theme="dark"] .small-box {
        margin-bottom: 0.85rem;
    }
}

@media (max-width: 600px) {
    .auth-body {
        padding: 1rem;
    }

    .profile-avatar-highlight {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-toast-container {
        right: 0.75rem;
        left: 0.75rem;
        bottom: 0.75rem;
    }

    .app-toast {
        min-width: 0;
        width: 100%;
    }

    .app-toast-close {
        width: 36px;
        height: 36px;
        font-size: 1.35rem;
    }

    .topbar-action,
    .topbar-profile {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .user-menu-caret {
        margin-left: 0.35rem !important;
        font-size: 10px;
    }

    .login-box {
        width: min(100%, 94vw) !important;
    }
}
