/* ============================================
   VARIABLES
   ============================================ */
:root {
    /* Light theme (default) — остаётся как есть */
    --rs-bg: #ffffff;
    --rs-bg-elevated: #f8f9fa;
    --rs-bg-hover: #f1f3f4;
    --rs-bg-active: #ede9fe;          /* фиолетовый 100 */
    --rs-border: #e5e7eb;
    --rs-text: #1f2937;
    --rs-text-muted: #6b7280;
    --rs-text-inverse: #ffffff;
    
    --rs-accent: #7c3aed;             /* violet 600 */
    --rs-accent-hover: #6d28d9;        /* violet 700 */
    --rs-accent-light: #ede9fe;        /* violet 100 */
    
    --rs-danger: #ef4444;
    --rs-danger-bg: #fef2f2;
    --rs-danger-hover: #fee2e2;
    
    --rs-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --rs-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --rs-shadow-popup: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --rs-radius: 12px;
    --rs-radius-sm: 8px;
    --rs-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    --rs-sidebar-width: 260px;
    --rs-sidebar-collapsed: 72px;
}

/* Dark theme — серо-тёмные тона + фиолетовый */
[data-theme="dark"] {
    --rs-bg: #0a0a0f;
    --rs-bg-elevated: #14141b;
    --rs-bg-hover: #1e1e2e;
    --rs-bg-active: #2e1065;
    --rs-border: #27273a;
    --rs-text: #e4e4e7;
    --rs-text-muted: #71717a;
    --rs-text-inverse: #0a0a0f;
    
    /* Фиолетовый темнее и приглушеннее */
    --rs-accent: #7c3aed;           /* violet-600 вместо violet-400 */
    --rs-accent-hover: #6d28d9;      /* violet-700 */
    --rs-accent-light: #2e1065;      /* violet-950 — тёмный фон */
    
    --rs-danger: #ef4444;
    --rs-danger-bg: #450a0a;
    --rs-danger-hover: #7f1d1d;
    
    --rs-success: #10b981;
    --rs-warning: #f59e0b;
    
    --rs-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --rs-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    --rs-shadow-popup: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
}



/* Auto dark (system preference) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --rs-bg: #0a0a0f;
        --rs-bg-elevated: #14141b;
        --rs-bg-hover: #1e1e2e;
        --rs-bg-active: #2e1065;
        --rs-border: #27273a;
        --rs-text: #e4e4e7;
        --rs-text-muted: #71717a;
        --rs-text-inverse: #0a0a0f;
        
        --rs-accent: #a78bfa;
        --rs-accent-hover: #c4b5fd;
        --rs-accent-light: #4c1d95;
        
        --rs-danger: #f87171;
        --rs-danger-bg: #450a0a;
        --rs-danger-hover: #7f1d1d;
        
        --rs-success: #34d399;
        --rs-warning: #fbbf24;
        
        --rs-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
        --rs-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
        --rs-shadow-popup: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 10px 10px -5px rgba(0, 0, 0, 0.5);
    }
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --rs-accent: #7c3aed;        /* violet-600 */
        --rs-accent-hover: #6d28d9;   /* violet-700 */
        --rs-accent-light: #2e1065;   /* violet-950 */
    }
}
/* ============================================
   SIDEBAR BASE
   ============================================ */
.rudy-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--rs-collapsed);
    background: var(--rs-bg);
    border-right: 1px solid var(--rs-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    overflow: hidden;
}

.rudy-sidebar:hover,
.rudy-sidebar.expanded {
    width: var(--rs-expanded);
    box-shadow: var(--rs-shadow-lg);
}

/* ============================================
   VIEWS
   ============================================ */
.sidebar-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: var(--rs-expanded);
    opacity: 1;
    transition: opacity 0.2s ease;
}

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

/* ============================================
   BRAND
   ============================================ */
.sidebar-brand {
    padding: 16px 14px 12px;
    flex-shrink: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--rs-text);
    height: 40px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, var(--rs-accent), var(--rs-accent-hover));
    border-radius: var(--rs-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.brand-icon .ph {
    font-size: 22px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(-10px);
    transition: var(--rs-transition);
    white-space: nowrap;
    overflow: hidden;
}

.rudy-sidebar:hover .brand-text,
.rudy-sidebar.expanded .brand-text {
    opacity: 1;
    transform: translateX(0);
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--rs-text);
}

.brand-sub {
    font-size: 11px;
    color: var(--rs-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   NAVIGATION
   ============================================ */
.sidebar-nav {
    flex: 1;
    padding: 4px 10px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--rs-border);
    border-radius: 3px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 12px;
    border-radius: var(--rs-radius-sm);
    color: var(--rs-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: var(--rs-transition);
    margin-bottom: 3px;
    height: 44px;
}

.nav-item:hover {
    background: var(--rs-bg-hover);
    color: var(--rs-text);
}

.nav-item.active {
    background: var(--rs-bg-active);
    color: var(--rs-accent);
}

.nav-item.active .nav-indicator {
    opacity: 1;
    transform: scaleY(1);
}

.nav-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon .ph {
    font-size: 20px;
}

.nav-label {
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-8px);
    transition: var(--rs-transition);
    overflow: hidden;
}

.rudy-sidebar:hover .nav-label,
.rudy-sidebar.expanded .nav-label {
    opacity: 1;
    transform: translateX(0);
}

.nav-indicator {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 18px;
    background: var(--rs-accent);
    border-radius: 0 3px 3px 0;
    opacity: 0;
    transition: var(--rs-transition);
}

/* ============================================
   BOTTOM SECTION
   ============================================ */
.sidebar-bottom {
    padding: 8px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
    border-top: 1px solid var(--rs-border);
}

.bottom-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: var(--rs-radius-sm);
    border: none;
    background: transparent;
    color: var(--rs-text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--rs-transition);
    text-align: left;
    font-family: inherit;
    position: relative;
    height: 44px;
    text-decoration: none;
}

.bottom-btn:hover {
    background: var(--rs-bg-hover);
    color: var(--rs-text);
}

.bottom-btn.danger:hover {
    background: var(--rs-danger-bg);
    color: var(--rs-danger);
}

.bottom-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-icon .ph {
    font-size: 20px;
}

.bottom-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--rs-border);
}

.bottom-label,
.bottom-user {
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-8px);
    transition: var(--rs-transition);
    overflow: hidden;
}

.bottom-user {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.bottom-role {
    font-size: 11px;
    color: var(--rs-text-muted);
    text-transform: capitalize;
}

.rudy-sidebar:hover .bottom-label,
.rudy-sidebar:hover .bottom-user,
.rudy-sidebar.expanded .bottom-label,
.rudy-sidebar.expanded .bottom-user {
    opacity: 1;
    transform: translateX(0);
}

/* Badge */
.badge {
    position: absolute;
    top: 6px;
    left: 26px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--rs-danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: var(--rs-transition);
}

.rudy-sidebar:hover .badge,
.rudy-sidebar.expanded .badge {
    opacity: 1;
    transform: scale(1);
}

/* Theme icons */
.theme-icon-dark,
[data-theme="dark"] .theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: flex;
}

/* Logout form */
.logout-form {
    margin: 0;
}

/* ============================================
   VIEW HEADERS (notif / profile)
   ============================================ */
.view-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 12px;
    flex-shrink: 0;
    min-height: 56px;
    border-bottom: 1px solid var(--rs-border);
}

.header-back {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--rs-radius-sm);
    border: none;
    background: transparent;
    color: var(--rs-text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: var(--rs-transition);
    white-space: nowrap;
    font-family: inherit;
}

.header-back:hover {
    background: var(--rs-bg-hover);
    color: var(--rs-text);
}

.header-back .ph {
    font-size: 18px;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--rs-text);
    flex: 1;
    text-align: center;
    margin-right: 44px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-10px);
    transition: var(--rs-transition);
}

.rudy-sidebar:hover .header-title,
.rudy-sidebar.expanded .header-title {
    opacity: 1;
    transform: translateX(0);
}

.header-action {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: var(--rs-radius-sm);
    border: none;
    background: transparent;
    color: var(--rs-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--rs-transition);
}

.header-action:hover {
    background: var(--rs-bg-hover);
    color: var(--rs-accent);
}

/* ============================================
   VIEW CONTENT
   ============================================ */
.view-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Loader */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 12px;
}

.loader-dots {
    display: flex;
    gap: 6px;
}

.loader-dots span {
    width: 8px;
    height: 8px;
    background: var(--rs-accent);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loader-dots span:nth-child(1) { animation-delay: -0.32s; }
.loader-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.loader-text {
    font-size: 13px;
    color: var(--rs-text-muted);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border-radius: var(--rs-radius-sm);
    cursor: pointer;
    transition: var(--rs-transition);
    position: relative;
    margin-bottom: 4px;
}

.notif-item:hover {
    background: var(--rs-bg-hover);
}

.notif-item.unread {
    background: var(--rs-bg-active);
}

.notif-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--rs-text);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-item-body {
    font-size: 12px;
    color: var(--rs-text-muted);
    margin-top: 3px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-item-date {
    font-size: 11px;
    color: var(--rs-text-muted);
    margin-top: 4px;
    opacity: 0.7;
}

.notif-del {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--rs-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--rs-transition);
    padding: 0;
}

.notif-item:hover .notif-del {
    opacity: 1;
}

.notif-del:hover {
    background: var(--rs-danger-bg);
    color: var(--rs-danger);
}

.notif-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--rs-text-muted);
    font-size: 13px;
}

/* ============================================
   PROFILE CARD
   ============================================ */
.profile-card {
    padding: 4px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 8px;
    margin-bottom: 8px;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--rs-border);
}

.profile-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--rs-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 12px;
    color: var(--rs-accent);
    text-transform: capitalize;
    margin-top: 2px;
}

.profile-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--rs-radius-sm);
    color: var(--rs-text);
    text-decoration: none;
    font-size: 14px;
    transition: var(--rs-transition);
    height: 44px;
}

.profile-link:hover {
    background: var(--rs-bg-hover);
}

.profile-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rs-text-muted);
}

.profile-icon .ph {
    font-size: 20px;
}

.profile-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-arrow {
    color: var(--rs-text-muted);
    font-size: 14px;
    min-width: 16px;
}

/* ============================================
   MOBILE
   ============================================ */
.mob-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--rs-accent);
    color: white;
    border: none;
    box-shadow: var(--rs-shadow-lg);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 998;
}

.mob-toggle .ph {
    font-size: 24px;
}

@media (max-width: 768px) {
    .rudy-sidebar {
        transform: translateX(-100%);
        width: var(--rs-expanded);
        box-shadow: none;
    }
    
    .rudy-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: var(--rs-shadow-lg);
    }
    
    /* На мобильном всегда показываем текст */
    .rudy-sidebar .brand-text,
    .rudy-sidebar .nav-label,
    .rudy-sidebar .bottom-label,
    .rudy-sidebar .bottom-user,
    .rudy-sidebar .header-title {
        opacity: 1;
        transform: none;
    }
    
    .rudy-sidebar .badge {
        opacity: 1;
        transform: scale(1);
    }
    
    .mob-toggle {
        display: flex;
    }
}

/* Overlay for mobile */
@media (max-width: 768px) {
    .rudy-sidebar.mobile-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: var(--rs-expanded);
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: -1;
    }
}
/* ============================================
   SIDEBAR BASE — ИСПРАВЛЕНО
   ============================================ */
.rudy-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--rs-collapsed);        /* 64px свёрнут */
    background: var(--rs-bg);
    border-right: 1px solid var(--rs-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;                 /* ВАЖНО: не hidden, иначе обрежет панель */
}

/* Раскрытие при наведении */
.rudy-sidebar:hover,
.rudy-sidebar.expanded {
    width: var(--rs-expanded);         /* 240px раскрыт */
    box-shadow: var(--rs-shadow-lg);
}

/* ============================================
   VIEWS — ИСПРАВЛЕНО
   ============================================ */
.sidebar-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: var(--rs-expanded);         /* Фиксированная ширина контента */
    min-width: var(--rs-expanded);
    opacity: 1;
    transition: opacity 0.2s ease;
    overflow: hidden;                  /* Обрезаем лишнее внутри */
}

/* Скрытые вьюшки */
.sidebar-view[hidden] {
    display: none !important;
}

/* ============================================
   BRAND — ИСПРАВЛЕНО
   ============================================ */
.sidebar-brand {
    padding: 16px 14px 12px;
    flex-shrink: 0;
    width: var(--rs-expanded);         /* Фикс ширина */
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--rs-text);
    height: 40px;
    width: var(--rs-expanded);
}

.brand-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;                   /* Не сжиматься */
    background: linear-gradient(135deg, var(--rs-accent), var(--rs-accent-hover));
    border-radius: var(--rs-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.brand-text {
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(-10px);
    transition: var(--rs-transition);
    white-space: nowrap;
    overflow: hidden;
    width: 0;                          /* Начальная ширина 0 */
}

.rudy-sidebar:hover .brand-text,
.rudy-sidebar.expanded .brand-text {
    opacity: 1;
    transform: translateX(0);
    width: auto;                     /* Раскрывается при ховере */
}

/* ============================================
   NAVIGATION — ИСПРАВЛЕНО
   ============================================ */
.sidebar-nav {
    flex: 1;
    padding: 4px 10px;
    overflow-y: auto;
    overflow-x: hidden;
    width: var(--rs-expanded);         /* Фикс ширина */
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 12px;
    border-radius: var(--rs-radius-sm);
    color: var(--rs-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: var(--rs-transition);
    margin-bottom: 3px;
    height: 44px;
    width: var(--rs-expanded);         /* Фикс ширина */
    box-sizing: border-box;
}

.nav-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;                   /* Не сжиматься */
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-label {
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-8px);
    transition: var(--rs-transition);
    overflow: hidden;
    width: 0;
}

.rudy-sidebar:hover .nav-label,
.rudy-sidebar.expanded .nav-label {
    opacity: 1;
    transform: translateX(0);
    width: auto;
}

/* ============================================
   BOTTOM — ИСПРАВЛЕНО
   ============================================ */
.sidebar-bottom {
    padding: 8px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
    border-top: 1px solid var(--rs-border);
    width: var(--rs-expanded);         /* Фикс ширина */
}

.bottom-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: var(--rs-radius-sm);
    border: none;
    background: transparent;
    color: var(--rs-text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--rs-transition);
    text-align: left;
    font-family: inherit;
    position: relative;
    height: 44px;
    text-decoration: none;
    width: var(--rs-expanded);
    box-sizing: border-box;
}

.bottom-label,
.bottom-user {
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-8px);
    transition: var(--rs-transition);
    overflow: hidden;
    width: 0;
}

.rudy-sidebar:hover .bottom-label,
.rudy-sidebar:hover .bottom-user,
.rudy-sidebar.expanded .bottom-label,
.rudy-sidebar.expanded .bottom-user {
    opacity: 1;
    transform: translateX(0);
    width: auto;
}

/* ============================================
   VIEW HEADERS — ИСПРАВЛЕНО
   ============================================ */
.view-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 12px;
    flex-shrink: 0;
    min-height: 56px;
    border-bottom: 1px solid var(--rs-border);
    width: var(--rs-expanded);
    box-sizing: border-box;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--rs-text);
    flex: 1;
    text-align: center;
    margin-right: 44px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-10px);
    transition: var(--rs-transition);
    width: 0;
    overflow: hidden;
}

.rudy-sidebar:hover .header-title,
.rudy-sidebar.expanded .header-title {
    opacity: 1;
    transform: translateX(0);
    width: auto;
}

/* ============================================
   VIEW CONTENT — ИСПРАВЛЕНО
   ============================================ */
.view-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
    width: var(--rs-expanded);
    box-sizing: border-box;
}

/* ============================================
   PROFILE CARD — ИСПРАВЛЕНО
   ============================================ */
.profile-card {
    padding: 4px;
    width: var(--rs-expanded);
    box-sizing: border-box;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 8px;
    margin-bottom: 8px;
    width: var(--rs-expanded);
    box-sizing: border-box;
}

.profile-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--rs-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 140px;                      /* Ограничение чтобы не вылезло */
}

/* ============================================
   MOBILE — ИСПРАВЛЕНО
   ============================================ */
@media (max-width: 768px) {
    .rudy-sidebar {
        transform: translateX(calc(-1 * var(--rs-collapsed)));
        width: var(--rs-collapsed);
    }
    
    .rudy-sidebar.mobile-open {
        transform: translateX(0);
        width: var(--rs-expanded);     /* На мобильном сразу полная ширина */
    }
    
    /* На мобильном всегда показываем текст */
    .rudy-sidebar .brand-text,
    .rudy-sidebar .nav-label,
    .rudy-sidebar .bottom-label,
    .rudy-sidebar .bottom-user,
    .rudy-sidebar .header-title {
        opacity: 1;
        transform: none;
        width: auto;
    }
    
    .rudy-sidebar .badge {
        opacity: 1;
        transform: scale(1);
    }
}
body {
    font-family: 'Ubuntu', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
/* ============================================
   GLOBAL RESET
   ============================================ */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Ubuntu', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--rs-bg);
    color: var(--rs-text);
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app-content {
    min-height: 100vh;
    margin-left: var(--rs-sidebar-width);
    width: calc(100vw - var(--rs-sidebar-width));
    background: var(--rs-bg);
    color: var(--rs-text);
    overflow-x: hidden;
}

/* Когда sidebar свёрнут/раскрыт — можно менять отступы */
body.sidebar-collapsed .app-content {
    margin-left: var(--rs-sidebar-collapsed);
    width: calc(100vw - var(--rs-sidebar-collapsed));
}

/* Если sidebar открыт на hover, пусть layout не прыгает.
   Это важно: sidebar fixed, а контент должен жить отдельно. */

/* ============================================
   MOBILE
   ============================================ */
@media (max-width: 768px) {
    .app-content {
        margin-left: 0;
        width: 100vw;
    }
}

/* ============================================
   PREVENT WHITE GAPS FROM ROOT CONTAINERS
   ============================================ */
#aiwOverlay,
.aiw-page,
.aiw-shell,
.aiw-main,
.aiw-chatpanel,
.aiw-chat-surface {
    background: var(--rs-bg);
}

img {
    max-width: 100%;
    display: block;
}
.app-content {
    min-height: 100vh;
    margin-left: var(--rs-collapsed);
    width: calc(100vw - var(--rs-collapsed));
    background: var(--rs-bg);
    overflow: hidden;
}

@media (max-width: 768px) {
    .app-content {
        margin-left: 0;
        width: 100vw;
    }
}
:root {
    --rs-expanded: 260px;
    --rs-collapsed: 72px;
}

.app-content {
    min-height: 100vh;
    margin-left: var(--rs-collapsed);
    width: calc(100vw - var(--rs-collapsed));
}

@media (max-width: 768px) {
    .app-content {
        margin-left: 0;
        width: 100vw;
    }
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 12px;
    border-radius: var(--rs-radius-sm);
    color: var(--rs-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    transition: var(--rs-transition);
    margin-bottom: 3px;
    height: 44px;
    width: var(--rs-expanded);
    box-sizing: border-box;
}

.nav-item:hover {
    background: var(--rs-bg-hover);
    color: var(--rs-text);
}

.nav-item.active {
    background: color-mix(in srgb, var(--rs-accent) 12%, transparent);
    color: var(--rs-accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rs-accent) 18%, var(--rs-border));
}

.nav-item.active .nav-indicator {
    opacity: 1;
    transform: scaleY(1);
}

/* Свёрнутый sidebar — активный пункт компактный */
.rudy-sidebar:not(.expanded):not(:hover) .nav-item.active {
    background: transparent;
    color: var(--rs-accent);
    box-shadow: none;
}

.rudy-sidebar:not(.expanded):not(:hover) .nav-item.active .nav-indicator {
    opacity: 1;
    transform: scaleY(1);
}

/* Раскрытый sidebar — активный пункт мягко подсвечен */
.rudy-sidebar:hover .nav-item.active,
.rudy-sidebar.expanded .nav-item.active {
    background: var(--rs-bg-active);
    color: var(--rs-accent);
    box-shadow: none;
}
.rudy-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--rs-collapsed);
    background: var(--rs-bg);
    border-right: 1px solid var(--rs-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s ease;
    overflow: hidden;
    contain: layout paint;
}

.rudy-sidebar:hover,
.rudy-sidebar.expanded {
    width: var(--rs-expanded);
    box-shadow: var(--rs-shadow-lg);
}

/* ===== text visibility ===== */
.brand-text,
.nav-label,
.bottom-label,
.bottom-user,
.header-title {
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-10px);
    max-width: 0;
    overflow: hidden;
    transition:
        opacity 0.18s ease 0.12s,
        transform 0.18s ease 0.12s,
        max-width 0.18s ease 0.12s;
}

/* when opened */
.rudy-sidebar:hover .brand-text,
.rudy-sidebar:hover .nav-label,
.rudy-sidebar:hover .bottom-label,
.rudy-sidebar:hover .bottom-user,
.rudy-sidebar:hover .header-title,
.rudy-sidebar.expanded .brand-text,
.rudy-sidebar.expanded .nav-label,
.rudy-sidebar.expanded .bottom-label,
.rudy-sidebar.expanded .bottom-user,
.rudy-sidebar.expanded .header-title {
    opacity: 1;
    transform: translateX(0);
    max-width: 220px;
}
.nav-indicator {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 20px;              /* Чуть увеличил для заметности */
    background: var(--rs-accent);
    border-radius: 0 3px 3px 0;
    opacity: 0;
    transition: var(--rs-transition);
    pointer-events: none;      /* Чтобы не мешал кликам */
}
.nav-item.active .nav-indicator {
    opacity: 1;
    transform: translateY(-50%) scaleY(1);  /* ← важно: translateY(-50%) сохраняется */
}
.rudy-sidebar:not(.expanded):not(:hover) .nav-item.active .nav-indicator {
    opacity: 1;
    transform: translateY(-50%) scaleY(1);  /* ← добавил translateY(-50%) */
}
/* ============================================
   ADMIN ELEMENTS
   ============================================ */

/* Разделитель в навигации */
.nav-divider {
    padding: 8px 16px 4px;
    margin-top: 4px;
}

.divider-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted, #64748b);
}

/* Админский пункт в навигации */
.admin-item {
    position: relative;
}

.nav-badge-admin {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(124, 58, 237, 0.15);
    color: #7c3aed;
    border: 1px solid rgba(124, 58, 237, 0.3);
}

[data-theme="dark"] .nav-badge-admin {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
    border-color: rgba(167, 139, 250, 0.3);
}

/* Роль админа в bottom */
.bottom-role-admin {
    color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
}

/* Кнопка админки внизу */
.admin-bottom-btn {
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
}

.admin-bottom-btn:hover {
    background: rgba(245, 158, 11, 0.1) !important;
}

/* Админская роль в профиле */
.profile-role-admin {
    color: #f59e0b !important;
}

/* Разделитель в профиле */
.profile-divider {
    height: 1px;
    background: var(--border, #e2e8f0);
    margin: 4px 0;
}

/* Админская ссылка в профиле */
.admin-profile-link {
    border-left: 3px solid #f59e0b;
    padding-left: 13px !important;
}

.admin-profile-link:hover {
    background: rgba(245, 158, 11, 0.05);
}
/* ============================================
   NOTIFICATIONS IN SIDEBAR
   ============================================ */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.notif-item:hover {
    background: var(--bg, #f8fafc);
    border-color: var(--border, #e2e8f0);
}

.notif-item.unread {
    background: rgba(124, 58, 237, 0.06);
    border-color: rgba(124, 58, 237, 0.15);
}

.notif-item-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(124, 58, 237, 0.1);
}

.notif-item-content {
    flex: 1;
    min-width: 0;
}

.notif-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #0f172a);
    margin-bottom: 2px;
}

.notif-item-body {
    font-size: 12px;
    color: var(--text-muted, #64748b);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-item-date {
    font-size: 11px;
    color: var(--text-light, #94a3b8);
    margin-top: 4px;
}

.notif-del {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notif-item:hover .notif-del {
    opacity: 1;
}

.notif-del:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.notif-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #64748b);
    font-size: 14px;
}

.notif-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}
/* ============================================
   TOAST NOTIFICATION
   ============================================ */
.notification-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 22px;
    background: var(--card, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 18px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    min-width: 320px;
    max-width: 420px;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    backdrop-filter: blur(20px);
    cursor: pointer;
}

.notification-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.notification-toast.hide {
    transform: translateX(120%);
    opacity: 0;
}

.notification-toast-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: var(--accent-soft, #ede9fe);
    color: var(--accent, #7c3aed);
}

.notification-toast-content {
    flex: 1;
    min-width: 0;
}

.notification-toast-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text, #0f172a);
    margin-bottom: 4px;
    line-height: 1.3;
}

.notification-toast-body {
    font-size: 13px;
    color: var(--text-muted, #64748b);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
    line-height: 1;
    margin-top: -2px;
}

.notification-toast-close:hover {
    background: var(--accent-soft, #ede9fe);
    color: var(--text, #0f172a);
}

/* Progress bar */
.notification-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent, #7c3aed);
    border-radius: 0 0 18px 18px;
    transition: width 0.1s linear;
}

/* Stack multiple toasts */
.notification-toast:nth-child(2) {
    top: 120px;
}

.notification-toast:nth-child(3) {
    top: 216px;
}

/* Mobile */
@media (max-width: 640px) {
    .notification-toast {
        left: 16px;
        right: 16px;
        min-width: auto;
        max-width: none;
    }
}

/* Dark theme */
[data-theme="dark"] .notification-toast {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
}
/* На странице AI — форсируем текст в глобальном сайдбаре */
@media (max-width: 980px) {
    .rudy-sidebar.mobile-open .brand-text,
    .rudy-sidebar.mobile-open .nav-label,
    .rudy-sidebar.mobile-open .bottom-label,
    .rudy-sidebar.mobile-open .bottom-user,
    .rudy-sidebar.mobile-open .header-title {
        opacity: 1 !important;
        transform: translateX(0) !important;
        max-width: 220px !important;
        width: auto !important;
    }
    
    .rudy-sidebar.mobile-open .badge {
        opacity: 1 !important;
        transform: scale(1) !important;
    }
}
.badge[hidden] {
    display: none !important;
}