/* Импорт стилей для блока Lead Statistics */
@import url('leads-stats-styles.css');

/* Reset и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.4;
    font-size: 13px;
}

/* Экран входа */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-box {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-box h1 {
    color: #667eea;
    margin-bottom: 6px;
    font-size: 20px;
    font-weight: 700;
}

.login-subtitle {
    color: #6b7280;
    margin-bottom: 20px;
    font-size: 13px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: #374151;
    font-size: 12px;
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.error-message {
    color: #ef4444;
    font-size: 14px;
    margin-top: 8px;
    text-align: center;
    display: none;
}

.error-message.active {
    display: block;
}

/* Кнопки */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    min-height: 28px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 11px;
    min-height: 24px;
}

.btn-full {
    width: 100%;
    min-width: 120px;
}

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

/* Основной дашборд */
.dashboard-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.dashboard-header {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    box-sizing: border-box;
}

.dashboard-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-title h1 {
    color: #1f2937;
    font-size: 16px;
    font-weight: 700;
}

.version {
    background: #667eea;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-weight: 500;
}

.icon {
    font-size: 18px;
}

/* Основной контент */
.dashboard-main {
    flex: 1;
    max-width: 100%;
    margin: 0;
    padding: 8px;
    width: 100%;
    box-sizing: border-box;
}

.screen-section {
    animation: fadeIn 0.3s ease-in-out;
    width: 100%;
    box-sizing: border-box;
}

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

/* Экран выбора агента */
.agent-selection-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 1200px;
    margin: 0 auto;
}

.selection-header {
    text-align: center;
    margin-bottom: 20px;
}

.selection-header h2 {
    color: #1f2937;
    font-size: 20px;
    margin-bottom: 8px;
    font-weight: 700;
}

.selection-header p {
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 0;
}

/* Фильтры на странице выбора агента */
.agent-selection-filters {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.agent-selection-filters .date-filter-container {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* Таблица агентов */
.agents-table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.agents-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.agents-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.agents-table thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agents-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: all 0.2s ease;
    cursor: pointer;
}

.agents-table tbody tr:hover {
    background: #f9fafb;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.agents-table tbody td {
    padding: 14px 16px;
    font-size: 13px;
    color: #374151;
}

.agents-table tbody td:first-child {
    font-weight: 600;
    color: #1f2937;
}

.agents-table .text-center {
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

/* Бейджи для статистики в таблице агентов */
.agent-stat-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.agent-stat-badge.won {
    background: #d1fae5;
    color: #065f46;
}

.agent-stat-badge.lost {
    background: #fee2e2;
    color: #991b1b;
}

.agent-avg-score {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
}

.agent-select-container {
    text-align: left;
    margin-bottom: 24px;
}

.agent-select-container label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: #374151;
    font-size: 12px;
}

.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Экран списка лидов */
.leads-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.header-left h2 {
    color: #1f2937;
    font-size: 16px;
    margin-bottom: 4px;
    font-weight: 700;
}

.agent-stats {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.stat-badge {
    background: #f3f4f6;
    color: #374151;
    padding: clamp(2px, 0.3vw, 4px) clamp(6px, 0.6vw, 12px);
    border-radius: 12px;
    font-size: clamp(10px, 0.8vw, 14px);
    font-weight: 500;
    white-space: nowrap;
}

.agent-criteria-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.criteria-score-badge {
    background: #f3f4f6;
    color: #374151;
    padding: clamp(2px, 0.3vw, 4px) clamp(4px, 0.5vw, 8px);
    border-radius: 10px;
    font-size: clamp(9px, 0.7vw, 13px);
    font-weight: 500;
    border: 1px solid #e5e7eb;
    white-space: nowrap;
}

.criteria-score-badge.high {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.criteria-score-badge.medium {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.criteria-score-badge.low {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.leads-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}

.search-container {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
    max-width: 140px;
}

.compact-filters-group .search-container {
    max-width: 250px;
}

.compact-filters-group .search-container .form-input {
    font-size: 11px;
    padding: 5px 6px;
}

.search-container .btn {
    padding: 6px 8px;
    min-width: 32px;
    flex-shrink: 0;
}

.compact-filters-group .search-container .btn {
    padding: 5px 6px;
    min-width: 28px;
    font-size: 11px;
}

.date-filter-container {
    display: flex;
    flex-direction: row;
    gap: 4px;
    padding: 4px 8px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    align-items: center;
    flex: 0 1 auto;
}

.compact-filters-group .date-filter-container {
    padding: 3px 6px;
    gap: 3px;
}

.compact-filters-group .date-filter-container .btn {
    padding: 3px 6px;
    font-size: 10px;
    min-height: 22px;
}

.date-filter-container > label {
    font-weight: 600;
    font-size: 11px;
    color: #374151;
    white-space: nowrap;
}

.compact-filters-group .date-filter-container > label {
    font-size: 10px;
}

.date-inputs {
    display: flex;
    gap: 4px;
    align-items: center;
}

.compact-filters-group .date-inputs {
    gap: 3px;
}

.date-input-group {
    display: flex;
    flex-direction: row;
    gap: 2px;
    align-items: center;
}

.date-input-group label {
    font-size: 10px;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

.compact-filters-group .date-input-group label {
    font-size: 9px;
}

.date-input {
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 11px;
    min-width: 110px;
    max-width: 130px;
}

.compact-filters-group .date-input {
    padding: 3px 5px;
    font-size: 10px;
    min-width: 95px;
    max-width: 110px;
}

.date-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Timeframe Stats Container */
.timeframe-stats-container {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.compact-filters-group .timeframe-stats-container {
    padding: 2px 4px;
    gap: 2px;
}

.timeframe-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0px 3px;
    background: transparent;
    border-right: 1px solid rgba(102, 126, 234, 0.15);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.timeframe-stat-item:last-child {
    border-right: none;
}

.timeframe-stat-item:hover {
    background: rgba(102, 126, 234, 0.05);
}

.compact-filters-group .timeframe-stat-item {
    padding: 0px 2px;
    gap: 1px;
}

.timeframe-stat-item .stat-icon {
    font-size: 11px;
    line-height: 1;
    opacity: 0.7;
    flex-shrink: 0;
}

.compact-filters-group .timeframe-stat-item .stat-icon {
    font-size: 10px;
}

.timeframe-stat-item .stat-content {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.timeframe-stat-item .stat-label {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
    line-height: 1;
}

.compact-filters-group .timeframe-stat-item .stat-label {
    font-size: 10px;
}

.timeframe-stat-item .stat-value {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
    white-space: nowrap;
}

.compact-filters-group .timeframe-stat-item .stat-value {
    font-size: 10px;
}

@media (max-width: 1200px) {
    .timeframe-stats-container {
        gap: 4px;
        padding: 3px 6px;
    }

    .timeframe-stat-item {
        padding: 2px 4px;
        gap: 2px;
    }

    .timeframe-stat-item .stat-icon {
        font-size: 11px;
    }

    .timeframe-stat-item .stat-label {
        font-size: 8px;
    }

    .timeframe-stat-item .stat-value {
        font-size: 10px;
    }
}

@media (max-width: 768px) {
    .timeframe-stats-container {
        flex-wrap: wrap;
        width: 100%;
    }

    .timeframe-stat-item {
        flex: 1;
        min-width: calc(50% - 2px);
        border-right: none;
        border-bottom: 1px solid rgba(102, 126, 234, 0.15);
    }

    .timeframe-stat-item:nth-child(3),
    .timeframe-stat-item:nth-child(4) {
        border-bottom: none;
    }
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 1 auto;
}

.compact-filters-group .filter-controls {
    gap: 3px;
}

.filter-toggle-container {
    display: flex;
    align-items: center;
    gap: 2px;
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #374151;
    user-select: none;
    padding: 4px 8px;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
}

.compact-filters-group .filter-toggle {
    padding: 3px 6px;
    font-size: 10px;
    gap: 3px;
}

.filter-toggle:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}

.compact-filters-group .btn {
    padding: 5px 8px;
    font-size: 10px;
    min-height: 24px;
}

/* Оптимизация для широких экранов */
@media (min-width: 1400px) {
    .compact-header-filters {
        flex-wrap: nowrap;
    }
    
    .compact-filters-group {
        flex-wrap: nowrap;
    }
}

.filter-toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 32px;
    height: 16px;
    background: #cbd5e1;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.filter-toggle input[type="checkbox"]:checked + .toggle-slider {
    background: #3b82f6;
}

.filter-toggle input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(16px);
}

.toggle-text {
    font-weight: 500;
    color: inherit;
}


.form-input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    transition: border-color 0.3s ease;
    min-width: 90px;
    width: 100%;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

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

.filter-group label {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

/* Таблица лидов */
.leads-table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    overflow-x: visible;
    overflow-y: hidden;
    margin-bottom: 8px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.leads-table-container::after {
    content: none;
}

.data-table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    font-size: clamp(11px, 0.8vw, 15px);
}

.data-table thead {
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: clamp(6px, 0.8vw, 12px) clamp(4px, 0.5vw, 8px);
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    font-size: clamp(10px, 0.75vw, 14px);
    vertical-align: top;
}

/* Сортируемые колонки */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s;
}

.data-table th.sortable:hover {
    background-color: #f3f4f6;
}

.data-table th.sortable::after {
    content: '↕';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #9ca3af;
    opacity: 0.5;
    /* Убеждаемся, что стрелочка не перекрывается с текстом */
    z-index: 1;
}

.data-table th.sortable.asc::after {
    content: '↑';
    color: #3b82f6;
    opacity: 1;
    z-index: 1;
}

.data-table th.sortable.desc::after {
    content: '↓';
    color: #3b82f6;
    opacity: 1;
    z-index: 1;
}

.data-table th.sortable.active {
    background-color: #eff6ff;
    font-weight: 600;
}

/* Основные колонки */
.data-table th:first-child,
.data-table td:first-child {
    min-width: 80px; /* Created Date */
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    min-width: 60px; /* Lead ID */
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    min-width: 80px; /* Lead State */
}

.data-table th:nth-last-child(1),
.data-table td:nth-last-child(1) {
    min-width: 50px; /* Overall Avg */
}

/* Специальные стили для колонок критериев */
.data-table th.criteria-column {
    padding: 6px 4px;
    font-size: clamp(9px, 0.7vw, 13px);
    min-width: 60px;
    text-align: center;
    white-space: pre-line;
    line-height: 1.2;
    word-wrap: break-word;
    hyphens: auto;
    height: auto;
    min-height: 40px;
    /* Добавляем отступ справа для стрелочки сортировки */
    padding-right: 20px;
    /* Принудительный перенос длинных слов */
    word-break: break-word;
    overflow-wrap: break-word;
    /* Центрирование по вертикали */
    vertical-align: middle;
}

.data-table td.criteria-column {
    padding: 6px 4px;
    text-align: center;
    font-size: clamp(11px, 0.9vw, 16px);
    font-weight: 600;
    min-width: 60px;
}

.data-table td {
    padding: clamp(6px, 0.8vw, 12px) clamp(4px, 0.5vw, 8px);
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    line-height: 1.3;
    font-size: clamp(11px, 0.8vw, 15px);
}

.data-table tr:hover {
    background: #f9fafb;
}

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

.data-table code {
    font-size: clamp(10px, 0.75vw, 14px);
}

/* Badge стили */
.badge {
    display: inline-block;
    padding: clamp(2px, 0.3vw, 4px) clamp(4px, 0.5vw, 8px);
    background: #f3f4f6;
    color: #374151;
    border-radius: 4px;
    font-size: clamp(9px, 0.7vw, 13px);
    font-weight: 500;
    white-space: nowrap;
}

/* Цветовая схема оценок (шкала -1 до 10) */
.score-excellent { color: #10b981; font-weight: 600; } /* 8-10 */
.score-good { color: #84cc16; font-weight: 600; }      /* 6-7 */
.score-average { color: #eab308; font-weight: 600; }   /* 4-5 */
.score-below { color: #f97316; font-weight: 600; }     /* 2-3 */
.score-poor { color: #ef4444; font-weight: 600; }      /* 0-1 */
.score-none { color: #6b7280; font-weight: 500; }     /* -1 или null */

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    background: white;
    padding: 6px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    width: 100%;
    box-sizing: border-box;
}

.page-info {
    color: #6b7280;
    font-weight: 500;
    font-size: 10px;
    white-space: nowrap;
}

/* Экран детального анализа лида */
.lead-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    gap: 8px;
}

.header-left h2 {
    color: #1f2937;
    font-size: 16px;
    margin-bottom: 4px;
    font-weight: 700;
}

.lead-breadcrumb {
    color: #6b7280;
    font-size: 11px;
}

.lead-detail-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Новый расширенный заголовок лида */
.lead-detail-header-new {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.lead-header-main {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.lead-title {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    line-height: 1.2;
}

.lead-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.lead-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7280;
}

.meta-icon {
    font-size: 14px;
}

.meta-label {
    font-weight: 600;
    color: #9ca3af;
}

.meta-value {
    font-weight: 600;
    color: #1f2937;
}

.meta-badge {
    padding: 4px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.lead-actions-section {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.btn-bitrix {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-bitrix:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

.btn-timeline {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-timeline:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.btn-back {
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-back:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 16px;
}

.btn-text {
    white-space: nowrap;
}

.lead-header-score {
    display: flex;
    align-items: center;
}

.score-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 2px solid #e2e8f0;
}

.score-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.score-value {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

/* Карточки сводки */
.lead-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.summary-card {
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-icon {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 8px;
    flex-shrink: 0;
}

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

.card-label {
    color: #6b7280;
    font-size: 10px;
    margin-bottom: 2px;
    font-weight: 500;
    line-height: 1.2;
}

.card-value {
    color: #1f2937;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

/* Блок дополнительной статистики лида */
.lead-stats-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.lead-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.lead-stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.lead-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.lead-stat-card .stat-icon {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

.lead-stat-card .stat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lead-stat-card .stat-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.lead-stat-card .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.2;
}

.lead-stat-card .stat-subvalue {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .lead-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Timeline панель */
.timeline-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 12px;
    overflow: hidden;
}

.timeline-header {
    padding: 8px 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.timeline-header h3 {
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
}

.timeline-container {
    padding: 6px;
    max-height: 300px;
    overflow-y: auto;
}

/* Компактные однострочные события таймлайна */
.timeline-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    margin-bottom: 1px;
    background: white;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    scroll-margin-top: 10px;
}

.timeline-row:target {
    background-color: #fef3c7;
    animation: highlight-fade 2s ease-out;
}

@keyframes highlight-fade {
    0% { background-color: #fef3c7; }
    100% { background-color: white; }
}

.timeline-row:hover {
    background-color: #f9fafb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Развернутое состояние */
.timeline-row.expanded {
    flex-wrap: wrap;
    align-items: flex-start;
}

.timeline-row.expanded .timeline-row-text {
    flex-basis: 100%;
    white-space: normal;
    padding-left: 48px;
    margin-top: 4px;
}

.timeline-row-number {
    font-size: 10px;
    color: #9ca3af;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    flex-shrink: 0;
    min-width: 24px;
    text-align: right;
}

.timeline-row-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.timeline-row-time {
    font-size: 11px;
    color: #6b7280;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    flex-shrink: 0;
    min-width: 130px;
}

.timeline-row-label {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.label-blue {
    background-color: #dbeafe;
    color: #1e40af;
}

.label-purple {
    background-color: #e9d5ff;
    color: #7c3aed;
}

.label-green {
    background-color: #d1fae5;
    color: #047857;
}

.label-orange {
    background-color: #fed7aa;
    color: #c2410c;
}

.label-gray {
    background-color: #e5e7eb;
    color: #374151;
}

.timeline-row-text {
    flex: 1;
    font-size: 12px;
    line-height: 1.3;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.timeline-row-text.expandable {
    cursor: pointer;
}

.timeline-expand-btn {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    padding: 0;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 3px;
    color: #6b7280;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-expand-btn:hover {
    background: #e5e7eb;
    color: #374151;
    border-color: #d1d5db;
}

/* Цветовое кодирование для разных типов событий */
.timeline-row-message-client {
    border-left-color: #3b82f6;
}

.timeline-row-message-employee {
    border-left-color: #8b5cf6;
}

.timeline-row-call-client {
    border-left-color: #3b82f6;
}

.timeline-row-call-sales {
    border-left-color: #10b981;
}

.timeline-row-created {
    border-left-color: #f97316;
}

.timeline-row-status {
    border-left-color: #6b7280;
}

.timeline-row-default {
    border-left-color: #9ca3af;
}

/* Старые стили для совместимости (можно удалить позже) */
.timeline-simple-event {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
}

.timeline-simple-event:last-child {
    border-bottom: none;
}

.timeline-simple-event strong {
    color: #6b7280;
    font-weight: 600;
}

/* Анализ критериев */
.criteria-analysis {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.criteria-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.criteria-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.criteria-header {
    padding: 8px 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
    flex-wrap: wrap;
    gap: 6px;
}

.criteria-header:hover {
    background: #f3f4f6;
}

.criteria-title {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.criteria-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.criteria-name {
    color: #1f2937;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.criteria-score {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.criteria-avg-score {
    font-size: 13px;
    font-weight: 600;
}

.criteria-toggle {
    color: #6b7280;
    font-size: 14px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.criteria-toggle.expanded {
    transform: rotate(180deg);
}

.criteria-content {
    padding: 12px;
    display: none;
}

.criteria-content.expanded {
    display: block;
    animation: slideDown 0.3s ease-in-out;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 1000px; }
}

/* Компактные критерии - новый дизайн */
.criteria-card-compact {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: all 0.3s ease;
    margin-bottom: 0;
    width: 100%;
}

.criteria-card-compact:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.criteria-compact-header {
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    transition: all 0.2s ease;
}

.criteria-compact-header:hover {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.criteria-compact-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.criteria-compact-name {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
}

.criteria-header-summary {
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    line-height: 1.5;
    margin-top: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    border-left: 3px solid #0284c7;
    border-radius: 4px;
}

.criteria-compact-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.criteria-compact-score {
    font-size: 20px;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 20px;
    min-width: 50px;
    text-align: center;
    transition: all 0.2s ease;
}

.criteria-compact-toggle {
    color: #6b7280;
    font-size: 18px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.criteria-compact-toggle.expanded {
    transform: rotate(180deg);
}

.criteria-compact-content {
    padding: 20px;
    display: none;
    background: white;
}

.criteria-compact-content.expanded {
    display: block;
    animation: slideDownSmooth 0.3s ease-in-out;
    border-top: 1px solid #e5e7eb;
}

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

/* JTBD специальные стили */
.jtbd-card-compact {
    border: 2px solid #fbbf24;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.jtbd-card-compact .criteria-compact-header {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.jtbd-card-compact .criteria-icon {
    font-size: 20px;
}

.criteria-records {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Новый дизайн карточек критериев в стиле дашборда */
.criteria-dashboard-card {
    cursor: pointer;
    padding: 20px;
    background: white;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.criteria-dashboard-card:hover {
    background: #fafafa;
}

.criteria-card-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.criteria-score-circle {
    position: relative;
    flex-shrink: 0;
    width: 70px;
    height: 70px;
}

.criteria-score-circle svg {
    transform: rotate(0deg);
}

.score-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

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

.criteria-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.criteria-title {
    font-size: 17px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    line-height: 1.3;
    flex: 1;
}

.criteria-badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-excellent {
    background: #d1fae5;
    color: #065f46;
}

.badge-good {
    background: #dbeafe;
    color: #1e40af;
}

.badge-average {
    background: #fef3c7;
    color: #92400e;
}

.badge-poor {
    background: #fee2e2;
    color: #991b1b;
}

.badge-none {
    background: #f3f4f6;
    color: #6b7280;
}

.criteria-description {
    font-size: 14px;
    line-height: 1.5;
    color: #6b7280;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
}

.criteria-record {
    background: #f9fafb;
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 4px;
}

.record-score {
    font-size: 13px;
    font-weight: 600;
}

.record-date {
    color: #6b7280;
    font-size: 10px;
}

/* Score Reasoning */
.record-score-reasoning {
    margin-bottom: 12px;
    padding: 10px;
    background: linear-gradient(to right, #fef3c7, #fef9e7);
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
}

.score-reasoning-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #92400e;
    margin-bottom: 6px;
}

.score-reasoning-text {
    color: #78350f;
    font-size: 12px;
    line-height: 1.5;
    font-weight: 500;
}

/* Executive Summary */
.record-summary {
    margin-bottom: 12px;
    padding: 10px;
    background: linear-gradient(to right, #f0f9ff, #e0f2fe);
    border-left: 3px solid #0284c7;
    border-radius: 4px;
}

.summary-text {
    color: #0c4a6e;
    font-size: 12px;
    line-height: 1.5;
    font-weight: 500;
}

/* Detail Sections (Плюсы, Минусы, Советы) */
.record-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.detail-section {
    padding: 8px 10px;
    border-radius: 4px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
}

.strengths-section {
    border-left: 3px solid #10b981;
    background: linear-gradient(to right, #f0fdf4, #ffffff);
}

.weaknesses-section {
    border-left: 3px solid #ef4444;
    background: linear-gradient(to right, #fef2f2, #ffffff);
}

.recommendations-section {
    border-left: 3px solid #3b82f6;
    background: linear-gradient(to right, #eff6ff, #ffffff);
}

.buying-signals-section {
    border-left: 3px solid #22c55e;
    background: linear-gradient(to right, #f0fdf4, #ffffff);
}

.hesitation-signals-section {
    border-left: 3px solid #eab308;
    background: linear-gradient(to right, #fefce8, #ffffff);
}

.sales-tactics-section {
    border-left: 3px solid #8b5cf6;
    background: linear-gradient(to right, #f5f3ff, #ffffff);
}

.positive-signals-section {
    border-left: 3px solid #10b981;
    background: linear-gradient(to right, #ecfdf5, #ffffff);
}

.red-flags-section {
    border-left: 3px solid #dc2626;
    background: linear-gradient(to right, #fef2f2, #ffffff);
}

.next-steps-section {
    border-left: 3px solid #06b6d4;
    background: linear-gradient(to right, #ecfeff, #ffffff);
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.detail-icon {
    font-size: 14px;
    line-height: 1;
}

.detail-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #374151;
}

.detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-list li {
    font-size: 11px;
    line-height: 1.4;
    color: #1f2937;
    padding-left: 16px;
    position: relative;
}

.detail-list li::before {
    content: "•";
    position: absolute;
    left: 6px;
    color: #9ca3af;
    font-weight: bold;
}

.strengths-section .detail-list li::before {
    color: #10b981;
}

.weaknesses-section .detail-list li::before {
    color: #ef4444;
}

.recommendations-section .detail-list li::before {
    color: #3b82f6;
}

.buying-signals-section .detail-list li::before {
    color: #22c55e;
}

.hesitation-signals-section .detail-list li::before {
    color: #eab308;
}

.sales-tactics-section .detail-list li::before {
    color: #8b5cf6;
}

.positive-signals-section .detail-list li::before {
    color: #10b981;
}

.red-flags-section .detail-list li::before {
    color: #dc2626;
}

.next-steps-section .detail-list li::before {
    color: #06b6d4;
}

/* Подробный анализ (свернутый по умолчанию) */
.record-analysis details {
    margin-top: 10px;
    border-top: 1px solid #e5e7eb;
    padding-top: 8px;
}

.record-analysis summary {
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
    padding: 4px 0;
    list-style: none;
}

.record-analysis summary::-webkit-details-marker {
    display: none;
}

.record-analysis summary::before {
    content: "▶";
    display: inline-block;
    margin-right: 6px;
    font-size: 10px;
    transition: transform 0.2s;
}

.record-analysis details[open] summary::before {
    transform: rotate(90deg);
}

.record-analysis summary:hover {
    color: #374151;
}

.record-analysis .markdown-content {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.5;
}

/* JSON массивы */
.json-array {
    list-style: none;
    padding: 0;
    margin: 0;
}

.json-array li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.json-array li:last-child {
    border-bottom: none;
}

.json-array .icon {
    font-size: 16px;
    margin-top: 2px;
    flex-shrink: 0;
}

.json-array .content {
    flex: 1;
    color: #374151;
    line-height: 1.5;
}

.json-array.cons .icon { color: #ef4444; }
.json-array.pros .icon { color: #10b981; }
.json-array.recommendations .icon { color: #3b82f6; }

/* JSON объекты */
.json-object {
    background: #1f2937;
    color: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    padding: 10px 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-title {
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.modal-close:hover {
    background: #e5e7eb;
}

.modal-body {
    padding: 12px;
    max-height: 60vh;
    overflow-y: auto;
}

.json-modal .modal-body {
    padding: 0;
}

.json-content {
    background: #1f2937;
    color: #f9fafb;
    padding: 24px;
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Состояния загрузки */
.loading-state {
    display: none !important;
}

/* Глобальный оверлей загрузки */
.global-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

.global-loading-overlay.active {
    display: flex;
}

.global-loading-content {
    background-color: white;
    padding: 24px 32px;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-in;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

.global-loading-content p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .dashboard-main {
        padding: 8px;
    }
    
    .leads-filters {
        gap: 4px;
    }
    
    .compact-header-filters {
        padding: 8px 12px;
        gap: 10px;
    }
    
    .compact-filters-group {
        gap: 6px;
    }
}

@media (max-width: 768px) {
    .dashboard-main {
        padding: 6px;
    }
    
    .header-content {
        padding: 6px 8px;
    }
    
    .leads-header {
        padding: 8px;
    }
    
    .lead-detail-header {
        padding: 8px;
    }
    
    .lead-summary-cards {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .data-table th.criteria-column {
        min-width: 50px;
        font-size: clamp(8px, 0.6vw, 11px);
        padding-right: 18px;
        line-height: 1.1;
        min-height: 35px;
    }
    
    .data-table td.criteria-column {
        min-width: 50px;
    }
    
    .timeline-container {
        padding: 8px;
    }
    
    .criteria-content {
        padding: 8px;
    }
    
    /* Компактный заголовок на планшетах */
    .compact-header-filters {
        padding: 8px;
        gap: 8px;
    }
    
    .compact-header-filters .agent-title {
        min-width: 120px;
    }
    
    .compact-header-filters .agent-title h2 {
        font-size: 13px;
    }
    
    .compact-filters-group {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 16px;
        margin: 8px;
    }
    
    .agent-selection-container {
        padding: 12px;
        margin: 8px;
    }
    
    .agent-selection-filters .date-filter-container {
        flex-direction: column;
    }
    
    .agents-table thead th {
        font-size: 11px;
        padding: 10px 8px;
    }
    
    .agents-table tbody td {
        font-size: 11px;
        padding: 10px 8px;
    }
    
    .modal-content {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }
    
    .date-filter-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .date-inputs {
        flex-direction: column;
        gap: 4px;
    }
    
    .date-input {
        min-width: 100%;
    }
    
    .data-table th.criteria-column {
        min-width: 45px;
        font-size: clamp(7px, 0.5vw, 10px);
        padding-right: 16px;
        line-height: 1.0;
        min-height: 30px;
    }
    
    /* Компактный заголовок на мобильных */
    .compact-header-filters {
        padding: 6px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .compact-header-filters .agent-title {
        width: 100%;
        min-width: auto;
        margin-bottom: 6px;
    }
    
    .compact-header-filters .agent-title h2 {
        font-size: 12px;
    }
    
    .compact-filters-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 6px;
    }
    
    .compact-filters-group .search-container {
        max-width: 100%;
    }
    
    .compact-filters-group .date-filter-container {
        width: 100%;
    }
    
    .compact-filters-group .filter-controls {
        width: 100%;
    }
}

/* Утилиты */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-4 {
    gap: 16px;
}

.text-center {
    text-align: center;
}

/* Анимации для переходов */
.screen-section {
    transition: opacity 0.3s ease-in-out;
}

.screen-section.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Улучшения для accessibility */
.btn:focus,
.form-input:focus,
.form-select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Стили для скроллбара */
.timeline-container::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.timeline-container::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Markdown контент */
.markdown-content {
    line-height: 1.4;
    color: #374151;
    font-size: 12px;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    color: #1f2937;
    margin-top: 10px;
    margin-bottom: 6px;
    font-weight: 600;
}

.markdown-content h1 { font-size: 15px; }
.markdown-content h2 { font-size: 14px; }
.markdown-content h3 { font-size: 13px; }

.markdown-content p {
    margin-bottom: 8px;
}

.markdown-content ul,
.markdown-content ol {
    margin-left: 16px;
    margin-bottom: 8px;
}

.markdown-content li {
    margin-bottom: 3px;
}

.markdown-content strong {
    font-weight: 600;
    color: #1f2937;
}

.markdown-content em {
    font-style: italic;
}

.markdown-content code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

.markdown-content pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 12px;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Tooltip стили */
.stat-badge[title] {
    cursor: help;
    position: relative;
}

.stat-badge[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: pre-line;
    z-index: 1000;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.stat-badge[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
    z-index: 1000;
    pointer-events: none;
}

/* Tooltip для select options */
select option[title] {
    cursor: help;
}

/* Кликабельные строки таблицы */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background-color: #f8fafc;
}

.clickable-row:active {
    background-color: #e2e8f0;
}

/* Подсветка строк лидов в зависимости от наличия анализа */
.lead-analyzed {
    background-color: #f0fdf4 !important; /* Зеленая подсветка */
}

.lead-analyzed:hover {
    background-color: #dcfce7 !important;
}

.lead-not-analyzed {
    background-color: #fef2f2 !important; /* Красная подсветка */
}

.lead-not-analyzed:hover {
    background-color: #fee2e2 !important;
}

/* Бейджи для категорий лидов */
.lead-category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
    text-transform: uppercase;
}

.lead-category-badge.won {
    background: #d1fae5;
    color: #065f46;
}

.lead-category-badge.in_progress {
    background: #dbeafe;
    color: #1e40af;
}

.lead-category-badge.lost {
    background: #fee2e2;
    color: #991b1b;
}

/* Бейдж для In Progress в таблице агентов */
.agent-stat-badge.in-progress {
    background: #dbeafe;
    color: #1e40af;
}

/* JTBD специфичные стили */
.jtbd-card .criteria-header {
    background: #f0f9ff;
    border-bottom-color: #bfdbfe;
}

.jtbd-card .criteria-icon {
    color: #3b82f6;
}

/* Административная панель */
.admin-panel {
    max-width: 100%;
    margin: 0 auto;
    padding: 12px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-header h2 {
    margin: 0;
    color: #1f2937;
    font-size: 16px;
}

.admin-tabs {
    display: flex;
    gap: 4px;
    margin: 0 8px;
    flex-wrap: wrap;
}

.admin-tab {
    padding: 4px 10px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    font-size: 12px;
    white-space: nowrap;
}

.admin-tab:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

.admin-tab.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.admin-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.admin-section {
    padding: 8px;
}

.admin-section.hidden {
    display: none;
}

.admin-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.user-table-container {
    overflow-x: auto;
}

.user-table-container table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.user-table-container th,
.user-table-container td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 11px;
}

.user-table-container th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

/* Компактные колонки для таблицы пользователей */
.user-table-container th:nth-child(1),
.user-table-container td:nth-child(1) {
    width: 120px; /* Имя пользователя */
    min-width: 120px;
}

.user-table-container th:nth-child(2),
.user-table-container td:nth-child(2) {
    width: 80px; /* Роль */
    min-width: 80px;
}

.user-table-container th:nth-child(3),
.user-table-container td:nth-child(3) {
    width: 150px; /* Email */
    min-width: 150px;
}

.user-table-container th:nth-child(4),
.user-table-container td:nth-child(4) {
    width: 120px; /* Агент */
    min-width: 120px;
}

.user-table-container th:nth-child(5),
.user-table-container td:nth-child(5) {
    width: 100px; /* Создан */
    min-width: 100px;
}

.user-table-container th:nth-child(6),
.user-table-container td:nth-child(6) {
    width: 200px; /* Действия */
    min-width: 200px;
}

.user-table-container tr:hover {
    background: #f9fafb;
}

/* Стили для таблицы критериев */
.criteria-config-header {
    margin-bottom: 20px;
}

.criteria-config-header h3 {
    margin: 0 0 10px 0;
    color: #1f2937;
    font-size: 18px;
}

.criteria-description {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

.criteria-table-container {
    overflow-x: visible;
    margin-bottom: 20px;
}

.criteria-table-container table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.criteria-table-container th,
.criteria-table-container td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
}

.criteria-table-container th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

/* Специфичные ширины для колонок критериев */
.criteria-table-container th:nth-child(1),
.criteria-table-container td:nth-child(1) {
    width: auto;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

.criteria-table-container th:nth-child(2),
.criteria-table-container td:nth-child(2) {
    width: 80px;
    text-align: center;
}

.criteria-table-container th:nth-child(3),
.criteria-table-container td:nth-child(3) {
    width: 80px;
    text-align: center;
}

.criteria-table-container th:nth-child(4),
.criteria-table-container td:nth-child(4) {
    width: 120px;
    text-align: center;
}

.criteria-table-container tr:hover {
    background: #f9fafb;
}

.criteria-name {
    font-weight: 500;
    color: #1f2937;
    word-wrap: break-word;
    line-height: 1.3;
}

.criteria-toggle {
    display: inline-block;
    position: relative;
    width: 44px;
    height: 24px;
}

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

.criteria-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.criteria-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.criteria-toggle input:checked + .criteria-toggle-slider {
    background-color: #3b82f6;
}

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

.criteria-order-input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}

.criteria-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.role-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.admin {
    background: #fef3c7;
    color: #92400e;
}

.role-badge.agent {
    background: #dbeafe;
    color: #1e40af;
}

.actions {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}

.actions .btn {
    padding: 2px 4px;
    font-size: 9px;
    min-width: auto;
    white-space: nowrap;
    min-height: 20px;
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
}

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

.admin-nav-btn {
    margin-right: 12px;
}

/* Формы пользователей */
.user-form {
    max-width: 500px;
    margin: 0 auto;
}

.user-form .form-group {
    margin-bottom: 10px;
}

.user-form label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #374151;
    font-size: 12px;
}

.user-form input,
.user-form select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    transition: border-color 0.2s ease;
}

.user-form input:focus,
.user-form select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.form-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

/* Адаптивность для админ-панели */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .admin-actions {
        justify-content: center;
    }
    
    .user-table-container {
        font-size: 14px;
    }
    
    .user-table-container th,
    .user-table-container td {
        padding: 8px 12px;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Кнопка переключения языка */
.language-switcher {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
    text-align: center;
    white-space: nowrap;
}

.language-switcher:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.language-switcher:active {
    transform: translateY(0);
}

/* Заголовок экрана входа */
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    margin-bottom: 0.5rem;
}

.login-header .login-subtitle {
    margin-bottom: 1rem;
    color: #666;
}

/* Глобальный лоадер для переключения языка */
.language-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.language-loader-content {
    background-color: white;
    padding: 24px 36px;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-in;
}

.language-loader-content .spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
    margin-bottom: 12px;
}

.language-loader-content p {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Новые стили для дашборда агента */
.agent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    background: white;
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 12px;
}

.agent-title {
    flex: 0 0 auto;
    min-width: 200px;
}

.agent-title h2 {
    color: #1f2937;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
}

/* Объединенный блок заголовка и фильтров */
.compact-header-filters {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 12px;
    background: white;
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
}

.compact-header-filters .agent-title {
    flex: 0 0 auto;
    min-width: 150px;
}

.compact-header-filters .agent-title h2 {
    font-size: 15px;
    margin: 0;
    white-space: nowrap;
}

.compact-header-filters .timeframe-stats-container {
    flex: 0 0 auto;
}

.compact-filters-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.dashboard-stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 16px;
    margin-bottom: 20px;
}

/* На больших экранах: 2 колонки (левая с Leads+Profit, правая с Criteria) */
@media (min-width: 1200px) {
    .dashboard-stats-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 16px;
    }

    /* Левая колонка, строка 1 - Leads Statistics */
    .leads-stats-horizontal {
        grid-column: 1;
        grid-row: 1;
    }

    /* Левая колонка, строка 2 - Profit */
    .profit-stats-card {
        grid-column: 1;
        grid-row: 2;
    }

    /* Правая колонка на всю высоту - Criteria */
    .criteria-stats-card {
        grid-column: 2;
        grid-row: 1 / 3;
    }
}

/* На средних экранах - вертикальное размещение */
@media (max-width: 1199px) {
    .dashboard-stats-grid {
        grid-template-columns: 1fr;
    }

    .leads-stats-horizontal,
    .profit-stats-card,
    .criteria-stats-card {
        grid-column: 1;
    }
}

.stats-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.stats-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.stats-card .card-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.stats-card .card-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    z-index: 1;
    position: relative;
}

.stats-card .card-icon {
    font-size: 24px;
    z-index: 1;
    position: relative;
}

.stats-card .stats-content {
    padding: 20px;
}

.stats-card .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.stats-card .stat-item:hover {
    background: #f1f5f9;
}

.stats-card .stat-item:last-child {
    margin-bottom: 0;
}

.stats-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 4px;
    line-height: 1;
}

.stats-card .stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

/* Специфичные стили для разных типов статистики */
.won-leads {
    color: #10b981;
}

.lost-leads {
    color: #ef4444;
}

/* Новые стили для блока Profit - позитивный дизайн */
.profit-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profit-cards-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 6px 0;
}

/* Карточки прибыли */
.profit-card {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 12px 16px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

.profit-card-gained {
    animation-delay: 0.2s;
    border-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
}

.profit-card-potential {
    animation-delay: 0.4s;
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
}

.profit-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.profit-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.profit-card-icon {
    font-size: 18px;
}

.profit-card-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.profit-card-amount {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-left: auto;
}

.profit-amount {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #1e293b 0%, #475569 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.profit-currency {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
}

/* Детали карточки прибыли */
.profit-card-details {
    margin-top: 2px;
    margin-bottom: 6px;
    min-height: 16px;
}

.profit-details-text {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0.01em;
    opacity: 0.9;
}

.profit-currency {
    font-size: 14px;
    font-weight: 600;
    color: #94a3b8;
}

/* Прогресс-бары */
.profit-card-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.profit-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(90deg, transparent 0%, currentColor 100%);
}

.profit-bar-gained {
    color: #10b981;
    background: linear-gradient(90deg, #6ee7b7 0%, #10b981 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.profit-bar-potential {
    color: #3b82f6;
    background: linear-gradient(90deg, #93c5fd 0%, #3b82f6 100%);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Итоговая статистика */
.profit-summary {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 12px;
    border: 2px solid #f59e0b;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
    animation-delay: 0.6s;
}

.profit-summary-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profit-summary-label {
    font-size: 11px;
    font-weight: 600;
    color: #92400e;
    text-transform: uppercase;
}

.profit-summary-value {
    font-size: 18px;
    font-weight: 700;
    color: #78350f;
}

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

.value-number .value-currency {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
}

/* ===== Новые стили для блока Lead Statistics ===== */

/* Сетка карточек */
.leads-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    padding: 8px 0;
}

/* Базовая карточка */
.lead-stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0;
    animation: fadeInScale 0.5s ease-out forwards;
    cursor: pointer;
}

.lead-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Иконка карточки */
.lead-stat-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
}

/* Контент карточки */
.lead-stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.lead-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.lead-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.8;
    line-height: 1.2;
}

/* Анимация появления */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Цветовое кодирование карточек */

/* 1. Всего лидов - нейтральный серый */
.lead-stat-total {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-color: #cbd5e1;
    animation-delay: 0.1s;
}

.lead-stat-total .lead-stat-value {
    color: #475569;
}

.lead-stat-total .lead-stat-label {
    color: #64748b;
}

/* 2. Проанализировано - синий */
.lead-stat-analyzed {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #60a5fa;
    animation-delay: 0.2s;
}

.lead-stat-analyzed .lead-stat-value {
    color: #1e40af;
}

.lead-stat-analyzed .lead-stat-label {
    color: #2563eb;
}

/* 3. Won - золотой/зеленый */
.lead-stat-won {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #fbbf24;
    animation-delay: 0.3s;
}

.lead-stat-won .lead-stat-value {
    color: #92400e;
}

.lead-stat-won .lead-stat-label {
    color: #b45309;
}

.lead-stat-won:hover {
    box-shadow: 0 8px 24px rgba(251, 191, 36, 0.4);
}

/* 4. In Progress - циан */
.lead-stat-progress {
    background: linear-gradient(135deg, #cffafe 0%, #a5f3fc 100%);
    border-color: #22d3ee;
    animation-delay: 0.4s;
}

.lead-stat-progress .lead-stat-value {
    color: #0e7490;
}

.lead-stat-progress .lead-stat-label {
    color: #0891b2;
}

/* 5. Lost - мягкий оранжевый (не красный!) */
.lead-stat-lost {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    border-color: #fb923c;
    animation-delay: 0.5s;
}

.lead-stat-lost .lead-stat-value {
    color: #9a3412;
}

.lead-stat-lost .lead-stat-label {
    color: #c2410c;
}

/* 6. С оценкой - фиолетовый */
.lead-stat-scored {
    background: linear-gradient(135deg, #e9d5ff 0%, #d8b4fe 100%);
    border-color: #a78bfa;
    animation-delay: 0.6s;
}

.lead-stat-scored .lead-stat-value {
    color: #5b21b6;
}

.lead-stat-scored .lead-stat-label {
    color: #7c3aed;
}

/* 7. Без оценки - розовый */
.lead-stat-unscored {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    border-color: #f472b6;
    animation-delay: 0.7s;
}

.lead-stat-unscored .lead-stat-value {
    color: #9f1239;
}

.lead-stat-unscored .lead-stat-label {
    color: #be123c;
}

/* Адаптивность */
@media (max-width: 768px) {
    .leads-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .lead-stat-value {
        font-size: 20px;
    }

    .lead-stat-icon {
        font-size: 20px;
        width: 36px;
        height: 36px;
    }
}

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

/* ===== Конец стилей Lead Statistics ===== */

/* Цвета для overall_score на основе значения будут устанавливаться через JavaScript */
.overall-score {
    font-weight: 700;
}

/* Цвета для criteria-score (desire_to_buy, worth_working) на основе значения будут устанавливаться через JavaScript */
.criteria-score {
    font-weight: 700;
}

/* Вспомогательные классы для динамического окрашивания скоров */
.score-red {
    color: #ef4444 !important;
}

.score-yellow {
    color: #eab308 !important;
}

.score-green {
    color: #10b981 !important;
}

/* Стили для блока критериев */
.overall-score-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e5e7eb;
    position: relative;
}

.overall-score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 12px;
}

.connected-criteria {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.connected-criteria .criteria-badge {
    background: #dbeafe;
    color: #1e40af;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
    border: 1px solid #bfdbfe;
    position: relative;
}

.connected-criteria .criteria-badge::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -8px;
    width: 6px;
    height: 2px;
    background: #3b82f6;
    transform: translateY(-50%);
}

.separate-criteria {
    display: flex;
    gap: 12px;
}

.criteria-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    transition: all 0.2s ease;
}

.criteria-item:hover {
    background: #f1f5f9;
    border-color: #8b5cf6;
}

/* Адаптивность для новых блоков */
@media (max-width: 768px) {
    .dashboard-stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stats-card {
        margin: 0 4px;
    }

    .stats-card .card-header {
        padding: 12px 16px;
    }

    .stats-card .card-header h3 {
        font-size: 14px;
    }

    .stats-card .card-icon {
        font-size: 20px;
    }

    .stats-card .stats-content {
        padding: 16px;
    }

    .stats-card .stat-value {
        font-size: 24px;
    }

    .stats-card .stat-label {
        font-size: 11px;
    }

    .separate-criteria {
        flex-direction: column;
        gap: 8px;
    }

    .connected-criteria {
        gap: 6px;
    }

    .connected-criteria .criteria-badge {
        font-size: 9px;
        padding: 3px 6px;
    }

    /* Компактные элементы на мобильных */
    .leads-stats-horizontal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-item-compact {
        padding: 12px;
        gap: 8px;
    }

    .stat-item-compact .stat-icon {
        font-size: 20px;
    }

    .stat-item-compact .stat-value {
        font-size: 20px;
    }

    .stat-item-compact .stat-label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .agent-header {
        padding: 12px;
        margin-bottom: 12px;
    }

    .agent-title h2 {
        font-size: 16px;
    }

    .dashboard-stats-grid {
        gap: 8px;
    }

    .stats-card {
        margin: 0 2px;
    }

    .stats-card .card-header {
        padding: 10px 12px;
    }

    .stats-card .stats-content {
        padding: 12px;
    }

    .stats-card .stat-value {
        font-size: 20px;
    }

    .stats-card .stat-label {
        font-size: 10px;
    }

    /* Компактные элементы на очень маленьких экранах */
    .leads-stats-horizontal-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .stat-item-compact {
        padding: 10px;
    }

    .stat-item-compact .stat-icon {
        font-size: 20px;
    }

    .stat-item-compact .stat-value {
        font-size: 18px;
    }

    .stat-item-compact .stat-label {
        font-size: 10px;
    }

    .leads-stats-horizontal .stats-content {
        padding: 12px;
    }
}

/* Стили для наложения "under development" */
.under-development-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 10;
    backdrop-filter: blur(2px);
}

.under-development-label {
    font-size: 28px;
    font-weight: 700;
    color: #f97316;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: pulse-dev 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-dev {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

/* Стили для секции управления отображением */
.display-config-header {
    margin-bottom: 20px;
    padding: 0 16px;
}

.display-config-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.display-description {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

.display-toggles-container {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
    margin: 0 16px 20px 16px;
}

.display-toggle-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

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

.toggle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
}

.display-toggle-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.toggle-text {
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
}

.toggle-description {
    font-size: 12px;
    color: #9ca3af;
    margin-left: 28px;
    display: block;
    line-height: 1.4;
}

.display-actions {
    display: flex;
    gap: 8px;
    padding: 0 16px 16px 16px;
    justify-content: flex-start;
}

.display-actions .btn {
    padding: 8px 16px;
}

/* ==================== Criteria Trends Visualization ==================== */

/* Контейнер контента трендов */
.criteria-trends-content {
    padding: 16px;
}

/* Секция общего скора с трендом */
.overall-score-trend-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    margin-bottom: 24px;
    padding: 16px;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.overall-score-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

.overall-score-main .score-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    margin-bottom: 8px;
}

.score-value-container {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.score-value {
    font-size: 42px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

.score-change {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.score-change.trend-up {
    background: #dcfce7;
    color: #16a34a;
}

.score-change.trend-down {
    background: #fee2e2;
    color: #dc2626;
}

.score-change.trend-stable {
    background: #f3f4f6;
    color: #6b7280;
}

.change-icon {
    font-size: 16px;
}

.score-change.trend-up .change-icon::before {
    content: "↗";
}

.score-change.trend-down .change-icon::before {
    content: "↘";
}

.score-change.trend-stable .change-icon::before {
    content: "→";
}

.overall-score-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}

.overall-score-chart canvas {
    max-height: 150px;
}

/* Сетка критериев с трендами */
.criteria-trends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

/* Карточка одного критерия */
.criteria-trend-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.criteria-trend-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    border-color: #667eea;
}

.criteria-trend-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.criteria-trend-info {
    flex: 1;
}

.criteria-trend-name {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    margin-bottom: 6px;
}

.criteria-trend-score {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

.criteria-trend-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.criteria-trend-badge.trend-up {
    background: #dcfce7;
    color: #16a34a;
}

.criteria-trend-badge.trend-down {
    background: #fee2e2;
    color: #dc2626;
}

.criteria-trend-badge.trend-stable {
    background: #f3f4f6;
    color: #6b7280;
}

.criteria-sparkline {
    margin-top: 10px;
    height: 60px;
    position: relative;
}

.criteria-sparkline canvas {
    width: 100% !important;
    height: 60px !important;
}

/* Карточки качества лидов (для Desire to Buy и Worth Working) */
.criteria-quality-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.criteria-quality-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.3), rgba(102, 126, 234, 0.1));
}

.criteria-quality-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    border-color: #667eea;
}

.quality-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.quality-icon {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.quality-info {
    flex: 1;
}

.quality-name {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 2px;
    letter-spacing: 0.2px;
}

.quality-level {
    font-size: 13px;
    font-weight: 700;
    padding: 2px 0;
}

.quality-score-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    margin: 8px 0 4px 0;
}

.quality-score-value {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
}

.quality-progress-bar {
    width: 100%;
    height: 8px;
    background: #f3f4f6;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.quality-progress-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.6s ease, background 0.3s ease;
    position: relative;
    overflow: hidden;
}

.quality-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Цветовые схемы для уровней качества */
.quality-excellent {
    color: #7c3aed;
}

.quality-progress-fill.quality-excellent {
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
}

.quality-good {
    color: #16a34a;
}

.quality-progress-fill.quality-good {
    background: linear-gradient(90deg, #16a34a, #4ade80);
}

.quality-medium {
    color: #f59e0b;
}

.quality-progress-fill.quality-medium {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.quality-low {
    color: #ea580c;
}

.quality-progress-fill.quality-low {
    background: linear-gradient(90deg, #ea580c, #fb923c);
}

.quality-very-low {
    color: #dc2626;
}

.quality-progress-fill.quality-very-low {
    background: linear-gradient(90deg, #dc2626, #f87171);
}

/* Тултип для критериев */
.criteria-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 1000;
    pointer-events: none;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    line-height: 1.5;
}

.criteria-tooltip-title {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 13px;
}

.criteria-tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.criteria-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.criteria-tooltip-label {
    color: #d1d5db;
}

.criteria-tooltip-value {
    font-weight: 600;
}

/* Индикатор загрузки трендов */
.criteria-trends-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 12px;
}

.criteria-trends-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Адаптивность для маленьких экранов */
@media (max-width: 768px) {
    .overall-score-trend-section {
        grid-template-columns: 1fr;
    }

    .criteria-trends-grid {
        grid-template-columns: 1fr;
    }

    .score-value {
        font-size: 32px;
    }

    .criteria-trend-score {
        font-size: 24px;
    }
}

/* Стили для кликабельной статистики лидов */
.leads-stats-table {
    width: 100%;
    border-collapse: collapse;
}

.leads-stats-table tbody tr {
    transition: all 0.2s ease;
}

.stat-row-clickable {
    cursor: pointer;
    position: relative;
}

.stat-row-clickable:hover {
    background-color: #f8fafc;
}

.stat-row-clickable::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: transparent;
    transition: background-color 0.2s ease;
}

.stat-row-clickable:hover::before {
    background-color: #cbd5e1;
}

/* Активный фильтр */
.stat-row-active {
    background-color: #eff6ff !important;
    font-weight: 600;
}

.stat-row-active::before {
    background-color: #3b82f6 !important;
}

/* Специфичные цвета для разных категорий при активации */
.stat-row-won.stat-row-active {
    background-color: #ecfdf5 !important;
}

.stat-row-won.stat-row-active::before {
    background-color: #10b981 !important;
}

.stat-row-lost-high-potential.stat-row-active {
    background-color: #fef3c7 !important;
}

.stat-row-lost-high-potential.stat-row-active::before {
    background-color: #f59e0b !important;
}

.stat-row-lost-low-potential.stat-row-active {
    background-color: #fee2e2 !important;
}

.stat-row-lost-low-potential.stat-row-active::before {
    background-color: #ef4444 !important;
}

/* Стили для ячеек таблицы статистики */
.leads-stats-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.leads-stats-table .stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #475569;
}

.leads-stats-table .stat-icon {
    font-size: 18px;
}

.leads-stats-table .stat-value {
    text-align: right;
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
}

/* Анимация при наведении на кликабельные строки */
@keyframes pulse-border {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

.stat-row-active::before {
    animation: pulse-border 2s ease-in-out infinite;
}

/* Горизонтальный grid для статистики лидов */
.leads-stats-horizontal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

@media (min-width: 768px) {
    .leads-stats-horizontal-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .leads-stats-horizontal-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Компактные элементы статистики */
.stat-item-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 2px solid transparent;
    text-align: center;
}

.stat-item-compact:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.stat-item-compact .stat-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.stat-item-compact .stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    width: 100%;
}

.stat-item-compact .stat-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
}

.stat-item-compact .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

/* Активное состояние для компактных элементов */
.stat-item-compact.stat-row-active {
    background-color: #eff6ff !important;
    border-color: #3b82f6;
}

.stat-item-compact.stat-row-won:hover {
    border-color: #22c55e;
}

.stat-item-compact.stat-row-lost-high-potential:hover {
    border-color: #f59e0b;
}

.stat-item-compact.stat-row-lost-low-potential:hover {
    border-color: #ef4444;
}

/* Уменьшаем отступы для компактного блока */
.leads-stats-horizontal .stats-content {
    padding: 12px;
}

.leads-stats-horizontal .card-header {
    padding: 12px 16px;
}

.leads-stats-horizontal .card-header h3 {
    font-size: 14px;
}

.leads-stats-horizontal .card-icon {
    font-size: 20px;
}

/* ========== Асинхронная загрузка блоков ========== */

/* Индикатор загрузки для каждого блока */
.block-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 10;
    backdrop-filter: blur(4px);
}

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

.block-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.block-loading-text {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

/* Состояние загрузки для stats-card */
.stats-card {
    position: relative;
    min-height: 200px;
}

.stats-card.loading {
    pointer-events: none;
}

/* Позиционирование для timeframe-stats-container */
.timeframe-stats-container {
    position: relative;
}

/* Анимация появления контента после загрузки */
.stats-card.loaded .stats-content {
    animation: fadeIn 0.3s ease-in;
}

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

/* Индикатор загрузки для таблицы лидов */
.leads-table-container {
    position: relative;
    min-height: 400px;
}

.table-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 10;
    backdrop-filter: blur(4px);
}

/* Скелетон-загрузка для блоков (опционально) */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Стили для админ меню (промежуточная страница) */
.admin-menu-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.admin-menu-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    padding: 60px 40px;
    animation: slideUp 0.4s ease-out;
}

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

.admin-menu-header {
    text-align: center;
    margin-bottom: 50px;
}

.admin-menu-header h1 {
    font-size: 2.5em;
    color: #333;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.admin-menu-subtitle {
    font-size: 1.1em;
    color: #666;
    margin: 0;
}

.admin-menu-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.menu-option-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 25px;
    border: 2px solid #f0f0f0;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.menu-option-card:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateX(10px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
}

.menu-option-icon {
    font-size: 3em;
    min-width: 80px;
    text-align: center;
}

.menu-option-content {
    flex: 1;
}

.menu-option-content h3 {
    margin: 0 0 8px 0;
    font-size: 1.3em;
    color: #333;
}

.menu-option-content p {
    margin: 0;
    color: #999;
    font-size: 0.95em;
}

.menu-option-arrow {
    font-size: 1.5em;
    color: #667eea;
    transition: transform 0.3s ease;
}

.menu-option-card:hover .menu-option-arrow {
    transform: translateX(5px);
}

/* Адаптивность */
@media (max-width: 768px) {
    .admin-menu-container {
        padding: 40px 25px;
    }

    .admin-menu-header h1 {
        font-size: 2em;
    }

    .menu-option-card {
        padding: 20px;
        gap: 15px;
    }

    .menu-option-icon {
        font-size: 2.5em;
        min-width: 60px;
    }

    .menu-option-content h3 {
        font-size: 1.1em;
    }
}