/**
 * PRIME PRACTICE — app.css
 * ═══════════════════════════════════════════════════════
 * Sections:
 *   - CSS Variables & Base
 *   - Auth / Login Screen
 *   - Navbar, Sidebar
 *   - Tables, Cards, Badges
 *   - Chat UI (Instant Messenger)
 *   - Notification Panel
 *   - PWA Install Button & Banner
 *   - Sidebar Toggle (flexbox)
 *   - Custom Searchable Dropdown (CSD)
 *   - Mobile (@media max-width: 768px)
 *     - Bottom Nav, Task Cards, Client Cards
 *     - Bottom Sheets, Filter FAB
 *     - Collapsible Sections (clientFormBody, complianceSectionBody)
 *
 * TO EDIT: Upload only this file for styling/layout issues
 * ═══════════════════════════════════════════════════════
 */

        :root { --ca-navy: #0B2447; --ca-gold: #C5A880; --ca-bg: #F8F9FA; --ca-surface: #FFFFFF; --text-main: #2B2D42; }
        body { font-family: 'Inter', sans-serif; background-color: var(--ca-bg); color: var(--text-main); min-height: 100vh; margin: 0; }
        h1,h2,h3,h4,h5,.navbar-brand,.merriweather { font-family: 'Merriweather', serif; }

        /* ── ENHANCED: Split-Screen Login ───────────────── */
        .auth-wrapper { min-height: 100vh; display: flex; align-items: stretch; }
        .auth-left-panel {
            flex: 1;
            background: linear-gradient(145deg, var(--theme-primary, #071830) 0%, var(--ca-navy) 50%, var(--theme-primary-hover, #1a3f70) 100%);
            display: flex; flex-direction: column; align-items: center; justify-content: center;
            padding: 50px 40px; position: relative; overflow: hidden;
        }
        .auth-left-panel::before {
            content: '';
            position: absolute; inset: 0;
            background: url('https://images.unsplash.com/photo-1554224155-6726b3ff858f?w=900&q=80') center/cover no-repeat;
            opacity: 0.12;
        }
        .auth-left-panel::after {
            content: ''; position: absolute; bottom: -80px; right: -80px;
            width: 320px; height: 320px; border-radius: 50%;
            background: rgba(197,168,128,0.08);
        }
        .auth-left-content { position: relative; z-index: 1; text-align: center; }
        .auth-left-logo { width: 110px; margin-bottom: 28px; border-radius: 15px; box-shadow: 0 8px 20px rgba(0,0,0,0.25); background: white; padding: 5px; }
        .auth-left-title { font-family: 'Merriweather', serif; font-size: 2.4rem; font-weight: 900; color: #fff; line-height: 1.15; margin-bottom: 18px; }
        .auth-left-title span { color: var(--ca-gold); display: block; }
        .auth-left-tagline { color: rgba(255,255,255,0.75); font-size: 1rem; line-height: 1.6; max-width: 340px; margin: 0 auto 36px; }
        .auth-feature-list { list-style: none; padding: 0; margin: 0; }
        .auth-feature-list li { color: rgba(255,255,255,0.7); font-size: 0.85rem; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
        .auth-feature-list li i { color: var(--ca-gold); font-size: 1rem; }
        .auth-right-panel { width: 480px; min-width: 380px; background: #fff; display: flex; flex-direction: column; justify-content: center; padding: 48px 44px; overflow-y: auto; }
        .auth-right-panel .brand-mobile { display: none; }
        .auth-card { background: transparent; border: none; width: 100%; }
        .auth-card.wide { max-width: none; }
        @media (max-width: 768px) {
            .auth-left-panel { display: none; }
            .auth-right-panel { width: 100%; padding: 32px 24px; }
            .auth-right-panel .brand-mobile { display: block; text-align: center; margin-bottom: 20px; }
        }

        /* ── App Chrome ─────────────────────────────────── */
        .navbar { background-color: var(--ca-navy); border-bottom: 3px solid var(--ca-gold); }
        /* sidebar base styles are in the toggle block below */
        .nav-pills .nav-link { color: var(--text-main); font-weight: 500; cursor: pointer; border-radius: 8px; margin-bottom: 5px; font-size: 0.88rem; }
        .nav-pills .nav-link.active { background-color: var(--ca-gold); color: var(--ca-surface); }
        .nav-pills .nav-link:hover:not(.active) { background-color: var(--ca-bg); }
        .hidden { display: none !important; }
        .btn-primary { background-color: var(--ca-navy); border-color: var(--ca-navy); }
        .btn-primary:hover { background-color: #0d2d5a; border-color: #0d2d5a; }
        .accordion-button:not(.collapsed) { background-color: #f0f4f8; color: var(--ca-navy); font-weight: bold; }
        /* Enhancement 2: Smaller table font */
        .table th { background-color: var(--ca-navy); color: white; font-weight: 500; font-size: 0.82rem; }
        .table td { font-size: 0.82rem; }
        .dash-card { cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
        .dash-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.15) !important; }
        .bulk-card { border-radius: 14px; transition: box-shadow 0.2s; }
        .bulk-card:hover { box-shadow: 0 8px 24px rgba(11,36,71,0.13) !important; }
        .bulk-card .card-header { border-radius: 14px 14px 0 0 !important; font-size: 1rem; }
        .step-list { padding-left: 1.2rem; }
        .step-list li { margin-bottom: 6px; font-size: 0.84rem; color: #555; }
        .step-list li strong { color: var(--ca-navy); }
        .badge-freq { font-size: 0.7rem; }
        .table-sm td, .table-sm th { font-size: 0.80rem; }
        .manual-task-card { border-left: 5px solid #198754; }
        .tx-link-panel { background: #f0fff4; border: 1.5px solid #198754; border-radius: 10px; padding: 14px 16px; margin-top: 10px; }
        .tx-link-panel.adhoc { background: #fff8e1; border-color: #fd7e14; }
        .form-check-input:checked { background-color: var(--ca-navy); border-color: var(--ca-navy); }
        .billed-badge { font-size: 0.72rem; background: #d4edda; color: #155724; border: 1px solid #c3e6cb; padding: 2px 7px; border-radius: 20px; }
        .unbilled-badge { font-size: 0.72rem; background: #fff3cd; color: #856404; border: 1px solid #ffc107; padding: 2px 7px; border-radius: 20px; }

        /* Enhancement 11: Priority Badges */
        .priority-high   { background:#dc3545!important;color:#fff!important;font-size:0.68rem; }
        .priority-medium { background:#fd7e14!important;color:#fff!important;font-size:0.68rem; }
        .priority-low    { background:#6c757d!important;color:#fff!important;font-size:0.68rem; }

        /* Enhancement 15: Reminder Row Highlight */
        .task-reminder-row { background: rgba(220,53,69,0.07) !important; }
        .task-reminder-row td:first-child::before { content:'⚠️ '; }

        /* Enhancement 13: Chat Interface */
        /* ── Chat Panel: flex column keeps input always at bottom ── */
        #taskChatPanel { display: flex; flex-direction: column; }
        .chat-window { height: 280px; overflow-y: auto; background: #f4f6fb; border: 1px solid #dee2e6; border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
        /* FIX 4: Prevent Instant Messenger from collapsing when admin section is hidden on mobile */
        @media (max-width: 768px) {
            #taskUpdateModal .modal-body { min-height: 480px !important; }
            #taskChatPanel { min-height: 420px; display: flex; flex-direction: column; }
            #taskChatPanel .chat-window { flex: 1; height: auto; min-height: 260px; }
            /* FIX 5: When chat tab is active (full-screen mode) expand chat to use full modal height */
            #taskUpdateModal.chat-fullscreen .modal-body {
                display: flex; flex-direction: column; padding: 0 !important;
                height: calc(100svh - 56px) !important; min-height: unset !important;
            }
            #taskUpdateModal.chat-fullscreen #taskChatPanel {
                flex: 1; min-height: unset; padding: 8px 12px 4px;
                display: flex; flex-direction: column;
            }
            #taskUpdateModal.chat-fullscreen #taskChatPanel .chat-window {
                flex: 1; height: auto; min-height: unset;
            }
            #taskUpdateModal.chat-fullscreen #taskUpdatePanel { display: none !important; }
        }
        .chat-bubble-wrap { display: flex; align-items: flex-end; gap: 8px; }
        .chat-bubble-wrap.self { flex-direction: row-reverse; }
        .chat-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
        .chat-bubble { max-width: 72%; padding: 9px 13px; border-radius: 16px; font-size: 0.82rem; line-height: 1.45; position: relative; word-break: break-word; }
        .chat-bubble.incoming { background: #fff; border: 1px solid #e0e0e0; border-bottom-left-radius: 4px; }
        .chat-bubble.outgoing { background: var(--ca-navy); color: #fff; border-bottom-right-radius: 4px; }
        .chat-bubble .chat-meta { font-size: 0.68rem; opacity: 0.65; margin-bottom: 3px; font-weight: 600; }
        .chat-input-area { display: flex; gap: 8px; margin-top: 8px; flex-shrink: 0; }
        /* Desktop: chat input is sticky below chat window — never moves */
        @media (min-width: 769px) {
            #taskChatPanel { height: 100%; }
            #taskChatPanel .chat-window { flex: 1 1 0; min-height: 200px; height: auto !important; }
            .chat-input-area {
                position: sticky !important;
                bottom: 0 !important;
                background: #fff !important;
                padding: 10px 0 6px !important;
                border-top: 1px solid #e9ecef !important;
                box-shadow: 0 -2px 8px rgba(11,36,71,0.06) !important;
                z-index: 10;
            }
            #taskChatWindow { padding-bottom: 0 !important; }
        }
        .chat-input-area textarea { flex: 1; resize: none; border-radius: 20px; padding: 8px 14px; font-size: 0.83rem; border: 1px solid #ced4da; outline: none; }
        .chat-send-btn { border-radius: 50%; width: 38px; height: 38px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--ca-navy); color: #fff; border: none; cursor: pointer; }
        .chat-send-btn:hover { background: var(--theme-primary-hover, #1a3f70); }
        /* Enhancement 14: Unread badge */
        .unread-chat-dot { display: inline-block; width: 9px; height: 9px; background: #dc3545; border-radius: 50%; margin-left: 5px; vertical-align: middle; animation: pulse 1.2s infinite; }
        @keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

        /* FIX 9: Bell Notification Icon */
        .notif-bell-btn {
            position: relative; background: transparent; border: 1px solid rgba(255,255,255,0.35);
            color: #fff; border-radius: 8px; padding: 4px 10px;
            cursor: pointer; transition: background 0.15s;
            display: flex; align-items: center; justify-content: center;
        }
        .notif-bell-btn:hover { background: rgba(255,255,255,0.12); }
        .notif-bell-badge {
            position: absolute; top: -5px; right: -5px;
            background: #dc3545; color: #fff; border-radius: 50%;
            width: 18px; height: 18px; font-size: 0.6rem; font-weight: 700;
            display: flex; align-items: center; justify-content: center;
            border: 2px solid var(--ca-navy);
            animation: pulse 1.4s infinite;
        }
        /* Notification Panel */
        #notifPanel {
            display: none; position: fixed; top: 60px; right: 16px;
            width: 340px; max-height: 480px; overflow-y: auto;
            background: #fff; border-radius: 16px;
            box-shadow: 0 12px 40px rgba(11,36,71,0.22);
            border: 1px solid #e2e8f0; z-index: 9000;
        }
        #notifPanel.show { display: block; animation: slideDown 0.2s ease; }
        @keyframes slideDown { from{transform:translateY(-10px);opacity:0} to{transform:translateY(0);opacity:1} }
        .notif-item { padding: 10px 14px; border-bottom: 1px solid #f0f2f7; cursor: pointer; transition: background 0.15s; }
        .notif-item:hover { background: #f8f9ff; }
        .notif-item.unread { border-left: 3px solid var(--ca-gold); }
        .notif-item-title { font-size: 0.82rem; font-weight: 600; color: var(--ca-navy); }
        .notif-item-body  { font-size: 0.74rem; color: #6c757d; margin-top: 2px; }
        .notif-item-time  { font-size: 0.66rem; color: #adb5bd; margin-top: 3px; }
        /* Mobile bell in top header */
        .mob-notif-bell {
            position: relative; background: transparent; border: none;
            color: #fff; font-size: 1.1rem; cursor: pointer; padding: 4px 6px;
        }
        .mob-notif-badge {
            position: absolute; top: 0; right: 0;
            background: #dc3545; color: #fff; border-radius: 50%;
            width: 15px; height: 15px; font-size: 0.55rem; font-weight: 700;
            display: flex; align-items: center; justify-content: center;
            border: 1.5px solid var(--ca-navy);
        }

        /* Flatpickr overrides */
        .flatpickr-input { background: #fff !important; cursor: pointer; }

        /* ── PWA Install Button — Blinking / Attractive ──────── */
        @keyframes pwa-blink {
            0%,100% { box-shadow: 0 0 0 0 rgba(255,193,7,0.8); opacity:1; }
            50%      { box-shadow: 0 0 0 8px rgba(255,193,7,0); opacity:0.82; }
        }
        @keyframes pwa-shine {
            0%   { background-position: -200% center; }
            100% { background-position: 200% center; }
        }
        .mob-menu-install {
            display: flex; align-items: center; gap: 12px;
            padding: 13px 20px; cursor: pointer;
            background: linear-gradient(90deg, var(--ca-navy) 0%, var(--theme-primary-hover, #1a3f70) 40%, var(--ca-gold) 100%);
            background-size: 200% auto;
            animation: pwa-blink 1.6s ease-in-out infinite, pwa-shine 2.8s linear infinite;
            margin: 8px 12px 4px; border-radius: 12px;
            color: #fff !important; font-weight: 700; font-size: 0.9rem;
            border: 2px solid var(--ca-gold);
            position: relative; overflow: hidden;
        }
        .mob-menu-install::after {
            content: ''; position: absolute; inset: 0;
            background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
            background-size: 200% auto;
            animation: pwa-shine 2s linear infinite;
        }
        .mob-menu-install i { font-size: 1.25rem; color: var(--ca-gold); }
        .mob-menu-install .install-sub { font-size: 0.68rem; font-weight: 400; opacity: 0.85; display: block; margin-top: 1px; }
        /* pwaInstallBtn always visible — inline style handles it */

        /* ── PWA Install Banner (on-load prompt) ─────────────── */
        #pwaInstallBanner {
            display: none; position: fixed;
            bottom: 70px; left: 10px; right: 10px;
            background: linear-gradient(135deg, var(--ca-navy) 0%, var(--theme-primary-hover, #1a3f70) 100%);
            border: 2px solid var(--ca-gold); border-radius: 16px;
            box-shadow: 0 8px 32px rgba(11,36,71,0.45);
            z-index: 2000; padding: 14px 16px;
            animation: pwa-blink 2s ease-in-out infinite;
            color: #fff;
        }
        #pwaInstallBanner.show { display: flex; align-items: center; gap: 12px; }
        .pwa-banner-icon { font-size: 2rem; color: var(--ca-gold); flex-shrink: 0; }
        .pwa-banner-text { flex: 1; }
        .pwa-banner-text strong { display: block; font-size: 0.9rem; }
        .pwa-banner-text small { opacity: 0.8; font-size: 0.75rem; }
        .pwa-banner-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
        .btn-pwa-install {
            background: var(--ca-gold); color: var(--ca-navy); border: none;
            border-radius: 8px; padding: 6px 14px; font-weight: 700;
            font-size: 0.8rem; cursor: pointer; white-space: nowrap;
        }
        .btn-pwa-later {
            background: transparent; color: rgba(255,255,255,0.7);
            border: 1px solid rgba(255,255,255,0.3);
            border-radius: 8px; padding: 5px 14px;
            font-size: 0.75rem; cursor: pointer; white-space: nowrap;
        }

        /* ── Sidebar Toggle — pure flexbox, zero scroll jump ── */
        .sidebar {
            flex: 0 0 210px;
            width: 210px;
            overflow: hidden;
            background: #fff;
            border-right: 1px solid #E2E8F0;
            padding-top: 20px;
            transition: flex-basis 0.3s ease, width 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
        }
        .sidebar.sidebar-collapsed {
            flex-basis: 0 !important;
            width: 0 !important;
            padding: 0 !important;
            opacity: 0;
            pointer-events: none;
        }
        .main-content-area {
            flex: 1 1 0%;
            min-width: 0;
            padding: 1.5rem;
            background: var(--ca-bg);
        }
        .btn-sidebar-toggle {
            background: transparent;
            border: 1px solid rgba(255,255,255,0.35);
            color: #fff;
            border-radius: 6px;
            padding: 4px 10px;
            font-size: 1.1rem;
            line-height: 1;
            cursor: pointer;
            transition: background 0.15s;
            margin-right: 8px;
        }
        .btn-sidebar-toggle:hover { background: rgba(255,255,255,0.12); }

        /* ── Custom Searchable Dropdown (CSD) ─────────────── */
        .csd-wrap { position: relative; }
        .csd-list {
            display: none;
            position: absolute;
            top: 100%;
            left: 0; right: 0;
            z-index: 1055;
            background: #fff;
            border: 1px solid #ced4da;
            border-top: 2px solid var(--ca-navy);
            border-radius: 0 0 6px 6px;
            max-height: 200px;
            overflow-y: auto;
            box-shadow: 0 6px 16px rgba(0,0,0,0.12);
            list-style: none;
            padding: 0; margin: 0;
        }
        .csd-list.open { display: block; }
        .csd-list li {
            padding: 6px 11px;
            font-size: 0.82rem;
            cursor: pointer;
            border-bottom: 1px solid #f3f3f3;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .csd-list li:hover, .csd-list li.csd-active { background: #e8f0fe; color: var(--ca-navy); font-weight: 500; }
        .csd-list li.csd-no-match { color: #aaa; cursor: default; font-style: italic; }
        .csd-input.csd-valid { border-color: #198754 !important; box-shadow: 0 0 0 0.2rem rgba(25,135,84,.15) !important; }

        /* ═══════════════════════════════════════════════════════
           MOBILE-FIRST PWA STYLES — max-width: 768px
           ═══════════════════════════════════════════════════════ */
        @media (min-width: 769px) {
            #mobileBottomNav, .filter-fab, .mob-card-list,
            .mob-page-header, #mobileMenuSheet, #mobileMenuOverlay,
            .mob-top-header, .mob-filter-chips { display: none !important; }
        }

        @media (max-width: 768px) {
            :root {
                --mob-radius: 16px;
                --mob-card-shadow: 0 2px 16px rgba(11,36,71,0.10);
                --mob-active-glow: 0 0 14px rgba(197,168,128,0.6);
            }
            body { padding-bottom: 76px; background: #f0f2f7; }
            .navbar { display: none !important; }
            .sidebar, #appSidebar { display: none !important; }
            .main-content-area { padding: 0 0 1rem; }

            /* ── Mobile Page Header ───────────────────────────── */
            .mob-page-header {
                display: flex; align-items: center;
                background: linear-gradient(135deg, var(--ca-navy) 0%, var(--theme-primary-hover, #1a3f70) 100%);
                padding: 14px 16px 12px;
                border-bottom: 2px solid var(--ca-gold);
                position: sticky; top: 0; z-index: 200;
                box-shadow: 0 2px 12px rgba(11,36,71,0.3);
            }
            .mob-page-header h5 {
                color: #fff; font-family: 'Merriweather', serif;
                margin: 0; font-size: 1rem; flex: 1;
                letter-spacing: 0.2px;
            }
            .mob-header-actions { display: flex; align-items: center; gap: 8px; }
            .mob-header-actions .btn {
                padding: 5px 12px; font-size: 0.75rem;
                border-radius: 20px; font-weight: 600;
            }
            /* Header right icons */
            .mob-header-icon-btn {
                width: 34px; height: 34px; border-radius: 50%;
                border: 1.5px solid rgba(255,255,255,0.25);
                background: rgba(255,255,255,0.08);
                color: #fff; display: flex; align-items: center; justify-content: center;
                font-size: 1rem; cursor: pointer; flex-shrink: 0;
                -webkit-tap-highlight-color: transparent;
            }
            .mob-header-icon-btn:active { background: rgba(255,255,255,0.2); }

            /* ── BOTTOM NAVIGATION — Advanced ───────────────── */
            #mobileBottomNav {
                display: flex; position: fixed;
                bottom: 0; left: 0; right: 0;
                height: 68px;
                background: rgba(11,36,71,0.97);
                backdrop-filter: blur(12px);
                -webkit-backdrop-filter: blur(12px);
                border-top: 1px solid rgba(197,168,128,0.35);
                z-index: 1060; align-items: stretch;
                padding: 0 4px;
                box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
            }
            .mob-nav-item {
                flex: 1; display: flex; flex-direction: column;
                align-items: center; justify-content: center;
                color: rgba(255,255,255,0.42); font-size: 0.56rem;
                font-weight: 600; cursor: pointer; letter-spacing: 0.5px;
                border: none; background: transparent; gap: 4px;
                text-transform: uppercase; padding: 0 2px;
                transition: color 0.2s, transform 0.15s;
                -webkit-tap-highlight-color: transparent; outline: none;
                position: relative; border-radius: 12px; margin: 6px 2px;
            }
            .mob-nav-item i { font-size: 1.35rem; line-height: 1; transition: transform 0.2s; }
            .mob-nav-item.active {
                color: var(--ca-gold);
                background: rgba(197,168,128,0.12);
            }
            .mob-nav-item.active i { transform: translateY(-2px); }
            .mob-nav-item.active::after {
                content: '';
                position: absolute; bottom: -6px; left: 50%;
                transform: translateX(-50%);
                width: 24px; height: 3px;
                background: var(--ca-gold);
                border-radius: 2px 2px 0 0;
            }
            .mob-nav-item:active { transform: scale(0.9); }
            /* Nav badge for unread */
            .mob-nav-badge {
                position: absolute; top: 4px; right: calc(50% - 18px);
                background: #dc3545; color: #fff;
                font-size: 0.55rem; font-weight: 700;
                border-radius: 8px; padding: 1px 5px;
                min-width: 16px; text-align: center;
                line-height: 1.4; border: 1.5px solid rgba(11,36,71,0.97);
            }

            /* ── Hide tables on mobile, show card lists ──────── */
            #viewTasks .table-responsive { display: none !important; }
            #viewClients > .card .table-responsive { display: none !important; }
            .mob-card-list { display: flex !important; flex-direction: column; gap: 0; padding: 10px 12px 4px; }

            /* ── TASK CARD — Advanced glassmorphism style ────── */
            .swipe-wrapper {
                position: relative; overflow: hidden;
                border-radius: var(--mob-radius); margin-bottom: 10px;
                box-shadow: var(--mob-card-shadow);
            }
            .swipe-bg {
                position: absolute; top: 0; bottom: 0; width: 88px;
                display: flex; align-items: center; justify-content: center;
                flex-direction: column; gap: 5px; font-size: 0.65rem;
                font-weight: 700; color: #fff; user-select: none;
                letter-spacing: 0.3px;
            }
            .swipe-bg-left  { left: 0; background: linear-gradient(135deg,#0d6efd,#4d9eff); border-radius: var(--mob-radius) 0 0 var(--mob-radius); }
            .swipe-bg-right { right: 0; background: linear-gradient(135deg,#198754,#2dbb6e); border-radius: 0 var(--mob-radius) var(--mob-radius) 0; }
            .swipe-card {
                position: relative; z-index: 2;
                transition: transform 0.28s cubic-bezier(.4,0,.2,1);
                will-change: transform; touch-action: pan-y;
                border-radius: var(--mob-radius); background: #fff;
            }

            /* Task card main */
            .mob-task-card {
                padding: 14px 14px 10px;
                border-left: 4px solid #adb5bd;
                border-radius: var(--mob-radius);
            }
            .mob-task-card.priority-border-high   { border-left-color: #dc3545; }
            .mob-task-card.priority-border-medium { border-left-color: #fd7e14; }
            .mob-task-card.priority-border-low    { border-left-color: #198754; }

            .mob-task-card-title {
                font-weight: 700; font-size: 0.9rem; color: var(--ca-navy);
                line-height: 1.3;
            }
            .mob-task-card-sub {
                font-size: 0.75rem; color: #6c757d; margin-bottom: 2px;
                display: flex; align-items: center; gap: 5px;
            }
            .mob-task-card-sub i { font-size: 0.78rem; flex-shrink: 0; }
            .mob-task-card-meta {
                display: flex; gap: 8px; flex-wrap: wrap;
                margin-top: 8px; margin-bottom: 8px;
            }
            .mob-task-chip {
                display: inline-flex; align-items: center; gap: 3px;
                background: #f0f2f7; border-radius: 20px;
                padding: 3px 9px; font-size: 0.68rem; color: #495057;
                font-weight: 500;
            }
            .mob-task-chip.danger { background: #fff5f5; color: #dc3545; font-weight: 700; }
            .mob-task-chip.warning { background: #fff8f0; color: #fd7e14; }
            .mob-task-chip.success { background: #f0fff4; color: #198754; }
            .mob-task-card-actions {
                display: flex; gap: 6px; margin-top: 8px;
                align-items: center; flex-wrap: wrap;
                border-top: 1px solid #f0f0f0; padding-top: 10px;
            }
            .mob-action-btn {
                display: inline-flex; align-items: center; gap: 5px;
                border-radius: 20px; padding: 5px 12px;
                font-size: 0.73rem; font-weight: 600;
                border: none; cursor: pointer;
                -webkit-tap-highlight-color: transparent;
                transition: transform 0.1s, box-shadow 0.15s;
            }
            .mob-action-btn:active { transform: scale(0.95); }
            .mob-action-btn.call { background: #e8f4ff; color: #0d6efd; }
            .mob-action-btn.whatsapp { background: #e8fff0; color: #128C7E; }
            .mob-action-btn.whatsapp-tpl { background: #25D366; color: #fff; }
            .mob-wa-btn { background: #25D366 !important; border-color: #25D366 !important; color: #fff !important; }

            /* ── CLIENT CARDS — Advanced ─────────────────────── */
            .mob-client-card {
                background: #fff; border-radius: var(--mob-radius);
                padding: 14px 14px 12px; border-left: 4px solid var(--ca-navy);
                margin-bottom: 10px;
                box-shadow: var(--mob-card-shadow);
            }
            .mob-client-card-name {
                font-weight: 700; font-size: 0.92rem; color: var(--ca-navy);
            }
            .mob-client-card-id {
                font-size: 0.68rem; color: #adb5bd; font-weight: 500;
                letter-spacing: 0.3px;
            }
            .mob-client-card-pills {
                display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0;
            }
            .mob-client-pill {
                display: inline-flex; align-items: center; gap: 3px;
                background: #f0f2f7; border-radius: 20px;
                padding: 2px 8px; font-size: 0.67rem; color: #495057;
            }
            .mob-client-pill.group { background: #e8f4ff; color: #0d6efd; font-weight: 600; }
            .mob-client-pill.compliance { background: #f0e8ff; color: #6f42c1; }

            /* ── BOTTOM SHEETS ───────────────────────────────── */
            .modal.bottom-sheet { padding: 0 !important; }
            .modal.bottom-sheet .modal-dialog {
                position: fixed; bottom: 0; left: 0; right: 0; margin: 0;
                max-width: 100% !important; width: 100%;
                transform: translateY(100%);
                transition: transform 0.38s cubic-bezier(.4,0,.2,1);
            }
            .modal.bottom-sheet.show .modal-dialog { transform: translateY(0); }
            .modal.bottom-sheet .modal-content {
                border-radius: 24px 24px 0 0 !important; border: none;
                max-height: 92vh; overflow-y: auto; padding-top: 6px;
                box-shadow: 0 -8px 32px rgba(0,0,0,0.2);
            }
            .modal.bottom-sheet .modal-content::before {
                content: ''; display: block; width: 40px; height: 4px;
                background: #ced4da; border-radius: 2px; margin: 8px auto 10px;
            }

            /* ── Chat UI — Input FIXED above bottom nav, never moves ── */
            #taskUpdateModal.bottom-sheet .modal-content {
                max-height: 100svh; border-radius: 0 !important;
            }
            #taskUpdateModal.bottom-sheet .modal-content::before { display: none; }
            /* Chat window height = viewport minus: header(56) + tabs(40) + attachment-warning(36) + label(28) + fixed-input(70) + nav(68) + padding(20) */
            #taskUpdateModal .chat-window {
                height: calc(100svh - 390px);
                min-height: 150px;
                padding-bottom: 8px !important;
            }
            /* Fixed input bar — ALWAYS above bottom nav bar (68px), keyboard-proof */
            .chat-input-area {
                position: fixed !important;
                bottom: 68px !important;
                left: 0 !important;
                right: 0 !important;
                background: #fff !important;
                padding: 8px 12px 10px !important;
                z-index: 1080 !important;
                border-top: 2px solid #e2e8f0 !important;
                box-shadow: 0 -4px 16px rgba(11,36,71,0.12) !important;
            }
            /* Space at bottom of chat window so last message not hidden behind fixed input */
            #taskChatWindow {
                padding-bottom: 90px !important;
            }
            /* chat-fullscreen mode — same treatment */
            #taskUpdateModal.chat-fullscreen .chat-input-area {
                position: fixed !important;
                bottom: 68px !important;
                left: 0 !important; right: 0 !important;
                z-index: 1090 !important;
                padding: 8px 12px 10px !important;
                background: #fff !important;
                border-top: 2px solid #e2e8f0 !important;
                box-shadow: 0 -4px 16px rgba(11,36,71,0.12) !important;
            }
            /* Fullscreen chat window uses all available space */
            #taskUpdateModal.chat-fullscreen #taskChatPanel .chat-window {
                height: calc(100svh - 230px) !important;
                min-height: 180px;
            }
            /* Fix 3: Save button clears 68px bottom nav */
            #taskUpdatePanel .d-md-none.mt-3 {
                padding-bottom: 80px;
            }
            /* Also ensure modal body scrolls fully */
            #taskUpdateModal .modal-body {
                padding-bottom: 20px;
            }

            /* ── FILTER FAB ─────────────────────────────────── */
            .filter-fab {
                display: flex; position: fixed;
                bottom: 80px; right: 16px;
                width: 52px; height: 52px; border-radius: 26px;
                background: var(--ca-navy); color: var(--ca-gold);
                border: 2px solid var(--ca-gold);
                align-items: center; justify-content: center;
                font-size: 1.2rem;
                box-shadow: 0 6px 20px rgba(11,36,71,0.4);
                z-index: 1050; cursor: pointer;
                transition: transform 0.15s, box-shadow 0.15s;
                -webkit-tap-highlight-color: transparent;
            }
            .filter-fab:active { transform: scale(0.9); }
            .filter-fab.active { background: var(--ca-gold); color: var(--ca-navy); box-shadow: var(--mob-active-glow); }
            .mob-filter-panel { display: none; }
            .mob-filter-panel.open { display: block; }
            .mob-filter-panel .card { margin: 0 12px 10px; border-radius: 14px !important; }

            /* Sticky form buttons */
            #manualTaskCard .row .col-md-2:last-child .btn.btn-success,
            button[onclick="saveTransaction()"] {
                position: sticky; bottom: 70px; z-index: 50;
                width: 100% !important; border-radius: 24px !important;
                padding: 13px; font-size: 1rem; margin-top: 12px;
                box-shadow: 0 4px 16px rgba(25,135,84,0.35);
            }

            /* ── Mobile Top Header — Prime Practice + Right Menu ─── */
        .mob-top-header {
            display: none;
        }
        @media (max-width: 768px) {
            .mob-top-header {
                display: flex; align-items: center; justify-content: space-between;
                background: linear-gradient(135deg, var(--ca-navy) 0%, var(--theme-primary-hover, #1a3f70) 100%);
                padding: 10px 14px;
                border-bottom: 2px solid var(--ca-gold);
                position: sticky; top: 0; z-index: 210;
                box-shadow: 0 2px 12px rgba(11,36,71,0.35);
            }
            .mob-top-brand {
                display: flex; align-items: center; gap: 8px;
                color: #fff; font-family: 'Merriweather', serif; font-size: 0.95rem; font-weight: 700;
            }
            .mob-top-brand img { height: 28px; border-radius: 6px; background: #fff; padding: 2px; }
            .mob-top-brand span span { color: var(--ca-gold); }
            .mob-top-right { display: flex; align-items: center; gap: 6px; }
            .mob-top-menu-btn {
                width: 34px; height: 34px; border-radius: 50%;
                border: 1.5px solid rgba(255,255,255,0.3);
                background: rgba(255,255,255,0.1); color: #fff;
                display: flex; align-items: center; justify-content: center;
                font-size: 1.1rem; cursor: pointer;
            }
            /* Compact Mobile Filters */
            .mob-filter-chips {
                display: flex; flex-wrap: wrap; gap: 6px;
                padding: 8px 12px; background: #fff;
                border-bottom: 1px solid #e9ecef;
            }
            .mob-filter-chip {
                display: flex; align-items: center; gap: 4px;
                background: #f0f2f7; border: 1px solid #dee2e6;
                border-radius: 20px; padding: 4px 10px;
                font-size: 0.7rem; color: #495057; font-weight: 500;
                cursor: pointer; position: relative;
            }
            .mob-filter-chip.active { background: var(--ca-navy); color: #fff; border-color: var(--ca-navy); }
            .mob-filter-chip select {
                background: transparent; border: none; outline: none;
                font-size: 0.7rem; color: inherit; cursor: pointer;
                max-width: 100px;
            }
            .mob-filter-chip select option { color: #000; }
            /* Email template compact button */
            .mob-email-btn { background: #e8f4ff; color: #0d6efd; }
            .mob-email-btn:active { transform: scale(0.95); }
        }
            #mobileMenuSheet {
                display: block; position: fixed;
                bottom: -100%; left: 0; right: 0;
                background: #fff; border-radius: 24px 24px 0 0;
                box-shadow: 0 -8px 40px rgba(0,0,0,0.22);
                z-index: 1070; transition: bottom 0.35s cubic-bezier(.4,0,.2,1);
                padding: 6px 0 82px;
            }
            #mobileMenuSheet::before {
                content: ''; display: block; width: 40px; height: 4px;
                background: #ced4da; border-radius: 2px; margin: 10px auto 14px;
            }
            #mobileMenuSheet.show-sheet { bottom: 0; }
            #mobileMenuSheet .mob-menu-section-title {
                font-size: 0.65rem; font-weight: 700; letter-spacing: 1px;
                text-transform: uppercase; color: #adb5bd;
                padding: 6px 22px 4px; margin-top: 4px;
            }
            #mobileMenuSheet .mob-menu-item {
                display: flex; align-items: center; gap: 14px;
                padding: 13px 22px; font-size: 0.88rem; font-weight: 500;
                color: var(--text-main); cursor: pointer;
                -webkit-tap-highlight-color: transparent;
            }
            #mobileMenuSheet .mob-menu-item .mob-menu-icon {
                width: 38px; height: 38px; border-radius: 10px;
                display: flex; align-items: center; justify-content: center;
                font-size: 1.1rem; flex-shrink: 0;
            }
            #mobileMenuSheet .mob-menu-item:active { background: #f8f9fa; }
            #mobileMenuOverlay {
                display: none; position: fixed; inset: 0;
                background: rgba(0,0,0,0.45); z-index: 1065;
                backdrop-filter: blur(2px);
            }
            #mobileMenuOverlay.show { display: block; }

            /* ── DASHBOARD on mobile ────────────────────────── */
            #viewDashboard .row.g-3 > [class*="col-md-3"] { flex: 0 0 50%; max-width: 50%; }
            .dash-card {
                border-radius: 14px !important;
                overflow: hidden;
            }
            .dash-card .card-body { padding: 14px 12px !important; }
            .dash-card h3 { font-size: 1.5rem !important; }

            /* Manual task card - vertical stack */
            .manual-task-card .row.g-3 > div[class*="col-md"] { flex: 0 0 100%; max-width: 100%; }

            /* General */
            .card { border-radius: 14px !important; }
            .card-body { padding: 14px 12px; }
            .modal.bottom-sheet .modal-footer { position: sticky; bottom: 0; background: #f8f9fa; z-index: 10; }
            .auth-left-panel { display: none; }
            .auth-right-panel { width: 100%; padding: 28px 18px; }

            /* ── FLOATING WA Button ─────────────────────────── */
            .mob-wa-float {
                display: flex; align-items: center; gap: 5px;
                background: #25D366; color: #fff;
                border-radius: 20px; padding: 5px 12px;
                font-size: 0.73rem; font-weight: 700;
                border: none; cursor: pointer;
                box-shadow: 0 2px 8px rgba(37,211,102,0.4);
                -webkit-tap-highlight-color: transparent;
            }
            .mob-wa-float:active { transform: scale(0.95); }

            /* section spacing */
            .view-panel > * { margin-bottom: 0; }

            @media (max-width: 768px) {
            /* Hide individual page headers since global top header is used */
            .mob-page-header {
                display: none !important;
            }
            /* Add top padding to main content to account for global header */
            .main-content-area {
                padding-top: 0 !important;
            }
        }

        /* Mobile icon-only action buttons for client cards */
        .mob-icon-btn {
            width: 32px; height: 32px; min-width: 32px;
            border-radius: 8px; border: none; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            -webkit-tap-highlight-color: transparent;
            transition: opacity 0.15s, transform 0.12s;
        }
        .mob-icon-btn:active { transform: scale(0.88); opacity: 0.75; }

        /* Mobile icon-only action buttons for client cards */
        .mob-icon-btn {
            width: 32px; height: 32px; min-width: 32px;
            border-radius: 8px; border: none; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            -webkit-tap-highlight-color: transparent;
            transition: opacity 0.15s, transform 0.12s;
        }
        .mob-icon-btn:active { transform: scale(0.88); opacity: 0.75; }

        /* Task modal tabs (mobile) */
        .task-modal-tab { transition: background 0.2s, color 0.2s; border: none !important; }
        .task-modal-tab.active { background: var(--ca-navy) !important; color: #fff !important; }
        .task-status-btn { font-size: 0.75rem !important; padding: 6px 4px !important; font-weight: 600 !important; border-radius: 8px !important; }
        .task-status-btn.selected { box-shadow: 0 0 0 3px var(--ca-navy); transform: scale(1.04); }

        @media (max-width: 768px) {
            #taskUpdatePanel, #taskChatPanel { display: block; }
            #taskUpdatePanel.hidden-tab, #taskChatPanel.hidden-tab { display: none; }
            #taskModalTabs { display: flex !important; }
        }
        @media (min-width: 769px) {
            #taskModalTabs { display: none !important; }
            #taskUpdatePanel.hidden-tab, #taskChatPanel.hidden-tab { display: block !important; }
        }

        /* Pill status badges */
        .mob-status-pending   { background:#fff3cd;color:#856404;border-radius:20px;padding:2px 8px;font-size:0.67rem;font-weight:600; }
        .mob-status-wip       { background:#cff4fc;color:#0d6efd;border-radius:20px;padding:2px 8px;font-size:0.67rem;font-weight:600; }
        .mob-status-complete  { background:#d1e7dd;color:#0a3622;border-radius:20px;padding:2px 8px;font-size:0.67rem;font-weight:600; }

        /* ── COMPREHENSIVE MOBILE UI IMPROVEMENTS ──── */
        @media (max-width: 768px) {
            /* Body with top header space */
            body { padding-bottom: 80px; }

            /* Main content below mob-top-header */
            #appContainer .main-content-area { padding: 0 0 1rem; }

            /* Dashboard cards — 2 per row, better sizing */
            #viewDashboard .row.g-3 > [class*="col-md-3"] { flex: 0 0 50%; max-width: 50%; }
            .dash-card h3 { font-size: 1.4rem !important; }
            .dash-card .card-body { padding: 12px !important; }
            .dash-card { border-radius: 14px !important; min-height: 80px; }

            /* Filter bar compact */
            .mob-filter-chips { overflow-x: auto; flex-wrap: nowrap; padding: 8px 10px;
                scrollbar-width: none; -ms-overflow-style: none; }
            .mob-filter-chips::-webkit-scrollbar { display: none; }
            .mob-filter-chip { flex-shrink: 0; white-space: nowrap; }

            /* Task cards better typography */
            .mob-task-card { padding: 12px 13px 10px; }
            .mob-task-card-title { font-size: 0.88rem; font-weight: 700; color: var(--ca-navy); }
            .mob-task-card-sub   { font-size: 0.75rem; color: #6c757d; display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
            .mob-task-card-meta  { display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 0; }
            .mob-task-chip       { display: inline-flex; align-items: center; gap: 3px; background: #f0f2f7; border-radius: 20px; padding: 2px 8px; font-size: 0.66rem; color: #495057; }
            .mob-task-chip.danger { background: #fff0f0; color: #dc3545; }
            .mob-task-card-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px solid #f0f2f7; }

            /* Client cards */
            .mob-client-card { border-radius: 14px; padding: 13px; }

            /* Section headers inside views */
            #viewDashboard h3, #viewClients h3, #viewReports h3,
            #viewTasks h3, #viewFinance h3, #viewStaff h3 { font-size: 1.1rem !important; padding: 10px 12px 0; }

            /* Forms inside views */
            #viewClients .card-body, #viewFinance .card-body,
            #viewStaff .card-body { padding: 12px !important; }
            #viewClients .col-md-4, #viewClients .col-md-8 { flex: 0 0 100%; max-width: 100%; }

            /* Manual task card full width fields */
            #manualTaskCard .col-md-4,
            #manualTaskCard .col-md-2 { flex: 0 0 100%; max-width: 100%; }

            /* Bottom nav active indicator fix */
            .mob-nav-item.active::after { bottom: -8px; }

            /* Modal better on mobile */
            .modal.bottom-sheet .modal-body { padding: 14px; }
            .modal.bottom-sheet .modal-header { padding: 12px 14px; }

            /* Swipe hint text */
            .swipe-hint { font-size: 0.6rem; color: #adb5bd; text-align: center; margin-top: 4px; }

            /* Report cards smaller on mobile */
            #rptSummaryCards .merriweather { font-size: 0.95rem !important; }
            #rptSummaryCards .card-body { padding: 10px 12px !important; }

            /* Compliance filter input full width */
            #mobFilterComp { width: 90px; }

            /* ── Collapsible sections on mobile ────────────────── */
            /* Ensure hidden state is always respected — override card-body rules */
            #clientFormBody[style*="display:none"],
            #complianceSectionBody[style*="display:none"] {
                display: none !important;
            }
            /* When open, ensure card-body inside is visible */
            #clientFormBody[style*="display:block"],
            #clientFormBody[style*="display: block"] {
                display: block !important;
            }
            #complianceSectionBody[style*="display:block"],
            #complianceSectionBody[style*="display: block"] {
                display: block !important;
            }
            /* Card header tap target — full width, easy tap */
            #clientFormCardHeader {
                padding: 14px 16px !important;
                border-radius: 12px 12px 0 0;
            }
            #clientFormCardHeader:active {
                background: #f0f4ff !important;
            }
            #complianceSectionHeader {
                border-radius: 8px !important;
                padding: 10px 12px !important;
            }
            /* Chevron always visible */
            #clientFormChevron,
            #complianceSectionChevron {
                display: flex !important;
                align-items: center;
                justify-content: center;
                min-width: 32px;
                min-height: 32px;
            }

            /* Task update modal full height */
            #taskUpdateModal .modal-content { min-height: 60vh; }

            /* About modal compact */
            #aboutModal .modal-body { padding: 16px; }

            /* Hide desktop-only elements */
            .d-none.d-md-flex, .d-none.d-md-block { display: none !important; }

            /* Finance table scroll */
            #viewFinance .table-responsive { max-height: 60vh; overflow-y: auto; }
        }

