/* ==========================================================================
CrewSheet styles: pages/documents.css
==========================================================================
Quotes page, quote / invoice detail pages, the document header, email pop-up, terms, signature, status panel.

Part of the CrewSheet stylesheet set, loaded in this order by Views/Shared/_Layout.cshtml:
  base.css > components.css > pages/home.css > pages/jobs.css > pages/zones.css > pages/documents.css > pages/worklist.css > pages/reports.css > pages/settings.css
Section numbers are the same as in the old single site.css, so view comments like
"components.css 23" still point at the right place. New sections: next free number, in the file for that area.

SECTIONS IN THIS FILE
  17        QUOTE / INVOICE DOCUMENTS
  37        QUOTES PAGE (Views/Quotes/Index + _QuotePreview, wwwroot/js/quotes.js)
  39        QUOTE / INVOICE TOOLBAR, EMAIL TO CLIENT POP-UP, EMAIL HISTORY
  43        SIGNATURE LINES (Views/Shared/_DocumentSheet; the PDF draws the same)
  47        "PRICES CHANGED SINCE THIS QUOTE" WARNING (Views/Shared/_PriceChangeAlert, Services/PriceWatch)
  51        QUOTE / INVOICE DOCUMENT (Views/Shared/_DocumentSheet; the PDF draws the same layout)
  52        QUOTE / INVOICE STATUS PANEL (top of the page: status, next step, PDF buttons, record a payment, "More")
  65        CHANGE ORDER FORM (Views/ChangeOrders/Form; js/changeorders.js)
========================================================================== */

/* ==========================================================================
17. QUOTE / INVOICE DOCUMENTS
========================================================================== */
.company-logo {
    display: block;
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
}

/* Gap under the "Project Details" label on the project header */
.cs-project-header .cs-proj-eyebrow {
    margin-bottom: 0.5rem;
}

/* Mark Paid row on Invoice Details */
.cs-paid-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

    .cs-paid-form .form-control,
    .cs-paid-form .form-select {
        width: auto;
    }


/* ==========================================================================
37. QUOTES PAGE (Views/Quotes/Index + _QuotePreview, wwwroot/js/quotes.js)
========================================================================== */

/* Wrapper: flex column + gap controls all vertical spacing (like .cs-zones, section 27) */
.cs-quotes {
    display: flex;
    flex-direction: column;
    gap: var(--cs-gap);
}

    /* Pop-ups (<dialog>) are left alone: they center themselves with margin auto, and a 0 bottom margin pinned
       them to the bottom of the screen */
    .cs-quotes > *:not(dialog) {
        margin-bottom: 0 !important;
    }

/* ---------- 37a. Pricing + Generate cards, side by side (stacked on tablets/phones) ---------- */
.cs-quote-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: var(--cs-gap);
    align-items: start;
}

@media (max-width: 767.98px) {
    .cs-quote-top {
        grid-template-columns: minmax(0, 1fr);
    }
}

.cs-quote-card {
    padding: 1rem 1.25rem;
    border: 1px solid var(--cs-border);
    border-top: 4px solid var(--cs-navy);
    border-radius: var(--cs-radius-lg);
    background: var(--cs-surface);
    box-shadow: var(--cs-shadow-sm);
}

/* Title with its button inline next to it */
.cs-quote-card-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

    .cs-quote-card-head h3 {
        margin: 0;
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--cs-heading);
    }

/* Label | value pairs */
.cs-quote-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    margin: 0;
}

    .cs-quote-facts dt {
        font-weight: 600;
        color: var(--cs-muted);
    }

    .cs-quote-facts dd {
        margin: 0;
        font-weight: 600;
        color: var(--cs-text);
    }

.cs-quote-card-note {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--cs-muted);
}

/* ---------- 37b. Generate: Tax % / Discount % boxes ---------- */
.cs-quote-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

    .cs-quote-inputs .form-control {
        width: 8rem;
        text-align: right;
    }

/* ---------- 37c. Live preview ---------- */
.cs-quote-preview {
    margin-bottom: 0.9rem;
    padding: 0.6rem 0.9rem;
    background: var(--cs-blue-50);
    border: 1px solid var(--cs-blue-200);
    border-radius: var(--cs-radius-md);
    transition: opacity 0.15s;
}

    .cs-quote-preview.is-loading {
        opacity: 0.55;
    }

.cs-quote-preview-table {
    width: 100%;
}

    .cs-quote-preview-table th,
    .cs-quote-preview-table td {
        padding: 0.25rem 0;
    }

    .cs-quote-preview-table th {
        font-weight: 500;
        color: var(--cs-text);
    }

    .cs-quote-preview-table td {
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

.cs-quote-preview-note {
    font-size: 0.8rem;
    color: var(--cs-muted);
}

/* Subtotal and total get a rule above them */
.cs-quote-preview-sub th,
.cs-quote-preview-sub td {
    border-top: 1px solid var(--cs-blue-200);
    font-weight: 600;
}

.cs-quote-preview-total th,
.cs-quote-preview-total td {
    border-top: 2px solid var(--cs-navy);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--cs-heading);
}

.cs-quote-preview-empty {
    color: var(--cs-muted);
}

/* Lines that will quote as $0 (missing feet, tank settings...) */
.cs-quote-preview-problems {
    margin-top: 0.6rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--cs-warning);
    background: var(--cs-warning-alert-bg);
    border: 1px solid var(--cs-gold-soft);
    border-radius: var(--cs-radius);
}

    .cs-quote-preview-problems ul {
        margin: 0.25rem 0 0;
        padding-left: 1.2rem;
    }

/* "This replaces the open quote" */
.cs-quote-replace-note {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    color: var(--cs-warning);
}

/* ---------- 37d. Quotes table: side padding, row status buttons, replaced rows ---------- */
.cs-quotes-table th:first-child,
.cs-quotes-table td:first-child {
    padding-left: 1rem;
}

.cs-quotes-table th:last-child,
.cs-quotes-table td:last-child {
    padding-right: 1rem;
}

.cs-btn-accept {
    color: var(--cs-success);
    background: var(--cs-success-bg);
    border: 1px solid var(--cs-success-border);
}

    .cs-btn-accept:hover {
        color: var(--cs-surface);
        background: var(--cs-success);
        border-color: var(--cs-success);
    }

.cs-btn-decline {
    color: var(--cs-danger);
    background: var(--cs-danger-bg);
    border: 1px solid var(--cs-danger-border);
}

    .cs-btn-decline:hover {
        color: var(--cs-surface);
        background: var(--cs-danger);
        border-color: var(--cs-danger);
    }

/* Replaced by a newer quote: greyed out but still clickable */
.cs-quote-row-canceled > td {
    color: var(--cs-muted);
    opacity: 0.6;
}



/* ==========================================================================
39. QUOTE / INVOICE TOOLBAR, EMAIL TO CLIENT POP-UP, EMAIL HISTORY
   (Views/Quotes/Details, Views/Invoices/Details, Views/Shared/_EmailDocumentForm, _EmailHistory)
========================================================================== */

/* ---------- 39a. Status on the left, PDF / email buttons on the right (stacks on phones) ---------- */
.cs-doc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.cs-doc-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.cs-doc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (max-width: 575.98px) {
    .cs-doc-actions,
    .cs-doc-actions .btn,
    .cs-doc-actions .cs-inline-form {
        width: 100%;
    }
}

/* ---------- 39b. Email pop-up ---------- */
.cs-email-message {
    font-family: inherit;
    line-height: 1.45;
}

.cs-email-error {
    margin-bottom: 1rem;
}

/* "Testing mode: saved to a folder, not sent" */
.cs-email-testmode {
    margin-bottom: 1rem;
    padding: 0.55rem 0.8rem;
    font-size: 0.88rem;
    color: var(--cs-warning);
    background: var(--cs-warning-alert-bg);
    border: 1px solid var(--cs-gold-soft);
    border-radius: var(--cs-radius-md);
}

/* Attached / Your copy / Replies go to */
.cs-email-facts {
    margin: 0 0 1rem;
    padding: 0.6rem 0.9rem;
    list-style: none;
    font-size: 0.88rem;
    background: var(--cs-blue-50);
    border: 1px solid var(--cs-blue-200);
    border-radius: var(--cs-radius-md);
}

    .cs-email-facts li + li {
        margin-top: 0.2rem;
    }

    .cs-email-facts span {
        display: inline-block;
        min-width: 7rem;
        font-weight: 600;
        color: var(--cs-heading);
    }

    .cs-email-facts em {
        color: var(--cs-muted);
    }

/* Full-page version (no pop-up) */
.cs-email-page {
    max-width: 44rem;
    padding: 1.25rem 1.5rem;
}

.cs-email-page-title {
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--cs-heading);
}

/* ---------- 39c. Email history under the toolbar ---------- */
.cs-email-history {
    margin-bottom: 1rem;
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
    background: var(--cs-surface);
    border: 1px solid var(--cs-border);
    border-left: 4px solid var(--cs-navy);
    border-radius: var(--cs-radius-md);
}

.cs-email-history-title {
    margin-bottom: 0.3rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cs-heading);
}

.cs-email-history ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cs-email-history li {
    padding: 0.15rem 0;
}

.cs-email-dot {
    display: inline-block;
    width: 1.2rem;
    font-weight: 700;
    text-align: center;
}

.cs-email-history .is-sent .cs-email-dot {
    color: var(--cs-success);
}

.cs-email-history .is-test {
    color: var(--cs-muted);
}

/* A failed send stands out in red with its reason */
.cs-email-history .is-failed {
    color: var(--cs-danger);
}



/* ==========================================================================
43. SIGNATURE LINES (Views/Shared/_DocumentSheet; the PDF draws the same)
========================================================================== */
/* Quote: Acceptance; invoice: Work Completed. Navy bar (.cs-doc-bar, section 51), a sentence, three lines */
.cs-signature {
    margin-top: 2rem;
    break-inside: avoid;
}

.cs-signature-text {
    margin: 0.4rem 0.4rem 1.6rem;
    font-size: 0.85rem;
    color: var(--cs-muted);
}

/* Signature (wide) | Printed Name | Date */
.cs-signature-lines {
    display: grid;
    grid-template-columns: 2.5fr 2fr 1fr;
    gap: 1.25rem;
    font-size: 0.75rem;
    color: var(--cs-muted);
}

.cs-signature-line {
    display: block;
    height: 1.75rem;
    margin-bottom: 0.2rem;
    border-bottom: 1px solid var(--cs-navy);
}

@media (max-width: 575.98px) {
    .cs-signature-lines {
        grid-template-columns: 1fr;
    }
}



/* ==========================================================================
47. "PRICES CHANGED SINCE THIS QUOTE" WARNING (Views/Shared/_PriceChangeAlert, Services/PriceWatch)
========================================================================== */
.cs-price-alert {
    margin-bottom: 1rem;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    color: var(--cs-text);
    background: var(--cs-warning-alert-bg);
    border: 1px solid var(--cs-gold-soft);
    border-left: 4px solid var(--cs-gold);
    border-radius: var(--cs-radius-md);
}

.cs-price-alert-title {
    margin-bottom: 0.3rem;
    font-weight: 700;
    color: var(--cs-warning);
}

.cs-price-alert ul {
    margin: 0 0 0.35rem;
    padding-left: 1.2rem;
}

.cs-price-alert-help {
    font-size: 0.82rem;
    color: var(--cs-muted);
}

/* Up = costs you more (red), down = good news (green) */
.cs-price-up {
    font-weight: 600;
    color: var(--cs-danger);
}

.cs-price-down {
    font-weight: 600;
    color: var(--cs-success);
}



/* ==========================================================================
51. QUOTE / INVOICE DOCUMENT (Views/Shared/_DocumentSheet; the PDF, DocumentPdfService, draws the same layout)
   top:   logo (left margin, column 1) | QUOTATION / INVOICE + numbers (column 3)
   under: From | Job Details | Client  (navy bars, same height)
   items: navy header, tinted cells, gold Total Cost column; foot: Notes/Payment | totals under Total Cost
   Tablets: same layout, narrower. Phones: one column, items as cards, totals before notes.
========================================================================== */
.cs-doc-sheet {
    padding: 1.75rem;
    font-size: 0.9rem;
    color: var(--cs-text);
    background: var(--cs-surface);
    border: 1px solid var(--cs-gold);   /* thin gold frame around the sheet (screen only; printing drops it) */
    border-radius: var(--cs-radius-lg);
    box-shadow: var(--cs-shadow-sm);
}

/* ---------- 51a. Top + the three blocks share one grid: 2.1 | 2.5 | 2.1 (the PDF's columns) ---------- */
.cs-doc-top,
.cs-doc-blocks {
    display: grid;
    grid-template-columns: minmax(0, 2.1fr) minmax(0, 2.5fr) minmax(0, 2.1fr);
    gap: 1rem;
}

/* Invoices: From | Bill To | Job Details, so the wide column moves to the right (phones still stack) */
@media (min-width: 576px) {
    .cs-doc-blocks.cs-doc-blocks-invoice {
        grid-template-columns: minmax(0, 2.1fr) minmax(0, 2.1fr) minmax(0, 2.5fr);
    }
}

.cs-doc-top {
    align-items: center;
    margin-bottom: 1.25rem;
}

.cs-doc-logo-wrap {
    text-align: left;
}

/* Same size on the page as in the PDF (0.75 in tall on a 7 in wide sheet = about 8.75rem here) */
.cs-doc-logo {
    display: inline-block;
    max-width: 100%;
    max-height: 8.75rem;
    object-fit: contain;
}

/* Title + numbers: column 3, the highest block */
.cs-doc-meta {
    grid-column: 3;
    text-align: right;
}

.cs-doc-title {
    margin: 0 0 0.35rem;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--cs-heading);
}

/* Label (navy, right) | value (tinted box) */
.cs-doc-meta-list {
    display: grid;
    grid-template-columns: auto minmax(0, 1.3fr);
    justify-content: end;
    gap: 2px 0.5rem;
    margin: 0;
    font-size: 0.8rem;
}

    .cs-doc-meta-list dt {
        font-weight: 700;
        color: var(--cs-heading);
    }

    .cs-doc-meta-list dd {
        margin: 0;
        padding: 0.05rem 0.45rem;
        font-weight: 700;
        text-align: left;
        background: var(--cs-blue-100);
    }

/* ---------- 51b. From | Job Details | Client: navy bar, then the content; all three the same height ---------- */
.cs-doc-blocks {
    margin-bottom: 1.75rem;
}

.cs-doc-block {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* The navy title bar (also used by the signature section, 43) */
.cs-doc-bar {
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cs-on-dark);
    background: var(--cs-navy);
}

/* Company and client: shaded box with a gold edge, stretched to the block's height */
.cs-doc-box {
    flex: 1;
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
    line-height: 1.35;
    overflow-wrap: anywhere;    /* long emails wrap instead of pushing the page wide */
    background: var(--cs-blue-50);
    border-left: 3px solid var(--cs-gold);
}

.cs-doc-box-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--cs-heading);
}

/* Job details: label | tinted value, a white line between rows */
.cs-doc-info {
    flex: 1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: start;
    gap: 2px 0;
    margin: 0;
    font-size: 0.8rem;
}

    .cs-doc-info dt,
    .cs-doc-info dd {
        margin: 0;
        padding: 0.2rem 0.5rem;
    }

    .cs-doc-info dt {
        font-weight: 700;
        color: var(--cs-heading);
    }

    .cs-doc-info dd {
        background: var(--cs-blue-100);
        overflow-wrap: anywhere;
    }

/* ---------- 51c. Items: navy header, tinted cells with white lines, gold Total Cost, solid line under the last item ---------- */
.cs-doc-lines {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

/* Column widths (match the PDF and the totals below: 50 | 15.7 | 16.4 | 17.9 %) */
.cs-doc-col-desc { width: 50%; }
.cs-doc-col-qty { width: 15.7%; }
.cs-doc-col-price { width: 16.4%; }
.cs-doc-col-total { width: 17.9%; }

    .cs-doc-lines th,
    .cs-doc-lines td {
        padding: 0.45rem 0.6rem;
        text-align: right;
        border: 1px solid var(--cs-surface);
    }

    .cs-doc-lines th:first-child,
    .cs-doc-lines td:first-child {
        text-align: left;
    }

    .cs-doc-lines thead th {
        font-weight: 700;
        color: var(--cs-on-dark);
        background: var(--cs-navy);
    }

    .cs-doc-lines tbody td {
        background: var(--cs-blue-100);
    }

        .cs-doc-lines tbody td.cs-doc-line-total {
            font-weight: 700;
            background: var(--cs-gold-tint);
        }

    .cs-doc-lines tbody tr:last-child td {
        border-bottom: 2px solid var(--cs-navy);
    }

/* ---------- 51d. Foot: Notes / Payment (Description + Quantity) | totals (Unit Price + Total Cost columns) ---------- */
.cs-doc-foot {
    display: grid;
    grid-template-columns: 65.7% 34.3%;
    margin-top: 0.4rem;
    break-inside: avoid;
}

/* Top padding = about one blank line above NOTES (user's call; the PDF matches with SpaceBefore) */
.cs-doc-notes {
    padding: 1.45rem 0.6rem 0.45rem;
    font-size: 0.8rem;
    background: var(--cs-blue-50);
    border-left: 3px solid var(--cs-gold);
    border-right: 2px solid var(--cs-surface);
}

.cs-doc-notes-title {
    margin-bottom: 0.15rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cs-heading);
}

.cs-doc-notes p {
    margin: 0 0 0.2rem;
}

.cs-doc-notes-terms {
    font-weight: 700;
}

.cs-doc-notes-thanks {
    font-style: italic;
    color: var(--cs-muted);
}

/* Label (Unit Price column) | amount (Total Cost column) */
.cs-doc-totals {
    display: grid;
    grid-template-columns: 47.8% 52.2%;
    align-content: start;
    margin: 0;
}

    .cs-doc-totals dt,
    .cs-doc-totals dd {
        margin: 0;
        padding: 0.25rem 0.6rem;
        text-align: right;
        border-bottom: 1px solid var(--cs-surface);
    }

    .cs-doc-totals dt {
        font-weight: 700;
        color: var(--cs-heading);
    }

    .cs-doc-totals dd {
        background: var(--cs-gold-tint);
        border-left: 1px solid var(--cs-surface);
    }

        .cs-doc-totals dt.cs-doc-grand,
        .cs-doc-totals dd.cs-doc-grand {
            padding-top: 0.4rem;
            padding-bottom: 0.4rem;
            font-size: 1.15rem;
            font-weight: 700;
            color: var(--cs-heading);
            background: var(--cs-gold-tint-strong);
            border-top: 1px solid var(--cs-navy);
        }

/* Paid invoices: green stamp under the totals */
.cs-doc-paid {
    margin-top: 0.9rem;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: right;
    color: var(--cs-success);
}

/* Email / phone links in the From and Client boxes (Views/Shared/_DocumentSheet: mailto / tel) */
.cs-doc-link {
    color: var(--cs-heading);
    text-decoration: underline;
    text-decoration-color: var(--cs-blue-300);
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}

    .cs-doc-link:hover {
        text-decoration-color: var(--cs-gold);
    }

@media print {
    .cs-doc-link {
        color: inherit;
        text-decoration: none;
    }
}
/* ---------- 51e. Phones: one column; items as cards (components.css 50a); totals, then notes ---------- */
@media (max-width: 575.98px) {
    .cs-doc-sheet {
        padding: 0.9rem;
    }

    .cs-doc-top,
    .cs-doc-blocks,
    .cs-doc-foot {
        grid-template-columns: minmax(0, 1fr);
    }

    .cs-doc-meta {
        grid-column: auto;
        order: -1;
        text-align: left;
    }

    .cs-doc-meta-list {
        justify-content: start;
    }

    .cs-doc-logo-wrap {
        text-align: left;
    }

    .cs-doc-logo {
        max-height: 6rem;   /* smaller on a phone so the quote starts sooner */
    }

    .cs-doc-title {
        font-size: 1.4rem;
    }

    /* Item cards: tinted, white gap between them, the amount in gold */
    .cs-doc-lines tbody tr {
        margin-bottom: 2px;
        background: var(--cs-blue-100);
        border-bottom: none;
    }

        .cs-doc-lines tbody tr:last-child {
            border-bottom: 2px solid var(--cs-navy);
        }

    .cs-doc-lines tbody td,
    .cs-doc-lines tbody td.cs-doc-line-total {
        background: transparent;
    }

    .cs-doc-notes {
        order: 2;
        margin-top: 0.5rem;
        border-right: none;
    }

    .cs-doc-totals {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

/* Printing: keep the screen layout, drop the card frame, keep the colors */
@media print {
    .cs-doc-sheet {
        padding: 0;
        border: none;
        box-shadow: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}



/* ==========================================================================
52. QUOTE / INVOICE STATUS PANEL (top of the page: status, the next step, PDF buttons, record a payment, "More")
========================================================================== */
.cs-status-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem 1.25rem;
    align-items: center;
    margin-bottom: var(--cs-gap);
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--cs-navy);
    box-shadow: var(--cs-shadow-sm);
}

.cs-status-panel-main {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

/* A bigger status badge than the one in tables */
.cs-status-badge.cs-status-lg {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.cs-status-panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--cs-heading);
}

.cs-status-panel-text {
    font-size: 0.88rem;
    color: var(--cs-muted);
}

.cs-status-panel-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

    .cs-status-panel-actions .cs-inline-form {
        gap: 0.5rem;
    }

/* "Change status": tucked away, for fixing mistakes */
.cs-status-panel-more {
    grid-column: 1 / -1;
    padding-top: 0.6rem;
    font-size: 0.85rem;
    border-top: 1px dashed var(--cs-border);
}

    .cs-status-panel-more summary {
        width: fit-content;
        cursor: pointer;
        font-weight: 600;
        color: var(--cs-muted);
    }

.cs-status-panel-all {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

/* Phones: one column, the next-step buttons full width */
@media (max-width: 575.98px) {
    .cs-status-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .cs-status-panel-actions,
    .cs-status-panel-actions .cs-inline-form,
    .cs-status-panel-actions .btn {
        width: 100%;
    }

    .cs-status-panel-actions .cs-inline-form {
        flex-direction: column;
    }

    .cs-status-panel-actions .btn {
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
    }
}

/* ---------- 52b. Invoice: "Record a payment" box inside the panel (shaded, gold edge like the document boxes) ---------- */
.cs-pay-box {
    grid-column: 1 / -1;
    padding: 0.75rem 1rem;
    background: var(--cs-blue-50);
    border-left: 3px solid var(--cs-gold);
    border-radius: 0 var(--cs-radius-md) var(--cs-radius-md) 0;
}

.cs-pay-box-title {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cs-heading);
}

    .cs-pay-box-title span {
        font-size: 1rem;
        letter-spacing: 0;
        text-transform: none;
    }

/* Date | Method | Mark Paid on one line, wrapping on small screens */
.cs-pay-box-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

    .cs-pay-box-fields > div {
        flex: 1 1 11rem;
    }

    .cs-pay-box-fields .form-label {
        margin-bottom: 0.2rem;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--cs-muted);
    }

/* ---------- 52c. Top row as three boxes: status (+ Change status / More) | email history | buttons ----------
   Wide screens: three across. Tablets: status + email side by side, buttons full width under them. Phones: stacked. */
/* One gray panel behind the three white boxes, setting them apart from the white sheet below */
.cs-doc-top-row {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(17rem, 0.9fr);
    gap: 1rem;
    align-items: stretch;
    margin-bottom: var(--cs-gap);
    padding: 0.85rem;
    background: var(--cs-gray-300);
    border: 1px solid var(--cs-gold);   /* thin gold frame, same as the sheet below */
    border-radius: var(--cs-radius-lg);
}

.cs-top-box {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0;
    padding: 0.9rem 1.1rem;
    border-left: 4px solid var(--cs-navy);
    box-shadow: var(--cs-shadow-sm);
}

.cs-top-email {
    border-left-color: var(--cs-gold);
}

/* Quotes and invoices: all three boxes get the gold edge (status and buttons too) */
.cs-doc-top-row-gold .cs-top-box {
    border-left-color: var(--cs-gold);
}

    /* The history fills its box (no second border inside it) */
    .cs-top-email .cs-email-history {
        margin: 0;
        padding: 0;
        background: none;
        border: none;
    }

.cs-email-history-none {
    margin: 0;
    font-size: 0.88rem;
    color: var(--cs-muted);
}

/* Status box: "Change status" / "More" at the bottom of the box */
.cs-top-status .cs-status-panel-more {
    margin-top: auto;
}

/* Buttons box: two across, same size */
.cs-top-actions {
    justify-content: center;
}

    .cs-top-actions .cs-status-panel-actions {
        justify-content: stretch;
    }

        .cs-top-actions .cs-status-panel-actions > .btn,
        .cs-top-actions .cs-status-panel-actions > .cs-inline-form {
            flex: 1 1 calc(50% - 0.25rem);
        }

        .cs-top-actions .cs-status-panel-actions .cs-inline-form {
            display: flex;
            gap: 0.5rem;
        }

            .cs-top-actions .cs-status-panel-actions .cs-inline-form .btn {
                flex: 1 1 0;
            }

        /* Buttons in the box are white with a navy outline; the main next step (View Invoice, Email to Client,
           Create Invoice) stays solid navy, and Mark Accepted / Declined keep green / red */
        .cs-top-actions .btn-action {
            background-color: var(--cs-surface) !important;
            border-color: var(--cs-navy) !important;
            color: var(--cs-heading) !important;
            font-weight: 600;
        }

            .cs-top-actions .btn-action:hover {
                background-color: var(--cs-blue-50) !important;
                border-color: var(--cs-gold) !important;
                color: var(--cs-heading) !important;
            }

        /* A form with two buttons (Mark Accepted | Mark Declined) gets the whole row */
        .cs-top-actions .cs-status-panel-actions .cs-inline-form:has(> .btn + .btn) {
            flex-basis: 100%;
        }

/* Invoice: "Record a payment" as its own full-width box under the three */
.cs-pay-box.cs-pay-box-row {
    margin-bottom: var(--cs-gap);
    border-radius: var(--cs-radius-md);
    box-shadow: var(--cs-shadow-sm);
}

@media (max-width: 1199.98px) {
    .cs-doc-top-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cs-top-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 767.98px) {
    .cs-doc-top-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* "Change status:" label in the More section */
.cs-status-panel-label {
    align-self: center;
    font-size: 0.82rem;
    color: var(--cs-muted);
}

@media (max-width: 575.98px) {
    .cs-pay-box-fields > div,
    .cs-pay-box-fields .btn {
        flex: 1 1 100%;
        width: 100%;
    }
}



/* ==========================================================================
65. CHANGE ORDER FORM (Views/ChangeOrders/Form; js/changeorders.js)
What the extra work is, its priced lines (stacked on phones), tax and live totals.
========================================================================== */
.cs-co-page {
    display: flex;
    flex-direction: column;
    gap: var(--cs-gap);
    max-width: 62rem;
}

.cs-co-head {
    padding: 0.9rem 1.25rem;
    border-left: 4px solid var(--cs-gold);
    box-shadow: var(--cs-shadow-sm);
}

.cs-co-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--cs-heading);
}

.cs-co-sub {
    font-size: 0.9rem;
    color: var(--cs-muted);
}

.cs-co-form {
    padding: 1rem 1.25rem;
    box-shadow: var(--cs-shadow-sm);
}

.cs-co-section {
    margin: 0.75rem 0 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--cs-heading);
}

/* "+ Add from your Material Library" | "+ Add a line" */
.cs-co-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.cs-co-material {
    flex: 0 1 26rem;
}

.cs-co-lines td,
.cs-co-lines th {
    vertical-align: middle;
}

.cs-co-num {
    width: 8rem;
    text-align: right;
}

.cs-co-unit {
    width: 7rem;
}

.cs-co-labor {
    width: 4.5rem;
    text-align: center;
}

.cs-co-del {
    width: 2.5rem;
    text-align: right;
}

.cs-co-line-total {
    font-weight: 600;
    white-space: nowrap;
}

/* Tax on the left, totals on the right */
.cs-co-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.9rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--cs-border);
}

.cs-co-tax {
    max-width: 12rem;
}

.cs-co-totals {
    display: grid;
    grid-template-columns: auto 8rem;
    gap: 0.25rem 1rem;
    margin: 0;
    text-align: right;
}

    .cs-co-totals dt {
        font-weight: 600;
        color: var(--cs-muted);
    }

    .cs-co-totals dd {
        margin: 0;
        font-variant-numeric: tabular-nums;
    }

    .cs-co-totals .cs-co-grand {
        padding-top: 0.25rem;
        font-size: 1.1rem;
        font-weight: 800;
        color: var(--cs-heading);
        border-top: 2px solid var(--cs-gold);
    }

.cs-co-labor-option {
    font-weight: 700;
}

.cs-co-actions,
.cs-co-nolabor-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Phones: each line becomes a small card (cs-stack-table, components.css 50a); boxes full width */
@media (max-width: 575.98px) {
    .cs-co-num,
    .cs-co-unit,
    .cs-co-labor,
    .cs-co-del {
        width: auto;
        text-align: left;
    }

    .cs-co-foot {
        flex-direction: column;
        align-items: stretch;
    }

    .cs-co-tax {
        max-width: none;
    }

    .cs-co-actions .btn {
        flex: 1 1 0;
    }
}


/* ==========================================================================
66. RETAINAGE ON INVOICE DETAILS (Services/Retainage; Views/Invoices/Details)
========================================================================== */
/* "due now; $1,000 retainage held" beside the amount in a pay box */
.cs-pay-box-note {
    flex-basis: 100%;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--cs-muted);
}

/* "Retainage paid 10/9/2026. Undo" (admins) */
.cs-retainage-undo {
    margin-bottom: var(--cs-gap);
    font-size: 0.85rem;
    color: var(--cs-muted);
}