@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* :root { ... CSS переменные для удобства ... } */

/* Глобальный масштаб интерфейса 80% для всех страниц */
html {
    zoom: 0.8;
    overflow-x: hidden;
    height: 100%;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f9fafb;
    color: #111827;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    height: 100%;
    width: 100%;
    position: relative;
}

/* Альтернативный вариант для браузеров, которые не поддерживают zoom */
@supports not (zoom: 0.8) {
    html {
        transform: scale(0.8);
        transform-origin: top left;
        width: 125%;
    }
    
    body {
        width: 100%;
    }
}

body.modal-open {
    overflow: hidden;
}

/* --- Стили для страницы входа (переработано) --- */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f9fafb;
    padding: 20px;
}

.login-container form {
    background-color: #ffffff;
    padding: 48px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
}

.login-container h1 {
    text-align: center;
    color: #111827;
    margin-bottom: 32px;
    font-weight: 700;
    font-size: 24px;
}

.login-container .input-group {
    margin-bottom: 24px;
}

.login-container label {
    display: block;
    margin-bottom: 8px;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-container input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.login-container button {
    width: 100%;
    padding: 12px;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-container button:hover {
    background-color: #2563eb;
}

.error-message {
    color: #ef4444;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

/* --- Админ-панель --- */
.admin-container {
    display: flex;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    width: 100%;
    position: relative;
}

.sidebar {
    width: 260px;
    background-color: #991B1B;
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-toggle {
    position: absolute;
    top: 16px;
    right: -12px;
    width: 24px;
    height: 24px;
    background-color: #991B1B;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.2s ease;
    padding: 0;
}

.sidebar-toggle:hover {
    background-color: #334155;
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-header {
    padding: 28px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: padding 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-header {
    padding: 28px 12px;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-header h2 {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-weight: 500;
    position: relative;
}

.sidebar.collapsed .nav-item {
    padding: 14px 0;
    justify-content: center;
}

.nav-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    transition: all 0.2s;
}

.nav-text {
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background-color: rgba(99, 102, 241, 0.2);
    border-left-color: #6366f1;
    color: white;
}

.sidebar.collapsed .nav-item.active {
    border-left-color: transparent;
    border-radius: 8px;
    margin: 0 8px;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: padding 0.3s ease;
}

.sidebar.collapsed .sidebar-footer {
    padding: 20px 12px;
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
}

.sidebar.collapsed .sidebar-footer a {
    justify-content: center;
}

.sidebar-footer .nav-text {
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-footer .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.manager-info {
    margin-bottom: 12px;
    font-size: 14px;
    color: #e2e8f0;
    font-weight: 600;
    transition: opacity 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .manager-info {
    opacity: 0;
    height: 0;
    margin-bottom: 0;
}

.manager-info {
    margin-bottom: 12px;
    font-size: 14px;
    color: #e2e8f0;
    font-weight: 600;
}

.sidebar-footer a {
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
}

.sidebar-footer a:hover {
    color: white;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    padding: 32px 40px;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-shrink: 0;
}

.content-header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #111827;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.take-leads-button {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 180px;
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #9333ea);
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 12px 24px -10px rgba(79, 70, 229, 0.65);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    position: relative;
    overflow: visible;
}

.take-leads-button .take-leads-label {
    font-size: 12px;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.take-leads-button .take-leads-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin-left: -4px;
    margin-right: -4px;
}

.take-leads-button .take-leads-indicator .flame-icon {
    width: 32px;
    height: 32px;
    display: none !important;
    color: #ff6b35;
    filter: drop-shadow(0 0 8px rgba(255, 107, 53, 0.9)) drop-shadow(0 0 16px rgba(255, 107, 53, 0.7));
    animation: flameFlicker 0.5s ease-in-out infinite alternate;
}

.take-leads-button .take-leads-indicator .dot-icon {
    width: 10px;
    height: 10px;
    display: block;
    color: rgba(255, 255, 255, 0.5);
    transition: opacity 0.3s ease;
}

.take-leads-button .take-leads-indicator.active .flame-icon {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.take-leads-button .take-leads-indicator.active .dot-icon {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

@keyframes flameFlicker {
    0% {
        transform: scale(1) translateY(0);
        filter: drop-shadow(0 0 6px rgba(255, 107, 53, 0.8)) drop-shadow(0 0 12px rgba(255, 107, 53, 0.6));
    }
    25% {
        transform: scale(1.05) translateY(-1px) rotate(-1deg);
        filter: drop-shadow(0 0 8px rgba(255, 107, 53, 1)) drop-shadow(0 0 14px rgba(255, 107, 53, 0.8));
    }
    50% {
        transform: scale(0.98) translateY(1px) rotate(1deg);
        filter: drop-shadow(0 0 7px rgba(255, 107, 53, 0.9)) drop-shadow(0 0 13px rgba(255, 107, 53, 0.7));
    }
    75% {
        transform: scale(1.03) translateY(-0.5px) rotate(-0.5deg);
        filter: drop-shadow(0 0 8px rgba(255, 107, 53, 1)) drop-shadow(0 0 15px rgba(255, 107, 53, 0.8));
    }
    100% {
        transform: scale(1) translateY(0);
        filter: drop-shadow(0 0 6px rgba(255, 107, 53, 0.8)) drop-shadow(0 0 12px rgba(255, 107, 53, 0.6));
    }
}

.take-leads-button.has-leads {
    animation: pulseGlow 2.3s infinite;
}

.take-leads-button.has-leads:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px -10px rgba(79, 70, 229, 0.8);
}

.take-leads-button.has-leads:active {
    transform: translateY(0);
}

.take-leads-button.disabled {
    cursor: not-allowed;
    background: linear-gradient(135deg, #64748b, #475569);
    box-shadow: none;
    opacity: 0.7;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 18px 35px -15px rgba(79, 70, 229, 0.6), 0 0 0 rgba(129, 140, 248, 0);
    }
    50% {
        box-shadow: 0 20px 42px -12px rgba(79, 70, 229, 0.85), 0 0 20px rgba(129, 140, 248, 0.65);
    }
}

.manager-checklist {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.manager-checklist li {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(148, 163, 184, 0.1);
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.manager-checklist li.checked {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(34, 197, 94, 0.12);
}

.manager-checklist li.checked::before {
    content: "✓";
    font-weight: 700;
}

.button {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    display: inline-block;
}

.button.primary {
    background-color: #6366f1;
    color: white;
}

.button.primary:hover {
    background-color: #4f46e5;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background-color: #ffffff;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.stat-toggle-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6B7280;
    opacity: 0.5;
    transition: opacity 0.2s, color 0.2s, background 0.2s;
    z-index: 10;
    border-radius: 4px;
    width: 24px;
    height: 24px;
}

.stat-toggle-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
    color: #374151;
}

.stat-toggle-btn:active {
    transform: scale(0.95);
}

.stat-card:hover .stat-toggle-btn {
    opacity: 0.7;
}

.stat-toggle-btn.hidden {
    opacity: 0.3;
}

.stat-toggle-btn.hidden svg path:first-child {
    stroke-dasharray: 0, 1000;
    transition: stroke-dasharray 0.3s;
}

.stat-card.total-card {
    border-top: 3px solid #6366f1;
}

.stat-card.status-card {
    border-top: 3px solid var(--accent-color, #e2e8f0);
}

.stat-card-title {
    font-size: 13px;
    color: #475569;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-card-title .status-icon {
    font-size: 16px;
    line-height: 1;
}

.stat-card-value {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
}

.filters {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.filter-control {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.filter-control-compact {
    flex: 0 0 auto;
    min-width: 140px;
}

.filter-control-search {
    flex: 1 1 auto;
    min-width: 280px;
}

.filter-control label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.filter-control input,
.filter-control select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 14px;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.filter-control input:focus,
.filter-control select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    background: #fefefe;
}

.filter-date-input {
    width: 100%;
    padding: 11px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") no-repeat right 12px center;
    background-size: 16px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.filter-date-input:hover {
    border-color: #94a3b8;
}

.filter-date-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.filter-date-input.active {
    border-color: #6366f1;
    background-color: #eff6ff;
}

.search-input-wrapper {
    position: relative;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.15);
    padding: 8px 0;
    display: none;
    max-height: 220px;
    overflow-y: auto;
    z-index: 40;
}

.search-suggestions.visible {
    display: block;
}

.suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
    color: #1f2937;
}

.suggestion-item:hover {
    background: #f1f5f9;
}

.suggestion-count {
    font-size: 12px;
    color: #6366f1;
    font-weight: 600;
}

.leads-table-container {
    background-color: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow-x: auto;
    overflow-y: visible;
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
}

.leads-table th, .leads-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.leads-table .empty-table {
    text-align: center;
    padding: 32px 16px;
    color: #64748b;
    font-size: 15px;
}

.leads-table th {
    color: #6b7280;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 500;
}

.leads-table tr:last-child td {
    border-bottom: none;
}

.leads-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.leads-table tbody tr:hover {
    opacity: 0.85;
    filter: brightness(0.95);
}

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background-color: #ffffff;
    border-top: 1px solid #e5e7eb;
    margin-top: 0;
}

.pagination-info {
    display: flex;
    gap: 24px;
    align-items: center;
}

.pagination-text {
    font-size: 14px;
    color: #64748b;
}

.pagination-text strong {
    color: #1f2937;
    font-weight: 600;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background-color: #ffffff;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover:not(:disabled) {
    background-color: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}

.pagination-btn.active {
    background-color: #6366f1;
    border-color: #6366f1;
    color: #ffffff;
}

.pagination-btn.active:hover {
    background-color: #4f46e5;
    border-color: #4f46e5;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-ellipsis {
    padding: 0 8px;
    color: #94a3b8;
    font-size: 14px;
    user-select: none;
}

.status-badge {
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
    background: rgba(148, 163, 184, 0.15);
    color: #1f2937;
    border: 1px solid rgba(148, 163, 184, 0.3);
    transition: transform 0.2s ease;
}

.status-badge::before {
    content: attr(data-icon);
    font-size: 12px;
}

.status-badge:hover {
    transform: scale(1.05);
}

/* --- Стили для нового модального окна (исправленные) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(17, 24, 39, 0.8);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content.large {
    max-width: 700px;
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid #374151;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-body {
    padding: 32px;
}

.modal-requirements {
    background-color: #f3f4f6;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.modal-requirements p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #4b5563;
}

.modal-requirements ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.modal-requirements li {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
}

.content-area {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.settings-card {
    background-color: #ffffff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    padding: 32px 36px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.settings-card.danger-zone {
    border: 2px solid #EF4444;
    background-color: #FEF2F2;
}

.danger-zone-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.danger-zone-buttons .button.danger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    font-size: 15px;
    width: 100%;
    max-width: 400px;
}

.danger-zone-buttons .button.danger svg {
    width: 18px;
    height: 18px;
}

.settings-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}

.settings-card-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #111827;
}

.settings-card-header p {
    margin: 10px 0 0;
    color: #64748b;
    font-size: 14px;
    max-width: 560px;
    line-height: 1.6;
}

.teams-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.teams-container-empty {
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.04);
    padding: 40px;
    text-align: center;
    color: #475569;
}

.teams-empty-state h3 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.teams-empty-state p {
    margin: 0;
    font-size: 14px;
    color: #64748b;
}

.team-modal {
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.team-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 0;
}

.team-modal-content {
    position: relative;
    width: 420px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 32px 80px rgba(15, 23, 42, 0.35);
    overflow: hidden;
    z-index: 1;
}

.team-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(129, 140, 248, 0.06));
    border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}

.team-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.close-team-modal {
    background: rgba(99, 102, 241, 0.12);
    border-radius: 999px;
    color: #4f46e5;
}

.close-team-modal:hover {
    background: rgba(99, 102, 241, 0.2);
}

.team-modal-body {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.team-form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.team-form-field span {
    font-size: 12px;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: #4f46e5;
    text-transform: uppercase;
}

.team-form-field input {
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 500;
    color: #111827;
    background: linear-gradient(135deg, rgba(249, 250, 251, 1), rgba(238, 242, 255, 0.85));
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.team-form-field input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 14px 26px rgba(79, 70, 229, 0.18);
    transform: translateY(-1px);
}

.team-form-field input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.team-modal-footer {
    padding: 20px 28px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.team-card {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.team-card-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.team-card-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
}

.team-card-subtitle {
    margin: 6px 0 0;
    font-size: 13px;
    color: #64748b;
}

.team-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.manager-actions {
    padding: 18px 24px 0;
    display: flex;
    justify-content: flex-end;
}

.manager-table-wrapper {
    overflow-x: auto;
}

.manager-table {
    width: 100%;
    border-collapse: collapse;
}

.manager-table th,
.manager-table td {
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    font-size: 14px;
    color: #1f2937;
}

.manager-table th {
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
    background: #f8fafc;
}

.manager-table tr:last-child td {
    border-bottom: none;
}

.manager-table tbody tr:hover {
    background: #f8fafc;
}

.manager-name {
    font-weight: 600;
    color: #111827;
}

.manager-credentials {
    display: flex;
    align-items: center;
    gap: 10px;
}

.manager-credential-value {
    font-family: 'Inter', monospace;
    font-size: 14px;
    color: #0f172a;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 6px;
    padding: 4px 10px;
}

.button.small {
    padding: 8px 14px;
    font-size: 12px;
    border-radius: 8px;
}

.button.secondary {
    background-color: #e0e7ff;
    color: #3730a3;
}

.button.secondary:hover {
    background-color: #c7d2fe;
}

.button.ghost {
    background: transparent;
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #4f46e5;
}

.button.ghost:hover {
    background: rgba(99, 102, 241, 0.1);
}

.button.danger {
    background-color: #ef4444;
    color: #ffffff;
}

.button.danger:hover {
    background-color: #dc2626;
}

.button.icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.input-with-button {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-buttons input {
    flex: 1;
}

.phone-action-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}

.phone-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(148, 163, 184, 0.1);
    color: #94A3B8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.phone-action-btn:hover {
    background: rgba(148, 163, 184, 0.2);
    border-color: rgba(148, 163, 184, 0.5);
    color: #E2E8F0;
}

.phone-action-btn:active {
    transform: scale(0.95);
}

.phone-call-btn {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.1);
}

.phone-call-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
    color: #34d399;
}

.phone-call-btn.calling {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: #f87171;
    animation: pulseCall 1s ease-in-out infinite;
}

@keyframes pulseCall {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.input-with-button input {
    flex: 1;
}

.manager-form-row {
    background: #f5f3ff;
}

.manager-form-row td {
    padding-top: 18px;
    padding-bottom: 18px;
}

.manager-form-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.28);
    background: linear-gradient(135deg, rgba(255, 255, 255, 1), rgba(239, 246, 255, 0.95));
    color: #1f2937;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 14px;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border 0.2s ease;
}

.manager-form-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.manager-form-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.16);
    transform: translateY(-1px);
}

.input-with-button {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(99, 102, 241, 0.06);
    border-radius: 12px;
    padding: 4px;
}

.input-with-button .manager-form-input {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 10px 12px;
}

.input-with-button .manager-form-input:focus {
    border: none;
    box-shadow: none;
    transform: none;
}

.input-with-button .button.icon {
    background: #ede9fe;
    color: #4c1d95;
    border-radius: 10px;
    font-size: 16px;
    box-shadow: 0 8px 18px rgba(99, 102, 241, 0.18);
}

.input-with-button .button.icon:hover {
    background: #ddd6fe;
}

.manager-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.12);
}

.team-empty-managers {
    padding: 20px 24px;
    color: #64748b;
    font-size: 14px;
    text-align: center;
}

.input-group {
    margin-bottom: 24px;
}

/* --- Стили для модального окна (Новый дизайн) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(31, 41, 55, 0.8);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content.simple {
    background-color: #2D3748;
    color: #E2E8F0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 0;
    overflow: hidden;
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid #4A5568;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

/* Увеличенный заголовок для окна предпросмотра */
.modal-content.large .modal-header {
    padding: 28px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-content.large .modal-header h2 {
    font-size: 22px;
    margin: 0;
}

/* УДАЛЯЕМ СТИЛИ ДЛЯ КРЕСТИКА, ТАК КАК ЕГО БОЛЬШЕ НЕТ */
/* .close-button { ... } */

.modal-body {
    padding: 32px;
}

.drop-zone {
    border: 1px dashed #4A5568;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.drop-zone:hover {
    background-color: #4A5568;
    border-color: #6366F1;
}

.drop-zone-icon svg {
    width: 32px;
    height: 32px;
    color: #A0AEC0;
    margin-bottom: 16px;
}

.drop-zone p {
    margin: 0 0 8px 0;
    font-weight: 500;
}

.drop-zone small {
    color: #A0AEC0;
    margin-bottom: 16px;
    display: block;
}

.modal-footer {
    padding: 20px 24px;
    background-color: #1F2937;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid #4A5568;
}

.button-secondary,
.button-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
}

.button-secondary {
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.25);
    color: #E2E8F0;
}

.button-secondary:hover {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.35);
}

.button-secondary.ghost {
    background: transparent;
    border-style: dashed;
    border-color: rgba(148, 163, 184, 0.35);
    color: #CBD5F5;
}

.button-secondary.ghost:hover {
    background: rgba(148, 163, 184, 0.12);
}

.button-primary {
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    color: #FFFFFF;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.25);
}

.button-primary:hover {
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.button-primary[disabled],
.button-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Дополнительные стили для неактивной кнопки сохранения */
#managerContinueLeadSaveButton[disabled],
#managerContinueLeadSaveButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #9ca3af;
}

#managerContinueLeadSaveButton[disabled]:hover,
#managerContinueLeadSaveButton:disabled:hover {
    background: #9ca3af;
    transform: none;
}

.button-primary[disabled] {
    background: rgba(148, 163, 184, 0.25);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Стили для анализа и результатов */
#analyzing-state,
#results-state {
    text-align: center;
}

.results-title {
    margin-bottom: 16px;
    color: #A0AEC0;
    font-size: 14px;
}

.results-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.result-card {
    background-color: #4A5568;
    padding: 24px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.result-card .card-title {
    font-size: 16px;
    color: #A0AEC0;
}

.result-card .count {
    font-size: 36px;
    font-weight: 700;
    margin-top: 8px;
    display: block;
    color: #FFF;
}

.result-card:hover {
    border-color: #6366F1;
    transform: translateY(-2px);
}

.modal-footer {
    justify-content: flex-end;
}

/* Модальное окно предпросмотра */
.modal-content.large {
    background-color: #2D3748;
    color: #E2E8F0;
    border-radius: 12px;
    width: 96%;
    max-width: 1700px;
    max-height: 90vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-content.large .modal-footer {
    padding: 18px 40px;
}

.preview-table-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 40px;
}

#previewTable {
    width: 100%;
    border-collapse: collapse;
    min-height: 100%;
}

#previewTable th,
#previewTable td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid #4A5568;
    color: #E2E8F0;
    font-size: 14px;
}

#previewTable th {
    background-color: #1F2937;
    position: sticky;
    top: 0;
    font-weight: 600;
    z-index: 10;
}

#previewTable tbody tr:hover {
    background-color: #374151;
}

#previewTable tr:last-child td {
    border-bottom: none;
}

/* --- Карточка лида --- */
.lead-detail-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(14px);
    z-index: 1200;
    padding: 10px 40px;
    box-sizing: border-box;
}

.lead-detail-modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lead-detail-content {
    background: #0f172a;
    color: #E2E8F0;
    width: 85%;
    max-width: 1120px;
    height: calc(100% - 20px);
    max-height: calc(100% - 20px);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 80px rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(99, 102, 241, 0.12);
    overflow: hidden;
    margin: 10px auto;
}

.lead-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(56, 189, 248, 0.05));
    border-bottom: 1px solid rgba(99, 102, 241, 0.14);
}

.lead-detail-header h2 {
    margin: 0;
    font-weight: 600;
    font-size: 20px;
}

.lead-detail-subtitle {
    margin: 4px 0 0;
    color: #94a3b8;
    font-size: 12px;
}

.icon-button {
    border: none;
    background: rgba(148, 163, 184, 0.08);
    color: #e2e8f0;
    font-size: 26px;
    line-height: 1;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.icon-button:hover {
    background: rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
}

.lead-detail-body {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 26px;
    flex: 1;
    padding: 24px 28px 28px;
    overflow: hidden;
}

.lead-detail-form {
    padding: 20px 24px;
    background: rgba(15, 23, 42, 0.82);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.lead-detail-form::-webkit-scrollbar {
    width: 6px;
}

.lead-detail-form::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 18px 24px;
    row-gap: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: fit-content;
}

.form-field span {
    font-size: 12px;
    color: #cbd5f5;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.2;
    margin-bottom: 2px;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    box-sizing: border-box;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.68);
    color: #E2E8F0;
    font-size: 14px;
    padding: 11px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    line-height: 1.5;
}

.form-field input,
.form-field select {
    height: 40px;
}

.form-field textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.6;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-actions {
    margin-top: 14px;
    padding-top: 6px;
    display: flex;
    justify-content: flex-end;
    gap: 14px;
}

.lead-detail-chat {
    padding: 20px 24px;
    background: rgba(15, 23, 42, 0.85);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.chat-subtitle {
    margin: 5px 0 0;
    color: #94a3b8;
    font-size: 12px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    padding-right: 8px;
    padding-bottom: 8px;
    max-height: 400px;
    min-height: 200px;
}

.chat-history::-webkit-scrollbar {
    width: 8px;
}

.chat-history::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.7);
}

.history-empty {
    padding: 20px;
    border-radius: 16px;
    background-color: rgba(148, 163, 184, 0.12);
    border: 1px dashed rgba(148, 163, 184, 0.28);
    color: #94a3b8;
    text-align: center;
    font-size: 14px;
}

.history-entry {
    border-radius: 14px;
    padding: 14px 16px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(148, 163, 184, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-entry.status {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.18);
}

.history-entry.pending {
    opacity: 0.85;
    border-style: dashed;
}

.history-entry.admin-message {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.15);
}

.history-entry.admin-message .meta {
    color: rgba(239, 68, 68, 0.9);
}

.history-entry.admin-message .text {
    color: rgba(239, 68, 68, 0.95);
}

/* Стили для страницы статистики */
.statistics-container {
    padding: 24px;
    overflow: visible;
    flex: 1;
}

.statistics-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    height: auto;
    min-height: auto;
    max-height: none;
}

.statistics-chart-section {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 24px;
    max-height: calc(100vh / 3);
    overflow: hidden;
}

.statistics-chart-section canvas {
    max-width: 100%;
    max-height: 100%;
}

.statistics-list-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 24px;
    overflow-y: auto;
    max-height: calc(100vh / 3);
}

.statistics-group {
    margin-bottom: 32px;
}

.statistics-group:last-child {
    margin-bottom: 0;
}

.statistics-group-title {
    font-size: 18px;
    font-weight: 700;
    color: #1F2937;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #E5E7EB;
}

.statistics-group-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.statistics-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #F9FAFB;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.statistics-item:hover {
    background: #F3F4F6;
}

.statistics-item-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.statistics-item-code {
    font-weight: 600;
    color: #374151;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    min-width: 120px;
    flex-shrink: 0;
}

.statistics-item-label {
    color: #6B7280;
    font-size: 14px;
    flex: 1;
}

.statistics-item-color {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    min-width: 70px;
    text-align: center;
    flex-shrink: 0;
}

.statistics-item-count {
    font-size: 18px;
    font-weight: 700;
    color: #1F2937;
    min-width: 50px;
    text-align: right;
    flex-shrink: 0;
}

.statistics-item-selected {
    background: #EFF6FF !important;
    border: 2px solid #3B82F6 !important;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
}

.statistics-item-percentage {
    font-size: 14px;
    font-weight: 600;
    color: #6B7280;
    min-width: 60px;
    text-align: right;
    flex-shrink: 0;
    margin-left: 8px;
}

.statistics-chart-section canvas {
    transition: transform 0.2s ease;
    cursor: pointer;
}

/* Стили для статистики по менеджерам */
.manager-statistics-section {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 2px solid #E5E7EB;
}

.manager-statistics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.manager-statistics-title {
    font-size: 22px;
    font-weight: 700;
    color: #1F2937;
    margin: 0;
}

.manager-statistics-filters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-filter-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.date-range-input {
    padding: 8px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 14px;
    min-width: 250px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
    position: relative;
}

.date-filter-container {
    position: relative;
}

/* Позиционирование календаря Flatpickr для статистики менеджеров */
.date-filter-container .flatpickr-calendar {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    margin-top: 4px !important;
    z-index: 1000;
}

.date-range-input:hover {
    border-color: #9CA3AF;
}

.date-range-input:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.date-filter-buttons {
    display: flex;
    gap: 8px;
}

.date-filter-btn {
    padding: 8px 16px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    background: white;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-filter-btn:hover {
    background: #F9FAFB;
    border-color: #9CA3AF;
}

.date-filter-btn.active {
    background: #2563EB;
    color: white;
    border-color: #2563EB;
}

.manager-statistics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.manager-stat-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 20px;
    border: 1px solid #E5E7EB;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.manager-stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.manager-stat-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #E5E7EB;
}

.manager-stat-name {
    font-size: 16px;
    font-weight: 700;
    color: #1F2937;
    margin: 0;
}

.manager-stat-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.manager-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.manager-stat-label {
    color: #6B7280;
    font-weight: 500;
}

.manager-stat-value {
    color: #1F2937;
    font-weight: 700;
    font-size: 16px;
}

.manager-stat-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.manager-status-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #EFF6FF;
    color: #1E40AF;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.manager-stat-empty {
    color: #9CA3AF;
    font-size: 13px;
    font-style: italic;
}

.manager-stat-status-groups {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.manager-stat-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.manager-stat-group-label {
    font-size: 12px;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.manager-stat-group-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.manager-status-badge-small {
    display: inline-block;
    padding: 3px 8px;
    background: #F3F4F6;
    color: #374151;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.manager-status-badge-full {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.manager-status-icon {
    font-size: 14px;
    line-height: 1;
}

.manager-status-code {
    font-family: 'Courier New', monospace;
    font-weight: 700;
}

.manager-status-label {
    font-weight: 500;
}

.manager-status-count {
    margin-left: auto;
    font-weight: 700;
    font-size: 13px;
}

.history-entry .meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #cbd5f5;
}

.history-entry .text {
    font-size: 13px;
    color: #f8fafc;
    line-height: 1.5;
    word-break: break-word;
}

.chat-input {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-input textarea {
    width: 100%;
    min-height: 75px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.9);
    color: #E2E8F0;
    padding: 10px 14px;
    font-size: 13px;
    resize: vertical;
}

.chat-input textarea:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.chat-input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-input-actions .hint {
    font-size: 12px;
    color: #94a3b8;
}

/* === АДАПТИВНЫЕ СТИЛИ === */

/* Планшеты и маленькие десктопы */
@media (max-width: 1400px) {
    .lead-detail-body {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
        gap: 32px;
        padding: 32px 36px;
    }
    
    .form-grid {
        gap: 24px 28px;
        row-gap: 28px;
    }
}

/* Средние экраны */
@media (max-width: 1200px) {
    .admin-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 12px 20px;
    }
    
    .sidebar-header {
        padding: 0;
        border: none;
    }
    
    .sidebar-header h2 {
        font-size: 20px;
    }
    
    .sidebar-nav {
        display: flex;
        gap: 8px;
        padding: 0;
        margin-left: auto;
    }
    
    .nav-item {
        padding: 10px 16px;
        border-left: none;
        border-bottom: 3px solid transparent;
        font-size: 14px;
    }
    
    .nav-item.active {
        border-left: none;
        border-bottom-color: #6366f1;
    }
    
    .sidebar-footer {
        padding: 0;
        margin-left: 20px;
        border: none;
    }
    
    .tab-content {
        padding: 24px;
    }
    
    .content-header h1 {
        font-size: 24px;
    }
    
    .lead-detail-content {
        width: 95%;
        max-width: 100%;
        height: 95vh;
    }
    
    .lead-detail-body {
        grid-template-columns: 1fr;
        gap: 28px;
        padding: 28px 32px;
        overflow-y: auto;
    }
    
    .lead-detail-form,
    .lead-detail-chat {
        padding: 24px;
    }
    
    .lead-detail-chat {
        border-left: none;
        padding-left: 24px;
    }
}

/* Планшеты */
@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filter-input {
        min-width: 100%;
    }
    
    .leads-table-container {
        overflow-x: auto;
    }
    
    .leads-table {
        min-width: 800px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .lead-detail-modal {
        padding: 20px;
    }
    
    .lead-detail-header {
        padding: 24px 28px 20px;
    }
    
    .lead-detail-header h2 {
        font-size: 22px;
    }
}

/* Мобильные устройства */
@media (max-width: 768px) {
    .sidebar {
        flex-direction: column;
        padding: 16px;
    }
    
    .sidebar-nav {
        flex-direction: column;
        width: 100%;
        margin: 16px 0;
    }
    
    .nav-item {
        border-bottom: none;
        border-left: 3px solid transparent;
    }
    
    .nav-item.active {
        border-left-color: #6366f1;
        border-bottom: none;
    }
    
    .sidebar-footer {
        margin-left: 0;
    }
    
    .tab-content {
        padding: 20px 16px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .content-header h1 {
        font-size: 22px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .login-container form {
        padding: 32px 24px;
    }
    
    .lead-detail-modal {
        padding: 12px;
    }
    
    .lead-detail-content {
        width: 100%;
        height: 98vh;
        border-radius: 16px;
    }
    
    .lead-detail-header {
        padding: 20px 24px 16px;
    }
    
    .lead-detail-header h2 {
        font-size: 20px;
    }
    
    .lead-detail-subtitle {
        font-size: 12px;
    }
    
    .icon-button {
        width: 38px;
        height: 38px;
        font-size: 24px;
    }
    
    .lead-detail-body {
        padding: 20px 24px;
        gap: 24px;
    }
    
    .lead-detail-form,
    .lead-detail-chat {
        padding: 20px;
    }
    
    .form-field span {
        font-size: 12px;
    }
    
    .form-field input,
    .form-field select {
        height: 44px;
        font-size: 14px;
        padding: 12px 14px;
    }
    
    .form-field textarea {
        min-height: 120px;
        font-size: 14px;
    }
    
    .chat-header h3 {
        font-size: 16px;
    }
    
    .chat-input textarea {
        min-height: 100px;
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .modal-content.simple {
        width: 95%;
    }
    
    .modal-body {
        padding: 24px;
    }
    
    .drop-zone {
        padding: 30px 20px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .leads-table th,
    .leads-table td {
        padding: 12px 8px;
        font-size: 13px;
    }
    
    .button {
        padding: 10px 18px;
        font-size: 13px;
    }
    
    .stat-card {
        padding: 18px;
    }
    
    .stat-card-value {
        font-size: 28px;
    }
    
    .result-card {
        padding: 18px;
    }
    
    .result-card .count {
        font-size: 28px;
    }
}

/* Стили для контейнера перезвонов на главной странице менеджера */
.callbacks-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 24px;
    width: 33.333%;
    max-height: 50vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.callbacks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e5e7eb;
}

.callbacks-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.callbacks-count {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
}

.callbacks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    padding-right: 8px;
}

/* Стили для скроллбара списка перезвонов */
.callbacks-list::-webkit-scrollbar {
    width: 8px;
}

.callbacks-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.callbacks-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.callbacks-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.callback-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.callback-item:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
    transform: translateX(4px);
}

.callback-item.overdue {
    background: #fef2f2;
    border-color: #ef4444;
}

.callback-item.overdue:hover {
    background: #fee2e2;
}

.callback-info {
    flex: 1;
}

.callback-lead-name {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.callback-lead-phone {
    font-size: 14px;
    color: #6b7280;
}

.callback-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: #3b82f6;
    min-width: 120px;
    justify-content: flex-end;
}

.callback-item.overdue .callback-timer {
    color: #ef4444;
}

.callback-timer-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.callback-timer-text {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .callback-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .callback-timer {
        width: 100%;
        justify-content: flex-start;
    }
}

/* Стили для интерфейса дубликатов */
.duplicates-view-toggle {
    display: flex;
    gap: 8px;
    align-items: center;
}

.duplicates-view-toggle .toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.duplicates-view-toggle .toggle-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.duplicates-view-toggle .toggle-btn.active {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

.duplicates-view-toggle .toggle-btn svg {
    width: 16px;
    height: 16px;
}

.duplicates-table-container {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.duplicates-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.duplicates-table thead {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.duplicates-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.duplicates-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s ease;
}

.duplicates-table tbody tr:hover {
    background: #f9fafb;
}

.duplicates-table tbody tr.replaced-row {
    background: #f0fdf4;
}

.duplicates-table tbody tr.replaced-row:hover {
    background: #dcfce7;
}

.duplicates-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: #111827;
}

.duplicate-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.duplicate-status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.duplicate-status-badge.replaced {
    background: #d1fae5;
    color: #065f46;
}

.duplicates-container {
    padding: 20px;
    max-height: 75vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.duplicate-card {
    background: white;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.duplicate-card.replaced {
    border-color: #10b981;
    background: #f0fdf4;
}

.duplicate-card-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    padding: 16px;
    align-items: start;
}

.duplicate-side {
    background: #f9fafb;
    border-radius: 8px;
    padding: 12px;
    border-left: 4px solid;
}

.duplicate-new-side {
    border-left-color: #ef4444;
}

.duplicate-new-side.replaced {
    border-left-color: #10b981;
    background: #f0fdf4;
}

.duplicate-existing-side {
    border-left-color: #f97316;
}

.duplicate-existing-side.replaced {
    border-left-color: #10b981;
    background: #f0fdf4;
}

.duplicate-side-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.duplicate-side-title {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.duplicate-side-date {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
}

.duplicate-side-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.duplicate-field-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.duplicate-field-name {
    font-weight: 600;
    color: #6b7280;
    min-width: 70px;
    flex-shrink: 0;
    font-size: 12px;
}

.duplicate-field-val {
    color: #111827;
    font-weight: 500;
    word-break: break-word;
    flex: 1;
}

.duplicate-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    min-width: 150px;
}

.duplicate-replace-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    min-width: 140px;
}

.duplicate-replace-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.duplicate-replace-btn svg {
    width: 18px;
    height: 18px;
    opacity: 0.9;
}

.duplicate-replace-btn span {
    white-space: nowrap;
}

.duplicate-replaced-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: #10b981;
    color: white;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    min-width: 120px;
}

.duplicate-replaced-indicator svg {
    width: 18px;
    height: 18px;
}

.result-card .replaced-count {
    margin-left: 8px;
    font-size: 14px;
}

@media (max-width: 1200px) {
    .duplicate-card-content {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .duplicate-center {
        min-width: auto;
        width: 100%;
    }
    
    .duplicate-replace-btn,
    .duplicate-replaced-indicator {
        width: 100%;
        flex-direction: row;
        justify-content: center;
    }
}
