/* Orders Filters */
#ordersFilters {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#ordersFilters select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: none;
    cursor: pointer;
    min-width: 160px;
    outline: none;
}

#ordersFilters select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

#ordersWarningsCheckbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    margin-left: auto;
}

/* Orders Table */
#ordersTable {
    overflow: hidden;
}

#ordersTable table {
    width: 100%;
    border-collapse: collapse;
}

#ordersTable th {
    background: #f9fafb;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

#ordersTable td {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

#ordersTable tbody tr:hover {
    background: #f9fafb;
}

#ordersTable tbody tr.expanded {
    background: #f3f4f6;
}

#ordersTable tbody tr.hasWarning {
    background: #fffbeb;
}

.ordersExpandBtn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    color: #6b7280;
    transition: transform 0.2s;
    width: 24px;
}

.ordersExpandBtn.expanded {
    transform: rotate(90deg);
}

.ordersOrderLink {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.ordersOrderLink:hover {
    text-decoration: underline;
}

.ordersItemCount {
    font-size: 12px;
    color: #6b7280;
}

.ordersCustomer {
    font-size: 14px;
}

.ordersCustomerEmail {
    color: #6b7280;
    font-size: 12px;
}

.ordersDate {
    font-size: 14px;
    color: #6b7280;
    white-space: nowrap;
}

/* Status Badges */
.statusBadge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* IMS Status Colors */
.statusBadge.ims.not_in_ims {
    background: #fee2e2;
    color: #991b1b;
}

.statusBadge.ims.warning {
    background: #fef3c7;
    color: #92400e;
}

.statusBadge.ims.pending {
    background: #e5e7eb;
    color: #374151;
}

.statusBadge.ims.partially_ordered {
    background: #dbeafe;
    color: #1e40af;
}

.statusBadge.ims.ordered {
    background: #dbeafe;
    color: #1e40af;
}

.statusBadge.ims.partially_received {
    background: #d1fae5;
    color: #065f46;
}

.statusBadge.ims.ready_to_ship {
    background: #d1fae5;
    color: #065f46;
}

.statusBadge.ims.mixed {
    background: #fef3c7;
    color: #92400e;
}

/* Financial Status Colors */
.statusBadge.financial.pending {
    background: #fef3c7;
    color: #92400e;
}

.statusBadge.financial.authorized {
    background: #dbeafe;
    color: #1e40af;
}

.statusBadge.financial.paid {
    background: #d1fae5;
    color: #065f46;
}

.statusBadge.financial.partially_paid {
    background: #fef3c7;
    color: #92400e;
}

.statusBadge.financial.partially_refunded {
    background: #fef3c7;
    color: #92400e;
}

.statusBadge.financial.refunded {
    background: #fee2e2;
    color: #991b1b;
}

.statusBadge.financial.voided {
    background: #e5e7eb;
    color: #374151;
}

/* Fulfillment Status Colors */
.statusBadge.fulfillment.unfulfilled {
    background: #fef3c7;
    color: #92400e;
}

.statusBadge.fulfillment.partial {
    background: #dbeafe;
    color: #1e40af;
}

.statusBadge.fulfillment.fulfilled {
    background: #d1fae5;
    color: #065f46;
}

/* Actions */
.ordersActions button {
    display: inline-block;
    width: auto;
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.ordersActions button:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.ordersActions .processBtn {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.ordersActions .processBtn:hover {
    background: #1d4ed8;
}

/* Line Items Detail */
.ordersLineItemsRow {
    display: none;
}

.ordersLineItemsRow.visible {
    display: table-row;
}

.ordersLineItemsRow td {
    background: #f9fafb;
    padding: 0;
}

.ordersLineItems {
    padding: 16px;
}

.ordersLineItems h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
}

.ordersLineItemsList {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ordersLineItem {
    display: flex;
    align-items: center;
    gap: 16px;
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.ordersLineItem.notInIms {
    border-color: #ef4444;
    background: #fef2f2;
}

.ordersLineItem.unknownSku {
    border-color: #ef4444;
    background: #fef2f2;
}

/* Unknown SKU Badge */
.ordersLineItemUnknownSku {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: #fee2e2;
    color: #991b1b;
    font-weight: 500;
    white-space: nowrap;
}

.ordersLineItemInfo {
    flex: 1;
}

.ordersLineItemTitle {
    font-weight: 500;
    margin-bottom: 4px;
}

.ordersLineItemMeta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #6b7280;
}

.ordersLineItemStatus {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: #e5e7eb;
    color: #374151;
    white-space: nowrap;
}

.ordersLineItemStatus.notInIms {
    background: #fee2e2;
    color: #991b1b;
}

.ordersLineItemStatus.pending_inventory {
    background: #e5e7eb;
    color: #374151;
}

.ordersLineItemStatus.ordered {
    background: #dbeafe;
    color: #1e40af;
}

.ordersLineItemStatus.received {
    background: #d1fae5;
    color: #065f46;
}

/* SKU Override */
.ordersSkuOverride {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
}

.ordersSkuOriginal {
    text-decoration: line-through;
    color: #9ca3af;
}

.ordersSkuArrow {
    color: #6b7280;
}

.ordersSkuOverrideValue {
    color: #2563eb;
    font-weight: 500;
}

.ordersSkuOverrideClear {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    color: #6b7280;
    font-size: 14px;
    line-height: 1;
    padding: 1px 5px;
    transition: all 0.2s;
}

.ordersSkuOverrideClear:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #ef4444;
}

.ordersSkuOverrideInput {
    padding: 3px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    width: 180px;
    outline: none;
}

.ordersSkuOverrideInput:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.ordersSkuOverrideInput:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Empty State */
.ordersEmpty {
    padding: 40px;
    text-align: center;
    color: #6b7280;
}

/* Detail Loading */
.ordersDetailLoading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px;
    color: #6b7280;
    font-size: 14px;
}

.ordersDetailSpinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: ordersSpinnerSpin 0.6s linear infinite;
}

@keyframes ordersSpinnerSpin {
    to { transform: rotate(360deg); }
}

.ordersDetailError {
    padding: 24px;
    color: #991b1b;
    font-size: 14px;
}

.ordersDetailEmpty {
    padding: 16px 0;
    color: #6b7280;
    font-size: 13px;
}

/* Fulfill Readiness Banner */
.ordersFulfillBanner {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.ordersFulfillBanner.ready {
    background: #d1fae5;
    color: #065f46;
    font-weight: 500;
}

.ordersFulfillBanner.notReady {
    background: #fef3c7;
    color: #92400e;
}

.ordersFulfillBanner ul {
    margin: 6px 0 0 0;
    padding-left: 18px;
    font-size: 12px;
    font-weight: 400;
}

.ordersFulfillBanner li {
    margin-bottom: 2px;
}

/* Bundle Group — collapsed by default, expands on click */
.ordersBundleGroup {
    border: 1px solid #e5e7eb;
    border-left: 3px solid #2563eb;
    border-radius: 6px;
    margin-bottom: 12px;
    background: white;
    overflow: hidden;
}

.ordersBundleHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8fafc;
    cursor: pointer;
}

.ordersBundleHeader:hover {
    background: #f1f5f9;
}

.ordersBundleTitle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.ordersBundleExpandIcon {
    font-size: 10px;
    transition: transform 0.2s;
    color: #6b7280;
}

.ordersBundleGroup.active .ordersBundleExpandIcon {
    transform: rotate(90deg);
}

.ordersBundleComponentCount {
    font-size: 12px;
    color: #6b7280;
    font-weight: 400;
}

.ordersBundleTag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: #dbeafe;
    color: #1e40af;
}

.ordersBundleDelete {
    padding: 4px 10px;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    background: white;
    color: #dc2626;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ordersBundleDelete:hover {
    background: #fee2e2;
    border-color: #dc2626;
}

.ordersBundleComponents {
    display: none;
    border-top: 1px solid #e5e7eb;
}

.ordersBundleGroup.active .ordersBundleComponents {
    display: block;
}

.ordersBundleGroup .ordersLineItemsList {
    padding: 8px;
    gap: 4px;
}

/* Detail Line Item Row */
.ordersDetailItem {
    display: flex;
    align-items: center;
    gap: 16px;
    background: white;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.ordersDetailItem.notInIms {
    border-color: #ef4444;
    background: #fef2f2;
}

.ordersDetailItem.unknownSku {
    border-color: #ef4444;
    background: #fef2f2;
}

.ordersDetailItemRight {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* SKU Valid/Invalid Indicators */
.ordersSkuValid {
    color: #16a34a;
    font-weight: 600;
}

.ordersSkuInvalid {
    color: #dc2626;
    font-weight: 600;
}

/* Compact Status Select */
.ordersStatusSelect {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    cursor: pointer;
    outline: none;
}

.ordersStatusSelect:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.ordersStatusSelect:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Inventory Numbers */
.ordersInvGroup {
    display: flex;
    gap: 6px;
}

.ordersInvItem {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 48px;
    padding: 4px 6px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.ordersInvCommittedClickable {
    cursor: pointer;
    border-color: #2563eb;
}

.ordersInvCommittedClickable:hover {
    background: #eff6ff;
}

.ordersInvLabel {
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1;
    margin-bottom: 2px;
}

.ordersInvValue {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.ordersInvValue.positive {
    color: #16a34a;
}

.ordersInvValue.negative {
    color: #dc2626;
}

.ordersInvValue.zero {
    color: #9ca3af;
}

.ordersInvNone {
    font-size: 12px;
    color: #9ca3af;
}

/* Fulfill indicator in detail row */
.ordersDetailFulfill {
    font-size: 14px;
}

/* PO Badge */
.ordersPoBadge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: #dbeafe;
    color: #1e40af;
    text-decoration: none;
    white-space: nowrap;
}

.ordersPoBadge:hover {
    background: #bfdbfe;
    text-decoration: none;
}

/* Lead Time Badge */
.ordersLeadTimeBadge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.ordersLeadTimeBadge.onTime {
    background: #e5e7eb;
    color: #374151;
}

.ordersLeadTimeBadge.warning {
    background: #fef3c7;
    color: #92400e;
}

.ordersLeadTimeBadge.late {
    background: #fee2e2;
    color: #991b1b;
}

/* Item Delete Button */
.ordersItemDelete {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    color: #6b7280;
    font-size: 14px;
    line-height: 1;
    padding: 3px 6px;
    transition: all 0.2s;
}

.ordersItemDelete:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #ef4444;
}

/* Internal Note */
.ordersInternalNote {
    margin-top: 4px;
}

.ordersInternalNoteInput {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: inherit;
    color: #666;
    background: none;
    outline: none;
    width: 100%;
    max-width: 300px;
}

.ordersInternalNoteInput:hover {
    border-color: #e5e7eb;
}

.ordersInternalNoteInput:focus {
    border-color: #999;
    background: white;
}

/* Missing Items Section */
.ordersMissingSection {
    margin-top: 12px;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    background: #fef2f2;
    padding: 12px;
}

.ordersMissingSection h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 600;
    color: #991b1b;
}

.ordersMissingSection .ordersLineItemsList {
    gap: 6px;
}

.ordersMissingSection .ordersDetailItem {
    background: white;
}

/* Missing Item Actions */
.ordersMissingActions {
    display: flex;
    gap: 6px;
    margin-left: auto;
    white-space: nowrap;
}

.ordersMissingActions button {
    padding: 4px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    color: #374151;
    transition: all 0.2s;
}

.ordersMissingActions button:hover {
    background: #f3f4f6;
}

.ordersMissingActions .ordersMissingActionsMarkRepair:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #b45309;
}

.ordersMissingActions .ordersMissingActionsDelete:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #ef4444;
}

/* Customer Note */
.ordersDetailNote {
    background: #f0f9ff;
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: 6px;
    font-size: 13px;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Repair Section */
.ordersRepairSection {
    margin-top: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.ordersRepairToggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 10px 14px;
    background: #f9fafb;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    text-align: left;
    transition: background 0.2s;
}

.ordersRepairToggle:hover {
    background: #f3f4f6;
}

.ordersRepairToggle::after {
    content: "\25B6";
    font-size: 10px;
    margin-left: 4px;
    transition: transform 0.2s;
}

.ordersRepairSection.active .ordersRepairToggle::after {
    transform: rotate(90deg);
}

.ordersRepairItems {
    display: none;
    padding: 8px;
}

.ordersRepairSection.active .ordersRepairItems {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Add Custom Item */
.ordersAddCustomSection {
    margin-top: 12px;
}

.ordersAddCustomBtn {
    padding: 8px 16px;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    color: #6b7280;
    transition: all 0.2s;
}

.ordersAddCustomBtn:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #f0f7ff;
}

/* Product & SKU Links */
.ordersProductLink,
.ordersSkuLink {
    color: #2563eb;
    text-decoration: none;
}

.ordersProductLink:hover,
.ordersSkuLink:hover {
    text-decoration: underline;
}

/* Custom Item Swal Form */
.ordersCustomItemForm {
    text-align: left;
}

.ordersCustomItemLabel {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
}

.ordersCustomItemInput {
    margin-bottom: 10px;
}
