/**
 * Dexpert People Portal - PWA & Progressive Disclosure Stylesheet
 */

/* ==========================================================================
   1. Progressive Web App Fonts & Touch Enhancements
   ========================================================================== */
:root {
    /* Dexpert brand system - used across the installed PWA only */
    --pwa-primary: #336699;
    --pwa-primary-hover: #285580;
    --pwa-primary-light: #eaf2fa;
    --pwa-accent: #0284c7;
    --pwa-border: #e0e6ef;
    --pwa-bg: #f0f3f9;
    --pwa-surface: #ffffff;
    --pwa-soft: #f8fafc;
    --pwa-text-strong: #172033;
    --pwa-text-muted: #64748b;
    --pwa-success: #059669;
    /* Sidebar palette (drawer + persistent PWA sidebar only) */
    --pwa-sidebar-bg: #24496f;
    --pwa-sidebar-deep: #1d3b5c;
    --pwa-sidebar-brand: #336699;
    --pwa-sidebar-text: #f4f7fb;
    --pwa-sidebar-muted: #b9d0e7;
    --pwa-sidebar-active: #eaf2fa;
    --pwa-sidebar-avatar: #dce8f5;
    --pwa-bottom-nav-height: 60px;
    --pwa-header-height: 58px;
}

body {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Minimum touch target on interactive elements on mobile */
@media (max-width: 768px) {
    .btn, .nav-link, .pwa-touch-target {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================================================
   2. PWA Application Header (standalone only)
   ========================================================================== */
body.pwa-standalone-active .pwa-app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--pwa-border);
    padding-top: env(safe-area-inset-top, 0px);
}

.pwa-app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: var(--pwa-header-height);
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 10px;
}

.pwa-header-start,
.pwa-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.pwa-header-action {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #334155;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pwa-header-action svg {
    width: 20px;
    height: 20px;
}

.pwa-header-action:hover,
.pwa-header-action:active,
.pwa-header-action:focus-visible {
    background: #f1f5f9;
    color: var(--pwa-primary);
}

.pwa-header-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 0 2px;
    text-decoration: none !important;
}

.pwa-header-logo {
    display: block;
    max-height: 26px;
    max-width: 104px;
    width: auto;
    object-fit: contain;
}

.pwa-header-brand-text {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.pwa-header-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

.pwa-header-brand-mark svg {
    width: 16px;
    height: 16px;
}

.pwa-header-avatar {
    padding: 0;
    border-radius: 50%;
}

.pwa-header-avatar img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e2e8f0;
}

.pwa-account-menu {
    min-width: 216px;
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--pwa-border);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.pwa-account-menu .dropdown-item {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 500;
}

.pwa-account-menu .dropdown-divider {
    margin: 4px 0;
}

/* The menu trigger echoes the blue drawer it opens */
#pwa-header-menu-btn {
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

#pwa-header-menu-btn:hover,
#pwa-header-menu-btn:active {
    background: var(--pwa-primary);
    color: #ffffff;
}

/* Open drawer: the trigger stays solid blue while the menu is on screen */
body.pwa-standalone-active.pwa-drawer-open #pwa-header-menu-btn {
    background: var(--pwa-primary);
    color: #ffffff;
}

/* Keep page content clear of the fixed header */
body.pwa-standalone-active .page-container {
    margin-top: calc(var(--pwa-header-height) + env(safe-area-inset-top, 0px)) !important;
}

/* The app header already provides the navigation trigger: suppress any legacy toggle in the PWA */
body.pwa-standalone-active .sidebar-toggle-btn {
    display: none !important;
}

/* ==========================================================================
   3. PWA Bottom Navigation Bar - ONLY ACTIVE IN STANDALONE PWA
   ========================================================================== */
.pwa-bottom-nav {
    display: none !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--pwa-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    background: #ffffff;
    border-top: 1px solid var(--pwa-border);
    box-shadow: 0 -1px 0 rgba(15, 23, 42, 0.02);
    z-index: 1040;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform 0.2s ease;
}

@media (max-width: 990px) {
    body.pwa-standalone-active .pwa-bottom-nav {
        display: flex !important;
        align-items: stretch;
        justify-content: space-around;
    }

    /* Keep the last item clear of the bar and the device safe area */
    body.pwa-standalone-active .scrollable-page.main-scrollable-page {
        padding-bottom: calc(var(--pwa-bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 18px) !important;
    }
}

/* Hide the bar while the drawer or the soft keyboard is open */
body.pwa-standalone-active.pwa-drawer-open .pwa-bottom-nav,
body.pwa-standalone-active.pwa-form-focus .pwa-bottom-nav {
    transform: translateY(100%);
}

.pwa-nav-item {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    max-width: 96px;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px 2px 5px;
    border: 0;
    background: transparent;
    color: #64748b;
    font-family: inherit;
    text-decoration: none !important;
    cursor: pointer;
    transition: color 0.15s ease;
}

.pwa-nav-item .pwa-nav-icon {
    width: 22px;
    height: 22px;
    stroke-width: 1.9;
    flex: 0 0 auto;
}

.pwa-nav-item .pwa-nav-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.1px;
    line-height: 1.15;
}

.pwa-nav-item.active {
    color: var(--pwa-primary);
}

.pwa-nav-item.active .pwa-nav-icon {
    stroke: var(--pwa-primary);
    stroke-width: 2.4;
}

.pwa-nav-item.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 22px;
    height: 3px;
    margin-left: -11px;
    border-radius: 0 0 3px 3px;
    background: var(--pwa-primary);
}

.pwa-nav-item:focus-visible {
    outline: 2px solid var(--pwa-accent);
    outline-offset: -2px;
    border-radius: 12px;
}

/* ==========================================================================
   3. Quick Actions Bottom Sheet
   ========================================================================== */
.pwa-bottom-sheet-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1050;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.pwa-bottom-sheet-backdrop.show {
    display: block;
    opacity: 1;
}

.pwa-bottom-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    max-width: 500px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 1055;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.15);
    transition: bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-bottom-sheet.show {
    bottom: 0;
}

.pwa-sheet-handle {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 4px;
    margin: 0 auto 16px auto;
}

.pwa-sheet-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pwa-quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.pwa-action-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
    color: #1e293b !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.pwa-action-card:active,
.pwa-action-card:hover {
    background: var(--pwa-primary-light);
    border-color: #cbd5e1;
    color: var(--pwa-primary) !important;
}

.pwa-action-icon-circle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.04);
}

.pwa-action-icon-circle svg {
    width: 18px;
    height: 18px;
    color: var(--pwa-primary);
}

/* ==========================================================================
   4. PWA Installation Notification Banner & iOS Sheet
   ========================================================================== */
.pwa-install-banner {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 440px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15), 0 2px 6px rgba(15, 23, 42, 0.05);
    border: 1px solid #e2e8f0;
    z-index: 1045;
    animation: pwaSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pwaSlideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
    .pwa-install-banner {
        bottom: 20px;
        left: 12px;
        right: 12px;
    }
}

.pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.pwa-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.pwa-banner-text h6 {
    margin: 0 0 2px 0;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.pwa-banner-text p {
    margin: 0;
    font-size: 12px;
    color: #64748b;
    line-height: 1.35;
}

.pwa-banner-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.pwa-btn-install {
    background: var(--pwa-primary);
    color: white !important;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.pwa-btn-dismiss {
    background: #f1f5f9;
    color: #475569;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

/* ==========================================================================
   5. Superadmin Settings Page: Responsive Layout & Mobile Controls
   ========================================================================== */
.pwa-role-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pwa-role-badge.admin {
    background: #fef3c7;
    color: #92400e;
}

.pwa-role-badge.account_manager {
    background: #e0f2fe;
    color: #0369a1;
}

.pwa-role-badge.employee {
    background: #f3e8ff;
    color: #6b21a8;
}

.pwa-matrix-table th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.pwa-matrix-table td {
    vertical-align: middle;
    font-size: 13.5px;
}

.pwa-role-pills-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.pwa-role-pills-scroll::-webkit-scrollbar {
    height: 4px;
}

.pwa-role-pills-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.pwa-role-pills-scroll .btn {
    flex-shrink: 0;
}

.pwa-slot-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

.pwa-mobile-label {
    display: none;
}

@media (max-width: 768px) {
    /* Responsive card layout for tables on small screens */
    .pwa-matrix-table thead {
        display: none !important;
    }

    .pwa-matrix-table, 
    .pwa-matrix-table tbody, 
    .pwa-matrix-table tr, 
    .pwa-matrix-table td {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .pwa-matrix-table tbody tr {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 12px 14px;
        margin-bottom: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    }

    .pwa-matrix-table tbody td {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 6px 0 !important;
        border: none !important;
    }

    .pwa-matrix-table tbody td.pwa-mobile-header {
        border-bottom: 1px solid #f1f5f9 !important;
        padding-bottom: 8px !important;
        margin-bottom: 6px;
    }

    .pwa-matrix-table tbody td.pwa-mobile-footer {
        border-top: 1px dashed #f1f5f9 !important;
        padding-top: 8px !important;
        margin-top: 6px;
    }

    .pwa-mobile-label {
        display: inline-block;
        font-weight: 600;
        font-size: 12px;
        color: #64748b;
        margin-right: 8px;
    }

    /* PWA Settings Tabs */
    #pwaTab {
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #pwaTab::-webkit-scrollbar {
        display: none;
    }
    #pwaTab .nav-link {
        font-size: 13px;
        padding: 10px 14px;
        white-space: nowrap;
    }

    /* Padding adjust for mobile */
    #pwaTabContent {
        padding: 14px 10px !important;
    }

    /* Card header stack on mobile */
    .pwa-settings-card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }
}

/* ==========================================================================
   6. Dedicated Native Mobile App Experience (Standalone PWA Mode)
   ========================================================================== */
/* Dashboard canvas */
.pwa-mobile-dashboard {
    max-width: 960px;
    margin: 0 auto;
    padding: 14px 16px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: var(--pwa-text-strong);
}

/* 1. Welcome card */
.pwa-welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 16px;
    padding: 13px 15px;
    box-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
}

.pwa-welcome-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.pwa-welcome-avatar-wrap {
    position: relative;
    flex: 0 0 auto;
}

.pwa-welcome-avatar {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--pwa-border);
}

.pwa-online-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    background: var(--pwa-success);
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.pwa-welcome-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.pwa-welcome-greeting {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--pwa-text-muted);
}

.pwa-welcome-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-welcome-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 3px;
}

.pwa-welcome-date {
    display: inline-flex;
    align-items: center;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

.pwa-icon-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    border: 1px solid var(--pwa-border);
    background: var(--pwa-soft);
    color: var(--pwa-text-muted) !important;
    text-decoration: none !important;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pwa-icon-btn:hover {
    background: var(--pwa-primary-light);
    border-color: transparent;
    color: var(--pwa-primary) !important;
}

.pwa-announcement {
    margin: 0;
}

.pwa-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin: 0 2px -2px 2px;
}

.pwa-section-heading span {
    font-size: 13px;
    font-weight: 700;
    color: var(--pwa-text-strong);
}

.pwa-section-heading small {
    font-size: 11px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

/* 2. Financial metric grid */
.pwa-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 600px) {
    .pwa-metrics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (min-width: 1200px) {
    .pwa-metrics-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.pwa-metric-card {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-height: 94px;
    padding: 12px 12px 11px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 14px;
    text-decoration: none !important;
    box-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.pwa-metric-card:hover {
    border-color: #cdd9e8;
    box-shadow: 0 6px 16px rgba(23, 32, 51, 0.07);
}

.pwa-metric-card:active {
    transform: scale(0.985);
}

.pwa-metric-card:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

.pwa-metric-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

.pwa-metric-icon svg {
    width: 16px;
    height: 16px;
}

.pwa-metric-value {
    font-size: 15.5px;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.15;
    color: var(--pwa-text-strong);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-metric-value.is-success {
    color: var(--pwa-success);
}

.pwa-metric-value.is-danger {
    color: #dc2626;
}

.pwa-metric-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--pwa-text-muted);
}

/* 3. Shared cards */
.pwa-widgets-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pwa-card,
.pwa-app-card {
    display: flex;
    flex-direction: column;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 16px;
    padding: 14px 14px 12px;
    box-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
}

.pwa-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid #eef2f8;
}

.pwa-card-title {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.pwa-card-title h3 {
    margin: 0;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-card-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

.pwa-card-icon svg {
    width: 15px;
    height: 15px;
}

.pwa-count-badge {
    min-width: 24px;
    height: 22px;
    flex: 0 0 auto;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
    font-size: 11.5px;
    font-weight: 700;
}

.pwa-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
    flex: 0 0 auto;
}

.pwa-status-badge.is-on {
    background: #e7f6ef;
    color: var(--pwa-success);
}

.pwa-status-badge.is-off {
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    color: var(--pwa-text-muted);
}

.pwa-status-badge.is-warn {
    background: #fef3c7;
    color: #b45309;
}

.pwa-card-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eef2f8;
    text-align: center;
}

.pwa-card-footlink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--pwa-primary) !important;
    text-decoration: none !important;
}

.pwa-card-footlink:hover {
    background: var(--pwa-primary-light);
}

/* 4. Compact stat rows (projects, leave approvals) */
.pwa-stat-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    text-decoration: none !important;
}

.pwa-stat-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pwa-stat-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.pwa-stat-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--pwa-text-strong);
}

.pwa-stat-sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--pwa-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-stat-link {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
    color: var(--pwa-primary) !important;
    text-decoration: none !important;
}

.pwa-stat-value {
    font-size: 15px;
    font-weight: 800;
    color: var(--pwa-text-strong);
    font-variant-numeric: tabular-nums;
}

/* 5. Work shift & attendance */
.pwa-attendance-card {
    background: var(--pwa-surface);
}

.pwa-shift-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.pwa-field-label {
    display: block;
    margin-bottom: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pwa-text-muted);
}

.pwa-shift-time {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--pwa-text-strong);
}

.pwa-chip {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-top: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--pwa-border);
    background: var(--pwa-soft);
    color: var(--pwa-text-muted);
    font-size: 11px;
    font-weight: 600;
}

.pwa-attendance-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pwa-select {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--pwa-border);
    background: #ffffff;
    color: var(--pwa-text-strong);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
}

.pwa-select:focus {
    outline: none;
    border-color: var(--pwa-primary);
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.14);
}

.pwa-btn {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border: 0;
    border-radius: 11px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.pwa-btn-success {
    background: var(--pwa-success);
    color: #ffffff !important;
}

.pwa-btn-success:hover {
    background: #047857;
    color: #ffffff !important;
}

.pwa-btn-danger {
    background: #dc2626;
    color: #ffffff !important;
}

.pwa-btn-danger:hover {
    background: #b91c1c;
    color: #ffffff !important;
}

.pwa-btn.disabled,
.pwa-btn:disabled {
    opacity: 0.72;
    pointer-events: none;
}

/* 6. Tasks */
.pwa-task-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pwa-task-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--pwa-soft);
    text-decoration: none !important;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pwa-task-row:hover {
    background: #ffffff;
    border-color: var(--pwa-border);
}

.pwa-task-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pwa-task-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-task-sub {
    font-size: 11px;
    font-weight: 500;
    color: var(--pwa-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-priority {
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

.pwa-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 16px 10px 12px;
    text-align: center;
    color: var(--pwa-success);
}

.pwa-empty svg {
    color: var(--pwa-success);
    margin-bottom: 2px;
}

.pwa-empty-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--pwa-text-strong);
}

.pwa-empty-text {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

/* 7. Billing health & agenda */
.pwa-progress {
    height: 8px;
    border-radius: 999px;
    background: #e8eef6;
    overflow: hidden;
}

.pwa-progress-bar {
    height: 100%;
    border-radius: 999px;
    background: var(--pwa-primary);
    transition: width 0.3s ease;
}

.pwa-progress-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pwa-text-muted);
}

.pwa-event-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pwa-event-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--pwa-soft);
}

.pwa-event-time {
    flex: 0 0 auto;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
    font-size: 10.5px;
    font-weight: 700;
}

.pwa-event-main {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.pwa-event-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-event-sub {
    font-size: 10.5px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

.pwa-pulse-green {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--pwa-success);
    border-radius: 50%;
    animation: pwaPulseGreen 1.8s infinite;
}

@keyframes pwaPulseGreen {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.6); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* Narrow phones: keep two metric columns readable */
@media (max-width: 380px) {
    .pwa-mobile-dashboard {
        padding: 12px 12px 20px;
        gap: 12px;
    }

    .pwa-metric-card {
        padding: 11px 10px 10px;
    }

    .pwa-metric-value {
        font-size: 14.5px;
    }

    .pwa-card-title h3 {
        font-size: 12px;
    }
}

/* Tablet and wider PWA windows */
@media (min-width: 600px) {
    .pwa-mobile-dashboard {
        padding: 18px 20px 24px;
        gap: 16px;
    }

    .pwa-card,
    .pwa-app-card {
        padding: 16px 16px 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-metric-card,
    .pwa-task-row,
    .pwa-progress-bar,
    .pwa-icon-btn {
        transition: none !important;
    }

    .pwa-metric-card:active {
        transform: none;
    }
}

.bg-success-light { background: #dcfce7 !important; }
.bg-danger-light { background: #fee2e2 !important; }
.bg-warning-light { background: #fef3c7 !important; }

/* ==========================================================================
   7. PWA Off-Canvas Navigation Drawer (standalone only)
   ========================================================================== */
body.pwa-standalone-active .sidebar.pwa-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0 !important;
    width: min(318px, 84vw) !important;
    max-width: 84vw;
    height: 100% !important;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 14px;
    /* Solid navy base with only a whisper of depth towards the footer */
    background: linear-gradient(180deg, var(--pwa-sidebar-bg) 0%, var(--pwa-sidebar-bg) 55%, var(--pwa-sidebar-deep) 100%) !important;
    border-right: 0;
    border-radius: 0 20px 20px 0;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.34) !important;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 1046 !important;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.28s;
}

body.pwa-standalone-active.pwa-drawer-open .sidebar.pwa-drawer {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
}

/* The drawer overlays the page: never shift or compress the dashboard */
body.pwa-standalone-active.pwa-drawer-open {
    overflow: hidden !important;
}

body.pwa-standalone-active.pwa-drawer-open #left-menu-toggle-mask,
body.pwa-standalone-active.pwa-drawer-open .page-container {
    overflow: hidden !important;
}

.pwa-drawer-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1045;
    background: rgba(15, 23, 42, 0.42);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.pwa-drawer-backdrop[hidden] {
    display: none !important;
}

.pwa-drawer-backdrop.show {
    opacity: 1;
}

/* 7.1 Profile header — the logo lives only in the application header */
.pwa-drawer-head {
    flex: 0 0 auto;
    padding: 15px 14px 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pwa-drawer-profile {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.pwa-drawer-avatar {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border-radius: 50%;
    object-fit: cover;
    background: var(--pwa-sidebar-avatar);
    border: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.14);
}

.pwa-drawer-identity {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1 1 auto;
    min-width: 0;
}

.pwa-drawer-name {
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--pwa-sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-drawer-role {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--pwa-sidebar-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--pwa-sidebar-text);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.pwa-drawer-close:hover {
    background: rgba(255, 255, 255, 0.18);
}

.pwa-drawer-close:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.pwa-drawer-close svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
}

/* 7.2 Independently scrolling navigation region */
.pwa-drawer-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px 10px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(244, 247, 251, 0.28) transparent;
}

.pwa-drawer-nav::-webkit-scrollbar {
    width: 5px;
}

.pwa-drawer-nav::-webkit-scrollbar-track {
    background: transparent;
}

.pwa-drawer-nav::-webkit-scrollbar-thumb {
    background: rgba(244, 247, 251, 0.24);
    border-radius: 999px;
}

.pwa-drawer-nav:hover::-webkit-scrollbar-thumb {
    background: rgba(244, 247, 251, 0.38);
}

/* 7.3 Grouping: spacing first, no hairline per section */
.pwa-drawer-group + .pwa-drawer-group {
    margin-top: 12px;
}

.pwa-drawer-group-title {
    padding: 10px 12px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pwa-sidebar-muted);
}

.pwa-drawer-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.pwa-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 46px;
    margin-bottom: 2px;
    padding: 11px 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: rgba(244, 247, 251, 0.88);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pwa-drawer-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pwa-sidebar-text);
}

.pwa-drawer-link:active {
    background: rgba(29, 59, 92, 0.85);
}

.pwa-drawer-link:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: -2px;
}

.pwa-drawer-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    color: rgba(244, 247, 251, 0.86);
    stroke-width: 1.9;
}

.pwa-drawer-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-drawer-badge {
    flex: 0 0 auto;
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
}

.pwa-drawer-chevron {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    color: rgba(244, 247, 251, 0.55);
    transition: transform 0.22s ease, color 0.15s ease;
}

.pwa-drawer-item.is-open > .pwa-drawer-group-toggle .pwa-drawer-chevron {
    transform: rotate(180deg);
}

/* Single active treatment: soft blue surface, navy label, subtle brand accent */
.pwa-drawer-item.is-active > .pwa-drawer-link {
    background: var(--pwa-sidebar-active);
    color: var(--pwa-sidebar-bg);
    font-weight: 600;
    box-shadow: inset 3px 0 0 0 var(--pwa-sidebar-brand);
}

.pwa-drawer-item.is-active > .pwa-drawer-link:hover {
    background: var(--pwa-sidebar-active);
    color: var(--pwa-sidebar-bg);
}

.pwa-drawer-item.is-active > .pwa-drawer-link .pwa-drawer-icon {
    color: var(--pwa-sidebar-bg);
    stroke-width: 2.3;
}

.pwa-drawer-item.is-active > .pwa-drawer-link .pwa-drawer-chevron {
    color: var(--pwa-sidebar-bg);
}

.pwa-drawer-submenu {
    list-style: none;
    margin: 0;
    padding: 0 0 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Generous ceiling: long submenus are never clipped */
.pwa-drawer-item.is-open > .pwa-drawer-submenu {
    max-height: 1200px;
}

/* Restoring persisted open groups on load must not animate */
.pwa-no-transition .pwa-drawer-submenu,
.pwa-no-transition .pwa-drawer-chevron {
    transition: none !important;
}

.pwa-drawer-sub-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 12px 8px 42px;
    border-radius: 10px;
    color: rgba(244, 247, 251, 0.72);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pwa-drawer-sub-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pwa-sidebar-text);
}

.pwa-drawer-sub-link.is-active {
    background: var(--pwa-sidebar-active);
    color: var(--pwa-sidebar-bg);
    font-weight: 600;
}

.pwa-drawer-sub-dot {
    width: 5px;
    height: 5px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(244, 247, 251, 0.32);
}

.pwa-drawer-sub-link.is-active .pwa-drawer-sub-dot {
    background: var(--pwa-sidebar-bg);
}

.pwa-drawer-footer {
    flex: 0 0 auto;
    padding: 10px 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pwa-drawer-signout {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(244, 247, 251, 0.88);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pwa-drawer-signout:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pwa-sidebar-text);
}

.pwa-drawer-signout:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: -2px;
}

.pwa-drawer-signout .pwa-drawer-icon {
    color: #e9a08f;
    stroke-width: 1.9;
}

/* ==========================================================================
   8. Chat launcher (installed app only)
   The global launcher sits at bottom:20px and is fully covered by the bottom
   navigation. Lift it above the bar and the device home indicator, and lift
   the chat panel with it so its input row is never hidden.
   ========================================================================== */
body.pwa-standalone-active {
    --pwa-nav-offset: calc(var(--pwa-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    --pwa-chat-panel-height: 450px;
}

body.pwa-standalone-active .init-chat-icon {
    right: 16px;
    bottom: calc(var(--pwa-nav-offset) + 16px);
    z-index: 1035;
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pwa-primary);
    line-height: 1;
    font-weight: 700;
    border: 1px solid var(--pwa-border);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

body.pwa-standalone-active .init-chat-icon:active {
    transform: scale(0.96);
}

body.pwa-standalone-active .init-chat-icon:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

/* Unread state keeps its own colour, only the ring/shadow are normalised */
body.pwa-standalone-active .init-chat-icon.has-message {
    color: #ffffff;
    border-color: transparent;
}

body.pwa-standalone-active .rise-chat-wrapper {
    bottom: var(--pwa-nav-offset) !important;
    z-index: 1044;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.22);
}

/* While the panel is open the launcher becomes its close button and moves
   just above the panel instead of floating over the message input. */
body.pwa-standalone-active .init-chat-icon.move-chat-icon {
    right: 16px !important;
    bottom: min(calc(var(--pwa-nav-offset) + var(--pwa-chat-panel-height) + 12px), calc(100vh - 64px)) !important;
}

/* Wide installed windows: no bottom navigation, so the launcher returns to the
   classic bottom-right corner with the panel attached to it. */
@media (min-width: 991px) {
    body.pwa-standalone-active .init-chat-icon {
        right: 24px;
        bottom: 24px;
    }

    body.pwa-standalone-active .rise-chat-wrapper {
        bottom: 20px !important;
        border-radius: 12px;
    }
}

/* ==========================================================================
   9. Loading experience (installed app only)
   The global pre-loader positioned its spinner from the right edge (right: 56%)
   which drifts off-centre at every width. In the PWA it becomes a centred
   brand splash, and the body-level AJAX spinner is centred too.
   ========================================================================== */
body.pwa-standalone-active #pre-loader {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1085;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(env(safe-area-inset-top, 0px) + 24px) 24px calc(env(safe-area-inset-bottom, 0px) + 24px);
    background: #ffffff;
}

body.pwa-standalone-active #pre-loader .pwa-loader-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
}

body.pwa-standalone-active #pre-loader .pwa-loader-logo {
    max-height: 42px;
    max-width: 190px;
    width: auto;
    object-fit: contain;
}

body.pwa-standalone-active #pre-loader .pwa-loader-name {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--pwa-primary);
}

body.pwa-standalone-active #pre-loader .pwa-loader-ring {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--pwa-primary-light);
    border-top-color: var(--pwa-primary);
    animation: pwa-loader-spin 0.8s linear infinite;
}

body.pwa-standalone-active #pre-loader .pwa-loader-text {
    margin-top: -6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--pwa-text-muted);
}

@keyframes pwa-loader-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Body-level AJAX loader (filters, saves, quick requests): centre the spinner
   instead of parking it in the bottom-right corner. Never traps the user. */
body.pwa-standalone-active > #app-loader.app-loader {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1090 !important;
    pointer-events: none;
}

body.pwa-standalone-active > #app-loader.app-loader .loading {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid var(--pwa-primary-light);
    border-top-color: var(--pwa-primary);
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16), 0 0 0 10px rgba(255, 255, 255, 0.72);
}

/* Tablet landscape / wide PWA windows: persistent sidebar, no mobile bar */
@media (min-width: 991px) {
    body.pwa-standalone-active {
        min-height: 100% !important;
    }

    body.pwa-standalone-active .sidebar.pwa-drawer {
        width: 300px !important;
        max-width: 300px;
        height: 100% !important;
        position: fixed !important;
        border-radius: 0;
        box-shadow: none !important;
        border-right: 0;
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.25s ease, visibility 0s;
    }

    body.pwa-standalone-active.pwa-sidebar-collapsed .sidebar.pwa-drawer {
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.25s ease, visibility 0s linear 0.25s;
    }

    body.pwa-standalone-active .pwa-drawer-close,
    body.pwa-standalone-active .pwa-drawer-backdrop {
        display: none !important;
    }

    body.pwa-standalone-active .pwa-drawer-head {
        padding: 18px 16px 16px;
    }

    body.pwa-standalone-active .pwa-app-header {
        left: 300px;
        transition: left 0.25s ease;
    }

    body.pwa-standalone-active.pwa-sidebar-collapsed .pwa-app-header {
        left: 0;
    }

    body.pwa-standalone-active .page-container {
        margin-left: 300px !important;
        transition: margin-left 0.25s ease;
    }

    body.pwa-standalone-active.pwa-sidebar-collapsed .page-container {
        margin-left: 0 !important;
    }

    body.pwa-standalone-active .pwa-bottom-nav {
        display: none !important;
    }
}

/* ==========================================================================
   10. Sign-in screens (installed app only)
   The authentication views are shared with the standard browser. Everything
   here is gated behind .pwa-signin-page, a marker printed on the page wrapper
   only when is_pwa_standalone_mode() is true, so the browser login stays
   untouched. The marker sits on the wrapper instead of <body> because the
   presentation-mode script rewrites the body class list at runtime.
   ========================================================================== */
.pwa-signin-page {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto !important;
    overflow: visible !important;
    padding: calc(env(safe-area-inset-top, 0px) + 24px) 18px calc(env(safe-area-inset-bottom, 0px) + 24px);
    position: static !important;
    color: var(--pwa-text-strong);
    -webkit-text-size-adjust: 100%;
    /* Soft brand canvas: two corner glows over a light vertical wash */
    background-color: #eaf1f9;
    background-image:
        radial-gradient(60% 48% at 4% -2%, rgba(51, 102, 153, 0.2) 0%, rgba(51, 102, 153, 0) 72%),
        radial-gradient(56% 46% at 102% 102%, rgba(51, 102, 153, 0.22) 0%, rgba(51, 102, 153, 0) 74%),
        linear-gradient(180deg, #f8fbfe 0%, #e2ecf7 100%);
    background-repeat: no-repeat;
}

/* Overscroll canvas behind the wrapper */
body:has(> .pwa-signin-page) {
    height: auto !important;
    background-color: #eaf1f9 !important;
    background-image: none !important;
}

/* The shared perfect-scrollbar initialiser targets .scrollable-page; the sign-in
   wrapper scrolls natively instead. */
.pwa-signin-page .ps__rail-x,
.pwa-signin-page .ps__rail-y {
    display: none !important;
}

.pwa-signin-page .form-signin {
    width: 100%;
    max-width: 404px;
    margin: 0 auto;
    float: none;
}

/* Card shell */
.pwa-signin-page .pwa-signin-card {
    overflow: hidden;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 18px;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.1), 0 2px 8px rgba(15, 23, 42, 0.04);
}

/* Brand + heading area */
.pwa-signin-page .pwa-signin-head {
    padding: 28px 26px 20px;
    text-align: center;
}

.pwa-signin-page .pwa-signin-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 190px;
    max-height: 74px;
    margin: 0 auto 16px;
    object-fit: contain;
}

.pwa-signin-page .pwa-signin-wordmark {
    display: block;
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pwa-primary);
}

.pwa-signin-page .pwa-signin-title {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--pwa-text-strong);
}

.pwa-signin-page .pwa-signin-subtitle {
    margin: 7px 0 0;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--pwa-text-muted);
}

.pwa-signin-page .pwa-signin-body {
    padding: 0 26px 26px;
}

.pwa-signin-page .pwa-signin-body form {
    margin: 0;
}

/* Fields */
.pwa-signin-page .pwa-field {
    margin-bottom: 18px;
}

.pwa-signin-page .pwa-label {
    display: block;
    margin-bottom: 7px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pwa-text-strong);
}

.pwa-signin-page .pwa-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.pwa-signin-page .pwa-label-row .pwa-label {
    margin-bottom: 7px;
}

.pwa-signin-page .pwa-forgot {
    position: relative;
    font-size: 12px;
    font-weight: 600;
    color: var(--pwa-primary);
    text-decoration: none;
    white-space: nowrap;
}

/* Comfortable touch target without disturbing the label row */
.pwa-signin-page .pwa-forgot::after {
    content: "";
    position: absolute;
    top: -13px;
    right: -8px;
    bottom: -13px;
    left: -8px;
}

.pwa-signin-page .pwa-forgot:hover {
    color: var(--pwa-primary-hover);
    text-decoration: underline;
}

.pwa-signin-page .pwa-forgot:focus-visible {
    border-radius: 6px;
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

.pwa-signin-page .pwa-input {
    width: 100%;
    height: 48px;
    min-height: 48px;
    padding: 12px 14px !important;
    font-size: 15px;
    line-height: 1.3;
    color: var(--pwa-text-strong);
    background: var(--pwa-surface) !important;
    border: 1px solid #d8e1ec !important;
    border-radius: 12px;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pwa-signin-page .pwa-input::placeholder {
    color: #94a3b8;
}

.pwa-signin-page .pwa-input:focus {
    border-color: var(--pwa-primary) !important;
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.2);
    outline: 0;
}

/* Keyboard users get a solid, high contrast ring on top of the soft glow */
.pwa-signin-page .pwa-input:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 1px;
}

/* Invalid state: jQuery Validate inserts a .help-block span right after the
   field, so the field itself is flagged through that relationship. */
.pwa-signin-page .pwa-input[aria-invalid="true"],
.pwa-signin-page .pwa-field > .pwa-input:has(+ span.help-block),
.pwa-signin-page .pwa-input-wrap > .pwa-input:has(+ span.help-block) {
    border-color: #dc2626 !important;
}

.pwa-signin-page .pwa-field > .pwa-input:has(+ span.help-block):focus,
.pwa-signin-page .pwa-input-wrap > .pwa-input:has(+ span.help-block):focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16);
}

.pwa-signin-page .pwa-input.error {
    border-color: #dc2626 !important;
}

.pwa-signin-page .pwa-input-wrap {
    position: relative;
}

.pwa-signin-page .pwa-input-wrap .pwa-input {
    padding-right: 50px !important;
}

/* Validation feedback. The shared jQuery Validate setup inserts a
   <span class="help-block"> right after the field and flags the input itself. */
.pwa-signin-page .pwa-field span.help-block,
.pwa-signin-page .pwa-input-wrap span.help-block {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.35;
    color: #dc2626;
}

.pwa-signin-page .pwa-input.help-block {
    color: var(--pwa-text-strong);
    border-color: #dc2626 !important;
}

.pwa-signin-page .pwa-pw-toggle {
    position: absolute;
    top: 24px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--pwa-text-muted);
    transform: translateY(-50%);
    cursor: pointer;
}

.pwa-signin-page .pwa-pw-toggle:hover {
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

.pwa-signin-page .pwa-pw-toggle:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: -2px;
}

.pwa-signin-page .pwa-pw-toggle svg {
    width: 18px;
    height: 18px;
}

/* Primary action */
.pwa-signin-page .pwa-signin-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 50px;
    margin-top: 0;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: var(--pwa-primary);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.pwa-signin-page .pwa-signin-submit:hover {
    background: var(--pwa-primary-hover);
}

.pwa-signin-page .pwa-signin-submit:active {
    background: #214b73;
    transform: translateY(1px);
}

.pwa-signin-page .pwa-signin-submit:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

.pwa-signin-page .pwa-signin-spinner {
    display: none;
    width: 17px;
    height: 17px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: pwa-loader-spin 0.7s linear infinite;
}

.pwa-signin-page .pwa-signin-submit.is-loading {
    background: var(--pwa-primary-hover);
    pointer-events: none;
}

.pwa-signin-page .pwa-signin-submit.is-loading .pwa-signin-spinner {
    display: inline-block;
}

/* Secondary links + feedback */
.pwa-signin-page .pwa-signin-alt {
    margin: 18px 0 0;
    font-size: 13px;
    text-align: center;
    color: var(--pwa-text-muted);
}

.pwa-signin-page .pwa-signin-link {
    position: relative;
    color: var(--pwa-primary);
    font-weight: 600;
    text-decoration: none;
}

.pwa-signin-page .pwa-signin-link::after {
    content: "";
    position: absolute;
    top: -13px;
    right: -6px;
    bottom: -13px;
    left: -6px;
}

.pwa-signin-page .pwa-signin-link:hover {
    text-decoration: underline;
}

.pwa-signin-page .pwa-signin-form .form-group {
    margin-bottom: 16px;
}

/* reCAPTCHA keeps its own box; never let it force horizontal scrolling. */
.pwa-signin-page .pwa-signin-body .g-recaptcha {
    max-width: 100%;
    overflow: hidden;
    transform-origin: left top;
}

.pwa-signin-page .pwa-signin-body .alert {
    margin-bottom: 16px;
    padding: 11px 13px;
    border-radius: 12px;
    font-size: 12.5px;
    line-height: 1.45;
}

.pwa-signin-page .pwa-signin-body .alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* Password recovery + reset password screens keep their .card markup and
   inherit the same card, field and button treatment for consistency. */
.pwa-signin-page .form-signin .card {
    overflow: hidden;
    margin: 0;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 18px;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.1), 0 2px 8px rgba(15, 23, 42, 0.04);
}

.pwa-signin-page .form-signin .card-header {
    padding: 26px 24px 2px;
    background: transparent;
    border: 0;
    text-align: center;
}

.pwa-signin-page .form-signin .card-header img {
    display: block;
    max-height: 38px;
    margin: 0 auto;
    padding: 0 !important;
}

.pwa-signin-page .form-signin .card-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: var(--pwa-text-strong);
}

.pwa-signin-page .form-signin .card-body {
    padding: 18px 24px 24px !important;
}

.pwa-signin-page .form-signin .card-body label {
    margin-bottom: 7px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pwa-text-strong);
}

.pwa-signin-page .form-signin .card-body .form-control {
    height: 48px;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--pwa-text-strong);
    background: var(--pwa-surface);
    border: 1px solid #d8e1ec;
    border-radius: 12px;
    box-shadow: none;
}

.pwa-signin-page .form-signin .card-body .form-control:focus {
    border-color: var(--pwa-primary);
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.2);
}

.pwa-signin-page .form-signin .card-body .form-control:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 1px;
}

.pwa-signin-page .form-signin .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    padding: 0 18px;
    font-size: 15px;
    font-weight: 600;
    background: var(--pwa-primary);
    border: 0;
    border-radius: 12px;
}

.pwa-signin-page .form-signin .btn-primary:hover,
.pwa-signin-page .form-signin .btn-primary:focus {
    background: var(--pwa-primary-hover);
}

.pwa-signin-page .form-signin .card-body a {
    color: var(--pwa-primary);
    font-weight: 600;
}

/* Responsive tuning */
@media (min-width: 768px) {
    /* Faint brand dot texture fills the wider desktop canvas */
    .pwa-signin-page {
        background-image:
            radial-gradient(circle at 1px 1px, rgba(51, 102, 153, 0.08) 1px, transparent 0),
            radial-gradient(60% 48% at 4% -2%, rgba(51, 102, 153, 0.2) 0%, rgba(51, 102, 153, 0) 72%),
            radial-gradient(56% 46% at 102% 102%, rgba(51, 102, 153, 0.22) 0%, rgba(51, 102, 153, 0) 74%),
            linear-gradient(180deg, #f8fbfe 0%, #e2ecf7 100%);
        background-size: 24px 24px, auto, auto, auto;
        background-repeat: repeat, no-repeat, no-repeat, no-repeat;
    }
}

@media (max-width: 380px) {
    .pwa-signin-page .pwa-signin-head {
        padding: 24px 20px 18px;
    }

    .pwa-signin-page .pwa-signin-body {
        padding: 0 20px 22px;
    }

    .pwa-signin-page .pwa-signin-logo {
        max-height: 62px;
        margin-bottom: 14px;
    }

    .pwa-signin-page .pwa-signin-title {
        font-size: 21px;
    }

    .pwa-signin-page .form-signin .card-header {
        padding: 22px 20px 2px;
    }

    .pwa-signin-page .form-signin .card-body {
        padding: 16px 20px 22px !important;
    }

    .pwa-signin-page .pwa-signin-body .g-recaptcha {
        transform: scale(0.82);
    }
}

@media (min-width: 600px) {
    .pwa-signin-page .form-signin {
        max-width: 420px;
    }
}

/* Short viewports (landscape phones, small windows, open keyboard) keep the
   card anchored to the top so the whole form stays reachable. */
@media (max-height: 620px) {
    .pwa-signin-page {
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-signin-page .pwa-signin-submit,
    .pwa-signin-page .pwa-input {
        transition: none !important;
    }

    .pwa-signin-page .pwa-signin-spinner {
        animation-duration: 1.6s;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    body.pwa-standalone-active .sidebar.pwa-drawer,
    .pwa-drawer-backdrop,
    .pwa-bottom-nav,
    .pwa-drawer-chevron,
    .pwa-drawer-submenu,
    .pwa-app-header {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================================================
   11. Invoices module (installed app only)
   The invoice dashboard and the invoice list are rendered by
   app/Views/pwa/invoices/* only when is_pwa_standalone_mode() is true, so
   every rule below is namespaced with .pwa-inv- and cannot leak into the
   standard browser module or any shared component.
   ========================================================================== */
.pwa-inv-page {
    --pwa-inv-card-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
    --pwa-inv-accent: var(--pwa-primary);
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 16px 26px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: var(--pwa-text-strong);
    font-variant-numeric: tabular-nums;
}

/* Icon sizes that only exist inside the invoice module */
.pwa-inv-page .icon-12 {
    width: 12px;
    height: 12px;
}

.pwa-inv-page .icon-20 {
    width: 20px;
    height: 20px;
}

.pwa-inv-page svg.feather {
    flex: 0 0 auto;
}

/* 11.1 Page header */
.pwa-inv-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 16px;
    box-shadow: var(--pwa-inv-card-shadow);
}

.pwa-inv-hero-main {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.pwa-inv-hero-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

.pwa-inv-hero-icon svg {
    width: 20px;
    height: 20px;
}

.pwa-inv-hero-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pwa-inv-hero-text h1 {
    margin: 0;
    font-size: 16.5px;
    font-weight: 800;
    letter-spacing: -0.2px;
    line-height: 1.2;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-hero-sub {
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--pwa-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 11.2 Filters */
.pwa-inv-filters,
.pwa-inv-filter-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.pwa-inv-filter {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    margin: 0;
}

.pwa-inv-filter-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--pwa-text-muted);
}

.pwa-inv-select {
    width: 100%;
    height: 44px;
    min-height: 44px;
    padding: 10px 34px 10px 12px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--pwa-text-strong);
    background-color: var(--pwa-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 14px;
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pwa-inv-select:focus {
    border-color: var(--pwa-primary);
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.16);
    outline: 0;
}

.pwa-inv-select:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 1px;
}

.pwa-inv-select option {
    color: var(--pwa-text-strong);
}

.pwa-inv-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* 11.3 Buttons */
.pwa-inv-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pwa-inv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 44px;
    padding: 0 15px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-decoration: none !important;
    color: var(--pwa-text-strong) !important;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
    box-shadow: var(--pwa-inv-card-shadow);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pwa-inv-btn:hover {
    background: var(--pwa-soft);
    border-color: #cdd9e8;
}

.pwa-inv-btn:active {
    transform: scale(0.985);
}

.pwa-inv-btn:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

.pwa-inv-btn svg {
    width: 16px;
    height: 16px;
}

.pwa-inv-btn.is-primary {
    background: var(--pwa-primary);
    border-color: var(--pwa-primary);
    color: #ffffff !important;
}

.pwa-inv-btn.is-primary:hover {
    background: var(--pwa-primary-hover);
    border-color: var(--pwa-primary-hover);
}

.pwa-inv-btn.is-warning {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #3b2606 !important;
}

.pwa-inv-btn.is-warning:hover {
    background: #d97706;
    border-color: #d97706;
}

.pwa-inv-btn.is-ghost {
    background: transparent;
    box-shadow: none;
}

.pwa-inv-btn.is-ghost:hover {
    background: var(--pwa-primary-light);
    border-color: transparent;
}

.pwa-inv-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pwa-inv-icon-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-decoration: none !important;
    color: var(--pwa-text-muted) !important;
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pwa-inv-icon-btn svg {
    width: 18px;
    height: 18px;
}

.pwa-inv-icon-btn:hover {
    background: var(--pwa-primary-light);
    border-color: transparent;
    color: var(--pwa-primary) !important;
}

.pwa-inv-icon-btn:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

.pwa-inv-icon-btn.is-primary {
    background: var(--pwa-primary);
    border-color: var(--pwa-primary);
    color: #ffffff !important;
}

.pwa-inv-icon-btn.is-primary:hover {
    background: var(--pwa-primary-hover);
    border-color: var(--pwa-primary-hover);
    color: #ffffff !important;
}

.pwa-inv-icon-btn.is-small {
    width: 40px;
    height: 40px;
    border-radius: 11px;
}

.pwa-inv-icon-btn.is-small svg {
    width: 16px;
    height: 16px;
}

/* 11.4 Financial summary */
.pwa-inv-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.pwa-inv-metric {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    padding: 13px 12px 11px;
    overflow: hidden;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 14px;
    box-shadow: var(--pwa-inv-card-shadow);
}

.pwa-inv-metric::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--pwa-inv-accent);
}

.pwa-inv-metric.is-blue {
    --pwa-inv-accent: #336699;
}

.pwa-inv-metric.is-green {
    --pwa-inv-accent: #059669;
}

.pwa-inv-metric.is-red {
    --pwa-inv-accent: #dc2626;
}

.pwa-inv-metric.is-amber {
    --pwa-inv-accent: #d97706;
}

.pwa-inv-metric-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
}

.pwa-inv-metric-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.25;
    text-transform: uppercase;
    color: var(--pwa-text-muted);
}

.pwa-inv-metric-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--pwa-soft);
    color: var(--pwa-inv-accent);
}

.pwa-inv-metric-icon svg {
    width: 14px;
    height: 14px;
}

.pwa-inv-metric-value {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.2;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-metric-value.is-success {
    color: var(--pwa-success);
}

.pwa-inv-metric-value.is-danger {
    color: #dc2626;
}

.pwa-inv-metric-value.is-warning {
    color: #b45309;
}

.pwa-inv-metric-sub {
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--pwa-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 11.5 Section cards */
.pwa-inv-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 14px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 16px;
    box-shadow: var(--pwa-inv-card-shadow);
}

.pwa-inv-card.is-filters {
    padding: 13px;
    gap: 12px;
}

.pwa-inv-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.pwa-inv-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pwa-inv-card-title > div {
    min-width: 0;
}

.pwa-inv-card-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

.pwa-inv-card-icon svg {
    width: 16px;
    height: 16px;
}

.pwa-inv-card-title h2 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 800;
    letter-spacing: -0.1px;
    line-height: 1.25;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-card-title p {
    margin: 2px 0 0;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--pwa-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 0 0 auto;
    max-width: 46%;
    padding: 5px 9px;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    text-decoration: none !important;
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    border-radius: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-tag svg {
    width: 12px;
    height: 12px;
}

.pwa-inv-tag.is-action {
    min-height: 32px;
    color: var(--pwa-primary) !important;
    background: var(--pwa-primary-light);
    border-color: transparent;
}

.pwa-inv-tag.is-action:hover {
    background: #dcebf8;
}

.pwa-inv-tag.is-action:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

/* 11.6 Invoice pipeline */
.pwa-inv-pipeline {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.pwa-inv-pipe {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 11px 12px 10px 13px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-left: 3px solid var(--pwa-inv-accent);
    border-radius: 12px;
}

.pwa-inv-pipe.is-current {
    --pwa-inv-accent: #336699;
    background: linear-gradient(180deg, #f5f9fd 0%, #ffffff 62%);
}

.pwa-inv-pipe.is-next {
    --pwa-inv-accent: #0284c7;
}

.pwa-inv-pipe.is-quarter {
    --pwa-inv-accent: #94a3b8;
}

.pwa-inv-pipe-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.pwa-inv-pipe-period {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pwa-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-pipe-badge {
    flex: 0 0 auto;
    padding: 3px 8px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.5;
    white-space: nowrap;
    border-radius: 999px;
}

.pwa-inv-pipe-badge.is-primary {
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

.pwa-inv-pipe-badge.is-info {
    background: #e0f2fe;
    color: #0369a1;
}

.pwa-inv-pipe-badge.is-muted {
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    color: var(--pwa-text-muted);
}

.pwa-inv-pipe-amount {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.2;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-pipe-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

.pwa-inv-pipe-foot span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pwa-inv-pipe-foot span:last-child {
    flex: 0 0 auto;
}

/* 11.7 Month-wise comparison - compact selector */
.pwa-inv-mw-compact {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pwa-inv-mw-chips {
    display: flex;
    gap: 7px;
    margin: 0 -2px;
    padding: 2px 2px 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.pwa-inv-mw-chips::-webkit-scrollbar {
    display: none;
}

.pwa-inv-chip {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pwa-inv-chip.is-current {
    color: var(--pwa-primary);
    border-color: #c7dcee;
}

.pwa-inv-chip.is-active {
    background: var(--pwa-primary);
    border-color: var(--pwa-primary);
    color: #ffffff;
}

.pwa-inv-chip:hover {
    border-color: #cdd9e8;
}

.pwa-inv-chip.is-active:hover {
    background: var(--pwa-primary-hover);
    border-color: var(--pwa-primary-hover);
}

.pwa-inv-chip:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
}

.pwa-inv-mw-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
}

.pwa-inv-mw-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    border-bottom: 1px solid #eef2f8;
}

.pwa-inv-mw-row:last-child {
    border-bottom: 0;
}

.pwa-inv-mw-name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pwa-text-muted);
}

.pwa-inv-mw-name svg {
    color: var(--pwa-inv-accent);
}

.pwa-inv-mw-name.is-pipe {
    --pwa-inv-accent: #336699;
}

.pwa-inv-mw-name.is-invoiced {
    --pwa-inv-accent: #0891b2;
}

.pwa-inv-mw-name.is-collected {
    --pwa-inv-accent: #059669;
}

.pwa-inv-mw-value {
    font-size: 13.5px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--pwa-text-strong);
    white-space: nowrap;
}

/* 11.8 Dense tables (month matrix, recurring, recent invoices) */
.pwa-inv-mw-table,
.pwa-inv-table-wide {
    display: none;
}

.pwa-inv-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
}

.pwa-inv-table {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}

.pwa-inv-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 9px 11px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
    border-bottom: 1px solid var(--pwa-border);
}

.pwa-inv-table tbody th,
.pwa-inv-table tbody td {
    padding: 10px 11px;
    vertical-align: middle;
    color: var(--pwa-text-strong);
    border-bottom: 1px solid #eef2f8;
}

.pwa-inv-table tbody tr:last-child th,
.pwa-inv-table tbody tr:last-child td {
    border-bottom: 0;
}

.pwa-inv-table tbody tr:hover th,
.pwa-inv-table tbody tr:hover td {
    background: #fbfcfe;
}

.pwa-inv-table .num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.pwa-inv-table .center {
    text-align: center;
}

.pwa-inv-table thead th.num,
.pwa-inv-table thead th.is-current {
    color: var(--pwa-primary);
}

.pwa-inv-th-metric {
    position: sticky;
    left: 0;
    z-index: 2;
    font-size: 11.5px;
    font-weight: 700;
    text-align: left !important;
    white-space: nowrap;
    color: var(--pwa-text-muted) !important;
    background: var(--pwa-surface);
}

.pwa-inv-table thead .pwa-inv-th-metric {
    z-index: 3;
    background: var(--pwa-soft);
}

.pwa-inv-mw-table .pwa-inv-table {
    min-width: 940px;
}

.pwa-inv-cell-sub {
    display: block;
    margin-top: 2px;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

/* Semantic colour dots used by the matrix, legend and charts */
.pwa-inv-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    vertical-align: middle;
    border-radius: 50%;
    background: #94a3b8;
}

.pwa-inv-dot.is-pipe {
    background: #336699;
}

.pwa-inv-dot.is-invoiced {
    background: #0891b2;
}

.pwa-inv-dot.is-collected,
.pwa-inv-dot.is-paid {
    background: #059669;
}

.pwa-inv-dot.is-draft {
    background: #f59e0b;
}

.pwa-inv-dot.is-approved {
    background: #0891b2;
}

.pwa-inv-dot.is-sent {
    background: #336699;
}

.pwa-inv-dot.is-partial {
    background: #ea580c;
}

/* 11.9 Upcoming recurring invoices */
.pwa-inv-rec-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pwa-inv-rec-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    padding: 12px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
}

.pwa-inv-rec-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.pwa-inv-rec-client {
    min-width: 0;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--pwa-text-strong);
    overflow-wrap: break-word;
}

.pwa-inv-rec-freq {
    flex: 0 0 auto;
    padding: 3px 8px;
    font-size: 9.5px;
    font-weight: 800;
    line-height: 1.5;
    text-transform: capitalize;
    white-space: nowrap;
    color: var(--pwa-primary);
    background: var(--pwa-primary-light);
    border-radius: 999px;
}

.pwa-inv-rec-next {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 11.5px;
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
    border-radius: 10px;
}

.pwa-inv-rec-next svg {
    color: var(--pwa-primary);
}

.pwa-inv-rec-next-label {
    font-weight: 600;
}

.pwa-inv-rec-next strong {
    margin-left: auto;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    color: var(--pwa-text-strong);
}

.pwa-inv-rec-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pwa-inv-rec-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 11.5px;
    color: var(--pwa-text-muted);
}

.pwa-inv-rec-meta-row > span:first-child {
    flex: 0 0 auto;
}

.pwa-inv-rec-meta-row > span:last-child {
    min-width: 0;
    font-weight: 600;
    text-align: right;
    color: var(--pwa-text-strong);
    overflow-wrap: break-word;
}

.pwa-inv-rec-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 9px;
    border-top: 1px solid #eef2f8;
}

.pwa-inv-rec-amount {
    font-size: 13.5px;
    font-weight: 800;
    white-space: nowrap;
    color: var(--pwa-text-strong);
}

.pwa-inv-rec-actions {
    display: inline-flex;
    gap: 6px;
}

.pwa-inv-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
    border-radius: 999px;
}

.pwa-inv-pill.is-primary {
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

.pwa-inv-pill.is-info {
    background: #e0f2fe;
    color: #0369a1;
}

.pwa-inv-pill.is-muted {
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    color: var(--pwa-text-muted);
}

/* 11.10 Charts */
.pwa-inv-chart {
    position: relative;
    width: 100%;
    min-width: 0;
}

.pwa-inv-chart canvas {
    max-width: 100%;
}

.pwa-inv-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding-top: 10px;
    border-top: 1px solid #eef2f8;
}

.pwa-inv-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pwa-text-muted);
}

.pwa-inv-legend-item strong {
    font-weight: 800;
    color: var(--pwa-text-strong);
}

/* 11.11 Invoice cards */
.pwa-inv-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pwa-inv-item {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    padding: 12px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 13px;
    box-shadow: var(--pwa-inv-card-shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pwa-inv-item:hover {
    border-color: #cdd9e8;
    box-shadow: 0 6px 16px rgba(23, 32, 51, 0.06);
}

.pwa-inv-item-top {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pwa-inv-item-head {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13.5px;
    line-height: 1.3;
    overflow: hidden;
}

.pwa-inv-item-head a {
    color: var(--pwa-text-strong) !important;
    text-decoration: none !important;
}

.pwa-inv-item-head .badge {
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 700;
    vertical-align: middle;
    border-radius: 999px;
}

.pwa-inv-item-status {
    flex: 0 0 auto;
}

.pwa-inv-item-status .badge {
    padding: 4px 8px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.4;
    border-radius: 999px;
}

.pwa-inv-item-number {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 800;
    text-decoration: none !important;
    color: var(--pwa-primary) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-item-client {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--pwa-text-strong);
    overflow-wrap: break-word;
}

.pwa-inv-item-client .text-primary {
    color: var(--pwa-primary) !important;
    font-weight: 600;
}

.pwa-inv-item-date {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

.pwa-inv-item-date svg {
    width: 12px;
    height: 12px;
}

.pwa-inv-item-money {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 9px 10px;
    background: var(--pwa-soft);
    border-radius: 10px;
}

.pwa-inv-item-money > div {
    flex: 1 1 28%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pwa-inv-item-money span {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--pwa-text-muted);
}

.pwa-inv-item-money strong {
    font-size: 12px;
    font-weight: 800;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-item-money strong.is-success {
    color: var(--pwa-success);
}

.pwa-inv-item-money strong.is-due {
    color: #dc2626;
}

.pwa-inv-item-sub {
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--pwa-text-muted);
}

.pwa-inv-item-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #eef2f8;
}

.pwa-inv-inline-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.pwa-inv-item-foot .pwa-inv-inline-actions:last-child {
    justify-content: flex-end;
    margin-left: auto;
}

.pwa-inv-inline-actions > .edit,
.pwa-inv-inline-actions > .delete,
.pwa-inv-inline-actions .disabled-edit-wrapper > .edit {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    background: var(--pwa-soft);
    border-radius: 10px;
    transition: background-color 0.15s ease;
}

.pwa-inv-inline-actions > .edit:hover,
.pwa-inv-inline-actions .disabled-edit-wrapper > .edit:hover {
    background: var(--pwa-primary-light);
}

.pwa-inv-inline-actions > .delete:hover {
    background: #fef2f2;
}

.pwa-inv-inline-actions .edit svg,
.pwa-inv-inline-actions .delete svg {
    width: 16px;
    height: 16px;
}

.pwa-inv-inline-actions .btn {
    min-height: 36px;
    height: 36px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: 10px;
}

.pwa-inv-inline-actions .btn svg {
    width: 15px;
    height: 15px;
}

.pwa-inv-inline-actions .btn .badge {
    padding: 2px 6px;
    font-size: 9.5px;
}

.pwa-inv-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    margin: 0;
}

.pwa-inv-page .pwa-inv-checkbox {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    background-color: var(--pwa-surface);
    border: 1.5px solid #c3cfdd;
    border-radius: 6px;
}

.pwa-inv-page .pwa-inv-checkbox:checked {
    background-color: var(--pwa-primary);
    border-color: var(--pwa-primary);
}

.pwa-inv-page .pwa-inv-checkbox:focus {
    border-color: var(--pwa-primary);
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.18);
}

/* Status pills */
.pwa-inv-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.5;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    border-radius: 999px;
}

.pwa-inv-status.is-draft {
    color: #b45309;
    background: #fef3c7;
    border-color: transparent;
}

.pwa-inv-status.is-approved {
    color: #0369a1;
    background: #e0f2fe;
    border-color: transparent;
}

.pwa-inv-status.is-sent {
    color: var(--pwa-primary);
    background: var(--pwa-primary-light);
    border-color: transparent;
}

.pwa-inv-status.is-partial {
    color: #c2410c;
    background: #ffedd5;
    border-color: transparent;
}

.pwa-inv-status.is-paid {
    color: var(--pwa-success);
    background: #e7f6ef;
    border-color: transparent;
}

.pwa-inv-status.is-muted {
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
}

/* Links that open the shared breakdown modals */
.pwa-inv-page .pwa-inv-link {
    font-weight: 700;
    text-decoration: none !important;
    color: var(--pwa-primary) !important;
    border-bottom: 1px dashed transparent;
    cursor: pointer;
}

.pwa-inv-page .pwa-inv-link:hover {
    border-bottom-color: currentColor;
}

.pwa-inv-page .pwa-inv-link.is-success {
    color: var(--pwa-success) !important;
}

.pwa-inv-page .pwa-inv-link:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* 11.12 Manage invoices toolbar */
.pwa-inv-search {
    position: relative;
    display: flex;
    align-items: center;
}

.pwa-inv-search svg {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: #94a3b8;
    pointer-events: none;
}

.pwa-inv-input {
    width: 100%;
    height: 44px;
    min-height: 44px;
    padding: 10px 12px 10px 36px;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.2;
    color: var(--pwa-text-strong);
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.pwa-inv-input::placeholder {
    color: #94a3b8;
}

.pwa-inv-input:focus {
    border-color: var(--pwa-primary);
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.16);
    outline: 0;
}

.pwa-inv-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.pwa-inv-bulkbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 11px;
    color: #ffffff;
    background: var(--pwa-primary);
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(51, 102, 153, 0.26);
}

.pwa-inv-bulkbar[hidden] {
    display: none !important;
}

.pwa-inv-bulkbar-count {
    font-size: 12px;
    font-weight: 600;
}

.pwa-inv-bulkbar .pwa-inv-btn {
    min-height: 38px;
    padding: 0 12px;
    font-size: 12px;
}

.pwa-inv-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.pwa-inv-pager[hidden] {
    display: none !important;
}

.pwa-inv-pager .pwa-inv-btn {
    padding: 0 12px;
    box-shadow: none;
}

.pwa-inv-pager-info {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    color: var(--pwa-text-muted);
}

/* 11.13 Empty and loading states */
.pwa-inv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 26px 16px;
    text-align: center;
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
    border: 1px dashed var(--pwa-border);
    border-radius: 13px;
}

.pwa-inv-empty svg {
    color: #94a3b8;
}

.pwa-inv-empty-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--pwa-text-strong);
}

.pwa-inv-empty-text {
    max-width: 34ch;
    font-size: 11.5px;
    line-height: 1.45;
}

.pwa-inv-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 26px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pwa-text-muted);
}

.pwa-inv-loading .pwa-loader-ring {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    border: 2px solid var(--pwa-border);
    border-top-color: var(--pwa-primary);
    border-radius: 50%;
    animation: pwa-loader-spin 0.7s linear infinite;
}

/* 11.14 Wider windows: cards give way to the dense tables */
@media (min-width: 560px) {
    .pwa-inv-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pwa-inv-pipeline {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 700px) {
    .pwa-inv-filter-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Tablets get the full four-up summary instead of two very wide cards */
    .pwa-inv-metrics {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
    }
}

@media (min-width: 900px) {
    .pwa-inv-mw-compact,
    .pwa-inv-rec-list,
    .pwa-inv-card > .pwa-inv-list {
        display: none;
    }

    .pwa-inv-mw-table,
    .pwa-inv-table-wide {
        display: block;
    }

    .pwa-inv-table {
        min-width: 640px;
    }

    .pwa-inv-card {
        padding: 16px;
    }
}

@media (min-width: 1280px) {
    .pwa-inv-page {
        padding-top: 18px;
        gap: 16px;
    }
}

/* 11.15 Very narrow phones */
@media (max-width: 359px) {
    .pwa-inv-page {
        gap: 12px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .pwa-inv-card,
    .pwa-inv-card.is-filters {
        padding: 12px;
    }

    .pwa-inv-metric-value {
        font-size: 14px;
    }

    .pwa-inv-metric-label {
        font-size: 10px;
    }

    .pwa-inv-item-money strong {
        font-size: 11.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-inv-page .pwa-inv-btn,
    .pwa-inv-page .pwa-inv-icon-btn,
    .pwa-inv-page .pwa-inv-chip,
    .pwa-inv-page .pwa-inv-select,
    .pwa-inv-page .pwa-inv-item,
    .pwa-inv-page .pwa-inv-link,
    .pwa-inv-inline-actions > .edit,
    .pwa-inv-inline-actions > .delete {
        transition: none !important;
    }

    .pwa-inv-loading .pwa-loader-ring {
        animation-duration: 1.8s;
    }
}

/* ==========================================================================
   12. Pipeline Breakdown modal (installed app only)
   The shared #ajaxModal wrapper supplies the title and the single close
   button. The PWA view adds the .pwa-inv-modal marker to that wrapper, so
   everything below is double-scoped: it can never reach the standard browser
   modal, other ajax modals, or the invoices dashboard itself.
   ========================================================================== */
body.pwa-standalone-active .pwa-inv-modal .modal-dialog {
    width: calc(100% - 20px);
    max-width: 520px;
    margin: 10px auto;
}

body.pwa-standalone-active .pwa-inv-modal .modal-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    background: var(--pwa-surface);
    border: 0;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

/* Fixed header: compact title plus the only close control */
body.pwa-standalone-active .pwa-inv-modal .modal-header {
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    background: var(--pwa-surface);
    border-bottom: 1px solid var(--pwa-border);
    border-radius: 0;
}

body.pwa-standalone-active .pwa-inv-modal .modal-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: -0.2px;
    line-height: 1.25;
    color: var(--pwa-text-strong);
    white-space: normal;
    overflow-wrap: break-word;
}

body.pwa-standalone-active .pwa-inv-modal .modal-header .btn-close {
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 14px;
    margin: 0;
    background-color: var(--pwa-soft);
    background-size: 15px 15px;
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
    opacity: 1;
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

body.pwa-standalone-active .pwa-inv-modal .modal-header .btn-close:hover {
    background-color: var(--pwa-primary-light);
    border-color: transparent;
}

body.pwa-standalone-active .pwa-inv-modal .modal-header .btn-close:focus,
body.pwa-standalone-active .pwa-inv-modal .modal-header .btn-close:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: 2px;
    box-shadow: none;
}

/* Scrollable content region between the fixed header and footer */
body.pwa-standalone-active .pwa-inv-modal #ajaxModalContent {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px 14px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}

body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-footer {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--pwa-surface);
    border-top: 1px solid var(--pwa-border);
    border-radius: 0;
}

body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-footer .pwa-inv-btn {
    min-height: 40px;
    padding: 0 18px;
    font-size: 12.5px;
}

/* Currency context */
.pwa-inv-bd-context {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.pwa-inv-bd-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    border-radius: 999px;
}

/* Monthly financial summary */
.pwa-inv-bd-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

.pwa-inv-bd-kpi {
    --pwa-inv-accent: var(--pwa-primary);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    padding: 9px 12px 9px 14px;
    overflow: hidden;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
}

.pwa-inv-bd-kpi::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 3px;
    background: var(--pwa-inv-accent);
}

.pwa-inv-bd-kpi.is-green {
    --pwa-inv-accent: #059669;
}

.pwa-inv-bd-kpi.is-amber {
    --pwa-inv-accent: #d97706;
}

.pwa-inv-bd-kpi.is-blue {
    --pwa-inv-accent: #336699;
}

.pwa-inv-bd-kpi-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.3;
    text-transform: uppercase;
    color: var(--pwa-text-muted);
}

.pwa-inv-bd-kpi-value {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.2;
    color: var(--pwa-inv-accent);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.pwa-inv-bd-kpi-sub {
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--pwa-text-muted);
}

/* Invoice sections */
.pwa-inv-bd-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.pwa-inv-bd-head {
    --pwa-inv-accent: var(--pwa-primary);
    overflow: hidden;
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-border);
    border-left: 3px solid var(--pwa-inv-accent);
    border-radius: 12px;
}

.pwa-inv-bd-head.is-amber {
    --pwa-inv-accent: #d97706;
}

.pwa-inv-bd-head.is-blue {
    --pwa-inv-accent: #336699;
}

/* The whole bar is the toggle, so the tap target is never below 44px */
.pwa-inv-bd-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 8px 11px 8px 12px;
    font: inherit;
    text-align: left;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.pwa-inv-bd-toggle:hover {
    background: #eff4fb;
}

.pwa-inv-bd-toggle:focus,
.pwa-inv-bd-toggle:focus-visible {
    outline: 2px solid var(--pwa-primary);
    outline-offset: -2px;
}

.pwa-inv-bd-head-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pwa-surface);
    border-radius: 8px;
    color: var(--pwa-inv-accent);
}

.pwa-inv-bd-head-icon svg {
    width: 14px;
    height: 14px;
}

.pwa-inv-bd-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.pwa-inv-bd-head-title {
    display: block;
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1.25;
    color: var(--pwa-text-strong);
}

.pwa-inv-bd-head-sub {
    display: block;
    margin-top: 1px;
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--pwa-text-muted);
}

.pwa-inv-bd-head-total {
    flex: 0 0 auto;
    font-size: 12.5px;
    font-weight: 800;
    white-space: nowrap;
    color: var(--pwa-inv-accent);
    font-variant-numeric: tabular-nums;
}

.pwa-inv-bd-chevron {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--pwa-text-muted);
    transition: transform 0.2s ease;
}

.pwa-inv-bd-chevron svg {
    width: 16px;
    height: 16px;
}

.pwa-inv-bd-toggle[aria-expanded="false"] .pwa-inv-bd-chevron {
    transform: rotate(-90deg);
}

/* Collapsible panel: keeps its own rhythm while Bootstrap owns the height */
.pwa-inv-bd-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pwa-inv-bd-panel.collapsing {
    overflow: hidden;
}

/* Invoice cards (narrow screens) */
.pwa-inv-bd-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pwa-inv-bd-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    padding: 10px 11px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-border);
    border-radius: 12px;
}

.pwa-inv-bd-card-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.pwa-inv-bd-card-no {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1.3;
    text-decoration: none !important;
    color: var(--pwa-primary) !important;
    overflow-wrap: anywhere;
}

.pwa-inv-bd-card-no.is-projected,
.pwa-inv-bd-cell-no .is-projected,
.pwa-inv-bd-table .is-projected {
    color: var(--pwa-text-muted) !important;
    font-weight: 600;
}

.pwa-inv-bd-card-client {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--pwa-text-strong);
    overflow-wrap: anywhere;
}

.pwa-inv-bd-card-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

.pwa-inv-bd-card-meta svg {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
}

.pwa-inv-bd-card-money {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 2px;
    padding-top: 7px;
    border-top: 1px solid #eef2f8;
}

.pwa-inv-bd-card-money > div {
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.pwa-inv-bd-card-money span {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--pwa-text-muted);
}

.pwa-inv-bd-card-money strong {
    font-size: 12.5px;
    font-weight: 800;
    color: var(--pwa-text-strong);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.pwa-inv-bd-card-money strong.is-success {
    color: var(--pwa-success);
}

.pwa-inv-bd-card-money strong.is-due {
    color: #dc2626;
}

/* Subtotals under the card lists */
.pwa-inv-bd-subtotal {
    --pwa-inv-accent: var(--pwa-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 11px;
    background: var(--pwa-primary-light);
    border-radius: 11px;
}

.pwa-inv-bd-subtotal.is-amber {
    --pwa-inv-accent: #b45309;
    background: #fef3c7;
}

.pwa-inv-bd-subtotal.is-blue {
    background: var(--pwa-primary-light);
}

.pwa-inv-bd-subtotal span {
    min-width: 0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.3;
    text-transform: uppercase;
    color: var(--pwa-inv-accent);
}

.pwa-inv-bd-subtotal strong {
    flex: 0 0 auto;
    font-size: 13.5px;
    font-weight: 800;
    white-space: nowrap;
    color: var(--pwa-text-strong);
    font-variant-numeric: tabular-nums;
}

/* Tables (tablet and wider) */
.pwa-inv-bd-table-wrap {
    display: none;
}

.pwa-inv-bd-table .pwa-nowrap {
    white-space: nowrap;
}

/* Invoice links keep the dashboard styling inside the modal */
.pwa-inv-bd-table .pwa-inv-link {
    font-weight: 700;
    text-decoration: none !important;
    color: var(--pwa-primary) !important;
    border-bottom: 1px dashed transparent;
}

.pwa-inv-bd-table .pwa-inv-link:hover {
    color: var(--pwa-primary-hover) !important;
    border-bottom-color: var(--pwa-primary-hover);
}

.pwa-inv-bd-table td.is-success {
    color: var(--pwa-success);
}

.pwa-inv-bd-table td.is-due {
    color: #dc2626;
}

.pwa-inv-bd-table tfoot th {
    position: static;
    padding: 10px 11px;
    font-size: 11.5px;
    font-weight: 800;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    color: var(--pwa-text-strong);
    background: var(--pwa-soft);
    border-top: 1px solid var(--pwa-border);
}

.pwa-inv-bd-table tfoot th.is-amber {
    color: #b45309;
}

.pwa-inv-bd-table tfoot th.is-blue {
    color: var(--pwa-primary);
}

/* Longer identifiers wrap instead of widening the table */
.pwa-inv-bd-cell-no {
    max-width: 190px;
    overflow-wrap: anywhere;
}

.pwa-inv-bd-cell-client {
    max-width: 220px;
    overflow-wrap: anywhere;
}

/* Two-column financial rows once there is room */
@media (min-width: 380px) {
    .pwa-inv-bd-card-money > div {
        flex: 1 1 40%;
    }
}

/* Summary cards in a single row */
@media (min-width: 560px) {
    .pwa-inv-bd-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Comfortable centred modal and real tables */
@media (min-width: 768px) {
    body.pwa-standalone-active .pwa-inv-modal .modal-dialog {
        width: auto;
        max-width: 880px;
        margin: 24px auto;
    }

    body.pwa-standalone-active .pwa-inv-modal .modal-content {
        max-height: calc(100vh - 48px);
        max-height: calc(100dvh - 48px);
    }

    body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-body {
        padding: 16px 16px 18px;
    }

    body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-cards,
    body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-subtotal {
        display: none;
    }

    body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-table-wrap {
        display: block;
    }

    body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-table {
        min-width: 620px;
    }

    body.pwa-standalone-active .pwa-inv-modal .pwa-inv-bd-table.is-wide {
        min-width: 760px;
    }
}

/* Landscape phones and short windows keep the content usable */
@media (max-height: 560px) {
    body.pwa-standalone-active .pwa-inv-modal .modal-dialog {
        margin-top: 6px;
        margin-bottom: 6px;
    }

    .pwa-inv-bd-kpi-value {
        font-size: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.pwa-standalone-active .pwa-inv-modal .modal-header .btn-close {
        transition: none !important;
    }

    .pwa-inv-bd-toggle,
    .pwa-inv-bd-chevron {
        transition: none !important;
    }
}




/* ==========================================================================
   13. Quotation Management – Complete PWA UI/UX Architecture
   Rendered when is_pwa_standalone_mode() is active. Scoped strictly to
   body.pwa-standalone-active and .pwa-quot-* to guarantee zero side-effects
   on the standard desktop / web browser experience.
   ========================================================================== */

/* 13.1 Main Container & Layout */
body.pwa-standalone-active .pwa-quot-page {
    --pwa-quot-shadow: 0 2px 10px rgba(23, 32, 51, 0.05);
    --pwa-quot-border: #e2e8f0;
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 16px 28px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* 13.2 Hero Banner */
body.pwa-standalone-active .pwa-quot-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 16px;
    box-shadow: var(--pwa-quot-shadow);
}

body.pwa-standalone-active .pwa-quot-hero-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

body.pwa-standalone-active .pwa-quot-hero-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

body.pwa-standalone-active .pwa-quot-hero-icon svg {
    width: 22px;
    height: 22px;
}

body.pwa-standalone-active .pwa-quot-hero-text h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.2px;
    line-height: 1.2;
    color: var(--pwa-text-strong);
}

body.pwa-standalone-active .pwa-quot-hero-sub {
    font-size: 12px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

/* 13.3 Filters Bar */
body.pwa-standalone-active .pwa-quot-card.is-filters {
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 14px;
    box-shadow: var(--pwa-quot-shadow);
}

body.pwa-standalone-active .pwa-quot-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

body.pwa-standalone-active .pwa-quot-search {
    position: relative;
    flex: 1 1 200px;
    min-width: 0;
    display: flex;
    align-items: center;
}

body.pwa-standalone-active .pwa-quot-search svg {
    position: absolute;
    left: 12px;
    color: var(--pwa-text-muted);
    pointer-events: none;
}

body.pwa-standalone-active .pwa-quot-input {
    width: 100%;
    min-height: 42px;
    padding: 9px 34px 9px 36px;
    font-size: 13.5px;
    color: var(--pwa-text-strong);
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 10px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-input:focus {
    background: #ffffff;
    border-color: var(--pwa-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.12);
}

body.pwa-standalone-active .pwa-quot-search-clear {
    position: absolute;
    right: 8px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--pwa-text-muted);
    cursor: pointer;
}

body.pwa-standalone-active .pwa-quot-filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

body.pwa-standalone-active .pwa-quot-select {
    min-height: 42px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--pwa-text-strong);
    background-color: var(--pwa-soft);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 10px;
    outline: none;
}

body.pwa-standalone-active .pwa-quot-icon-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 10px;
    color: var(--pwa-text-muted);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-icon-btn:hover {
    color: var(--pwa-primary);
    background: var(--pwa-primary-light);
}

/* 13.4 Buttons System */
body.pwa-standalone-active .pwa-quot-btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-btn.is-primary {
    background: var(--pwa-primary);
    color: #ffffff !important;
}

body.pwa-standalone-active .pwa-quot-btn.is-primary:hover {
    background: var(--pwa-primary-hover);
}

body.pwa-standalone-active .pwa-quot-btn.is-secondary {
    background: var(--pwa-soft);
    color: var(--pwa-text-strong) !important;
    border-color: var(--pwa-quot-border);
}

body.pwa-standalone-active .pwa-quot-btn.is-secondary:hover {
    background: #e2e8f0;
}

body.pwa-standalone-active .pwa-quot-btn.is-outline {
    background: #ffffff;
    color: var(--pwa-primary) !important;
    border-color: var(--pwa-primary);
}

body.pwa-standalone-active .pwa-quot-btn.is-outline:hover {
    background: var(--pwa-primary-light);
}

body.pwa-standalone-active .pwa-quot-btn.is-sm {
    min-height: 34px;
    padding: 6px 11px;
    font-size: 12px;
    border-radius: 8px;
}

body.pwa-standalone-active .pwa-quot-sm-btn {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 7px;
    border: 1px solid var(--pwa-quot-border);
    background: #ffffff;
    color: var(--pwa-text-strong);
    cursor: pointer;
    transition: all 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-sm-btn:hover {
    background: var(--pwa-soft);
}

body.pwa-standalone-active .pwa-quot-sm-btn.is-primary {
    border-color: var(--pwa-primary);
    color: var(--pwa-primary);
}

body.pwa-standalone-active .pwa-quot-sm-btn.is-primary:hover {
    background: var(--pwa-primary-light);
}

/* 13.5 Pills & Badges */
body.pwa-standalone-active .pwa-quot-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

body.pwa-standalone-active .pwa-quot-pill.is-primary {
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

body.pwa-standalone-active .pwa-quot-pill.is-info {
    background: #e0f2fe;
    color: #0369a1;
}

body.pwa-standalone-active .pwa-quot-pill.is-subtle {
    background: var(--pwa-soft);
    color: var(--pwa-text-muted);
    border: 1px solid var(--pwa-quot-border);
    font-weight: 500;
}

body.pwa-standalone-active .pwa-quot-template-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--pwa-text-muted);
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 6px;
}

/* 13.6 Mobile Quotation Card Items (< 768px) */
body.pwa-standalone-active .pwa-quot-cards-wrapper {
    display: flex !important;
    flex-direction: column !important;
    gap: 0px !important;
}

body.pwa-standalone-active .pwa-quot-card-item {
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 5px !important;
    box-shadow: 0 1px 3px rgba(23, 32, 51, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-cards-wrapper > .pwa-quot-card-item:last-child {
    margin-bottom: 0 !important;
}

body.pwa-standalone-active .pwa-quot-card-item:hover,
body.pwa-standalone-active .pwa-quot-card-item.is-expanded {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(23, 32, 51, 0.06);
}

body.pwa-standalone-active .pwa-quot-card-head {
    padding: 13px 14px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.pwa-standalone-active .pwa-quot-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 7px;
}

body.pwa-standalone-active .pwa-quot-date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    color: var(--pwa-text-muted);
}

body.pwa-standalone-active .pwa-quot-card-title {
    margin: 0 0 6px 0;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--pwa-text-strong);
    line-height: 1.35;
    word-break: break-word;
}

body.pwa-standalone-active .pwa-quot-card-sub {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

body.pwa-standalone-active .pwa-quot-template {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--pwa-text-muted);
}

body.pwa-standalone-active .pwa-quot-chevron {
    color: var(--pwa-text-muted);
    transition: transform 0.2s ease;
}

body.pwa-standalone-active .pwa-quot-card-item.is-expanded .pwa-quot-chevron {
    transform: rotate(180deg);
}

/* Accordion expandable details */
body.pwa-standalone-active .pwa-quot-card-details {
    padding: 12px 14px 14px;
    background: #f8fafc;
    border-top: 1px solid #edf2f7;
}

body.pwa-standalone-active .pwa-quot-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

body.pwa-standalone-active .pwa-quot-detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

body.pwa-standalone-active .pwa-quot-detail-label {
    font-size: 10.5px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--pwa-text-muted);
}

body.pwa-standalone-active .pwa-quot-detail-val {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--pwa-text-strong);
}

body.pwa-standalone-active .pwa-quot-actions-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

body.pwa-standalone-active .pwa-quot-act-btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid var(--pwa-quot-border);
    background: #ffffff;
    color: var(--pwa-text-strong) !important;
    transition: all 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-act-btn:hover {
    background: #e2e8f0;
}

body.pwa-standalone-active .pwa-quot-act-btn.is-view {
    background: var(--pwa-primary-light);
    color: var(--pwa-primary) !important;
    border-color: transparent;
}

body.pwa-standalone-active .pwa-quot-act-btn.is-edit {
    background: #f1f5f9;
}

body.pwa-standalone-active .pwa-quot-act-btn.is-variation {
    background: #f0fdf4;
    color: #15803d !important;
    border-color: #bbf7d0;
}

body.pwa-standalone-active .pwa-quot-act-btn.is-print {
    background: #eff6ff;
    color: #1d4ed8 !important;
    border-color: #bfdbfe;
}

body.pwa-standalone-active .pwa-quot-act-btn.is-delete {
    padding: 7px 9px;
    color: #dc2626 !important;
    background: #fef2f2;
    border-color: #fecaca;
    margin-left: auto;
}

/* 13.7 Tablet & Desktop Responsive Table (>= 768px) */
body.pwa-standalone-active .pwa-quot-table-wrapper {
    background: #ffffff;
    border: 1px solid var(--pwa-quot-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--pwa-quot-shadow);
}

body.pwa-standalone-active .pwa-quot-table {
    margin-bottom: 0;
}

body.pwa-standalone-active .pwa-quot-table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--pwa-quot-border);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pwa-text-muted);
    padding: 12px 14px;
}

body.pwa-standalone-active .pwa-quot-table tbody td {
    padding: 12px 14px;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
}

body.pwa-standalone-active .pwa-quot-table tbody tr:hover td {
    background: #f8fafc;
}

body.pwa-standalone-active .pwa-quot-table-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* 13.8 Pagination */
body.pwa-standalone-active .pwa-quot-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 4px 0;
}

body.pwa-standalone-active .pwa-quot-pager-info {
    font-size: 12px;
    font-weight: 600;
    color: var(--pwa-text-muted);
}

/* 13.9 Empty & Loading States */
body.pwa-standalone-active .pwa-quot-empty {
    text-align: center;
    padding: 44px 20px;
    background: #ffffff;
    border: 1px solid var(--pwa-quot-border);
    border-radius: 14px;
}

body.pwa-standalone-active .pwa-quot-empty-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pwa-soft);
    color: var(--pwa-text-muted);
}

body.pwa-standalone-active .pwa-quot-empty-icon svg {
    width: 26px;
    height: 26px;
}

body.pwa-standalone-active .pwa-quot-empty-title {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--pwa-text-strong);
}

body.pwa-standalone-active .pwa-quot-empty-text {
    margin: 0;
    font-size: 13px;
    color: var(--pwa-text-muted);
}

body.pwa-standalone-active .pwa-quot-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 50px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--pwa-text-muted);
}

/* ==========================================================================
   13.10 PWA Full-Screen Quotation Modal Workflow
   Applied strictly when #ajaxModal has class .pwa-quot-modal inside PWA
   ========================================================================== */

/* Mobile Full-Screen Takeover (< 768px) */
@media (max-width: 767.98px) {
    body.pwa-standalone-active .pwa-quot-modal .modal-dialog {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    body.pwa-standalone-active .pwa-quot-modal .modal-content {
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
    }
}

/* Tablet & Desktop Dialog (>= 768px) */
@media (min-width: 768px) {
    body.pwa-standalone-active .pwa-quot-modal .modal-dialog {
        max-width: 960px !important;
        width: 94vw !important;
        margin: 20px auto !important;
    }

    body.pwa-standalone-active .pwa-quot-modal .modal-content {
        max-height: calc(100vh - 40px) !important;
        max-height: calc(100dvh - 40px) !important;
        border-radius: 18px !important;
        box-shadow: 0 25px 60px rgba(15, 23, 42, 0.28) !important;
    }
}

body.pwa-standalone-active .pwa-quot-modal .modal-content {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #ffffff !important;
}

/* Hide standard #ajaxModal default header and footer when quotation modal is active */
body.pwa-standalone-active .pwa-quot-modal .modal-header,
body.pwa-standalone-active .pwa-quot-modal > .modal-footer {
    display: none !important;
}

body.pwa-standalone-active .pwa-quot-modal #ajaxModalContent {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

body.pwa-standalone-active .pwa-quot-form-root {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Sticky Modal Header */
body.pwa-standalone-active .pwa-quot-modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--pwa-quot-border);
    z-index: 1010;
}

body.pwa-standalone-active .pwa-quot-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

body.pwa-standalone-active .pwa-quot-header-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

body.pwa-standalone-active .pwa-quot-modal-title {
    margin: 0;
    font-size: 15.5px;
    font-weight: 800;
    letter-spacing: -0.2px;
    color: var(--pwa-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.pwa-standalone-active .pwa-quot-header-sub {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    color: var(--pwa-text-muted);
}

body.pwa-standalone-active .pwa-quot-close-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 11px;
    color: var(--pwa-text-strong);
    cursor: pointer;
    transition: all 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-close-btn:hover {
    background: var(--pwa-primary-light);
    color: var(--pwa-primary);
}

/* 13.11 3-Step Wizard Navigation */
body.pwa-standalone-active .pwa-quot-wizard-nav {
    flex: 0 0 auto;
    background: #f8fafc;
    border-bottom: 1px solid var(--pwa-quot-border);
    padding: 8px 16px;
}

body.pwa-standalone-active .pwa-quot-wizard-track {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 600px;
    margin: 0 auto;
}

body.pwa-standalone-active .pwa-quot-step {
    display: flex;
    align-items: center;
    gap: 7px;
    background: none;
    border: none;
    padding: 5px 8px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-step.is-active,
body.pwa-standalone-active .pwa-quot-step.is-complete {
    opacity: 1;
}

body.pwa-standalone-active .pwa-quot-step-num {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--pwa-text-strong);
    transition: all 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-step.is-active .pwa-quot-step-num {
    background: var(--pwa-primary);
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.2);
}

body.pwa-standalone-active .pwa-quot-step.is-complete .pwa-quot-step-num {
    background: #059669;
    color: #ffffff;
}

body.pwa-standalone-active .pwa-quot-step-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--pwa-text-strong);
    display: none;
}

@media (min-width: 480px) {
    body.pwa-standalone-active .pwa-quot-step-label {
        display: inline;
    }
}

body.pwa-standalone-active .pwa-quot-step-line {
    flex: 1 1 20px;
    height: 2px;
    margin: 0 6px;
    background: #e2e8f0;
    transition: background 0.15s ease;
}

body.pwa-standalone-active .pwa-quot-step-line.is-complete {
    background: var(--pwa-primary);
}

/* 13.12 Scrollable Body */
body.pwa-standalone-active .pwa-quot-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

body.pwa-standalone-active .pwa-quot-form-card {
    background: var(--pwa-surface);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 12px;
    padding: 14px;
}

body.pwa-standalone-active .pwa-quot-label {
    display: block;
    margin-bottom: 5px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--pwa-text-strong);
}

body.pwa-standalone-active .pwa-quot-textarea {
    width: 100%;
    font-size: 13.5px;
    line-height: 1.5;
    padding: 10px 12px;
    color: var(--pwa-text-strong);
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 10px;
    resize: vertical;
}

body.pwa-standalone-active .pwa-quot-textarea:focus {
    background: #ffffff;
    border-color: var(--pwa-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.12);
}

body.pwa-standalone-active .pwa-quot-subtext {
    font-size: 11.5px;
    color: var(--pwa-text-muted);
    line-height: 1.4;
}

/* 13.13 Sticky Bottom Action Bar */
body.pwa-standalone-active .pwa-quot-modal-footer {
    flex: 0 0 auto;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    background: #ffffff;
    border-top: 1px solid var(--pwa-quot-border);
    z-index: 1010;
}

body.pwa-standalone-active .pwa-quot-footer-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

body.pwa-standalone-active .pwa-quot-footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Mobile full responsiveness: 2-tier stacked footer prevents button clipping */
@media (max-width: 520px) {
    body.pwa-standalone-active .pwa-quot-modal-footer {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    }

    body.pwa-standalone-active .pwa-quot-footer-group {
        display: flex;
        flex-direction: column-reverse;
        gap: 8px;
        width: 100%;
    }

    body.pwa-standalone-active .pwa-quot-footer-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    body.pwa-standalone-active .pwa-quot-cancel-btn {
        width: 100%;
        min-height: 40px;
        font-size: 13px;
        justify-content: center;
    }

    body.pwa-standalone-active .pwa-quot-footer-actions .pwa-quot-btn {
        width: 100%;
        min-height: 44px;
        padding: 8px 6px;
        font-size: 12.5px;
        white-space: nowrap;
        justify-content: center;
        text-align: center;
    }

    body.pwa-standalone-active .pwa-quot-footer-actions .pwa-quot-btn svg {
        flex-shrink: 0;
    }
}

@media (max-width: 350px) {
    body.pwa-standalone-active .pwa-quot-footer-actions .pwa-quot-btn {
        font-size: 11.5px;
        padding: 7px 4px;
        gap: 4px;
    }
}

/* 13.14 Step 2 Summernote Fixes */
body.pwa-standalone-active .pwa-quot-editor-toolbar-card {
    background: #f8fafc;
    border: 1px solid var(--pwa-quot-border);
    border-radius: 10px;
    padding: 8px 12px;
}

body.pwa-standalone-active .pwa-quot-editor-hint {
    font-size: 12px;
    color: var(--pwa-text-strong);
}

body.pwa-standalone-active .pwa-quot-editor-wrapper {
    background: #ffffff;
    border: 1px solid var(--pwa-quot-border);
    border-radius: 12px;
    overflow: hidden;
}

body.pwa-standalone-active .note-editor.note-frame {
    border: none !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
}

body.pwa-standalone-active .note-toolbar {
    background: #f8fafc !important;
    border-bottom: 1px solid var(--pwa-quot-border) !important;
    padding: 6px 8px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
}

body.pwa-standalone-active .note-toolbar .note-btn {
    min-height: 34px !important;
    padding: 5px 9px !important;
    border-radius: 7px !important;
}

body.pwa-standalone-active .note-editable {
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    color: #2d3748 !important;
    padding: 14px 16px !important;
    max-width: 100% !important;
    overflow-x: auto !important;
}

/* 13.15 Step 3 & Final Preview Letterhead Viewport */
body.pwa-standalone-active .pwa-quot-preview-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid var(--pwa-quot-border);
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

body.pwa-standalone-active .pwa-quot-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #ffffff;
    padding: 3px 5px;
    border-radius: 8px;
    border: 1px solid var(--pwa-quot-border);
}

body.pwa-standalone-active .pwa-zoom-btn {
    min-width: 28px;
    height: 28px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 700;
    border: none;
    background: none;
    color: var(--pwa-text-strong);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

body.pwa-standalone-active .pwa-zoom-btn:hover {
    background: var(--pwa-soft);
}

body.pwa-standalone-active .pwa-zoom-btn.is-active {
    background: var(--pwa-primary);
    color: #ffffff;
}

body.pwa-standalone-active .pwa-sheets-viewport {
    background: #2e3440;
    border-radius: 12px;
    padding: 16px 8px;
    min-height: 480px;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-overflow-scrolling: touch;
}

body.pwa-standalone-active .pwa-sheets-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

body.pwa-standalone-active .pwa-sheet-scaler-wrap {
    display: block !important;
    position: relative !important;
    margin: 0 auto 20px auto !important;
    box-sizing: border-box !important;
    overflow: visible;
}

body.pwa-standalone-active .pwa-a4-sheet {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    box-sizing: border-box;
    overflow: hidden;
}

body.pwa-standalone-active .pwa-a4-content {
    width: 100%;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: #2d3748;
    overflow: hidden;
}

body.pwa-standalone-active .pwa-a4-page-num {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    color: #718096;
    font-family: Arial, sans-serif;
}

/* 13.16 AI Generation Overlay */
body.pwa-standalone-active .pwa-ai-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
}

@keyframes pwaPulseOuter {
    0% { transform: scale(0.85); opacity: 0.8; }
    50% { transform: scale(1.35); opacity: 0.2; }
    100% { transform: scale(0.85); opacity: 0.8; }
}

@keyframes pwaPulseInner {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 0.3; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

body.pwa-standalone-active .pwa-ai-orb-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

body.pwa-standalone-active .pwa-ai-pulse-outer {
    position: absolute;
    width: 95px;
    height: 95px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(51, 102, 153, 0.25) 0%, rgba(36, 73, 111, 0.05) 70%, transparent 100%);
    border: 2px solid rgba(51, 102, 153, 0.35);
    animation: pwaPulseOuter 2.8s infinite ease-in-out;
}

body.pwa-standalone-active .pwa-ai-pulse-inner {
    position: absolute;
    width: 75px;
    height: 75px;
    border-radius: 50%;
    border: 2px dashed rgba(51, 102, 153, 0.5);
    animation: pwaPulseInner 2.2s infinite ease-in-out 0.3s;
}

body.pwa-standalone-active .pwa-ai-orb-core {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #336699 0%, #24496f 60%, #0284c7 100%);
    box-shadow: 0 8px 25px rgba(51, 102, 153, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

body.pwa-standalone-active .pwa-ai-title {
    margin: 0 0 6px 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--pwa-text-strong);
}

body.pwa-standalone-active .pwa-ai-model-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    margin-bottom: 12px;
    background: var(--pwa-soft);
    border: 1px solid var(--pwa-quot-border);
    border-radius: 20px;
    font-size: 11.5px;
    color: var(--pwa-primary);
}

body.pwa-standalone-active .pwa-ai-ticker-box {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    margin-bottom: 12px;
    background: #ffffff;
    border: 1px solid var(--pwa-quot-border);
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    font-size: 12px;
    font-weight: 600;
    color: var(--pwa-primary);
    max-width: 90%;
}

body.pwa-standalone-active .pwa-ai-progress-track {
    width: 100%;
    max-width: 320px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}

body.pwa-standalone-active .pwa-ai-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #336699, #0284c7);
    transition: width 0.8s ease;
}

body.pwa-standalone-active .pwa-ai-timer-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

body.pwa-standalone-active .pwa-ai-timer-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #ffffff;
    border: 1px solid var(--pwa-quot-border);
    border-radius: 16px;
    font-size: 12px;
    color: var(--pwa-text-strong);
}

body.pwa-standalone-active .pwa-ai-timer-note {
    font-size: 11px;
    color: var(--pwa-text-muted);
}

/* 13.17 Preview Dialog Wrapper - Dedicated Single-Scroll Full-Height Layout */
body.pwa-standalone-active .pwa-quot-preview-dialog {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

body.pwa-standalone-active .pwa-quot-preview-dialog .pwa-quot-modal-body {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important; /* CRITICAL: Disables outer modal body scrollbar */
    padding: 0 !important;
}

body.pwa-standalone-active .pwa-quot-preview-dialog .pwa-sheets-viewport {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important; /* Let it fill the body naturally */
    overflow-y: auto !important; /* THE ONLY VERTICAL SCROLLBAR */
    overflow-x: auto !important;
    border-radius: 0 !important;
    padding: 16px 8px 30px 8px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
}

body.pwa-standalone-active .pwa-quot-preview-dialog .pwa-sheets-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    margin: 0 auto !important;
}

/* ==========================================================================
   14. PWA Invoice Modal – Step 2: Line Items & Deliverables Responsive Cards
   Applied exclusively when body has .pwa-standalone-active
   ========================================================================== */

/* 14.1 Full-Screen Mobile Dialog (< 768px) */
@media (max-width: 767.98px) {
    body.pwa-standalone-active #ajaxModal:has(#invoice-form) .modal-dialog,
    body.pwa-standalone-active .pwa-invoice-editor-modal .modal-dialog {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.pwa-standalone-active #ajaxModal:has(#invoice-form) .modal-content,
    body.pwa-standalone-active .pwa-invoice-editor-modal .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        background: #ffffff !important;
    }

    body.pwa-standalone-active #ajaxModal:has(#invoice-form) #ajaxModalContent,
    body.pwa-standalone-active .pwa-invoice-editor-modal #ajaxModalContent {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    body.pwa-standalone-active #invoice-form {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* Fixed Modal Header */
    body.pwa-standalone-active #invoice-form .custom-modal-top-header {
        flex: 0 0 auto !important;
        padding: 12px 14px !important;
        background: #ffffff !important;
        border-bottom: 1px solid #e2e8f0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        z-index: 20 !important;
    }

    body.pwa-standalone-active #invoice-form .custom-modal-top-header h4 {
        font-size: 16px !important;
        font-weight: 800 !important;
        color: #0f172a !important;
        margin: 0 !important;
        letter-spacing: -0.2px !important;
    }

    body.pwa-standalone-active #invoice-form .custom-modal-top-header p {
        display: none !important;
    }

    body.pwa-standalone-active #invoice-form .custom-modal-close-btn {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        border-radius: 9px !important;
        background: #f1f5f9 !important;
        color: #475569 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        cursor: pointer !important;
        transition: background-color 0.15s ease !important;
    }

    body.pwa-standalone-active #invoice-form .custom-modal-close-btn:hover {
        background: #e2e8f0 !important;
        color: #0f172a !important;
    }

    /* Independent Scrollable Body Area */
    body.pwa-standalone-active #invoice-form .invoice-modal-content-area {
        flex: 1 1 auto !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        padding: 12px 12px 36px 12px !important;
        background: #f8fafc !important;
    }

    /* Compact Horizontally-Scrollable Stepper */
    body.pwa-standalone-active #invoice-form .invoice-wizard-stepper {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 8px !important;
        margin-bottom: 12px !important;
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 12px !important;
        scrollbar-width: none !important;
    }

    body.pwa-standalone-active #invoice-form .invoice-wizard-stepper::-webkit-scrollbar {
        display: none !important;
    }

    body.pwa-standalone-active #invoice-form .wizard-step-node {
        padding: 6px 10px !important;
        border-radius: 8px !important;
        gap: 6px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    body.pwa-standalone-active #invoice-form .wizard-step-node .step-desc {
        display: none !important;
    }

    body.pwa-standalone-active #invoice-form .wizard-step-node .step-title {
        font-size: 11.5px !important;
        font-weight: 700 !important;
    }

    body.pwa-standalone-active #invoice-form .wizard-step-node .step-icon-circle {
        width: 22px !important;
        height: 22px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
    }

    body.pwa-standalone-active #invoice-form .invoice-main-card {
        padding: 12px !important;
        border-radius: 14px !important;
        border: 1px solid #e2e8f0 !important;
        background: #ffffff !important;
    }

    /* Sticky Bottom Action Footer */
    body.pwa-standalone-active #invoice-form .invoice-modal-footer {
        flex: 0 0 auto !important;
        display: flex !important;
        justify-content: stretch !important;
        align-items: center !important;
        padding: 10px 14px !important;
        padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)) !important;
        background: #ffffff !important;
        border-top: 1px solid #e2e8f0 !important;
        z-index: 20 !important;
        box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.05) !important;
    }

    body.pwa-standalone-active #invoice-form .invoice-modal-footer .invoice-footer-close-wrap,
    body.pwa-standalone-active #invoice-form .invoice-modal-footer > div:has(.btn-footer-close),
    body.pwa-standalone-active #invoice-form .btn-footer-close {
        display: none !important;
    }

    body.pwa-standalone-active #invoice-form .invoice-modal-footer .invoice-footer-actions,
    body.pwa-standalone-active #invoice-form .invoice-modal-footer .d-flex.gap-2 {
        display: flex !important;
        width: 100% !important;
        gap: 10px !important;
    }

    body.pwa-standalone-active #invoice-form .btn-footer-back,
    body.pwa-standalone-active #invoice-form .btn-footer-next,
    body.pwa-standalone-active #invoice-form .btn-footer-submit {
        min-height: 42px !important;
        font-size: 12.5px !important;
        font-weight: 700 !important;
        border-radius: 9px !important;
        padding: 8px 14px !important;
    }

    body.pwa-standalone-active #invoice-form #btn-wizard-prev {
        flex: 0 0 auto !important;
        min-width: 90px !important;
        justify-content: center !important;
    }

    body.pwa-standalone-active #invoice-form #btn-wizard-next,
    body.pwa-standalone-active #invoice-form #btn-wizard-submit {
        flex: 1 1 auto !important;
        justify-content: center !important;
    }
}

/* 14.2 Tablet Dialog Layout (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    body.pwa-standalone-active #ajaxModal:has(#invoice-form) .modal-dialog,
    body.pwa-standalone-active .pwa-invoice-editor-modal .modal-dialog {
        width: 94vw !important;
        max-width: 960px !important;
        margin: 20px auto !important;
    }

    body.pwa-standalone-active #ajaxModal:has(#invoice-form) .modal-content,
    body.pwa-standalone-active .pwa-invoice-editor-modal .modal-content {
        max-height: calc(100vh - 40px) !important;
        max-height: calc(100dvh - 40px) !important;
        border-radius: 18px !important;
        box-shadow: 0 25px 60px rgba(15, 23, 42, 0.28) !important;
    }

    body.pwa-standalone-active #invoice-form .invoice-modal-content-area {
        max-height: calc(100vh - 190px) !important;
        max-height: calc(100dvh - 190px) !important;
        overflow-y: auto !important;
    }
}

/* 14.3 Mobile Line Items Responsive Cards (< 600px) */
@media (max-width: 600px) {
    /* Section Header & Add Line Item Button */
    body.pwa-standalone-active #step-content-items .section-card-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        margin-bottom: 16px !important;
    }

    body.pwa-standalone-active #step-content-items .section-header-left {
        display: flex !important;
        align-items: flex-start !important;
        gap: 10px !important;
        width: 100% !important;
    }

    body.pwa-standalone-active #step-content-items .section-header-icon {
        width: 36px !important;
        height: 36px !important;
        border-radius: 8px !important;
        flex-shrink: 0 !important;
    }

    body.pwa-standalone-active #step-content-items .section-header-title {
        font-size: 15.5px !important;
        font-weight: 800 !important;
        color: #0f172a !important;
        margin: 0 0 2px 0 !important;
    }

    body.pwa-standalone-active #step-content-items .section-header-subtitle {
        font-size: 11.5px !important;
        color: #64748b !important;
        line-height: 1.35 !important;
        margin: 0 !important;
    }

    body.pwa-standalone-active #step-content-items #btn-add-item {
        width: 100% !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        font-size: 13.5px !important;
        font-weight: 700 !important;
        border-radius: 10px !important;
        background-color: var(--pwa-primary, #336699) !important;
        color: #ffffff !important;
        border: none !important;
        box-shadow: 0 2px 6px rgba(51, 102, 153, 0.25) !important;
        margin-top: 2px !important;
    }

    /* Convert Table into Cards */
    body.pwa-standalone-active #invoice-form colgroup,
    body.pwa-standalone-active #invoice-form colgroup col,
    body.pwa-standalone-active #invoice-form thead {
        display: none !important;
    }

    body.pwa-standalone-active #invoice-form .table-responsive {
        overflow-x: visible !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
    }

    /* Card Item Row */
    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px 12px !important;
        background: #ffffff !important;
        border: 1.5px solid #e2e8f0 !important;
        border-radius: 14px !important;
        padding: 13px 12px !important;
        box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04) !important;
        position: relative !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td {
        padding: 0 !important;
        border: none !important;
        vertical-align: top !important;
    }

    /* Row 1: Item # (Left) and Delete (Right) */
    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(1) {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        background: #eff6ff !important;
        color: #1d4ed8 !important;
        border: 1px solid #dbeafe !important;
        padding: 4px 10px !important;
        border-radius: 8px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        width: fit-content !important;
        height: 30px !important;
        text-align: left !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(1)::before {
        content: "Item #";
        font-weight: 700;
        color: #1d4ed8;
        margin-right: 2px;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(6) {
        grid-column: 2 / 3 !important;
        grid-row: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
    }

    body.pwa-standalone-active #invoice-form .btn-remove-item {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px !important;
        min-height: 30px !important;
        padding: 4px 10px !important;
        background: #fef2f2 !important;
        border: 1px solid #fee2e2 !important;
        border-radius: 8px !important;
        color: #dc2626 !important;
        font-size: 11.5px !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        transition: all 0.15s ease !important;
        transform: none !important;
        opacity: 1 !important;
    }

    body.pwa-standalone-active #invoice-form .btn-remove-item:hover {
        background: #fee2e2 !important;
        border-color: #fca5a5 !important;
        color: #b91c1c !important;
        transform: none !important;
    }

    body.pwa-standalone-active #invoice-form .btn-remove-item::after {
        content: "Delete";
        font-size: 11.5px;
        font-weight: 700;
    }

    /* Row 2: Full-width Description */
    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(2) {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        width: 100% !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(2)::before {
        content: "Description *";
        font-size: 12px;
        font-weight: 700;
        color: #334155;
        display: block;
    }

    body.pwa-standalone-active #invoice-form textarea.item-description {
        width: 100% !important;
        min-height: 84px !important;
        font-size: 13px !important;
        line-height: 1.45 !important;
        padding: 9px 11px 32px 11px !important;
        border: 1.5px solid #cbd5e1 !important;
        border-radius: 8px !important;
        background-color: #ffffff !important;
        color: #0f172a !important;
        box-sizing: border-box !important;
    }

    body.pwa-standalone-active #invoice-form .desc-ai-wrapper {
        position: relative !important;
        width: 100% !important;
    }

    body.pwa-standalone-active #invoice-form .btn-polish-desc {
        position: absolute !important;
        bottom: 7px !important;
        right: 8px !important;
        z-index: 2 !important;
        padding: 3px 8px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        border-radius: 6px !important;
    }

    /* Row 3: SAC / HSN Code (Full-width) */
    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(3) {
        grid-column: 1 / -1 !important;
        grid-row: 3 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        width: 100% !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(3)::before {
        content: "SAC / HSN Code";
        font-size: 12px;
        font-weight: 700;
        color: #334155;
        display: block;
    }

    body.pwa-standalone-active #invoice-form select.item-sac-hsn {
        width: 100% !important;
        height: 42px !important;
        font-size: 13px !important;
        border: 1.5px solid #cbd5e1 !important;
        border-radius: 8px !important;
        background-color: #ffffff !important;
        box-sizing: border-box !important;
    }

    /* Row 4: Currency (Left) & Amount (Right) */
    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(4) {
        grid-column: 1 / 2 !important;
        grid-row: 4 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(4)::before {
        content: "Currency";
        font-size: 12px;
        font-weight: 700;
        color: #334155;
        display: block;
    }

    body.pwa-standalone-active #invoice-form select.item-currency {
        width: 100% !important;
        height: 42px !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        border: 1.5px solid #cbd5e1 !important;
        border-radius: 8px !important;
        background-color: #ffffff !important;
        box-sizing: border-box !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(5) {
        grid-column: 2 / 3 !important;
        grid-row: 4 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table tr.item-row > td:nth-child(5)::before {
        content: "Amount *";
        font-size: 12px;
        font-weight: 700;
        color: #334155;
        display: block;
    }

    body.pwa-standalone-active #invoice-form input.item-amount {
        width: 100% !important;
        height: 42px !important;
        font-size: 14px !important;
        font-weight: 700 !important;
        color: #0f172a !important;
        border: 1.5px solid #cbd5e1 !important;
        border-radius: 8px !important;
        background-color: #ffffff !important;
        box-sizing: border-box !important;
    }

    /* Full-width Totals & Summary Card on Mobile */
    body.pwa-standalone-active #invoice-form .d-flex.justify-content-end:has(.summary-card-box),
    body.pwa-standalone-active #invoice-form #step-content-items .d-flex.justify-content-end {
        display: block !important;
        width: 100% !important;
    }

    body.pwa-standalone-active #invoice-form .summary-card-box {
        width: 100% !important;
        max-width: 100% !important;
        background: #f8fafc !important;
        border: 1.5px solid #e2e8f0 !important;
        border-radius: 14px !important;
        padding: 16px !important;
        margin-top: 16px !important;
        box-sizing: border-box !important;
    }

    body.pwa-standalone-active #invoice-form .summary-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 6px 0 !important;
        font-size: 13.5px !important;
    }

    body.pwa-standalone-active #invoice-form .summary-label-muted {
        font-size: 13px !important;
        font-weight: 600 !important;
        color: #475569 !important;
    }

    body.pwa-standalone-active #invoice-form .summary-val-muted {
        font-size: 14px !important;
        font-weight: 700 !important;
        color: #0f172a !important;
    }

    body.pwa-standalone-active #invoice-form .summary-label-gst {
        font-size: 13px !important;
        font-weight: 600 !important;
        color: var(--pwa-primary, #336699) !important;
    }

    body.pwa-standalone-active #invoice-form .summary-val-gst {
        font-size: 13.5px !important;
        font-weight: 700 !important;
        color: var(--pwa-primary, #336699) !important;
    }

    body.pwa-standalone-active #invoice-form .summary-payable-title {
        font-size: 14px !important;
        font-weight: 800 !important;
        color: #0f172a !important;
    }

    body.pwa-standalone-active #invoice-form .summary-payable-subtitle {
        font-size: 11px !important;
        color: #64748b !important;
    }

    body.pwa-standalone-active #invoice-form .summary-payable-amount {
        font-size: 20px !important;
        font-weight: 800 !important;
        color: #059669 !important;
    }
}

/* 14.4 Tablet Table Layout (601px - 1024px) */
@media (min-width: 601px) and (max-width: 1024px) {
    body.pwa-standalone-active #invoice-form .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    body.pwa-standalone-active #invoice-form .line-items-table {
        min-width: 640px !important;
        table-layout: fixed !important;
    }

    body.pwa-standalone-active #invoice-form textarea.item-description {
        min-height: 72px !important;
        font-size: 13px !important;
    }

    body.pwa-standalone-active #invoice-form select.form-select,
    body.pwa-standalone-active #invoice-form input.item-amount {
        height: 40px !important;
        font-size: 13px !important;
    }

    body.pwa-standalone-active #invoice-form .summary-card-box {
        width: 320px !important;
    }
}

/* ==========================================================================
   15. PWA Invoice Preview – Responsive Quick Preview Modal & Scaling Engine
   Applied exclusively in PWA standalone mode (body.pwa-standalone-active)
   ========================================================================== */

/* 15.1 Mobile Full-Screen Takeover (< 768px) */
@media (max-width: 767.98px) {
    body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active .modal-dialog,
    body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) .modal-dialog {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active .modal-content,
    body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        background: #2e3440 !important;
    }

    body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active #ajaxModalContent,
    body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) #ajaxModalContent {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }
}

/* 15.2 Tablet & Desktop Modal (>= 768px) */
@media (min-width: 768px) {
    body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active .modal-dialog,
    body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) .modal-dialog {
        max-width: 960px !important;
        width: 94vw !important;
        margin: 20px auto !important;
    }

    body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active .modal-content,
    body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) .modal-content {
        max-height: calc(100vh - 40px) !important;
        max-height: calc(100dvh - 40px) !important;
        border-radius: 16px !important;
        box-shadow: 0 25px 60px rgba(15, 23, 42, 0.35) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        background: #2e3440 !important;
    }

    body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active #ajaxModalContent,
    body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) #ajaxModalContent {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }
}

/* 15.3 Suppress default modal chrome when custom preview dialog is active */
body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active .modal-header,
body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) .modal-header,
body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active > .modal-footer,
body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) > .modal-footer {
    display: none !important;
}

/* 15.4 Dialog structure */
.pwa-inv-preview-dialog {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: #2e3440;
}

/* Header */
.pwa-inv-modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    z-index: 1010;
}

.pwa-inv-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.pwa-inv-header-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #eff6ff;
    color: #0b63ce;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pwa-inv-header-titles {
    min-width: 0;
}

.pwa-inv-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.2px;
    color: #0f172a;
    line-height: 1.2;
}

.pwa-inv-header-sub {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-inv-pill.is-primary {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 700;
    font-size: 10.5px;
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.3px;
}

.pwa-inv-client-tag {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.pwa-inv-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.pwa-inv-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* 15.5 Topbar & Zoom controls */
.pwa-inv-preview-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    gap: 8px;
    z-index: 1005;
}

@media (max-width: 480px) {
    .pwa-inv-preview-topbar {
        padding: 6px 10px;
        gap: 6px;
    }
    .pwa-inv-topbar-actions {
        flex: 1 1 auto;
        display: flex;
        gap: 4px;
    }
    .pwa-inv-topbar-actions .pwa-inv-btn {
        flex: 1 1 0%;
        justify-content: center;
        padding: 0 6px;
        font-size: 11px;
    }
}

.pwa-inv-topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pwa-inv-zoom-controls {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.pwa-zoom-btn {
    height: 28px;
    min-width: 30px;
    padding: 0 8px;
    border: none;
    background: transparent;
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.pwa-zoom-btn:hover,
.pwa-zoom-btn.is-active {
    background: #ffffff;
    color: #0b63ce;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 15.6 Viewport & Document Container (Single Vertical Scrollbar) */
.pwa-inv-modal-body {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important; /* CRITICAL: Disables outer modal body scrollbar */
    padding: 0 !important;
    background: #2e3440 !important;
}

.pwa-inv-sheets-viewport {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important; /* THE ONLY VERTICAL SCROLLBAR */
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 16px 8px 30px 8px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    background: #2e3440 !important;
}

.pwa-inv-sheets-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    margin: 0 auto !important;
}

.pwa-inv-scaler-wrap {
    position: relative;
    box-sizing: border-box;
    transition: width 0.15s ease, height 0.15s ease;
}

.pwa-inv-sheet-stage {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    border-radius: 4px;
    background: #ffffff;
    overflow: visible;
}

/* 15.7 Sticky Bottom Action Bar */
.pwa-inv-modal-footer {
    flex: 0 0 auto;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    z-index: 1010;
}

.pwa-inv-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.pwa-inv-footer-actions .pwa-inv-btn {
    flex: 1 1 50%;
    justify-content: center;
}

/* Universal PWA Invoice Buttons */
.pwa-inv-btn {
    height: 42px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.pwa-inv-btn.is-sm {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 7px;
    gap: 5px;
}

.pwa-inv-btn.is-primary {
    background: linear-gradient(135deg, #0b63ce 0%, #1d4ed8 100%);
    color: #ffffff !important;
    border: 1px solid #2563eb;
    box-shadow: 0 2px 8px rgba(11, 99, 206, 0.35);
}
.pwa-inv-btn.is-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 4px 12px rgba(11, 99, 206, 0.45);
    transform: translateY(-1px);
}

.pwa-inv-btn.is-outline {
    background: #ffffff;
    color: #334155 !important;
    border: 1px solid #cbd5e1;
}
.pwa-inv-btn.is-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a !important;
}

/* Print Overrides – Preserve 100% Unscaled A4 */
@media print {
    body.pwa-standalone-active #ajaxModal.pwa-inv-preview-modal-active .modal-dialog,
    body.pwa-standalone-active #ajaxModal:has(.pwa-inv-preview-dialog) .modal-dialog {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .pwa-inv-modal-header,
    .pwa-inv-preview-topbar,
    .pwa-inv-modal-footer {
        display: none !important;
    }
    .pwa-inv-sheets-viewport {
        padding: 0 !important;
        background: #ffffff !important;
        overflow: visible !important;
    }
    .pwa-inv-scaler-wrap {
        width: 100% !important;
        height: auto !important;
        position: static !important;
        margin: 0 !important;
    }
    .pwa-inv-sheet-stage {
        width: 100% !important;
        position: static !important;
        transform: none !important;
        box-shadow: none !important;
    }
}
