/* ============================================
   БАЗОВЫЕ СТИЛИ
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Сброс стилей для ссылок, чтобы не конфликтовали с точками статусов */
a {
    text-decoration: none;
    color: inherit;
}

a * {
    color: inherit;
}

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
    /* Основные цвета палитры */
    --alizarin-crimson: #ea2d28;  /* Активный красный */
    --regal-blue: #023b69;        /* Глубокий синий */
    --old-lace: #fdf8ef;          /* Светлый бежевый фон */
    --mojo: #bb3b36;              /* Темный красный */
    --wedgewood: #467d9d;         /* Светлый синий */
    --tonys-pink: #e58780;        /* Светлый розовый */
    --blue-zodiac: #103555;       /* Темный синий */
    --punch: #dd312e;             /* Яркий красный */
    
    /* Основные цвета интерфейса */
    --brand-blue: var(--regal-blue);        /* Основной синий */
    --brand-blue-dark: var(--blue-zodiac);  /* Темный синий */
    --brand-blue-light: var(--wedgewood);   /* Светлый синий */
    --brand-red: var(--alizarin-crimson);   /* Активный красный */
    --brand-red-dark: var(--mojo);          /* Темный красный */
    --brand-beige: var(--old-lace);         /* Светлый бежевый фон */
    --brand-white: #ffffff;                 /* Чистый белый */
    
    /* Цвета интерфейса (без градиентов) */
    --primary-color: var(--brand-blue);
    --primary-hover: var(--brand-blue-light);
    --primary-dark: var(--brand-blue-dark);
    --accent-color: var(--brand-red);
    --accent-hover: var(--punch);
    --danger-color: var(--brand-red);
    
    --sidebar-bg: var(--brand-blue);
    --sidebar-hover: var(--blue-zodiac);
    --chat-bg: var(--brand-beige);
    --message-user-bg: var(--brand-blue);
    --message-assistant-bg: var(--brand-white);
    --border-color: rgba(2, 59, 105, 0.15);
    --text-primary: var(--blue-zodiac);
    --text-primary-on-blue: var(--brand-white);
    --text-secondary: rgba(16, 53, 85, 0.7);
    --text-muted: rgba(16, 53, 85, 0.5);
    
    /* Размеры */
    --sidebar-width: 280px;
    --header-height: 70px;
    --input-height: 60px;
    
    /* Типографика - строгий технологичный стиль */
    --font-primary: 'Montserrat', 'Inter', 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-h1: 36px;      /* 32-40px, bold */
    --font-size-h2: 26px;      /* 24-28px, semibold */
    --font-size-h3: 21px;      /* 20-22px, medium */
    --font-size-body: 15px;    /* 14-16px, regular/medium */
    --font-size-small: 14px;
    
    /* Тени - минималистичные */
    --shadow-sm: 0 1px 2px rgba(2, 59, 105, 0.08);
    --shadow-md: 0 2px 4px rgba(2, 59, 105, 0.12);
    --shadow-lg: 0 4px 8px rgba(2, 59, 105, 0.15);
}

body {
    font-family: var(--font-primary);
    background: var(--brand-beige);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
    font-size: var(--font-size-body);
    font-weight: 400;  /* regular */
    line-height: 1.6;
}

/* Типографика заголовков - строгий технологичный стиль */
h1 {
    font-size: var(--font-size-h1);
    font-weight: 700;  /* bold */
    font-family: var(--font-primary);
    color: var(--text-primary);
    line-height: 1.2;
    margin: 0 0 16px 0;
    letter-spacing: -0.5px;
}

h2 {
    font-size: var(--font-size-h2);
    font-weight: 600;  /* semibold */
    font-family: var(--font-primary);
    color: var(--text-primary);
    line-height: 1.3;
    margin: 0 0 12px 0;
    letter-spacing: -0.3px;
}

h3 {
    font-size: var(--font-size-h3);
    font-weight: 500;  /* medium */
    font-family: var(--font-primary);
    color: var(--text-primary);
    line-height: 1.4;
    margin: 0 0 8px 0;
    letter-spacing: -0.2px;
}

/* ============================================
   КОНТЕЙНЕР ПРИЛОЖЕНИЯ
   ============================================ */

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ============================================
   БОКОВАЯ ПАНЕЛЬ
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);  /* Плоский цвет без градиента */
    color: var(--brand-white);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(2, 59, 105, 0.15);
}

.sidebar-header {
    padding: 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.app-logo {
    max-width: 100%;
    height: 75px;
    object-fit: contain;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);  /* Плоский цвет без градиента */
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: var(--brand-white);
    font-size: var(--font-size-small);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    font-family: var(--font-primary);
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.15);  /* Плоский цвет */
    border-color: rgba(255, 255, 255, 0.3);
    transform: none;  /* Убираем трансформацию для строгости */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.new-chat-btn .btn-icon {
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chats-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.chat-item:hover {
    background: var(--sidebar-hover);
}

.chat-item.active {
    background: rgba(255, 255, 255, 0.15);
    border-left: 3px solid var(--brand-red);
}

.chat-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-item-title {
    font-size: var(--font-size-small);
    font-weight: 500;
    color: var(--brand-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-date {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.chat-item-actions {
    display: none;
    gap: 4px;
}

.chat-item:hover .chat-item-actions {
    display: flex;
}

.chat-item-action-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-item-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-footer-user {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.sidebar-user-name {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.sidebar-user-name:hover {
    color: rgba(255, 255, 255, 1);
    text-decoration: underline;
}

.sidebar-logout-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.sidebar-logout-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-logout-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-footer-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    opacity: 0.8;
}

.logo-firstbit {
    max-width: 100%;
    max-height: 30px;
    height: auto;
    object-fit: contain;
}


/* ============================================
   ОБЛАСТЬ ЧАТА
   ============================================ */

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    overflow: hidden;
    position: relative;
}

/* ============================================
   ТАБЫ (ВКЛАДКИ)
   ============================================ */

.tabs-container {
    display: flex;
    gap: 0;
    background: var(--brand-white);
    border-bottom: 2px solid var(--border-color);
    padding: 0 32px;
    box-shadow: 0 2px 4px rgba(0, 38, 64, 0.05);
}

.tab-btn {
    padding: 16px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: var(--font-size-small);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-primary);
    position: relative;
}


.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(2, 59, 105, 0.03);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--accent-color);  /* Плоский цвет без градиента */
    font-weight: 600;
}

.tab-btn .moderation-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--brand-red);
    color: var(--brand-white);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tab-content {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px;
    background: var(--chat-bg);
    max-height: calc(100vh - 120px);
}

.chat-header {
    height: var(--header-height);
    padding: 0 32px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);  /* Светлая граница на темном фоне */
    display: flex;
    align-items: center;
    background: var(--blue-zodiac);  /* Темный синий из цветокорра (#103555) */
    color: var(--brand-white);  /* Белый текст */
    z-index: 10;
    box-shadow: 0 2px 4px rgba(2, 59, 105, 0.15);
}

.chat-header-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-title {
    font-size: var(--font-size-h3);
    font-weight: 600;
    color: var(--brand-white);  /* Белый текст на темном фоне */
    font-family: var(--font-primary);
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);  /* Белый текст с прозрачностью */
    transition: all 0.2s ease;
    font-size: 16px;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);  /* Светлый фон при наведении */
    color: var(--brand-white);  /* Белый текст */
}

/* ============================================
   ОБЛАСТЬ СООБЩЕНИЙ
   ============================================ */

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    background: var(--chat-bg);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    object-fit: cover;
    border-radius: 66px;
    position: relative;
    opacity: 1;
    /* Эффект прозрачности краев */
    mask-image: radial-gradient(circle, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
    -webkit-mask-image: radial-gradient(circle, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
}

.empty-state-icon::before {
    display: none;
}

.empty-state h2 {
    font-size: var(--font-size-h2);
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    font-family: var(--font-primary);
}

.empty-state p {
    font-size: var(--font-size-body);
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-weight: 400;
}

.example-queries {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 500px;
    width: 100%;
}

.example-query {
    padding: 16px;
    background: var(--message-assistant-bg);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 14px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.example-query:hover {
    background: var(--brand-white);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-width: 2px;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 768px;
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--message-user-bg);
    color: #ffffff;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.message.assistant .message-avatar {
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 1px;
}

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

.message-bubble {
    padding: 16px 20px;
    border-radius: 16px;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: normal;
    position: relative;
}

.message.user .message-bubble {
    background: var(--message-user-bg);  /* Плоский цвет без градиента */
    color: var(--brand-white);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 4px rgba(2, 59, 105, 0.1);
}

.message.assistant .message-bubble {
    background: var(--message-assistant-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-text {
    font-size: var(--font-size-body);
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    font-weight: 400;
    width: 100%;
}

.message-with-search .message-split-layout {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 16px;
}

.uncertainty-banner {
    margin-top: 12px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
}
.uncertainty-banner .uncertainty-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #b91c1c;
}
.uncertainty-banner .uncertainty-reason {
    font-size: 13px;
    color: #7f1d1d;
}
.uncertainty-medium {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.08);
}
.uncertainty-medium .uncertainty-title { color: #92400e; }
.uncertainty-medium .uncertainty-reason { color: #92400e; }

.feedback-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}
.feedback-btn {
    border: 1px solid var(--border-color);
    background: var(--brand-white);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
}
.feedback-btn:hover {
    background: rgba(2, 59, 105, 0.05);
}

.message-text code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message.user .message-text code {
    background: rgba(255, 255, 255, 0.2);
}

.message-text pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message.user .message-text pre {
    background: rgba(255, 255, 255, 0.15);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.message-time {
    opacity: 0.7;
}

.message-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.message.user .message-sources {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.sources-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-item {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(2, 59, 105, 0.08);
    border-radius: 4px;
    font-size: 12px;
    margin: 4px 4px 0 0;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(2, 59, 105, 0.15);
}

.source-item:hover {
    background: rgba(2, 59, 105, 0.15);
    border-color: var(--primary-color);
}

/* ============================================
   ДВУХКОЛОНОЧНЫЙ МАКЕТ ДЛЯ ОТВЕТОВ С ПОИСКОМ
   ============================================ */

.message-with-search {
    padding: 0;
    overflow: hidden;
}

.message-split-layout {
    display: flex;
    gap: 0;
    min-height: 200px;
}

.message-text-column {
    flex: 1.2;
    padding: 20px 24px;
    background: var(--message-assistant-bg);
    border-right: 2px solid var(--border-color);
}

.message-stats-column {
    flex: 0.8;
    padding: 20px 24px;
    background: rgba(2, 59, 105, 0.03);
    border-left: 2px solid var(--border-color);
    max-height: 600px;
    overflow-y: auto;
}

.stats-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(2, 59, 105, 0.08);
}

.stats-item:last-child {
    border-bottom: none;
}

.stats-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stats-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.stats-value.stats-high {
    color: #10b981;
}

.stats-value.stats-medium {
    color: #f59e0b;
}

.stats-value.stats-low {
    color: #ef4444;
}

.stats-document {
    padding: 12px;
    background: var(--brand-white);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.stats-document:last-child {
    margin-bottom: 0;
}

.stats-document-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    word-break: break-word;
}

.stats-document-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.stats-detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.stats-detail-value {
    font-weight: 600;
    color: var(--text-primary);
}

.stats-detail-value.relevance-высокая,
.stats-detail-value.relevance-high {
    color: #10b981;
}

.stats-detail-value.relevance-средняя,
.stats-detail-value.relevance-medium {
    color: #f59e0b;
}

.stats-detail-value.relevance-низкая,
.stats-detail-value.relevance-low {
    color: #ef4444;
}

.stats-keywords {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.stats-keywords-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
    font-weight: 500;
}

.stats-keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.stats-keyword {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(2, 59, 105, 0.08);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-primary);
    border: 1px solid rgba(2, 59, 105, 0.15);
}

.stats-keyword-more {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(2, 59, 105, 0.05);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.stats-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.sources-list {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.sources-list .sources-title {
    margin-bottom: 12px;
}

.sources-list .source-item {
    display: block;
    margin: 6px 0;
    padding: 6px 10px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .message-split-layout {
        flex-direction: column;
    }
    
    .message-text-column,
    .message-stats-column {
        flex: 1;
        border-right: none;
        border-left: none;
        border-top: 2px solid var(--border-color);
    }
    
    .message-text-column {
        border-top: none;
    }
    
    .message-stats-column {
        max-height: 400px;
    }
}

.message.loading .message-bubble {
    padding: 20px;
}

.loading-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: loadingDot 1.4s infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loadingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ============================================
   ПОЛЕ ВВОДА
   ============================================ */

.input-area {
    padding: 20px 32px;
    border-top: 2px solid var(--border-color);
    background: var(--brand-white);
    box-shadow: 0 -2px 8px rgba(0, 38, 64, 0.05);
}

.input-container {
    display: flex;
    align-items: stretch;
    gap: 12px;
    max-width: 768px;
    margin: 0 auto;
    width: 100%;
}

.attach-btn {
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 100% !important;
    min-height: 48px;
    align-self: stretch;
}

.attach-btn:hover {
    background: var(--message-assistant-bg);
    color: var(--text-primary);
}

/* Иконка скрепки */
.icon-attach {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    width: 18px;
    height: 18px;
    text-align: center;
    flex-shrink: 0;
    pointer-events: none;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#messageInput {
    width: 100%;
    min-height: 48px;
    max-height: 200px;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: var(--font-size-body);
    font-family: var(--font-primary);
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    background: var(--brand-white);
    color: var(--text-primary);
    font-weight: 400;
}

#messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(2, 59, 105, 0.1);
}

.send-btn {
    background: var(--primary-color);  /* Плоский цвет без градиента */
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--brand-white);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(2, 59, 105, 0.2);
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-hover);  /* Плоский цвет */
    transform: none;  /* Убираем масштабирование для строгости */
    box-shadow: 0 2px 6px rgba(2, 59, 105, 0.3);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-icon {
    font-size: 18px;
}

.input-footer {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
}

.prompt-selector {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.prompt-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

.prompt-checkbox-label:hover {
    color: var(--text-primary);
}

.prompt-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.input-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.attached-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--message-assistant-bg);
    border-radius: 8px;
    font-size: 14px;
}

.file-name {
    color: var(--text-primary);
}

.remove-file-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.remove-file-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   КОМПАКТНЫЙ МОНИТОРИНГ
   ============================================ */

/* ============================================
   СИСТЕМНЫЕ МЕТРИКИ В ФУТЕРЕ
   ============================================ */

.system-metrics-footer {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
}

.metrics-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--primary-color);  /* Плоский цвет без градиента */
    color: var(--brand-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(2, 59, 105, 0.2);
    position: relative;
}

.metrics-toggle-btn:hover {
    background: var(--primary-hover);  /* Плоский цвет */
    transform: none;  /* Убираем масштабирование для строгости */
    box-shadow: 0 2px 10px rgba(2, 59, 105, 0.3);
}

/* Иконка меню из трёх полос (гамбургер) */
.icon-metrics {
    display: block;
    width: 20px;
    height: 2px;
    position: relative;
    background-color: var(--brand-white);
    border-radius: 2px;
    transition: all 0.2s ease;
}

.icon-metrics::before,
.icon-metrics::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--brand-white);
    border-radius: 2px;
    transition: all 0.2s ease;
}

/* Верхняя полоса */
.icon-metrics::before {
    top: -6px;
}

/* Нижняя полоса */
.icon-metrics::after {
    bottom: -6px;
}

/* Анимация при наведении */
.metrics-toggle-btn:hover .icon-metrics::before {
    top: -5px;
}

.metrics-toggle-btn:hover .icon-metrics::after {
    bottom: -5px;
}

.compact-metrics {
    display: flex;
    gap: 8px;
    background: var(--brand-white);
    backdrop-filter: blur(10px);
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--border-color);
}

.metric-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}

.metric-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   МОДАЛЬНЫЕ ОКНА
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 59, 105, 0.6);  /* Плоский цвет без градиента */
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--brand-white);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 38, 64, 0.25);
    max-width: 650px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    border: 2px solid var(--border-color);
}

.settings-modal {
    max-width: 700px;
}

.audit-modal {
    max-width: 1200px;
    width: 95%;
}

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

.modal-header {
    padding: 24px 32px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--brand-white);
}

.modal-header h2 {
    font-size: var(--font-size-h2);
    font-weight: 600;
    font-family: var(--font-primary);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: var(--accent-color);  /* Плоский цвет без градиента */
    border-radius: 2px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(2, 59, 105, 0.08);
    color: var(--accent-color);
    transform: rotate(90deg);
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
    background: var(--brand-white);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--brand-white);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--brand-white);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(2, 59, 105, 0.1);
}

.form-input[type="file"] {
    padding: 8px;
    cursor: pointer;
}

.settings-section {
    margin-bottom: 36px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-section h3 {
    font-size: var(--font-size-h3);
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(2, 59, 105, 0.1);
}

.setting-group {
    margin-bottom: 20px;
}

.setting-label {
    display: block;
    font-size: var(--font-size-small);
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-family: var(--font-primary);
}

.setting-label span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.model-select,
.text-input,
.file-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: var(--font-size-small);
    font-family: var(--font-primary);
    background: var(--brand-white);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
    font-weight: 400;
}

.model-select:hover,
.text-input:hover,
.file-input:hover {
    border-color: rgba(2, 59, 105, 0.3);
}

.model-select:focus,
.text-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(2, 59, 105, 0.1);
    background: var(--brand-white);
}

/* Стили для моделей из плагинов */
.model-select option.model-from-plugin {
    background: linear-gradient(135deg, rgba(2, 59, 105, 0.05) 0%, rgba(70, 125, 157, 0.05) 100%);
    color: var(--primary-color);
    font-weight: 500;
    padding: 8px 12px;
}

.model-select option.model-from-plugin:hover {
    background: linear-gradient(135deg, rgba(2, 59, 105, 0.1) 0%, rgba(70, 125, 157, 0.1) 100%);
}

/* Визуальное выделение для выбранных моделей из плагинов */
.model-select option.model-from-plugin:checked {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: var(--brand-white);
    font-weight: 600;
}

.file-input {
    padding: 10px 14px;
    cursor: pointer;
    border-style: dashed;
}

.file-input:hover {
    background: rgba(2, 59, 105, 0.02);
    border-color: var(--primary-color);
}

.setting-info {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-primary);
    line-height: 1.5;
    padding: 8px 12px;
    background: rgba(2, 59, 105, 0.03);
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
    justify-content: flex-end;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);  /* Плоский цвет без градиента */
    color: var(--brand-white);
    font-weight: 600;
    border: 2px solid var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-hover);  /* Плоский цвет */
    border-color: var(--primary-hover);
    box-shadow: 0 2px 4px rgba(2, 59, 105, 0.25);
}

.btn-secondary {
    background: var(--brand-white);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    font-weight: 500;
}

.btn-secondary:hover {
    background: rgba(2, 59, 105, 0.05);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(2, 59, 105, 0.15);
}

.btn-info {
    background: var(--primary-color);  /* Синий цвет вместо красного */
    color: var(--brand-white);
    font-weight: 600;
    border: 2px solid var(--primary-color);
}

.btn-info:hover {
    background: var(--primary-hover);  /* Синий цвет при наведении */
    border-color: var(--primary-hover);
    box-shadow: 0 2px 4px rgba(2, 59, 105, 0.25);
}

.btn-danger {
    background: var(--primary-color);  /* Синий цвет вместо красного */
    color: var(--brand-white);
    font-weight: 600;
    border: 2px solid var(--primary-color);
}

.btn-danger:hover {
    background: var(--primary-hover);  /* Синий цвет при наведении */
    border-color: var(--primary-hover);
    box-shadow: 0 2px 4px rgba(2, 59, 105, 0.35);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

.status-box {
    padding: 14px 18px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: var(--font-size-small);
    font-family: var(--font-primary);
    font-weight: 500;
    border: 2px solid;
}

.status-box.success {
    background: rgba(34, 197, 94, 0.08);
    color: #16a34a;
    border-color: rgba(34, 197, 94, 0.3);
}

.status-box.error {
    background: rgba(220, 38, 38, 0.08);
    color: var(--accent-color);
    border-color: rgba(220, 38, 38, 0.3);
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 200;
        transition: left 0.3s ease;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .chat-container {
        width: 100%;
    }
    
    .messages-list {
        max-width: 100%;
    }
    
    .input-container {
        max-width: 100%;
    }
    
    .system-metrics-footer {
        bottom: 0;
        right: 0;
        padding: 8px;
    }
    
    .compact-metrics {
        flex-direction: column;
        gap: 4px;
    }
    
    .tabs-container {
        padding: 0 16px;
    }
    
    .tab-btn {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .settings-content {
        padding: 20px;
    }
    
    .firstbit-progress-text {
        font-size: 36px;
    }
}

/* ============================================
   ПРОКРУТКА
   ============================================ */

.sidebar-content::-webkit-scrollbar,
.messages-area::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.settings-content::-webkit-scrollbar {
    width: 10px;
}

.sidebar-content::-webkit-scrollbar-track,
.messages-area::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.settings-content::-webkit-scrollbar-track {
    background: rgba(2, 59, 105, 0.05);
    border-radius: 5px;
}

.sidebar-content::-webkit-scrollbar-thumb,
.messages-area::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.settings-content::-webkit-scrollbar-thumb {
    background: rgba(2, 59, 105, 0.3);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.messages-area::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.settings-content::-webkit-scrollbar-thumb:hover {
    background: rgba(2, 59, 105, 0.5);
    background-clip: padding-box;
}

/* ============================================
   ИНФОРМАЦИЯ О КОЛЛЕКЦИИ
   ============================================ */

.collection-info {
    background: rgba(2, 59, 105, 0.05);
    border: 2px solid rgba(2, 59, 105, 0.15);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
}

.collection-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.collection-info-item:last-child {
    margin-bottom: 0;
}

.collection-info-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.collection-info-value {
    font-size: var(--font-size-body);
    color: var(--primary-color);
    font-weight: 600;
}

.collection-info-error {
    color: var(--danger-color);
    font-size: 14px;
    text-align: center;
}

.collection-info-divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 0;
}

.collection-info-subtitle {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
    margin-top: 4px;
}

.collection-info-subitem {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-left: 12px;
}

.collection-info-subitem:last-child {
    margin-bottom: 0;
}

.collection-info-sublabel {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.collection-info-subvalue {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   МОДАЛЬНОЕ ОКНО ОБРАБОТКИ
   ============================================ */

.processing-modal {
    max-width: 500px;
}

.processing-content {
    text-align: center;
    padding: 20px;
}

.loading-indicator-large {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.loading-indicator-large .loading-dot {
    width: 12px;
    height: 12px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: loading-pulse 1.4s ease-in-out infinite;
}

.loading-indicator-large .loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-indicator-large .loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-indicator-large .loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading-pulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.processing-message {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.processing-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Строка статуса с вращающейся картинкой */
.processing-status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
    padding: 16px;
    background: rgba(2, 59, 105, 0.03);
    border-radius: 8px;
}

.processing-spinner {
    width: 60px !important;
    height: 60px !important;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.processing-current-action {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
}

/* Стили для текста статуса обработки */
.processing-current-action {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    text-align: left;
    max-width: 350px;
    line-height: 1.4;
}

/* ============================================
   ПРОГРЕСС-БАР "ПЕРВЫЙ .БИТ"
   ============================================ */

.firstbit-progress-container {
    margin: 30px 0;
    padding: 40px 20px;
    background: var(--blue-zodiac); /* Темно-синий фон для контраста с белым текстом */
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.firstbit-progress-text {
    text-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.firstbit-logo-wrapper {
    position: relative;
    display: inline-block;
    width: auto;
    height: auto;
}

.firstbit-logo {
    display: block;
    height: 40px; /* Уменьшенная высота логотипа */
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.firstbit-logo-white {
    position: relative;
    z-index: 0;
}

.firstbit-logo-black {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    clip-path: inset(0 100% 0 0); /* Изначально полностью скрыт справа */
    transition: clip-path 0.5s ease;
    width: 100%; /* Обеспечиваем одинаковую ширину с белым логотипом */
    height: 100%; /* Обеспечиваем одинаковую высоту с белым логотипом */
}

.firstbit-text-fill {
    position: relative;
    display: inline-block;
    color: #ffffff; /* Изначально белый */
    transition: color 0.5s ease;
    overflow: hidden;
    white-space: nowrap;
    margin-right: 4px; /* Сокращаем расстояние между словами */
}

/* Эффект заполнения черным цветом поверх белого */
.firstbit-text-fill::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    color: #000000; /* Черный цвет для заполнения */
    clip-path: var(--clip-path-1, inset(0 100% 0 0));
    transition: clip-path 0.5s ease;
    z-index: 1;
    pointer-events: none;
    white-space: nowrap;
}

.firstbit-with-dot::after {
    clip-path: var(--clip-path-2, inset(0 100% 0 0));
}

.firstbit-with-dot {
    position: relative;
    padding-left: 14px; /* Место для точки перед текстом */
}

/* Косая черта в букве Б (как в оригинальном логотипе) */
.firstbit-with-dot::before {
    content: '';
    position: absolute;
    bottom: 0.15em;
    left: 0.05em;
    width: 0.35em;
    height: 2px;
    background: var(--slash-color, #ffffff);
    transform: rotate(-35deg);
    transform-origin: bottom left;
    z-index: 2;
    transition: background 0.5s ease;
}

.firstbit-letter-b {
    position: relative;
    display: inline-block;
}

.firstbit-dot {
    position: absolute;
    left: 12px;
    top: 0.8em;
    width: 10px;
    height: 10px;
    border-radius: 0;
    background: #ffffff;
    border: 2px solid #ffffff;
    margin: 0;
    transition: all 0.5s ease;
    box-sizing: border-box;
}

.firstbit-dot.filled {
    background: #ff69b4; /* Розовый цвет из логотипа Первого бита */
    border-color: #000000; /* Черная обводка */
}

/* Косая черта в букве Б - альтернативный подход через псевдоэлемент на контейнере */
.firstbit-with-dot::before {
    content: '';
    position: absolute;
    bottom: 0.2em;
    left: 0.05em;
    width: 0.4em;
    height: 2px;
    background: #ffffff;
    transform: rotate(-35deg);
    transform-origin: bottom left;
    z-index: 2;
    transition: background 0.5s ease;
}

/* При заполнении черным цветом */
.firstbit-text-fill::after ~ .firstbit-with-dot::before,
.firstbit-text-fill[style*="clip-path"] ~ .firstbit-with-dot::before {
    background: #000000;
}

.processing-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 24px;
    margin: 16px 0;
    padding: 12px 16px;
    background: rgba(2, 59, 105, 0.05);
    border-radius: 8px;
}

.threads-header {
    margin-top: 8px;
    font-weight: 600;
    color: #333;
}
.threads-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}
.thread-row {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr 1fr;
    gap: 8px;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 13px;
}
.thread-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.thread-file {
    font-weight: 600;
}
.thread-error {
    grid-column: 1 / -1;
    color: #b91c1c;
    font-size: 12px;
}

.processing-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    font-family: var(--font-primary);
}

.stat-separator {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 1px;
    margin: 0 4px;
}

.prompt-textarea {
    min-height: 200px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
}

/* ============================================
   СТИЛИ ДЛЯ КАТАЛОГОВ
   ============================================ */

.catalog-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--chat-bg);
}

.catalog-header {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--brand-white);
    flex-shrink: 0;
    min-height: 64px;
}

.catalog-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.catalog-left-panel {
    width: 350px;
    background: var(--brand-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.catalog-projects-section,
.catalog-tree-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.catalog-projects-section {
    border-bottom: 1px solid var(--border-color);
    max-height: 40%;
}

.catalog-tree-section {
    flex: 1;
    min-height: 0;
}

.catalog-section-header {
    padding: 16px 24px;
    background: rgba(2, 59, 105, 0.05);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.catalog-section-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.catalog-right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    background: var(--chat-bg);
    gap: 12px;
}

.catalog-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

.catalog-actions-left,
.catalog-actions-right {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(2, 59, 105, 0.4) rgba(2, 59, 105, 0.1);
    -webkit-overflow-scrolling: touch;
    min-width: 0;
    position: relative;
    padding-bottom: 2px;
    margin-bottom: -2px;
}

.catalog-actions-left::-webkit-scrollbar,
.catalog-actions-right::-webkit-scrollbar {
    height: 8px;
}

.catalog-actions-left::-webkit-scrollbar-track,
.catalog-actions-right::-webkit-scrollbar-track {
    background: rgba(2, 59, 105, 0.05);
    border-radius: 4px;
    margin: 0 2px;
}

.catalog-actions-left::-webkit-scrollbar-thumb,
.catalog-actions-right::-webkit-scrollbar-thumb {
    background: rgba(2, 59, 105, 0.4);
    border-radius: 4px;
    min-width: 20px;
}

.catalog-actions-left::-webkit-scrollbar-thumb:hover,
.catalog-actions-right::-webkit-scrollbar-thumb:hover {
    background: rgba(2, 59, 105, 0.6);
}

.catalog-actions-left {
    justify-content: flex-start;
    margin-left: 0;
    flex: 0 1 35%;
    max-width: 35%;
}

.catalog-actions-right {
    justify-content: flex-end;
    flex: 0 1 65%;
    max-width: 65%;
}

/* Обеспечиваем единообразное выравнивание кнопок */
.catalog-actions-bar .btn {
    height: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: fit-content;
}

.catalog-right-panel-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

.projects-list {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.project-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    transition: background 0.2s;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.project-item-content {
    flex: 1;
    cursor: pointer;
}

.project-item:hover {
    background: rgba(2, 59, 105, 0.05);
}

.project-item.active {
    background: rgba(2, 59, 105, 0.1);
    border-color: var(--primary-color);
}

.project-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.project-item:hover .project-item-actions {
    opacity: 1;
}

.project-edit-btn,
.project-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}

.project-edit-btn:hover {
    background: rgba(2, 59, 105, 0.1);
    color: var(--primary-color);
}

.project-delete-btn:hover {
    background: rgba(234, 45, 40, 0.1);
    color: var(--danger-color);
}

.project-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.project-item-description {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.catalog-files-header {
    padding: 16px 24px;
    background: var(--brand-white);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.catalog-files-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.catalog-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.breadcrumb-item:last-child {
    color: var(--text-primary);
    font-weight: 600;
}

.breadcrumb-separator {
    color: var(--text-muted);
}

.breadcrumb-link {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.catalog-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
}

.catalog-files-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;
}

.catalog-info-header {
    padding: 12px 16px;
    background: rgba(2, 59, 105, 0.05);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.catalog-info-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.catalog-info-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    min-height: 0;
    background: var(--brand-white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.catalog-info-block {
    display: none !important; /* Панель информации о папке скрыта */
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    background: var(--brand-white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px 12px;
    max-height: 50vh;
    overflow: auto;
    flex-shrink: 0;
}

/* Файлы на модерации */
.file-pending-moderation {
    background-color: rgba(255, 165, 0, 0.1);
    border-left: 3px solid #FFA500;
}

.moderation-badge {
    margin-right: 5px;
    opacity: 0.7;
    font-size: 14px;
}

/* Панель модерации в превью */
.file-moderation-panel {
    padding: 20px;
    background: var(--background-secondary);
    border: 2px solid #FFA500;
    border-radius: 8px;
    text-align: center;
}

.file-moderation-panel h4 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 18px;
}

.file-moderation-panel p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
}

.moderation-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-approve, .btn-reject {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-approve {
    background: #10b981;
    color: white;
}

.btn-approve:hover {
    background: #059669;
}

.btn-reject {
    background: #ef4444;
    color: white;
}

.btn-reject:hover {
    background: #dc2626;
}

/* Превью файла */
.catalog-preview {
    background: var(--brand-white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.catalog-preview-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.catalog-preview-body {
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.catalog-preview-content {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-mono, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace);
    font-size: 13px;
    color: var(--text-primary);
    margin: 0;
}

.catalog-preview-content.html-content {
    white-space: normal;
    font-family: var(--font-primary, 'Inter', system-ui, -apple-system, sans-serif);
    line-height: 1.5;
    overflow-x: auto;
    padding: 16px;
}

.catalog-preview-content.html-content * {
    max-width: 100%;
}

.catalog-preview-content.html-content img {
    max-width: 100%;
    height: auto;
}

.catalog-preview-content.html-content table {
    width: 100%;
    border-collapse: collapse;
}

.catalog-preview-content.html-content pre {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

.empty-catalog-info {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 16px;
}

.catalog-info-section {
    margin-bottom: 24px;
}

.catalog-info-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.catalog-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.catalog-file-preview-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--brand-white);
    transition: all 0.2s ease;
    overflow: hidden;
}

.catalog-file-preview-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(2, 59, 105, 0.1);
    transform: translateY(-1px);
}

.catalog-file-preview-item.selected {
    border-color: var(--primary-color);
    background: rgba(2, 59, 105, 0.05);
    box-shadow: 0 2px 12px rgba(2, 59, 105, 0.15);
}

.catalog-file-preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
}

.catalog-file-preview-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.catalog-file-preview-icon.file-status-processed {
    background-color: #10b981;
}

.catalog-file-preview-icon.file-status-processing {
    background-color: #3b82f6;
}

.catalog-file-preview-icon.file-status-error {
    background-color: #ef4444;
}

.catalog-file-preview-icon.file-status-not-processed {
    background-color: #ef4444;
}

.catalog-file-preview-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.catalog-file-preview-status {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: rgba(2, 59, 105, 0.05);
    border-radius: 4px;
    white-space: nowrap;
}

.info-item {
    display: flex;
    margin-bottom: 12px;
    align-items: flex-start;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 140px;
    margin-right: 12px;
}

.info-value {
    color: var(--text-primary);
    flex: 1;
    word-break: break-word;
}

.info-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(2, 59, 105, 0.03);
    border-radius: 6px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-value {
    font-weight: 600;
    font-size: 14px;
}

.stat-processed {
    color: #10b981;
}

.stat-processing {
    color: #3b82f6;
}

.stat-not-processed {
    color: #666;
}

.stat-error {
    color: #ef4444;
}

.info-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Стили для файлов в дереве */
.catalog-file-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    margin-left: 24px;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: pointer;
    position: relative;
}

.catalog-file-item:hover {
    background: rgba(2, 59, 105, 0.05);
}

.catalog-file-item.selected {
    background: rgba(2, 59, 105, 0.1);
    border-left: 3px solid var(--primary-color);
}

.catalog-file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
    width: 100%;
    justify-content: space-between;
    padding: 4px 0;
}

.catalog-file-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    opacity: 0;
    margin-left: 4px;
}

.catalog-file-item:hover .catalog-file-delete-btn {
    opacity: 1;
}

.catalog-file-delete-btn:hover {
    background: rgba(234, 45, 40, 0.1);
    color: var(--danger-color);
}

.catalog-file-icon {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.catalog-file-name {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-catalog-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 16px;
}

.catalog-folder {
    display: flex;
    flex-direction: column;
    margin: 2px 0;
    user-select: none;
}

.catalog-folder-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: pointer;
}

.catalog-folder-item:hover {
    background: rgba(2, 59, 105, 0.05);
}

.catalog-folder-item.selected {
    background: rgba(2, 59, 105, 0.1);
    border-left: 3px solid var(--primary-color);
}

.catalog-file {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin: 4px 0;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;
    border: 1px solid var(--border-color);
    background: var(--brand-white);
}

.catalog-file:hover {
    background: rgba(2, 59, 105, 0.05);
    border-color: var(--primary-color);
}

.catalog-folder-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.catalog-folder-main {
    display: flex;
    align-items: center;
    flex: 1;
}

.catalog-folder-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.catalog-folder-item:hover .catalog-folder-actions {
    opacity: 1;
}

.catalog-edit-btn,
.catalog-delete-btn,
.catalog-add-folder-btn,
.catalog-add-file-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}

.catalog-edit-btn:hover {
    background: rgba(2, 59, 105, 0.1);
    color: var(--primary-color);
}

.catalog-delete-btn:hover {
    background: rgba(234, 45, 40, 0.1);
    color: var(--danger-color);
}

.catalog-add-folder-btn:hover {
    background: rgba(2, 59, 105, 0.1);
    color: var(--primary-color);
}

.catalog-add-file-btn:hover {
    background: rgba(2, 59, 105, 0.1);
    color: var(--primary-color);
}

.catalog-root-folder-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    margin: 4px 0;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
}

.catalog-root-folder-item:hover {
    background: rgba(2, 59, 105, 0.05);
}

.catalog-root-folder-item.selected {
    background: rgba(2, 59, 105, 0.1);
    border-left: 3px solid var(--primary-color);
}

.catalog-add-folder-root {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.catalog-add-folder-root .catalog-add-folder-btn {
    opacity: 1;
    padding: 8px 12px;
    background: rgba(2, 59, 105, 0.05);
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    text-align: left;
}

.catalog-add-folder-root .catalog-add-folder-btn:hover {
    background: rgba(2, 59, 105, 0.1);
}

.catalog-folder-icon,
.catalog-file-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.catalog-folder-name,
.catalog-file-name {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.catalog-file-name {
    color: var(--text-secondary);
}

.catalog-folder-children {
    margin-left: 20px;
    border-left: 1px solid var(--border-color);
    padding-left: 8px;
    margin-top: 2px;
    display: none !important;
}

.catalog-folder.expanded .catalog-folder-children {
    display: block !important;
}

/* Убраны псевдоэлементы ::before для иконок папок - используем эмодзи напрямую в HTML */

.catalog-folder-toggle {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.catalog-folder.expanded .catalog-folder-toggle {
    transform: rotate(90deg);
}

.catalog-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.catalog-file-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--brand-white);
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.catalog-file-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(2, 59, 105, 0.1);
    transform: translateY(-2px);
}

.catalog-file-card-icon {
    font-size: 48px;
    margin-bottom: 8px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Убраны стили для file-icon и file-status-icon - используем только точки */

.catalog-file-status-dot {
    width: 12px !important;
    height: 12px !important;
    border-radius: 50% !important;
    flex-shrink: 0;
    margin-left: auto;
    display: block !important;
    min-width: 12px !important;
    min-height: 12px !important;
    border: none !important;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1) !important;
    background-color: transparent !important;
}

.catalog-file-link .catalog-file-status-dot.file-status-processed,
.catalog-file-status-dot.file-status-processed {
    background-color: #10b981 !important;
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.3) !important;
}

.catalog-file-link .catalog-file-status-dot.file-status-processing,
.catalog-file-status-dot.file-status-processing {
    background-color: #3b82f6 !important;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3) !important;
}

.catalog-file-link .catalog-file-status-dot.file-status-error,
.catalog-file-link .catalog-file-status-dot.file-status-not-processed,
.catalog-file-status-dot.file-status-error,
.catalog-file-status-dot.file-status-not-processed {
    background-color: #ef4444 !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3) !important;
}

.catalog-file-card-name {
    font-size: 13px;
    text-align: center;
    word-break: break-word;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.catalog-file-card-path {
    font-size: 11px;
    text-align: center;
    word-break: break-word;
    color: var(--text-secondary);
    opacity: 0.7;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.catalog-file-icon::before {
    content: "📄";
}

/* Стили для ссылок на каталоги в источниках */
.source-item-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 12px;
    margin-bottom: 4px;
}

.source-catalog-link {
    display: none;
}

.catalog-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
    display: inline-block;
}

.catalog-link:hover {
    transform: scale(1.2);
}

/* Стили для форм в модальных окнах */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.text-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--brand-white);
    transition: border-color 0.2s;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.text-input::placeholder {
    color: var(--text-muted);
}

/* Адаптивность для каталогов */
@media (max-width: 768px) {
    .catalog-layout {
        flex-direction: column;
    }
    
    .catalog-left-panel {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .catalog-projects-section {
        max-height: 50%;
    }
    
    .project-item-actions,
    .catalog-folder-actions {
        opacity: 1;
    }
    
    /* Уменьшенные кнопки для маленьких экранов */
    .catalog-actions-bar {
        gap: 12px;
    }
    
    .catalog-actions-left,
    .catalog-actions-right {
        gap: 6px;
    }
    
    .catalog-actions-bar .btn {
        height: 36px;
        min-height: 36px;
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .catalog-header {
        padding: 12px 16px;
    }
    
    .catalog-actions-bar {
        gap: 8px;
    }
    
    .catalog-actions-left,
    .catalog-actions-right {
        gap: 4px;
    }
    
    .catalog-actions-bar .btn {
        height: 32px;
        min-height: 32px;
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ============================================
   КАСТОМНЫЕ МОДАЛЬНЫЕ ОКНА
   ============================================ */

.custom-confirm-modal,
.custom-alert-modal {
    max-width: 500px;
    width: 90%;
}

.custom-confirm-modal .modal-header,
.custom-alert-modal .modal-header {
    background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-light) 100%);
    color: white;
    padding: 20px 24px;
    border-radius: 8px 8px 0 0;
}

.custom-confirm-modal .modal-header h3,
.custom-alert-modal .modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: white;
}

.custom-confirm-modal .modal-body,
.custom-alert-modal .modal-body {
    padding: 24px;
    background: white;
}

.custom-confirm-modal .modal-footer,
.custom-alert-modal .modal-footer {
    padding: 16px 24px;
    background: var(--brand-beige);
    border-radius: 0 0 8px 8px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.custom-confirm-modal .modal-footer button,
.custom-alert-modal .modal-footer button {
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.custom-confirm-modal .btn-secondary {
    background: #e0e0e0;
    color: var(--text-primary);
}

.custom-confirm-modal .btn-secondary:hover {
    background: #d0d0d0;
}

.custom-confirm-modal .btn-danger {
    background: var(--brand-red);
    color: white;
}

.custom-confirm-modal .btn-danger:hover {
    background: var(--brand-red-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(234, 45, 40, 0.3);
}

/* ============================================
   ПЛАГИНЫ
   ============================================ */

.plugins-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    padding: 32px;
    background: var(--chat-bg);
    position: relative;
}


.plugins-header {
    margin-bottom: 32px;
}

.plugins-header h2 {
    font-size: var(--font-size-h2);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    font-family: var(--font-primary);
}

.plugins-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    overflow: visible;
    align-items: start;
    padding-bottom: 0;
    margin-bottom: 0;
}

.plugin-card {
    background: transparent;
    border-radius: 12px;
    perspective: 1000px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible;
    padding-top: 0px;
    padding-bottom: 0px;
    padding-left: 2px;
    padding-right: 2px;
}

.plugin-card-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    border-radius: 12px;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.plugin-card-front,
.plugin-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    background: var(--brand-white);
    display: flex;
    flex-direction: column;
}

.plugin-card-front {
    justify-content: center;
    transform: rotateY(0deg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.plugin-card-back {
    transform: rotateY(180deg);
    pointer-events: none;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Когда карточка перевернута, показываем оборотную сторону */
.plugin-card:hover:not(:has(.plugin-card-controls:hover)) .plugin-card-inner {
    transform: rotateY(180deg);
}

/* Предотвращаем переворачивание при наведении на элементы управления */
.plugin-card:has(.plugin-card-controls:hover) .plugin-card-inner {
    transform: rotateY(0deg);
}

/* Когда карточка перевернута, оборотная сторона становится активной и видимой */
.plugin-card:hover:not(:has(.plugin-card-controls:hover)) .plugin-card-back {
    pointer-events: auto;
    z-index: 3;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
}

/* Предотвращаем переворачивание при наведении на элементы управления - оборотная сторона */
.plugin-card:has(.plugin-card-controls:hover) .plugin-card-back {
    pointer-events: none;
    z-index: 1;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Когда карточка перевернута, лицевая сторона не должна перехватывать клики и должна быть скрыта */
.plugin-card:hover:not(:has(.plugin-card-controls:hover)) .plugin-card-front {
    pointer-events: none;
    z-index: 1;
    opacity: 0;
}

/* Предотвращаем переворачивание при наведении на элементы управления - лицевая сторона */
.plugin-card:has(.plugin-card-controls:hover) .plugin-card-front {
    pointer-events: auto;
    z-index: 2;
    opacity: 1;
}


.plugin-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.plugin-card:not(:hover) {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.plugin-card-name-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.5) 50%, transparent 100%);
    color: var(--brand-white);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    padding: 16px 12px 12px 12px;
    line-height: 1.3;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}


.plugin-card-image {
    position: relative;
    width: 100%;
    flex: 1;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(2, 59, 105, 0.1) 0%, rgba(2, 59, 105, 0.05) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.plugin-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.plugin-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 59, 105, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.plugin-card:hover .plugin-card-overlay {
    opacity: 1;
}

.plugin-toggle,
.plugin-settings {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-primary);
}

.plugin-toggle {
    background: var(--brand-white);
    color: var(--primary-color);
}

.plugin-toggle:hover {
    background: rgba(255, 255, 255, 0.9);
}

.plugin-settings {
    background: transparent;
    color: var(--brand-white);
    border: 2px solid var(--brand-white);
}

.plugin-settings:hover {
    background: rgba(255, 255, 255, 0.1);
}

.plugin-card-content {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}

.plugin-card-back-content {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    position: relative;
    z-index: 1;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
}

.plugin-card-back-content::-webkit-scrollbar {
    width: 6px;
}

.plugin-card-back-content::-webkit-scrollbar-track {
    background: transparent;
}

.plugin-card-back-content::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.plugin-card-back-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

.plugin-card-back-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    font-family: var(--font-primary);
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
}

.plugin-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
    flex-shrink: 0;
    flex-grow: 0;
    min-height: auto;
    max-height: none;
    overflow: visible;
}

.plugin-card-back-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
    flex-shrink: 0;
}

.plugin-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.plugin-info-item:last-child {
    border-bottom: none;
}

/* Переключатель в конце оборотной стороны карточки */
.plugin-card-back-content .plugin-toggle-switch {
    margin-top: 20px;
    align-self: flex-start;
}

.plugin-info-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.plugin-info-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
}

.plugin-info-value.status-enabled {
    color: var(--primary-color);
}

.plugin-info-value.status-disabled {
    color: var(--text-muted);
}

.plugin-category-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(2, 59, 105, 0.1);
    color: var(--primary-color);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plugin-card.enabled {
    border-color: var(--primary-color);
    border-width: 2px;
    padding-top: 0;
    padding-bottom: 0;
}

/* Элементы управления в верхнем правом углу карточки */
.plugin-card-controls {
    position: absolute;
    top: -10px;
    right: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 100;
    width: 24px;
    pointer-events: auto;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
}

/* Toggle switch для включения/отключения плагина */
.plugin-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
    pointer-events: auto;
}

.plugin-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.plugin-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(16, 53, 85, 0.2);
    transition: 0.3s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.plugin-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--brand-white);
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.plugin-toggle-switch input:checked + .plugin-toggle-slider {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.plugin-toggle-switch input:checked + .plugin-toggle-slider:before {
    transform: translateX(20px);
}

.plugin-toggle-switch:hover .plugin-toggle-slider {
    box-shadow: 0 0 0 2px rgba(2, 59, 105, 0.1);
}

/* Кнопка удаления плагина */
.plugin-delete-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--brand-white);
    color: var(--text-secondary);
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.plugin-delete-btn:hover {
    background: #ef4444;
    color: var(--brand-white);
    border-color: #ef4444;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.plugin-delete-btn:active {
    transform: scale(0.95);
}

.plugin-card.enabled .plugin-category-badge {
    background: var(--primary-color);
    color: var(--brand-white);
}

.plugin-card-add {
    background: var(--brand-white);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-direction: column;
    gap: 12px;
    color: var(--text-secondary);
}

.plugin-card-add:hover {
    border-color: var(--primary-color);
    background: rgba(2, 59, 105, 0.02);
    color: var(--primary-color);
}

.plugin-card-add-icon {
    font-size: 48px;
    font-weight: 300;
    line-height: 1;
}

.plugin-card-add-text {
    font-size: 16px;
    font-weight: 500;
}

/* Модальное окно плагина */
.plugin-modal,
.plugin-settings-modal {
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-primary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-primary);
    color: var(--text-primary);
    background: var(--brand-white);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(2, 59, 105, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.password-input-wrapper {
    position: relative;
    width: 100%;
}

.password-input-wrapper .form-input {
    padding-right: 45px;
}

.password-toggle-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 8px;
    width: 28px;
    height: 28px;
    color: var(--text-secondary);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.password-toggle-btn:hover {
    color: var(--primary-color);
}

.password-toggle-btn:focus {
    outline: none;
    color: var(--primary-color);
}

.password-toggle-icon {
    user-select: none;
    pointer-events: none;
    width: 20px;
    height: 20px;
    display: inline-block;
    position: relative;
}

.password-toggle-icon img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Адаптивность для плагинов */
@media (max-width: 768px) {
    .plugins-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 16px;
    }
    
    .plugins-content {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .plugins-grid {
        grid-template-columns: 1fr;
    }
}

.custom-alert-modal .btn-primary {
    background: var(--brand-blue);
    color: white;
    min-width: 120px;
}

.custom-alert-modal .btn-primary:hover {
    background: var(--brand-blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 59, 105, 0.3);
}

/* Анимация появления */
.custom-confirm-modal,
.custom-alert-modal {
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   ЗАГРУЗКА ZIP-ФАЙЛОВ ПЛАГИНОВ
   ============================================ */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--brand-white);
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(2, 59, 105, 0.02);
}

.file-upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(2, 59, 105, 0.05);
    border-style: solid;
}

.file-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.file-upload-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.file-upload-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-upload-main-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.file-upload-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--brand-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 12px;
}

.file-info span {
    font-size: 14px;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-remove-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: 12px;
}

.file-remove-btn:hover {
    background: rgba(234, 45, 40, 0.1);
    color: var(--accent-color);
}

.upload-progress {
    margin-top: 16px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(2, 59, 105, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    display: block;
}

/* ============================================
   МОДАЛЬНОЕ ОКНО ЛОГИНА
   ============================================ */

.login-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.login-modal-content {
    background: var(--bg-primary, #ffffff);
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-modal-header {
    margin-bottom: 24px;
    text-align: center;
}

.login-modal-header h2 {
    margin: 0;
    color: var(--text-primary, #1a1a1a);
    font-size: 24px;
    font-weight: 600;
}

.login-modal-body .form-group {
    margin-bottom: 20px;
}

.login-modal-body label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary, #1a1a1a);
    font-weight: 500;
}

.login-modal-body input[type="text"],
.login-modal-body input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
}

.login-modal-body input[type="text"]:focus,
.login-modal-body input[type="password"]:focus {
    outline: none;
    border-color: var(--brand-blue, #3b82f6);
}

.login-modal-body .btn {
    width: 100%;
    padding: 12px;
    background: var(--brand-blue, #3b82f6);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.login-modal-body .btn:hover {
    background: var(--brand-blue-dark, #2563eb);
}

.login-modal-body .error-message {
    color: #ef4444;
    font-size: 14px;
    margin-top: 8px;
    padding: 8px;
    background: #fee2e2;
    border-radius: 4px;
}

/* ============================================
   МОДЕРАЦИЯ ФАЙЛОВ
   ============================================ */

/* Стили модерации удалены - модерация теперь осуществляется через вкладку Каталогов */

.btn-success {
    background: var(--success-color, #10b981);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-success:hover {
    background: var(--success-color-dark, #059669);
}

.btn-danger {
    background: var(--danger-color, #ef4444);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-danger:hover {
    background: var(--danger-color-dark, #dc2626);
}

/* ============================================
   СТИЛИ ДЛЯ ВКЛАДКИ ПОЛЬЗОВАТЕЛЕЙ
   ============================================ */

.users-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.users-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.users-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.user-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
}

.user-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 8px;
}

.user-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    align-items: center;
}

.user-role {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-admin {
    background: var(--accent-color, #ea2d28);
    color: white;
}

.role-user {
    background: var(--primary-color-light, #467d9d);
    color: white;
}

.user-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: var(--success-color, #10b981);
    color: white;
}

.status-inactive {
    background: var(--text-secondary, #666);
    color: white;
}

.user-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.user-actions {
    display: flex;
    gap: 12px;
    margin-left: 20px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Стили для выбора аватара */
.avatar-selector {
    margin-top: 8px;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.avatar-item {
    width: 80px;
    height: 80px;
    border: 2px solid var(--border-color, #ddd);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s;
    background: var(--bg-secondary, #f5f5f5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-item:hover {
    border-color: var(--primary-color, #023b69);
    transform: scale(1.05);
}

.avatar-item.selected {
    border-color: var(--primary-color, #023b69);
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(2, 59, 105, 0.2);
}

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

/* Стили для отображения пользователей с аватарами */
.user-avatar-name {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.user-avatar-small {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color, #ddd);
}

.user-name-block {
    flex: 1;
}

.user-username {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin-top: 2px;
}

.user-email,
.user-phone {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin-right: 12px;
}

/* ==================== Стили для внешних пользователей ==================== */

.external-users-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid var(--border-color, #ddd);
}

.external-users-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.external-users-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary, #333);
}

.platform-filter {
    padding: 8px 16px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #333);
    font-size: 14px;
    cursor: pointer;
}

.external-users-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.external-user-item {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
}

.external-user-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.external-user-info {
    flex: 1;
}

.external-user-platform {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin-bottom: 8px;
}

.external-user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin-bottom: 4px;
}

.external-user-username {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin-bottom: 8px;
}

.external-user-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 12px;
}

.external-user-status.status-approved {
    background: #d4edda;
    color: #155724;
}

.external-user-status.status-pending {
    background: #fff3cd;
    color: #856404;
}

.external-user-date {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin-top: 8px;
}

.external-user-actions {
    display: flex;
    gap: 8px;
}

/* ==================== Стили для связей пользователей ==================== */

.user-links-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid var(--border-color, #ddd);
}

.user-links-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.user-links-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary, #333);
}

.user-links-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.user-link-item {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s;
}

.user-link-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-link-info {
    flex: 1;
}

.user-link-pair {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.user-link-user {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary, #333);
}

.user-link-connector {
    font-size: 18px;
    color: var(--text-secondary, #666);
}

.user-link-date {
    font-size: 13px;
    color: var(--text-secondary, #666);
    margin-top: 4px;
}

.user-link-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   СТИЛИ ДЛЯ МОДАЛЬНОГО ОКНА АУДИТА
   ============================================ */

.audit-modal {
    max-width: 1200px;
    width: 95%;
}

.audit-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--brand-beige);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group:last-child {
    flex-direction: row;
    align-items: flex-end;
    justify-content: flex-end;
    grid-column: 1 / -1;
}

.filter-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.filter-select {
    min-width: 150px;
}

.audit-table-container {
    position: relative;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--brand-white);
}

.audit-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.audit-table-wrapper {
    overflow-x: auto;
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.audit-table thead {
    position: sticky;
    top: 0;
    background: var(--brand-blue);
    color: var(--text-primary-on-blue);
    z-index: 5;
}

.audit-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--brand-blue-dark);
}

.audit-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.audit-table tbody tr {
    transition: background-color 0.2s ease;
}

.audit-table tbody tr:hover {
    background: var(--brand-beige);
}

.audit-table tbody tr:last-child td {
    border-bottom: none;
}

.audit-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.audit-status.success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.audit-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.audit-status.denied {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.audit-action {
    display: inline-block;
    padding: 4px 8px;
    background: var(--brand-blue-light);
    color: var(--text-primary-on-blue);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.audit-details-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.audit-details-btn:hover {
    background: var(--brand-blue);
    color: var(--text-primary-on-blue);
    border-color: var(--brand-blue);
}

.audit-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.audit-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 16px;
    background: var(--brand-beige);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.audit-page-info {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.audit-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.audit-details-popup {
    position: absolute;
    background: var(--brand-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-width: 400px;
    font-size: 12px;
    color: var(--text-primary);
}

.audit-details-popup pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

/* ============================================
   STREAMING ANIMATIONS
   ============================================ */

.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 15px;
    background-color: var(--brand-blue);
    margin-left: 4px;
    vertical-align: middle;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.message-text p:last-child {
    display: inline;
}

.message-text {
    line-height: 1.6;
}

/* Анимация для потокового текста */
.message-text .streaming-chunk {
    animation: fadeIn 0.1s ease-in;
}

/* Анимация "три точки" при ожидании */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(2, 59, 105, 0.08);
    border-radius: 16px;
    width: fit-content;
    margin: 8px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid rgba(2, 59, 105, 0.1);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: var(--brand-blue);
    border-radius: 50%;
    animation: typing-bounce 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message-text.streaming {
    position: relative;
}

/* Стили для статусных сообщений во время стриминга */
.streaming-status {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-style: italic;
}

.streaming-status .spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(2, 59, 105, 0.1);
    border-top: 2px solid var(--brand-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   REASONING BLOCK (AI THINKING)
   ============================================ */

.message-reasoning {
    margin-bottom: 12px;
    border-radius: 8px;
    background-color: rgba(2, 59, 105, 0.03);
    border: 1px solid rgba(2, 59, 105, 0.1);
    overflow: hidden;
    transition: all 0.2s ease;
}

.message-reasoning summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    background-color: rgba(2, 59, 105, 0.02);
}

.message-reasoning summary::marker {
    color: var(--brand-blue-light);
}

.message-reasoning summary:hover {
    background-color: rgba(2, 59, 105, 0.05);
    color: var(--brand-blue);
}

.message-reasoning summary::before {
    content: "🧠";
    font-size: 14px;
}

.message-reasoning-content {
    padding: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    font-style: italic;
    border-top: 1px solid rgba(2, 59, 105, 0.05);
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.message-reasoning[open] {
    background-color: rgba(2, 59, 105, 0.05);
    border-color: rgba(2, 59, 105, 0.15);
}

.message-reasoning[open] summary {
    border-bottom: 1px solid rgba(2, 59, 105, 0.05);
    color: var(--brand-blue);
}
