/* ============================================================
   RRV3 Sales Module - Stylesheet
   Loaded AFTER rrv3-styles-core.css (for CSS custom properties).
   ============================================================ */

/* Sales dashboard tables */
.rrv3-bulk-table-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Quotation create/edit */
#rrv3-quotation-form .rrv3-section {
    border: 1px solid var(--rr-border);
    border-radius: var(--rr-radius-lg);
    box-shadow: var(--rr-shadow-sm);
}
#quotation-items-table {
    table-layout: auto;
}
#quotation-items-table .quote-desc-cell {
    width: 52%;
    min-width: 360px;
}
#quotation-items-table .quote-description-input {
    width: 100%;
    min-height: 42px;
    resize: vertical;
    overflow: hidden;
    line-height: 1.45;
    white-space: pre-wrap;
}
#quotation-items-table .qty-input,
#quotation-items-table .price-input,
#quotation-items-table .item-amount,
#quote-grand-total {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
#quotation-items-table .quote-unit-select {
    min-width: 92px;
}
.rrv3-quote-bottom-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 0 4px;
    border-top: 1px solid var(--rr-border);
}
.rrv3-quote-bottom-actions .quote-action-tab-title,
.rrv3-quote-bottom-actions .quote-action-tab-hint {
    display: none;
}

/* Job Costing / Client picker cards used in quotation form */
.quote-selected-job-card,
.quote-selected-client-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--rr-border);
    border-radius: 16px;
    background: #fff7ed;
    box-shadow: var(--rr-shadow-sm);
    margin-bottom: 14px;
}
.quote-selected-job-card.has-selection,
.quote-selected-client-card.has-selection {
    background: #eff6ff;
    border-color: #93c5fd;
}
.quote-selected-job-card strong,
.quote-selected-job-card span,
.quote-selected-client-card strong,
.quote-selected-client-card span {
    display: block;
}
.quote-selected-job-card strong,
.quote-selected-client-card strong {
    color: var(--rr-blue-dark);
    margin-bottom: 3px;
}
.quote-selected-job-card span,
.quote-selected-client-card span {
    color: var(--rr-text-muted);
    font-size: 12.5px;
}
.quote-job-picker-content,
.quote-client-picker-content {
    max-width: 980px !important;
}
.quote-job-picker-list,
.quote-client-picker-list {
    display: grid;
    gap: 10px;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 4px;
}
.quote-job-picker-card,
.quote-client-picker-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--rr-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--rr-shadow-sm);
}
.quote-job-picker-card strong,
.quote-job-picker-card span,
.quote-job-picker-card small,
.quote-client-picker-card strong,
.quote-client-picker-card span,
.quote-client-picker-card small {
    display: block;
}
.quote-job-picker-card strong,
.quote-client-picker-card strong {
    color: var(--rr-blue-dark);
    margin-bottom: 3px;
}
.quote-job-picker-card span,
.quote-job-picker-card small,
.quote-client-picker-card span,
.quote-client-picker-card small {
    color: var(--rr-text-muted);
}

/* Quotation view / print document */
.rrv3-quote-print-view {
    padding-bottom: 92px;
}
.rrv3-quote-print-view .rrv3-actions-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}
.rrv3-quote-print-view .rrv3-quote-sticky-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    margin: 0;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #dbe3ef;
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(10px);
}
.rrv3-quote-print-view .rrv3-quote-sticky-actions .rrv3-field-hint {
    margin-right: auto;
}
.rrv3-quote-document {
    max-width: 980px;
    margin: 0 auto;
    padding: 34px 38px;
    background: #fff;
    color: #1f2937;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 40, 85, 0.14);
    font-family: Arial, Helvetica, sans-serif;
}
.rrv3-quote-document .quote-header {
    display: flex;
    align-items: center;
    gap: 18px;
    padding-bottom: 18px;
    border-bottom: 3px solid #1a365d;
    margin-bottom: 24px;
}
.rrv3-quote-document .company-logo-wrapper {
    flex: 0 0 120px;
    text-align: center;
}
.rrv3-quote-document .company-logo {
    max-width: 110px;
    max-height: 78px;
    object-fit: contain;
}
.rrv3-quote-document .company-info {
    flex: 1;
}
.rrv3-quote-document .company-info h2 {
    margin: 0 0 7px;
    color: #1a365d;
    font-size: 20px;
    line-height: 1.25;
    letter-spacing: -0.02em;
}
.rrv3-quote-document .company-info p {
    margin: 3px 0;
    color: #4b5563;
    font-size: 12.5px;
    line-height: 1.45;
}
.rrv3-quote-document .quote-details-row {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.rrv3-quote-document .client-info,
.rrv3-quote-document .quote-meta,
.rrv3-quote-document .quote-notes,
.rrv3-quote-document .quote-terms,
.rrv3-quote-document .quote-signoff > div {
    padding: 15px 16px;
    border: 1px solid #e5edf7;
    border-radius: 10px;
    background: #f8fafc;
}
.rrv3-quote-document h3 {
    margin: 0 0 10px;
    color: #1a365d;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.rrv3-quote-document p {
    margin: 5px 0;
    font-size: 12.8px;
    line-height: 1.5;
}
.quote-title-above-items {
    margin: 18px 0 10px;
    padding: 12px 14px;
    border-left: 5px solid var(--rr-blue, #2563eb);
    border-radius: 10px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 16px;
    font-weight: 900;
}
.quote-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 24px;
    border: 1px solid #dbe3ef;
    font-size: 12.5px;
}
.quote-items-table th {
    background: #1a365d;
    color: #fff;
    text-align: left;
    padding: 10px 11px;
    border: 1px solid #1a365d;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.quote-items-table td {
    padding: 10px 11px;
    border: 1px solid #e5edf7;
    vertical-align: top;
    line-height: 1.45;
}
.quote-items-table tbody tr:nth-child(even) td {
    background: #f8fafc;
}
.quote-items-table td:nth-child(1),
.quote-items-table td:nth-child(3),
.quote-items-table td:nth-child(4),
.quote-items-table td:nth-child(5),
.quote-items-table td:nth-child(6) {
    white-space: nowrap;
}
.quote-items-table td:nth-child(3),
.quote-items-table td:nth-child(5),
.quote-items-table td:nth-child(6),
.quote-items-table tfoot td {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.quote-items-table tfoot td {
    background: #eef6ff;
    color: #1a365d;
    font-size: 13px;
}
.quote-notes,
.quote-terms {
    margin-bottom: 18px;
}
.quote-signoff {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    margin-top: 28px;
}
.customer-signoff .sign-fields {
    margin-top: 14px;
}
.customer-signoff .sign-fields p {
    margin: 11px 0;
}

/* Quotation Settings tab */
.rrv3-quotation-settings-panel .rrv3-section {
    border-radius: 16px;
    box-shadow: var(--rr-shadow-sm);
}
.rrv3-quotation-settings-panel .rrv3-info-box {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--rr-blue-dark);
}
.rrv3-quotation-settings-panel textarea {
    resize: vertical;
}
.quote-preset-library {
    margin-top: 18px;
}
.quote-preset-form {
    padding: 14px 16px;
    border: 1px solid var(--rr-border);
    border-radius: 16px;
    background: #f8fafc;
    margin-bottom: 14px;
}
.quote-preset-button-group {
    display: flex;
    align-items: flex-end;
}
.quote-preset-button-group .rrv3-button {
    width: 100%;
}
.quote-presets-table td,
.quote-presets-table th {
    vertical-align: top;
}

/* Quotation Audit Log */
.rrv3-quotation-audit-panel #quotation-audit-table td {
    vertical-align: top;
}
.rrv3-quotation-audit-panel small {
    color: var(--rr-text-muted);
}
.audit-event-view { background: #dbeafe; color: #1d4ed8; }
.audit-event-print { background: #dcfce7; color: #15803d; }
.audit-event-copy-source,
.audit-event-copy-created { background: #fef3c7; color: #b45309; }

@media print {
    .rrv3-quote-print-view .rrv3-page-header,
    .rrv3-quote-print-view .rrv3-actions-bar,
    .rrv3-quote-print-view .rrv3-user-greeting-card,
    .rrv3-quote-print-view .rrv3-role-switcher,
    .rrv3-quote-print-view .rrv3-instructions,
    .rrv3-header,
    .site-header,
    .site-footer,
    #wpadminbar {
        display: none !important;
    }
    .rrv3-quote-document {
        max-width: none;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .quote-items-table th {
        background: #1a365d !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .quote-items-table tbody tr:nth-child(even) td,
    .quote-items-table tfoot td,
    .rrv3-quote-document .client-info,
    .rrv3-quote-document .quote-meta,
    .rrv3-quote-document .quote-notes,
    .rrv3-quote-document .quote-terms,
    .rrv3-quote-document .quote-signoff > div,
    .quote-title-above-items {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .rrv3-quote-print-view.quotation-not-approved .rrv3-quote-document {
        display: none !important;
    }
    .rrv3-quote-print-view.quotation-not-approved::before {
        content: 'Printing disabled until SBU Head approval.';
        display: block !important;
        visibility: visible !important;
        font-size: 22px;
        font-weight: 900;
        color: #b91c1c;
        padding: 40px;
    }
}

@media (max-width: 720px) {
    .rrv3-quote-document {
        padding: 22px 18px;
    }
    .rrv3-quote-document .quote-header,
    .rrv3-quote-document .quote-details-row,
    .quote-signoff,
    .quote-selected-job-card,
    .quote-selected-client-card,
    .quote-job-picker-card,
    .quote-client-picker-card {
        align-items: stretch;
        flex-direction: column;
        grid-template-columns: 1fr;
    }
}

/* Customer acknowledgement table */
.quote-ack-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 12.8px;
}
.quote-ack-table th,
.quote-ack-table td {
    border: 1px solid #cbd5e1;
    padding: 10px 12px;
    vertical-align: bottom;
}
.quote-ack-table th {
    width: 34%;
    text-align: left;
    color: #1a365d;
    background: #f8fafc;
    font-weight: 800;
}
.quote-ack-table td {
    height: 32px;
    background: #fff;
}
.quote-ack-table .signature-row th,
.quote-ack-table .signature-row td {
    padding-top: 22px;
    padding-bottom: 22px;
}
.quote-ack-table .signature-row td {
    height: 72px;
}

/* Compact customer acknowledgement + sender signature/stamp */
.quote-ack-table {
    font-size: 11.5px;
    margin-top: 10px;
}
.quote-ack-table th,
.quote-ack-table td {
    padding: 5px 8px;
    font-weight: 400;
}
.quote-ack-table th {
    width: 32%;
    font-weight: 400;
    color: #334155;
    background: #f8fafc;
}
.quote-ack-table td {
    height: 22px;
}
.quote-ack-table .signature-row th,
.quote-ack-table .signature-row td {
    padding-top: 12px;
    padding-bottom: 12px;
}
.quote-ack-table .signature-row td {
    height: 48px;
}
.sender-signature-space {
    position: relative;
    min-height: 82px;
    margin: 10px 0 12px;
    border-bottom: 1px solid #94a3b8;
}
.sender-signature-img {
    position: absolute;
    left: 8px;
    bottom: 8px;
    max-width: 170px;
    max-height: 58px;
    object-fit: contain;
    z-index: 2;
}
.sender-stamp-img {
    position: absolute;
    left: 118px;
    bottom: -6px;
    width: 86px;
    height: 86px;
    object-fit: contain;
    opacity: 0.82;
    z-index: 1;
    transform: rotate(-8deg);
}
@media print {
    .sender-signature-img,
    .sender-stamp-img {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* SBU approval UI refinements */
.jc-status-approved_with_edits,
.jc-status-approved-with-edits {
    background-color: #ecfdf5 !important;
    color: #047857 !important;
    border: 1px solid #6ee7b7 !important;
}

button.rrv3-button-delete.jc-sbu-reject-btn,
button.rrv3-button-delete.quote-sbu-reject-btn,
button.rrv3-button-delete.director-reject-btn {
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    border-radius: var(--rr-radius) !important;
    padding: 7px 12px !important;
    line-height: 1.2 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    font-weight: 700;
}

/* SBU Head edit flags shown to Sales after approval/review edits */
.rrv3-sbu-edit-line-note {
    margin-top: 6px;
    padding: 6px 8px;
    border-left: 3px solid #f59e0b;
    background: #fffbeb;
    color: #92400e;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    border-radius: 6px;
}
.quote-items-table .rrv3-sbu-edit-line-note {
    font-size: 10.5px;
    font-weight: 700;
}

/* Softer quotation title typography */
.quote-title-above-items {
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 650 !important;
    letter-spacing: 0 !important;
}

/* Internal Job Costing vs Quotation comparison (not printed) */
.rrv3-quote-jc-comparison {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}
.rrv3-quote-jc-comparison.comparison-ok {
    border-color: #86efac;
    background: #f0fdf4;
}
.rrv3-quote-jc-comparison.comparison-different {
    border-color: #fde68a;
    background: #fffbeb;
}
.quote-jc-comparison-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    background: #dcfce7;
    color: #166534;
}
.comparison-different .quote-jc-comparison-badge {
    background: #fef3c7;
    color: #92400e;
}
.quote-ack-statement {
    margin-bottom: 4px !important;
}
.customer-signoff .quote-ack-table {
    margin-top: 0 !important;
}
.rrv3-bottom-actions {
    margin-top: 18px;
    justify-content: flex-end;
}

/* Quotation print-view alignment and typography refinements */
.quote-title-above-items {
    font-family: Arial, Helvetica, sans-serif !important;
    font-weight: 700 !important;
}
.rrv3-quote-document .client-info p,
.rrv3-quote-document .quote-meta p,
.rrv3-quote-document .quote-terms p {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.rrv3-quote-document .client-info p strong,
.rrv3-quote-document .quote-meta p strong,
.rrv3-quote-document .quote-terms p strong {
    flex: 0 0 auto;
    display: inline-block;
    white-space: nowrap;
}
.rrv3-quote-document .client-info p strong { width: 92px; }
.rrv3-quote-document .quote-meta p strong { width: 150px; }
.rrv3-quote-document .quote-terms p strong { width: 165px; }
.sender-stamp-img {
    left: 145px !important;
    bottom: -8px !important;
    z-index: 3 !important;
}

/* Long form UX helpers */
.rrv3-quote-bottom-actions,
.jc-actions-bar {
    position: sticky;
    bottom: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #e2e8f0;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
    padding: 12px;
    backdrop-filter: blur(8px);
}
.rrv3-section-jump-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 18px;
    padding: 10px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #f8fafc;
}
.rrv3-section-jump-links a {
    padding: 6px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12.5px;
    font-weight: 650;
    text-decoration: none;
}
.rrv3-section-jump-links a:hover {
    background: #2563eb;
    color: #fff;
}
.rrv3-back-to-top {
    position: fixed;
    right: 22px;
    bottom: 24px;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: #1d4ed8;
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(30, 64, 175, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: all 0.18s ease;
    z-index: 9999;
}
.rrv3-back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
@media print {
    .rrv3-quote-bottom-actions,
    .jc-actions-bar,
    .rrv3-section-jump-links,
    .rrv3-back-to-top {
        display: none !important;
    }
}

/* Print preview header sizing/alignment and robust print output */
.rrv3-quote-document .quote-header {
    align-items: center !important;
}
.rrv3-quote-document .company-logo-wrapper {
    flex: 0 0 170px !important;
    text-align: left !important;
}
.rrv3-quote-document .company-logo {
    max-width: 154px !important;
    max-height: 109px !important;
}
.rrv3-quote-document .company-info {
    text-align: right !important;
    align-self: center !important;
}
.rrv3-quote-document .company-info h2 {
    font-size: 12px !important;
    line-height: 1.15 !important;
    margin-bottom: 4px !important;
    letter-spacing: 0 !important;
}
.rrv3-quote-document .company-info p {
    font-size: 7.5px !important;
    line-height: 1.25 !important;
    margin: 1px 0 !important;
}
.rrv3-quote-document .quote-info-line {
    display: grid !important;
    grid-template-columns: var(--quote-label-width, 92px) 10px 1fr;
    gap: 0;
    align-items: start;
    margin: 5px 0;
}
.rrv3-quote-document .quote-info-label {
    font-weight: 700;
    white-space: nowrap;
}
.rrv3-quote-document .quote-info-colon {
    text-align: center;
    font-weight: 700;
}
.rrv3-quote-document .quote-info-value {
    min-width: 0;
}
.rrv3-quote-document .client-info { --quote-label-width: 82px; }
.rrv3-quote-document .quote-meta { --quote-label-width: 145px; }
.rrv3-quote-document .quote-terms { --quote-label-width: 158px; }

@media print {
    html, body {
        background: #ffffff !important;
    }
    .rrv3-quote-print-view,
    .rrv3-quote-print-view .rrv3-quote-document,
    .rrv3-quote-print-view .rrv3-quote-document * {
        visibility: visible !important;
    }
    .rrv3-quote-print-view .rrv3-quote-document {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #111827 !important;
    }
    .rrv3-quote-print-view .no-print,
    .rrv3-quote-print-view .rrv3-page-header,
    .rrv3-quote-print-view .rrv3-actions-bar,
    .rrv3-quote-print-view .rrv3-quote-jc-comparison {
        display: none !important;
        visibility: hidden !important;
    }
}

/* Print preview header fine-tuning: larger logo and company name */
.rrv3-quote-document .company-logo-wrapper {
    flex-basis: 240px !important;
}
.rrv3-quote-document .company-logo {
    max-width: 216px !important;
    max-height: 153px !important;
}
.rrv3-quote-document .company-info h2 {
    font-size: 16px !important;
    line-height: 1.18 !important;
}

/* Make browser print match the on-screen quotation print preview as closely as possible */
@page {
    size: A4;
    margin: 0;
}
@media print {
    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    body * {
        visibility: hidden !important;
    }
    .rrv3-quote-print-view .rrv3-quote-document,
    .rrv3-quote-print-view .rrv3-quote-document * {
        visibility: visible !important;
    }
    .rrv3-quote-print-view .rrv3-quote-document {
        display: block !important;
        position: static !important;
        width: auto !important;
        max-width: 980px !important;
        margin: 0 auto !important;
        padding: 34px 38px !important;
        background: #ffffff !important;
        color: #1f2937 !important;
        border: 1px solid #dbe3ef !important;
        border-radius: 14px !important;
        box-shadow: none !important;
        font-family: Arial, Helvetica, sans-serif !important;
        page-break-inside: auto !important;
    }
    .rrv3-quote-print-view .rrv3-quote-jc-comparison,
    .rrv3-quote-print-view .rrv3-page-header,
    .rrv3-quote-print-view .rrv3-actions-bar,
    .rrv3-quote-print-view .rrv3-bottom-actions,
    .rrv3-quote-print-view .rrv3-user-greeting-card,
    .rrv3-quote-print-view .rrv3-role-switcher,
    .rrv3-quote-print-view .rrv3-instructions,
    .rrv3-quote-print-view .no-print,
    .rrv3-header,
    .site-header,
    .site-footer,
    #wpadminbar {
        display: none !important;
        visibility: hidden !important;
    }
    .rrv3-quote-document .quote-header,
    .rrv3-quote-document .quote-details-row,
    .rrv3-quote-document .quote-signoff,
    .rrv3-quote-document .client-info,
    .rrv3-quote-document .quote-meta,
    .rrv3-quote-document .quote-notes,
    .rrv3-quote-document .quote-terms,
    .rrv3-quote-document .quote-signoff > div,
    .quote-title-above-items,
    .quote-items-table th,
    .quote-items-table td {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Clean page breaks for long quotation print previews */
@media print {
    .quote-signoff,
    .quote-signoff > div,
    .sender-signoff,
    .customer-signoff,
    .sender-signature-space,
    .quote-ack-table,
    .quote-ack-table tr,
    .quote-items-table tr,
    .quote-notes,
    .quote-terms,
    .quote-title-above-items {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
    .quote-signoff {
        break-before: auto;
        page-break-before: auto;
    }
    .quote-items-table thead {
        display: table-header-group;
    }
    .quote-items-table tfoot {
        display: table-footer-group;
    }
}

/* Quotation main/sub line item structure */
.quote-sub-item-row td {
    background: #fbfdff;
}
.quote-desc-wrap {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.quote-sub-label-display {
    min-width: 24px;
    padding-top: 8px;
    color: #475569;
    font-weight: 700;
}
.quote-sub-item-row .quote-description-input {
    padding-left: 4px;
}
.quote-print-sub-prefix {
    display: inline-block;
    min-width: 26px;
    font-weight: 700;
    color: #475569;
}
.quote-items-table tr.quote-sub-item-row td:nth-child(2) {
    padding-left: 22px;
}

/* Quotation AI item extraction modal */
.quote-ai-items-content {
    max-width: 980px;
}
.quote-ai-preview-table th,
.quote-ai-preview-table td {
    vertical-align: top;
    font-size: 12.5px;
}
.quote-ai-preview-table td:nth-child(5) {
    min-width: 280px;
}
#quote-ai-status {
    margin: 8px 0 12px;
    font-weight: 700;
    color: #1d4ed8;
}

/* Performance hotfix: keep sticky actions but reduce repaint cost */
.rrv3-quote-bottom-actions,
.jc-actions-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 -3px 12px rgba(15, 23, 42, 0.06) !important;
    background: #ffffff !important;
}
.rrv3-back-to-top {
    box-shadow: 0 6px 16px rgba(30, 64, 175, 0.22) !important;
    transition: opacity 0.15s ease !important;
}

/* Editable AI preview table controls */
.quote-ai-preview-table .rrv3-input {
    min-width: 72px;
    padding: 5px 7px;
    font-size: 12px;
}
.quote-ai-preview-table .quote-ai-description {
    min-width: 280px;
    resize: vertical;
}
.quote-ai-preview-table .quote-ai-line-type {
    min-width: 82px;
}
.quote-ai-preview-table .quote-ai-sub-label {
    max-width: 58px;
}

/* Job Costing quotation usage badges */
.rrv3-jc-usage {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}
.rrv3-jc-usage-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
.rrv3-jc-usage-badge.available {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}
.rrv3-jc-usage-badge.used {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}
.rrv3-jc-usage-badge.not-available {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

/* Attention pulse for required save-before-approve action */
.rrv3-attention-pulse {
    animation: rrv3AttentionPulse 0.7s ease-in-out 3;
}
@keyframes rrv3AttentionPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
    50% { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.35); }
}

/* Customer acknowledgement quotation reference line */
.quote-ack-ref {
    margin: 2px 0 3px !important;
    font-size: 12.5px;
}

/* Quotation print/PDF-aligned item table and quotation title card */
.quote-meta-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}
.quote-label-box {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    border-radius: 12px;
    padding: 9px 12px;
    text-align: center;
    font-weight: 800;
    letter-spacing: 0.04em;
}
.quote-meta-stack .quote-meta {
    flex: 1;
}
.quote-items-table td.quote-main-display {
    text-align: center !important;
    font-weight: 700;
}
.quote-items-table td.quote-sub-display {
    text-align: left !important;
    padding-left: 10px !important;
    font-weight: 700;
    color: #475569;
}
.quote-items-table td.quote-item-description,
.quote-items-table tbody td:nth-child(2) {
    text-align: justify !important;
    text-justify: inter-word;
}
.quote-items-table tbody td:nth-child(3) {
    text-align: right !important;
}
.quote-items-table tbody td:nth-child(4) {
    text-align: left !important;
}
.quote-items-table tbody td:nth-child(5),
.quote-items-table tbody td:nth-child(6) {
    text-align: right !important;
}

/* Quotation item/sub-item alignment refinement */
.quote-label-box {
    padding: 6px 10px !important;
    font-size: 18px !important;
    line-height: 1.1 !important;
}
.quote-items-table td.quote-main-display {
    text-align: center !important;
    font-weight: 700 !important;
}
.quote-items-table td.quote-sub-display {
    text-align: right !important;
    padding-left: 6px !important;
    padding-right: 8px !important;
    font-weight: 400 !important;
    color: #475569;
}

/* A4-style quotation print preview with visible page-break guides */
@media screen {
    .rrv3-quote-print-view {
        background: #e5e7eb;
        padding-top: 28px;
        padding-bottom: 118px;
    }
    .rrv3-quote-print-view .rrv3-quote-document {
        position: relative;
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm;
        box-sizing: border-box;
        margin: 22px auto 36px !important;
        padding: 12mm !important;
        border: 0;
        border-radius: 3px;
        overflow: visible;
        box-shadow: 0 14px 36px rgba(15, 23, 42, 0.24);
        background-color: #ffffff;
        background-image: repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent calc(297mm - 1px),
            rgba(220, 38, 38, 0.42) calc(297mm - 1px),
            rgba(220, 38, 38, 0.42) 297mm
        );
        background-repeat: repeat-y;
        background-size: 100% 297mm;
    }
    .rrv3-quote-print-view .rrv3-quote-document::before {
        content: "A4 preview — red guide lines show page breaks";
        position: absolute;
        right: 0;
        top: -22px;
        color: #64748b;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.02em;
    }
}

.rrv3-quote-document .quote-header,
.rrv3-quote-document .quote-details-row,
.rrv3-quote-document .quote-title-above-items,
.rrv3-quote-document .quote-notes,
.rrv3-quote-document .quote-terms,
.rrv3-quote-document .quote-signoff,
.rrv3-quote-document .sender-signoff,
.rrv3-quote-document .customer-signoff {
    break-inside: avoid;
    page-break-inside: avoid;
}
.quote-items-table {
    break-inside: auto;
    page-break-inside: auto;
}
.quote-items-table thead {
    display: table-header-group;
}
.quote-items-table tfoot {
    display: table-footer-group;
}
.quote-items-table tr,
.quote-items-table td,
.quote-items-table th {
    break-inside: avoid;
    page-break-inside: avoid;
}

@media print {
    .rrv3-quote-print-view {
        padding: 0 !important;
        background: #ffffff !important;
    }
    .rrv3-quote-print-view .rrv3-quote-document {
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm !important;
        margin: 0 auto !important;
        padding: 12mm !important;
        box-sizing: border-box !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background-image: none !important;
    }
    .rrv3-quote-print-view .rrv3-quote-document::before {
        display: none !important;
        content: none !important;
    }
}

/* Quotation SBU edit safety: block approval preview until edits are saved */
.quote-sbu-unsaved-approval-warning {
    display: inline-flex;
    align-items: center;
    max-width: 420px;
}
.rrv3-button.quote-sbu-preview-disabled,
.rrv3-button.quote-sbu-preview-disabled:hover {
    background-color: #cbd5e1 !important;
    border-color: #cbd5e1 !important;
    color: #ffffff !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Quotation SBU edit tracking summary */
.rrv3-sbu-edit-summary {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}
.rrv3-sbu-edit-summary h3 {
    margin-top: 0;
    color: #92400e;
}
.rrv3-sbu-edit-section-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}
.rrv3-sbu-edit-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    color: #92400e;
    font-size: 12px;
    font-weight: 800;
}
.rrv3-sbu-edit-details summary {
    cursor: pointer;
    font-weight: 800;
    color: #92400e;
    margin: 8px 0;
}
.rrv3-sbu-edit-summary-table td,
.rrv3-sbu-edit-summary-table th {
    font-size: 12px;
    vertical-align: top;
}

/* Approval readiness checklist */
.rrv3-approval-readiness {
    border-left: 4px solid #2563eb;
    background: #eff6ff;
}
.rrv3-approval-readiness h3 {
    margin-top: 0;
    color: #1e3a8a;
}
.rrv3-approval-readiness-list {
    display: grid;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
}
.rrv3-readiness-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 9px 10px;
    border-radius: 12px;
    border: 1px solid #bfdbfe;
    background: #ffffff;
}
.rrv3-readiness-item.is-ok {
    border-color: #86efac;
    background: #f0fdf4;
}
.rrv3-readiness-item.is-warning {
    border-color: #fbbf24;
    background: #fffbeb;
}
.rrv3-readiness-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    font-weight: 900;
    color: #ffffff;
    background: #f59e0b;
}
.rrv3-readiness-item.is-ok .rrv3-readiness-icon {
    background: #16a34a;
}
.rrv3-readiness-text strong,
.rrv3-readiness-text small {
    display: block;
}
.rrv3-readiness-text small {
    margin-top: 2px;
    color: #64748b;
}

/* Client batch upload/download tools */
.rrv3-client-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}
.rrv3-client-batch-preview {
    margin-top: 12px;
}
.rrv3-client-batch-preview-table {
    margin-top: 10px;
}
@media (max-width: 720px) {
    .rrv3-client-toolbar-actions,
    .rrv3-client-toolbar-actions .rrv3-button {
        width: 100%;
    }
    .rrv3-client-toolbar-actions .rrv3-button {
        justify-content: center;
    }
}

/* 1307-34: Quotation item group drag/reorder */
.quote-group-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-right: 4px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    cursor: grab;
    font-weight: 900;
    line-height: 1;
}
.quote-group-drag-handle:active {
    cursor: grabbing;
}
.quote-sub-drag-spacer {
    display: inline-block;
    width: 31px;
}
#quotation-items-body tr.quote-row-dragging {
    opacity: .45;
    background: #eff6ff;
}
#quotation-items-body tr.quote-main-drop-target-before td {
    border-top: 3px solid #2563eb !important;
}
#quotation-items-body tr.quote-main-drop-target-after td {
    border-bottom: 3px solid #2563eb !important;
}
html.rrv3-dark-mode .quote-group-drag-handle {
    background: #1f2937;
    color: #e5e7eb;
    border-color: #475569;
}

/* 1507-01: sticky action live total and revision comparison */
.quote-action-live-total {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    font-weight: 1000;
    margin-right: auto;
}
.quote-current-revision-row td {
    background: #eff6ff !important;
    font-weight: 800;
}
html.rrv3-dark-mode .quote-action-live-total {
    background: #431407;
    border-color: #fb923c;
    color: #fed7aa;
}
html.rrv3-dark-mode .quote-current-revision-row td {
    background: #0b2a4a !important;
}

/* Quotation tax selection */
.quote-tax-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.quote-tax-summary {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    font-weight: 800;
    line-height: 1.7;
}
html.rrv3-dark-mode .quote-tax-summary {
    background: #0b2a4a;
    color: #dbeafe;
    border-color: #2563eb;
}
#quote-line-tax-summary {
    margin: 6px 0 4px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-weight: 800;
    line-height: 1.7;
}
html.rrv3-dark-mode #quote-line-tax-summary {
    background: #0b2a4a;
    color: #dbeafe;
    border-color: #2563eb;
}

/* 1507 tax total alignment + superseded status readability */
.quote-tax-summary-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 170px;
    gap: 12px;
    align-items: center;
    width: 100%;
}
.quote-tax-summary-row span {
    text-align: right;
    font-weight: 900;
}
.quote-tax-summary-row strong {
    text-align: right;
    font-weight: 1000;
    white-space: nowrap;
}
.quote-tax-summary-total {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #93c5fd;
    font-size: 1.05em;
}
.jc-status-superseded,
.status-superseded {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    border: 1px solid #9ca3af !important;
}
html.rrv3-dark-mode .jc-status-superseded,
html.rrv3-dark-mode .status-superseded {
    background-color: #374151 !important;
    color: #f9fafb !important;
    border-color: #9ca3af !important;
}
@media (max-width: 640px) {
    .quote-tax-summary-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }
    .quote-tax-summary-row span,
    .quote-tax-summary-row strong {
        text-align: right;
    }
}

/* 1507-11: Accounting currency format and merged quotation totals */
.quote-money-cell,
.quote-total-amount {
    text-align: right !important;
}
.quote-accounting-amount {
    display: inline-grid;
    grid-template-columns: 34px minmax(120px, 1fr);
    gap: 8px;
    align-items: baseline;
    width: 100%;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.quote-accounting-currency {
    text-align: left;
    font-weight: inherit;
}
.quote-accounting-number {
    text-align: right;
    font-weight: inherit;
}
.quote-items-table tfoot .quote-total-label {
    text-align: right !important;
    padding-right: 12px !important;
}
.quote-items-table tfoot .quote-total-amount {
    min-width: 210px;
}
.quote-items-table tfoot .quote-grand-total-row td {
    border-top: 2px solid #1e3a8a !important;
    font-size: 1.05em;
}
.quote-tax-summary-row strong {
    min-width: 210px;
}

/* Chunk 2007-25: quotation line-level tax selector */
.quote-line-tax-select {
    min-width: 130px;
}
.quote-line-tax-amount {
    display: block;
    margin-top: 4px;
    color: var(--rr-text-muted, #64748b);
    font-size: 11px;
    font-weight: 700;
}
#quotation-items-table th,
#quotation-items-table td {
    vertical-align: top;
}

/* Chunk 2007-27: dynamic quotation note lines */
#quote-notes-list .quote-note-row {
    padding-bottom: 10px;
    border-bottom: 1px dashed #e2e8f0;
}
#quote-notes-list .quote-note-row:last-child {
    border-bottom: none;
}
.quote-remove-note-line {
    margin-top: 6px;
}
#quote-add-note-line {
    margin-top: 6px;
}

/* Chunk 2007-28: collapsible Job Costing vs Quotation Revision Chain */
.rrv3-quote-jc-comparison summary.rrv3-quote-jc-comparison-summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 2px 0;
    font-weight: 800;
    color: #1e3a8a;
}
.rrv3-quote-jc-comparison summary.rrv3-quote-jc-comparison-summary::-webkit-details-marker {
    display: none;
}
.rrv3-quote-jc-comparison summary.rrv3-quote-jc-comparison-summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s ease;
}
.rrv3-quote-jc-comparison[open] summary.rrv3-quote-jc-comparison-summary::before {
    transform: rotate(90deg);
}
.rrv3-quote-jc-comparison-summary small {
    color: #64748b;
    font-weight: 700;
}
.rrv3-quote-jc-comparison-body {
    margin-top: 12px;
}

/* Chunk RRv3-81: Quotation two-line Amount / Tax layout */
.quote-amount-stack-cell,
.quote-preview-amount-stack {
    min-width: 170px;
    vertical-align: top;
}
.quote-line-base-amount {
    font-weight: 800;
    text-align: right;
    margin-bottom: 6px;
}
.quote-line-tax-control {
    margin: 4px 0;
}
.quote-line-tax-control select {
    font-size: 12px;
    padding: 6px 8px;
}
.quote-line-tax-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 5px;
    font-size: 12px;
    color: #475569;
}
.quote-tax-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    font-weight: 800;
    white-space: nowrap;
}
html.rrv3-dark-mode .quote-line-tax-inline {
    color: #cbd5e1;
}
html.rrv3-dark-mode .quote-tax-pill {
    background: #451a03;
    color: #fcd34d;
    border-color: #92400e;
}

/* Chunk RRv3-85: Quotation preview column balance */
.quote-items-table {
    table-layout: fixed;
}
.quote-items-table th:nth-child(1),
.quote-items-table td:nth-child(1) { width: 7%; }
.quote-items-table th:nth-child(2),
.quote-items-table td:nth-child(2) { width: 52%; }
.quote-items-table th:nth-child(3),
.quote-items-table td:nth-child(3) { width: 7%; }
.quote-items-table th:nth-child(4),
.quote-items-table td:nth-child(4) { width: 8%; }
.quote-items-table th:nth-child(5),
.quote-items-table td:nth-child(5) { width: 12%; }
.quote-items-table th:nth-child(6),
.quote-items-table td:nth-child(6) { width: 14%; }
.quote-items-table td.quote-item-description,
.quote-items-table tbody td:nth-child(2) {
    white-space: normal !important;
    word-break: normal;
    overflow-wrap: anywhere;
}
.quote-items-table tbody td:nth-child(5),
.quote-items-table tbody td:nth-child(6) {
    padding-left: 6px;
    padding-right: 6px;
    white-space: normal !important;
}
.quote-items-table tbody .quote-accounting-amount {
    grid-template-columns: 22px minmax(58px, 1fr);
    gap: 4px;
    min-width: 0;
}
.quote-items-table .quote-line-tax-inline {
    gap: 4px;
    justify-content: flex-end;
}
.quote-items-table .quote-tax-pill {
    padding: 2px 6px;
    font-size: 10.5px;
}
.quote-items-table tfoot .quote-total-amount,
.quote-tax-summary-row strong {
    min-width: 150px;
}
@media (max-width: 900px) {
    .quote-items-table {
        table-layout: auto;
    }
}
