/* Mobile-Responsive Improvements for Madhouse CRM
 * This file contains mobile-only improvements that don't affect desktop views
 * Breakpoints: 
 * - Small mobile: max-width: 480px
 * - Mobile/tablet: max-width: 1199px
 */

/* ===== LOADING SPINNER ===== */
.mobile-loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.mobile-loading-spinner.active {
    opacity: 1;
    visibility: visible;
}

.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.spinner-border {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #2563eb;
    border-radius: 50%;
    animation: spinner 1s linear infinite;
}

.spinner-text {
    margin-top: 10px;
    color: #333;
    font-weight: 500;
}

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

/* ===== FILTER IMPROVEMENTS ===== */
/* Sticky filters for list views */
.sticky-filter-container {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: white;
    padding: 10px 0;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sticky-filter-container.sticky-active {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.sticky-filter-container.sticky-hidden {
    transform: translateY(-100%);
}

.sticky-filter-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 101;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: none;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sticky-filter-toggle.visible {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 1199px) {
    /* Stack filter elements vertically */
    .filter-section .row,
    .filter-section-unified .row {
        display: flex;
        flex-direction: column;
    }
    
    .filter-section .col-md-3,
    .filter-section .col-md-4,
    .filter-section .col-md-6,
    .filter-section-unified .col-md-3,
    .filter-section-unified .col-md-4,
    .filter-section-unified .col-md-6 {
        width: 100%;
        margin-bottom: 15px;
    }
    
    /* Make inputs full width on mobile */
    .filter-section input,
    .filter-section select,
    .filter-section .form-control,
    .filter-section-unified input,
    .filter-section-unified select,
    .filter-section-unified .form-control {
        width: 100%;
        max-width: none;
    }
    
    /* Filters button that opens modal */
    .mobile-filter-toggle {
        position: fixed;
        bottom: 70px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary-blue, #2563eb);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
        z-index: 100;
        border: none;
        font-size: 20px;
    }
    
    /* Hide default filter sections on mobile */
    .filter-section,
    .filter-section-unified {
        display: none;
    }
    
    /* Mobile filter modal */
    .mobile-filter-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1050;
        display: none;
    }
    
    .mobile-filter-modal.active {
        display: block;
    }
    
    .mobile-filter-drawer {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 80vh;
        background: white;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
        z-index: 1051;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        padding: 20px;
    }
    
    .mobile-filter-modal.active .mobile-filter-drawer {
        transform: translateY(0);
    }
    
    /* Mobile Pagination Styles */
    .mobile-pagination {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin: 20px 0;
        padding: 15px;
        background-color: #ffffff;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .mobile-pagination-info {
        font-size: 14px;
        color: #4b5563;
        margin-bottom: 12px;
        text-align: center;
    }
    
    .mobile-pagination-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
        width: 100%;
    }
    
    .mobile-pagination-button {
        min-width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #f3f4f6;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        font-weight: 500;
        font-size: 16px;
        color: #374151;
        text-decoration: none;
    }
    
    .mobile-pagination-button.active {
        background-color: #2563eb;
        color: white;
        border-color: #2563eb;
    }
    
    .mobile-pagination-button.disabled {
        opacity: 0.5;
        pointer-events: none;
    }
    
    .mobile-pagination-button i {
        font-size: 18px;
    }
    
    /* Standard pagination adjustments for mobile */
    .pagination-container {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .pagination {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
        margin-bottom: 10px;
    }
    
    .pagination > li > a,
    .pagination > li > span {
        min-width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        margin: 0;
        font-size: 15px;
    }
    
    .pagination-info {
        font-size: 13px;
        text-align: center;
    }
    
    .mobile-filter-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 10px;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .mobile-filter-title {
        font-size: 18px;
        font-weight: 600;
        margin: 0;
    }
    
    .mobile-filter-close {
        background: none;
        border: none;
        font-size: 20px;
        color: #6b7280;
        padding: 5px;
    }
    
    .mobile-filter-actions {
        display: flex;
        justify-content: space-between;
        margin-top: 20px;
        padding-top: 15px;
        border-top: 1px solid #e5e7eb;
    }
}

/* ===== TABLE TO CARD TRANSFORMATION ===== */
@media (max-width: 1199px) {
    /* Hide table headers on mobile */
    .table-responsive table thead {
        display: none;
    }
    
    /* Card styles for table rows */
    .table-responsive table tbody tr {
        display: block;
        margin-bottom: 20px;
        border: 1px solid #ddd;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        background-color: #fff;
        padding: 10px 0;
    }
    
    /* Style for table cells */
    /* Hide default borders */
    .table-responsive table tbody td {
        display: flex;
        border: none;
        padding: 8px 15px;
        text-align: left;
        position: relative;
        min-height: 40px;
        align-items: center;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Create labels for each cell */
    .table-responsive table tbody td:before {
        content: attr(data-title);
        font-weight: 700;
        color: #374151;
        text-align: left;
        width: 35%;
        margin-right: 10px;
        flex-shrink: 0;
        display: block;
        font-size: 13px;
        line-height: 1.3;
        letter-spacing: 0.01em;
        text-transform: uppercase;
    }
    
    /* Status-based styling for booking cards */
    .table-responsive table tbody tr[data-status="New"] {
        border-left: 5px solid #28a745;
    }
    
    .table-responsive table tbody tr[data-status="Completed"] {
        border-left: 5px solid #007bff;
    }
    
    .table-responsive table tbody tr[data-status="Cancelled"] {
        border-left: 5px solid #dc3545;
    }
    
    .table-responsive table tbody tr[data-status="Pending"] {
        border-left: 5px solid #ffc107;
    }
    
    /* Fix blank record blocks */
    .table-responsive table tbody tr.blank-row,
    .table-responsive table tbody tr.empty-row {
        display: none !important;
    }
    
    /* Style for customer/booking cards */
    .customer-card, .booking-card {
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        margin-bottom: 12px;
        padding: 12px;
    }
    
    /* Mobile-optimized button styles */
    .table-responsive .btn,
    .mobile-card-actions .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 8px 12px;
        margin: 2px;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Icon-only buttons for mobile */
    .table-responsive .btn-icon,
    .mobile-card-actions .btn-icon {
        min-width: 40px;
        width: 40px;
        padding: 8px;
        overflow: hidden;
    }
    
    .table-responsive .btn-icon i,
    .mobile-card-actions .btn-icon i {
        margin-right: 0;
    }
    
    /* Improved card layout and spacing */
    .mobile-card-key-info {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 8px;
        color: #333;
        padding: 0 15px;
    }
    
    .mobile-card-secondary-info {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 8px;
        padding: 0 15px;
    }
    
    .mobile-card-secondary-info div {
        margin-right: 12px;
        margin-bottom: 4px;
        font-size: 14px;
        color: #666;
    }
    
    /* Mobile event drawer for calendar */
.mobile-event-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    max-height: 80vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-event-drawer.active {
    transform: translateY(0);
}

.mobile-event-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: white;
}

.mobile-event-drawer-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.mobile-event-drawer-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mobile-event-drawer-content {
    padding: 16px 20px;
}

.mobile-event-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.mobile-event-drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-event-drawer-actions {
    display: flex;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid #eee;
}

.mobile-event-drawer-actions button {
    min-height: 44px;
    min-width: 44px;
    margin-left: 10px;
}

/* Specific styles for customer cards */
    @media (max-width: 1199px) {
        /* Ensure proper layout for customer cards */
        .table-responsive.customers-table table tbody td {
            display: flex;
            padding: 15px;
            border-bottom: 1px solid #eee;
            min-height: 50px;
            align-items: center;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: normal;
            word-break: break-word;
        }
        
        /* Ensure email addresses don't get cut off */
        .table-responsive.customers-table table tbody td[data-title="Email"] {
            flex-wrap: wrap;
        }
        
        /* Prioritize key fields */
        .table-responsive.customers-table table tbody td[data-title="Email"],
        .table-responsive.customers-table table tbody td[data-title="Name"],
        .table-responsive.customers-table table tbody td[data-title="Total Bookings"] {
            font-weight: 500;
            background-color: #f8f9fa;
        }
        
        /* Style action buttons */
        .table-responsive.customers-table table tbody td:last-child {
            display: flex;
            justify-content: flex-start;
            gap: 10px;
            padding-top: 20px;
            padding-bottom: 20px;
        }
    }
    
    /* Style for key information in cards */
    .mobile-card-key-info {
        font-weight: 700;
        font-size: 16px;
        margin-bottom: 5px;
        color: #111827;
        line-height: 1.4;
    }
    
    .mobile-card-secondary-info {
        font-size: 14px;
        color: #4b5563;
        margin-bottom: 3px;
        line-height: 1.5;
    }
    
    /* Enhanced styles for two-column key fields */
    .key-fields-container {
        display: flex;
        flex-wrap: wrap;
        margin: 0 -5px 15px -5px;
        padding-bottom: 5px;
    }
    
    .key-field {
        width: 50%;
        padding: 0 5px;
        margin-bottom: 10px;
        box-sizing: border-box;
    }
    
    .key-field.full-width {
        width: 100%;
    }
    
    .key-field-container {
        background-color: #f8fafc;
        border-radius: 6px;
        border: 1px solid rgba(203, 213, 225, 0.5);
        padding: 8px 12px;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .key-field-label {
        font-weight: 700;
        color: #374151;
        font-size: 12px;
        margin-bottom: 4px;
        display: flex;
        align-items: center;
        line-height: 1.3;
        letter-spacing: 0.01em;
    }
    
    .key-field-label i {
        margin-right: 5px;
        opacity: 0.7;
        font-size: 14px;
        width: 16px;
        text-align: center;
        color: #4b5563;
    }
    
    .key-field-value {
        font-size: 14px;
        color: #111827;
        word-break: break-word;
        font-weight: 500;
        line-height: 1.4;
    }
    
    /* Action buttons at the bottom of cards */
    .mobile-card-actions {
        display: flex;
        gap: 10px;
        margin-top: 15px;
        padding-top: 10px;
        border-top: 1px solid #e5e7eb;
    }
    
    /* Make action buttons touch-friendly */
    .mobile-card-actions .btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px 15px;
        border-radius: 6px;
        font-weight: 500;
        flex: 1;
    }
    
    /* View more/less section for additional details */
    .mobile-card-details {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #e5e7eb;
        display: none;
    }
    
    .mobile-card-details.active {
        display: block;
    }
    
    .mobile-card-toggle {
        background: none;
        border: none;
        color: #2563eb;
        padding: 5px 0;
        font-size: 14px;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 5px;
        margin-top: 10px;
    }
    
    /* Hide details rows in tables */
    .details-row {
        display: none !important;
    }
    
    /* Status badges in cards */
    .mobile-card .status-badge {
        margin-bottom: 10px;
        display: inline-block;
    }
}

/* ===== CONSOLIDATED ACTIONS ===== */
@media (max-width: 1199px) {
    /* Floating action button */
    .mobile-fab {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary-blue, #2563eb);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
        z-index: 100;
        border: none;
        font-size: 24px;
    }
    
    /* FAB menu */
    .mobile-fab-menu {
        position: fixed;
        bottom: 90px;
        right: 20px;
        display: flex;
        flex-direction: column;
        gap: 15px;
        z-index: 99;
        opacity: 0;
        transform: translateY(20px);
        transition: all 0.3s ease;
        pointer-events: none;
    }
    
    .mobile-fab-menu.active {
        opacity: 1;
        transform: translateY(0);
        pointer-events: all;
    }
    
    .mobile-fab-item {
        display: flex;
        align-items: center;
        background: white;
        padding: 10px 15px;
        border-radius: 30px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        font-weight: 500;
        color: #1f2937;
        text-decoration: none;
        gap: 8px;
        min-height: 44px;
    }
    
    .mobile-fab-item i {
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--primary-blue, #2563eb);
        color: white;
        border-radius: 50%;
    }
    
    /* Kebab menu for secondary actions */
    .mobile-kebab-menu {
        position: absolute;
        top: 10px;
        right: 10px;
        background: none;
        border: none;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #6b7280;
        z-index: 10;
    }
    
    .mobile-dropdown-menu {
        position: absolute;
        top: 40px;
        right: 0;
        background: white;
        border-radius: 8px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        min-width: 180px;
        display: none;
        z-index: 100;
    }
    
    .mobile-dropdown-menu.active {
        display: block;
    }
    
    .mobile-dropdown-item {
        padding: 12px 15px;
        display: flex;
        align-items: center;
        gap: 10px;
        color: #1f2937;
        text-decoration: none;
        border-bottom: 1px solid #f3f4f6;
        min-height: 44px;
    }
    
    .mobile-dropdown-item:last-child {
        border-bottom: none;
    }
    
    /* Hide desktop action buttons */
    .header-actions .btn {
        display: none;
    }
}

/* ===== CALENDAR MOBILE OPTIMIZATIONS ===== */
@media (max-width: 1199px) {
    /* Default to list/agenda view */
    .fc-view-container .fc-month-view {
        display: none;
    }
    
    .fc-view-container .fc-listWeek-view {
        display: block !important;
    }
    
    /* Make day cells larger for touch */
    .fc-day {
        min-height: 60px;
    }
    
    /* Collapse filter panel into banner */
    .calendar-page .filter-section {
        padding: 10px;
        margin-bottom: 15px;
        cursor: pointer;
    }
    
    .calendar-page .filter-content {
        display: none;
    }
    
    .calendar-page .filter-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0;
        background: none;
        border: none;
    }
    
    .calendar-page .filter-header h3 {
        font-size: 16px;
        margin: 0;
    }
    
    .calendar-page .filter-header:after {
        content: "\f107";
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: 16px;
    }
    
    /* Calendar container styles */
    .fc-view-container {
        margin-top: 15px;
        height: auto !important;
        min-height: 500px;
    }
    
    /* Make calendar stretch edge to edge */
    .calendar-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: -15px;
        margin-right: -15px;
        width: calc(100% + 30px);
    }
    
    /* Remove extra padding from calendar wrapper */
    .fc {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Calendar event indicators */
    .fc-day-grid-event {
        margin: 1px 0;
        padding: 2px 5px;
    }
    
    /* Maximize space for calendar */
    .dashboard-container {
        padding: 10px;
    }
    
    .page-header-modern {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    /* Touch-friendly buttons */
    .fc button {
        height: 44px;
        font-size: 14px;
    }
}

/* ===== EXTRA SMALL DEVICES ===== */
@media (max-width: 480px) {
    /* Further optimize for very small screens */
    .dashboard-container {
        padding: 8px;
    }
    
    .page-header-modern {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .header-left h1.page-title-modern {
        font-size: 1.5rem;
    }
    
    /* Smaller action buttons */
    .mobile-card-actions {
        flex-wrap: wrap;
    }
    
    .mobile-card-actions .btn {
        flex: 0 0 calc(50% - 5px);
    }
    
    /* Simplified table cards */
    .table-responsive table tbody tr {
        padding: 12px 10px;
    }
    
    .table-responsive table tbody td {
        padding: 6px 5px;
        padding-left: 45%;
        font-size: 13px;
    }
}

/* ===== MODERN CRM RESPONSIVE SHELL =====
 * Newer CRM pages use their own page headers, dense tables and split layouts.
 * These overrides preserve desktop styling while making laptop-width windows,
 * tablets and phones use a predictable single-column app shell.
 */
@media (max-width: 1199px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .app-container {
        width: 100%;
        overflow-x: hidden;
    }

    .mobile-menu-toggle {
        display: flex !important;
    }

    .sidebar,
    .sidebar.collapsed {
        position: fixed !important;
        top: 0 !important;
        left: -290px !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 2000 !important;
        border-radius: 0 !important;
        transition: left 0.25s ease !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .sidebar.mobile-open,
    .sidebar.collapsed.mobile-open {
        left: 0 !important;
    }

    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .nav-section-title,
    .sidebar.collapsed .sidebar-brand span,
    .sidebar.collapsed .sidebar-footer .nav-item span,
    .sidebar.collapsed .sidebar-toggle-btn span {
        opacity: 1 !important;
        width: auto !important;
        overflow: visible !important;
    }

    .sidebar.collapsed .nav-item,
    .sidebar.collapsed .sidebar-toggle-btn {
        justify-content: flex-start !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    .sidebar.collapsed .nav-item i {
        margin-right: 10px !important;
    }

    .mobile-overlay.active {
        display: block !important;
        z-index: 1990 !important;
    }

    .main-content,
    .sidebar.collapsed ~ .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 76px 16px 20px !important;
        overflow-x: hidden;
    }

    .main-content.modern-page {
        padding: 76px 16px 20px !important;
    }

    .modern-page > *,
    .dashboard-container,
    .dashboard-page,
    .tasks-page-container,
    .outreach-page,
    .tools-shell,
    .sop-container {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .page-header-modern,
    .outreach-header {
        padding: 18px !important;
        margin-bottom: 16px !important;
        border-radius: 10px !important;
    }

    .page-header-modern .header-content,
    .outreach-header-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px !important;
    }

    .page-title-modern,
    .outreach-title {
        font-size: 1.55rem !important;
        line-height: 1.18 !important;
        gap: 10px !important;
        overflow-wrap: anywhere;
    }

    .page-subtitle,
    .outreach-subtitle {
        font-size: 0.95rem !important;
        line-height: 1.45 !important;
    }

    .header-actions,
    .outreach-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        gap: 10px !important;
        margin-left: 0 !important;
        width: 100%;
    }

    .header-actions .btn,
    .header-actions .btn-unified,
    .outreach-actions .btn-outreach {
        display: inline-flex !important;
        flex: 1 1 150px;
        min-height: 42px;
        white-space: normal;
    }

    .card,
    .panel,
    .panel-default,
    .panel-primary,
    .card-modern,
    .outreach-card {
        border-radius: 8px !important;
        padding: 14px !important;
    }

    .table-responsive {
        width: 100%;
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Modern pages favour readable scrollable tables over broken pseudo-cards. */
    .modern-page .table-responsive table,
    .modern-page table.outreach-table {
        min-width: 720px;
    }

    .modern-page .table-responsive table thead {
        display: table-header-group !important;
    }

    .modern-page .table-responsive table tbody tr {
        display: table-row !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .modern-page .table-responsive table tbody td {
        display: table-cell !important;
        min-height: 0 !important;
        padding: 10px 12px !important;
        border-bottom: 1px solid #e5e7eb !important;
        text-align: left !important;
        vertical-align: middle !important;
        white-space: normal;
        word-break: normal;
        overflow-wrap: anywhere;
    }

    .modern-page .table-responsive table tbody td::before {
        content: none !important;
        display: none !important;
    }

    .modern-page .table-responsive .btn,
    .modern-page .table-responsive .btn-unified,
    .outreach-row-actions .outreach-icon-btn {
        min-width: 40px;
        min-height: 38px;
        margin: 2px;
    }

    .modal,
    .absolute.inset-0 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .modal-dialog,
    .modal-dialog.modal-lg {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        margin: 12px auto !important;
    }

    .modal-content {
        max-height: calc(100vh - 24px);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    input,
    select,
    textarea,
    .form-control {
        max-width: 100%;
    }
}

/* Tablet and narrow laptop layouts */
@media (max-width: 980px) {
    .crm-dashboard-grid,
    .outreach-stats,
    .tools-grid,
    .sop-layout {
        grid-template-columns: 1fr !important;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    #tasksMainSplit {
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    #listsSidebar {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        border-right: 0 !important;
        border-bottom: 1px solid #e2e8f0 !important;
        max-height: 360px;
    }

    #listsResizeHandle {
        display: none !important;
    }

    #taskTableScrollPanel {
        overflow: visible !important;
        padding: 14px !important;
    }

    #taskControlsBar {
        gap: 12px !important;
    }

    #taskControlsBar > .relative,
    #taskControlsBar > div {
        width: 100%;
    }

    #taskControlsBar input {
        padding-top: 14px !important;
        padding-bottom: 14px !important;
        font-size: 1rem !important;
    }

    #sortMenu,
    #taskFilterMenu,
    #listFiltersPopup,
    #listsViewMenu {
        position: fixed !important;
        left: 16px !important;
        right: 16px !important;
        top: auto !important;
        bottom: 18px !important;
        width: auto !important;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        z-index: 3000 !important;
    }

    .outreach-live-scans,
    .outreach-form-grid {
        grid-template-columns: 1fr !important;
    }

    .outreach-search-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Phone layouts */
@media (max-width: 640px) {
    .main-content,
    .main-content.modern-page,
    .sidebar.collapsed ~ .main-content {
        padding: 72px 10px 16px !important;
    }

    .page-header-modern,
    .outreach-header {
        padding: 16px !important;
    }

    .page-title-modern,
    .outreach-title {
        font-size: 1.35rem !important;
    }

    .header-actions .btn,
    .header-actions .btn-unified,
    .outreach-actions .btn-outreach {
        flex-basis: 100%;
        width: 100%;
    }

    .stat-grid,
    .outreach-stats {
        grid-template-columns: 1fr !important;
    }

    .tools-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .tool-card {
        padding: 16px !important;
    }

    .sop-step {
        grid-template-columns: 32px minmax(0, 1fr) !important;
    }

    .sop-step-shot {
        grid-column: 1 / -1 !important;
        max-width: 100% !important;
    }

    .modern-page .table-responsive table,
    .modern-page table.outreach-table {
        min-width: 680px;
    }

    .outreach-table th,
    .outreach-table td {
        padding: 10px 9px !important;
    }

    #tasksMainSplit .p-8,
    #tasksMainSplit .p-6,
    #tasksMainSplit .p-5,
    #tasksMainSplit .p-4 {
        padding: 12px !important;
    }

    #tasksMainSplit button {
        min-height: 40px;
    }

    #listsSidebar > .p-4 > .flex {
        flex-wrap: wrap !important;
    }

    #listsSidebar > .p-4 > .flex > * {
        flex: 1 1 140px;
    }

    #tasksPageRoot .page-header-modern .header-actions,
    #tasksPageRoot .page-header-modern .header-actions button {
        width: 100%;
    }
}

/* ===== CRM COMPACT TABLE CARDS ===== */
@media (max-width: 1199px) {
    .modern-page .table-responsive.crm-card-table-wrap {
        overflow: visible !important;
    }

    .modern-page .table-responsive table.crm-card-table,
    .modern-page table.crm-card-table {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        border: 0 !important;
        border-collapse: separate !important;
        background: transparent !important;
    }

    .modern-page .table-responsive table.crm-card-table thead,
    .modern-page table.crm-card-table thead {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody,
    .modern-page table.crm-card-table tbody {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        width: 100%;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr,
    .modern-page table.crm-card-table tbody tr {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
        gap: 7px 12px;
        margin: 0 !important;
        padding: 12px !important;
        min-width: 0;
        border: 1px solid #dbe3ef !important;
        border-left: 4px solid var(--status-border-color, #2563eb) !important;
        border-radius: 8px !important;
        background: var(--status-row-bg, #ffffff) !important;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06) !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.crm-card-empty-row,
    .modern-page table.crm-card-table tbody tr.crm-card-empty-row,
    .modern-page .table-responsive table.crm-card-table tbody tr.details-row,
    .modern-page table.crm-card-table tbody tr.details-row {
        grid-column: 1 / -1;
        display: block !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td,
    .modern-page table.crm-card-table tbody td {
        display: grid !important;
        grid-template-columns: minmax(76px, 34%) minmax(0, 1fr);
        align-items: center;
        gap: 8px;
        min-height: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        color: #0f172a;
        font-size: 12.5px;
        line-height: 1.25;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .modern-page .table-responsive table.crm-card-table tbody td::before,
    .modern-page table.crm-card-table tbody td::before {
        content: attr(data-title) !important;
        display: block !important;
        width: auto !important;
        margin: 0 !important;
        color: #64748b;
        font-size: 10px;
        font-weight: 900;
        line-height: 1.2;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"],
    .modern-page table.crm-card-table tbody td[data-title="Name"],
    .modern-page table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page table.crm-card-table tbody td[data-title="Deal"] {
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
        gap: 2px;
        font-size: 14px;
        font-weight: 800;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Name"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Company Name"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Deal"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"],
    .modern-page table.crm-card-table tbody td[data-title="Select"],
    .modern-page table.crm-card-table tbody td[data-title="Details"] {
        grid-column: auto;
        grid-template-columns: 1fr;
        align-items: center;
        justify-items: start;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Select"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Details"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"],
    .modern-page table.crm-card-table tbody td[data-title="Actions"] {
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
        padding-top: 4px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Actions"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] .btn-group,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] > div,
    .modern-page table.crm-card-table tbody td[data-title="Actions"] .btn-group,
    .modern-page table.crm-card-table tbody td[data-title="Actions"] > div {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        align-items: center !important;
    }

    .modern-page .table-responsive table.crm-card-table .btn,
    .modern-page .table-responsive table.crm-card-table .btn-unified,
    .modern-page table.crm-card-table .btn,
    .modern-page table.crm-card-table .btn-unified {
        min-width: 34px !important;
        min-height: 32px !important;
        padding: 6px 8px !important;
        margin: 0 !important;
        font-size: 12px !important;
        border-radius: 6px !important;
    }

    .modern-page .table-responsive table.crm-card-table select,
    .modern-page table.crm-card-table select {
        max-width: 100%;
        min-height: 30px;
        font-size: 12px !important;
        padding: 4px 8px !important;
    }

    .modern-page .table-responsive table.crm-card-table a,
    .modern-page table.crm-card-table a {
        overflow-wrap: anywhere;
    }

    .deals-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .deals-stat {
        padding: 12px !important;
    }

    .deals-stat strong {
        font-size: 1.35rem !important;
    }
}

@media (max-width: 767px) {
    .modern-page .table-responsive table.crm-card-table tbody,
    .modern-page table.crm-card-table tbody {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr,
    .modern-page table.crm-card-table tbody tr {
        padding: 10px !important;
        gap: 6px 10px;
    }

    .modern-page .table-responsive table.crm-card-table tbody td,
    .modern-page table.crm-card-table tbody td {
        grid-template-columns: minmax(70px, 32%) minmax(0, 1fr);
        font-size: 12px;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Number"],
    .modern-page table.crm-card-table tbody td[data-title="Email"],
    .modern-page table.crm-card-table tbody td[data-title="Phone"],
    .modern-page table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page table.crm-card-table tbody td[data-title="Number"] {
        grid-column: 1 / -1;
    }

    .deals-panel-header {
        align-items: stretch !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
}

/* CRM list table consistency on desktop and responsive views */
.modern-page #customersTable thead th,
.modern-page #organizationsTable thead th,
.modern-page .deals-table thead th {
    background: #1f2937 !important;
    border-color: #111827 !important;
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 900 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
}

.modern-page .table-card-unified,
.modern-page .card-modern,
.modern-page .deals-panel {
    overflow: hidden;
}

.modern-page .table-card-unified .panel-body.no-padding,
.modern-page .card-modern .table-responsive,
.modern-page .deals-panel .table-responsive {
    padding: 0 !important;
    margin: 0 !important;
}

.modern-page .table-card-unified .help-section[style*="display: none"],
.modern-page .table-card-unified .help-section:not(.is-open) {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
}

@media (max-width: 1199px) {
    .modern-page .table-responsive table.crm-card-table tbody,
    .modern-page table.crm-card-table tbody {
        gap: 12px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr,
    .modern-page table.crm-card-table tbody tr {
        position: relative;
        grid-template-columns: 58px minmax(0, 1fr) auto !important;
        grid-auto-rows: min-content;
        gap: 6px 10px !important;
        padding: 12px 14px 12px 12px !important;
        min-height: 126px;
        border: 1px solid #dbeafe !important;
        border-left: 4px solid var(--status-border-color, #2563eb) !important;
        border-radius: 10px !important;
        background: color-mix(in srgb, var(--status-row-bg, #ffffff) 34%, #ffffff) !important;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08) !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr::before,
    .modern-page table.crm-card-table tbody tr::before {
        content: attr(data-card-initials);
        grid-column: 1;
        grid-row: 1 / span 3;
        align-self: start;
        width: 46px;
        height: 46px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 18px;
        background: var(--crm-card-image, linear-gradient(135deg, #2563eb 0%, #0891b2 100%));
        background-size: cover;
        background-position: center;
        border: 3px solid #dbeafe;
        color: #ffffff;
        font-size: 16px;
        font-weight: 900;
        box-shadow: 0 2px 8px rgba(37, 99, 235, 0.18);
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.has-card-image::before,
    .modern-page table.crm-card-table tbody tr.has-card-image::before {
        content: "";
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row::before,
    .modern-page .table-responsive table.crm-card-table tbody tr.crm-card-empty-row::before,
    .modern-page table.crm-card-table tbody tr.details-row::before,
    .modern-page table.crm-card-table tbody tr.crm-card-empty-row::before {
        content: none !important;
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row:not(:has(.collapse.in)):not(:has(.show)),
    .modern-page table.crm-card-table tbody tr.details-row:not(:has(.collapse.in)):not(:has(.show)) {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row:has(.collapse.in),
    .modern-page .table-responsive table.crm-card-table tbody tr.details-row:has(.show),
    .modern-page table.crm-card-table tbody tr.details-row:has(.collapse.in),
    .modern-page table.crm-card-table tbody tr.details-row:has(.show) {
        grid-column: 1 / -1;
        display: block !important;
        min-height: 0 !important;
        padding: 10px !important;
        border-left-color: #93c5fd !important;
        background: #ffffff !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td,
    .modern-page table.crm-card-table tbody td {
        grid-template-columns: minmax(74px, 30%) minmax(0, 1fr) !important;
        font-size: 12px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"],
    .modern-page table.crm-card-table tbody td[data-title="Name"],
    .modern-page table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page table.crm-card-table tbody td[data-title="Deal"] {
        grid-column: 2 / 3 !important;
        grid-row: 1;
        align-self: end;
        font-size: 14px !important;
        line-height: 1.2 !important;
        min-width: 0;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"] a,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"] strong,
    .modern-page table.crm-card-table tbody td[data-title="Name"] a,
    .modern-page table.crm-card-table tbody td[data-title="Deal"] strong {
        color: #0f172a !important;
        font-weight: 900 !important;
        text-decoration: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"],
    .modern-page table.crm-card-table tbody td[data-title="Email"] {
        grid-column: 2 / -1 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"] *,
    .modern-page table.crm-card-table tbody td[data-title="Email"] * {
        min-width: 0;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"],
    .modern-page table.crm-card-table tbody td[data-title="Select"] {
        position: absolute;
        top: 10px;
        left: 10px;
        display: block !important;
        width: 20px;
        height: 20px;
        z-index: 2;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"],
    .modern-page table.crm-card-table tbody td[data-title="Details"] {
        position: absolute;
        top: 9px;
        right: 10px;
        display: block !important;
        width: 30px;
        height: 30px;
        z-index: 2;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"] .expand-btn,
    .modern-page table.crm-card-table tbody td[data-title="Details"] .expand-btn {
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        min-height: 30px !important;
        border-radius: 999px !important;
        background: #dbeafe !important;
        color: #2563eb !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"],
    .modern-page table.crm-card-table tbody td[data-title="Status"] {
        grid-column: 3 / 4 !important;
        grid-row: 1;
        justify-self: end;
        align-self: center;
        grid-template-columns: 1fr !important;
        min-width: 112px;
        padding-right: 34px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Status"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"],
    .modern-page table.crm-card-table tbody td[data-title="Actions"] {
        grid-column: 2 / -1 !important;
        align-self: end;
        padding-top: 4px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] .btn-group,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] > div,
    .modern-page table.crm-card-table tbody td[data-title="Actions"] .btn-group,
    .modern-page table.crm-card-table tbody td[data-title="Actions"] > div {
        justify-content: flex-start !important;
    }

    .modern-page .table-responsive table.crm-card-table .btn,
    .modern-page .table-responsive table.crm-card-table .btn-unified,
    .modern-page table.crm-card-table .btn,
    .modern-page table.crm-card-table .btn-unified {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        padding: 0 !important;
    }
}

@media (max-width: 767px) {
    .modern-page .table-responsive table.crm-card-table tbody tr,
    .modern-page table.crm-card-table tbody tr {
        grid-template-columns: 52px minmax(0, 1fr) auto !important;
        min-height: 118px;
        padding: 10px 12px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr::before,
    .modern-page table.crm-card-table tbody tr::before {
        width: 42px;
        height: 42px;
        margin-top: 18px;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"],
    .modern-page table.crm-card-table tbody td[data-title="Status"] {
        grid-column: 2 / -1 !important;
        grid-row: auto;
        justify-self: stretch;
        padding-right: 0 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"] select,
    .modern-page table.crm-card-table tbody td[data-title="Status"] select {
        width: 100%;
    }
}

/* Final responsive CRM polish: keep desktop tables intact, use compact cards below laptop widths. */
.mobile-top-logo {
    display: none;
}

.modern-page .companies-table-card {
    padding: 0 !important;
}

@media (max-width: 1199px) {
    .mobile-top-logo {
        align-items: center;
        background: rgba(255, 255, 255, 0.96);
        border: 1px solid #dbeafe;
        border-radius: 14px;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
        display: flex !important;
        height: 50px;
        justify-content: center;
        padding: 6px 10px;
        position: fixed;
        right: 16px;
        top: 16px;
        width: 74px;
        z-index: 1800;
    }

    .mobile-top-logo img {
        display: block;
        height: 38px;
        max-width: 56px;
        object-fit: contain;
        width: auto;
    }

    .sidebar.mobile-open,
    .sidebar.collapsed.mobile-open {
        display: flex !important;
        flex-direction: column !important;
        left: 0 !important;
        visibility: visible !important;
    }

    .sidebar.mobile-open > *,
    .sidebar.collapsed.mobile-open > *,
    .sidebar.mobile-open .nav-menu,
    .sidebar.collapsed.mobile-open .nav-menu,
    .sidebar.mobile-open .nav-section,
    .sidebar.collapsed.mobile-open .nav-section,
    .sidebar.mobile-open .sidebar-footer,
    .sidebar.collapsed.mobile-open .sidebar-footer {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .sidebar.mobile-open .sidebar-brand,
    .sidebar.collapsed.mobile-open .sidebar-brand {
        display: flex !important;
        justify-content: flex-end !important;
        min-height: 108px !important;
        opacity: 1 !important;
        padding: 22px 22px 12px !important;
        visibility: visible !important;
    }

    .sidebar.mobile-open .sidebar-brand img,
    .sidebar.collapsed.mobile-open .sidebar-brand img {
        display: block !important;
        height: 72px !important;
        opacity: 1 !important;
        visibility: visible !important;
        width: auto !important;
    }

    .sidebar.mobile-open .nav-item,
    .sidebar.collapsed.mobile-open .nav-item {
        display: flex !important;
        justify-content: flex-start !important;
        opacity: 1 !important;
        visibility: visible !important;
        white-space: normal !important;
    }

    .sidebar.mobile-open .nav-item span,
    .sidebar.collapsed.mobile-open .nav-item span,
    .sidebar.mobile-open .sidebar-toggle-btn span,
    .sidebar.collapsed.mobile-open .sidebar-toggle-btn span {
        color: #ffffff !important;
        display: inline !important;
        opacity: 1 !important;
        overflow: visible !important;
        visibility: visible !important;
        width: auto !important;
    }

    body .mobile-filter-toggle {
        border-radius: 10px !important;
        bottom: 8px !important;
        height: 48px !important;
        left: 16px !important;
        max-width: 420px !important;
        right: auto !important;
        transform: none !important;
        width: calc(100vw - 32px) !important;
        z-index: 9996 !important;
    }

    body #globalNotificationsFab {
        bottom: 74px !important;
        height: 56px !important;
        right: 18px !important;
        width: 56px !important;
        z-index: 9997 !important;
    }

    body #globalNotificationsPanel {
        bottom: 138px !important;
        right: 12px !important;
    }

    .modern-page .page-header-modern,
    .modern-page .deals-header {
        border-radius: 10px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .modern-page .table-card-unified,
    .modern-page .card-modern,
    .modern-page .deals-panel {
        border-radius: 10px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody,
    .modern-page table.crm-card-table tbody {
        display: grid !important;
        gap: 12px !important;
        grid-template-columns: repeat(2, minmax(280px, 1fr)) !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr,
    .modern-page table.crm-card-table tbody tr {
        align-items: start !important;
        display: grid !important;
        gap: 5px 12px !important;
        grid-template-columns: 52px minmax(0, 1fr) auto !important;
        min-height: 0 !important;
        padding: 12px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td,
    .modern-page table.crm-card-table tbody td {
        align-items: center !important;
        border: 0 !important;
        display: grid !important;
        font-size: 12px !important;
        gap: 8px !important;
        grid-template-columns: 88px minmax(0, 1fr) !important;
        min-height: 0 !important;
        min-width: 0 !important;
        padding: 0 !important;
        width: auto !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td::before,
    .modern-page table.crm-card-table tbody td::before {
        color: #475569 !important;
        content: attr(data-title);
        display: block !important;
        font-size: 10px !important;
        font-weight: 900 !important;
        letter-spacing: 0.04em !important;
        line-height: 1.1 !important;
        min-width: 0 !important;
        text-transform: uppercase !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"],
    .modern-page table.crm-card-table tbody td[data-title="Name"],
    .modern-page table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page table.crm-card-table tbody td[data-title="Deal"] {
        align-self: center !important;
        display: block !important;
        font-size: 14px !important;
        grid-column: 2 / 3 !important;
        grid-row: 1 !important;
        line-height: 1.2 !important;
        padding-right: 6px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Name"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Company Name"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Deal"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"],
    .modern-page table.crm-card-table tbody td[data-title="Select"] {
        grid-column: 3 / 4 !important;
        grid-row: 1 !important;
        justify-self: end !important;
        position: static !important;
        width: auto !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"],
    .modern-page table.crm-card-table tbody td[data-title="Details"] {
        grid-column: 1 / 2 !important;
        grid-row: 2 !important;
        justify-self: center !important;
        position: static !important;
        width: auto !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Last Contact"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Date"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Date Booked"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Value"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Stage"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Close Date"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Last Deal"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Total Deals"],
    .modern-page table.crm-card-table tbody td[data-title="Company"],
    .modern-page table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page table.crm-card-table tbody td[data-title="Email"],
    .modern-page table.crm-card-table tbody td[data-title="Phone"],
    .modern-page table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page table.crm-card-table tbody td[data-title="Number"],
    .modern-page table.crm-card-table tbody td[data-title="Last Contact"],
    .modern-page table.crm-card-table tbody td[data-title="Date"],
    .modern-page table.crm-card-table tbody td[data-title="Date Booked"],
    .modern-page table.crm-card-table tbody td[data-title="Value"],
    .modern-page table.crm-card-table tbody td[data-title="Stage"],
    .modern-page table.crm-card-table tbody td[data-title="Close Date"],
    .modern-page table.crm-card-table tbody td[data-title="Last Deal"],
    .modern-page table.crm-card-table tbody td[data-title="Total Deals"] {
        grid-column: 2 / -1 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Number"],
    .modern-page table.crm-card-table tbody td[data-title="Email"],
    .modern-page table.crm-card-table tbody td[data-title="Phone"],
    .modern-page table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page table.crm-card-table tbody td[data-title="Number"] {
        white-space: nowrap !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"] *,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone"] *,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone Number"] *,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Number"] *,
    .modern-page table.crm-card-table tbody td[data-title="Email"] *,
    .modern-page table.crm-card-table tbody td[data-title="Phone"] *,
    .modern-page table.crm-card-table tbody td[data-title="Phone Number"] *,
    .modern-page table.crm-card-table tbody td[data-title="Number"] * {
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"],
    .modern-page table.crm-card-table tbody td[data-title="Actions"] {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        grid-column: 2 / -1 !important;
        justify-content: flex-start !important;
        padding-top: 4px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Actions"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] .btn,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] .btn-unified,
    .modern-page table.crm-card-table tbody td[data-title="Actions"] .btn,
    .modern-page table.crm-card-table tbody td[data-title="Actions"] .btn-unified {
        border-radius: 7px !important;
        flex: 0 0 34px !important;
        height: 34px !important;
        width: 34px !important;
    }
}

@media (max-width: 767px) {
    .main-content,
    .main-content.modern-page,
    .sidebar.collapsed ~ .main-content {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody,
    .modern-page table.crm-card-table tbody {
        grid-template-columns: 1fr !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr,
    .modern-page table.crm-card-table tbody tr {
        grid-template-columns: 52px minmax(0, 1fr) 22px !important;
        padding: 11px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td,
    .modern-page table.crm-card-table tbody td {
        grid-template-columns: 82px minmax(0, 1fr) !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"],
    .modern-page table.crm-card-table tbody td[data-title="Status"] {
        grid-column: 2 / -1 !important;
        justify-self: stretch !important;
        min-width: 0 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Status"]::before {
        display: block !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"] select,
    .modern-page table.crm-card-table tbody td[data-title="Status"] select {
        min-width: 0 !important;
        width: 100% !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"],
    .modern-page table.crm-card-table tbody td[data-title="Actions"] {
        grid-column: 2 / -1 !important;
    }
}

/* Mobile cards/control fixes layered last so older page scripts cannot win. */
@media (max-width: 1199px) {
    body .mobile-fab,
    body .mobile-fab-menu {
        display: none !important;
    }

    .modern-page .companies-table-card {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    .modern-page .companies-table-card .table-responsive {
        overflow: visible !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr:not(.details-row),
    .modern-page table.crm-card-table tbody tr:not(.details-row) {
        border: 1px solid #bfdbfe !important;
        border-left: 4px solid var(--status-border-color, #2563eb) !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr::before,
    .modern-page table.crm-card-table tbody tr::before {
        pointer-events: none !important;
        z-index: 1 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row,
    .modern-page table.crm-card-table tbody tr.details-row {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row:has(.collapse.in),
    .modern-page .table-responsive table.crm-card-table tbody tr.details-row:has(.show),
    .modern-page table.crm-card-table tbody tr.details-row:has(.collapse.in),
    .modern-page table.crm-card-table tbody tr.details-row:has(.show) {
        display: block !important;
        grid-column: 1 / -1 !important;
        margin-top: -4px !important;
        min-height: 0 !important;
        padding: 8px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row .collapse:not(.in):not(.show),
    .modern-page table.crm-card-table tbody tr.details-row .collapse:not(.in):not(.show) {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row::before,
    .modern-page table.crm-card-table tbody tr.details-row::before {
        content: none !important;
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"],
    .modern-page table.crm-card-table tbody td[data-title="Details"] {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
        justify-self: center !important;
        margin-top: 42px !important;
        position: relative !important;
        width: auto !important;
        z-index: 5 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"] button,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"] a,
    .modern-page table.crm-card-table tbody td[data-title="Details"] button,
    .modern-page table.crm-card-table tbody td[data-title="Details"] a {
        pointer-events: auto !important;
        position: relative !important;
        z-index: 6 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"] .expand-btn,
    .modern-page table.crm-card-table tbody td[data-title="Details"] .expand-btn {
        background: #dbeafe !important;
        border: 0 !important;
        color: #2563eb !important;
    }

    .mobile-filter-content .mobile-filter-toggle,
    .mobile-filter-content button.mobile-filter-toggle {
        display: none !important;
    }
}

/* Final mobile shell/card fixes: appended after legacy rules so phones and resized views match. */
#globalNotificationSettingsModal {
    z-index: 10080 !important;
}

body.notification-settings-open .modal-backdrop {
    z-index: 10070 !important;
}

@media (max-width: 1199px) {
    body.mobile-menu-is-open .mobile-filter-toggle,
    body.mobile-filter-open .mobile-filter-toggle,
    body.mobile-filter-open #globalNotificationsFab {
        display: none !important;
    }

    .sidebar.mobile-open .sidebar-brand,
    .sidebar.collapsed.mobile-open .sidebar-brand,
    .sidebar.mobile-open .sidebar-brand img,
    .sidebar.collapsed.mobile-open .sidebar-brand img {
        display: none !important;
        min-height: 0 !important;
        opacity: 0 !important;
        padding: 0 !important;
        visibility: hidden !important;
    }

    #mobileMenuToggle {
        z-index: 2200 !important;
    }

    #mobileMenuToggle i.fa-times {
        color: #ffffff !important;
    }

    .mobile-overlay.active {
        z-index: 170 !important;
    }

    .mobile-filter-modal {
        z-index: 10020 !important;
    }

    .mobile-filter-drawer {
        border-radius: 16px 16px 0 0 !important;
        max-height: calc(100vh - 16px) !important;
        padding: 18px !important;
        z-index: 10021 !important;
    }

    .mobile-filter-content {
        display: grid !important;
        gap: 12px !important;
    }

    .mobile-filter-content .filter-section,
    .mobile-filter-content .filter-section-unified,
    .mobile-filter-section-clone {
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 12px !important;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06) !important;
        display: block !important;
        margin: 0 !important;
        padding: 12px !important;
    }

    .mobile-filter-actions {
        background: #ffffff !important;
        border-top: 1px solid #e2e8f0 !important;
        display: grid !important;
        gap: 10px !important;
        grid-template-columns: 1fr 1fr !important;
        margin-top: 14px !important;
        padding-top: 14px !important;
        position: static !important;
    }

    .mobile-filter-actions .btn {
        border-radius: 12px !important;
        min-height: 44px !important;
        width: 100% !important;
    }

    .main-content.modern-page {
        padding-bottom: 108px !important;
    }

    .dataTables_wrapper,
    .pagination-container,
    .pagination,
    .modern-pagination,
    .mobile-pagination {
        margin-bottom: 78px !important;
    }

    .dashboard-page .dashboard-group-toggle,
    .dashboard-page .dropdown-toggle,
    .dashboard-page select {
        background: #ffffff !important;
        border: 1px solid #dbe3ef !important;
        border-radius: 12px !important;
        color: #0f172a !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row.crm-details-open,
    .modern-page table.crm-card-table tbody tr.details-row.crm-details-open {
        display: block !important;
        grid-column: 1 / -1 !important;
        margin-top: -6px !important;
        min-height: 0 !important;
        padding: 8px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row:not(.crm-details-open),
    .modern-page table.crm-card-table tbody tr.details-row:not(.crm-details-open) {
        display: none !important;
    }

    #tasksPageRoot {
        overflow-x: hidden !important;
    }

    #tasksPageRoot .page-header-modern .header-content,
    #tasksPageRoot .page-header-modern .header-actions {
        align-items: stretch !important;
    }

    #tasksMainSplit {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    #listsSidebar {
        border-bottom: 1px solid #e2e8f0 !important;
        border-right: 0 !important;
        max-height: 52vh !important;
        min-height: 260px !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    #listsContainer {
        max-height: calc(52vh - 86px) !important;
        overflow-y: auto !important;
    }

    #taskTableScrollPanel {
        overflow: visible !important;
        padding: 12px !important;
    }

    #taskControlsBar {
        background: transparent !important;
        margin-bottom: 12px !important;
    }

    #taskControlsBar > div {
        width: 100% !important;
    }

    #taskControlsBar .flex.items-center.gap-3 {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        width: 100% !important;
    }
}

@media (max-width: 767px) {
    .main-content,
    .main-content.modern-page,
    .sidebar.collapsed ~ .main-content {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .mobile-top-logo {
        height: 48px !important;
        right: 18px !important;
        top: 18px !important;
        width: 68px !important;
    }

    .modern-page .table-card-unified,
    .modern-page .card-modern,
    .modern-page .companies-table-card,
    .modern-page .deals-panel,
    .modern-page .table-responsive.crm-card-table-wrap {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    .modern-page .table-responsive table.crm-card-table,
    .modern-page table.crm-card-table,
    .modern-page .table-responsive table,
    .modern-page table.outreach-table {
        display: block !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody,
    .modern-page table.crm-card-table tbody {
        display: grid !important;
        gap: 10px !important;
        grid-template-columns: 1fr !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr:not(.details-row):not(.crm-card-empty-row),
    .modern-page table.crm-card-table tbody tr:not(.details-row):not(.crm-card-empty-row) {
        align-items: start !important;
        background: #eff6ff !important;
        border: 1px solid #bfdbfe !important;
        border-left: 4px solid var(--status-border-color, #2563eb) !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08) !important;
        display: grid !important;
        gap: 5px 10px !important;
        grid-template-columns: 48px minmax(0, 1fr) 24px !important;
        margin: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
        padding: 12px !important;
        position: relative !important;
        width: 100% !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr:not(.details-row)::before,
    .modern-page table.crm-card-table tbody tr:not(.details-row)::before {
        grid-column: 1 / 2 !important;
        grid-row: 1 / span 4 !important;
        height: 38px !important;
        margin-top: 4px !important;
        width: 38px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td,
    .modern-page table.crm-card-table tbody td {
        border: 0 !important;
        display: grid !important;
        gap: 6px !important;
        grid-template-columns: 78px minmax(0, 1fr) !important;
        min-width: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td::before,
    .modern-page table.crm-card-table tbody td::before {
        color: #475569 !important;
        content: attr(data-title) !important;
        display: block !important;
        font-size: 10px !important;
        font-weight: 900 !important;
        letter-spacing: .05em !important;
        line-height: 1.15 !important;
        overflow-wrap: anywhere !important;
        text-transform: uppercase !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"],
    .modern-page table.crm-card-table tbody td[data-title="Select"] {
        display: block !important;
        grid-column: auto !important;
        grid-row: auto !important;
        height: auto !important;
        justify-self: auto !important;
        margin: 0 !important;
        position: absolute !important;
        right: 12px !important;
        top: 12px !important;
        width: auto !important;
        z-index: 8 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Select"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"],
    .modern-page table.crm-card-table tbody td[data-title="Details"] {
        display: block !important;
        grid-column: 1 / 2 !important;
        grid-row: 2 !important;
        justify-self: center !important;
        margin: 34px 0 0 !important;
        position: relative !important;
        width: 34px !important;
        z-index: 7 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Details"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"],
    .modern-page table.crm-card-table tbody td[data-title="Name"],
    .modern-page table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page table.crm-card-table tbody td[data-title="Deal"] {
        display: block !important;
        font-size: 15px !important;
        font-weight: 900 !important;
        grid-column: 2 / 3 !important;
        grid-row: 1 !important;
        line-height: 1.15 !important;
        padding-right: 26px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Name"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Company Name"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Deal"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Date"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Date Booked"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Last Contact"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Last Deal"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Total Deals"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Value"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Stage"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Close Date"],
    .modern-page table.crm-card-table tbody td[data-title="Company"],
    .modern-page table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page table.crm-card-table tbody td[data-title="Email"],
    .modern-page table.crm-card-table tbody td[data-title="Phone"],
    .modern-page table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page table.crm-card-table tbody td[data-title="Number"],
    .modern-page table.crm-card-table tbody td[data-title="Date"],
    .modern-page table.crm-card-table tbody td[data-title="Date Booked"],
    .modern-page table.crm-card-table tbody td[data-title="Last Contact"],
    .modern-page table.crm-card-table tbody td[data-title="Last Deal"],
    .modern-page table.crm-card-table tbody td[data-title="Total Deals"],
    .modern-page table.crm-card-table tbody td[data-title="Value"],
    .modern-page table.crm-card-table tbody td[data-title="Stage"],
    .modern-page table.crm-card-table tbody td[data-title="Close Date"] {
        grid-column: 2 / -1 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"] *,
    .modern-page table.crm-card-table tbody td[data-title="Email"],
    .modern-page table.crm-card-table tbody td[data-title="Email"] * {
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Number"],
    .modern-page table.crm-card-table tbody td[data-title="Phone"],
    .modern-page table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page table.crm-card-table tbody td[data-title="Number"] {
        overflow-wrap: anywhere !important;
        white-space: normal !important;
        word-break: normal !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"],
    .modern-page table.crm-card-table tbody td[data-title="Status"] {
        grid-column: 2 / -1 !important;
        max-width: 180px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"] select,
    .modern-page table.crm-card-table tbody td[data-title="Status"] select {
        border-radius: 8px !important;
        min-height: 34px !important;
        width: 100% !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"],
    .modern-page table.crm-card-table tbody td[data-title="Actions"] {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        grid-column: 2 / -1 !important;
        justify-content: flex-start !important;
        margin-top: 4px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Actions"]::before {
        display: none !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] .btn-group,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] > div,
    .modern-page table.crm-card-table tbody td[data-title="Actions"] .btn-group,
    .modern-page table.crm-card-table tbody td[data-title="Actions"] > div {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .mobile-filter-drawer {
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
    }

    .mobile-filter-actions {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 640px) {
    #tasksPageRoot .page-header-modern {
        margin-bottom: 12px !important;
    }

    #tasksPageRoot .page-header-modern .header-actions {
        display: grid !important;
        gap: 8px !important;
        grid-template-columns: 1fr !important;
    }

    #tasksPageRoot .page-header-modern .header-actions button,
    #tasksPageRoot .page-header-modern .header-actions a {
        min-height: 42px !important;
        width: 100% !important;
    }

    #tasksPageRoot > .bg-white,
    #tasksPageRoot > div > .bg-white {
        overflow: visible !important;
    }

    #tasksPageRoot .flex.items-center.gap-3.flex-nowrap.shrink-0 {
        display: grid !important;
        gap: 8px !important;
        grid-template-columns: 1fr 1fr !important;
        overflow: visible !important;
        width: 100% !important;
    }

    #tasksPageRoot .flex.items-center.gap-3.flex-nowrap.shrink-0 button,
    #tasksPageRoot .flex.items-center.gap-3.shrink-0 button {
        border-radius: 12px !important;
        justify-content: center !important;
        min-height: 42px !important;
        padding: 10px 12px !important;
        width: 100% !important;
    }

    #tasksPageRoot .flex.items-center.gap-3.shrink-0 {
        display: grid !important;
        gap: 8px !important;
        grid-template-columns: 1fr 1fr !important;
        width: 100% !important;
    }

    #listsSidebar {
        max-height: 60vh !important;
        min-height: 340px !important;
    }

    #listsContainer {
        max-height: calc(60vh - 96px) !important;
    }

    #sortMenu,
    #taskFilterMenu,
    #listFiltersPopup,
    #listsViewMenu {
        bottom: 10px !important;
        left: 10px !important;
        max-height: calc(100vh - 80px) !important;
        right: 10px !important;
        width: auto !important;
    }

    #newTaskModal {
        align-items: flex-start !important;
        overflow-y: auto !important;
        padding: 12px !important;
    }

    #newTaskModal > div {
        max-height: calc(100vh - 24px) !important;
        max-width: none !important;
        overflow-y: auto !important;
        width: 100% !important;
    }
}

/* Follow-up mobile fixes for real phone browsers. */
@media (max-width: 1199px) {
    .mobile-top-logo {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    .main-content.modern-page {
        padding-bottom: 78px !important;
    }

    .dataTables_wrapper,
    .pagination-container,
    .pagination,
    .modern-pagination,
    .mobile-pagination {
        margin-bottom: 24px !important;
    }
}

@media (max-width: 767px) {
    .modern-page .table-responsive table.crm-card-table tbody tr:not(.details-row):not(.crm-card-empty-row),
    .modern-page table.crm-card-table tbody tr:not(.details-row):not(.crm-card-empty-row) {
        grid-template-columns: 46px minmax(0, 1fr) 36px !important;
        overflow: visible !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"],
    .modern-page table.crm-card-table tbody td[data-title="Select"] {
        right: 10px !important;
        top: 10px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td,
    .modern-page table.crm-card-table tbody td {
        grid-template-columns: minmax(68px, 26%) minmax(0, 1fr) !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"],
    .modern-page table.crm-card-table tbody td[data-title="Company"],
    .modern-page table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page table.crm-card-table tbody td[data-title="Email"] {
        grid-template-columns: 1fr !important;
        gap: 2px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Primary Contact"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Company"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Primary Contact"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Email"]::before {
        margin-bottom: 1px !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company"] *,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Primary Contact"] *,
    .modern-page table.crm-card-table tbody td[data-title="Company"],
    .modern-page table.crm-card-table tbody td[data-title="Company"] *,
    .modern-page table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page table.crm-card-table tbody td[data-title="Primary Contact"] * {
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        word-break: normal !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row.crm-details-open,
    .modern-page table.crm-card-table tbody tr.details-row.crm-details-open {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        margin-top: -2px !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row.crm-details-open td,
    .modern-page table.crm-card-table tbody tr.details-row.crm-details-open td {
        display: block !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .modern-page .table-responsive table.crm-card-table tbody tr.details-row.crm-details-open td::before,
    .modern-page table.crm-card-table tbody tr.details-row.crm-details-open td::before {
        display: none !important;
    }

    .modern-page .booking-details-card,
    .modern-page .customer-details {
        max-width: 100% !important;
        overflow-wrap: anywhere !important;
    }
}

/* Projects/deals has enough columns that the compact card conversion becomes
   harder to read on desktop-sized app windows. Keep the table layout until the
   page is genuinely tablet/phone width. */
@media (min-width: 901px) and (max-width: 1199px) {
    .modern-page .deals-panel .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .modern-page .deals-panel table.deals-table.crm-card-table,
    .modern-page .deals-panel .table-responsive table.deals-table.crm-card-table {
        display: table !important;
        width: 100% !important;
        min-width: 1040px !important;
        border-collapse: collapse !important;
        background: #ffffff !important;
    }

    .modern-page .deals-panel table.deals-table.crm-card-table thead,
    .modern-page .deals-panel .table-responsive table.deals-table.crm-card-table thead {
        display: table-header-group !important;
    }

    .modern-page .deals-panel table.deals-table.crm-card-table tbody,
    .modern-page .deals-panel .table-responsive table.deals-table.crm-card-table tbody {
        display: table-row-group !important;
    }

    .modern-page .deals-panel table.deals-table.crm-card-table tbody tr,
    .modern-page .deals-panel .table-responsive table.deals-table.crm-card-table tbody tr {
        display: table-row !important;
        margin: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-left: 0 !important;
        border-radius: 0 !important;
        background: #ffffff !important;
        box-shadow: none !important;
    }

    .modern-page .deals-panel table.deals-table.crm-card-table tbody tr::before,
    .modern-page .deals-panel .table-responsive table.deals-table.crm-card-table tbody tr::before {
        content: none !important;
        display: none !important;
    }

    .modern-page .deals-panel table.deals-table.crm-card-table tbody td,
    .modern-page .deals-panel .table-responsive table.deals-table.crm-card-table tbody td {
        display: table-cell !important;
        min-height: 0 !important;
        padding: 8px !important;
        border-top: 1px solid #e5e7eb !important;
        background: transparent !important;
        color: #0f172a !important;
        font-size: .9rem !important;
        line-height: 1.35 !important;
        vertical-align: middle !important;
        white-space: normal !important;
    }

    .modern-page .deals-panel table.deals-table.crm-card-table tbody td::before,
    .modern-page .deals-panel .table-responsive table.deals-table.crm-card-table tbody td::before {
        content: none !important;
        display: none !important;
    }
}

/* Stage 3 final responsive stabilisers. Keep these last so old page rules cannot win. */
.dashboard-group-toggle .chev {
    align-items: center !important;
    background: #ffffff !important;
    border: 1px solid #dbe3ef !important;
    border-radius: 999px !important;
    color: #0f172a !important;
    display: inline-flex !important;
    height: 28px !important;
    justify-content: center !important;
    width: 28px !important;
}

@media (max-width: 1199px) {
    body.mobile-menu-open .mobile-filter-toggle,
    body.mobile-menu-open #globalNotificationsFab {
        display: none !important;
    }

    .sidebar.mobile-open .sidebar-toggle-btn,
    .sidebar.mobile-open .sidebar-brand {
        display: none !important;
    }

    .mobile-top-logo {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        height: auto !important;
        padding: 0 !important;
        right: 18px !important;
        top: 18px !important;
        width: auto !important;
    }

    .mobile-top-logo img {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        max-height: 44px !important;
        width: auto !important;
    }
}

@media (max-width: 767px) {
    .modern-page .table-card-unified,
    .modern-page .companies-table-card {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .modern-page .table-card-unified > .panel-body,
    .modern-page .companies-table-card > .panel-body,
    .modern-page .card-modern {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .modern-page .table-responsive.crm-card-table-wrap,
    .modern-page .table-responsive {
        overflow: visible !important;
    }

    .modern-page table.crm-card-table,
    .modern-page .table-responsive table.crm-card-table {
        border-collapse: separate !important;
        border-spacing: 0 12px !important;
    }

    .modern-page table.crm-card-table tbody,
    .modern-page .table-responsive table.crm-card-table tbody {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .modern-page table.crm-card-table tbody tr:not(.details-row):not(.crm-card-empty-row),
    .modern-page .table-responsive table.crm-card-table tbody tr:not(.details-row):not(.crm-card-empty-row) {
        align-items: start !important;
        background: #eff6ff !important;
        border: 1px solid #bfdbfe !important;
        border-left: 5px solid #2563eb !important;
        border-radius: 14px !important;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07) !important;
        display: grid !important;
        gap: 6px 10px !important;
        grid-template-columns: 52px minmax(0, 1fr) 34px 34px !important;
        margin: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
        padding: 12px !important;
        position: relative !important;
        width: 100% !important;
    }

    .modern-page table.crm-card-table tbody tr:not(.details-row):not(.crm-card-empty-row)::before,
    .modern-page .table-responsive table.crm-card-table tbody tr:not(.details-row):not(.crm-card-empty-row)::before {
        grid-column: 1 !important;
        grid-row: 1 / span 2 !important;
        margin: 0 !important;
        position: static !important;
    }

    .modern-page table.crm-card-table tbody td,
    .modern-page .table-responsive table.crm-card-table tbody td {
        align-items: center !important;
        border: 0 !important;
        display: grid !important;
        gap: 2px 8px !important;
        grid-column: 2 / -1 !important;
        grid-template-columns: minmax(92px, 30%) minmax(0, 1fr) !important;
        min-height: 0 !important;
        min-width: 0 !important;
        overflow: visible !important;
        padding: 0 !important;
        white-space: normal !important;
        width: 100% !important;
        word-break: normal !important;
    }

    .modern-page table.crm-card-table tbody td > *,
    .modern-page .table-responsive table.crm-card-table tbody td > * {
        min-width: 0 !important;
    }

    .modern-page table.crm-card-table tbody td::before,
    .modern-page .table-responsive table.crm-card-table tbody td::before {
        color: #475569 !important;
        content: attr(data-title) !important;
        display: block !important;
        font-size: 0.68rem !important;
        font-weight: 900 !important;
        letter-spacing: .04em !important;
        margin: 0 !important;
        min-width: 0 !important;
        text-transform: uppercase !important;
        width: auto !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Name"],
    .modern-page table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page table.crm-card-table tbody td[data-title="Deal"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"] {
        grid-column: 2 / 4 !important;
        grid-row: 1 !important;
        grid-template-columns: 1fr !important;
        padding-right: 8px !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Name"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Company Name"]::before,
    .modern-page table.crm-card-table tbody td[data-title="Deal"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"]::before {
        display: none !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Name"] a,
    .modern-page table.crm-card-table tbody td[data-title="Company Name"] a,
    .modern-page table.crm-card-table#bookingsTable tbody td[data-title="Name"],
    .modern-page table.crm-card-table tbody td[data-title="Deal"] strong,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Name"] a,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company Name"] a,
    .modern-page .table-responsive table.crm-card-table#bookingsTable tbody td[data-title="Name"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Deal"] strong {
        color: #0f172a !important;
        font-size: 1.02rem !important;
        font-weight: 900 !important;
        line-height: 1.2 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: normal !important;
        word-break: normal !important;
    }

    .modern-page table.crm-card-table#bookingsTable tbody td[data-title="Name"],
    .modern-page .table-responsive table.crm-card-table#bookingsTable tbody td[data-title="Name"] {
        display: block !important;
    }

    .modern-page #customersTable tbody td[data-title="Name"] {
        padding-right: 40px !important;
    }

    .modern-page #customersTable tbody td[data-title="Name"] .customer-select {
        margin: 0 !important;
        position: absolute !important;
        right: 14px !important;
        top: 14px !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Select"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"] {
        align-items: start !important;
        display: flex !important;
        grid-column: 4 !important;
        grid-row: 1 !important;
        justify-content: flex-end !important;
        position: static !important;
        width: auto !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Select"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Select"]::before {
        display: none !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Details"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"] {
        align-items: start !important;
        display: flex !important;
        grid-column: 3 !important;
        grid-row: 1 !important;
        justify-content: flex-end !important;
        position: static !important;
        width: auto !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Details"]::before,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Details"]::before {
        display: none !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Company"],
    .modern-page table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page table.crm-card-table tbody td[data-title="Email"],
    .modern-page table.crm-card-table tbody td[data-title="Phone"],
    .modern-page table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page table.crm-card-table tbody td[data-title="Number"],
    .modern-page table.crm-card-table tbody td[data-title="Last Contact"],
    .modern-page table.crm-card-table tbody td[data-title="Last Deal"],
    .modern-page table.crm-card-table tbody td[data-title="Total Deals"],
    .modern-page table.crm-card-table tbody td[data-title="Value"],
    .modern-page table.crm-card-table tbody td[data-title="Stage"],
    .modern-page table.crm-card-table tbody td[data-title="Close Date"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Primary Contact"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Last Contact"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Last Deal"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Total Deals"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Value"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Stage"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Close Date"] {
        grid-column: 2 / -1 !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Email"] *,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Email"] *,
    .modern-page table.crm-card-table tbody td[data-title="Company"] *,
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Company"] * {
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        word-break: normal !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Phone"],
    .modern-page table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page table.crm-card-table tbody td[data-title="Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Phone Number"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Number"] {
        white-space: nowrap !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Actions"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Actions"] {
        display: flex !important;
        gap: 8px !important;
        grid-column: 2 / -1 !important;
        justify-content: flex-start !important;
        margin-top: 8px !important;
    }

    .modern-page table.crm-card-table tbody td[data-title="Status"],
    .modern-page .table-responsive table.crm-card-table tbody td[data-title="Status"] {
        align-items: center !important;
    }

    .modern-page table.crm-card-table .status-dropdown-container,
    .modern-page table.crm-card-table .status-form,
    .modern-page table.crm-card-table .status-dropdown {
        float: none !important;
        max-width: 190px !important;
        min-width: 0 !important;
        position: static !important;
        width: 100% !important;
    }

    .modern-page table.crm-card-table .status-dropdown {
        border-radius: 8px !important;
        height: 36px !important;
        line-height: 1.2 !important;
    }

    .modern-page table.crm-card-table tbody tr.details-row,
    .modern-page .table-responsive table.crm-card-table tbody tr.details-row {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        display: block !important;
        margin: -8px 0 0 !important;
        padding: 0 !important;
    }

    .modern-page table.crm-card-table tbody tr.details-row td,
    .modern-page .table-responsive table.crm-card-table tbody tr.details-row td {
        display: block !important;
        padding: 0 !important;
    }

    .modern-page table.crm-card-table tbody tr.details-row td::before,
    .modern-page .table-responsive table.crm-card-table tbody tr.details-row td::before {
        display: none !important;
    }

    .mobile-filter-toggle {
        bottom: 12px !important;
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        z-index: 9995 !important;
    }

    #globalNotificationsFab {
        bottom: 84px !important;
        right: 18px !important;
    }
}

/* Final mobile shell override: keep the slide-out menu readable and clear of floating controls. */
@media (max-width: 1199px) {
    #sidebar.sidebar,
    #sidebar.sidebar.collapsed {
        left: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateX(-105%) !important;
        transition: transform 0.25s ease, opacity 0.2s ease !important;
        visibility: hidden !important;
        width: min(78vw, 300px) !important;
    }

    #sidebar.sidebar::before,
    #sidebar.sidebar::after,
    #sidebar.sidebar.collapsed::before,
    #sidebar.sidebar.collapsed::after {
        bottom: 0 !important;
        height: 100% !important;
        left: 0 !important;
        position: absolute !important;
        right: 0 !important;
        top: 0 !important;
        width: 100% !important;
    }

    body.mobile-menu-is-open .mobile-filter-toggle,
    body.mobile-menu-open .mobile-filter-toggle,
    body.mobile-menu-is-open #globalNotificationsFab,
    body.mobile-menu-open #globalNotificationsFab,
    body.mobile-menu-is-open .mobile-top-logo,
    body.mobile-menu-open .mobile-top-logo {
        display: none !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }

    #sidebar.sidebar.mobile-open,
    #sidebar.sidebar.collapsed.mobile-open {
        display: flex !important;
        flex-direction: column !important;
        left: 0 !important;
        opacity: 1 !important;
        overflow-y: auto !important;
        pointer-events: auto !important;
        transform: translateX(0) !important;
        visibility: visible !important;
        width: min(78vw, 300px) !important;
        z-index: 2100 !important;
    }

    #sidebar.sidebar.mobile-open .nav-menu,
    #sidebar.sidebar.collapsed.mobile-open .nav-menu,
    #sidebar.sidebar.mobile-open .nav-section,
    #sidebar.sidebar.collapsed.mobile-open .nav-section,
    #sidebar.sidebar.mobile-open .sidebar-footer,
    #sidebar.sidebar.collapsed.mobile-open .sidebar-footer,
    #sidebar.sidebar.mobile-open .nav-dropdown,
    #sidebar.sidebar.collapsed.mobile-open .nav-dropdown,
    #sidebar.sidebar.mobile-open .nav-submenu.open,
    #sidebar.sidebar.collapsed.mobile-open .nav-submenu.open {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    #sidebar.sidebar.mobile-open .nav-item,
    #sidebar.sidebar.collapsed.mobile-open .nav-item,
    #sidebar.sidebar.mobile-open a.nav-item,
    #sidebar.sidebar.collapsed.mobile-open a.nav-item,
    #sidebar.sidebar.mobile-open .nav-dropdown-toggle,
    #sidebar.sidebar.collapsed.mobile-open .nav-dropdown-toggle,
    #sidebar.sidebar.mobile-open .sidebar-toggle-btn,
    #sidebar.sidebar.collapsed.mobile-open .sidebar-toggle-btn {
        align-items: center !important;
        color: #ffffff !important;
        display: flex !important;
        gap: 14px !important;
        justify-content: flex-start !important;
        opacity: 1 !important;
        padding: 14px 22px !important;
        pointer-events: auto !important;
        transform: none !important;
        visibility: visible !important;
        width: 100% !important;
    }

    #sidebar.sidebar.mobile-open .nav-item span,
    #sidebar.sidebar.collapsed.mobile-open .nav-item span,
    #sidebar.sidebar.mobile-open .nav-item i,
    #sidebar.sidebar.collapsed.mobile-open .nav-item i,
    #sidebar.sidebar.mobile-open .nav-item svg,
    #sidebar.sidebar.collapsed.mobile-open .nav-item svg,
    #sidebar.sidebar.mobile-open .sidebar-toggle-btn span,
    #sidebar.sidebar.collapsed.mobile-open .sidebar-toggle-btn span {
        color: #ffffff !important;
        display: inline-flex !important;
        opacity: 1 !important;
        overflow: visible !important;
        text-indent: 0 !important;
        transform: none !important;
        visibility: visible !important;
        width: auto !important;
    }

    #sidebar.sidebar.mobile-open .nav-section-title,
    #sidebar.sidebar.collapsed.mobile-open .nav-section-title,
    #sidebar.sidebar.mobile-open .sidebar-brand,
    #sidebar.sidebar.collapsed.mobile-open .sidebar-brand {
        display: none !important;
    }
}
