/* Workshop Purchase Orders — detachable add-on (scoped) */
.ws-purchase-orders-section {
    margin-top: 0;
}
.ws-po-section-header {
    margin-top: 18px;
}
.ws-po-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}
.ws-po-toolbar a.btn-secondary {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    box-sizing: border-box;
}
.ws-po-hint {
    margin: 0 0 12px;
    font-size: 12px;
    color: #6c757d;
}
.ws-po-recent-table,
.ws-po-list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}
.ws-po-recent-table th,
.ws-po-recent-table td,
.ws-po-list-table th,
.ws-po-list-table td {
    border-bottom: 1px solid #dee2e6;
    padding: 6px 8px;
    text-align: left;
    vertical-align: middle;
}
.ws-po-list-table .col-supplier {
    width: 90px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ws-po-list-table .col-stock {
    width: 80px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ws-po-list-table .col-qty {
    width: 40px;
    text-align: center;
}
.ws-po-list-table .col-status {
    width: 60px;
    white-space: nowrap;
}
.ws-po-list-table .col-actions {
    width: auto;
}
.ws-po-list-table .col-edit {
    width: 84px;
    white-space: nowrap;
    text-align: right;
}
.ws-po-row-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}
.ws-po-list-table .btn-sm.edit,
.ws-po-list-table .btn-sm.del {
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid #ced4da;
    background: #fff;
    cursor: pointer;
    line-height: 1.3;
}
.ws-po-list-table .btn-sm.edit:hover {
    background: #e7f1ff;
    border-color: #0d6efd;
    color: #0d6efd;
}
.ws-po-list-table .btn-sm.del {
    color: #b91c1c;
    border-color: #f5c2c7;
}
.ws-po-list-table .btn-sm.del:hover {
    background: #fef2f2;
    border-color: #dc3545;
}
.ws-po-del-dispatch-box {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
}
.ws-po-del-dispatch-box label {
    display: block;
    margin-top: 6px;
    cursor: pointer;
}
.ws-po-recent-table th,
.ws-po-list-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}
.ws-po-recent-empty,
.ws-po-list-empty {
    font-size: 12px;
    color: #6c757d;
    padding: 8px 0;
}
.ws-po-list-section {
    margin-top: 4px;
}
.ws-po-list-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: linear-gradient(90deg, #ffffff 0%, #b2b7bb 100%);
    color: #495057;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    gap: 12px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
#tab-supplier-orders .ws-po-list-toggle,
#tab-workshop .ws-po-list-toggle {
    border: 1px solid #dee2e6;
    background: linear-gradient(90deg, #ffffff 0%, #b2b7bb 100%);
}
.ws-po-list-toggle .toggle-left {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.ws-po-list-toggle .section-sub {
    color: #6c757d;
    font-weight: 600;
}
.ws-po-list-hint {
    font-weight: 600;
    font-size: 13px;
    color: #6c757d;
}
.ws-po-list-toggle:hover {
    background: linear-gradient(90deg, #f8f9fa 0%, #9aa0a6 100%);
    border-color: #ced4da;
}
.ws-po-list-toggle .toggle-arrow {
    font-size: 11px;
    transition: transform 0.2s;
    color: #6c757d;
}
.ws-po-list-toggle.collapsed .toggle-arrow {
    transform: rotate(-90deg);
}
.ws-po-list-body.collapsed {
    display: none;
}
.ws-po-list-body {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #f8f9fa;
}
.ws-po-list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.ws-po-list-filters {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.ws-po-check-row {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    color: #495057;
    margin: 0;
}
.ws-po-check-row input {
    margin: 0;
}
.ws-po-list-scroll {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #fff;
    padding: 8px;
}
.ws-po-supplier-group-label {
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}
.ws-po-status-pending {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
}
.ws-po-status-sent {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: #dbeafe;
    color: #1e40af;
}
.ws-po-status-received {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: #dcfce7;
    color: #166534;
}
.ws-po-status-cancelled {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: #f1f5f9;
    color: #64748b;
}
.ws-po-list-table tr.ws-po-row-received td {
    background: #fce7f3;
}
.ws-po-list-table tr.ws-po-row-cancelled td {
    color: #6c757d;
    text-decoration: line-through;
    opacity: 0.65;
}
.ws-po-list-table tr.ws-po-row-cancelled .ws-po-status-cancelled,
.ws-po-list-table tr.ws-po-row-cancelled .btn-sm,
.ws-po-list-table tr.ws-po-row-cancelled .ws-po-row-actions {
    text-decoration: none;
}
.ws-purchase-orders-section .btn-sm {
    padding: 3px 8px;
    font-size: 11px;
}
.ws-po-stock-search-results {
    max-height: 140px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-top: 6px;
}
.ws-po-stock-search-results[hidden] {
    display: none !important;
}
.ws-po-manual-modal-content {
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 3vh auto;
}
.ws-po-manual-modal-content .modal-header {
    padding: 10px 12px 10px 16px;
    flex-shrink: 0;
}
.ws-po-manual-modal-content .modal-header h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}
.ws-po-manual-modal-content .modal-header .close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: #fff;
    color: #495057;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.ws-po-manual-modal-content .modal-header .close-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
}
.ws-po-manual-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}
.ws-po-manual-search-wrap {
    margin-bottom: 12px;
    position: relative;
}
.ws-po-stock-search-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: none;
    border-bottom: 1px solid #eee;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}
.ws-po-stock-search-item:hover,
.ws-po-stock-search-item.selected {
    background: #e7f1ff;
}
.ws-po-calc {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    margin-top: 8px;
}
.ws-po-calc-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}
.ws-po-calc-row.total {
    font-weight: 700;
    border-top: 1px solid #dee2e6;
    margin-top: 4px;
    padding-top: 6px;
}
.ws-po-readonly {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    background: #f8f9fa;
    color: #495057;
}
.ws-po-batch-supplier-block {
    margin-bottom: 16px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
}
.ws-po-batch-supplier-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: #f0f4f8;
    border-bottom: 1px solid #dee2e6;
}
.ws-po-batch-supplier-head h4 {
    margin: 0;
    font-size: 14px;
}
.ws-po-batch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.ws-po-batch-table th,
.ws-po-batch-table td {
    border-bottom: 1px solid #eee;
    padding: 6px 8px;
    text-align: left;
}
.ws-po-batch-table th {
    background: #fafbfc;
}
.ws-po-batch-table input[type="number"] {
    width: 72px;
    padding: 3px 5px;
    font-size: 12px;
}
.ws-po-warn {
    color: #856404;
    font-size: 12px;
}
.ws-po-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 8px;
}
.ws-po-progress {
    font-size: 13px;
    color: #0d6efd;
    margin: 8px 0;
}

/* Batch PO modal — single scroll region (avoid nested scrollbars) */
#purchaseOrderBatchModal .modal-content {
    width: min(900px, 92vw);
    max-width: 900px;
    max-height: min(90vh, calc(100vh - 32px));
    margin: 16px auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#purchaseOrderBatchModal .modal-header {
    flex-shrink: 0;
    padding: 10px 12px 10px 16px;
}
#purchaseOrderBatchModal .modal-header h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}
#purchaseOrderBatchModal .modal-header .close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: #fff;
    color: #495057;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
#purchaseOrderBatchModal .modal-header .close-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
}
#purchaseOrderBatchModal .ws-po-batch-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px 20px;
    -webkit-overflow-scrolling: touch;
}
#purchaseOrderBatchModal .ws-po-batch-modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px 16px;
    border-top: 1px solid #dee2e6;
    background: #fff;
}
#purchaseOrderBatchModal .ws-po-batch-supplier-block:last-child {
    margin-bottom: 0;
}

/* PO print blocks (preview / email) — mirrored in _poPrintStylesCss() for popup windows */
.ws-po-cover-note {
    margin-bottom: 28px;
    padding: 14px 16px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 13px;
    page-break-after: always;
    break-after: page;
}
.ws-po-print-doc {
    page-break-after: always;
    break-after: page;
    margin: 0 0 40px 0;
    padding: 28px 32px 32px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
.ws-po-print-doc:last-child {
    page-break-after: auto;
    break-after: auto;
    margin-bottom: 0;
}
.ws-po-print-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 2px solid #c0100e;
}
.ws-po-print-brand {
    flex: 0 0 120px;
}
.ws-po-print-logo {
    display: block;
    max-width: 120px;
    max-height: 52px;
    width: auto;
    height: auto;
}
.ws-po-print-header-main {
    flex: 1;
    text-align: right;
}
.ws-po-print-header h1 {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #c0100e;
}
.ws-po-print-company {
    text-align: right;
    font-size: 11px;
    line-height: 1.5;
    color: #4b5563;
}
.ws-po-print-company strong {
    color: #111;
    font-size: 12px;
}
.ws-po-print-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    margin-bottom: 16px;
    font-size: 12px;
    line-height: 1.5;
}
.ws-po-print-meta label {
    font-weight: 600;
    margin-right: 6px;
    color: #374151;
}
.ws-po-print-vat-banner {
    text-align: center;
    font-weight: 700;
    color: #dc2626;
    font-size: 13px;
    margin: 12px 0 16px;
    padding: 10px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
}
.ws-po-print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 12px;
}
.ws-po-print-table th,
.ws-po-print-table td {
    border: 1px solid #d1d5db;
    padding: 9px 10px;
}
.ws-po-print-table th {
    background: #f3f4f6;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #374151;
}
.ws-po-print-totals {
    max-width: 280px;
    margin-left: auto;
    font-size: 12px;
}
.ws-po-print-totals .row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}
.ws-po-print-totals .row.total {
    font-weight: 700;
    border-top: 2px solid #333;
    margin-top: 6px;
    padding-top: 8px;
    font-size: 13px;
}
@media print {
    .ws-po-print-doc {
        page-break-after: always;
        break-after: page;
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }
    .ws-po-print-doc:last-child {
        page-break-after: auto;
        break-after: auto;
    }
    .ws-po-cover-note {
        page-break-after: always;
        break-after: page;
    }
}
