/* ===== ARTEL CRM - МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
/* Полностью переработанная мобильная версия для удобной работы */

/* ===== ДЕСКТОПНАЯ ВЕРСИЯ (по умолчанию) ===== */
/* Мобильные карточки скрыты на десктопе */
#contacts-mobile-cards,
#leads-mobile-cards,
#deals-mobile-cards {
    display: none !important;
}

/* Таблицы показаны на десктопе */
#page-contacts .table-container,
#page-deals .table-container,
#leads-list-container .table-container {
    display: block !important;
}

/* ===== БАЗОВЫЕ МОБИЛЬНЫЕ ПЕРЕМЕННЫЕ ===== */
:root {
    --mobile-nav-height: 64px;
    --mobile-header-height: 56px;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --touch-target-min: 44px;
    --mobile-card-radius: 16px;
    --mobile-spacing: 12px;
}

/* ===== МОБИЛЬНЫЙ РЕЖИМ (до 600px) ===== */
@media (max-width: 600px) {
    /* Отключаем горизонтальный скролл на body */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* ===== SPLASH ЭКРАН ===== */
    .loading-screen {
        background: linear-gradient(135deg, #0891b2 0%, #06b6d4 40%, #22d3ee 70%, #67e8f9 100%) !important;
    }
    
    .splash-logo {
        flex-direction: column;
        gap: 20px;
    }
    
    .splash-icon {
        width: 100px;
        height: 100px;
    }
    
    .splash-text {
        font-size: 36px;
        letter-spacing: 8px;
    }
    
    /* ===== СКРЫТИЕ ДЕСКТОПНЫХ ЭЛЕМЕНТОВ ===== */
    .sidebar {
        display: none !important;
    }
    
    .hide-mobile {
        display: none !important;
    }
    
    /* ===== ОСНОВНОЙ КОНТЕЙНЕР ===== */
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 16px) !important;
        width: 100% !important;
        min-height: 100vh;
    }
    
    /* ===== МОБИЛЬНЫЙ HEADER ===== */
    .page-header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--bg-card);
        padding: var(--mobile-spacing);
        margin: 0;
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        gap: 8px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    .page-header h1 {
        font-size: 20px;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-actions {
        width: 100%;
        display: flex;
        gap: 8px;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 4px;
    }
    
    .header-actions::-webkit-scrollbar {
        display: none;
    }
    
    .header-actions .btn {
        flex-shrink: 0;
        white-space: nowrap;
        min-height: var(--touch-target-min);
        padding: 10px 14px;
        font-size: 13px;
    }
    
    /* ===== МОБИЛЬНАЯ НИЖНЯЯ НАВИГАЦИЯ ===== */
    .mobile-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--mobile-nav-height);
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        padding-bottom: var(--mobile-safe-bottom);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }
    
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 12px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 10px;
        min-width: 60px;
        transition: all 0.2s ease;
        border-radius: 12px;
        position: relative;
    }
    
    .mobile-nav-item i {
        font-size: 20px;
        margin-bottom: 4px;
    }
    
    .mobile-nav-item.active {
        color: var(--primary-color);
        background: rgba(232, 69, 28, 0.1);
    }
    
    .mobile-nav-add {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary-color), #ff6b4a);
        border: none;
        color: white;
        font-size: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 15px rgba(232, 69, 28, 0.4);
        margin-top: -20px;
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .mobile-nav-add:active {
        transform: scale(0.95);
    }
    
    /* ===== МОБИЛЬНОЕ МЕНЮ "ЕЩЁ" ===== */
    .mobile-more-menu {
        position: fixed;
        inset: 0;
        z-index: 2000;
    }
    
    .mobile-more-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
    }
    
    .mobile-more-content {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-radius: 24px 24px 0 0;
        max-height: 80vh;
        overflow-y: auto;
        padding-bottom: var(--mobile-safe-bottom);
        animation: slideUp 0.3s ease;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .mobile-more-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        border-bottom: 1px solid var(--border-color);
        font-weight: 600;
        font-size: 18px;
    }
    
    .mobile-more-close {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--bg-hover);
        border: none;
        color: var(--text-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    
    .mobile-more-items {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        padding: 12px;
    }
    
    .mobile-more-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 16px 8px;
        color: var(--text-primary);
        text-decoration: none;
        font-size: 12px;
        border-radius: 16px;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: background 0.2s ease;
        min-height: 80px;
    }
    
    .mobile-more-item:active {
        background: var(--bg-hover);
    }
    
    .mobile-more-item i {
        font-size: 24px;
        margin-bottom: 8px;
        color: var(--primary-color);
    }
    
    .mobile-more-item.logout {
        color: var(--danger-color);
    }
    
    .mobile-more-item.logout i {
        color: var(--danger-color);
    }
    
    .mobile-more-item.install {
        background: linear-gradient(135deg, var(--primary-color), #ff6b4a);
        color: white;
        border-radius: 12px;
        margin: 8px 0;
    }
    
    .mobile-more-item.install i {
        color: white;
    }
    
    /* ===== КАНБАН-ДОСКА МОБИЛЬНАЯ ===== */
    #leads-kanban,
    .kanban-board {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100vw;
        height: calc(100vh - var(--mobile-nav-height) - 120px);
    }
    
    .kanban-column {
        flex: 0 0 85vw !important;
        width: 85vw !important;
        min-width: 85vw !important;
        max-width: 85vw !important;
        height: 100% !important;
        scroll-snap-align: center;
        margin: 0 2.5vw !important;
        border-radius: 16px !important;
        background: #f0f2f5 !important;
        display: flex;
        flex-direction: column;
        box-shadow: none;
        border: none;
    }
    
    .kanban-column:first-child {
        margin-left: 7.5vw !important;
    }
    
    .kanban-column:last-child {
        margin-right: 7.5vw !important;
    }
    
    .kanban-column-header {
        padding: 12px 16px;
        border-bottom: none;
        background: transparent;
        flex-shrink: 0;
    }
    
    .kanban-header-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .kanban-stage-name {
        font-size: 16px;
        font-weight: 600;
    }
    
    .kanban-stage-count {
        font-size: 14px;
        color: var(--text-secondary);
        background: var(--bg-hover);
        padding: 4px 10px;
        border-radius: 12px;
        margin-left: 8px;
    }
    
    .kanban-header-line {
        height: 4px;
        border-radius: 2px;
        margin-top: 8px;
    }
    
    .kanban-column-body {
        flex: 1;
        overflow-y: auto;
        padding: 8px 12px;
        -webkit-overflow-scrolling: touch;
    }
    
    .kanban-column-footer {
        padding: 12px;
        border-top: 1px solid var(--border-color);
        flex-shrink: 0;
    }
    
    .kanban-column-footer .btn {
        width: 100%;
        justify-content: center;
        min-height: var(--touch-target-min);
    }
    
    /* ===== КАРТОЧКИ ЛИДОВ/ЗАДАЧ/СДЕЛОК ===== */
    .kanban-card {
        padding: 14px;
        padding-top: 36px;
        margin-bottom: 12px;
        border-radius: 14px;
        background: #ffffff;
        border: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        position: relative;
        overflow: hidden;
    }
    
    .kanban-card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }
    
    .kanban-card-title {
        font-size: 15px;
        font-weight: 600;
        margin-bottom: 10px;
        line-height: 1.4;
        color: var(--text-primary);
        padding-right: 10px;
    }
    
    .kanban-card-info {
        font-size: 13px;
        color: var(--text-secondary);
        line-height: 1.6;
    }
    
    .kanban-card-info > div {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 6px;
        word-break: break-word;
    }
    
    .kanban-card-info i {
        width: 16px;
        min-width: 16px;
        text-align: center;
        font-size: 12px;
        color: var(--primary-color);
    }
    
    .kanban-card-priority {
        position: absolute;
        top: 0;
        right: 0;
        padding: 6px 12px;
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        border-radius: 0 14px 0 12px;
    }
    
    .kanban-card-actions {
        display: flex;
        gap: 10px;
        margin-top: 14px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }
    
    .kanban-card-actions .btn {
        flex: 1;
        min-height: 42px;
        font-size: 13px;
        padding: 10px 12px;
        justify-content: center;
        border-radius: 10px;
    }
    
    .kanban-card-actions .btn-outline {
        background: #f3f4f6;
        border: none;
        color: var(--text-secondary);
    }
    
    .kanban-card-actions .btn-primary {
        background: linear-gradient(135deg, var(--primary-color), #ff6b4a);
        border: none;
        color: white;
    }
    
    /* Приоритеты */
    .priority-low {
        background: rgba(16, 185, 129, 0.15);
        color: #10b981;
    }
    
    .priority-normal {
        background: rgba(59, 130, 246, 0.15);
        color: #3b82f6;
    }
    
    .priority-high {
        background: rgba(245, 158, 11, 0.15);
        color: #f59e0b;
    }
    
    .priority-urgent {
        background: rgba(239, 68, 68, 0.15);
        color: #ef4444;
    }
    
    /* ===== ИНДИКАТОР КОЛОНОК КАНБАНА ===== */
    .kanban-dots-indicator {
        display: flex !important;
        justify-content: center;
        gap: 6px;
        padding: 12px;
        background: var(--bg-card);
        position: sticky;
        bottom: 0;
    }
    
    .kanban-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--border-color);
        transition: all 0.3s ease;
    }
    
    .kanban-dot.active {
        width: 24px;
        border-radius: 4px;
        background: var(--primary-color);
    }
    
    /* ===== МОБИЛЬНЫЙ ФИЛЬТР ===== */
    .mobile-filter-bar {
        display: flex !important;
        padding: 8px var(--mobile-spacing);
        gap: 8px;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
    }
    
    .mobile-filter-bar::-webkit-scrollbar {
        display: none;
    }
    
    .mobile-filter-chip {
        flex-shrink: 0;
        padding: 8px 14px;
        border-radius: 20px;
        background: var(--bg-hover);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        font-size: 13px;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 6px;
        white-space: nowrap;
        transition: all 0.2s ease;
    }
    
    .mobile-filter-chip.active {
        background: var(--primary-color);
        border-color: var(--primary-color);
        color: white;
    }
    
    .mobile-filter-chip i {
        font-size: 12px;
    }
    
    /* ===== СПИСКИ ЗАДАЧ/КОНТАКТОВ ===== */
    .mobile-list {
        padding: var(--mobile-spacing);
    }
    
    .mobile-list-item {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        padding: 14px;
        background: var(--bg-card);
        border-radius: var(--mobile-card-radius);
        margin-bottom: 10px;
        border: 1px solid var(--border-color);
        cursor: pointer;
        transition: transform 0.2s ease;
    }
    
    .mobile-list-item:active {
        transform: scale(0.98);
    }
    
    .mobile-list-item-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        flex-shrink: 0;
    }
    
    .mobile-list-item-content {
        flex: 1;
        min-width: 0;
    }
    
    .mobile-list-item-title {
        font-size: 15px;
        font-weight: 600;
        margin-bottom: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .mobile-list-item-subtitle {
        font-size: 13px;
        color: var(--text-secondary);
        display: flex;
        align-items: center;
        gap: 4px;
    }
    
    .mobile-list-item-meta {
        font-size: 11px;
        color: var(--text-muted);
        margin-top: 4px;
        display: flex;
        gap: 12px;
    }
    
    .mobile-list-item-action {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        flex-shrink: 0;
    }
    
    /* ===== ЗАДАЧИ МОБИЛЬНЫЕ ===== */
    .mobile-task-card {
        padding: 14px;
        background: var(--bg-card);
        border-radius: var(--mobile-card-radius);
        margin-bottom: 10px;
        border: 1px solid var(--border-color);
        position: relative;
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        overflow: hidden;
    }
    
    .mobile-task-card:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-task-status {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        border-radius: var(--mobile-card-radius) 0 0 var(--mobile-card-radius);
    }
    
    .mobile-task-status.overdue {
        background: var(--danger-color);
    }
    
    .mobile-task-status.today {
        background: var(--warning-color);
    }
    
    .mobile-task-status.upcoming {
        background: var(--success-color);
    }
    
    .mobile-task-status.done {
        background: var(--text-muted);
    }
    
    /* Контейнер для мобильных карточек */
    .mobile-cards-container {
        padding: 0;
    }
    
    .mobile-task-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
        padding-left: 8px;
    }
    
    .mobile-task-title {
        font-size: 15px;
        font-weight: 600;
        flex: 1;
        padding-right: 8px;
    }
    
    .mobile-task-checkbox {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        border: 2px solid var(--border-color);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: all 0.2s ease;
    }
    
    .mobile-task-checkbox.checked {
        background: var(--success-color);
        border-color: var(--success-color);
        color: white;
    }
    
    .mobile-task-body {
        padding-left: 8px;
    }
    
    .mobile-task-contact {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        color: var(--primary-color);
        margin-bottom: 8px;
    }
    
    .mobile-task-time {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        color: var(--text-secondary);
    }
    
    .mobile-task-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }
    
    .mobile-task-actions .btn {
        flex: 1;
        min-height: 40px;
        justify-content: center;
    }
    
    /* ===== СДЕЛКИ МОБИЛЬНЫЕ ===== */
    .mobile-deal-card {
        padding: 16px;
        background: var(--bg-card);
        border-radius: var(--mobile-card-radius);
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
    }
    
    .mobile-deal-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
    }
    
    .mobile-deal-title {
        font-size: 16px;
        font-weight: 600;
        flex: 1;
    }
    
    .mobile-deal-amount {
        font-size: 18px;
        font-weight: 700;
        color: var(--success-color);
    }
    
    .mobile-deal-stage {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        background: var(--bg-hover);
        border-radius: 20px;
        font-size: 12px;
        margin-bottom: 8px;
    }
    
    .mobile-deal-stage-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
    }
    
    .mobile-deal-contact {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        color: var(--text-secondary);
    }
    
    /* ===== МОДАЛЬНЫЕ ОКНА МОБИЛЬНЫЕ ===== */
    .modal-overlay {
        backdrop-filter: blur(4px);
    }
    
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }
    
    /* Модальное окно снизу для быстрых действий */
    .modal-content.modal-bottom {
        height: auto !important;
        max-height: 90vh !important;
        position: absolute;
        bottom: 0;
        border-radius: 24px 24px 0 0 !important;
        animation: slideUp 0.3s ease;
    }
    
    .modal-header {
        padding: 16px 20px;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .modal-header h3 {
        font-size: 18px;
        margin: 0;
    }
    
    .modal-close {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: var(--bg-hover);
        border: none;
        color: var(--text-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 18px;
    }
    
    .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 20px;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-footer {
        padding: 16px 20px;
        padding-bottom: calc(16px + var(--mobile-safe-bottom));
        border-top: 1px solid var(--border-color);
        flex-shrink: 0;
        display: flex;
        gap: 12px;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-height: 48px;
        justify-content: center;
        font-size: 15px;
    }
    
    /* ===== ФОРМЫ МОБИЛЬНЫЕ ===== */
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-group label {
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 8px;
        display: block;
        color: var(--text-secondary);
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px; /* Предотвращает zoom на iOS */
        border: 1px solid var(--border-color);
        border-radius: 12px;
        background: var(--bg-main);
        color: var(--text-primary);
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }
    
    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(232, 69, 28, 0.1);
        outline: none;
    }
    
    .form-group textarea {
        min-height: 100px;
        resize: vertical;
    }
    
    /* ===== КНОПКИ МОБИЛЬНЫЕ ===== */
    .btn {
        min-height: var(--touch-target-min);
        padding: 12px 20px;
        font-size: 14px;
        font-weight: 500;
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        border: none;
        white-space: nowrap;
    }
    
    .btn:active {
        transform: scale(0.97);
    }
    
    .btn-primary {
        background: linear-gradient(135deg, var(--primary-color), #ff6b4a);
        color: white;
        box-shadow: 0 4px 12px rgba(232, 69, 28, 0.3);
    }
    
    .btn-outline {
        background: transparent;
        border: 1px solid var(--border-color);
        color: var(--text-primary);
    }
    
    .btn-danger {
        background: var(--danger-color);
        color: white;
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .btn-block {
        width: 100%;
    }
    
    /* ===== FAB - СКРЫТ НА МОБИЛЬНОМ (есть кнопка + в навигации) ===== */
    .fab {
        display: none !important;
    }
    
    /* ===== СКРЫТЬ ИКОНКУ УВЕДОМЛЕНИЙ НА МОБИЛЬНОМ ===== */
    .notification-bell-btn,
    #notification-bell {
        display: none !important;
    }
    
    /* ===== ПОИСК МОБИЛЬНЫЙ ===== */
    .mobile-search-container {
        padding: var(--mobile-spacing);
        background: var(--bg-card);
        position: sticky;
        top: 0;
        z-index: 50;
    }
    
    .mobile-search {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        background: var(--bg-main);
        border: 1px solid var(--border-color);
        border-radius: 12px;
    }
    
    .mobile-search i {
        color: var(--text-muted);
        font-size: 16px;
    }
    
    .mobile-search input {
        flex: 1;
        border: none;
        background: transparent;
        font-size: 16px;
        color: var(--text-primary);
        outline: none;
    }
    
    .mobile-search input::placeholder {
        color: var(--text-muted);
    }
    
    /* ===== SWIPE ACTIONS ===== */
    .swipe-container {
        overflow: hidden;
        position: relative;
    }
    
    .swipe-content {
        transition: transform 0.3s ease;
    }
    
    .swipe-actions {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        display: flex;
    }
    
    .swipe-action {
        width: 80px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-size: 20px;
    }
    
    .swipe-action.edit {
        background: var(--primary-color);
    }
    
    .swipe-action.delete {
        background: var(--danger-color);
    }
    
    .swipe-action.complete {
        background: var(--success-color);
    }
    
    /* ===== PULL TO REFRESH ===== */
    .pull-to-refresh {
        position: absolute;
        top: -50px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: var(--bg-card);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        transition: transform 0.3s ease;
    }
    
    .pull-to-refresh.active {
        transform: translateX(-50%) translateY(60px);
    }
    
    .pull-to-refresh i {
        font-size: 18px;
        color: var(--primary-color);
        animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
    
    /* ===== ТАБЛИЦЫ -> КАРТОЧКИ ===== */
    .data-table {
        display: none !important;
    }
    
    .mobile-cards-view {
        display: block !important;
    }
    
    /* ===== DASHBOARD МОБИЛЬНЫЙ ===== */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: var(--mobile-spacing);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 14px;
        border-radius: 14px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    /* ===== TOAST УВЕДОМЛЕНИЯ ===== */
    .toast {
        left: var(--mobile-spacing) !important;
        right: var(--mobile-spacing) !important;
        bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 16px) !important;
        max-width: none !important;
        border-radius: 12px;
    }
    
    /* ===== ПРОЦЕССЫ НА МОБИЛЬНОМ ===== */
    #processes-list {
        padding: var(--mobile-spacing);
    }
    
    #processes-list > div {
        padding: 12px !important;
        border-radius: 14px !important;
    }
    
    #processes-list h3 {
        font-size: 14px !important;
        margin-bottom: 10px !important;
    }
    
    #processes-list button {
        min-width: auto !important;
        padding: 10px 14px !important;
        font-size: 13px !important;
    }
    
    /* ===== ПЕРЕКЛЮЧАТЕЛЬ ВИДОВ ===== */
    .view-toggle {
        display: flex;
        background: var(--bg-hover);
        border-radius: 10px;
        padding: 4px;
        gap: 4px;
    }
    
    .view-toggle-btn {
        flex: 1;
        padding: 8px 12px;
        border: none;
        background: transparent;
        border-radius: 8px;
        color: var(--text-secondary);
        font-size: 13px;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    
    .view-toggle-btn.active {
        background: var(--bg-card);
        color: var(--text-primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* ===== СКРЫТИЕ DESKTOP ЭЛЕМЕНТОВ ===== */
    #leads-kanban-header {
        padding: 8px var(--mobile-spacing) !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
    }
    
    #leads-kanban-header .btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    
    /* Скрываем кнопку настройки на мобильном */
    #kanban-edit-mode-btn {
        display: none !important;
    }
    
    /* ===== КАРТОЧКА КОНТАКТА/ЛИДА ===== */
    .entity-view-content {
        grid-template-columns: 1fr !important;
        padding: var(--mobile-spacing);
    }
    
    .entity-info-panel {
        order: -1;
    }
    
    /* ===== АНИМАЦИИ ===== */
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    @keyframes slideDown {
        from { transform: translateY(-100%); }
        to { transform: translateY(0); }
    }
    
    /* ===== УЛУЧШЕНИЯ ДЛЯ TOUCH ===== */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    input, textarea, select, button {
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Предотвращаем случайное выделение текста */
    .mobile-nav,
    .mobile-nav-item,
    .kanban-card,
    .mobile-list-item,
    .btn {
        user-select: none;
        -webkit-user-select: none;
    }
    
    /* ===== СТРАНИЦА КОНТАКТОВ НА МОБИЛЬНОМ ===== */
    #page-contacts .page-toolbar {
        flex-direction: column;
        gap: 8px;
        padding: 8px var(--mobile-spacing);
    }
    
    #page-contacts .page-toolbar .search-box {
        width: 100%;
    }
    
    #page-contacts .page-toolbar select,
    #page-contacts .page-toolbar .form-control {
        width: 100%;
        min-width: unset !important;
    }
    
    #page-contacts .page-toolbar label {
        width: 100%;
        justify-content: flex-start;
        padding: 8px 0;
    }
    
    #page-contacts .page-toolbar .btn {
        width: 100%;
    }
    
    /* ===== НОВЫЕ МОБИЛЬНЫЕ КАРТОЧКИ ===== */
    #contacts-mobile-cards,
    #leads-mobile-cards {
        display: block !important;
        padding: 12px;
        background: #f0f2f5 !important;
    }
    
    .mobile-card {
        display: flex;
        background: #ffffff;
        border-radius: 16px;
        margin-bottom: 16px;
        overflow: hidden;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
        cursor: pointer;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    
    .mobile-card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
    }
    
    .mobile-card-indicator {
        width: 6px;
        flex-shrink: 0;
    }
    
    .mobile-card-content {
        flex: 1;
        padding: 14px 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .mobile-card-top {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .mobile-card-avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary-color), #ff6b4a);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 16px;
        flex-shrink: 0;
        box-shadow: 0 4px 12px rgba(232, 69, 28, 0.3);
    }
    
    .mobile-card-info {
        flex: 1;
        min-width: 0;
    }
    
    .mobile-card-name {
        font-size: 16px;
        font-weight: 600;
        color: #1a1a2e;
        margin-bottom: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .mobile-card-stage {
        font-size: 13px;
        color: #6b7280;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .mobile-card-details {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .mobile-card-row {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
        background: #f8f9fb;
        border-radius: 10px;
        font-size: 14px;
        color: #374151;
        text-decoration: none;
    }
    
    .mobile-card-row i {
        width: 18px;
        color: var(--primary-color);
        font-size: 14px;
    }
    
    .mobile-card-row span {
        flex: 1;
    }
    
    .mobile-card-row:active {
        background: #eef1f5;
    }
    
    .mobile-card-footer {
        display: flex;
        align-items: center;
        gap: 8px;
        padding-top: 12px;
        border-top: 1px solid #e5e7eb;
    }
    
    .mobile-card-stat {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        color: #6b7280;
        padding: 6px 12px;
        background: #f3f4f6;
        border-radius: 8px;
    }
    
    .mobile-card-stat i {
        font-size: 12px;
        color: #9ca3af;
    }
    
    .mobile-card-btn {
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 10px;
        background: #f3f4f6;
        color: #6b7280;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
        transition: background 0.15s ease;
    }
    
    .mobile-card-btn:active {
        background: #e5e7eb;
    }
    
    .mobile-card-btn.primary {
        background: linear-gradient(135deg, var(--primary-color), #ff6b4a);
        color: white;
        margin-left: 4px;
        box-shadow: 0 2px 8px rgba(232, 69, 28, 0.3);
    }
    
    .mobile-card-btn.primary:active {
        background: linear-gradient(135deg, #d93a1c, #e85320);
    }
    
    /* ===== СТРАНИЦА ЛИДОВ НА МОБИЛЬНОМ ===== */
    #page-leads .page-toolbar {
        flex-direction: column;
        gap: 8px;
        padding: 8px var(--mobile-spacing);
    }
    
    #page-leads .page-toolbar .filters {
        width: 100%;
    }
    
    #leads-list-filters {
        flex-direction: column !important;
        width: 100%;
    }
    
    #leads-list-filters select,
    #leads-list-filters input {
        width: 100% !important;
        min-width: unset !important;
    }
    
    #page-leads .view-toggle {
        order: -1;
    }
    
    /* ===== СТРАНИЦА СДЕЛОК НА МОБИЛЬНОМ ===== */
    #page-deals .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    #page-deals .page-header > div {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start !important;
    }
    
    #page-deals .page-header .btn-primary {
        width: 100%;
        margin-top: 8px;
    }
    
    #page-deals .page-toolbar {
        flex-direction: column;
        gap: 8px;
        padding: 8px var(--mobile-spacing);
    }
    
    #page-deals .page-toolbar .filters {
        width: 100%;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    #page-deals .page-toolbar .search-box {
        width: 100%;
        min-width: unset !important;
    }
    
    #page-deals .page-toolbar select {
        width: 100%;
        min-width: unset !important;
    }
    
    #deal-date-range {
        flex-direction: column !important;
        width: 100%;
    }
    
    #deal-date-range > div {
        width: 100%;
    }
    
    #deal-date-range input {
        width: 100% !important;
        min-width: unset !important;
    }
    
    /* Мобильные карточки сделок */
    #deals-mobile-cards {
        display: block !important;
        padding: var(--mobile-spacing);
    }
    
    .deal-card {
        background: var(--bg-card);
        border-radius: var(--mobile-card-radius);
        padding: 14px;
        margin-bottom: 10px;
        border: 1px solid var(--border-color);
        cursor: pointer;
    }
    
    .deal-card:active {
        transform: scale(0.98);
    }
    
    .deal-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 10px;
    }
    
    .deal-card-title {
        font-size: 15px;
        font-weight: 600;
        flex: 1;
        padding-right: 8px;
    }
    
    .deal-card-amount {
        font-size: 16px;
        font-weight: 700;
        color: var(--success-color);
        white-space: nowrap;
    }
    
    .deal-card-stage {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 11px;
        padding: 4px 10px;
        border-radius: 12px;
        background: var(--bg-hover);
        margin-bottom: 8px;
    }
    
    .deal-card-stage-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
    }
    
    .deal-card-body {
        font-size: 13px;
        color: var(--text-secondary);
    }
    
    .deal-card-body > div {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 4px;
    }
    
    .deal-card-body i {
        width: 16px;
        text-align: center;
    }
    
    .deal-card-footer {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }
    
    .deal-card-footer .btn {
        flex: 1;
        min-height: 36px;
        font-size: 12px;
    }

    /* ===== СКРЫТИЕ ТАБЛИЦ НА МОБИЛЬНОМ ===== */
    #page-contacts .table-container,
    #page-deals .table-container,
    #leads-list-container .table-container {
        display: none !important;
    }
    
    /* Кнопка обновить - на всю ширину */
    #page-contacts .page-toolbar > .btn,
    #page-deals .page-toolbar > .btn,
    #page-leads .page-toolbar > .btn {
        width: 100%;
    }
    
    /* ===== ЛИЧНЫЕ ДЕЛА — МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    /* Страница «Мои дела» */
    .personal-tasks-page {
        padding: 0 !important;
    }
    
    .personal-tasks-page .page-header {
        flex-direction: column;
        gap: 10px;
        padding: var(--mobile-spacing);
    }
    
    .personal-tasks-page .page-header h1 {
        font-size: 20px;
    }
    
    .personal-tasks-page .page-header .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Фильтр-табы */
    .personal-tasks-page .filter-tabs {
        padding: 0 var(--mobile-spacing);
        gap: 6px;
    }
    
    .personal-tasks-page .filter-tab {
        flex: 1;
        justify-content: center;
        padding: 10px 8px;
        font-size: 13px;
    }
    
    /* Секции задач */
    .personal-tasks-page .tasks-sections {
        padding: var(--mobile-spacing);
    }
    
    .personal-tasks-page .tasks-section {
        margin-bottom: 12px;
    }
    
    /* Карточки дел */
    .personal-tasks-page .task-card {
        padding: 12px 12px 12px 16px;
        border-radius: 14px;
        gap: 10px;
    }
    
    .personal-tasks-page .task-card .task-title {
        font-size: 14px;
    }
    
    .personal-tasks-page .task-card .task-description {
        font-size: 12px;
    }
    
    .personal-tasks-page .task-card .task-meta {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .personal-tasks-page .task-card .task-meta span {
        font-size: 11px;
    }
    
    /* Чек-лист внутри карточки */
    .task-checklist-inline {
        margin-top: 6px;
        padding-top: 6px;
    }
    
    .checklist-items-inline li {
        padding: 5px 4px;
        font-size: 13px;
    }
    
    .checklist-items-inline li i {
        font-size: 15px;
    }
    
    .checklist-progress-text {
        font-size: 11px;
    }
    
    /* Модалка личного дела — центрированная как на десктопе */
    .personal-task-modal-wrapper {
        align-items: center !important;
        justify-content: center !important;
    }
    
    .personal-task-modal-content {
        width: 94% !important;
        max-width: 480px !important;
        max-height: 90vh !important;
        border-radius: 16px !important;
        animation: slideUp 0.25s ease !important;
    }
    
    .personal-task-modal-header {
        padding: 16px 20px;
    }
    
    .personal-task-form {
        padding: 16px 20px !important;
        padding-bottom: calc(16px + var(--mobile-safe-bottom)) !important;
    }
    
    .personal-task-form .form-group {
        margin-bottom: 14px;
    }
    
    /* Инпуты в модалке — компактнее, как на десктопе */
    .personal-task-input,
    .personal-task-textarea,
    .personal-task-select {
        font-size: 14px !important;
        padding: 10px 12px !important;
    }
    
    /* Переключатель типа дела */
    .task-type-switcher {
        gap: 0;
    }
    
    .task-type-switcher .type-btn {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    /* Чек-лист в модалке — как на десктопе */
    .checklist-editor {
        max-height: 220px;
    }
    
    .checklist-editor-item {
        padding: 6px 8px;
        gap: 6px;
        background: var(--bg-secondary);
        border-radius: 8px;
    }
    
    .checklist-checkbox {
        width: 18px;
        height: 18px;
    }
    
    .checklist-checkbox input[type="checkbox"] {
        width: 18px;
        height: 18px;
        accent-color: var(--primary-color);
    }
    
    .checklist-text-input {
        font-size: 14px !important;
        padding: 4px 6px;
    }
    
    .btn-danger-sm {
        opacity: 1 !important;
        padding: 6px;
        font-size: 13px;
    }
    
    .checklist-add-row {
        margin-top: 8px;
    }
    
    .checklist-add-row .personal-task-input {
        font-size: 14px !important;
        padding: 10px 12px !important;
    }
    
    /* Row с приоритетом и напоминанием — в ряд как на десктопе */
    .personal-task-form-row {
        flex-direction: row !important;
        gap: 12px !important;
    }
    
    .personal-task-form-row .form-group-half {
        flex: 1 !important;
        width: auto !important;
    }
    
    .personal-task-form-actions {
        flex-direction: row;
        gap: 10px;
    }
    
    .personal-task-form-actions .btn {
        flex: 1;
        min-height: 44px;
        font-size: 14px;
        justify-content: center;
    }
    
    /* DateTimePicker trigger */
    .datetime-picker-trigger {
        padding: 14px 16px !important;
        font-size: 14px;
    }
    
    /* ===== ЗАКРЕПЛЁННЫЕ КОММЕНТАРИИ — МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    .pinned-comments-section {
        padding: 10px 12px;
        margin-bottom: 14px;
        border-radius: 10px;
    }
    
    .pinned-comments-header {
        font-size: 12px;
    }
    
    .pinned-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    /* Кнопка булавки — увеличенный touch target */
    .pin-btn {
        padding: 8px 10px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }
    
    /* Pin days popup — bottom sheet на мобильном */
    .pin-days-popup {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        border-radius: 20px 20px 0 0 !important;
        min-width: 100% !important;
        width: 100% !important;
        padding: 16px 20px calc(16px + var(--mobile-safe-bottom)) !important;
        animation: slideUp 0.25s ease;
        box-sizing: border-box;
    }
    
    .pin-days-popup-title {
        font-size: 14px;
        padding: 8px;
        text-align: center;
    }
    
    .pin-days-option {
        padding: 14px 16px;
        font-size: 15px;
        border-radius: 10px;
        min-height: var(--touch-target-min);
        justify-content: center;
        text-align: center;
    }
    
    .pin-days-option.pin-forever {
        padding-top: 14px;
    }
    
    /* ===== АНАЛИТИКА — ПОЛНАЯ МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    #page-analytics .page-header {
        padding: var(--mobile-spacing);
    }
    
    #analytics-content {
        padding: 0 var(--mobile-spacing) var(--mobile-spacing) !important;
    }
    
    /* Табы аналитики — горизонтальный скролл */
    .analytics-tabs {
        display: flex !important;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 6px;
        padding-bottom: 12px;
        margin-bottom: 16px;
    }
    
    .analytics-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .analytics-tab {
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .analytics-tab i {
        margin-right: 4px;
    }
    
    /* Фильтры аналитики — вертикальная укладка */
    .analytics-filters {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
        margin-bottom: 16px;
    }
    
    .analytics-filters .filter-group {
        width: 100%;
    }
    
    .analytics-filters select,
    .analytics-filters input[type="date"] {
        width: 100%;
        min-width: unset;
        font-size: 16px;
        padding: 12px;
        border-radius: 10px;
    }
    
    .analytics-filters .filter-checkbox {
        padding: 8px 0;
    }
    
    .analytics-filters .checkbox-inline {
        font-size: 14px;
    }
    
    .analytics-filters .checkbox-inline input {
        width: 20px;
        height: 20px;
    }
    
    .analytics-filters-secondary {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    
    .analytics-filters-secondary select,
    .analytics-filters-secondary input[type="date"] {
        width: 100%;
        font-size: 16px;
    }
    
    /* Карточка воронки */
    .funnel-card {
        border-radius: 14px;
        margin-bottom: 14px;
    }
    
    .funnel-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 16px;
    }
    
    .funnel-title {
        font-size: 15px;
    }
    
    .funnel-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        width: 100%;
    }
    
    .funnel-stats .stat-item {
        padding: 8px 10px;
        min-width: unset;
    }
    
    .funnel-stats .stat-value {
        font-size: 18px;
    }
    
    .funnel-stats .stat-label {
        font-size: 10px;
    }
    
    .funnel-body {
        padding: 12px;
    }
    
    /* Этапы воронки — одна колонка */
    .funnel-stage-row {
        grid-template-columns: 1fr !important;
        gap: 8px;
        padding: 10px;
    }
    
    .stage-info {
        margin-bottom: 4px;
    }
    
    .stage-name {
        font-size: 13px;
        white-space: normal;
    }
    
    .stage-metrics {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .metric-block {
        min-width: 40px;
    }
    
    .metric-value {
        font-size: 14px;
    }
    
    .metric-value.clickable {
        padding: 4px 10px;
        font-size: 14px;
        min-height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .metric-label {
        font-size: 9px;
    }
    
    /* Результаты БП — вертикальная укладка */
    .funnel-results-section {
        flex-direction: column;
        gap: 8px;
    }
    
    .result-card {
        padding: 10px 14px;
    }
    
    .result-percent {
        font-size: 18px;
    }
    
    .result-count.clickable {
        padding: 4px 8px;
        font-size: 13px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
    }
    
    /* Кликабельное количество на этапе */
    .count-clickable {
        padding: 6px 12px;
        font-size: 14px;
        min-height: 34px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Компактная таблица воронки — горизонтальный скролл */
    .funnel-table-compact {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px;
    }
    
    .funnel-table-compact table {
        min-width: 500px;
    }
    
    .funnel-table-compact th,
    .funnel-table-compact td {
        padding: 8px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    /* Custom funnel */
    .custom-funnel-visual {
        padding: 0;
    }
    
    .custom-funnel-row {
        flex-direction: column;
        gap: 4px;
        padding: 8px 0;
    }
    
    .funnel-label {
        padding-left: 0;
    }
    
    .funnel-stage-name {
        font-size: 13px;
    }
    
    .funnel-conv-inline {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .conv-badge {
        font-size: 10px;
    }
    
    .conv-start-inline {
        font-size: 10px;
    }
    
    .custom-funnel-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .custom-funnel-table table {
        min-width: 400px;
    }
    
    /* Сводка по пользователям — горизонтальный скролл */
    .users-summary {
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 8px;
        padding: 12px;
    }
    
    .users-summary .summary-item {
        flex-shrink: 0;
        min-width: 80px;
        padding: 8px 12px;
    }
    
    /* Таблица пользователей */
    .analytics-users-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .analytics-users-table table {
        min-width: 600px;
    }
    
    /* ===== ПОПАП КЛИЕНТОВ НА ЭТАПЕ — BOTTOM SHEET ===== */
    
    .stage-leads-popup {
        align-items: flex-end !important;
    }
    
    .stage-leads-popup-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 85vh !important;
        border-radius: 20px 20px 0 0 !important;
        animation: slideUp 0.3s ease;
    }
    
    .stage-leads-popup-header {
        padding: 14px 20px;
    }
    
    .stage-leads-popup-header h4 {
        font-size: 15px;
    }
    
    .stage-leads-popup-header .popup-close-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
    
    .stage-leads-popup-body {
        padding: 12px 16px;
        padding-bottom: calc(12px + var(--mobile-safe-bottom));
    }
    
    /* Карточки клиентов в попапе */
    .stage-lead-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px;
    }
    
    .stage-lead-item .lead-name {
        font-size: 14px;
    }
    
    .lead-popup-card {
        padding: 12px;
    }
    
    /* ===== КАРТОЧКА КОНТАКТА/ЛИДА — TIMELINE МОБИЛЬНАЯ ===== */
    
    .timeline-item {
        gap: 10px;
    }
    
    .timeline-icon {
        width: 30px;
        height: 30px;
        font-size: 12px;
        flex-shrink: 0;
    }
    
    .timeline-content {
        padding: 12px;
        min-width: 0;
    }
    
    .timeline-content-header {
        flex-direction: column;
        gap: 4px;
    }
    
    .timeline-title {
        font-size: 13px;
    }
    
    .timeline-description {
        font-size: 12px;
        word-break: break-word;
    }
    
    .timeline-meta {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .timeline-meta-item {
        font-size: 11px;
    }
    
    .timeline-actions {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .timeline-actions .btn-icon,
    .timeline-actions .btn {
        min-width: 36px;
        min-height: 36px;
        font-size: 12px;
    }
    
    .timeline-actions .btn-sm {
        padding: 6px 10px;
    }
    
    /* Группы таймлайна */
    .timeline-group {
        margin-bottom: 12px;
    }
    
    .timeline-date {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .timeline-separator {
        margin: 16px 0;
        font-size: 12px;
    }
    
    /* ===== ENTITY VIEW — МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    .entity-view-header {
        padding: 14px 16px;
        gap: 12px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .entity-view-title h1 {
        font-size: 18px !important;
    }
    
    .entity-view-title {
        min-width: 0;
        width: 100%;
    }
    
    .entity-view-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .entity-view-actions .btn {
        flex: 1;
        min-width: 80px;
        justify-content: center;
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .entity-view-badge {
        font-size: 11px;
        padding: 3px 8px;
    }
    
    .lead-view-meta {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    /* Панель информации */
    .entity-info-panel {
        padding: var(--mobile-spacing);
    }
    
    .info-section {
        padding: 12px;
    }
    
    .info-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Форма добавления события/комментария */
    .timeline-add-form {
        padding: 12px;
    }
    
    .timeline-add-form textarea {
        font-size: 16px !important;
        min-height: 80px;
    }
    
    .timeline-add-form .btn {
        min-height: 44px;
    }
    
    /* ===== DASHBOARD — МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    .dashboard-content {
        padding: var(--mobile-spacing);
    }
    
    .dashboard-stats-row {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .dashboard-row.three-columns {
        grid-template-columns: 1fr !important;
    }
    
    .dashboard-card {
        padding: 14px;
        border-radius: 14px;
    }
    
    .dashboard-card-header {
        padding: 12px 14px;
    }
    
    .dashboard-card-header h3 {
        font-size: 14px;
    }
    
    .dashboard-card-body {
        padding: 12px 14px;
    }
    
    /* ===== ПЛАН + РЕЙТИНГ БЛОК ===== */
    .dashboard-plan-rating-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .plan-rating-card {
        padding: 12px !important;
    }
    
    /* Заголовок блока планов/рейтинга */
    .plan-card-title {
        font-size: 12px !important;
        margin-bottom: 10px !important;
    }
    
    .rating-block-title {
        font-size: 12px !important;
        margin-bottom: 8px !important;
    }
    
    /* ===== МИНИ-КАРТОЧКИ ПЛАНОВ ===== */
    .plan-mini-list {
        gap: 8px !important;
    }
    
    .plan-mini-card {
        padding: 10px 12px !important;
        gap: 10px !important;
        flex-wrap: nowrap;
    }
    
    .plan-mini-icon {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }
    
    .plan-mini-info {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }
    
    .plan-mini-label {
        font-size: 10px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .plan-mini-values {
        font-size: 13px !important;
        white-space: nowrap;
        overflow: hidden;
    }
    
    .plan-mini-fact {
        font-size: 13px !important;
    }
    
    .plan-mini-target {
        font-size: 11px !important;
    }
    
    .plan-mini-circle {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
    }
    
    .plan-mini-pct {
        font-size: 9px !important;
    }
    
    /* ===== РЕЙТИНГ — КОМПАКТНАЯ ВЕРСИЯ ===== */
    .rating-table {
        max-height: 220px !important;
    }
    
    .rating-table-header {
        display: none !important;
    }
    
    .rating-row {
        grid-template-columns: 24px 28px 1fr auto !important;
        gap: 8px !important;
        padding: 6px 8px !important;
    }
    
    .rating-col-pos {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .rating-col-num {
        display: none !important;
    }
    
    .rating-col-avatar {
        display: flex !important;
    }
    
    .rating-avatar,
    .rating-avatar-placeholder {
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
    }
    
    .rating-col-name {
        font-size: 13px !important;
        display: block !important;
    }
    
    .rating-col-position {
        display: none !important;
    }
    
    .rating-col-value {
        font-size: 12px !important;
        white-space: nowrap;
    }
    
    .rating-col-plan {
        display: none !important;
    }
    
    .rating-medal {
        font-size: 14px !important;
    }
    
    .rating-medal i {
        font-size: 14px !important;
    }
    
    .rating-empty {
        font-size: 12px !important;
        padding: 16px !important;
    }
    
    /* Планы на дашборде (старые) */
    .plans-row {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .dashboard-plan-card {
        padding: 16px;
    }
    
    .plan-circle-container {
        width: 80px;
        height: 80px;
    }
    
    .plan-percent {
        font-size: 16px;
    }
    
    /* Элементы списка дашборда */
    .dashboard-item {
        padding: 10px 12px;
    }
    
    .dashboard-item .item-title {
        font-size: 13px;
    }
    
    .dashboard-item .item-subtitle {
        font-size: 12px;
    }
    
    .dashboard-item .item-meta {
        font-size: 11px;
        white-space: nowrap;
    }
    
    /* Leads grid дашборд */
    .dashboard-leads-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* ===== FINANCE — МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    .total-balance-card {
        padding: 16px 20px;
        flex-direction: column;
        text-align: center;
    }
    
    .balance-value {
        font-size: 24px;
    }
    
    .accounts-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Таблица транзакций */
    .transactions-table-container,
    .finance-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .transactions-table,
    .finance-table {
        min-width: 500px;
    }
    
    .transactions-summary {
        flex-direction: column;
        gap: 8px;
    }
    
    /* Табы финансов */
    .finance-tabs {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .finance-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .finance-tab {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 13px;
    }
    
    /* Фильтры финансов */
    .finance-filters {
        flex-direction: column;
        gap: 8px;
    }
    
    .finance-filters select {
        width: 100%;
    }
    
    /* ===== KNOWLEDGE BASE — МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    .knowledge-grid {
        grid-template-columns: 1fr !important;
    }
    
    .ql-toolbar.ql-snow {
        padding: 6px !important;
        flex-wrap: wrap;
    }
    
    .ql-editor {
        min-height: 150px !important;
        font-size: 15px !important;
    }
    
    .knowledge-card {
        padding: 14px;
    }
    
    .knowledge-card-header {
        flex-direction: column;
        gap: 8px;
    }
    
    /* ===== УВЕДОМЛЕНИЯ — МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    .notifications-list {
        padding: var(--mobile-spacing);
    }
    
    .notification-item {
        padding: 12px;
        gap: 10px;
    }
    
    .notification-item .notification-text {
        font-size: 13px;
    }
    
    .notification-item .notification-time {
        font-size: 11px;
    }
    
    /* ===== ОТКАЗЫ — МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
    
    #page-rejections .page-toolbar {
        flex-direction: column;
        gap: 8px;
    }
    
    #page-rejections .page-toolbar select,
    #page-rejections .page-toolbar input {
        width: 100%;
    }
    
    /* ===== ТАБЛИЦЫ — ВСЕГДА ГОРИЗОНТАЛЬНЫЙ СКРОЛЛ ===== */
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 600px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
    }
    
}

/* ===== МАЛЕНЬКИЕ ЭКРАНЫ (до 480px) ===== */
@media (max-width: 480px) {
    :root {
        --mobile-spacing: 10px;
    }
    
    .page-header h1 {
        font-size: 18px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .mobile-more-items {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .kanban-column {
        flex: 0 0 90vw !important;
        width: 90vw !important;
        min-width: 90vw !important;
        max-width: 90vw !important;
        margin: 0 2vw !important;
    }
    
    .kanban-column:first-child {
        margin-left: 5vw !important;
    }
    
    .kanban-column:last-child {
        margin-right: 5vw !important;
    }
    
    .modal-footer .btn {
        font-size: 14px;
        padding: 12px 16px;
    }
    
    /* ===== СТРАНИЦА ЗАДАЧ - ХЕДЕР ===== */
    #page-tasks .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    #page-tasks .page-header > div {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-start;
    }
    
    #page-tasks .header-stat-badge {
        padding: 6px 10px;
        font-size: 12px;
        gap: 4px;
        flex: 0 0 auto;
    }
    
    #page-tasks .header-stat-badge span {
        display: none;
    }
    
    #page-tasks .header-stat-badge i {
        font-size: 12px;
    }
    
    #page-tasks .header-stat-badge strong {
        font-size: 13px;
    }
    
    #page-tasks .page-header .btn-primary {
        flex: 1;
        justify-content: center;
        margin-top: 4px;
    }
    
    /* Всего задач - компактнее */
    #page-tasks .page-header > div > div:last-of-type:not(.header-stat-badge) {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* ===== СТРАНИЦА ЗАДАЧ - ТУЛБАР ===== */
    #page-tasks .page-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    
    #page-tasks .toolbar-left {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        flex: 1;
        min-width: 0;
    }
    
    #page-tasks .toolbar-left .search-box {
        flex: 1;
        min-width: 150px !important;
    }
    
    #page-tasks .toolbar-left .filters-toggle {
        flex: 0 0 auto;
    }
    
    #page-tasks .toolbar-left .filters-toggle span:not(.filter-badge) {
        display: none;
    }
    
    #page-tasks .toolbar-left .btn-sm {
        padding: 8px 10px;
    }
    
    #page-tasks .toolbar-right {
        flex: 0 0 auto;
    }
    
    #page-tasks .toolbar-right .btn span {
        display: none;
    }
    
    /* ===== СТРАНИЦА ЛИДЫ - ТУЛБАР ===== */
    #page-leads .page-toolbar {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
    
    #page-leads .toolbar-left {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #page-leads .toolbar-left .search-box {
        flex: 1;
        min-width: 150px;
    }
    
    #page-leads .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    #page-leads .view-toggle {
        flex: 0 0 auto;
    }
    
    #page-leads .toolbar-right .btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
    }
    
    #page-leads .toolbar-right .btn span {
        display: none;
    }
    
    /* ===== ЛИЧНЫЕ ДЕЛА — МАЛЕНЬКИЕ ЭКРАНЫ ===== */
    
    .personal-tasks-page .task-card .task-meta span {
        font-size: 10px;
    }
    
    .personal-tasks-page .section-header h3 {
        font-size: 14px;
    }
    
    .personal-tasks-page .section-header .count {
        font-size: 12px;
    }
    
    .task-type-switcher .type-btn {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .checklist-editor-item {
        gap: 6px;
        padding: 5px 6px;
    }
    
    .checklist-text-input {
        font-size: 13px !important;
    }
    
    /* Карточка клиента на маленьких экранах */
    .entity-view-actions .btn {
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .entity-view-actions .btn span {
        display: none;
    }
    
    /* Аналитика на маленьких экранах */
    .analytics-tabs {
        gap: 4px;
    }
    
    .analytics-tab {
        padding: 7px 10px;
        font-size: 12px;
    }
    
    .analytics-tab i {
        display: none;
    }
    
    .funnel-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .funnel-stats .stat-value {
        font-size: 16px;
    }
    
    .funnel-card-header {
        padding: 10px 12px;
    }
    
    .funnel-body {
        padding: 10px;
    }
    
    .result-card {
        padding: 8px 12px;
    }
    
    .result-percent {
        font-size: 16px;
    }
    
    /* Dashboard маленькие экраны */
    .dashboard-card-header h3 {
        font-size: 13px;
    }
    
    .dashboard-item {
        padding: 8px 10px;
    }
    
    .dashboard-item .item-title {
        font-size: 12px;
    }
    
    /* Планы — ещё компактнее */
    .plan-mini-card {
        padding: 8px 10px !important;
        gap: 8px !important;
    }
    
    .plan-mini-icon {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        font-size: 12px !important;
    }
    
    .plan-mini-label {
        font-size: 9px !important;
    }
    
    .plan-mini-values {
        font-size: 12px !important;
    }
    
    .plan-mini-circle {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }
    
    .plan-mini-pct {
        font-size: 8px !important;
    }
    
    /* Рейтинг — ещё компактнее */
    .rating-row {
        grid-template-columns: 22px 24px 1fr auto !important;
        gap: 6px !important;
        padding: 5px 6px !important;
    }
    
    .rating-avatar,
    .rating-avatar-placeholder {
        width: 24px !important;
        height: 24px !important;
        font-size: 10px !important;
    }
    
    .rating-col-name {
        font-size: 12px !important;
    }
    
    .rating-col-value {
        font-size: 11px !important;
    }
    
    .rating-medal,
    .rating-medal i {
        font-size: 12px !important;
    }
    
    /* Timeline маленькие экраны */
    .timeline-icon {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
    
    .timeline-content {
        padding: 10px;
    }
    
    .timeline-title {
        font-size: 12px;
    }
    
    .timeline-description {
        font-size: 11px;
    }
    
    .timeline-actions .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
        min-width: 32px;
        min-height: 32px;
    }
    
    /* Попап клиентов — маленькие экраны */
    .stage-leads-popup-header {
        padding: 12px 16px;
    }
    
    .stage-leads-popup-body {
        padding: 10px 12px;
    }
    
    .stage-lead-item {
        padding: 10px;
    }
}

/* ===== КОММЕНТАРИИ МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
@media (max-width: 768px) {
    .timeline-quick-add {
        padding: 10px 12px;
        gap: 8px;
    }
    
    .comment-type-select {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .comment-compose {
        border-radius: 10px;
    }
    
    .comment-textarea {
        font-size: 15px;
        padding: 10px 12px 6px;
        min-height: 38px;
    }
    
    .comment-toolbar {
        padding: 2px 6px 6px;
    }
    
    .color-picker-dropdown {
        left: 0;
        right: auto;
    }
    
    .comment-edit-form {
        gap: 6px;
    }
    
    .comment-edit-textarea {
        font-size: 15px;
    }
    
    .comment-edit-actions {
        flex-wrap: wrap;
    }
    
    .comment-edit-colors {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Чек-лист в timeline на мобильном */
    .checklist-compose {
        padding: 10px;
        border-radius: 10px;
    }
    
    .checklist-title-input {
        font-size: 15px;
    }
    
    .checklist-item-input {
        font-size: 14px;
        padding: 8px 10px;
    }
    
    .checklist-timeline-label {
        font-size: 14px;
        padding: 4px 0;
    }
    
    .checklist-timeline-checkmark {
        width: 20px;
        height: 20px;
        min-width: 20px;
    }
    
    .checklist-add-row {
        flex-wrap: wrap;
    }
    
    /* Форма редактирования чек-листа */
    .checklist-edit-form {
        gap: 6px;
    }
    
    .checklist-edit-title {
        font-size: 15px;
        padding: 8px 10px;
    }
    
    .checklist-edit-text {
        font-size: 14px;
        padding: 6px 8px;
    }
    
    .checklist-edit-item {
        gap: 8px;
    }
    
    .checklist-edit-actions {
        flex-wrap: wrap;
    }
}

/* ===== MOBILE CHAT ===== */
@media (max-width: 600px) {
    #page-chat {
        display: none;
        flex-direction: column;
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));
        height: auto !important;
        overflow: hidden;
        z-index: 100;
        background: #fff;
        padding: 0 !important;
        margin: 0 !important;
    }
    #page-chat.active {
        display: flex !important;
    }

    .mchat-view {
        display: none;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
    .mchat-view.active {
        display: flex;
    }

    /* Room list */
    .mchat-search {
        padding: 8px 12px;
        border-bottom: 1px solid #f1f5f9;
    }
    .mchat-search input {
        width: 100%;
        padding: 10px 14px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        font-size: 14px;
        background: #f8fafc;
        box-sizing: border-box;
    }
    .mchat-search input:focus {
        border-color: #3b82f6;
        outline: none;
        background: #fff;
    }

    .mchat-room-list {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mchat-room-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        cursor: pointer;
        border-bottom: 1px solid #f8fafc;
        transition: background 0.12s;
    }
    .mchat-room-item:active {
        background: #f1f5f9;
    }
    .mchat-room-item.unread {
        background: #eff6ff;
    }

    .mchat-avatar {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: #e2e8f0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #64748b;
        font-size: 16px;
        font-weight: 600;
        flex-shrink: 0;
        overflow: hidden;
    }
    .mchat-avatar.sm {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    .mchat-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mchat-room-body {
        flex: 1;
        min-width: 0;
    }
    .mchat-room-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }
    .mchat-room-name {
        font-size: 14px;
        font-weight: 600;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }
    .mchat-room-time {
        font-size: 11px;
        color: #94a3b8;
        flex-shrink: 0;
    }
    .mchat-room-bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        margin-top: 3px;
    }
    .mchat-room-last {
        font-size: 13px;
        color: #64748b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }
    .mchat-room-badge {
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        background: #3b82f6;
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .mchat-bottom-actions {
        display: flex;
        gap: 8px;
        padding: 10px 16px;
        border-top: 1px solid #f1f5f9;
        flex-shrink: 0;
    }
    .mchat-action-btn {
        flex: 1;
        padding: 10px;
        border: 2px dashed #e2e8f0;
        border-radius: 12px;
        background: transparent;
        color: #64748b;
        font-size: 13px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    .mchat-action-btn:active {
        border-color: #3b82f6;
        color: #3b82f6;
        background: #eff6ff;
    }

    .mchat-empty {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        color: #94a3b8;
        font-size: 14px;
        gap: 10px;
    }
    .mchat-empty i {
        font-size: 40px;
        opacity: 0.4;
    }

    /* Message header */
    .mchat-msg-header {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-bottom: 1px solid #f1f5f9;
        flex-shrink: 0;
        background: #fff;
        transition: background 0.2s;
    }
    .mchat-msg-header-client {
        background: linear-gradient(135deg, #c2410c 0%, #ea580c 100%) !important;
        border-bottom-color: #ea580c !important;
    }
    .mchat-msg-header-client .mchat-back-btn,
    .mchat-msg-header-client .mchat-settings-btn,
    .mchat-msg-header-client .mchat-msg-title {
        color: #fff !important;
    }
    .mchat-back-btn,
    .mchat-settings-btn {
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        background: #f1f5f9;
        border-radius: 10px;
        cursor: pointer;
        color: #64748b;
        font-size: 14px;
        flex-shrink: 0;
    }
    .mchat-back-btn:active,
    .mchat-settings-btn:active {
        background: #e2e8f0;
    }
    .mchat-msg-title {
        flex: 1;
        font-size: 15px;
        font-weight: 600;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Messages */
    .mchat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 12px;
        display: flex;
        flex-direction: column;
        gap: 4px;
        background: #fafbfc;
    }

    .mchat-date-sep {
        text-align: center;
        font-size: 12px;
        color: #94a3b8;
        padding: 10px 0 6px;
    }

    .mchat-msg {
        display: flex;
        max-width: 88%;
    }
    .mchat-msg.mine {
        align-self: flex-end;
    }
    .mchat-msg.theirs {
        align-self: flex-start;
    }

    .mchat-bubble {
        padding: 8px 12px;
        border-radius: 16px;
        font-size: 14px;
        line-height: 1.4;
        word-break: break-word;
        position: relative;
    }
    .mchat-msg.mine .mchat-bubble {
        background: linear-gradient(135deg, #3b82f6, #2563eb);
        color: #fff;
        border-bottom-right-radius: 4px;
    }
    .mchat-msg.theirs .mchat-bubble {
        background: #f1f5f9;
        color: #1e293b;
        border-bottom-left-radius: 4px;
    }
    .mchat-bubble.deleted {
        font-style: italic;
        opacity: 0.5;
        font-size: 13px;
    }

    .mchat-sender-name {
        font-size: 11px;
        font-weight: 600;
        opacity: 0.7;
        margin-bottom: 2px;
    }

    .mchat-reply {
        padding: 4px 8px;
        margin-bottom: 4px;
        border-radius: 8px;
        font-size: 12px;
        border-left: 3px solid;
    }
    .mchat-msg.mine .mchat-reply {
        background: rgba(255,255,255,0.15);
        border-left-color: rgba(255,255,255,0.5);
    }
    .mchat-msg.theirs .mchat-reply {
        background: rgba(0,0,0,0.04);
        border-left-color: #3b82f6;
    }
    .mchat-reply-name {
        font-weight: 600;
        font-size: 11px;
    }
    .mchat-reply-txt {
        margin-top: 1px;
        opacity: 0.85;
    }

    .mchat-bubble-img {
        max-width: 240px;
        max-height: 200px;
        border-radius: 12px;
        cursor: pointer;
        margin-bottom: 2px;
    }
    .mchat-bubble-text {}
    .mchat-bubble-file {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-top: 4px;
    }
    .mchat-bubble-file a {
        font-size: 13px;
        text-decoration: underline;
    }
    .mchat-msg.mine .mchat-bubble-file a { color: rgba(255,255,255,0.9); }
    .mchat-msg.theirs .mchat-bubble-file a { color: #3b82f6; }

    .mchat-bubble-meta {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-top: 3px;
        font-size: 10px;
        opacity: 0.6;
        justify-content: flex-end;
    }
    .mchat-edited {
        font-style: italic;
    }

    .mchat-msg-actions {
        display: none;
        position: absolute;
        top: -32px;
        right: 0;
        background: #fff;
        border-radius: 10px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.14);
        padding: 4px;
        gap: 2px;
        z-index: 10;
    }
    .mchat-bubble:active .mchat-msg-actions {
        display: flex;
    }
    .mchat-msg-actions button {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        background: transparent;
        color: #64748b;
        border-radius: 8px;
        cursor: pointer;
        font-size: 12px;
    }
    .mchat-msg-actions button:active {
        background: #f1f5f9;
    }

    /* Typing */
    .mchat-typing {
        display: none;
        padding: 4px 14px;
        font-size: 12px;
        color: #94a3b8;
        font-style: italic;
    }
    .mchat-typing.active { display: block; }

    /* Reply bar */
    .mchat-reply-bar {
        display: none;
        align-items: center;
        gap: 8px;
        padding: 8px 14px;
        border-top: 1px solid #f1f5f9;
        background: #fafbfc;
        font-size: 13px;
        color: #64748b;
    }
    .mchat-reply-bar.active { display: flex; }
    .mchat-reply-text {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Input area */
    .mchat-input-area {
        display: flex;
        align-items: flex-end;
        gap: 8px;
        padding: 8px 12px;
        padding-bottom: calc(8px + var(--mobile-safe-bottom));
        border-top: 1px solid #f1f5f9;
        background: #fff;
        flex-shrink: 0;
    }
    .mchat-input-field {
        flex: 1;
        min-height: 40px;
        max-height: 100px;
        padding: 10px 14px;
        border: 1px solid #e2e8f0;
        border-radius: 20px;
        font-size: 14px;
        resize: none;
        overflow-y: auto;
        font-family: inherit;
        line-height: 1.4;
        box-sizing: border-box;
    }
    .mchat-input-field:focus {
        border-color: #3b82f6;
        outline: none;
    }
    .mchat-input-btn {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        font-size: 16px;
        flex-shrink: 0;
        background: #f1f5f9;
        color: #64748b;
    }
    .mchat-input-btn:active {
        background: #e2e8f0;
    }
    .mchat-send-btn {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        font-size: 16px;
        flex-shrink: 0;
        background: #3b82f6;
        color: #fff;
    }
    .mchat-send-btn:active {
        background: #2563eb;
    }

    /* User list */
    .mchat-user-list {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mchat-user-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        cursor: pointer;
        border-bottom: 1px solid #f8fafc;
    }
    .mchat-user-item:active {
        background: #f1f5f9;
    }
    .mchat-user-item.selected {
        background: #eff6ff;
    }
    .mchat-user-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
    }
    .mchat-user-avatar.sm {
        width: 32px;
        height: 32px;
    }
    .mchat-user-info {
        flex: 1;
        min-width: 0;
    }
    .mchat-user-name {
        font-size: 14px;
        font-weight: 600;
        color: #1e293b;
    }
    .mchat-user-role {
        font-size: 12px;
        color: #94a3b8;
        margin-top: 1px;
    }
    .mchat-online-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #22c55e;
        flex-shrink: 0;
    }

    /* Checkbox for group */
    .mchat-checkbox {
        width: 24px;
        height: 24px;
        border: 2px solid #cbd5e1;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-size: 12px;
        flex-shrink: 0;
        transition: all 0.15s;
    }
    .mchat-checkbox.checked {
        background: #3b82f6;
        border-color: #3b82f6;
    }

    /* Group fields */
    .mchat-label {
        font-size: 13px;
        font-weight: 600;
        color: #64748b;
        display: block;
        margin-bottom: 6px;
    }
    .mchat-field {
        width: 100%;
        padding: 10px 14px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        font-size: 14px;
        box-sizing: border-box;
    }
    .mchat-field:focus {
        border-color: #3b82f6;
        outline: none;
    }
    .mchat-create-group-btn {
        width: 100%;
        padding: 12px;
        border: none;
        border-radius: 12px;
        background: #3b82f6;
        color: #fff;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    .mchat-create-group-btn:active {
        background: #2563eb;
    }

    /* Chat info */
    .mchat-info-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
    }
    .mchat-info-header {
        text-align: center;
        padding-bottom: 16px;
        border-bottom: 1px solid #f1f5f9;
        margin-bottom: 12px;
    }
    .mchat-info-big-icon {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        background: #eff6ff;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 10px;
        font-size: 28px;
        color: #3b82f6;
    }
    .mchat-info-big-avatar {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        object-fit: cover;
        display: block;
        margin: 0 auto 10px;
    }
    .mchat-info-title {
        font-size: 18px;
        font-weight: 700;
        color: #1e293b;
    }
    .mchat-info-sub {
        font-size: 13px;
        color: #94a3b8;
        margin-top: 2px;
    }
    .mchat-info-section {
        padding: 12px 0;
        border-bottom: 1px solid #f1f5f9;
    }
    .mchat-info-section:last-child { border-bottom: none; }

    .mchat-info-label {
        font-size: 12px;
        font-weight: 600;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        margin-bottom: 10px;
    }
    .mchat-info-row {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        padding: 12px 0;
        border: none;
        background: transparent;
        font-size: 14px;
        color: #1e293b;
        cursor: pointer;
        text-align: left;
    }
    .mchat-info-row i {
        width: 22px;
        text-align: center;
        color: #64748b;
        font-size: 15px;
    }
    .mchat-info-row.add {
        color: #3b82f6;
    }
    .mchat-info-row.add i { color: #3b82f6; }
    .mchat-info-row.danger {
        color: #ef4444;
    }
    .mchat-info-row.danger i { color: #ef4444; }

    .mchat-participant-row {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 0;
    }
    .mchat-remove-btn {
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        background: transparent;
        color: #ef4444;
        cursor: pointer;
        border-radius: 8px;
        font-size: 12px;
    }
    .mchat-remove-btn:active {
        background: #fef2f2;
    }

    .mchat-small-btn {
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        flex-shrink: 0;
    }
    .mchat-small-btn.primary {
        background: #3b82f6;
        color: #fff;
    }
    .mchat-small-btn.primary:active {
        background: #2563eb;
    }

    /* Badge on mobile nav */
    .mobile-chat-badge {
        position: absolute;
        top: 2px;
        right: calc(50% - 20px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        background: #ef4444;
        color: #fff;
        font-size: 9px;
        font-weight: 700;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 4px rgba(239,68,68,0.4);
    }
    .mobile-chat-badge:empty {
        display: none;
    }

    .mchat-header-badge {
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        background: #ef4444;
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mchat-header-badge:empty {
        display: none;
    }

    /* Hide desktop chat popup on mobile */
    .chat-popup,
    .chat-trigger-btn {
        display: none !important;
    }
}

/* ===== PWA STANDALONE MODE ===== */
@media (display-mode: standalone) {
    .main-content {
        padding-top: var(--mobile-safe-top) !important;
    }
    
    .mobile-nav {
        padding-bottom: var(--mobile-safe-bottom);
    }
}

