:root {
    --tt-primary: #5b21ff;
    --tt-primary-dark: #3f16b8;
    --tt-accent: #a78bfa;
    --tt-black: #0f1118;
    --tt-surface: #171c28;
    --tt-surface-soft: #1f2635;
    --tt-light: #f4f5f8;
    --tt-white: #ffffff;
    --tt-text: #1a1d23;
    --tt-text-muted: #6b7280;
    --tt-border: #e9eef5;
    --tt-border-strong: #d6dce7;
    --tt-shadow-sm: 0 8px 22px rgba(15, 17, 24, 0.06);
    --tt-shadow-md: 0 18px 36px rgba(15, 17, 24, 0.16);
    --tt-radius-card: 14px;
    --tt-radius-control: 10px;
    --bs-primary: var(--tt-primary);
    --bs-primary-rgb: 91, 33, 255;
}

body {
    background-color: var(--tt-light);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--tt-text);
}

body:not(.auth-page) {
    padding-left: 56px;
}

body.tt-sidebar-pinned {
    padding-left: 262px;
}

.btn-primary,
.bg-primary {
    background-color: var(--tt-primary) !important;
    border-color: var(--tt-primary) !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--tt-primary-dark) !important;
    border-color: var(--tt-primary-dark) !important;
}

.text-primary {
    color: var(--tt-primary) !important;
}

.card {
    border-radius: var(--tt-radius-card);
    border-color: var(--tt-border);
    box-shadow: var(--tt-shadow-sm);
}

.card-header {
    border-radius: var(--tt-radius-card) var(--tt-radius-card) 0 0 !important;
}

.table > thead > tr > th {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tt-text-muted);
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding-top: 10px;
    padding-bottom: 10px;
}

.table > tbody > tr > td {
    font-size: 0.875rem;
    vertical-align: middle;
    border-color: #f0f2f5;
}

.table-hover tbody tr:hover {
    background-color: rgba(91, 33, 255, 0.03);
}

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

.form-control:focus,
.form-select:focus {
    border-color: rgba(91, 33, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(91, 33, 255, 0.12);
}

.btn {
    font-weight: 500;
}

.badge {
    font-weight: 500;
    letter-spacing: 0.02em;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f0f2f5;
}

::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.app-flash-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.app-flash-stack--closing .app-flash {
    opacity: 0;
    transform: translateY(12px);
}

.app-flash {
    --app-flash-accent: var(--tt-primary);
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--tt-border-strong);
    border-left: 4px solid var(--app-flash-accent);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafe 100%);
    box-shadow: 0 16px 32px rgba(15, 17, 24, 0.12);
    transition: opacity 0.22s ease, transform 0.22s ease;
    animation: appFlashSlideIn 0.22s ease-out;
}

.app-flash__body {
    min-width: 0;
    flex: 1 1 auto;
}

.app-flash__title {
    margin-bottom: 4px;
    color: var(--app-flash-accent);
    font-size: 0.72rem;
    line-height: 1.2;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.app-flash__message {
    color: var(--tt-text);
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.app-flash__close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #8a94a6;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-flash__close:hover {
    background: rgba(15, 17, 24, 0.06);
    color: var(--tt-text);
}

.app-flash--success {
    --app-flash-accent: #16a34a;
    background: linear-gradient(180deg, #ffffff 0%, #f4fbf6 100%);
    border-color: #cfe6d6;
}

.app-flash--danger {
    --app-flash-accent: #dc2626;
    background: linear-gradient(180deg, #ffffff 0%, #fdf6f6 100%);
    border-color: #f0d2d2;
}

.app-flash--warning {
    --app-flash-accent: #d97706;
    background: linear-gradient(180deg, #ffffff 0%, #fff9f1 100%);
    border-color: #f2ddbd;
}

.app-flash--info {
    --app-flash-accent: var(--tt-accent);
    background: linear-gradient(180deg, #ffffff 0%, #f7f5ff 100%);
    border-color: #ddd3ff;
}

html,
body.auth-page {
    min-height: 100%;
}

body.auth-page {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top, rgba(167, 139, 250, 0.22) 0%, rgba(167, 139, 250, 0) 38%),
        linear-gradient(180deg, #0f1118 0%, #171c28 100%);
    color: var(--tt-white);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.auth-shell {
    width: 100%;
    max-width: 420px;
    padding: 24px 16px;
}

.auth-panel {
    padding: 30px 26px 26px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 24px;
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.28);
}

.auth-brand {
    margin-bottom: 24px;
    text-align: center;
}

.auth-mark,
.tt-logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #5b21ff 0%, #7c3aed 100%);
    color: #fff;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 12px 26px rgba(91, 33, 255, 0.22);
}

.auth-mark {
    width: 48px;
    height: 48px;
    margin: 0 auto 14px;
    font-size: 1rem;
}

.auth-title {
    margin: 0;
    color: #111827;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.auth-subtitle {
    margin: 8px 0 0;
    color: #64748b;
    font-size: 0.84rem;
    line-height: 1.5;
}

.auth-form {
    width: 100%;
}

.auth-field {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    border-bottom: 1px solid #d0d6e2;
    transition: border-color .2s ease;
}

.auth-field + .auth-field {
    margin-top: 12px;
}

.auth-field:focus-within {
    border-color: var(--tt-primary);
}

.auth-field svg {
    width: 18px;
    height: 18px;
    color: #9ca3af;
    flex-shrink: 0;
}

.auth-field input {
    width: 100%;
    padding: 13px 0;
    border: none;
    outline: none;
    background: transparent;
    color: #111827;
    font-size: 0.95rem;
    box-shadow: none !important;
}

.auth-field input::placeholder {
    color: #9aa6b2;
}

.auth-submit {
    width: 100%;
    margin-top: 24px;
    padding: 12px 16px;
    border: 1px solid var(--tt-primary);
    border-radius: 12px;
    background: linear-gradient(135deg, #5b21ff 0%, #7c3aed 100%);
    color: #fff;
    font-size: 0.94rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
    box-shadow: 0 14px 28px rgba(91, 33, 255, 0.24);
}

.auth-submit:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(91, 33, 255, 0.28);
}

.auth-submit:active {
    transform: translateY(0);
}

@keyframes appFlashSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tt-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    width: 56px;
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(180deg, #0f1118 0%, #141824 70%, #120a2b 100%);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.18);
    transition: width 0.22s cubic-bezier(.4, 0, .2, 1);
    will-change: width;
}

.tt-sidebar:hover,
.tt-sidebar.pinned {
    width: 262px;
}

.tt-sidebar-inner {
    display: flex;
    flex-direction: column;
    width: 262px;
    height: 100%;
}

.tt-sidebar-logo {
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 14px;
    color: var(--tt-white);
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 1px solid rgba(91, 33, 255, 0.25);
}

.tt-logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    height: 28px;
    color: var(--tt-white);
    background: rgba(91, 33, 255, 0.22);
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-radius: 8px;
    flex-shrink: 0;
}

.tt-logo-mark {
    width: 100%;
    height: 100%;
    font-size: 0.62rem;
    box-shadow: none;
}

.tt-logo-text {
    margin-left: 12px;
    color: var(--tt-white);
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tt-brand-name {
    font-weight: 800;
    letter-spacing: 0.02em;
}

.tt-sidebar:hover .tt-logo-text,
.tt-sidebar.pinned .tt-logo-text,
.tt-sidebar:hover .tt-nav-label,
.tt-sidebar.pinned .tt-nav-label,
.tt-sidebar:hover .tt-user-info,
.tt-sidebar.pinned .tt-user-info {
    opacity: 1;
}

.tt-sidebar:hover .tt-logo-text,
.tt-sidebar:hover .tt-nav-label {
    transition-delay: 0.08s;
}

.tt-sidebar-nav {
    flex: 1;
    padding: 6px 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
}

.tt-sidebar-nav::-webkit-scrollbar {
    display: none;
}

.tt-nav-item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 9px 15px;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.855rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tt-nav-item:hover {
    color: var(--tt-white);
    background: rgba(255, 255, 255, 0.06);
    border-left-color: rgba(91, 33, 255, 0.55);
    text-decoration: none;
}

.tt-nav-item.active {
    color: var(--tt-white);
    background: rgba(91, 33, 255, 0.22);
    border-left-color: var(--tt-primary);
}

.tt-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    flex-shrink: 0;
}

.tt-nav-label {
    display: flex;
    align-items: center;
    min-width: 0;
    margin-left: 12px;
    line-height: 1.25;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.tt-sidebar:hover .tt-nav-label,
.tt-sidebar.pinned .tt-nav-label {
    transform: translateX(0);
}

.tt-sidebar-bottom {
    flex-shrink: 0;
    padding: 6px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.tt-user-dropdown-wrapper {
    position: relative;
}

.tt-user-item {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 8px 15px;
    color: inherit;
    white-space: nowrap;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.tt-user-dropdown-toggle {
    position: relative;
}

.tt-user-dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tt-user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    height: 28px;
    color: var(--tt-white);
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    flex-shrink: 0;
}

.tt-user-info {
    flex: 1;
    margin-left: 10px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tt-user-name {
    max-width: 130px;
    overflow: hidden;
    color: var(--tt-white);
    font-size: 0.8rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-user-dropdown-arrow {
    position: absolute;
    top: 50%;
    right: 8px;
    opacity: 0.5;
    transform: translateY(-50%);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.tt-user-dropdown-wrapper.active .tt-user-dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.tt-user-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 8px;
    width: 230px;
    overflow: hidden;
    background: #1e2630;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.tt-user-dropdown-wrapper.active .tt-user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tt-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: #e0e6ed;
    font-size: 0.875rem;
    text-decoration: none;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tt-user-dropdown-item:last-child {
    border-bottom: 0;
}

.tt-user-dropdown-item:hover {
    color: var(--tt-white);
    background: rgba(255, 255, 255, 0.08);
}

.tt-user-dropdown-item-danger:hover {
    color: #ff6b6b;
    background: rgba(220, 53, 69, 0.15);
}

.app-admin-content {
    min-height: 100vh;
}

.app-admin-page-body {
    padding: 24px;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 0 18px;
    background: #fff;
    border-bottom: 1px solid var(--tt-border-strong);
    box-shadow: 0 1px 0 rgba(15, 17, 24, 0.02);
}

.app-topbar__title-wrap {
    display: flex;
    align-items: center;
    min-width: 0;
}

.app-topbar__title-text {
    min-width: 0;
    overflow: hidden;
    color: #4b5563;
    font-size: 0.95rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-topbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 18px;
}

.app-topbar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: #667085;
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.app-topbar__btn:hover,
.app-topbar__btn.is-open {
    color: var(--tt-primary);
    background: #f3f0ff;
}

.app-topbar__btn:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(91, 33, 255, 0.16);
}

.app-topbar__btn svg {
    width: 18px;
    height: 18px;
}

.app-topbar__menu-wrap {
    position: relative;
}

.app-topbar__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1300;
    display: none;
    min-width: 230px;
    overflow: hidden;
    padding: 6px 0;
    background: #fff;
    border: 1px solid var(--tt-border);
    border-radius: 12px;
    box-shadow: 0 18px 38px rgba(15, 17, 24, 0.16);
}

.app-topbar__menu-wrap.is-open .app-topbar__menu {
    display: block;
}

.app-topbar__menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 42px;
    padding: 10px 16px;
    color: var(--tt-text);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.app-topbar__menu-item:hover {
    color: var(--tt-primary);
    background: #f8f7ff;
}

.app-topbar__menu-item--danger {
    color: #dc2626;
}

.app-topbar__menu-item--danger:hover {
    color: #b91c1c;
    background: #fff1f2;
}

@media (max-width: 767px) {
    body:not(.auth-page),
    body.tt-sidebar-pinned {
        padding-top: 56px;
        padding-left: 0;
    }

    .app-flash-stack {
        right: 12px;
        left: 12px;
        bottom: 12px;
        width: auto;
    }

    .tt-sidebar,
    .tt-sidebar:hover,
    .tt-sidebar.pinned {
        width: 100%;
        height: 56px;
        overflow: visible;
    }

    .tt-sidebar-inner {
        flex-direction: row;
        width: 100%;
    }

    .tt-sidebar-logo {
        width: 56px;
        padding: 14px;
        border-bottom: 0;
    }

    .tt-sidebar-nav {
        display: flex;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .tt-nav-item {
        min-width: 56px;
        padding: 9px 14px;
        border-bottom: 3px solid transparent;
        border-left: 0;
    }

    .tt-nav-item.active {
        border-bottom-color: var(--tt-primary);
        border-left-color: transparent;
    }

    .tt-nav-label,
    .tt-logo-text,
    .tt-user-info,
    .tt-user-dropdown-arrow {
        display: none !important;
    }

    .tt-sidebar-bottom {
        margin-left: auto;
        padding: 4px 6px;
        border-top: 0;
    }

    .tt-user-item {
        min-height: 48px;
        padding: 8px;
    }

    .tt-user-dropdown-menu {
        left: auto;
        right: 0;
        width: 230px;
    }

    .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .app-admin-page-body {
        padding: 16px 12px;
    }

    .app-topbar {
        top: 56px;
        min-height: 48px;
        padding: 0 12px;
    }

    .app-topbar__actions {
        gap: 6px;
        margin-left: 10px;
    }

    .app-topbar__btn {
        width: 34px;
        height: 34px;
    }

    .app-topbar__menu {
        right: -4px;
        min-width: 220px;
    }

    .auth-shell {
        max-width: calc(100vw - 24px);
        padding: 24px 0;
    }

    .auth-panel {
        padding: 24px 20px 22px;
        border-radius: 20px;
    }
}
