        /* Mobile optimizations */
        @media (max-width: 767px) {
            html, body {
                min-width: 0;
                width: 100%;
                overflow-x: hidden;
            }
            .filters {
                display: flex;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                padding-bottom: 0.5rem;
                gap: 0.5rem;
            }
            
            .filter-select {
                flex: 0 0 auto;
                min-width: 130px;
                font-size: 0.8rem;
                padding: 0.5rem;
            }
            
            .status-multiselect {
                flex: 0 0 auto;
                min-width: 130px;
            }
            .status-multiselect-toggle {
                font-size: 0.8rem;
                padding: 0.5rem;
            }
            
            .task-card {
                padding: 0.75rem;
            }
            
            .task-title {
                font-size: 0.9rem;
            }
            
            .task-deadline-row {
                font-size: 0.8rem;
                gap: 0.5rem;
            }
            
            .task-meta {
                gap: 0.3rem;
            }
            
            .task-meta-item {
                font-size: 0.75rem;
            }
            
            .task-detail {
                font-size: 0.75rem;
                padding: 0.3rem 0.5rem;
            }
            
            .btn {
                padding: 0.6rem 0.8rem;
                font-size: 0.8rem;
            }
            
            .btn-small {
                padding: 0.35rem 0.5rem;
                font-size: 0.75rem;
                min-height: 44px;
                min-width: 44px;
            }
            
            .total-time-badge {
                font-size: 0.75rem;
                padding: 0.4rem 0.8rem;
            }
            
            .controls-row {
                justify-content: space-between;
                width: 100%;
            }
            
            .modal-content {
                margin-top: 0;
                border-radius: var(--radius) var(--radius) 0 0;
                max-height: 95vh;
            }
            
            .form-input, .form-select, .form-textarea {
                font-size: 16px; /* Prevents zoom on iOS */
            }
            
            /* Hide table on mobile */
            .tasks-table { display: none !important; }
            
            /* Mobile task cards */
            .mobile-tasks-list { display: block; }
            
            .mobile-task-card {
                background: transparent;
                border-radius: 0;
                margin-bottom: 0;
                position: relative;
                overflow: hidden;
            }
            
            .mobile-task-content {
                background: white;
                padding: 1rem 1rem;
                border-left: 4px solid var(--gray);
                position: relative;
                z-index: 2;
                transition: transform 0.15s ease-out, opacity 0.2s, background 0.15s;
                border-bottom: 1px solid #f0f0f0;
                min-height: 56px;
                -webkit-tap-highlight-color: transparent;
            }
            
            .mobile-task-content:active {
                background: #f3f4f6;
                transform: scale(0.985);
            }
            
            .mobile-task-card.status-new .mobile-task-content { border-left-color: #3498db; }
            .mobile-task-card.status-progress .mobile-task-content { border-left-color: #f39c12; }
            .mobile-task-card.status-review .mobile-task-content { border-left-color: #9b59b6; }
            .mobile-task-card.status-done .mobile-task-content { border-left-color: #27ae60; opacity: 0.65; }
            .mobile-task-card.overdue .mobile-task-content { border-left-color: #e74c3c; }
            .mobile-task-card.pinned .mobile-task-content { border-left-color: #e74c3c; background: #fff5f5; }
            
            .mobile-task-header {
                display: flex;
                justify-content: space-between;
                align-items: flex-start;
                gap: 0.5rem;
                margin-bottom: 0.35rem;
            }
            
            .mobile-task-title {
                font-weight: 600;
                font-size: 0.9rem;
                color: #1a1a1a;
                flex: 1;
                line-height: 1.3;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                overflow: hidden;
            }
            
            .mobile-task-title-done {
                text-decoration: line-through;
                color: #999;
            }
            
            .mobile-task-deadline-badge {
                flex-shrink: 0;
                font-size: 0.75rem;
                font-weight: 500;
                padding: 0.15rem 0.5rem;
                border-radius: 6px;
                white-space: nowrap;
            }
            
            .mobile-task-deadline-badge.overdue {
                background: #fef2f2;
                color: #dc2626;
            }
            
            .mobile-task-deadline-badge.today {
                background: #fffbeb;
                color: #d97706;
            }
            
            .mobile-task-deadline-badge.upcoming {
                color: #6b7280;
            }
            
            .mobile-task-status {
                flex-shrink: 0;
            }
            
            .mobile-task-meta {
                display: flex;
                flex-wrap: wrap;
                gap: 0.4rem;
                font-size: 0.75rem;
                color: #888;
                align-items: center;
            }
            
            .mobile-task-meta-item {
                display: flex;
                align-items: center;
                gap: 0.2rem;
            }
            
            .mobile-task-meta-item .icon {
                width: 13px;
                height: 13px;
            }
            
            .mobile-task-meta-item.deadline-overdue {
                color: #e74c3c;
                font-weight: 600;
            }
            
            .mobile-task-meta-item.deadline-today {
                color: #f57c00;
                font-weight: 600;
            }
            
            .mobile-task-meta-sep {
                color: #ddd;
                font-size: 0.6rem;
            }
            
            /* Аватар ініціали */
            .mobile-task-avatar {
                width: 28px;
                height: 28px;
                border-radius: 50%;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 0.65rem;
                font-weight: 700;
                color: white;
                flex-shrink: 0;
            }
            
            /* Badges row — коментарі, файли, чеклист */
            .mobile-task-badges {
                display: flex;
                align-items: center;
                gap: 0.6rem;
                margin-top: 0.35rem;
            }
            
            .mobile-badge {
                display: flex;
                align-items: center;
                gap: 0.2rem;
                font-size: 0.7rem;
                color: #999;
            }
            
            .mobile-badge .icon {
                width: 13px;
                height: 13px;
            }
            
            .mobile-badge.has-items {
                color: #22c55e;
                font-weight: 600;
            }
            
            .mobile-task-actions {
                display: flex;
                gap: 0.4rem;
                padding-top: 0.6rem;
                border-top: 1px solid #f0f0f0;
                margin-top: 0.4rem;
            }
            
            .mobile-action-btn {
                flex: 1;
                display: flex;
                align-items: center;
                justify-content: center;
                gap: 0.3rem;
                padding: 0.55rem;
                border: none;
                border-radius: 8px;
                font-size: 0.8rem;
                font-weight: 500;
                cursor: pointer;
                min-height: 44px;
                transition: all 0.15s;
                touch-action: manipulation;
                -webkit-tap-highlight-color: transparent;
            }
            
            .mobile-action-btn.delete {
                flex: 0 0 44px;
                max-width: 44px;
            }
            
            .mobile-action-btn.complete {
                background: #e8f5e9;
                color: #2e7d32;
            }
            
            .mobile-action-btn.edit {
                background: #e3f2fd;
                color: #1565c0;
            }
            
            .mobile-action-btn.delete {
                background: #ffebee;
                color: #c62828;
            }
            
            .mobile-action-btn:active {
                transform: scale(0.95);
            }

        /* ══════════════════════════════════════
           КООРДИНАЦІЇ — мобільний вигляд
           ══════════════════════════════════════ */
        #coordinationRoot > div {
            padding: 0.5rem !important;
        }

        /* Картки координацій — на всю ширину */
        #coordList > div > div[style*="grid"] {
            grid-template-columns: 1fr !important;
        }

        /* Сесія координації — одна колонка */
        #coordSessionModal .modal-content > div[style*="grid-template-columns"] {
            grid-template-columns: 1fr !important;
        }

        /* Протокол модалка — на всю ширину */
        #coordProtocolModal .modal-content,
        #coordAnalysisModal .modal-content,
        #coordModal .modal-content,
        #coordDynAgendaModal .modal-content {
            max-width: 100% !important;
            width: 100% !important;
            margin: 0 !important;
            border-radius: 16px 16px 0 0 !important;
            max-height: 95vh !important;
        }

        /* Сесія — повноекранна */
        #coordSessionModal .modal-content {
            max-width: 100% !important;
            width: 100% !important;
            margin: 0 !important;
            border-radius: 0 !important;
            max-height: 100vh !important;
            min-height: 100vh !important;
        }

        /* ══════════════════════════════════════
           КОНТРОЛЬ — мобільний вигляд  
           ══════════════════════════════════════ */
        #controlTab .control-grid,
        #controlTab [style*="grid-template-columns"] {
            grid-template-columns: 1fr !important;
        }

        /* ══════════════════════════════════════
           ПРОЦЕСИ — мобільний вигляд
           ══════════════════════════════════════ */
        #processesTab [style*="grid-template-columns: repeat"] {
            grid-template-columns: 1fr !important;
        }

        /* ══════════════════════════════════════
           МОДАЛКИ — загальне на мобільному
           ══════════════════════════════════════ */
        .modal-content[style*="max-width:580px"],
        .modal-content[style*="max-width:640px"],
        .modal-content[style*="max-width:680px"],
        .modal-content[style*="max-width:900px"],
        .modal-content[style*="max-width:920px"] {
            max-width: 100% !important;
            width: 100% !important;
            margin: auto 0 0 !important;
            border-radius: 16px 16px 0 0 !important;
        }

        /* Кнопки в рядок — не стискаються */
        .modal-content button,
        .modal-content .btn {
            min-height: 44px;
            touch-action: manipulation;
        }

        }
        
        /* Desktop: show table, hide mobile cards */
        @media (min-width: 768px) {
            .mobile-tasks-list { display: none !important; }
            .tasks-table { display: table !important; }
            .bottom-nav { display: none !important; }
            .fab-add { display: none !important; }
            .mobile-filter-bar { display: none !important; }
            .filters-row:not(#calendarFiltersRow) { display: flex !important; }
            .controls-row .btn { display: inline-flex !important; }
        }
        
        /* Bottom Navigation for Mobile */
        .bottom-nav {
            display: none;
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: white;
            box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
            z-index: 900;
            padding: 0.4rem 0;
            padding-bottom: calc(0.4rem + env(safe-area-inset-bottom));
            border-top: 1px solid #f0f0f0;
        }
        
        .bottom-nav-items {
            display: flex;
            justify-content: space-around;
            max-width: 500px;
            margin: 0 auto;
        }
        
        .bottom-nav-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.15rem;
            padding: 0.4rem 0.3rem;
            background: none;
            border: none;
            color: #b0b8c4;
            font-size: 0.6rem;
            font-weight: 500;
            cursor: pointer;
            border-radius: 10px;
            min-width: 60px;
            min-height: 48px;
            transition: color 0.15s, transform 0.1s;
            position: relative;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
        }
        
        .bottom-nav-btn .icon {
            width: 22px;
            height: 22px;
            transition: all 0.2s;
        }
        
        .bottom-nav-btn.active {
            color: var(--primary);
            background: transparent;
        }
        
        .bottom-nav-btn.active .icon {
            transform: scale(1.1);
        }
        
        .bottom-nav-btn.active::after {
            content: '';
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 20px;
            height: 3px;
            background: var(--primary);
            border-radius: 0 0 3px 3px;
        }
        
        .bottom-nav-btn:active {
            transform: scale(0.92);
        }
        
        @media (max-width: 767px) {
            .bottom-nav { display: block; }
            .tab-navigation { display: none !important; }
            .main-interface { padding-bottom: 80px; }
            .hide-mobile { display: none !important; }
            .support-btn { bottom: 80px; }
            
            /* Compact mobile header */
            .header {
                padding: 0.5rem 0.75rem;
                position: sticky;
                top: 0;
            }
            
            .header .header-ai-btn,
            .header .lang-switcher,
            .header .user-info,
            .header #logoutBtn,
            .header #demoDataBtnDesktop {
                display: none !important;
            }
            
            .logo {
                font-size: 0.95rem;
            }
            
            .header-actions {
                gap: 0.25rem;
            }
            
            /* Mobile logout icon only */
            .header .mobile-logout-btn {
                display: flex !important;
                background: rgba(255,255,255,0.15);
                border: none;
                color: white;
                width: 36px;
                height: 36px;
                border-radius: 50%;
                align-items: center;
                justify-content: center;
                cursor: pointer;
            }
            
            .container {
                padding: 0.5rem;
            }
            
            /* Tab content title — compact */
            .tab-content h3 {
                font-size: 0.95rem;
                margin-bottom: 0.5rem;
            }
            
            /* Fullscreen modals on mobile - only main editing modals */
            .modal {
                padding: 0;
            }
            
            #taskModal .modal-content,
            #regularTaskModal .modal-content,
            #processTemplatesModal .modal-content,
            #projectModal .modal-content {
                border-radius: 0;
                max-height: 100vh;
                min-height: 100vh;
                margin: 0;
                max-width: 100%;
                animation: slideUpModal 0.25s ease-out;
            }
            
            @keyframes slideUpModal {
                from { transform: translateY(40px); opacity: 0.8; }
                to { transform: translateY(0); opacity: 1; }
            }
            
            /* Smaller modals stay compact */
            #demoDataModal .modal-content,
            #profileModal .modal-content,
            #filterModal .modal-content {
                border-radius: 16px;
                min-height: auto;
                max-height: 90vh;
                margin: auto;
                max-width: 95%;
            }
            
            /* Mobile menu - bottom sheet */
            #mobileMenuModal .modal-content {
                min-height: auto;
                max-height: none;
            }
            
            .modal-header {
                border-radius: 0;
                padding: 0.75rem 1rem;
                position: sticky;
                top: 0;
            }
            
            .modal-header h2 {
                font-size: 1rem;
            }
            
            .modal-body {
                padding: 0.75rem;
            }
            
            /* Smooth card shadows */
            .task-card, .process-pipeline-row, .project-card {
                box-shadow: 0 1px 3px rgba(0,0,0,0.06);
                border: 1px solid #f0f0f0;
            }
            
            /* Empty states compact */
            .empty-state {
                padding: 2rem 1rem;
            }
            
            .empty-state h3 {
                font-size: 1rem;
            }
            
            /* FAB for adding tasks */
            .fab-add {
                position: fixed;
                bottom: 90px;
                right: 16px;
                width: 56px;
                height: 56px;
                border-radius: 50%;
                background: var(--success);
                color: white;
                border: none;
                box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
                cursor: pointer;
                z-index: 899;
                display: flex;
                align-items: center;
                justify-content: center;
                transition: all 0.2s;
            }
            
            .fab-add:active {
                transform: scale(0.9);
            }
            
            .fab-add .icon {
                width: 24px;
                height: 24px;
            }
            
            /* Hide desktop add buttons on mobile */
            .controls .btn-success:first-child { display: none; }
            
            /* Compact mobile header */
            .header-container {
                padding: 0.5rem 1rem;
            }
            
            .header-logo {
                font-size: 1rem;
            }
            
            .header-logo .company-badge {
                display: none !important;
            }
            
            .header-actions {
                gap: 0.5rem;
            }
            
            /* Hide AI buttons, support link, lang switcher on mobile */
            .header-ai-btn { display: none !important; }
            #aiDropdown { display: none !important; }
            .header-actions > a[href*="chatgpt"] { display: none !important; }
            .header-actions > .hdr-dropdown:not(#notifDropdown):not(#userDropdown) { display: none !important; }
            .header-btn span { display: none; }
            .header-btn { 
                padding: 0.5rem; 
                border-radius: 50%;
                min-width: 40px;
                min-height: 40px;
                display: flex;
                align-items: center;
                justify-content: center;
            }
            .header-btn .icon { margin: 0; }
            
            .lang-switcher { display: none; }
            .user-info { display: none !important; }

            /* Дзвіночок — завжди видимий на мобільному */
            #notificationBell {
                display: flex !important;
                align-items: center;
                justify-content: center;
                min-width: 36px;
                min-height: 36px;
                flex-shrink: 0;
            }
            
            /* Pull-to-refresh */
            .ptr-indicator {
                text-align: center;
                padding: 0;
                overflow: hidden;
                height: 0;
                transition: height 0.2s;
                color: var(--primary);
                font-size: 0.85rem;
                font-weight: 500;
                display: flex;
                align-items: center;
                justify-content: center;
                gap: 0.4rem;
            }
            
            .ptr-indicator.pulling {
                height: 50px;
            }
            
            .ptr-indicator.refreshing {
                height: 50px;
            }
            
            .ptr-spinner {
                width: 20px;
                height: 20px;
                border: 2px solid #e5e7eb;
                border-top-color: var(--primary);
                border-radius: 50%;
                animation: spin 0.6s linear infinite;
            }
            
            @keyframes spin {
                to { transform: rotate(360deg); }
            }
            
            /* Swipe to complete */
            .mobile-task-card {
                position: relative;
                overflow: hidden;
                touch-action: pan-y;
                transition: transform 0.2s ease-out;
            }

/* ══════════════════════════════════════════════════════════
   MOBILE UX — iPhone-style: щільність, центрування, touch
   ══════════════════════════════════════════════════════════ */

@media (max-width: 767px) {

    /* ── 1. Модалка завдання — повноекранна, без зазорів ── */
    #taskModal .modal-content,
    #regularTaskModal .modal-content {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
        display: flex;
        flex-direction: column;
    }

    /* ── 2. Modal body — компактний padding, весь простір ── */
    #taskModal .modal-body,
    #regularTaskModal .modal-body {
        padding: 0.65rem 0.75rem !important;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ── 3. form-grid — завжди 1 колонка на мобільному ──── */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 0.55rem !important;
    }
    .form-group.full-width {
        grid-column: span 1 !important;
    }

    /* ── 4. form-group — щільніше (iPhone Settings стиль) ─ */
    .form-group {
        margin-bottom: 0 !important;
    }
    .form-label {
        font-size: 0.78rem !important;
        margin-bottom: 0.25rem !important;
        color: #6b7280 !important;
        font-weight: 500 !important;
    }

    /* ── 5. Inputs — висота 44px (Apple HIG мінімум) ─────── */
    .form-input,
    .form-select {
        padding: 0.6rem 0.75rem !important;
        font-size: 16px !important; /* запобігає zoom на iOS */
        min-height: 44px !important;
        border-radius: 10px !important;
        border: 1.5px solid #e5e7eb !important;
        background: #fafafa !important;
    }
    .form-input:focus,
    .form-select:focus {
        background: #fff !important;
        border-color: #22c55e !important;
    }
    .form-textarea {
        font-size: 16px !important;
        padding: 0.6rem 0.75rem !important;
        border-radius: 10px !important;
        border: 1.5px solid #e5e7eb !important;
        min-height: 80px !important;
    }

    /* ── 6. Два поля в рядку → стек на мобільному ────────── */
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    [style*="grid-template-columns:1fr 2fr"],
    [style*="grid-template-columns: 1fr 2fr"] {
        grid-template-columns: 1fr !important;
    }
    [style*="grid-template-columns:2fr 1fr"],
    [style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    [style*="grid-template-columns:repeat(auto-fit"],
    [style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr !important;
    }

    /* ── 7. Кнопки дій — великі, повна ширина ────────────── */
    .form-actions {
        padding: 0.75rem !important;
        gap: 0.5rem !important;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid #f0f0f0;
        margin-top: 0 !important;
    }
    .form-actions .btn {
        flex: 1 !important;
        min-height: 48px !important;
        font-size: 0.95rem !important;
        border-radius: 12px !important;
        justify-content: center;
    }

    /* ── 8. Modal header — компактний ────────────────────── */
    .modal-header {
        padding: 0.75rem 1rem !important;
        min-height: 52px;
    }
    .modal-header h2 {
        font-size: 0.95rem !important;
    }

    /* ── 9. Accordion розширені налаштування ─────────────── */
    #taskAdvancedToggle {
        min-height: 44px !important;
        font-size: 0.82rem !important;
    }
    #taskAdvancedPanel {
        grid-template-columns: 1fr !important;
    }

    /* ── 10. CRM slide-in — повна висота, без обрізання ──── */
    #crmTodoCardOverlay > div {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 0 !important;
    }

    /* ── 11. CRM форма угоди — compact ───────────────────── */
    #crmDealModal .modal-content,
    #crmCreateDealModal .modal-content {
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        min-height: 100dvh !important;
    }

    /* ── 12. CRM список лідів — рядки щільніше ───────────── */
    [data-crm-row] {
        padding: 0.55rem 0.75rem !important;
        gap: 0.5rem !important;
    }
    [data-crm-row] > div:first-child {
        min-width: 58px !important;
    }

    /* ── 13. CRM кнопки консультації — текст коротший ─────── */
    [data-crm-row] button[onclick*="Consultation"] {
        font-size: 0.68rem !important;
        padding: 3px 6px !important;
    }

    /* ── 14. taskReviewActions — компактний ──────────────── */
    #taskReviewActions {
        padding: 0.6rem 0.75rem !important;
        margin: 0.35rem 0 !important;
    }

    /* ── 15. Чеклист і підзавдання — touch-friendly ──────── */
    #subtasksSection,
    .checklist-item {
        padding: 0.6rem 0.75rem !important;
    }

    /* ── 16. Кнопка «Відкрити угоду CRM» в завданні ──────── */
    #taskCrmDealBtn {
        min-height: 44px !important;
        border-radius: 12px !important;
        font-size: 0.85rem !important;
    }

    /* ── 17. Розширені чекбокси — touch area ─────────────── */
    #taskAdvancedPanel label[style*="display:flex"] {
        min-height: 44px !important;
        padding: 0.6rem 0.75rem !important;
        border-radius: 10px !important;
    }

    /* ── 18. Scrollable content — без горизонтального scroll */
    #taskModal *,
    #regularTaskModal * {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* ── 19. Section separators — iOS-style групування ────── */
    .form-section-title {
        font-size: 0.72rem;
        font-weight: 700;
        color: #9ca3af;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        padding: 0.5rem 0 0.2rem;
    }

    /* ── 20. Time tracking — горизонтальний flex ─────────── */
    #timeTrackingSection [style*="display:flex;gap:1rem"] {
        gap: 0.5rem !important;
        flex-wrap: nowrap !important;
    }
}

/* ── dvh підтримка для старих iOS ────────────────────────── */
@supports not (height: 100dvh) {
    @media (max-width: 767px) {
        #taskModal .modal-content,
        #regularTaskModal .modal-content {
            min-height: -webkit-fill-available !important;
            max-height: -webkit-fill-available !important;
        }
    }
}
