/* Paint the darkened gradient on the scrolling surface itself. Viewport-sized
   pseudo-elements stopped covering the menu once its content was scrolled. */
#sidebar.sidebar {
    background-image: linear-gradient(#0009, #0009), repeating-linear-gradient(
        180deg, #fb5804 0px, #ed1577 200px, #a5198c 400px,
        #5266c4 600px, #22c2f8 800px, #0c8e2e 1000px, #fb5804 1200px
    ) !important;
    background-size: 100% 1200px !important;
    animation: sidebarGradientScroll 20s linear infinite;
    animation-delay: var(--sidebar-gradient-delay, 0s);
}
#sidebar.sidebar::before, #sidebar.sidebar::after { display:none !important; }

/* Quick actions remain icon-only, including inside the mobile-open menu.
   Native title tooltips and aria-labels retain their accessible descriptions. */
#sidebar.sidebar .sidebar-footer .sidebar-footer-actions {
    display:flex !important;
    flex-wrap:nowrap !important;
    gap:2px !important;
    width:100% !important;
}
#sidebar.sidebar .sidebar-footer .sidebar-footer-actions > .nav-item {
    display:flex !important;
    flex:1 1 0 !important;
    width:auto !important;
    min-width:0 !important;
    min-height:44px !important;
    padding:8px 0 !important;
    gap:0 !important;
    justify-content:center !important;
}
#sidebar.sidebar .sidebar-footer .sidebar-footer-actions > .nav-item > span { display:none !important; }
#sidebar.sidebar .sidebar-footer .sidebar-footer-actions > .nav-item > i { margin:0 !important; flex:0 0 auto !important; }
@media (min-width:1200px) {
    #sidebar.sidebar.collapsed .sidebar-footer .sidebar-footer-actions { flex-direction:column !important; }
}
@media (prefers-reduced-motion:reduce) {
    #sidebar.sidebar { animation:none; }
}
@media (min-width:1600px) {
    .modern-page .deals-panel .table-responsive { overflow-x:auto; }
    #projectsDealsTable { min-width:1450px; }
    #projectsDealsTable :is(th,td):nth-child(2) { min-width:180px; overflow-wrap:break-word; }
}

/* Deals has thirteen columns: use cards before the desktop table gets squeezed.
   One self-contained layout wins over the older shared phone/tablet overrides. */
@media (max-width:1599px) {
    .modern-page .deals-panel .table-responsive { overflow:visible !important; min-width:0 !important; }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table {
        display:block !important; width:100% !important; min-width:0 !important; max-width:100% !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable > thead { display:none !important; }
    html body .modern-page .deals-panel #projectsDealsTable > tbody {
        display:grid !important; grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr)) !important;
        gap:12px !important; width:100% !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] {
        display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)) !important;
        align-content:start !important; align-items:start !important; gap:10px 12px !important;
        position:relative !important; width:100% !important; min-width:0 !important; max-width:100% !important;
        height:auto !important; min-height:0 !important; margin:0 !important; padding:12px !important;
        border:1px solid #bfdbfe !important; border-left:4px solid var(--status-border-color,#2563eb) !important;
        border-radius:12px !important; background:var(--status-row-bg,#fff) !important;
        box-shadow:0 2px 6px #0f172a0a !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable > tbody > tr[data-deal-row]::before {
        content:attr(data-card-initials) !important; display:flex !important; position:absolute !important;
        grid-column:auto !important; grid-row:auto !important; margin:0 !important; transform:none !important;
        top:12px !important; left:12px !important; width:30px !important; height:30px !important;
        align-items:center !important; justify-content:center !important; border-radius:50% !important;
        background:#147bd1 !important; color:#fff !important; font-size:12px !important; font-weight:800 !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] > td {
        display:block !important; position:static !important; align-self:start !important; float:none !important;
        grid-column:auto !important; grid-row:auto !important; order:0 !important;
        width:100% !important; min-width:0 !important; max-width:100% !important;
        height:auto !important; min-height:0 !important; padding:0 !important; margin:0 !important;
        border:0 !important; box-shadow:none !important; background:transparent !important; text-align:left !important;
        font-size:13px !important; line-height:1.35 !important; white-space:normal !important; overflow-wrap:anywhere !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] > td::before {
        content:attr(data-title) !important; display:block !important; position:static !important;
        width:auto !important; margin:0 0 4px !important; color:#52647c !important; font-size:9px !important;
        font-weight:800 !important; line-height:1.3 !important; text-transform:uppercase !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] > td[data-title="Deal"] {
        grid-column:1 / -1 !important; order:-1 !important; min-height:34px !important;
        padding:0 64px 0 40px !important; font-size:15px !important; font-weight:800 !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] > td[data-title="Priority"] {
        position:absolute !important; top:12px !important; right:12px !important; left:auto !important;
        width:56px !important; padding:0 !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] > td:is([data-title="Deal"],[data-title="Priority"],[data-title="Actions"])::before { display:none !important; }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] > td:is([data-title="Paid / Value"],[data-title="Task List"],[data-title="Stage"],[data-title="Actions"]) { grid-column:1 / -1 !important; }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] > td:is([data-title="Paid / Value"],[data-title="Task List"],[data-title="Actions"]) {
        border-top:1px solid #e2e8f0 !important; padding-top:8px !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable .deals-actions {
        display:flex !important; flex-wrap:nowrap !important; width:100% !important; gap:6px !important;
    }
    html body .modern-page .deals-panel #projectsDealsTable .deals-action-btn { flex:0 0 34px !important; width:34px !important; height:34px !important; padding:0 !important; }
    html body .modern-page .deals-panel #projectsDealsTable .deal-assign-btn { width:auto !important; max-width:100% !important; min-height:32px !important; padding:3px 9px !important; }
    html body .modern-page .deals-panel #projectsDealsTable .deals-inline-select { min-height:32px !important; }
    html body .modern-page .deals-panel #projectsDealsTable.crm-card-table > tbody > tr[data-deal-row] > td[data-title="Paid / Value"]::before { display:none !important; }
    html body .modern-page .deals-panel #projectsDealsTable td[data-title="Paid / Value"] > div { display:inline-block !important; margin:0 14px 0 0 !important; }
    html body .modern-page .deals-panel #projectsDealsTable td[data-title="Paid / Value"] .deals-field-label { display:block !important; margin:0 0 4px !important; }
    html body .modern-page .deals-panel #projectsDealsTable td:is([data-title="Payment"],[data-title="Task List"]) .deals-field-label { display:none !important; }
    html body .modern-page .deals-panel #projectsDealsTable .deals-progress { display:flex !important; flex-wrap:nowrap !important; gap:6px !important; align-items:center !important; min-width:0 !important; margin-top:5px !important; }
    html body .modern-page .deals-panel #projectsDealsTable .deals-progress-track { flex:1 1 40px !important; min-width:20px !important; margin:0 !important; }
    html body .modern-page .deals-panel #projectsDealsTable .deals-progress-value { white-space:nowrap !important; }
    .deals-stats { grid-template-columns:repeat(3,minmax(0,1fr)); }
    html body .modern-page .deals-panel #projectsDealsTable > tbody > tr:not([data-deal-row]) { display:block !important; grid-column:1 / -1 !important; }
    html body .modern-page .deals-panel #projectsDealsTable > tbody > tr:not([data-deal-row])::before { display:none !important; }
}
@media (max-width:600px) {
    .deals-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
/* Lead card header: initials, name, selection; all fields follow below it.
   Scope these rules to Leads so other record/table layouts stay unchanged. */
@media (max-width: 1199px) {
    html body .modern-page #bookingsTable.crm-card-table > tbody > tr.customer-row {
        display:flex !important; flex-direction:column !important; align-items:stretch !important;
    }
    html body .modern-page #bookingsTable.crm-card-table > tbody > tr.customer-row > td[data-title="Name"] {
        display:block !important; order:-2 !important; margin:0 0 8px !important;
        padding:2px 36px 8px 44px !important; min-height:40px !important;
        width:100% !important; font-size:15px !important; font-weight:800 !important;
    }
    html body .modern-page #bookingsTable.crm-card-table > tbody > tr.customer-row > td[data-title="Name"]::before,
    html body .modern-page #bookingsTable.crm-card-table > tbody > tr.customer-row > td[data-title="Details"] {
        display:none !important;
    }
    html body .modern-page #bookingsTable.crm-card-table > tbody > tr.customer-row > td[data-title="Select"] {
        position:absolute !important; top:12px !important; right:12px !important; left:auto !important;
        width:24px !important; margin:0 !important; padding:0 !important;
    }
}
