/* business.css - Business Management System Styles */

/* ============================================
   Layout & Container Styles
   ============================================ */

#edit-page {
    /* Layout from .main (translucent area + side margins) and .container (max-width + padding) */
}

.top-sections {
    display: flex;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.left-section,
.right-section {
    flex: 1;
    min-width: 260px;
    max-width: 480px;
}

.left-section {
    display: flex;
    flex-direction: column;
}

/* Right-align the right section */
.right-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Right-align the quote details table */
.quote-details {
    text-align: right;
    margin-right: 0;
}

.quote-details th {
    text-align: right;
}

.quote-details td {
    text-align: right;
}

/* Right-align input/select content in quote details (Issue Date, Lead Time, logistics) to match Quote #, Created, Last Updated */
.quote-details input[type="date"],
.quote-details input[type="number"],
.quote-details input[type="text"],
.quote-details select {
    text-align: right;
    text-align-last: right;
}

.timestamp-cell {
    font-size: 0.9em;
    color: var(--text-muted, #666);
}

.record-right-meta {
    margin-top: auto;
    align-self: stretch;
    text-align: right;
}

.record-right-meta .record-relationship-meta {
    margin-top: 0;
}

.record-right-meta .record-audit-meta {
    margin: 4px 0 0;
    padding: 0;
}

.record-address-selectors {
    margin-top: 6px;
}

.record-address-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin-bottom: 0;
}

.record-address-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.record-address-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark, #495057);
    line-height: 1.3;
}

.record-address-selectors select,
.record-address-select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid var(--header-table-border, #ced4da);
    border-radius: 3px;
    background-color: var(--background-card, #fff);
    color: var(--text-dark, #333);
    font-family: inherit;
}

.record-address-selectors select:focus,
.record-address-select:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: 0 0 0 2px rgba(175, 100, 100, 0.2);
}

.record-address-preview {
    min-height: 2.5rem;
    margin: 0;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-dark, #495057);
    background: var(--background-muted, #f8f9fa);
    border: 1px solid var(--header-table-border, #e9ecef);
    border-radius: 3px;
}

.record-address-preview-placeholder,
.record-address-preview-incomplete {
    color: var(--text-muted, #6c757d);
    font-style: italic;
}

.record-address-preview-incomplete a {
    font-style: normal;
    font-weight: 600;
    color: var(--text-dark, #343a40);
}

.record-address-empty {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted, #6c757d);
    line-height: 1.4;
}

.record-address-empty a {
    color: var(--text-dark, #343a40);
    font-weight: 600;
}

[data-theme="dark"] .record-address-label {
    color: var(--text-dark, #d0d0d0);
}

[data-theme="dark"] .record-address-selectors select,
[data-theme="dark"] .record-address-select,
[data-theme="dark"] #invoice_address_id,
[data-theme="dark"] #delivery_address_id {
    color-scheme: dark;
    background-color: var(--background-card, #1e1e1e);
    border-color: var(--border-color, #404040);
    color: var(--text-dark, #f5f5f5);
}

[data-theme="dark"] .record-address-selectors select:focus,
[data-theme="dark"] .record-address-select:focus,
[data-theme="dark"] #invoice_address_id:focus,
[data-theme="dark"] #delivery_address_id:focus {
    background-color: #2a2a2a;
    border-color: var(--brand-color, #af6464);
    box-shadow: 0 0 0 2px rgba(175, 100, 100, 0.2);
}

[data-theme="dark"] .record-address-selectors select option {
    background-color: #1e1e1e;
    color: #f5f5f5;
}

[data-theme="dark"] .record-address-preview {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--header-table-border, #444);
    color: var(--text-muted, #b0b0b0);
}

[data-theme="dark"] .record-address-empty,
[data-theme="dark"] .record-address-empty a,
[data-theme="dark"] .record-address-preview-incomplete a {
    color: var(--text-muted, #b0b0b0);
}

@media (max-width: 520px) {
    .record-address-grid {
        grid-template-columns: 1fr;
    }
}

.record-relationship-meta {
    margin-top: 2px;
}

.record-relationship-meta a {
    color: var(--text-dark, #343a40);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.record-relationship-meta a:hover {
    color: var(--text-dark, #212529);
}

[data-theme="dark"] .record-relationship-meta a {
    color: var(--text-dark, #d8d8d8);
}

[data-theme="dark"] .record-relationship-meta a:hover {
    color: #fff;
}

.record-audit-meta {
    margin: 6px 0 0;
    padding: 0 2px;
    font-size: 0.85em;
    color: var(--text-muted, #6c757d);
    text-align: right;
    line-height: 1.4;
}

[data-theme="dark"] .record-audit-meta {
    color: var(--text-muted, #b0b0b0);
}

/* Quote currency block: below the quote-details table, right-aligned */
.quote-currency-block {
    margin-top: 4px;
    padding: 4px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    justify-content: flex-end;
    color: var(--text-dark, #212529);
}
.quote-currency-block .quote-currency-label {
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #6c757d);
    margin: 0;
}
.quote-currency-block .quote-currency-select {
    min-width: 6em;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    background: var(--background-white, #fff);
    color: var(--text-dark, #212529);
    font-size: 14px;
}
.quote-currency-block .quote-rate-info {
    color: var(--text-muted, #6c757d);
    font-size: 13px;
}
.quote-currency-block .quote-rate-input,
.quote-currency-block .quote-rate-date {
    width: 90px;
    padding: 6px 8px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    background: var(--background-white, #fff);
    color: var(--text-dark, #212529);
    font-size: 14px;
    text-align: right;
}
.quote-currency-block .quote-rate-date {
    width: 130px;
}

[data-theme="dark"] .quote-currency-block {
    color: var(--text-dark, #e0e0e0);
}
[data-theme="dark"] .quote-currency-block .quote-currency-label {
    color: var(--text-muted, #b0b0b0);
}
[data-theme="dark"] .quote-currency-block .quote-currency-select {
    border-color: var(--text-muted, #b0b0b0);
    background: var(--background-white, #1a1a1a);
    color: var(--text-dark, #e0e0e0);
}
[data-theme="dark"] .quote-currency-block .quote-rate-info {
    color: var(--text-muted, #b0b0b0);
}
[data-theme="dark"] .quote-currency-block .quote-rate-input,
[data-theme="dark"] .quote-currency-block .quote-rate-date {
    border-color: var(--text-muted, #b0b0b0);
    background: var(--background-white, #1a1a1a);
    color: var(--text-dark, #e0e0e0);
}
[data-theme="dark"] .quote-currency-block .quote-rate-input:focus,
[data-theme="dark"] .quote-currency-block .quote-rate-date:focus,
[data-theme="dark"] .quote-currency-block .quote-currency-select:focus {
    background: #2a2a2a;
    border-color: var(--brand-color, #af6464);
}

.item-table-section {
    margin-bottom: 30px;
    width: 100%;
    overflow-x: auto;
}

.delivery-packages-section {
    margin: 0;
    width: 100%;
    min-width: 0;
}
.delivery-packages-header {
    margin-bottom: 0.65rem;
}
.delivery-packages-heading {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}
.delivery-packages-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.delivery-package-card {
    border: 1px solid var(--border-color, #d8d8d8);
    border-radius: 6px;
    background: var(--background-card, #fff);
    padding: 0.45rem 0.55rem 0.5rem;
}
[data-theme="dark"] .delivery-package-card {
    background: color-mix(in srgb, var(--background-card, #1e1e1e) 100%, #000);
    border-color: #3a3a3a;
}
.delivery-package-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.delivery-package-card-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    opacity: 0.65;
}
.package-card-summary {
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: none;
    opacity: 0.9;
}
.delivery-package-card-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}
.delivery-package-card-actions .pkg-pack-remaining {
    font-size: 0.78rem;
    padding: 0.2rem 0.55rem;
    line-height: 1.2;
}
.delivery-package-meta {
    display: grid;
    grid-template-columns: 5rem 7rem 3.6rem 3.6rem 3.6rem 4.6rem;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
    align-items: end;
}
.delivery-package-field {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    min-width: 0;
    margin: 0;
}
.delivery-package-field > span {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.6;
    font-weight: 600;
}
.delivery-package-field input,
.delivery-package-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.28rem 0.4rem;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    background: var(--input-bg, #fff);
    color: inherit;
    font: inherit;
    font-size: 0.9rem;
}
.delivery-package-field .pkg-qty,
.delivery-package-field .pkg-weight,
.delivery-package-field .pkg-length,
.delivery-package-field .pkg-width,
.delivery-package-field .pkg-height {
    text-align: right;
}
.delivery-package-field--type select.pkg-type {
    text-align: left;
}
.delivery-package-readonly {
    display: block;
    padding: 0.28rem 0;
    min-height: 1.25rem;
    font-size: 0.9rem;
}
.delivery-package-alloc {
    margin: 0;
}
.pkg-alloc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.pkg-alloc-table th {
    text-align: left;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.6;
    font-weight: 600;
    padding: 0 0.25rem 0.2rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.pkg-alloc-table td {
    padding: 0.2rem 0.25rem;
    vertical-align: middle;
}
.pkg-alloc-each-col {
    width: 5.25rem;
}
.pkg-alloc-total-col {
    width: 3.5rem;
    text-align: right;
}
.pkg-alloc-total,
.pkg-alloc-composer-total {
    display: inline-block;
    min-width: 1.5rem;
    font-variant-numeric: tabular-nums;
}
.pkg-alloc-actions-col {
    width: 2.75rem;
    text-align: right;
}
.pkg-alloc-table input[type="number"],
.pkg-alloc-table select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.25rem 0.35rem;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    background: var(--input-bg, #fff);
    color: inherit;
    font: inherit;
    font-size: 0.85rem;
}
.pkg-alloc-table input[type="number"] {
    text-align: right;
}
.pkg-alloc-composer td {
    padding-top: 0.35rem;
}
.pkg-alloc-add.btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.45rem;
    line-height: 1.2;
}
.pkg-alloc-remove {
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.5;
    border: none;
    background: transparent;
    cursor: pointer;
    color: inherit;
    padding: 0 0.15rem;
}
.pkg-alloc-remove:hover {
    opacity: 1;
}
.pkg-alloc-empty {
    font-size: 0.8rem;
}
.pkg-pack-note {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    line-height: 1.35;
    color: #9a6700;
}
[data-theme="dark"] .pkg-pack-note {
    color: #e3b341;
}
@media (max-width: 720px) {
    .delivery-package-meta {
        grid-template-columns: 5rem 1fr 1fr;
    }
    .delivery-package-field--type {
        grid-column: 2 / -1;
    }
}
.delivery-packages-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.75rem;
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border-color, #ddd);
    font-size: 0.9rem;
}
.delivery-packages-footer-summary {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.35rem;
}
.delivery-packages-footer-sep {
    opacity: 0.45;
    margin: 0 0.1rem;
}
.delivery-packages-alloc-status {
    font-size: 0.85rem;
    opacity: 0.8;
}
.delivery-packages-alloc-status.is-warn {
    color: #b45309;
    opacity: 1;
}
.delivery-packages-alloc-status.is-ok {
    color: #15803d;
    opacity: 1;
}
.delivery-packages-alloc-status.is-error {
    color: #b91c1c;
    opacity: 1;
}
.sales-items-table th.weight-col,
.sales-items-table td.weight-col {
    width: 5.5rem;
    text-align: right;
    white-space: nowrap;
}
.sales-items-table td.weight-col .delivery-line-unit-weight {
    width: 4.75rem;
    max-width: 100%;
    text-align: right;
    padding: 0.25rem 0.35rem;
}
.pkg-dims-hint {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    color: #b45309;
}
[data-theme="dark"] .pkg-dims-hint {
    color: #fbbf24;
}
.delivery-packages-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.65rem;
}
.delivery-packages-empty {
    padding: 0.75rem 0.25rem;
    opacity: 0.7;
    font-style: italic;
}
.delivery-edit-page .delivery-logistics-field {
    width: 100%;
    box-sizing: border-box;
}

.delivery-edit-page .edit-table-header select.delivery-logistics-field {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 4px 8px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 0;
    font-size: 14px;
    background-color: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
    text-align: right;
    text-align-last: right;
}

.delivery-edit-page .edit-table-header select.delivery-logistics-field:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 25%, transparent);
}

[data-theme="dark"] .delivery-edit-page .edit-table-header select.delivery-logistics-field {
    background-color: var(--background-card, #1a1a1a);
    color: var(--text-dark, #e8e8e8);
    border-color: var(--header-table-border, #555);
}
.delivery-package-card .package-remove-row {
    font-size: 1.25rem;
    line-height: 1;
    border: none;
    background: transparent;
    cursor: pointer;
    color: inherit;
    opacity: 0.45;
    padding: 0 0.15rem;
}
.delivery-package-card .package-remove-row:hover {
    opacity: 1;
}
.delivery-bottom-left {
    flex: 1 1 0;
    min-width: 0;
    max-width: calc(100% - 440px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.delivery-notes-under-packages {
    margin: 0;
}
.delivery-notes-under-packages textarea {
    width: 100%;
    min-height: 4.5rem;
    box-sizing: border-box;
}

@media (max-width: 960px) {
    .delivery-bottom-left {
        max-width: 100%;
    }
    .delivery-edit-page .sales-notes-summary,
    .convert-order-page .sales-notes-summary {
        flex-direction: column;
    }
}

.sales-notes-summary {
    display: flex;
    flex-direction: row;
    gap: 40px;
    margin-top: 30px;
    max-width: 100%;
    justify-content: space-between;
    align-items: flex-start;
}

.sales-notes-summary .notes {
    flex: 1 1 0;
    margin-right: 20px;
}

.sales-notes-summary .summary {
    flex: 0 0 400px !important;
    max-width: 400px !important;
    min-width: 350px !important;
    width: 400px !important;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Summary card shrinks to its content width; full-width flex default would stretch it to 400px. */
.sales-notes-summary .summary > .summary-box {
    align-self: flex-end;
}

.sales-notes-summary .summary > .summary-actions {
    align-self: stretch;
    width: 100%;
}

.summary-actions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.summary-actions-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.summary-actions-cancel-form {
    display: contents;
}

.summary-actions-btn {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.25;
    white-space: normal;
    background: var(--brand-color, rgb(175, 100, 100));
    color: var(--text-light, #ffffff);
    border: 1px solid color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 88%, #000);
}

.summary-actions-btn:hover {
    background: color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 90%, #000);
    color: var(--text-light, #ffffff);
}

.summary-actions-btn:focus-visible {
    outline: 2px solid var(--brand-color, rgb(175, 100, 100));
    outline-offset: 2px;
}

.summary-actions-btn--full {
    grid-column: 1 / -1;
}

.summary-actions-btn--destructive {
    background: #fff;
    color: #c5221f;
    border-color: #c5221f;
}

.summary-actions-btn--destructive:hover {
    background: #fce8e6;
    color: #a50e0e;
}

.summary-actions-btn-wrap {
    display: block;
    width: 100%;
    min-width: 0;
}

.summary-actions-btn-wrap--disabled {
    cursor: not-allowed;
}

.summary-actions-btn-wrap--disabled .summary-actions-btn:disabled {
    pointer-events: none;
}

.summary-actions-btn--destructive:disabled,
.summary-actions-btn-wrap--disabled .summary-actions-btn--destructive {
    background: var(--background-muted, #f1f3f4);
    color: #9aa0a6;
    border-color: #dadce0;
    opacity: 1;
    cursor: not-allowed;
}

.summary-actions-btn--secondary {
    background: var(--background-card, #fff);
    color: var(--text-dark, #333);
    border-color: var(--border-color, #ced4da);
}

.summary-actions-btn--secondary:hover {
    background: var(--background-muted, #f8f9fa);
    color: var(--text-dark, #333);
}

.delivery-summary-heading {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 600;
}

.delivery-invoice-totals {
    margin-bottom: 8px;
}

.delivery-invoice-totals-summary {
    cursor: pointer;
    font-size: 0.92rem;
    color: var(--text-muted, #6c757d);
    margin-bottom: 6px;
    list-style: none;
}

.delivery-invoice-totals-summary::-webkit-details-marker {
    display: none;
}

.delivery-invoice-totals[open] .delivery-invoice-totals-summary {
    margin-bottom: 8px;
}

.delivery-pdf-more {
    margin-top: 10px;
}

.delivery-pdf-more-summary {
    cursor: pointer;
    font-size: 0.92rem;
    color: var(--text-muted, #6c757d);
    margin-bottom: 8px;
    list-style: none;
    user-select: none;
}

.delivery-pdf-more-summary--button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    min-height: 0;
    text-align: center;
    color: var(--text-light, #ffffff);
    background: var(--brand-color, rgb(175, 100, 100));
    border: 1px solid color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 88%, #000);
}

.delivery-pdf-more-summary--button:hover {
    background: color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 90%, #000);
    color: var(--text-light, #ffffff);
}

.delivery-pdf-more-summary-label {
    flex: 1 1 auto;
    text-align: center;
}

.delivery-pdf-more-summary::-webkit-details-marker {
    display: none;
}

.delivery-pdf-more-summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 0;
    transition: transform 0.15s ease;
}

.delivery-pdf-more[open] > .delivery-pdf-more-summary::before {
    transform: rotate(90deg);
}

.delivery-pdf-more-grid {
    margin-top: 4px;
}

.delivery-pdf-doc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 4px;
    overflow: hidden;
    background: var(--background-card, #fff);
}

.delivery-pdf-doc-item + .delivery-pdf-doc-item {
    border-top: 1px solid var(--border-color, #dee2e6);
}

.delivery-pdf-doc-row {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.delivery-pdf-doc-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    text-decoration: none;
    color: var(--text-dark, #333);
    font-size: 0.92rem;
    line-height: 1.25;
}

.delivery-pdf-doc-link:hover {
    background: var(--background-muted, #f8f9fa);
    color: var(--text-dark, #333);
}

.delivery-pdf-doc-label {
    min-width: 0;
}

.delivery-pdf-doc-required {
    flex: 0 0 auto;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--brand-color, rgb(175, 100, 100));
}

.delivery-pdf-doc-actions {
    display: flex;
    align-items: stretch;
    flex: 0 0 auto;
    border-left: 1px solid var(--border-color, #dee2e6);
}

.delivery-pdf-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted, #6c757d);
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
}

.delivery-pdf-icon-btn + .delivery-pdf-icon-btn {
    border-left: 1px solid var(--border-color, #dee2e6);
}

.delivery-pdf-icon-btn:hover {
    background: var(--background-muted, #f8f9fa);
    color: var(--text-dark, #333);
}

.delivery-pdf-icon-btn--on-summary {
    width: 1.25em;
    height: 1.25em;
    min-height: 0;
    flex: 0 0 auto;
    border-radius: 3px;
    font-size: 12px;
    line-height: 1;
    color: var(--text-light, #ffffff);
}

.delivery-pdf-icon-btn--on-summary:hover {
    background: rgba(255, 255, 255, 0.18);
    color: var(--text-light, #ffffff);
}

[data-theme="dark"] .delivery-pdf-doc-list {
    background: var(--background-card, #1e1e1e);
    border-color: var(--border-color, #3c4043);
}

[data-theme="dark"] .delivery-pdf-doc-item + .delivery-pdf-doc-item {
    border-top-color: var(--border-color, #3c4043);
}

[data-theme="dark"] .delivery-pdf-doc-link {
    color: var(--text-dark, #e8eaed);
}

[data-theme="dark"] .delivery-pdf-doc-link:hover {
    background: var(--background-muted, #2a2a2a);
    color: var(--text-dark, #e8eaed);
}

[data-theme="dark"] .delivery-pdf-doc-required {
    color: #f28b82;
}

[data-theme="dark"] .delivery-pdf-doc-actions {
    border-left-color: var(--border-color, #3c4043);
}

[data-theme="dark"] .delivery-pdf-icon-btn {
    color: var(--text-muted, #9aa0a6);
}

[data-theme="dark"] .delivery-pdf-icon-btn:hover {
    background: var(--background-muted, #2a2a2a);
    color: var(--text-dark, #e8eaed);
}

[data-theme="dark"] .delivery-pdf-icon-btn + .delivery-pdf-icon-btn {
    border-left-color: var(--border-color, #3c4043);
}

/* Delivery edit: packages sit left of summary — keep side-by-side layout */
.delivery-edit-page .sales-notes-summary:not(:has(.delivery-bottom-left)) {
    justify-content: flex-end;
}

.delivery-edit-page .sales-notes-summary {
    padding-bottom: 1.5rem;
}

.delivery-edit-page .sales-notes-summary .summary {
    align-items: stretch;
    width: min(400px, 100%) !important;
    max-width: min(400px, 100%) !important;
    min-width: 0 !important;
    flex: 0 0 auto;
}

.delivery-edit-page .delivery-summary-heading {
    text-align: right;
}

.delivery-edit-page .summary-actions:not(.delivery-summary-actions) .summary-actions-grid > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.delivery-edit-page .summary-actions + .summary-actions.delivery-summary-actions {
    margin-top: 0;
    padding-top: 8px;
    border-top: none;
}

.edit-table-header.quote-details td.record-delivery-progress-cell {
    padding: 4px 8px;
    vertical-align: middle;
}

.record-delivery-progress-inner {
    display: block;
    font-size: 14px;
    line-height: 1.35;
    max-width: 100%;
    text-align: right;
}

#items-table[data-qty-delivered-hover] th.qty-col {
    cursor: help;
}

/* Order qty + hover delivered: wrapper fills cell like a bare quantity input (quotations) */
.sales-items-table td.qty-col .order-line-qty-cell {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.order-line-qty-delivered {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 4px 6px;
    font-size: 12px;
    font-family: inherit;
    line-height: 1.35;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted, #6c757d);
}

.order-line-qty-delivered--complete {
    color: var(--status-success-text, #2e7d32);
    font-weight: 600;
}

#items-table[data-qty-delivered-hover].qty-col--show-delivered th.qty-col {
    background-color: var(--background-muted, #f0f1f3);
}

#items-table[data-qty-delivered-hover].qty-col--show-delivered td.qty-col {
    background-color: var(--background-muted, #f0f1f3);
    overflow: hidden;
}

#items-table[data-qty-delivered-hover].qty-col--show-delivered td.qty-col .order-line-qty-ordered {
    display: none;
}

#items-table[data-qty-delivered-hover].qty-col--show-delivered td.qty-col .order-line-qty-delivered {
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .order-line-qty-delivered {
    color: var(--text-muted, #9aa0a6);
}

[data-theme="dark"] .order-line-qty-delivered--complete {
    color: #81c995;
}

[data-theme="dark"] #items-table[data-qty-delivered-hover].qty-col--show-delivered th.qty-col {
    background-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] #items-table[data-qty-delivered-hover].qty-col--show-delivered td.qty-col {
    background-color: rgba(255, 255, 255, 0.06);
}

.record-delivery-progress-summary {
    color: var(--text-dark, #333);
}

.record-delivery-progress-summary--muted {
    color: var(--text-muted, #6c757d);
    font-size: 12px;
}

.record-delivery-progress-sep {
    color: var(--text-muted, #6c757d);
    font-weight: 400;
}

/* Meta links in edit header panels (source quote/order #, deliveries list, etc.) */
.record-quote-status-value a,
.record-delivery-link {
    color: var(--brand-color, rgb(175, 100, 100));
    font-weight: 600;
    text-decoration: none;
}

.record-quote-status-value a:hover,
.record-delivery-link:hover {
    text-decoration: underline;
}

[data-theme="dark"] .record-delivery-progress-summary {
    color: var(--text-dark, #e8eaed);
}

[data-theme="dark"] .record-delivery-progress-sep {
    color: var(--text-muted, #9aa0a6);
}

[data-theme="dark"] .record-quote-status-value a,
[data-theme="dark"] .record-delivery-link {
    color: #f28b82;
}

[data-theme="dark"] .record-quote-status-value a:hover,
[data-theme="dark"] .record-delivery-link:hover {
    color: #f6aea8;
}

.summary-actions-hint {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted, #6c757d);
    text-align: right;
}

/* Override generic .btn border reset so destructive/secondary variants keep their outline */
.summary-actions .btn.summary-actions-btn {
    border: 1px solid color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 88%, #000);
}

.summary-actions .btn.summary-actions-btn--destructive {
    border: 1px solid #c5221f;
}

.summary-actions .btn.summary-actions-btn--secondary {
    border: 1px solid var(--border-color, #ced4da);
}

.edit-table-header td.record-quote-status-cell,
.edit-table-header td.record-order-status-cell {
    padding: 4px 8px;
    text-align: right;
    vertical-align: middle;
}

.record-quote-status-value {
    font-size: 14px;
    color: var(--text-dark, #333);
}

.record-quote-status-value--muted {
    color: var(--text-muted, #6c757d);
}

.record-contacts-cell {
    vertical-align: middle;
}

.edit-table-header td.record-contacts-cell {
    padding: 3px 6px;
    vertical-align: middle;
}

/* Compact chips; scroll inside cell when many contacts so the header row stays bounded */
.record-contacts-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    gap: 4px;
    min-height: 24px;
    max-height: 4.75rem;
    padding: 1px 0;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
}

.record-contact-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 1 auto;
    max-width: min(100%, 11rem);
    padding: 1px 4px 1px 7px;
    border: 1px solid color-mix(in srgb, var(--border-color, #ced4da) 82%, var(--text-dark, #000));
    border-radius: 999px;
    background: color-mix(in srgb, var(--background-muted, #f8f9fa) 88%, #fff);
    color: var(--text-dark, #333);
    font-size: 12px;
    line-height: 1.25;
}

.record-contact-pill--primary {
    border-color: var(--brand-color, rgb(175, 100, 100));
    background: color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 18%, #fff);
    font-weight: 600;
    box-shadow: inset 2px 0 0 0 var(--brand-color, rgb(175, 100, 100));
    padding-left: 6px;
}

.record-contact-pill:not(.record-contact-pill--primary) {
    cursor: pointer;
}

.record-contact-pill-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-contact-pill-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: color-mix(in srgb, var(--text-muted, #6c757d) 85%, var(--text-dark, #000));
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.record-contact-pill-remove:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-dark, #333);
}

.record-contacts-add-input {
    flex: 1 1 9rem;
    flex-shrink: 0;
    min-width: 9rem;
    max-width: none;
    padding: 2px 6px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 0;
    background-color: var(--background-card, #ffffff);
    font-size: 12px;
    line-height: 1.25;
    color: var(--text-dark, #333);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.record-contacts-add-input:focus {
    outline: none;
    border-color: var(--brand-color, #007bff);
    box-shadow: 0 0 0 2px var(--brand-color-light, rgba(0, 123, 255, 0.25));
}

/* Contacts row: do not use full-cell absolute positioning from edit-table-header inputs */
.edit-table-header td.record-contacts-cell .record-contacts-add-input {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    width: auto;
    height: auto;
    margin: 0;
}

[data-theme="dark"] .record-contacts-add-input {
    background-color: var(--background-card, #1e1e1e);
    border-color: var(--header-table-border, #444);
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .record-contact-pill {
    background: #3c4043;
    border-color: #5f6368;
    color: #e8eaed;
}

[data-theme="dark"] .record-contact-pill--primary {
    background: rgba(242, 139, 130, 0.18);
    border-color: #f28b82;
    box-shadow: inset 2px 0 0 0 #f28b82;
}

[data-theme="dark"] .record-contact-pill-remove:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e8eaed;
}

[data-theme="dark"] .summary-actions-btn--destructive {
    background: #1e1e1e;
    color: #f28b82;
    border-color: #f28b82;
}

[data-theme="dark"] .summary-actions-btn--destructive:hover {
    background: #5c1a18;
    color: #fff;
}

[data-theme="dark"] .summary-actions-btn--destructive:disabled,
[data-theme="dark"] .summary-actions-btn-wrap--disabled .summary-actions-btn--destructive {
    background: #3c4043;
    color: #80868b;
    border-color: #5f6368;
}

[data-theme="dark"] .summary-actions-btn--secondary {
    background: #1e1e1e;
    color: #e0e0e0;
    border-color: #555;
}

[data-theme="dark"] .record-quote-status-value {
    color: #e0e0e0;
}

[data-theme="dark"] .summary-actions {
    border-top-color: var(--border-color, #444);
}

[data-theme="dark"] .summary-actions-btn {
    border-color: color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 70%, #fff);
}

[data-theme="dark"] .summary-actions-btn:hover {
    background: color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 82%, #fff);
}

.record-status-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
    vertical-align: middle;
}

.record-status--open {
    background: #e8f0fe;
    color: #1a4b8c;
}

.record-status--ordered {
    background: #e6f4ea;
    color: #137333;
}

.record-status--complete {
    background: #e6f4ea;
    color: #137333;
}

.record-status--cancelled {
    background: #fce8e6;
    color: #c5221f;
}

.record-status--expired {
    background: #f1f3f4;
    color: #5f6368;
}

.record-status-select {
    max-width: 11rem;
}

.edit-table-header td.record-status-cell {
    padding: 0;
    vertical-align: middle;
}

.edit-table-header td.record-status-cell .record-status-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    box-sizing: border-box;
    padding: 0 6px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 0;
    background-color: var(--background-card, #ffffff);
    overflow: hidden;
}

.edit-table-header td.record-status-cell .record-status-inner:focus-within {
    outline: none;
    border-color: var(--brand-color, #007bff);
    box-shadow: 0 0 0 2px var(--brand-color-light, rgba(0, 123, 255, 0.25));
}

.record-status-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.record-status-dot.record-status--open {
    background-color: #1a4b8c;
}

.record-status-dot.record-status--ordered,
.record-status-dot.record-status--complete {
    background-color: #137333;
}

.record-status-dot.record-status--cancelled {
    background-color: #c5221f;
}

.edit-table-header .record-status-select {
    position: static;
    flex: 0 1 auto;
    min-width: 5.25rem;
    max-width: calc(100% - 14px);
    width: auto;
    height: auto;
    align-self: stretch;
    min-height: 100%;
    margin: 0;
    padding: 4px 2px 4px 0;
    border: none;
    border-radius: 0;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.4;
    background-color: transparent;
    color: var(--text-dark, #333);
    box-shadow: none;
    cursor: pointer;
}

.quote-details .record-status-select {
    text-align: right;
    text-align-last: right;
}

.edit-table-header .record-status-select:focus {
    outline: none;
    box-shadow: none;
}

.edit-table-header .record-status-select:disabled {
    opacity: 0.85;
    cursor: wait;
}

.record-status-row td.record-status-cell .record-status-message {
    position: absolute;
    top: calc(100% + 2px);
    right: 0;
    margin-top: 0;
    white-space: nowrap;
    z-index: 2;
    font-size: 0.78rem;
}

[data-theme="dark"] .edit-table-header td.record-status-cell .record-status-inner {
    background-color: var(--background-card, #1e1e1e);
    border-color: var(--header-table-border, #444);
}

[data-theme="dark"] .edit-table-header .record-status-select {
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .record-status-dot.record-status--open {
    background-color: #aecbfa;
}

[data-theme="dark"] .record-status-dot.record-status--ordered,
[data-theme="dark"] .record-status-dot.record-status--complete {
    background-color: #81c995;
}

[data-theme="dark"] .record-status-dot.record-status--cancelled {
    background-color: #f28b82;
}

.record-status-message {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-muted, #6c757d);
}

.record-status-hint {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted, #6c757d);
}

.list-filter-form {
    margin: 0 0 1rem;
}

.list-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.92rem;
    cursor: pointer;
}

.record-readonly .auto-save-field:not(.record-status-select),
.record-readonly .item-input-quantity,
.record-readonly .item-input-price,
.record-readonly .item-input-due-date {
    background: #f8f9fa;
    cursor: not-allowed;
}

[data-theme="dark"] .record-status--open {
    background: #1e3a5f;
    color: #aecbfa;
}

[data-theme="dark"] .record-status--ordered,
[data-theme="dark"] .record-status--complete {
    background: #1e4620;
    color: #81c995;
}

[data-theme="dark"] .record-status--cancelled {
    background: #5c1a18;
    color: #f28b82;
}

[data-theme="dark"] .record-status--expired {
    background: #3c4043;
    color: #bdc1c6;
}

/* ============================================
   Table Styles
   ============================================ */

.edit-table-header {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
}

.edit-table-header th {
    text-align: left;
    padding: 4px 10px;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light, #ffffff);
    background-color: var(--brand-color, rgb(175, 100, 100));
    border: 1px solid var(--header-table-border, #a8a8a8);
    width: 28%;
}

.edit-table-header td {
    padding: 0;
    position: relative;
    min-height: 32px;
    border: 1px solid var(--header-table-border, #a8a8a8);
    background-color: var(--background-card, transparent);
    color: var(--text-dark, #333);
}

.edit-table-header td.timestamp-cell {
    padding: 4px 8px;
}

.record-customer-manage-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-muted, #6c757d);
    border: 1px solid transparent;
    border-radius: 3px;
    text-decoration: none;
    line-height: 1;
    transform: translateY(-50%);
}

.record-customer-manage-btn:hover,
.record-customer-manage-btn:focus-visible {
    color: var(--text-dark, #343a40);
    border-color: var(--header-table-border, #ced4da);
    background: var(--background-muted, #f8f9fa);
    outline: none;
}

.record-customer-manage-btn .fa {
    font-size: 13px;
}

.edit-table-header td.record-customer-cell input.record-customer-name-input {
    padding-right: 32px;
}

.edit-table-header td.record-despatch-status-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    padding: 4px 8px;
    min-height: 32px;
}

.edit-table-header td.record-despatch-status-cell .record-despatch-source-order {
    display: block;
    margin-top: 2px;
}

.quote-currency-block--readonly .quote-currency-readonly-value {
    font-size: 14px;
    font-weight: 600;
    display: inline-block;
    min-width: 6em;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    background: var(--background-white, #fff);
    color: var(--text-dark, #212529);
}

[data-theme="dark"] .quote-currency-block--readonly .quote-currency-readonly-value {
    color: var(--text-dark, #e8e8e8);
    background: var(--background-muted, #2a2a2a);
    border-color: var(--header-table-border, #555);
}

.edit-table-header td.record-readonly-field-cell,
.edit-table-header td.record-customer-cell {
    position: relative;
}

.edit-table-header .record-readonly-inline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    margin: 0;
    padding: 4px 8px;
    font-size: 14px;
    line-height: 1.3;
    color: var(--text-dark, #333);
    background-color: var(--background-muted, #f8f9fa);
    border: 1px solid var(--border-color, #ced4da);
}

/* Multi-line PO list must stay in normal flow so the table row can grow. */
.edit-table-header td.record-readonly-field-cell--multiline {
    height: auto;
    min-height: 32px;
}

.edit-table-header tr:has(td.record-readonly-field-cell--multiline) th {
    vertical-align: top;
    padding-top: 8px;
}

.edit-table-header td.record-readonly-field-cell--multiline .record-readonly-inline--stack {
    position: static;
    display: block;
    height: auto;
    min-height: 32px;
    line-height: 1.45;
    white-space: normal;
}

.edit-table-header td.record-customer-cell .record-readonly-inline {
    padding-right: 32px;
}

.record-readonly .edit-table-header .record-readonly-inline {
    cursor: default;
}

[data-theme="dark"] .edit-table-header .record-readonly-inline {
    color: var(--text-dark, #e8e8e8);
    background-color: var(--background-muted, #2a2a2a);
    border-color: var(--header-table-border, #555);
}

[data-theme="dark"] .record-customer-manage-btn {
    color: var(--text-muted, #b0b0b0);
}

[data-theme="dark"] .record-customer-manage-btn:hover,
[data-theme="dark"] .record-customer-manage-btn:focus-visible {
    color: var(--text-dark, #e8e8e8);
    border-color: var(--header-table-border, #555);
    background: var(--background-muted, #2a2a2a);
}

[data-theme="dark"] .edit-table-header th,
[data-theme="dark"] .edit-table-header td {
    border-color: var(--header-table-border, #151515);
}

/* Inputs fill parent cell like items table */
.edit-table-header input[type="text"],
.edit-table-header input[type="date"],
.edit-table-header input[type="number"] {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 4px 8px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 0;
    font-size: 14px;
    background-color: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.edit-table-header input[type="text"]:focus,
.edit-table-header input[type="date"]:focus,
.edit-table-header input[type="number"]:focus {
    outline: none;
    border-color: var(--brand-color, #007bff);
    box-shadow: 0 0 0 2px var(--brand-color-light, rgba(0, 123, 255, 0.25));
}

.sales-items-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--background-card, #ffffff);
    box-shadow: none; /* Match v2_01 - no box-shadow */
    border: 1px solid var(--text-dark, #000000);
    font-size: 15px;
}

/* Outer borders for table - 1px (matching v2_01) */
.sales-items-table {
    border: 1px solid var(--text-dark, #000000) !important;
}

/* Base borders on cells only - dotted grey like v2_01; overrides make outer/row borders solid black */
.sales-items-table td {
    border: 1px dotted var(--text-muted, #cccccc) !important;
}

/* Internal vertical separators - solid for header, dotted for body cells */
.sales-items-table th:not(:last-child) {
    border-right: 1px solid var(--text-dark, #000000) !important; /* Solid for header - more distinct */
}

.sales-items-table td:not(:last-child) {
    border-right: 1px dotted var(--text-muted, #cccccc) !important; /* Dotted for body */
}

/* Internal horizontal separators - solid */
.sales-items-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--text-dark, #000000) !important;
}

/* Outer borders - 1px solid (matching v2_01) */
.sales-items-table th:first-child,
.sales-items-table td:first-child {
    border-left: 1px solid var(--text-dark, #000000) !important;
}

.sales-items-table th:last-child,
.sales-items-table td:last-child {
    border-right: 1px solid var(--text-dark, #000000) !important;
}

.sales-items-table tbody tr:last-child td {
    border-bottom: 1px solid var(--text-dark, #000000) !important;
}

/* Top border for header row - 1px (matching v2_01) */
.sales-items-table thead th {
    border-top: 1px solid var(--text-dark, #000000) !important;
}

/* Dark mode borders - use theme colors (opposite to light mode), opacity 1.0 */
/* --text-dark in dark mode = light (#f5f5f5), --text-muted = grey (#b0b0b0) */
[data-theme="dark"] .sales-items-table {
    border: 1px solid var(--text-muted, #b0b0b0) !important;
}

/* Base cell borders in dark mode */
[data-theme="dark"] .sales-items-table td {
    border-color: var(--text-muted, #b0b0b0) !important;
    color: var(--text-dark, #e0e0e0) !important;
}

/* Header vertical separators in dark mode */
[data-theme="dark"] .sales-items-table th:not(:last-child) {
    border-right: 1px solid var(--text-muted, #b0b0b0) !important;
}

/* Body vertical separators in dark mode - dotted, uses muted */
[data-theme="dark"] .sales-items-table td:not(:last-child) {
    border-right: 1px dotted var(--text-muted, #b0b0b0) !important;
}

/* Internal horizontal separators in dark mode */
[data-theme="dark"] .sales-items-table tbody tr:not(:last-child) td {
    border-bottom-color: var(--text-muted, #b0b0b0) !important;
}

/* Outer borders in dark mode */
[data-theme="dark"] .sales-items-table th:first-child,
[data-theme="dark"] .sales-items-table td:first-child {
    border-left-color: var(--text-muted, #b0b0b0) !important;
}

[data-theme="dark"] .sales-items-table th:last-child,
[data-theme="dark"] .sales-items-table td:last-child {
    border-right-color: var(--text-muted, #b0b0b0) !important;
}

[data-theme="dark"] .sales-items-table tbody tr:last-child td {
    border-bottom-color: var(--text-muted, #b0b0b0) !important;
}

/* Top border for header row in dark mode */
[data-theme="dark"] .sales-items-table thead th {
    border-top-color: var(--text-muted, #b0b0b0) !important;
}

/* Thead border-bottom in dark mode */
[data-theme="dark"] .sales-items-table thead {
    border-bottom-color: var(--text-muted, #b0b0b0) !important;
}

.sales-items-table thead {
    background-color: var(--brand-color, rgb(175, 100, 100));
    border-bottom: 1px solid var(--text-dark, #000000) !important;
}

/* Override .header-content min-height (from style.css) - that rule targets main nav, not table headers */
.sales-items-table thead th .header-content {
    min-height: 0 !important;
    padding: 0 !important;
    gap: 0.25rem;
    justify-content: center;
}

.sales-items-table thead th.details-col {
    text-align: left;
}

.sales-items-table thead th.details-col .header-content {
    justify-content: flex-start;
}

.sales-items-table th {
    padding: 10px 12px !important;
    line-height: 1;
    text-align: center;
    font-weight: bold;
    color: var(--text-light, #ffffff);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    /* Border handled by specific rules above - don't set here to avoid conflicts */
    vertical-align: middle;
    background-color: var(--brand-color, rgb(175, 100, 100)) !important;
}

.sales-items-table td {
    padding: 2px 12px !important; /* Match v2_01 - more compact */
    /* Border handled by specific rules above - don't set here to avoid conflicts */
    vertical-align: middle;
    color: var(--text-dark, #333);
    background: var(--background-card, #ffffff);
    position: relative;
}

/* Total column - currency symbol positioned absolutely, total text flows normally */
.sales-items-table td.total-col {
    position: relative; /* Ensure absolute positioning context for currency symbol */
}

.sales-items-table td.total-col .currency-symbol {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: #c00;
    z-index: 10;
}

.sales-items-table td.total-col .item-total {
    display: inline-block;
    padding-left: 2.3em; /* Make room for currency symbol */
    text-align: right;
    width: 100%;
    box-sizing: border-box;
}

/* Total column styling - red color and bold like v2_01 */
.sales-items-table td.total-col,
.sales-items-table td.total {
    color: #c00 !important;
    font-weight: bold !important;
}

/* Total column elements are red (now directly in td, not in flex container) */
.sales-items-table td.total-col .currency-symbol,
.sales-items-table td.total-col .item-total {
    color: #c00 !important;
}

.sales-items-table td.total-col .item-total {
    font-weight: bold !important;
}

/* Dark mode total column - brighter red for visibility */
[data-theme="dark"] .sales-items-table td.total-col,
[data-theme="dark"] .sales-items-table td.total {
    color: #ff6b6b !important; /* Brighter red for dark mode */
}

[data-theme="dark"] .sales-items-table td.total-col .currency-symbol,
[data-theme="dark"] .sales-items-table td.total-col .item-total {
    color: #ff6b6b !important; /* Brighter red for dark mode */
}

/* Note: border-bottom for last row is handled above */

/* Alternating row colors for better visual separation */
.sales-items-table tbody tr:nth-child(even):not(.add-row) {
    background-color: #e8e8e8 !important;
}

.sales-items-table tbody tr:nth-child(even):not(.add-row) td {
    background-color: #e8e8e8 !important;
}

.sales-items-table tbody tr:nth-child(odd):not(.add-row) {
    background-color: var(--background-card, #ffffff) !important;
}

.sales-items-table tbody tr:nth-child(odd):not(.add-row) td {
    background-color: var(--background-card, #ffffff) !important;
}

/* Dark mode alternating rows - odd soft black, even lighter for clear stripe */
[data-theme="dark"] .sales-items-table tbody tr:nth-child(odd):not(.add-row),
[data-theme="dark"] .sales-items-table tbody tr:nth-child(odd):not(.add-row) td {
    background-color: #111111 !important;
}

[data-theme="dark"] .sales-items-table tbody tr:nth-child(even):not(.add-row),
[data-theme="dark"] .sales-items-table tbody tr:nth-child(even):not(.add-row) td {
    background-color: #2a2a2a !important;
}

/* Hover with slight brand color tint */
.sales-items-table tbody tr:hover:not(.add-row) {
    background-color: color-mix(in srgb, var(--brand-color) 7%, #f8f9fa) !important;
}

.sales-items-table tbody tr:hover:not(.add-row) td {
    background-color: color-mix(in srgb, var(--brand-color) 7%, #f8f9fa) !important;
}

/* Dark mode hover state - visible hover with brand tint */
[data-theme="dark"] .sales-items-table tbody tr:hover:not(.add-row),
[data-theme="dark"] .sales-items-table tbody tr:hover:not(.add-row) td {
    background-color: color-mix(in srgb, var(--brand-color) 14%, #2a2a2a) !important;
}

/* Delivery rows are read-only snapshots; avoid edit-like hover tint */
.delivery-edit-page .sales-items-table tbody tr:hover:not(.add-row),
.delivery-edit-page .sales-items-table tbody tr:hover:not(.add-row) td {
    background-color: inherit !important;
}
[data-theme="dark"] .delivery-edit-page .sales-items-table tbody tr:hover:not(.add-row),
[data-theme="dark"] .delivery-edit-page .sales-items-table tbody tr:hover:not(.add-row) td {
    background-color: inherit !important;
}

.sales-items-table tbody tr.dragging {
    opacity: 0 !important; /* Completely hide original - custom drag image shows instead */
    pointer-events: none !important; /* Prevent interaction with original during drag */
    /* Take it out of visual flow but keep in DOM for drag to work */
    height: 0 !important;
    overflow: hidden !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Smooth transitions for rows when placeholder moves */
.sales-items-table tbody tr:not(.dragging):not(.drag-placeholder) {
    transition: transform 0.15s ease-out;
}

.sales-items-table tbody tr.drag-over {
    background-color: var(--brand-color-lighter, #fff3cd);
}

/* Add row styling - yellow/beige background like v2_01 */
.sales-items-table tbody tr.add-row {
    background-color: #fff3cd !important; /* Yellow/beige like v2_01 */
}

.sales-items-table tbody tr.add-row:hover {
    background-color: #ffe69c !important; /* Slightly darker yellow on hover */
}

.sales-items-table tbody tr.add-row td {
    background-color: #fff3cd !important; /* Match row background */
    font-weight: bold !important; /* Bold text like v2_01 */
    padding: 2px 12px !important; /* Match v2_01 padding */
    border-top: 1px solid #000000 !important; /* Match v2_01 - solid black (on cells for reliable rendering) */
}

/* Dark mode for add-row - distinct warm dark background, clear text */
[data-theme="dark"] .sales-items-table tbody tr.add-row,
[data-theme="dark"] .sales-items-table tbody tr.add-row td {
    background-color: #3d3628 !important; /* Lighter warm dark for contrast and readability */
}

[data-theme="dark"] .sales-items-table tbody tr.add-row td {
    color: #e8e8e8 !important; /* Clear text on warm dark background */
    border-top: 1px solid var(--text-muted, #b0b0b0) !important;
}

[data-theme="dark"] .sales-items-table tbody tr.add-row .currency-symbol,
[data-theme="dark"] .sales-items-table tbody tr.add-row .item-total {
    color: #e8e8e8 !important;
}

[data-theme="dark"] .sales-items-table tbody tr.add-row:hover,
[data-theme="dark"] .sales-items-table tbody tr.add-row:hover td {
    background-color: #453d2e !important; /* Slightly lighter on hover */
}

/* Dark mode for input fields in table */
[data-theme="dark"] .sales-items-table input[type="text"],
[data-theme="dark"] .sales-items-table input[type="number"],
[data-theme="dark"] .sales-items-table input[type="date"] {
    color: #e0e0e0 !important; /* Light text for dark backgrounds */
}

[data-theme="dark"] .sales-items-table input[type="text"]::placeholder,
[data-theme="dark"] .sales-items-table input[type="number"]::placeholder,
[data-theme="dark"] .sales-items-table input[type="date"]::placeholder {
    color: #909090 !important; /* Visible placeholder on dark backgrounds */
}

/* Dark mode add-row: input fields with dark theme (background + placeholder) */
/* Add-row inputs: visible border like top tables */
.sales-items-table tbody tr.add-row input[type="text"],
.sales-items-table tbody tr.add-row input[type="number"],
.sales-items-table tbody tr.add-row input[type="date"] {
    border: 1px solid var(--border-color, #ced4da) !important;
}

[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="text"],
[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="number"],
[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="date"] {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #e8e8e8 !important;
}

[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="text"]::placeholder,
[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="number"]::placeholder,
[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="date"]::placeholder {
    color: #b0b0b0 !important; /* Clear placeholder in add-row */
}

[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="text"]:focus,
[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="number"]:focus,
[data-theme="dark"] .sales-items-table tbody tr.add-row input[type="date"]:focus {
    background: rgba(0, 0, 0, 0.35) !important;
    border-color: var(--brand-color, rgb(175, 100, 100)) !important;
}

/* Dark mode for input focus state (data rows) */
[data-theme="dark"] .sales-items-table input[type="text"]:focus,
[data-theme="dark"] .sales-items-table input[type="number"]:focus,
[data-theme="dark"] .sales-items-table input[type="date"]:focus {
    background: #2a2a2a !important; /* Dark background instead of white */
    color: #e0e0e0 !important; /* Light text */
}

/* Dark theme: Style date picker calendar icon and calendar popup */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(0.8); /* Make calendar icon visible on dark background */
    opacity: 0.7;
    cursor: pointer;
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Dark mode for line column - ensure header text is white */
[data-theme="dark"] .sales-items-table th.line-col {
    color: var(--text-light, #ffffff) !important; /* White text for header in dark mode */
}

/* Dark mode for line column body cells */
[data-theme="dark"] .sales-items-table td.line-col {
    color: #b0b0b0 !important; /* Lighter gray for dark mode */
}

/* Dark mode for input labels */
[data-theme="dark"] .sales-items-table .input-label {
    color: #b0b0b0 !important; /* Lighter gray for dark mode */
}

.table-scroll {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.list-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--background-card, #ffffff);
    box-shadow: 0 2px 4px var(--shadow-color, rgba(0, 0, 0, 0.1));
    border: 2px solid var(--border-color, #dee2e6);
}

.list-table thead {
    background-color: var(--brand-color, rgb(175, 100, 100));
}

.list-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--text-dark, #000000);
    color: var(--text-light, #ffffff);
    background-color: var(--brand-color, rgb(175, 100, 100)) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.list-table th.list-col-numeric,
.list-table td.list-col-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.list-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color, #dee2e6);
    color: var(--text-dark, #333);
    background: var(--background-card, #ffffff);
}

.list-table tbody tr:hover,
.list-table tbody tr:hover td {
    background-color: var(--background-light, #f8f9fa);
}

/* Orders / quotations / deliveries lists: legacy peach hover for every row. */
.list-table#orders-list-table tbody tr:hover,
.list-table#orders-list-table tbody tr:hover td,
.list-table#quotations-list-table tbody tr:hover,
.list-table#quotations-list-table tbody tr:hover td,
.list-table#deliveries-list-table tbody tr:hover,
.list-table#deliveries-list-table tbody tr:hover td {
    background-color: #ffcd82;
    color: #111111;
}

.table-row-link {
    cursor: pointer;
}

.table-row-link:hover {
    background-color: var(--background-light, #f8f9fa);
}

.list-table#orders-list-table tbody tr.table-row-link:hover,
.list-table#quotations-list-table tbody tr.table-row-link:hover,
.list-table#deliveries-list-table tbody tr.table-row-link:hover {
    background-color: #ffcd82;
    color: #111111;
}

.list-inline-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.list-inline-link:hover {
    color: inherit;
}

.list-sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.list-sort-link:hover {
    text-decoration: underline;
}

.list-sort-link.is-active::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.9;
}

/* Due-date urgency: full-row wash (legacy Jobs Active colours) */
.list-table tbody tr.order-row--late,
.list-table tbody tr.order-row--late td {
    background-color: #111111;
    color: #ffffff;
}

.list-table tbody tr.order-row--urgent,
.list-table tbody tr.order-row--urgent td {
    background-color: rgba(255, 100, 100, 0.9);
    color: #ffffff;
}

.list-table tbody tr.order-row--important,
.list-table tbody tr.order-row--important td {
    background-color: #ffff00;
    color: #111111;
}

.list-table tbody tr.order-row--due,
.list-table tbody tr.order-row--due td {
    background-color: #90ee90;
    color: #111111;
}

.list-table tbody tr.order-row--late:hover,
.list-table tbody tr.order-row--late:hover td,
.list-table tbody tr.order-row--urgent:hover,
.list-table tbody tr.order-row--urgent:hover td,
.list-table tbody tr.order-row--important:hover,
.list-table tbody tr.order-row--important:hover td,
.list-table tbody tr.order-row--due:hover,
.list-table tbody tr.order-row--due:hover td {
    background-color: #ffcd82;
    color: #111111;
}

/* Dark mode adjustments for list-table */
[data-theme="dark"] .list-table {
    border-color: var(--border-color, #666666);
}

[data-theme="dark"] .list-table th {
    background-color: var(--brand-color, rgb(175, 100, 100)) !important;
    color: var(--text-light, #ffffff);
    border-bottom-color: var(--border-color, #666666);
}

[data-theme="dark"] .list-table td {
    color: var(--text-dark, #f5f5f5);
    background: var(--background-card, #1e1e1e);
    border-bottom-color: var(--border-color, #333333);
}

[data-theme="dark"] .list-table tbody tr:hover,
[data-theme="dark"] .list-table tbody tr:hover td {
    background-color: var(--background-light, #0f0f0f);
}

[data-theme="dark"] .list-table#orders-list-table tbody tr:hover,
[data-theme="dark"] .list-table#orders-list-table tbody tr:hover td {
    background-color: #ffcd82;
    color: #111111;
}

/* Late rows: pure black vanishes into dark UI — charcoal + red rail keeps severity readable. */
[data-theme="dark"] .list-table tbody tr.order-row--late,
[data-theme="dark"] .list-table tbody tr.order-row--late td {
    background-color: #1c1c1c;
    color: #f5f5f5;
    border-bottom-color: #3a3a3a;
}

[data-theme="dark"] .list-table tbody tr.order-row--late td:first-child {
    box-shadow: inset 4px 0 0 #e85d5d;
}

[data-theme="dark"] .list-table tbody tr.order-row--urgent,
[data-theme="dark"] .list-table tbody tr.order-row--urgent td {
    background-color: rgba(200, 70, 70, 0.95);
    color: #ffffff;
}

[data-theme="dark"] .list-table tbody tr.order-row--important,
[data-theme="dark"] .list-table tbody tr.order-row--important td {
    background-color: #c9b800;
    color: #111111;
}

[data-theme="dark"] .list-table tbody tr.order-row--due,
[data-theme="dark"] .list-table tbody tr.order-row--due td {
    background-color: #3d8f5a;
    color: #ffffff;
}

[data-theme="dark"] .list-table tbody tr.order-row--late:hover,
[data-theme="dark"] .list-table tbody tr.order-row--late:hover td,
[data-theme="dark"] .list-table tbody tr.order-row--urgent:hover,
[data-theme="dark"] .list-table tbody tr.order-row--urgent:hover td,
[data-theme="dark"] .list-table tbody tr.order-row--important:hover,
[data-theme="dark"] .list-table tbody tr.order-row--important:hover td,
[data-theme="dark"] .list-table tbody tr.order-row--due:hover,
[data-theme="dark"] .list-table tbody tr.order-row--due:hover td {
    background-color: #ffcd82;
    color: #111111;
}

[data-theme="dark"] .list-table tbody tr.order-row--late:hover td:first-child {
    box-shadow: none;
}

.order-due-cell {
    white-space: nowrap;
}

.order-lines-preview {
    position: fixed;
    z-index: 1200;
    max-width: 400px;
    max-height: min(320px, calc(100vh - 24px));
    overflow: auto;
    padding: 10px 12px;
    border: 4px solid #ffcd82;
    border-radius: 4px;
    background: #ffffff;
    color: #111111;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.22);
    font-size: 0.9em;
    line-height: 1.35;
    pointer-events: auto;
}

.order-lines-preview__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.order-lines-preview__list li {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: baseline;
    padding: 3px 0;
    border-bottom: 1px solid var(--border-color, #e6e6e6);
}

.order-lines-preview__list li:last-child {
    border-bottom: none;
}

.order-lines-preview__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-lines-preview__meta,
.order-lines-preview__qty {
    flex: 0 0 auto;
    color: var(--text-muted, #666666);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.order-lines-preview__more,
.order-lines-preview__empty {
    margin-top: 6px;
    color: var(--text-muted, #666666);
    font-size: 0.92em;
}

.order-lines-preview__label .coalesced-override {
    color: #ff9800;
    font-weight: 500;
}

[data-theme="dark"] .order-lines-preview__label .coalesced-override {
    color: #ffb74d;
}

[data-theme="dark"] .order-lines-preview {
    background: #1a1a1a;
    color: #f5f5f5;
    border: 4px solid #ffcd82;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 4px 14px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .order-lines-preview__list li {
    border-bottom-color: var(--border-color, #333333);
}

[data-theme="dark"] .order-lines-preview__meta,
[data-theme="dark"] .order-lines-preview__qty,
[data-theme="dark"] .order-lines-preview__more,
[data-theme="dark"] .order-lines-preview__empty {
    color: var(--text-muted, #bbbbbb);
}

/* Activity log table: styled like sales-items-table (borders, header, alternating rows) */
.activity-log-table {
    width: auto;
    table-layout: fixed;
    border-collapse: collapse;
    background: var(--background-card, #ffffff);
    border: 1px solid var(--text-dark, #000000);
    font-size: 15px;
}

.activity-log-table td {
    border: 1px dotted var(--text-muted, #cccccc);
    padding: 2px 12px;
    vertical-align: middle;
    color: var(--text-dark, #333);
    background: var(--background-card, #ffffff);
}

.activity-log-table th {
    padding: 10px 12px;
    line-height: 1;
    text-align: left;
    font-weight: bold;
    color: var(--text-light, #ffffff);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
    background-color: var(--brand-color, rgb(175, 100, 100));
    border: 1px solid var(--text-dark, #000000);
}

.activity-log-table th:not(:last-child) {
    border-right: 1px solid var(--text-dark, #000000);
}

.activity-log-table td:not(:last-child) {
    border-right: 1px dotted var(--text-muted, #cccccc);
}

.activity-log-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--text-dark, #000000);
}

.activity-log-table thead th {
    border-top: 1px solid var(--text-dark, #000000);
}

/* Alternating row colors */
.activity-log-table tbody tr:nth-child(even) td {
    background-color: #e8e8e8;
}

.activity-log-table tbody tr:nth-child(odd) td {
    background-color: var(--background-card, #ffffff);
}

.activity-log-table tbody tr:hover td {
    background-color: color-mix(in srgb, var(--brand-color) 7%, #f8f9fa);
}

/* Compact column widths */
.activity-log-col-user {
    width: 100px;
}

.activity-log-col-action {
    width: 220px; /* Fits "Quotation header updated" on one line in modal */
}

.activity-log-col-details {
    width: 420px;
}

.activity-log-col-datetime {
    width: 105px;
}

.activity-log-datetime-cell {
    white-space: nowrap;
}

.activity-log-action-cell {
    white-space: nowrap;
}

.activity-log-table td:nth-child(3) {
    white-space: nowrap; /* User column */
}

/* Dark mode - activity log table */
[data-theme="dark"] .activity-log-table {
    border-color: var(--text-muted, #b0b0b0);
}

[data-theme="dark"] .activity-log-table td {
    border-color: var(--text-muted, #b0b0b0);
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .activity-log-table th {
    border-color: var(--text-muted, #b0b0b0);
    background-color: var(--brand-color, rgb(175, 100, 100));
    color: var(--text-light, #ffffff);
}

[data-theme="dark"] .activity-log-table th:not(:last-child) {
    border-right-color: var(--text-muted, #b0b0b0);
}

[data-theme="dark"] .activity-log-table td:not(:last-child) {
    border-right-color: var(--text-muted, #b0b0b0);
}

[data-theme="dark"] .activity-log-table tbody tr:not(:last-child) td {
    border-bottom-color: var(--text-muted, #b0b0b0);
}

[data-theme="dark"] .activity-log-table tbody tr:nth-child(odd) td {
    background-color: #111111;
}

[data-theme="dark"] .activity-log-table tbody tr:nth-child(even) td {
    background-color: #2a2a2a;
}

[data-theme="dark"] .activity-log-table tbody tr:hover td {
    background-color: color-mix(in srgb, var(--brand-color) 7%, #0f0f0f);
}

/* Activity log modal: wide enough for table, scrollable body */
.activity-log-modal-content {
    max-width: 860px;
    width: 90vw;
}

.activity-log-modal-content .modal-body {
    max-height: 70vh;
    overflow-y: auto;
    scrollbar-gutter: stable; /* reserve space for scrollbar so table width doesn't change when scrollbar appears */
}

#activityLogModal .po-activity-section + .po-activity-section {
    margin-top: 16px;
}

#activityLogModal .po-activity-subhead:first-of-type {
    margin-top: 0;
}

/* ============================================
   Column Widths
   ============================================ */

.drag-col {
    width: 30px;
    text-align: center;
}

.line-col {
    width: 72px;
    min-width: 72px;
    text-align: center;
    font-weight: bold;
    color: var(--text-muted, #6c757d);
    white-space: nowrap;
}

.price-option-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #8a5a00;
    background: #fff3cd;
    border: 1px solid #e0c36a;
    vertical-align: middle;
}

.price-option-badge[hidden] {
    display: none !important;
}

.sales-items-table tbody tr.is-price-option td {
    background-color: rgba(255, 243, 205, 0.45);
}

[data-theme="dark"] .price-option-badge {
    color: #ffd978;
    background: rgba(255, 193, 7, 0.18);
    border-color: rgba(255, 193, 7, 0.45);
}

[data-theme="dark"] .sales-items-table tbody tr.is-price-option td {
    background-color: rgba(255, 193, 7, 0.08);
}

.details-col {
    min-width: 300px;
}

.qty-col {
    width: 100px;
}

/* Delivery edit / create: compact line table header alignment */
.delivery-edit-page .sales-items-table thead th,
#create-delivery-page .sales-items-table thead th {
    white-space: nowrap;
}

.delivery-edit-page .sales-items-table th.line-col,
.delivery-edit-page .sales-items-table td.line-col,
#create-delivery-page .sales-items-table th.line-col,
#create-delivery-page .sales-items-table td.line-col {
    text-align: center;
}

.delivery-edit-page .sales-items-table th.qty-col,
.delivery-edit-page .sales-items-table td.qty-col,
#create-delivery-page .sales-items-table th.qty-col,
#create-delivery-page .sales-items-table td.qty-col {
    text-align: right;
    min-width: 5.5rem;
}

.delivery-edit-page .sales-items-table th.include-col,
#create-delivery-page .sales-items-table th.include-col,
.delivery-edit-page .sales-items-table td.include-col,
#create-delivery-page .sales-items-table td.include-col {
    text-align: center;
    width: 52px;
    min-width: 52px;
}

.delivery-edit-page .sales-items-table th.date-col,
#create-delivery-page .sales-items-table th.date-col,
.delivery-edit-page .sales-items-table td.date-col,
#create-delivery-page .sales-items-table td.date-col {
    text-align: left;
    min-width: 7rem;
    white-space: nowrap;
}

.price-col {
    width: 120px;
}

.total-col {
    width: 120px;
}

.date-col {
    width: 130px;
}

.actions-col {
    width: 100px;
}

/* Actions column - remove odd borders from base td rule; keep only structural grid borders */
.sales-items-table td.actions-col {
    border-left: 1px dotted var(--text-muted, #cccccc) !important;
    border-right: 1px solid var(--text-dark, #000000) !important;
    border-top: none !important;
    border-bottom: 1px solid var(--text-dark, #000000) !important;
}

/* Row separators: top border comes from row above, so reset base dotted for actions cell */
.sales-items-table tbody tr:not(:first-child) td.actions-col {
    border-top: 1px solid var(--text-dark, #000000) !important;
}

/* Dark mode */
[data-theme="dark"] .sales-items-table td.actions-col {
    border-left-color: var(--text-muted, #b0b0b0) !important;
    border-right-color: var(--text-muted, #b0b0b0) !important;
    border-bottom-color: var(--text-muted, #b0b0b0) !important;
}

[data-theme="dark"] .sales-items-table tbody tr:not(:first-child) td.actions-col {
    border-top-color: var(--text-muted, #b0b0b0) !important;
}

/* ============================================
   Item Details Container
   ============================================ */

.item-details-container {
    position: relative;
}

.drawing-info,
.description-info,
.material-info,
.heat-treatment-info,
.surface-finishing-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.input-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    margin-right: 8px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Input fields in table - fill entire cell using absolute positioning */
.sales-items-table input[type="text"],
.sales-items-table input[type="number"],
.sales-items-table input[type="date"] {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border: 1px solid transparent; /* Border always present, transparent by default */
    background: transparent;
    margin: 0;
    padding: 4px 6px;
    font-size: 15px;
    outline: none;
    z-index: 10;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s;
}


.sales-items-table input[type="text"]:focus,
.sales-items-table input[type="number"]:focus,
.sales-items-table input[type="date"]:focus {
    background: var(--background-card, #ffffff);
    border-color: var(--brand-color, rgb(175, 100, 100)); /* Change border color on focus */
    outline: none;
}

/* Exclude details-col, drag-col, and PO material/desc cells from absolute positioning */
.sales-items-table td.details-col input[type="text"],
.sales-items-table td.details-col input[type="number"],
.sales-items-table td.details-col input[type="date"],
.sales-items-table td.drag-col input[type="text"],
.sales-items-table td.drag-col input[type="number"],
.sales-items-table td.drag-col input[type="date"],
.po-lines-table td.po-line-material-cell input[type="number"],
.po-lines-table .po-add-line-material .po-add-line-field,
.po-lines-table .po-add-line-material .po-spec-search,
.po-lines-table .po-add-line-material .po-line-input-piece-count,
.po-lines-table .po-add-line-material .po-line-input-piece-length {
    position: relative !important;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    width: auto;
    height: auto;
    z-index: auto;
}

.po-lines-table .po-add-line-material .po-add-line-field,
.po-lines-table .po-add-line-material .po-spec-search {
    width: 100%;
    height: auto;
}

.item-details-container input[type="text"] {
    flex: 1;
    min-width: 100px;
    padding: 4px 6px;
    margin: 0;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-dark, #495057);
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

.item-details-container input[type="text"]:focus {
    background: var(--background-card, #ffffff);
    border: 1px solid var(--brand-color, rgb(175, 100, 100));
    outline: none;
}

/* Override indicators and revert buttons */
.input-with-revert {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 100px;
    position: relative;
}

.item-details-container input.has-override {
    background-color: rgba(255, 235, 59, 0.2); /* Light yellow background for overridden fields */
    border-left: 3px solid #ffc107; /* Yellow left border indicator */
}

.item-details-container input.has-override:focus {
    background-color: rgba(255, 235, 59, 0.3);
    border-left: 3px solid #ff9800; /* Darker yellow on focus */
}

.revert-to-master {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    padding: 0;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
    line-height: 1;
}

.revert-to-master:hover {
    background: #5a6268;
}

.revert-to-master:active {
    background: #495057;
}

/* Coalesced line styles */
.item-details-coalesced {
    display: flex;
    align-items: center;
    width: 100%;
}

.coalesced-line-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    flex-wrap: wrap;
}

.coalesced-line {
    flex: 1;
    min-width: 200px;
    font-size: 14px;
    color: var(--text-dark, #495057);
    line-height: 1.5;
    padding: 4px 0;
    position: relative;
    z-index: 20;
    pointer-events: auto;
}

.coalesced-override {
    color: #ff9800; /* Orange color for overridden fields */
    font-weight: 500;
}

.coalesced-meta {
    color: var(--text-muted, #6c757d);
    font-size: 12px;
}

.coalesced-override .coalesced-meta {
    color: inherit;
}

.coalesced-empty {
    color: var(--text-muted, #6c757d);
    font-style: italic;
}

.edit-item-details-btn {
    background: var(--brand-color, rgb(175, 100, 100));
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    z-index: 20;
    pointer-events: auto;
}

.edit-item-details-btn:hover {
    background: rgba(175, 100, 100, 0.9);
}

.edit-item-details-btn:active {
    background: rgba(175, 100, 100, 0.8);
}

/* Inline editing fields */
.inline-edit-fields {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
}

/* Ensure inline-edit-fields don't block clicks when hidden */
.inline-edit-fields {
    pointer-events: auto;
}

.inline-edit-fields[style*="display: none"],
.inline-edit-fields[style*="display:none"] {
    pointer-events: none !important;
}

.inline-edit-fields input {
    position: relative;
    z-index: 15;
    pointer-events: auto;
    min-width: 200px;
    padding: 4px 0;
}

/* Static drawing/revision text in inline edit */
.inline-edit-drawing-revision {
    color: var(--text-dark, #495057);
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
    margin-right: 8px;
}

/* Labels for inline edit inputs */
.inline-edit-label {
    font-size: 13px;
    color: var(--text-muted, #6c757d);
    font-weight: 500;
    flex-shrink: 0;
    margin-right: 4px;
}

.inline-edit-fields input[type="text"] {
    padding: 4px 8px;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 3px;
    font-size: 13px;
    font-family: inherit;
    background: var(--background-card, #ffffff);
    color: var(--text-dark, #495057);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-width: 80px;
    flex: 1;
    max-width: 200px;
}

.inline-edit-fields input[type="text"]:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: 0 0 0 2px rgba(175, 100, 100, 0.1);
}

.inline-edit-fields input[type="text"].has-override {
    border-left: 3px solid #ff9800;
    background-color: rgba(255, 152, 0, 0.05);
}

.inline-edit-fields input[type="text"].has-override:focus {
    border-left: 3px solid #f57c00;
    background-color: rgba(255, 152, 0, 0.1);
}

.inline-separator {
    color: var(--text-muted, #6c757d);
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    padding: 0 2px;
}

.coalesced-line {
    transition: opacity 0.2s ease;
}

.coalesced-line:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Delivery line details are read-only snapshots; no hover affordance */
.delivery-edit-page .coalesced-line:hover {
    opacity: 1;
    text-decoration: none;
}

/* Modal form styles */
.input-with-revert-modal {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.master-value-hint {
    font-size: 11px;
    color: var(--text-muted, #6c757d);
    font-style: italic;
    margin-top: -2px;
}

.field-format-hint {
    font-size: 11px;
    color: var(--text-muted, #6c757d);
    margin-top: -2px;
}

.field-format-inline {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted, #6c757d);
}

.inline-field-note {
    display: block;
    font-size: 11px;
    color: var(--text-muted, #6c757d);
    margin-bottom: 4px;
}

#editItemDetailsModal .form-control::placeholder {
    color: var(--text-muted, #6c757d);
    opacity: 1;
}

[data-theme="dark"] #editItemDetailsModal .form-control::placeholder {
    color: #b0b0b0;
    opacity: 1;
}

.revert-to-master-modal {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    align-self: flex-start;
    margin-top: 4px;
}

.revert-to-master-modal:hover {
    background: #5a6268;
}

.revert-to-master-modal:active {
    background: #495057;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-dark, #495057);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: 0 0 0 3px rgba(175, 100, 100, 0.1);
}

.form-control.has-override {
    border-left: 3px solid #ff9800;
    background-color: rgba(255, 152, 0, 0.08);
}

#editItemDetailsModal .form-control.has-override {
    border-left: 3px solid #ff9800;
    background-color: rgba(255, 152, 0, 0.1);
}

#editItemDetailsModal .form-control.has-override:focus {
    border-color: var(--brand-color, rgb(175, 100, 100));
    border-left-color: #f57c00;
    background-color: rgba(255, 152, 0, 0.14);
    box-shadow: 0 0 0 3px rgba(175, 100, 100, 0.1);
}

[data-theme="dark"] #editItemDetailsModal .form-control.has-override {
    background-color: rgba(255, 193, 7, 0.14);
    border-left-color: #ffc107;
}

[data-theme="dark"] #editItemDetailsModal .form-control.has-override:focus {
    background-color: rgba(255, 193, 7, 0.22);
    border-left-color: #ff9800;
}

#editItemDetailsModal.item-details-modal--view-only .form-control,
#editItemDetailsModal.item-details-modal--view-only input[type="text"],
#editItemDetailsModal.item-details-modal--view-only textarea {
    cursor: default;
    background-color: var(--surface-muted, #f5f5f5);
    color: inherit;
    opacity: 1;
}

#editItemDetailsModal.item-details-modal--view-only .form-control:disabled,
#editItemDetailsModal.item-details-modal--view-only input[type="text"]:disabled,
#editItemDetailsModal.item-details-modal--view-only textarea:disabled {
    opacity: 1;
    -webkit-text-fill-color: inherit;
    color: inherit;
}

#editItemDetailsModal.item-details-modal--view-only .form-control:focus {
    box-shadow: none;
    border-color: var(--border-color, #ccc);
}

.record-readonly .coalesced-line {
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--brand-color, rgb(175, 100, 100));
    color: white;
}

.btn-primary:hover {
    background: rgba(175, 100, 100, 0.9);
}

.btn-secondary {
    background: var(--text-muted, #6c757d);
    color: white;
}

.btn-secondary:hover {
    background: rgba(108, 117, 125, 0.9);
}

.hover-trigger {
    position: static;
    width: 80px;
    height: 28px;
    cursor: pointer;
    background: var(--brand-color, rgb(175, 100, 100));
    border: none;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: var(--text-light, #ffffff);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: 0 1px 3px var(--shadow-color, rgba(0, 0, 0, 0.2));
    flex-shrink: 0;
    margin-left: auto;
    text-decoration: none;
    padding: 0;
}

.hover-trigger:hover {
    background: rgba(139, 38, 53, 1);
    box-shadow: 0 2px 6px var(--shadow-color, rgba(0, 0, 0, 0.3));
    text-decoration: none;
}

.hover-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.hover-details .input-label {
    display: block;
    margin-bottom: 4px;
}

.hover-details input[type="text"] {
    width: 100%;
    margin-bottom: 8px;
}

/* ============================================
   Input Styles
   ============================================ */

.item-input-quantity,
.item-input-due-date {
    /* Inherits absolute positioning from parent rule */
}

.item-input-quantity:focus,
.item-input-due-date:focus {
    /* Inherits focus styles from parent rule */
}

/* Price input with currency symbol - 2.3em left; 12px right so value has visible space */
.sales-items-table .item-input-price {
    /* Inherits absolute positioning from general rule (like quantity input) */
    padding: 2px 12px 2px 2.3em !important; /* !important overrides base .sales-items-table input padding: 4px 6px */
    text-align: right;
    border: 1px solid transparent; /* Border always present, transparent by default */
    background: transparent; /* Transparent by default, like v2_01 */
    box-sizing: border-box;
    transition: background 0.2s, border-color 0.2s;
}

/* General item-input-price rule for non-table contexts */
.item-input-price {
    padding: 2px 12px 2px 2.3em;
    text-align: right;
    border: 1px solid transparent; /* Border always present, transparent by default */
    background: transparent; /* Transparent by default, like v2_01 */
    box-sizing: border-box;
    transition: background 0.2s, border-color 0.2s;
}

.sales-items-table .item-input-price:focus {
    background: var(--background-card, #ffffff);
    border-color: var(--brand-color, rgb(175, 100, 100)); /* Change border color on focus */
    border-width: 1px; /* Keep same width as default */
    outline: none;
}

.item-input-price:focus {
    background: var(--background-card, #ffffff);
    border: 1.5px solid var(--brand-color, rgb(175, 100, 100));
    outline: none;
}

/* Dark theme for price input */
[data-theme="dark"] .sales-items-table .item-input-price {
    background: transparent; /* Transparent by default in dark theme too */
    color: #e0e0e0;
}

[data-theme="dark"] .sales-items-table .item-input-price:focus {
    background: #2a2a2a; /* Background only on focus */
    color: #e0e0e0;
}

[data-theme="dark"] .item-input-price {
    background: var(--background-white, #1a1a1a);
    color: #e0e0e0;
}

[data-theme="dark"] .item-input-price:focus {
    background: #2a2a2a;
    color: #e0e0e0;
}

/* Remove number input spinner for price input */
.item-input-price::-webkit-outer-spin-button,
.item-input-price::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.item-input-price[type=number] {
    -moz-appearance: textfield;
}

/*
 * Lead time: match Issue Date cell (full-cell bordered control). Inner flex fills td like a single input;
 * avoids absolute number covering the unit select.
 */
.edit-table-header td.lead-time-cell {
    padding: 0;
    vertical-align: middle;
}

.edit-table-header td.lead-time-cell .lead-time-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    box-sizing: border-box;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 0;
    background-color: var(--background-card, #ffffff);
    overflow: hidden;
}

.edit-table-header td.lead-time-cell .lead-time-inner:focus-within {
    outline: none;
    border-color: var(--brand-color, #007bff);
    box-shadow: 0 0 0 2px var(--brand-color-light, rgba(0, 123, 255, 0.25));
}

.edit-table-header td.lead-time-cell .lead-time-input {
    position: static;
    inset: auto;
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    max-width: none;
    height: auto;
    align-self: stretch;
    min-height: 100%;
    border: none;
    border-radius: 0;
    border-right: 1px solid var(--border-color, #ced4da);
    box-shadow: none;
}

.edit-table-header td.lead-time-cell .lead-time-input:focus {
    box-shadow: none;
}

.edit-table-header td.lead-time-cell .lead-time-unit {
    flex: 0 0 auto;
    min-width: 5.25rem;
    max-width: 42%;
    padding: 4px 6px;
    margin: 0;
    border: none;
    border-radius: 0;
    font-size: 14px;
    background-color: transparent;
    color: var(--text-dark, #333);
    box-sizing: border-box;
    align-self: stretch;
    cursor: pointer;
}

[data-theme="dark"] .edit-table-header td.lead-time-cell .lead-time-inner {
    background-color: var(--background-card, #1e1e1e);
    border-color: var(--header-table-border, #444);
}

[data-theme="dark"] .edit-table-header td.lead-time-cell .lead-time-input {
    border-right-color: var(--header-table-border, #444);
}

[data-theme="dark"] .edit-table-header td.lead-time-cell .lead-time-unit {
    color: var(--text-dark, #e0e0e0);
}

.lead-time-input::-webkit-outer-spin-button,
.lead-time-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.lead-time-input[type=number] {
    -moz-appearance: textfield;
}

/* Dark theme: Style number input arrows if they're visible (for browsers that don't hide them) */
[data-theme="dark"] input[type="number"]::-webkit-inner-spin-button,
[data-theme="dark"] input[type="number"]::-webkit-outer-spin-button {
    filter: invert(1) brightness(0.8); /* Make arrows visible on dark background */
    opacity: 0.7;
}

[data-theme="dark"] input[type="number"]::-webkit-inner-spin-button:hover,
[data-theme="dark"] input[type="number"]::-webkit-outer-spin-button:hover {
    opacity: 1;
}

.price-flex {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
}

/* Delivery flex container (used in summary section, not table) */
.delivery-flex {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

/* Currency symbol for price input (absolute positioned relative to td) */
.sales-items-table td.price-col .currency-symbol {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: var(--text-dark, #495057);
    pointer-events: none;
    z-index: 20;
}

/* Currency symbol for total column (absolute positioned like price) */
.sales-items-table td.total-col .currency-symbol {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: #c00;
    z-index: 10;
}

/* Currency symbol for delivery (still uses flex layout in summary section) */
/* Delivery flex currency symbol - for table context (if used) */
.delivery-flex .currency-symbol {
    position: static; /* Not absolute - flows with flex layout */
    font-weight: normal; /* Match summary row styling */
    color: inherit; /* Match text color */
    flex-shrink: 0; /* Prevent shrinking */
}

/* Dark theme for currency symbols */
[data-theme="dark"] .sales-items-table td.price-col .currency-symbol {
    color: #e0e0e0;
}

[data-theme="dark"] .sales-items-table td.total-col .currency-symbol {
    color: #ff6b6b; /* Match total text color in dark mode */
}

[data-theme="dark"] .delivery-flex .currency-symbol {
    color: inherit; /* Match text color of other summary rows in dark mode */
}

/* Currency symbol after amount (e.g. EUR: 10 €) - sales edit page only */
#edit-page.currency-symbol-after .sales-items-table td.price-col .currency-symbol {
    left: auto;
    right: 12px;
    top: calc(50% + 1px); /* Nudge down so symbol aligns with input text (not cell center) */
}

#edit-page.currency-symbol-after .sales-items-table .item-input-price,
#edit-page.currency-symbol-after .item-input-price {
    padding: 2px 2.3em 2px 12px !important; /* Ensure gap between number and symbol (overrides base input padding) */
    text-align: left; /* Value left, symbol right */
}

#edit-page.currency-symbol-after .sales-items-table td.total-col .currency-symbol {
    left: auto;
    right: 12px;
}

#edit-page.currency-symbol-after .sales-items-table td.total-col .item-total {
    padding-left: 0;     /* Value 12px from left (cell padding only, like we did for right when symbol left) */
    padding-right: 2.3em;
    text-align: left;    /* Value left, symbol right (match price each) */
}

/* Symbol-after: inline amount + symbol, right-aligned as a unit (avoids justify-between drift on short values) */
#edit-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value,
#convert-order-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value {
    display: table-cell;
    vertical-align: middle;
    padding-left: 12px;
    padding-right: 12px;
    text-align: right;
}

#edit-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value #subtotal,
#edit-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value #vat-amount,
#edit-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value #total,
#convert-order-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value #subtotal,
#convert-order-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value #vat-amount,
#convert-order-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value #total {
    text-align: right;
}

#edit-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value .delivery-input,
#convert-order-page.currency-symbol-after .sales-notes-summary .summary-box .summary-value .delivery-input {
    text-align: right;
}

[data-theme="dark"] #edit-page.currency-symbol-after .sales-items-table td.price-col .currency-symbol {
    color: #e0e0e0;
}

[data-theme="dark"] #edit-page.currency-symbol-after .sales-items-table td.total-col .currency-symbol,
[data-theme="dark"] #edit-page.currency-symbol-after .sales-items-table td.total-col .item-total {
    color: #ff6b6b;
}

/* ============================================
   Drag and Drop Styles
   ============================================ */

.drag-handle {
    cursor: move;
    color: var(--text-muted, #6c757d);
    font-size: 16px;
    user-select: none;
    position: relative;
    z-index: 20;
    pointer-events: auto;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    outline: none;
}

.drag-handle:hover {
    color: var(--brand-color, #007bff);
}

/* Dark theme for drag handle */
[data-theme="dark"] .drag-handle {
    color: var(--text-muted, #b0b0b0);
}

[data-theme="dark"] .drag-handle:hover {
    color: var(--brand-color, rgb(175, 100, 100));
}

/* Drag clone styling - ensure it never gets stuck */
[data-drag-clone="true"] {
    position: fixed !important;
    z-index: 2147483647 !important;
    pointer-events: none !important;
    isolation: isolate !important;
    will-change: transform !important;
    touch-action: none !important;
}

[data-drag-clone="true"] * {
    pointer-events: none !important;
    user-select: none !important;
}

/* Dragged row borders - move to table, remove all cell borders */
/* Override all existing border rules with !important */
table[data-drag-clone="true"].sales-items-table,
table[data-drag-clone="true"] {
    /* Remove all borders first */
    border: none !important;
    /* Add only top and bottom dashed borders */
    border-top: 2px dashed rgb(175, 100, 100) !important;
    border-bottom: 2px dashed rgb(175, 100, 100) !important;
    border-left: none !important;
    border-right: none !important;
}

/* Remove ALL borders from cells in dragged table */
table[data-drag-clone="true"].sales-items-table tbody tr td,
table[data-drag-clone="true"] tbody tr td,
table[data-drag-clone="true"].sales-items-table tbody tr,
table[data-drag-clone="true"] tbody tr {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
}

.drag-placeholder {
    visibility: visible !important;
    background-color: rgba(175, 100, 100, 0.4) !important;
    border-top: 2px dashed rgb(175, 100, 100) !important;
    border-bottom: 2px dashed rgb(175, 100, 100) !important;
    border-left: none !important;
    border-right: none !important;
    opacity: 1 !important;
    display: table-row !important;
    position: relative !important;
    /* Height will be set inline by JavaScript */
}

/* Ensure placeholder is visible even if inside table - override all row styles */
.sales-items-table .drag-placeholder,
.sales-items-table tbody .drag-placeholder,
.sales-items-table tbody tr.drag-placeholder {
    background-color: rgba(175, 100, 100, 0.4) !important;
    border-top: 2px dashed rgb(175, 100, 100) !important;
    border-bottom: 2px dashed rgb(175, 100, 100) !important;
    border-left: none !important;
    border-right: none !important;
}

/* Override alternating row colors for placeholder */
.sales-items-table tbody tr.drag-placeholder:nth-child(even),
.sales-items-table tbody tr.drag-placeholder:nth-child(odd) {
    background-color: rgba(175, 100, 100, 0.4) !important;
}

/* Make placeholder cells visible - show the colored background */
/* Override alternating row cell backgrounds with higher specificity */
.drag-placeholder td,
.sales-items-table .drag-placeholder td,
.sales-items-table tbody tr.drag-placeholder td,
.sales-items-table tbody tr.drag-placeholder:nth-child(even) td,
.sales-items-table tbody tr.drag-placeholder:nth-child(odd) td,
.sales-items-table tbody tr.drag-placeholder:nth-child(even):not(.add-row) td,
.sales-items-table tbody tr.drag-placeholder:nth-child(odd):not(.add-row) td {
    pointer-events: none !important;
    visibility: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background-color: rgba(175, 100, 100, 0.4) !important; /* Override alternating row colors */
    min-height: 1px !important; /* Ensure cells have height */
    /* Height will be set inline by JavaScript */
}

/* ============================================
   Actions
   ============================================ */

.actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Actions div inside table cell - fill the cell (td stays normal table cell, no flex) */
.sales-items-table td.actions-col .actions {
    width: 100%;
    min-height: 100%;
}

/* Action buttons in sales table - no border, pointer cursor */
.sales-items-table .delete-item,
.sales-items-table #add-item-btn {
    border: none !important;
    box-shadow: none !important;
    cursor: pointer !important;
}

/* Delete button (trash icon) - match v2_01 styling */
.sales-items-table .delete-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 4px 8px;
}

.sales-items-table .delete-item .fa-trash {
    color: #c00;
    font-size: 1.1em;
}

.sales-items-table .delete-item:hover .fa-trash {
    color: #a00;
}

/* Add button - brand colors */
.sales-items-table #add-item-btn {
    background-color: var(--brand-color, rgb(175, 100, 100));
    color: #fff;
    padding: 6px 18px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 15px;
}

.sales-items-table #add-item-btn:hover {
    background-color: #7e3333;
}

/* ============================================
   Save Indicators
   ============================================ */

.save-indicator {
    font-size: 12px;
    font-weight: 600;
    color: #28a745;
    margin-left: 8px;
}

.row-save-indicator {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: #28a745;
}

#item-save-indicator {
    margin-bottom: 8px;
    color: var(--brand-color, #007bff);
    font-weight: bold;
}

/* Dark theme for save indicator */
[data-theme="dark"] #item-save-indicator {
    color: var(--brand-color, rgb(175, 100, 100));
}

/* ============================================
   Notes Section
   ============================================ */

.notes h3,
.summary h3 {
    margin-bottom: 6px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark, #495057);
}

.sales-notes-summary .notes .record-documents-panel {
    margin-top: 14px;
}

.sales-notes-summary textarea {
    width: 100%;
    height: 120px;
    min-height: 120px;
    border: 1px solid var(--border-color, #ccc);
    padding: 8px;
    resize: vertical;
    font-size: 15px;
    font-family: inherit;
    background-color: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
}

#notes {
    width: 100%;
    min-height: 120px;
    padding: 8px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    background-color: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
}

#notes:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: 0 0 0 2px var(--brand-color-light, rgba(175, 100, 100, 0.1));
}

#save-notes-btn {
    margin-top: 10px;
    background: var(--brand-color, #007bff);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px var(--shadow-color, rgba(0, 0, 0, 0.1));
}

#save-notes-btn:hover {
    background: var(--brand-color-hover, rgba(0, 123, 255, 0.8));
    transform: translateY(-1px);
    box-shadow: 0 4px 6px var(--shadow-color, rgba(0, 0, 0, 0.15));
}

#save-notes-btn:active {
    transform: translateY(0);
}

/* ============================================
   Financial Summary
   ============================================ */

.summary-box {
    background: var(--background-light, #f8f9fa);
    padding: 15px;
    border-radius: 5px;
    width: 100%;
    border: 1px solid var(--border-color, #dee2e6);
    color: var(--text-dark, #333);
}

/* Dark theme for summary box */
[data-theme="dark"] .summary-box {
    background: var(--background-white, #1a1a1a);
    border-color: var(--border-color, #333333);
    color: var(--text-dark, #f5f5f5);
}

/* Financial summary uses a CSS table so the amount column stays one consistent width across
   all rows (wide subtotals vs short delivery amounts line up decimals and symbols).
   max-content width keeps the amount column only as wide as the widest figure (not full panel). */
.sales-notes-summary .summary-box {
    display: table;
    table-layout: auto;
    border-collapse: collapse;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

.sales-notes-summary .summary-box > .vat-row,
.sales-notes-summary .summary-box > .summary-row,
.sales-notes-summary .summary-box > .total {
    display: table-row;
}

.sales-notes-summary .summary-box > .summary-tbd-note {
    display: table-caption;
    caption-side: bottom;
    margin: 10px 0 0;
    padding: 8px 10px 0;
    border-top: 1px solid var(--border-color, #dee2e6);
    font-size: 12px;
    line-height: 1.35;
    color: var(--text-muted, #6c757d);
    white-space: normal;
    text-align: left;
}

.sales-notes-summary .summary-box > .summary-tbd-note[hidden] {
    display: none !important;
}

[data-theme="dark"] .sales-notes-summary .summary-box > .summary-tbd-note {
    border-top-color: var(--border-color, #333);
}

.sales-notes-summary .summary-box > .vat-row > span:first-child,
.sales-notes-summary .summary-box > .summary-row > span:first-child,
.sales-notes-summary .summary-box > .total > span:first-child {
    display: table-cell;
    vertical-align: middle;
    text-align: left;
    padding-left: 8px;
    padding-right: 12px;
    white-space: nowrap;
}

.sales-notes-summary .summary-box > .vat-row > select {
    display: table-cell;
    vertical-align: middle;
    text-align: right;
}

.sales-notes-summary .summary-box > .vat-row > span:first-child {
    white-space: normal;
}

.sales-notes-summary .summary-box > .summary-row > .summary-value,
.sales-notes-summary .summary-box > .total > .summary-value {
    display: table-cell;
    vertical-align: middle;
}

/* Financial Summary: £/symbol sits next to figures; flex avoids old absolute symbol + baseline drift on bold total */
.sales-notes-summary .summary-box .summary-money {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.28em;
    justify-content: flex-end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
}

.sales-notes-summary .summary-box .summary-money:has(.base-hover-overlay) {
    display: inline-grid;
    justify-items: end;
    align-items: baseline;
    vertical-align: baseline;
}

.sales-notes-summary .summary-box .summary-money .summary-amount {
    grid-area: 1 / 1;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.28em;
    justify-content: flex-end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
}

/* Base-currency overlay stacks in the same grid cell as the quote amount */
.sales-notes-summary .summary-box .summary-money .base-hover-overlay {
    grid-area: 1 / 1;
    position: static;
    inset: auto;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.28em;
    justify-content: flex-end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
    font: inherit;
    font-weight: inherit;
    color: inherit;
    background: transparent;
    opacity: 0;
    pointer-events: none;
    padding: 0;
    width: auto;
}

.sales-notes-summary .summary-box .summary-money:has(.delivery-input) .summary-amount,
.sales-notes-summary .summary-box .summary-money:has(.delivery-input) .base-hover-overlay {
    align-items: baseline;
}

.sales-notes-summary .summary-box .summary-money:has(.delivery-input:focus) .summary-amount {
    position: relative;
    z-index: 1;
}

.sales-notes-summary .summary-box .summary-money .base-overlay-symbol,
.sales-notes-summary .summary-box .summary-money .base-overlay-value {
    flex-shrink: 0;
    font-weight: inherit;
    font-size: inherit;
}

.sales-notes-summary .summary-box .total .summary-money .base-overlay-symbol {
    font-weight: bold;
}

.sales-notes-summary .summary-box .summary-value .currency-symbol {
    position: static;
    left: auto;
    top: auto;
    right: auto;
    transform: none;
    width: auto;
    flex-shrink: 0;
    font-weight: inherit;
    font-size: inherit;
    text-align: inherit;
    transition: opacity 0.15s ease;
}

.sales-notes-summary .summary-box .total .summary-money .currency-symbol {
    font-weight: bold;
    font-size: inherit;
}

/* Delivery uses <input>; its content sits higher inside the widget than plain spans, so
   align-items:center makes £ look low next to digits. Baseline-align + match font metrics. */
.sales-notes-summary .summary-box .summary-money:has(.delivery-input) {
    align-items: baseline;
}

.sales-notes-summary .summary-money .delivery-amount-field {
    display: inline-block;
    vertical-align: baseline;
    max-width: 14ch;
    flex: 0 0 auto;
}

.sales-notes-summary .summary-money .delivery-amount-field .delivery-input {
    font: inherit;
    font-size: inherit;
    line-height: 1.2;
    padding: 0;
    margin: 0;
    appearance: none;
    -moz-appearance: textfield;
    border-width: 0;
    outline: none;
    vertical-align: baseline;
    display: block;
    width: 100%;
    min-width: 0;
    min-inline-size: 0;
    max-width: none;
    max-inline-size: none;
    field-sizing: fixed;
    box-sizing: border-box;
    text-align: right;
    transition: opacity 0.15s ease;
}

.sales-notes-summary .summary-box .delivery-save-indicator {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    white-space: nowrap;
}

.sales-notes-summary .summary-money .delivery-amount-field .delivery-input:focus {
    border-width: 1px;
    border-style: solid;
    border-color: var(--brand-color, rgb(175, 100, 100));
    background: var(--background-card, #ffffff);
}

[data-theme="dark"] .sales-notes-summary .summary-money .delivery-amount-field .delivery-input:focus {
    background: #2a2a2a;
}

.summary-row {
    width: 100%;
}

/* Edit page Financial Summary only (quotation/order edit — symbol + amount cluster is .summary-money) */
.summary-value {
    position: relative;
    display: inline-block;
    text-align: right;
    box-sizing: border-box;
    padding-left: 12px;
    padding-right: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Inline base-conversion overlay (replaces tooltip): show base amount on hover */
td.price-col,
td.total-col,
.summary-value:has(.base-hover-overlay) {
    position: relative;
}

.base-hover-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
    padding: inherit;
    font: inherit;
    font-weight: inherit;
    color: inherit;
    background: inherit;
    pointer-events: none;
}

/* Table cells: overlay padding matches cell only (12px), no extra 4px like item-total value span */
td.total-col .base-hover-overlay {
    padding: 2px 12px 2px 12px;
}
/* Price cell: +1px right so overlay aligns with input (input has 1px border inside box, content sits 1px in) */
td.price-col .base-hover-overlay {
    padding: 2px 13px 2px 12px;
}

#edit-page.currency-symbol-after td.total-col .base-hover-overlay {
    padding: 2px 12px 2px 12px;
}
#edit-page.currency-symbol-after td.price-col .base-hover-overlay {
    padding: 2px 12px 2px 13px;
}

td.price-col:hover .base-hover-overlay,
td.total-col:hover .base-hover-overlay {
    display: flex;
}

.summary-value .base-hover-overlay .base-overlay-symbol {
    width: auto;
    min-width: auto;
    text-align: inherit;
    flex-shrink: 0;
}
.summary-value .base-hover-overlay .base-overlay-value {
    flex: 0 0 auto;
    text-align: inherit;
    min-width: 0;
}

/* Financial summary: swap quote/base amounts on hover within the same grid cell */
.summary-value:hover .summary-money:has(.base-hover-overlay):not(:has(.delivery-input)) .base-hover-overlay {
    opacity: 1;
}
.summary-value:hover .summary-money:has(.base-hover-overlay):not(:has(.delivery-input)) .summary-amount {
    visibility: hidden;
}
/* Delivery row: fade quote input/symbol on hover (not visibility:hidden) so input stays clickable */
.summary-value:hover .summary-money:has(.base-hover-overlay):has(.delivery-input):not(:has(.delivery-input:focus)) .base-hover-overlay {
    opacity: 1;
}
.summary-value:hover .summary-money:has(.base-hover-overlay):has(.delivery-input):not(:has(.delivery-input:focus)) .currency-symbol,
.summary-value:hover .summary-money:has(.base-hover-overlay):has(.delivery-input):not(:has(.delivery-input:focus)) .delivery-input {
    opacity: 0;
}
.summary-money:has(.delivery-input:focus) .base-hover-overlay {
    opacity: 0;
}

td.price-col:has(.item-input-price:focus) .base-hover-overlay,
.summary-value:has(.delivery-input:focus) .base-hover-overlay {
    display: none;
}
td.price-col:hover:has(.base-hover-overlay):not(:has(.item-input-price:focus)) .item-input-price,
td.price-col:hover:has(.base-hover-overlay):not(:has(.item-input-price:focus)) .currency-symbol {
    opacity: 0;
}
td.total-col:hover:has(.base-hover-overlay) .currency-symbol,
td.total-col:hover:has(.base-hover-overlay) .item-total {
    visibility: hidden;
}

td.price-col:hover:has(.base-hover-overlay),
td.total-col:hover:has(.base-hover-overlay) {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] td.price-col:hover:has(.base-hover-overlay),
[data-theme="dark"] td.total-col:hover:has(.base-hover-overlay) {
    background: rgba(255, 255, 255, 0.06);
}

/* Tax row participates in Financial Summary table layout (see .sales-notes-summary .summary-box) */
.sales-notes-summary .summary-box > .vat-row {
    display: table-row;
    width: auto;
}

.vat-row label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vat-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--brand-color, rgb(175, 100, 100));
}

.vat-row select {
    min-width: 180px;
    padding: 4px 8px;
    font-size: 14px;
    border: 1px solid var(--border-color, #dee2e6);
    background: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
    border-radius: 4px;
}

.vat-row select:focus {
    border-color: var(--brand-color, rgb(175, 100, 100));
    outline: none;
}

/* Dark theme for vat-row select */
[data-theme="dark"] .vat-row select {
    border-color: var(--text-muted, #b0b0b0);
    background: var(--background-white, #1a1a1a);
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .vat-row select:focus {
    background: #2a2a2a;
    border-color: var(--brand-color, rgb(175, 100, 100));
}

.delivery-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    width: 100%;
}

.delivery-input-wrapper,
.delivery-flex {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.delivery-input {
    box-sizing: border-box;
    width: auto;
    min-inline-size: 4.25ch;
    max-inline-size: 18rem;
    field-sizing: content;
    text-align: right;
    border: 1px solid transparent; /* Transparent border by default to match other inputs */
    background: transparent; /* Transparent background by default to match other summary rows */
    font-size: 15px;
    padding: 0; /* No padding to match inline text appearance */
    margin: 0;
    transition: background 0.2s, border-color 0.2s;
    color: inherit; /* Match text color of other summary rows */
    display: inline-block;
    vertical-align: baseline;
}

.delivery-input:focus {
    background: var(--background-card, #ffffff);
    border-color: var(--brand-color, rgb(175, 100, 100));
    outline: none;
}

/* Dark theme for delivery input */
[data-theme="dark"] .delivery-input {
    background: transparent;
    color: inherit;
}

[data-theme="dark"] .delivery-input:focus {
    background: #2a2a2a; /* Background only on focus in dark theme */
    border-color: var(--brand-color, rgb(175, 100, 100));
}

/* Hide number input arrows for delivery input */
input[type="number"].delivery-input::-webkit-outer-spin-button,
input[type="number"].delivery-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"].delivery-input[type=number] {
    -moz-appearance: textfield;
}

@supports not (field-sizing: content) {
    .delivery-input {
        width: 8ch;
    }
}

.delivery-flex .currency-symbol {
    position: static; /* Not absolute - flows with flex layout (matches total-flex) */
    color: inherit; /* Match text color of other summary rows */
    font-size: 15px;
    font-weight: normal; /* Match weight of other summary rows (not bold) */
    flex-shrink: 0; /* Prevent shrinking */
    font-family: inherit;
}

.sales-notes-summary .summary-box .total {
    font-weight: bold;
    font-size: 1.15em;
    width: auto;
}

.sales-notes-summary .summary-box > .total > span:first-child,
.sales-notes-summary .summary-box > .total > .summary-value {
    border-top: 1px solid var(--border-color, #ccc);
    padding-top: 12px;
}

.total {
    font-weight: bold;
    font-size: 1.15em;
    color: var(--text-dark, #333);
}

.sales-notes-summary .summary-box > .summary-row > *,
.sales-notes-summary .summary-box > .vat-row > * {
    padding-bottom: 4px;
}

.sales-notes-summary .summary-box > .total > * {
    padding-bottom: 0;
}

.total span:last-child,
.total .summary-value {
    font-weight: bold; /* Ensure all parts of total line are bold */
    color: var(--text-dark, #333);
}

/* ============================================
   Autocomplete Styles
   ============================================ */

.autocomplete-dropdown {
    position: fixed;
    background: var(--background-card, #ffffff);
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 10000;
    box-shadow: 0 4px 6px var(--shadow-color, rgba(0, 0, 0, 0.1));
    color: var(--text-dark, #333333);
}

.autocomplete-option {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-dark, #333333);
    transition: background-color 0.15s ease;
}

.autocomplete-option:hover,
.autocomplete-option.highlighted {
    background-color: var(--brand-color-lighter, rgba(175, 100, 100, 0.08));
    color: var(--text-dark, #333333);
}

[data-theme="dark"] .autocomplete-option:hover,
[data-theme="dark"] .autocomplete-option.highlighted {
    background-color: var(--brand-color-light, rgba(175, 100, 100, 0.25));
}

.autocomplete-option:last-child {
    border-bottom: none;
}

/* ============================================
   Page Header
   ============================================ */

.page-header {
    margin-bottom: 16px;
}

.page-header h1 {
    font-size: 28px;
    color: var(--text-dark, #495057);
    margin: 0;
}

.sales-edit-page-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

.sales-edit-page-header h1 {
    font-size: 26px;
    line-height: 1.2;
}

[data-theme="dark"] .sales-edit-page-header {
    border-bottom-color: var(--header-table-border, #444);
}

.page-header--with-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
}

.page-header-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-muted, #6c757d);
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.list-page-header {
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

.list-page-header .page-header-main {
    min-width: 0;
}

.list-page-header .page-header-actions {
    flex: 1 1 auto;
    margin-left: auto;
    justify-content: flex-end;
    align-items: center;
    gap: 12px 16px;
    min-width: 0;
}

.list-page-header .sales-list-filter-chips {
    flex: 0 1 auto;
    margin: 0;
    min-width: 0;
    max-width: min(520px, 40vw);
    justify-content: flex-end;
}

.list-page-header .sales-list-search-wrap {
    flex: 0 1 420px;
    width: min(420px, 42vw);
    min-width: 180px;
    max-width: 420px;
}

.list-page-header .sales-list-year-form {
    margin: 0;
    flex: 0 0 auto;
}

.list-page-header .sales-list-year-form select {
    width: auto;
    min-width: 110px;
    font-size: 14px;
}

.list-page-header .list-filter-form {
    margin: 0;
}

.list-page-header .list-filter-toggle {
    font-size: 0.875rem;
    color: var(--text-muted, #6c757d);
    white-space: nowrap;
}

[data-theme="dark"] .list-page-header {
    border-bottom-color: var(--header-table-border, #444);
}

[data-theme="dark"] .list-page-header .list-filter-toggle {
    color: var(--text-muted, #adb5bd);
}

@media (max-width: 640px) {
    .list-page-header .page-header-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }

    .list-page-header .sales-list-filter-chips {
        flex: 1 1 100%;
        order: 2;
    }

    .list-page-header .sales-list-search-wrap {
        flex: 1 1 100%;
        width: 100%;
        max-width: none;
        order: 1;
    }
}

/* Active / Completed view switch — quieter than the primary CTA */
.list-status-tabs {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    margin: 0;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    overflow: hidden;
    background: var(--background-card, #ffffff);
}

.list-status-tab {
    padding: 5px 16px;
    border: 0;
    border-right: 1px solid var(--border-color, #ced4da);
    border-radius: 0;
    background: transparent;
    color: var(--text-muted, #6c757d);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.5;
}

.list-status-tab:last-child {
    border-right: 0;
}

.list-status-tab:hover {
    background: var(--background-light, #f8f9fa);
    color: var(--text-dark, #333);
}

.list-status-tab.is-active {
    background: rgba(175, 100, 100, 0.12);
    color: var(--brand-color, rgb(175, 100, 100));
    font-weight: 600;
}

[data-theme="dark"] .list-status-tabs {
    background: var(--background-card, #1e1e1e);
    border-color: var(--border-color, #555);
}

[data-theme="dark"] .list-status-tab {
    border-right-color: var(--border-color, #555);
    color: var(--text-muted, #adb5bd);
}

[data-theme="dark"] .list-status-tab:hover {
    background: var(--background-light, #0f0f0f);
    color: var(--text-dark, #f5f5f5);
}

[data-theme="dark"] .list-status-tab.is-active {
    background: rgba(175, 100, 100, 0.22);
    color: rgb(220, 150, 150);
}

/* Sales list filter bar (year + chips only; search is in the page header) */
.sales-list-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: -4px 0 16px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

.sales-list-search-wrap {
    flex: 1 1 320px;
    max-width: 420px;
}

.sales-list-year-form {
    margin: 0 0 0 auto;
}

.sales-list-year-form select {
    width: auto;
    min-width: 110px;
    font-size: 14px;
}

.sales-list-filter-bar .sales-list-filter-chips {
    flex: 1 1 auto;
    margin-top: 0;
}

.sales-list-search-input {
    width: 100%;
    font-size: 14px;
}

.sales-list-filter-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.sales-list-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color, #ced4da);
    background: var(--background-muted, #f8f9fa);
    color: var(--text-dark, #333);
    font-size: 12px;
    text-decoration: none;
    line-height: 1.35;
}

.sales-list-filter-chip:hover {
    border-color: var(--brand-color, rgb(175, 100, 100));
    text-decoration: none;
}

.sales-list-filter-chip-remove {
    font-size: 14px;
    line-height: 1;
    opacity: 0.65;
}

.sales-list-limit-hint {
    margin: 0 0 12px;
    font-size: 12px;
    color: var(--text-muted, #6c757d);
}

.sales-list-search-dropdown {
    max-height: 320px;
    overflow-y: auto;
}

.sales-list-search-dropdown--columns {
    max-height: 400px;
    width: max-content;
    max-width: min(96vw, 1100px);
}

.sales-list-search-columns-wrap {
    padding: 8px 10px 10px;
}

.sales-list-search-columns-hint {
    margin: 0 0 10px;
    padding: 0 2px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-muted, #6c757d);
}

[data-theme="dark"] .sales-list-search-columns-hint {
    color: var(--text-muted, #a8a8a8);
}

.sales-list-search-columns {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(200px, max-content);
    gap: 10px;
    align-items: start;
}

.sales-list-search-column {
    min-width: 200px;
    max-width: 360px;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 6px;
    overflow: hidden;
    background: var(--background-muted, #f8f9fa);
}

[data-theme="dark"] .sales-list-search-column {
    background: var(--background-elevated, #2a2a2a);
    border-color: var(--border-color, #404040);
}

.sales-list-search-column.autocomplete-section {
    border-bottom: none;
}

.sales-list-search-column .autocomplete-section-header {
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--border-color, #dee2e6);
    text-align: center;
}

.sales-list-search-section .autocomplete-section-header {
    position: sticky;
    top: 0;
    z-index: 1;
}

.sales-list-search-option {
    font-size: 13px;
    white-space: normal;
    line-height: 1.35;
    padding-top: 6px;
    padding-bottom: 6px;
}

.sales-list-search-dropdown--columns .sales-list-search-option {
    padding-left: 10px;
    padding-right: 10px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

[data-theme="dark"] .sales-list-filter-bar {
    border-bottom-color: var(--header-table-border, #444);
}

[data-theme="dark"] .sales-list-filter-chip {
    background: #2a2a2a;
    border-color: #555;
    color: #e8eaed;
}


.content-section {
    background: var(--background-card, #ffffff);
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px var(--shadow-color, rgba(0, 0, 0, 0.1));
}

.content-section h2 {
    font-size: 20px;
    color: var(--text-dark, #495057);
    margin-bottom: 15px;
}

/* Dark mode adjustments for page elements */
[data-theme="dark"] .page-header h1 {
    color: var(--text-dark, #f5f5f5);
}

[data-theme="dark"] .content-section {
    background: var(--background-card, #1e1e1e);
}

[data-theme="dark"] .content-section h2 {
    color: var(--text-dark, #f5f5f5);
}

/* ============================================
   Convert quote to order
   ============================================ */

.convert-order-page .convert-order-back {
    margin: 0;
}

.convert-order-page .convert-order-back-link {
    font-size: 13px;
    color: var(--brand-color, rgb(175, 100, 100));
    text-decoration: none;
    font-weight: 600;
}

.convert-order-page .convert-order-back-link:hover {
    text-decoration: underline;
}

.convert-order-page .convert-order-notes {
    margin-top: 12px;
}

.convert-order-page .convert-order-notes-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #6c757d);
}

.convert-order-page .convert-order-notes textarea {
    width: 100%;
    min-height: 96px;
    padding: 8px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
    background-color: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
}

.convert-order-page .convert-order-notes textarea:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 25%, transparent);
}

.convert-order-page .quote-details td.timestamp-cell a {
    color: var(--brand-color, rgb(175, 100, 100));
    text-decoration: none;
    font-weight: 600;
}

.convert-order-page .quote-details td.timestamp-cell a:hover {
    text-decoration: underline;
}

.convert-order-page .convert-order-currency-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark, #333);
}

.convert-order-page .edit-table-header select:not(.lead-time-unit) {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 4px 8px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 0;
    font-size: 14px;
    background-color: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
    text-align: right;
    text-align-last: right;
}

.convert-order-page .edit-table-header select:not(.lead-time-unit):focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 25%, transparent);
}

.convert-order-page .quote-details select.lead-time-unit {
    position: static;
}

.convert-order-page .sales-items-table .include-col input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--brand-color, rgb(175, 100, 100));
}

.convert-order-page .sales-items-table td.details-col {
    padding: 8px 10px;
    vertical-align: middle;
}

.convert-order-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #dee2e6);
    width: 100%;
}

.convert-order-actions .summary-actions-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
}

.convert-order-page #convert_order_notes {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
    background-color: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
}

[data-theme="dark"] .convert-order-page .convert-order-notes textarea {
    background-color: var(--background-card, #1e1e1e);
    color: var(--text-dark, #e0e0e0);
    border-color: var(--border-color, #444);
}

[data-theme="dark"] .convert-order-page .edit-table-header select:not(.lead-time-unit) {
    background-color: var(--background-card, #1e1e1e);
    color: var(--text-dark, #e0e0e0);
    border-color: var(--border-color, #444);
}

[data-theme="dark"] .convert-order-page .convert-order-currency-value {
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .convert-order-actions {
    border-top-color: var(--border-color, #444);
}

/* ============================================
   Update Button
   ============================================ */

button[type="submit"][form="edit-record"] {
    background-color: var(--brand-color, #007bff);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin-top: 12px;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px var(--shadow-color, rgba(0, 0, 0, 0.1));
}

button[type="submit"][form="edit-record"]:hover {
    background-color: var(--brand-color-hover, rgba(0, 123, 255, 0.8));
    transform: translateY(-1px);
    box-shadow: 0 4px 6px var(--shadow-color, rgba(0, 0, 0, 0.15));
}

button[type="submit"][form="edit-record"]:active {
    transform: translateY(0);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    .top-sections {
        flex-direction: column;
    }
    
    .sales-notes-summary {
        flex-direction: column;
    }
    
    .sales-items-table {
        font-size: 12px;
    }
    
    .sales-items-table th {
        padding: 10px 4px !important;
    }
    .sales-items-table td {
        padding: 6px 4px;
    }
    
    .details-col {
        min-width: 200px;
    }
}

/* ============================================
   Button Styles
   ============================================ */

.button-primary {
    background-color: var(--brand-color, #af6464);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s ease;
}

.button-primary:hover {
    background-color: rgba(175, 100, 100, 0.9);
}

.button-primary:active {
    background-color: rgba(175, 100, 100, 0.8);
}

.button-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s ease;
}

.button-secondary:hover {
    background-color: #5a6268;
}

.button-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.button-danger:hover {
    background-color: #c82333;
}

.button-danger-icon {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.button-danger-icon:hover {
    background-color: #c82333;
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
    display: none !important;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

.text-muted {
    color: var(--text-muted, #6c757d);
}

/* Dark theme for text-muted */
[data-theme="dark"] .text-muted {
    color: var(--text-muted, #b0b0b0);
}

/* ============================================
   Autocomplete Section Styles
   ============================================ */

.autocomplete-section {
    border-bottom: 1px solid #e0e0e0;
}

.autocomplete-section:last-child {
    border-bottom: none;
}

.autocomplete-section-header {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    letter-spacing: 0.5px;
}

.autocomplete-item-label {
    font-weight: 500;
}

.autocomplete-item-company {
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
}

[data-theme="dark"] .autocomplete-section-header {
    background-color: #2d2d2d;
    color: #b0b0b0;
    border-bottom-color: #404040;
}

[data-theme="dark"] .autocomplete-section {
    border-bottom-color: #404040;
}

/* ============================================
   Items Filter Section
   ============================================ */

.items-filter-section {
    background: var(--background-light, #f8f9fa);
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color, #dee2e6);
}

.items-filter-form {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 15px;
    align-items: end;
}

.filter-field {
    display: flex;
    flex-direction: column;
}

.filter-field-button {
    display: flex;
    align-items: flex-end;
}

.filter-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-dark, #495057);
    font-size: 14px;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    font-size: 14px;
    background: var(--background-card, #ffffff);
    color: var(--text-dark, #333333);
    font-family: inherit;
}

.filter-select-multiple {
    min-height: 38px;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--brand-color, #af6464);
    box-shadow: 0 0 0 2px rgba(175, 100, 100, 0.1);
}

/* Dark theme for filter section */
[data-theme="dark"] .items-filter-section {
    background: var(--background-card, #2d2d2d);
    border-color: var(--border-color, #404040);
}

[data-theme="dark"] .filter-label {
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .filter-input,
[data-theme="dark"] .filter-select {
    background: var(--background-card, #1e1e1e);
    border-color: var(--border-color, #404040);
    color: var(--text-dark, #f5f5f5);
}

[data-theme="dark"] .filter-input::placeholder {
    color: var(--text-muted, #888);
}

[data-theme="dark"] .filter-input:focus,
[data-theme="dark"] .filter-select:focus {
    border-color: var(--brand-color, #af6464);
    box-shadow: 0 0 0 2px rgba(175, 100, 100, 0.2);
}

/* Multiple select styling for dark theme */
[data-theme="dark"] select[multiple],
[data-theme="dark"] .filter-select-multiple,
[data-theme="dark"] select.form-control[multiple] {
    background: var(--background-card, #1e1e1e) !important;
    border-color: var(--border-color, #404040) !important;
    color: var(--text-dark, #f5f5f5) !important;
}

[data-theme="dark"] select[multiple] option,
[data-theme="dark"] .filter-select-multiple option,
[data-theme="dark"] select.form-control[multiple] option {
    background: var(--background-card, #1e1e1e);
    color: var(--text-dark, #f5f5f5);
}

[data-theme="dark"] select[multiple] option:checked,
[data-theme="dark"] .filter-select-multiple option:checked,
[data-theme="dark"] select.form-control[multiple] option:checked {
    background: var(--brand-color, #af6464);
    color: #ffffff;
}

/* Scrollbar styling for multiple selects and autocomplete dropdown in dark theme */
[data-theme="dark"] select[multiple]::-webkit-scrollbar,
[data-theme="dark"] .filter-select-multiple::-webkit-scrollbar,
[data-theme="dark"] select.form-control[multiple]::-webkit-scrollbar,
[data-theme="dark"] .autocomplete-dropdown::-webkit-scrollbar {
    width: 12px;
    background: var(--background-card, #1e1e1e);
}

[data-theme="dark"] select[multiple]::-webkit-scrollbar-thumb,
[data-theme="dark"] .filter-select-multiple::-webkit-scrollbar-thumb,
[data-theme="dark"] select.form-control[multiple]::-webkit-scrollbar-thumb,
[data-theme="dark"] .autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-color, #404040);
    border-radius: 6px;
}

[data-theme="dark"] select[multiple]::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .filter-select-multiple::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] select.form-control[multiple]::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #505050;
}

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.status-badge.status-active {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

[data-theme="dark"] .status-badge.status-active {
    background: #1e4d2e;
    color: #90ee90;
}

[data-theme="dark"] .status-badge.status-inactive {
    background: #4d1e1e;
    color: #ff6b6b;
}

/* Responsive filter form */
@media (max-width: 1200px) {
    .items-filter-form {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .filter-field-button {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .items-filter-form {
        grid-template-columns: 1fr;
    }
}

/* Record document attachments */
.record-documents-panel {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--header-table-border, #dee2e6);
    border-radius: 4px;
    background: var(--background-card, #fff);
}

.record-documents-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin-bottom: 8px;
}

.record-documents-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.record-documents-upload-btn {
    cursor: pointer;
    margin: 0;
    font-size: 13px;
}

.record-documents-upload-btn.is-uploading {
    opacity: 0.7;
    pointer-events: none;
}

.record-documents-empty.record-documents-error {
    color: var(--danger, #dc3545);
    font-style: normal;
    font-weight: 500;
}

.record-documents-upload-meta {
    margin-bottom: 8px;
}

.record-documents-type-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
}

.record-documents-type-select {
    max-width: 200px;
}

.record-documents-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.record-documents-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color, #eee);
}

.record-documents-item:last-child {
    border-bottom: none;
}

.record-documents-link {
    color: var(--brand-color, rgb(175, 100, 100));
    font-weight: 600;
    text-decoration: none;
}

.record-documents-link:hover {
    text-decoration: underline;
}

.record-documents-cert-meta,
.record-documents-date {
    display: block;
    font-size: 12px;
    color: var(--text-muted, #6c757d);
}

.record-documents-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.record-line-cert-panel {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.record-line-cert-title {
    margin: 0 0 10px;
    font-size: 14px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
}

.line-cert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    padding: 4px;
    font-size: 14px;
    line-height: 1;
    color: var(--brand-color, rgb(175, 100, 100));
    opacity: 0.85;
    flex-shrink: 0;
    cursor: default;
}

.record-item-drawing-panel {
    margin-top: 12px;
}

.modal-open-item-link {
    flex-shrink: 0;
    margin-left: 12px;
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
}

/* .button-secondary sets display:inline-block, which overrides [hidden] */
.modal-open-item-link[hidden] {
    display: none !important;
}

#editItemDetailsModal .record-item-drawing-panel,
#editItemDetailsModal .record-line-cert-panel {
    margin-top: 0;
    padding: 0;
    border: none;
    background: transparent;
}

/* Item details modal layout */
.item-details-modal-content {
    display: flex;
    flex-direction: column;
    max-width: 760px;
    width: 94%;
    max-height: 90vh;
    overflow: hidden;
    padding: 0;
}

.item-details-modal-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--background-card, #fff);
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

.item-details-modal-subtitle {
    font-size: 13px;
    color: var(--text-muted, #6c757d);
    font-weight: normal;
}

.item-details-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem 1.5rem 1.25rem;
}

.item-details-modal-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    border-top: 1px solid var(--border-color, #dee2e6);
    background: var(--background-card, #fff);
    position: sticky;
    bottom: 0;
    z-index: 2;
}

.item-details-save-hint {
    margin-right: auto;
    font-size: 13px;
    color: var(--text-muted, #6c757d);
}

.item-details-modal-form .form-group:last-child {
    margin-bottom: 0;
}

.item-details-grade-context {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted, #6c757d);
    line-height: 1.4;
}

.item-details-spec-grid {
    margin-top: 0.25rem;
}

.item-details-section {
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 6px;
    margin-top: 12px;
    background: var(--background-card, #fff);
}

.item-details-section:first-child {
    margin-top: 0;
}

.item-details-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark, #333);
    cursor: pointer;
    text-align: left;
}

.item-details-section-toggle:hover {
    background: var(--background-hover, rgba(0, 0, 0, 0.03));
}

.item-details-section-chevron::before {
    content: '▸';
    display: inline-block;
    color: var(--text-muted, #6c757d);
    transition: transform 0.15s ease;
}

.item-details-section.is-open .item-details-section-chevron::before {
    transform: rotate(90deg);
}

.item-details-section-body {
    padding: 0 14px 14px;
    border-top: 1px solid var(--border-color, #e9ecef);
}

.item-details-section:not(.is-open) .item-details-section-body {
    display: none;
}

#editItemDetailsModal .record-item-drawing-panel .record-documents-title {
    display: none;
}

#editItemDetailsModal .record-item-drawing-panel {
    margin-top: 8px;
}

#editItemDetailsModal .record-item-drawing-panel.is-empty-compact {
    padding: 0;
    border: none;
}

#editItemDetailsModal .record-item-drawing-panel.is-empty-compact .record-documents-head {
    margin-bottom: 0;
}

.record-line-cert-panel {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.record-line-cert-title {
    display: none;
}

.record-line-subheading {
    margin: 10px 0 6px;
    font-size: 13px;
    font-weight: 600;
}

.record-line-procurement-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 10px;
}

.record-line-cert-upload-details {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px dashed var(--border-color, #ced4da);
    border-radius: 4px;
    background: var(--background-subtle, #f8f9fa);
}

.record-line-cert-upload-details .record-line-cert-upload {
    margin-top: 10px;
}

.record-line-link-lot {
    margin-top: 10px;
}

.record-line-traceability-links {
    margin: 8px 0 0;
    font-size: 13px;
}

.record-line-traceability-links a {
    color: var(--brand-color, rgb(175, 100, 100));
    font-weight: 600;
    text-decoration: none;
}

.record-line-traceability-links a:hover {
    text-decoration: underline;
}

[data-theme="dark"] .item-details-modal-header,
[data-theme="dark"] .item-details-modal-footer {
    background: var(--background-card, #1e1e1e);
}

[data-theme="dark"] .record-line-cert-upload-details {
    background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] #editItemDetailsModal .record-item-drawing-panel,
[data-theme="dark"] #editItemDetailsModal .record-line-cert-panel {
    background: transparent;
}

[data-theme="dark"] .record-documents-panel {
    background: var(--background-card, #1e1e1e);
    border-color: var(--border-color, #444);
}

[data-theme="dark"] .record-documents-link {
    color: #f28b82;
}

/* ============================================
   Page tabs (materials, shared list views)
   ============================================ */

.page-tabs,
.master-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 0 0 20px;
    padding: 0;
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

.page-tab,
.master-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    text-decoration: none;
}

.page-tab:hover,
.master-tab:hover {
    color: var(--text-dark, #495057);
    text-decoration: none;
}

.page-tab.is-active,
.master-tab.is-active {
    color: var(--brand-color, rgb(175, 100, 100));
    border-bottom-color: var(--brand-color, rgb(175, 100, 100));
}

.page-tab .badge,
.master-tab .badge {
    font-size: 10px;
    padding: 1px 7px;
    vertical-align: baseline;
}

[data-theme="dark"] .page-tabs,
[data-theme="dark"] .master-tabs {
    border-bottom-color: var(--header-table-border, #444);
}

[data-theme="dark"] .page-tab:hover,
[data-theme="dark"] .master-tab:hover {
    color: var(--text-dark, #f5f5f5);
}

/* ============================================
   Materials — grades & library
   ============================================ */

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 999px;
    vertical-align: middle;
}

.badge-muted {
    background: var(--background-muted, #f1f3f5);
    color: var(--text-muted, #6c757d);
    border: 1px solid var(--border-color, #dee2e6);
}

[data-theme="dark"] .badge-muted {
    background: #2a2a2a;
    border-color: var(--border-color, #444);
    color: var(--text-muted, #adb5bd);
}

.materials-section-lead {
    margin: -4px 0 16px;
    font-size: 13px;
    color: var(--text-muted, #6c757d);
    font-style: normal;
}

.materials-group-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.materials-group-chip.is-active {
    border-color: var(--brand-color, rgb(175, 100, 100));
    color: var(--brand-color, rgb(175, 100, 100));
    background: rgba(175, 100, 100, 0.08);
    font-weight: 600;
}

[data-theme="dark"] .materials-group-chip.is-active {
    background: rgba(175, 100, 100, 0.18);
}

.materials-filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
    margin-bottom: 16px;
}

.materials-filter-form .form-group {
    margin-bottom: 0;
}

.materials-filter-form .form-control {
    min-width: 180px;
}

.materials-catalog-equiv {
    color: var(--text-muted, #6c757d);
    font-size: 13px;
    max-width: 520px;
}

.materials-catalog-actions-col {
    width: 44px;
}

.materials-catalog-actions {
    text-align: right;
    white-space: nowrap;
}

.materials-catalog-remove-form {
    display: inline;
    margin: 0;
}

.materials-catalog-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #c00;
    font-size: 1.05em;
    line-height: 1;
}

.materials-catalog-remove:hover {
    color: #a00;
}

.material-grade-equivalents-table th:last-child,
.material-grade-equivalents-table td.materials-library-actions {
    width: 9.5rem;
    min-width: 9.5rem;
}

.materials-library-actions {
    text-align: right;
    white-space: nowrap;
}

.materials-library-actions form {
    display: block;
}

/* Table-row actions: outline = available (.materials-library-add-btn), solid = added (.materials-library-in-catalog).
   Colours match .button-primary; size matches compact table controls, not page-level buttons. */
.materials-library-add-btn,
.materials-library-in-catalog {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 4px 10px;
    min-height: 26px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    border-radius: 3px;
    white-space: nowrap;
    box-sizing: border-box;
    border: 1px solid var(--brand-color, rgb(175, 100, 100));
}

.materials-library-add-btn {
    background: transparent;
    color: var(--brand-color, rgb(175, 100, 100));
    cursor: pointer;
}

.materials-library-add-btn:hover:not(:disabled) {
    background: rgba(175, 100, 100, 0.08);
}

.materials-library-add-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

.materials-library-search {
    margin-bottom: 14px;
    max-width: 420px;
}

.materials-library-search .form-group,
.materials-library-search label {
    margin-bottom: 6px;
    display: block;
    font-size: 13px;
    font-weight: 600;
}

.materials-library-family-filters {
    margin-bottom: 10px;
}

.materials-library-sub-filters {
    margin-bottom: 16px;
    padding-left: 2px;
}

.materials-library-sub-chip {
    font-size: 11px;
}

.materials-library-empty {
    margin-top: 20px;
    padding: 32px 20px;
    text-align: center;
    background: var(--background-muted, #f8f9fa);
    border: 1px dashed var(--border-color, #ced4da);
    border-radius: 4px;
    color: var(--text-muted, #6c757d);
}

.materials-library-empty p {
    margin: 0;
}

.materials-library-empty-meta {
    margin-top: 8px !important;
    font-size: 12px;
    opacity: 0.85;
}

.materials-library-results-meta {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-muted, #6c757d);
}

.materials-library-results-meta a {
    font-weight: 600;
}

[data-theme="dark"] .materials-library-empty {
    background: #252525;
    border-color: var(--border-color, #444);
}

.materials-library-in-catalog {
    color: #fff;
    background: var(--brand-color, rgb(175, 100, 100));
    cursor: default;
}

.materials-library-in-catalog .fa-check {
    font-size: 11px;
    color: #fff;
}

[data-theme="dark"] .materials-library-add-btn {
    background: transparent;
}

[data-theme="dark"] .materials-library-add-btn:hover:not(:disabled) {
    background: rgba(175, 100, 100, 0.15);
}

[data-theme="dark"] .materials-library-in-catalog {
    background: var(--brand-color, rgb(175, 100, 100));
    border-color: var(--brand-color, rgb(175, 100, 100));
    color: #fff;
}

.materials-list-hint {
    margin: 10px 0 0;
    font-style: normal;
}

.materials-empty-state {
    padding: 28px 20px;
    text-align: center;
    background: var(--background-muted, #f8f9fa);
    border: 1px dashed var(--border-color, #ced4da);
    border-radius: 4px;
}

.materials-empty-state p {
    margin: 0 0 12px;
}

.materials-empty-state p:last-child {
    margin-bottom: 0;
}

[data-theme="dark"] .materials-empty-state {
    background: #252525;
    border-color: var(--border-color, #444);
}

.material-family-group {
    margin-bottom: 8px;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 4px;
    padding: 0 12px 12px;
    background: var(--background-card, #fff);
}

.material-family-group summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 4px;
    list-style: none;
    color: var(--text-dark, #495057);
}

.material-family-group summary::-webkit-details-marker {
    display: none;
}

.material-family-group summary::before {
    content: '▸ ';
    color: var(--text-muted, #6c757d);
}

.material-family-group[open] summary::before {
    content: '▾ ';
}

.materials-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.materials-modal-overlay:not([hidden]) {
    display: flex;
}

/* Generic overlay modal (PO receive, stock browse) — centered card over a backdrop */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay:not([hidden]) {
    display: flex;
}

.modal-overlay .modal-dialog {
    background: var(--background-card, #fff);
    border-radius: 8px;
    box-shadow: 0 20px 25px var(--shadow-color, rgba(0, 0, 0, 0.2));
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-overlay .modal-dialog > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.modal-overlay .modal-body {
    overflow-y: auto;
}

.modal-overlay .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

[data-theme="dark"] .modal-overlay .modal-dialog {
    background: var(--background-card, #1e1e1e);
}

/* PO receive modal — summary panel, sectioned form */
/* Compact vertical rhythm so the whole form fits without scrolling */
#po-receive-modal .modal-body {
    padding: 18px 24px;
}

#po-receive-modal .form-group {
    margin-bottom: 12px;
}

#po-receive-modal .form-group label {
    margin-bottom: 4px;
    font-size: 12px;
}

#po-receive-modal .form-control {
    padding: 0.5rem 0.65rem;
    font-size: 14px;
    border-radius: 0.4rem;
}

.po-receive-context {
    background: var(--background-muted, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.po-receive-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.po-receive-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.po-receive-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #6c757d);
}

.po-receive-stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark, #212529);
}

.po-receive-stat.is-remaining .po-receive-stat-value {
    color: var(--primary-color, #b03a3a);
}

.po-receive-stat-sub {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #6c757d);
}

.po-receive-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--text-muted, #6c757d);
}

.po-receive-section {
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--border-color, #e9ecef);
}

.po-receive-section-title {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6c757d);
}

.po-receive-section-title--subtle {
    font-weight: 600;
    font-size: 12px;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-muted, #868e96);
}

.po-receive-qty-group {
    margin-top: 10px;
    margin-bottom: 0;
}

.po-receive-grn-group {
    margin-top: 10px;
    margin-bottom: 0;
}

.po-receive-qty-input {
    position: relative;
    display: flex;
    align-items: center;
}

.po-receive-qty-input .form-control {
    padding-right: 44px;
    -moz-appearance: textfield;
    appearance: textfield;
}

.po-receive-qty-input .form-control::-webkit-outer-spin-button,
.po-receive-qty-input .form-control::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.po-receive-qty-unit {
    position: absolute;
    right: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    pointer-events: none;
}

.po-receive-field-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted, #6c757d);
}

.po-receive-preview {
    margin: 12px 0 0;
    padding: 8px 12px;
    background: var(--background-muted, #f1f5f9);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-dark, #334155);
}

.po-receive-history-block {
    margin-bottom: 18px;
    padding: 12px 14px;
    background: var(--background-muted, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
}

.po-receive-history-title {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6c757d);
}

.po-receive-history-items {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-dark, #334155);
}

.po-receive-history-items li + li {
    margin-top: 2px;
}

.po-duplicate-warning {
    margin-top: 10px;
    padding: 8px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    font-size: 13px;
    color: #92400e;
}

.po-duplicate-warning a {
    color: inherit;
    font-weight: 600;
}

[data-theme="dark"] .po-receive-context,
[data-theme="dark"] .po-receive-history-block {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .po-receive-preview {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .po-duplicate-warning {
    background: rgba(180, 130, 20, 0.15);
    border-color: rgba(253, 230, 138, 0.3);
    color: #fcd34d;
}

.materials-modal-card {
    background: var(--background-card, #fff);
    padding: 20px 24px;
    border-radius: 4px;
    box-shadow: 0 4px 16px var(--shadow-color, rgba(0, 0, 0, 0.15));
    max-width: 420px;
    width: 90%;
}

.materials-modal-card h2 {
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--text-dark, #495057);
}

.materials-modal-option {
    display: block;
    margin: 8px 0;
    font-size: 14px;
}

.materials-modal-actions {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

[data-theme="dark"] .material-family-group {
    background: var(--background-card, #1e1e1e);
    border-color: var(--border-color, #444);
}

[data-theme="dark"] .materials-modal-card {
    background: var(--background-card, #1e1e1e);
}

[data-theme="dark"] .materials-modal-card h2 {
    color: var(--text-dark, #f5f5f5);
}

/* ============================================
   Material grade edit page
   ============================================ */

.button-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--brand-color, rgb(175, 100, 100));
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
    font-family: inherit;
}

.button-link:hover {
    opacity: 0.85;
}

.material-grade-edit-back {
    margin: 8px 0 0;
    font-size: 13px;
}

.material-grade-edit-back a {
    text-decoration: none;
}

.material-grade-copy-seed-form,
.material-grade-remove-form {
    margin: 0;
    display: inline;
}

.material-grade-tab-panel {
    display: none;
}

.material-grade-tab-panel.is-active {
    display: block;
}

.material-grade-subheading {
    margin: 20px 0 10px;
    font-size: 15px;
    font-weight: 600;
}

.material-grade-primary-badge {
    margin-left: 6px;
    font-size: 10px;
}

.material-grade-actions-col {
    width: 9rem;
    white-space: nowrap;
}

.material-grade-actions {
    text-align: right;
    white-space: nowrap;
}

.material-grade-actions .button-link {
    margin-left: 8px;
    font-size: 13px;
}

.material-grade-actions .button-link:first-child {
    margin-left: 0;
}

.material-grade-inline-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.material-grade-inline-form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
}

.material-grade-inline-form-row .form-group {
    margin-bottom: 0;
    flex: 1 1 180px;
    min-width: 140px;
}

.material-grade-inline-checkbox {
    flex: 0 0 auto !important;
    min-width: 0 !important;
}

.material-grade-inline-submit {
    flex: 0 0 auto !important;
    min-width: 0 !important;
}

.material-grade-notes-field {
    grid-column: 1 / -1;
}

.material-grade-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
    max-width: 640px;
}

.material-grade-details-span2 {
    grid-column: 1 / -1;
}

.material-grade-details-density .form-control {
    max-width: 140px;
}

.material-grade-details-form .form-group {
    margin-bottom: 0;
}

.material-grade-details-form label {
    margin-bottom: 0.35rem;
    font-size: 13px;
    font-weight: 600;
}

@media (max-width: 640px) {
    .material-grade-details-grid {
        grid-template-columns: 1fr;
        max-width: none;
    }

    .material-grade-details-density .form-control {
        max-width: none;
    }
}

.material-grade-spec-panel {
    padding: 8px 0 4px;
}

.material-grade-spec-panel-card {
    padding: 16px 18px;
    border: 1px solid var(--border-color, #dee2e6);
    border-left: 3px solid var(--brand-color, rgb(175, 100, 100));
    border-radius: 6px;
    background: var(--background-elevated, #fff);
}

.material-grade-spec-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

.material-grade-spec-panel-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.material-grade-spec-panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted, #6c757d);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.material-grade-spec-panel-close:hover {
    background: var(--background-muted, #f0f0f0);
    color: inherit;
}

.material-grade-spec-section {
    margin-bottom: 16px;
}

.material-grade-spec-section:last-of-type {
    margin-bottom: 0;
}

.material-grade-spec-section-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, #6c757d);
}

.material-grade-spec-identity-grid {
    grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr);
}

.material-grade-spec-identity-grid .material-grade-spec-identity-span {
    grid-column: 1 / -1;
}

.material-grade-spec-size-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    margin-bottom: 10px;
}

.material-grade-spec-size-row .form-group {
    flex: 1 1 140px;
    min-width: 0;
    margin: 0;
}

.material-grade-spec-preview-wrap {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.material-grade-spec-preview-label-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted, #6c757d);
    margin-bottom: 4px;
}

.material-grade-spec-preview-inline {
    margin: 0;
    padding: 8px 10px;
    min-height: 38px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    background: var(--background-muted, #f8f9fa);
    border: 1px solid var(--border-color, #dee2e6);
    font-size: 13px;
}

.material-grade-spec-label-hint {
    font-weight: 400;
    color: var(--text-muted, #6c757d);
}

.material-grade-field-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    border-radius: 50%;
    background: var(--background-muted, #e9ecef);
    color: var(--text-muted, #6c757d);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    cursor: help;
    vertical-align: middle;
}

.material-grade-spec-edit-row td {
    background: var(--background-muted, #f8f9fa);
    padding-top: 4px;
    padding-bottom: 12px;
}

.material-grade-specs-table tbody tr.is-spec-editing {
    background: rgba(175, 100, 100, 0.08);
}

.material-grade-specs-table tbody tr.is-spec-editing td:first-child {
    box-shadow: inset 3px 0 0 var(--brand-color, rgb(175, 100, 100));
}

.material-grade-spec-edit-row:not([hidden]) {
    animation: material-grade-spec-open 0.18s ease-out;
}

@keyframes material-grade-spec-open {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.material-grade-spec-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.material-grade-add-spec-form .material-grade-spec-form-actions,
.material-grade-edit-spec-form .material-grade-spec-form-actions {
    grid-column: unset;
}

.material-grade-spec-prices {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color, #dee2e6);
}

.material-grade-spec-prices-summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    user-select: none;
}

.material-grade-spec-prices .list-table {
    margin-top: 10px;
}

.material-grade-price-heading {
    margin: 16px 0 8px;
    font-size: 14px;
}

.material-grade-specs-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 12px;
}

.material-grade-specs-header-main h2 {
    margin: 0 0 4px;
}

.material-grade-specs-header-main .materials-section-lead {
    margin: 0;
}

.material-grade-spec-custom-hint {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted, #6b7280);
}

.material-grade-add-spec-modal-card {
    max-width: 620px;
    width: min(620px, 94vw);
}

.material-grade-spec-preview {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-muted, #6c757d);
}

.material-grade-flash {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 14px;
}

.material-grade-flash.is-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.material-grade-flash.is-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

[data-theme="dark"] .material-grade-spec-edit-row td {
    background: #252525;
}

[data-theme="dark"] .material-grade-spec-panel-card {
    background: #2a2a2a;
    border-color: var(--border-color, #444);
}

[data-theme="dark"] .material-grade-spec-preview-inline {
    background: #1f1f1f;
    border-color: var(--border-color, #444);
}

[data-theme="dark"] .material-grade-spec-panel-close:hover {
    background: #333;
}

[data-theme="dark"] .material-grade-specs-table tbody tr.is-spec-editing {
    background: rgba(175, 100, 100, 0.12);
}

[data-theme="dark"] .material-grade-inline-form {
    border-top-color: var(--border-color, #444);
}

.procurement-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.procurement-panel h2 {
    font-size: 1.05rem;
    margin-bottom: 10px;
}

.sales-dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.sales-dashboard-kpi {
    background: var(--background-card, #fff);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 6px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease;
}

a.sales-dashboard-kpi:hover {
    border-color: var(--brand-color, rgb(175, 100, 100));
}

.sales-dashboard-kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-dark, #333);
}

.sales-dashboard-kpi-label {
    font-size: 0.85rem;
    color: var(--text-muted, #6c757d);
}

.sales-dashboard-section {
    margin-bottom: 28px;
}

.sales-dashboard-section-title {
    margin: 0 0 12px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, #6c757d);
}

.sales-dashboard-grid {
    display: grid;
    gap: 16px;
    align-items: start;
}

.sales-dashboard-grid--actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sales-dashboard-grid--recent {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sales-dashboard-panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.sales-dashboard-panel-head h2,
.sales-dashboard-panel-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-dark, #333);
}

.sales-dashboard-panel-link {
    flex: 0 0 auto;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand-color, rgb(175, 100, 100));
    text-decoration: none;
}

.sales-dashboard-panel-link:hover {
    text-decoration: underline;
}

.sales-dashboard .master-section.procurement-panel {
    background: var(--background-card, #fff);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 6px;
    padding: 14px 16px;
    min-width: 0;
}

.sales-dashboard .master-empty {
    color: var(--text-muted, #6c757d);
    font-style: italic;
    font-size: 13px;
    margin: 0;
}

.sales-dashboard-table {
    table-layout: fixed;
    width: 100%;
}

.sales-dashboard-table th:first-child,
.sales-dashboard-table td:first-child {
    width: 6.75rem;
}

.sales-dashboard-table th:last-child,
.sales-dashboard-table td:last-child {
    width: 7.5rem;
    white-space: nowrap;
}

.sales-dashboard-table th:nth-child(2),
.sales-dashboard-table td:nth-child(2) {
    overflow: hidden;
    max-width: 0;
}

/* Needs attention: Order # | Customer | Due (date · urgency · qty) */
.sales-dashboard-table--attention-orders th:last-child,
.sales-dashboard-table--attention-orders td:last-child {
    width: 17.5rem;
    white-space: nowrap;
}

/* Needs attention: Delivery # | Customer | Order # | Days */
.sales-dashboard-table--attention-invoices th:nth-child(3),
.sales-dashboard-table--attention-invoices td:nth-child(3) {
    width: 6.75rem;
    white-space: nowrap;
}

.sales-dashboard-table--attention-invoices th:last-child,
.sales-dashboard-table--attention-invoices td:last-child {
    width: 4.25rem;
}

.sales-dashboard-table td,
.sales-dashboard-table th {
    vertical-align: middle;
}

/* Peach hover — same affordance as orders / quotations / deliveries lists */
.sales-dashboard .list-table.sales-dashboard-table tbody tr:hover,
.sales-dashboard .list-table.sales-dashboard-table tbody tr:hover td,
.sales-dashboard .list-table.sales-dashboard-table tbody tr.table-row-link:hover,
.sales-dashboard .list-table.sales-dashboard-table tbody tr.table-row-link:hover td {
    background-color: #ffcd82;
    color: #111111;
}

[data-theme="dark"] .sales-dashboard .list-table.sales-dashboard-table tbody tr:hover,
[data-theme="dark"] .sales-dashboard .list-table.sales-dashboard-table tbody tr:hover td,
[data-theme="dark"] .sales-dashboard .list-table.sales-dashboard-table tbody tr.table-row-link:hover,
[data-theme="dark"] .sales-dashboard .list-table.sales-dashboard-table tbody tr.table-row-link:hover td {
    background-color: #ffcd82;
    color: #111111;
}

.sales-dashboard-ellipsis {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .sales-dashboard-grid--recent {
        grid-template-columns: 1fr;
    }

    .sales-dashboard-grid--actions {
        grid-template-columns: 1fr;
    }

    .sales-dashboard-kpis {
        grid-template-columns: 1fr;
    }
}

[data-theme="dark"] .sales-dashboard-kpi,
[data-theme="dark"] .sales-dashboard .master-section.procurement-panel {
    background: var(--background-card, #1e1e1e);
    border-color: var(--border-color, #3c4043);
}

[data-theme="dark"] .sales-dashboard-kpi-value {
    color: var(--text-dark, #e8eaed);
}

[data-theme="dark"] .sales-dashboard-panel-head h2,
[data-theme="dark"] .sales-dashboard-panel-head h3 {
    color: var(--text-dark, #e8eaed);
}

.po-order-chip {
    display: inline-block;
    padding: 2px 8px;
    background: #ecfdf5;
    border-radius: 4px;
    font-size: 12px;
}

.po-order-chip a {
    color: inherit;
    text-decoration: none;
}

/* PO edit page — scoped like sales #edit-page (no card shell) */
#edit-page.po-edit-page {
    margin-bottom: 24px;
}

#edit-page.po-edit-page .edit-table-header select {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 4px 8px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 0;
    font-size: 14px;
    background-color: var(--background-card, #ffffff);
    color: var(--text-dark, #333);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#edit-page.po-edit-page .edit-table-header select:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 25%, transparent);
}

[data-theme="dark"] #edit-page.po-edit-page .edit-table-header select {
    background-color: var(--background-card, #1e1e1e);
    color: var(--text-dark, #e0e0e0);
    border-color: var(--border-color, #444);
}

#edit-page.po-edit-page .po-edit-return {
    margin: 0 0 12px;
}

#edit-page.po-edit-page .customer-return-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-color, rgb(175, 100, 100));
    text-decoration: none;
}

#edit-page.po-edit-page .customer-return-link:hover {
    text-decoration: underline;
}

#edit-page.po-edit-page .po-lines-block {
    margin: 20px 0 24px;
}

#edit-page.po-edit-page .po-lines-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

#edit-page.po-edit-page .po-toolbar-btn {
    display: inline-block;
    width: auto;
    min-width: 0;
    padding: 7px 14px;
    font-size: 13px;
    line-height: 1.25;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid var(--border-color, #ced4da);
    background: var(--background-card, #fff);
    color: var(--text-dark, #212529);
    text-decoration: none;
}

#edit-page.po-edit-page .po-toolbar-btn:hover {
    border-color: var(--brand-color, rgb(175, 100, 100));
    color: var(--brand-color, rgb(175, 100, 100));
}

#edit-page.po-edit-page .po-toolbar-btn--primary {
    background: var(--brand-color, rgb(175, 100, 100));
    border-color: color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 88%, #000);
    color: var(--text-light, #fff);
}

#edit-page.po-edit-page .po-toolbar-btn--primary:hover {
    background: color-mix(in srgb, var(--brand-color, rgb(175, 100, 100)) 90%, #000);
    color: var(--text-light, #fff);
}

#edit-page.po-edit-page .po-lines-empty .po-toolbar-btn {
    margin-top: 4px;
}

#edit-page.po-edit-page .po-lines-empty-hint--inline {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--text-muted, #6c757d);
}

#edit-page.po-edit-page .po-add-line-actions .po-toolbar-btn--primary {
    min-width: 120px;
}

#edit-page.po-edit-page .po-section-heading {
    font-size: 16px;
    font-weight: 600;
    margin: 28px 0 12px;
}

#edit-page.po-edit-page .notes .po-documents-inline {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.po-edit-page .po-edit-documents-panel .record-documents-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 10px;
}

#edit-page.po-edit-page .po-notes-readonly {
    min-height: 80px;
    padding: 8px 10px;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 4px;
    background: var(--background-subtle, #f8f9fa);
    font-size: 14px;
    line-height: 1.45;
}

#edit-page.po-edit-page .po-summary-action-form {
    display: contents;
}

#edit-page.po-edit-page .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#edit-page.po-edit-page .po-lines-table.sales-items-table thead th {
    white-space: nowrap;
    font-size: 11px;
}

.po-save-status {
    font-size: 13px;
    color: var(--text-muted, #6c757d);
}

.po-header-form--compact .po-header-fields {
    display: grid;
    grid-template-columns: minmax(140px, 180px) minmax(200px, 1fr) minmax(90px, 120px);
    gap: 12px 16px;
    margin-bottom: 12px;
}

.po-header-hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--text-muted, #6c757d);
}

.po-lines-empty {
    text-align: center;
    padding: 24px 16px;
    border: 1px dashed var(--border-color, #dee2e6);
    border-radius: 4px;
    margin-bottom: 16px;
}

.po-lines-empty-hint {
    margin: 0 0 16px;
    color: var(--text-muted, #6c757d);
}

.po-activity-subhead {
    font-size: 14px;
    font-weight: 600;
    margin: 20px 0 8px;
}

.po-activity-subhead:first-of-type {
    margin-top: 0;
}

.po-line-inline-form {
    padding: 14px 16px;
    background: var(--background-subtle, #f8f9fa);
    border-radius: 4px;
}

.po-lines-table tr.po-line-edit-row > td {
    padding: 8px !important;
    vertical-align: top;
    background: var(--background-subtle, #f8f9fa);
}

/* Override sales-items-table absolute inputs — they fill the colspan cell and break this form */
.po-lines-table .po-line-inline-form input[type="text"],
.po-lines-table .po-line-inline-form input[type="number"],
.po-lines-table .po-line-inline-form input[type="date"],
.po-lines-table .po-line-inline-form select.form-control {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0;
    z-index: auto;
    background: var(--background-card, #ffffff);
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 14px;
}

.po-lines-table .po-line-inline-form input:focus,
.po-lines-table .po-line-inline-form select:focus {
    background: var(--background-card, #ffffff);
    border-color: var(--brand-color, rgb(175, 100, 100));
    outline: none;
}

.po-line-inline-grid {
    display: grid;
    gap: 12px 16px;
    align-items: start;
}

.po-line-inline-grid--order {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.85fr) minmax(0, 1fr);
}

.po-line-inline-grid--pieces {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.po-line-inline-grid .form-group,
.po-line-inline-desc.form-group {
    margin-bottom: 0;
    min-width: 0;
}

.po-line-inline-grid .form-group label,
.po-line-inline-desc.form-group label {
    margin-bottom: 4px;
    font-size: 12px;
}

.po-line-inline-desc.form-group {
    margin-bottom: 12px;
}

.po-line-inline-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
}

.po-line-inline-ref-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.po-line-inline-ref-value {
    font-weight: 600;
    font-size: 15px;
}

.po-line-inline-sections {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 20px 28px;
    align-items: start;
}

.po-line-inline-sections--single {
    grid-template-columns: minmax(0, 1fr);
    max-width: 520px;
}

.po-line-inline-fieldset {
    border: none;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.po-line-inline-fieldset legend {
    display: block;
    width: 100%;
    padding: 0 0 8px;
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-color, #e9ecef);
}

@media (max-width: 900px) {
    .po-line-inline-sections {
        grid-template-columns: 1fr;
    }

    .po-line-inline-grid--order {
        grid-template-columns: 1fr 1fr;
    }

    .po-line-inline-grid--order .form-group:last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 520px) {
    .po-line-inline-grid--order,
    .po-line-inline-grid--pieces {
        grid-template-columns: 1fr;
    }
}

.po-line-inline-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
}

.po-spec-option-bohler {
    display: block;
    font-size: 11px;
    color: var(--text-muted, #6c757d);
}

.po-edit-flash.is-error {
    color: #b42318;
}

.po-edit-page .master-section:last-child {
    padding-bottom: 0;
    border-bottom: none;
    margin-bottom: 0;
}

.po-header-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.po-header-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.po-header-toolbar-actions form {
    margin: 0;
}

.po-header-toolbar--readonly {
    margin-top: 16px;
}

.po-header-charges {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.po-header-charges-title {
    margin: 0 0 4px;
    font-size: 0.95rem;
}

.po-header-charges-hint {
    margin: 0 0 12px;
    font-size: 0.85rem;
    color: var(--text-muted, #6b7280);
}

.po-header-charges-fields {
    display: grid;
    grid-template-columns: minmax(140px, 220px) minmax(180px, 280px);
    gap: 12px 16px;
}

.po-totals-panel {
    margin-top: 16px;
    max-width: 360px;
    margin-left: auto;
    padding: 12px 14px;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 8px;
    background: var(--surface-muted, #f8f9fa);
}

.po-totals-list {
    margin: 0;
}

.po-totals-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 6px;
    font-size: 0.92rem;
}

.po-totals-row dt,
.po-totals-row dd {
    margin: 0;
}

.po-totals-row dd {
    font-variant-numeric: tabular-nums;
}

.po-totals-row--total {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, #dee2e6);
    font-weight: 600;
}

.po-header-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 20px;
    margin: 0;
}

.po-header-summary-item {
    margin: 0;
}

.po-header-summary-item--full {
    grid-column: 1 / -1;
}

.po-header-summary dt {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted, #6c757d);
}

.po-header-summary dd {
    margin: 0;
    font-size: 14px;
}

.po-edit-page .po-edit-documents-panel {
    margin-top: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.po-edit-page .po-edit-documents-panel .record-documents-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.po-edit-page .po-edit-documents-panel .record-documents-toolbar .record-documents-type-label {
    margin: 0;
}

.po-lines-table {
    width: 100%;
}

.po-line-muted {
    color: var(--text-muted, #6c757d);
}

.po-line-material-cell {
    min-width: 12rem;
    vertical-align: top;
}

.po-line-desc-cell {
    min-width: 10rem;
    position: relative;
    vertical-align: top;
}

.po-lines-table .po-line-num-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.po-lines-table thead .po-line-num-col {
    text-align: right;
}

.po-lines-table td.po-line-qty-cell {
    text-align: right;
}

.po-lines-table td.po-line-qty-cell .item-input-quantity {
    text-align: right;
    padding-left: 6px;
    padding-right: 10px;
    -moz-appearance: textfield;
}

.po-lines-table td.po-line-qty-cell .item-input-quantity::-webkit-outer-spin-button,
.po-lines-table td.po-line-qty-cell .item-input-quantity::-webkit-inner-spin-button,
.po-lines-table td.po-line-price-cell .item-input-price::-webkit-outer-spin-button,
.po-lines-table td.po-line-price-cell .item-input-price::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.po-lines-table td.po-line-price-cell .item-input-price {
    -moz-appearance: textfield;
}

.po-lines-table .po-line-unit-col {
    width: 4.5rem;
    min-width: 4.5rem;
    max-width: 5.5rem;
}

.po-lines-table thead .po-line-unit-col {
    text-align: center;
    color: var(--text-light, #ffffff);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: bold;
}

.po-lines-table .po-line-unit-cell {
    width: 4.5rem;
    min-width: 4.5rem;
    max-width: 5.5rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.po-line-material-grade {
    display: block;
    font-weight: 500;
    line-height: 1.35;
    padding-bottom: 2px;
}

.po-line-material-size {
    display: block;
    margin-top: 2px;
    color: var(--text-muted, #6c757d);
    font-size: 0.92em;
}

.po-line-size-edit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem 0.4rem;
    margin-top: 2px;
    width: fit-content;
    max-width: 100%;
    font-size: 0.92em;
    line-height: 1.4;
    color: var(--text-muted, #6c757d);
}

.po-line-size-part {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    flex: 0 0 auto;
    margin: 0;
}

.po-line-size-part .po-line-input-piece-count,
.po-line-size-part .po-line-input-piece-length {
    flex: 0 0 auto;
    width: auto;
    min-width: 1.25em;
    max-width: 6em;
    field-sizing: content;
    margin: 0;
    padding: 0 2px;
    border: 1px solid color-mix(in srgb, var(--text-muted, #6c757d) 30%, transparent);
    border-radius: 3px;
    background: transparent;
    font-size: inherit;
    line-height: 1.4;
    color: var(--text-dark, #333);
    text-align: left;
    font-variant-numeric: tabular-nums;
    outline: none;
    box-shadow: none;
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    height: auto;
    z-index: auto;
    -moz-appearance: textfield;
}

.po-line-size-part input[type="number"]::-webkit-outer-spin-button,
.po-line-size-part input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.po-line-size-part .po-line-input-piece-count:focus,
.po-line-size-part .po-line-input-piece-length:focus {
    border-color: var(--brand-color, rgb(175, 100, 100));
    background: var(--background-card, #ffffff);
    outline: none;
}

.po-line-size-label {
    flex: 0 0 auto;
    padding: 0;
    font-size: inherit;
    line-height: 1.4;
    color: inherit;
    white-space: nowrap;
    user-select: none;
}

.po-line-size-mult {
    flex: 0 0 auto;
    color: inherit;
    font-size: inherit;
    line-height: 1.4;
    padding: 0 0.05rem;
}

[data-theme="dark"] .po-line-size-part .po-line-input-piece-count,
[data-theme="dark"] .po-line-size-part .po-line-input-piece-length {
    color: var(--text-dark, #e8e8e8);
    border-color: color-mix(in srgb, var(--text-muted, #9ca3af) 35%, transparent);
}

[data-theme="dark"] .po-line-size-part .po-line-input-piece-count:focus,
[data-theme="dark"] .po-line-size-part .po-line-input-piece-length:focus {
    background: var(--background-card, #2a2a2a);
}

.po-lines-table td.po-line-desc-cell input.po-line-input-description {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box;
    padding: 4px 6px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-dark, #333);
    outline: none;
    z-index: 10;
    transition: background 0.2s, border-color 0.2s;
}

.po-lines-table .po-line-desc-cell:has(.po-line-meta) .po-line-input-description,
.po-lines-table .po-line-desc-cell:has(.po-receipt-history) .po-line-input-description {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 1.75rem;
    z-index: auto;
}

.po-lines-table .po-line-desc-cell .po-line-input-description:focus {
    background: var(--background-card, #ffffff);
    border-color: var(--brand-color, rgb(175, 100, 100));
    outline: none;
}

.po-lines-table .po-line-unit-cell select.po-line-input-unit {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border: 1px solid transparent;
    background: transparent;
    margin: 0;
    padding: 4px 6px;
    font-size: 15px;
    outline: none;
    z-index: 10;
    font-family: inherit;
    text-align: center;
    text-align-last: center;
    cursor: pointer;
    color: var(--text-dark, #333);
    transition: background 0.2s, border-color 0.2s;
}

.po-lines-table .po-line-unit-cell select.po-line-input-unit:focus {
    background: var(--background-card, #ffffff);
    border-color: var(--brand-color, rgb(175, 100, 100));
    outline: none;
}

[data-theme="dark"] .po-lines-table .po-line-unit-cell select.po-line-input-unit {
    color: var(--text-dark, #e0e0e0);
}

[data-theme="dark"] .po-lines-table .po-line-unit-cell select.po-line-input-unit:focus {
    background: var(--background-card, #2a2a2a);
}

.po-line-row.po-line-saved-flash td {
    animation: po-line-saved-pulse 0.7s ease;
}

@keyframes po-line-saved-pulse {
    0% { background-color: color-mix(in srgb, #28a745 18%, transparent); }
    100% { background-color: transparent; }
}

.po-line-meta {
    margin-top: 6px;
}

.po-line-meta + .po-receipt-history,
.po-line-material-size + .po-line-meta {
    margin-top: 6px;
}

#edit-page.po-edit-page .po-add-line-form .field-hint,
#edit-page.po-edit-page .po-line-inline-form .field-hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted, #6c757d);
}

.po-receipt-history {
    margin-top: 6px;
    font-size: 12px;
}

.po-receipt-history-list {
    margin: 4px 0 0;
    padding-left: 18px;
}

.po-add-line-form-anchor {
    display: none;
}

.po-lines-table tbody tr.po-add-line-row td {
    vertical-align: top;
}

.po-lines-table tbody tr.po-add-line-row td.po-add-line-line-col,
.po-lines-table tbody tr.po-add-line-row td.po-line-progress,
.po-lines-table tbody tr.po-add-line-row td.po-line-status,
.po-lines-table tbody tr.po-add-line-row td.po-line-total-cell {
    font-weight: normal !important;
    vertical-align: middle !important;
}

.po-lines-table tbody tr.po-add-line-row td.po-line-total-cell,
.po-lines-table tbody tr.po-add-line-row td.po-line-progress {
    font-variant-numeric: tabular-nums;
}

.po-lines-table tbody tr.po-add-line-row td.po-add-line-detail-cell {
    font-weight: normal !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    min-width: 14rem;
}

.po-add-line-material {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-weight: normal;
}

.po-add-line-material--has-spec {
    max-height: 3.4rem;
    overflow: hidden;
}

.po-add-line-desc-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.po-add-line-desc-wrap .po-add-line-spec-picker {
    flex: 1 1 12rem;
    min-width: 10rem;
}

.po-add-line-spec-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.po-add-line-spec-wrap .po-add-line-spec-picker {
    flex: 1 1 12rem;
    min-width: 10rem;
}

.po-add-line-spec-optional {
    margin-top: 2px;
}

.po-add-line-spec-optional .po-spec-search {
    font-size: 12px;
    padding: 2px 6px;
}

.po-add-line-preview-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-weight: normal;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s;
}

.po-add-line-preview-row:hover .po-add-line-preview-actions,
.po-add-line-preview-row:focus-within .po-add-line-preview-actions {
    opacity: 1;
    visibility: visible;
}

.po-add-line-preview-actions .button-link {
    font-size: 11px;
    font-weight: normal;
}
.po-add-line-spec-change {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: normal;
    padding: 0;
    white-space: nowrap;
}

.po-add-line-preview-row[hidden] {
    display: none !important;
}

.po-add-line-preview-row:not([hidden]) {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 10px;
    min-height: 1.35em;
}

.po-add-line-material-preview {
    font-weight: 500;
    line-height: 1.35;
}

.po-add-line-size-edit {
    margin-top: 1px;
}

.po-add-line-material--spec-first:not(.po-add-line-material--has-spec) .po-add-line-size-edit {
    display: none !important;
}

.po-add-line-size-edit[hidden] {
    display: none !important;
}

.po-add-line-qty-wrap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.po-add-line-row td.po-line-qty-cell {
    position: relative;
    vertical-align: middle !important;
}

.po-add-line-row .po-add-line-qty-input {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    font-weight: normal !important;
    pointer-events: auto;
}

.po-lines-table td.po-line-qty-cell .po-add-line-qty-wrap--has-meta .po-add-line-qty-input {
    bottom: 13px !important;
    padding-right: 10px;
}

.po-add-line-qty-meta {
    position: absolute;
    top: auto;
    bottom: 2px;
    left: 8px;
    right: auto;
    width: auto;
    max-width: calc(100% - 1rem);
    height: auto;
    z-index: 11;
    pointer-events: auto;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    font-size: 10px;
    line-height: 1.2;
    font-weight: normal;
    font-variant-numeric: tabular-nums;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.po-add-line-qty-meta:not(.po-add-line-qty-meta--show) {
    display: none;
}

.po-add-line-qty-meta.po-add-line-qty-meta--show {
    display: flex;
}

.po-add-line-weight-estimate {
    margin: 0;
}

.po-add-line-material--has-spec .po-add-line-desc-wrap {
    display: none !important;
}

.po-add-line-qty-meta .po-weight-estimate {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 10px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted, #6c757d);
    overflow: hidden;
    text-overflow: ellipsis;
}

.po-add-line-qty-meta .po-use-estimate-btn {
    margin: 0;
    font-size: 10px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    padding: 0;
    color: var(--text-muted, #6c757d);
}

.po-add-line-qty-meta .po-use-estimate-btn:hover,
.po-add-line-qty-meta .po-use-estimate-btn:focus {
    color: var(--brand-color, rgb(175, 100, 100));
}

.po-add-line-use-estimate {
    padding: 0;
    margin: 0;
}

.po-add-line-field {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100%;
    height: auto !important;
    min-height: 0;
    margin: 0;
    padding: 3px 6px;
    border: 1px solid var(--border-color, #ced4da);
    border-radius: 3px;
    background: #fff;
    font-size: 13px;
    font-weight: normal;
    line-height: 1.35;
    color: var(--text-dark, #333);
    box-sizing: border-box;
    z-index: auto;
}

.po-add-line-field:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    background: #fff;
}

.po-add-line-spec-picker .po-spec-picker-control {
    position: relative;
}

.po-add-line-actions-cell {
    text-align: right;
    white-space: nowrap;
    vertical-align: middle !important;
}

.po-lines-table tbody tr.po-add-line-row td.po-line-unit-cell,
.po-lines-table tbody tr.po-add-line-row td.po-line-price-cell {
    vertical-align: middle !important;
}

.po-add-line-submit {
    min-width: 4.5rem;
    padding: 6px 12px;
    font-size: 13px;
}

.po-add-line-total {
    display: inline-block;
    font-weight: normal;
    color: var(--text-muted, #6c757d);
}

.po-add-line-total.po-add-line-total--computed {
    color: var(--text-dark, #333);
}

.po-lines-table tbody tr.po-add-line-row .po-line-progress,
.po-lines-table tbody tr.po-add-line-row .po-line-status {
    color: var(--text-muted, #6c757d);
    font-weight: normal;
}

[data-theme="dark"] .po-add-line-total.po-add-line-total--computed {
    color: #e8e8e8;
}

[data-theme="dark"] .po-lines-table tbody tr.po-add-line-row .po-line-progress,
[data-theme="dark"] .po-lines-table tbody tr.po-add-line-row .po-line-status {
    color: #adb5bd;
}

[data-theme="dark"] .po-add-line-field {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
    color: #e8e8e8;
}

[data-theme="dark"] .po-add-line-field:focus {
    background: rgba(0, 0, 0, 0.35);
    border-color: var(--brand-color, rgb(175, 100, 100));
}

[data-theme="dark"] .po-lines-table tbody tr.po-add-line-row .po-line-size-part .po-line-input-piece-count,
[data-theme="dark"] .po-lines-table tbody tr.po-add-line-row .po-line-size-part .po-line-input-piece-length {
    background: rgba(0, 0, 0, 0.15);
}

.po-add-line-fieldset {
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0 0 22px;
    background: transparent;
}

.po-add-line-fieldset:not(:last-of-type) {
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border-color, #e9ecef);
}

.po-add-line-fieldset--optional {
    background: transparent;
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
}

.po-add-line-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 28px;
    align-items: start;
    padding-bottom: 22px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border-color, #e9ecef);
}

.po-add-line-fieldset legend {
    display: block;
    width: 100%;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6c757d);
    margin: 0 0 14px;
    padding: 0;
    border-bottom: none;
}

.po-add-line-optional {
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-muted, #868e96);
}

.po-add-line-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}

.po-add-line-grid--compact {
    max-width: none;
}

.po-add-line-grid--pricing {
    grid-template-columns: minmax(0, 1fr) minmax(100px, 0.45fr);
    max-width: none;
    gap: 16px 14px;
}

.po-add-line-grid--pricing .po-add-line-span-full {
    grid-column: 1 / -1;
}

.po-add-line-span-full {
    grid-column: 1 / -1;
}

.po-add-line-form .form-group {
    margin-bottom: 0;
}

.po-add-line-form .form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark, #212529);
}

.po-add-line-form .form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid #adb5bd;
    border-radius: 4px;
    background: #fff;
    color: var(--text-dark, #212529);
    font-size: 14px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.po-add-line-form .form-control::placeholder {
    color: #868e96;
}

.po-add-line-form .form-control:focus {
    outline: none;
    border-color: var(--brand-color, rgb(175, 100, 100));
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 3px rgba(175, 100, 100, 0.15);
}

.po-add-line-form select.form-control {
    cursor: pointer;
    background-color: #fff;
}

.po-add-line-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.po-weight-estimate {
    margin: 14px 0 0;
    padding: 10px 12px;
    border: 1px dashed #ced4da;
    border-radius: 4px;
    background: var(--background-subtle, #f8f9fa);
    font-size: 13px;
    color: var(--text-muted, #495057);
    line-height: 1.45;
}

.po-use-estimate-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 0;
    font-size: 13px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.field-required {
    color: var(--brand-color, rgb(175, 100, 100));
}

.po-spec-picker-control {
    position: relative;
    display: flex;
    align-items: stretch;
}

.po-spec-search {
    flex: 1 1 auto;
    min-width: 0;
}

.po-spec-picker-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-muted, #6c757d);
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}

.po-spec-picker-clear:hover {
    color: var(--text-dark, #333);
}

.po-spec-picker-dropdown {
    max-height: 280px;
    overflow-y: auto;
}

.po-spec-picker-grade {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--background-subtle, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #dee2e6);
    padding: 6px 12px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.po-spec-picker-bohler-tag {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #6c757d);
    padding: 1px 6px;
    border-radius: 3px;
    background: #fff;
    border: 1px solid var(--border-color, #dee2e6);
}

.po-spec-picker-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px 8px 20px;
}

.po-spec-option-bohler {
    display: none;
}

.po-spec-option-label {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    line-height: 1.35;
}

.po-spec-option-meta {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted, #6c757d);
    white-space: nowrap;
}

.material-grade-spec-size-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--text-muted, #6c757d);
}

.po-line-size-hint {
    color: var(--text-muted, #6c757d);
}

@media (max-width: 768px) {
    #edit-page.po-edit-page {
        padding: 16px;
    }

    #edit-page.po-edit-page .sales-notes-summary .summary {
        flex: 1 1 auto !important;
        max-width: none !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .po-add-line-columns {
        grid-template-columns: 1fr;
    }

    .po-add-line-grid,
    .po-add-line-grid--pricing {
        grid-template-columns: 1fr;
    }

    .po-edit-page .po-header-form.master-grid-3,
    .po-header-form--compact .po-header-fields {
        grid-template-columns: 1fr;
    }
    .po-header-summary {
        grid-template-columns: 1fr;
    }

    .po-edit-page .master-field--narrow {
        max-width: none;
    }

    .po-header-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .po-header-toolbar-actions {
        justify-content: flex-start;
    }
}

/* Material stock page */
.stock-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color, #dee2e6);
}

.stock-filter-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 20px;
    flex: 1 1 480px;
    min-width: 0;
}

.stock-filter-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
}

.stock-filter-field--grade .form-control {
    min-width: 160px;
    max-width: 220px;
}

.stock-filter-field--search .form-control {
    min-width: 200px;
    max-width: 280px;
}

.stock-filter-checks {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding-bottom: 8px;
}

.stock-filter-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    color: var(--text-dark, #333);
    cursor: pointer;
    white-space: nowrap;
}

.stock-filter-check input {
    margin: 0;
    flex-shrink: 0;
}

.stock-filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.stock-table {
    width: 100%;
}

@media (max-width: 640px) {
    .stock-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .stock-filter-fields {
        flex-direction: column;
        align-items: stretch;
    }

    .stock-filter-field--grade .form-control,
    .stock-filter-field--search .form-control {
        max-width: none;
        width: 100%;
    }

    .stock-filter-actions {
        justify-content: flex-start;
    }
}

.compact-table th,
.compact-table td {
    padding: 6px 8px;
    font-size: 13px;
}

.material-grade-flash.is-success,
.procurement-flash.is-success {
    background: #ecfdf5;
    color: #047857;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.material-grade-flash.is-error,
.procurement-flash.is-error {
    background: #fef2f2;
    color: #b91c1c;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
}

