/* ═══════════════════════════════════════════════
   Order Upload — Tile-specific styles
   ═══════════════════════════════════════════════ */

/* ─── Desktop (non-PWA) full-width override ─── */
/* When accessed in a normal browser (not installed PWA), remove the
   42rem max-width cap from shared.css so the side-by-side layout
   can use the full viewport. Uses the same display-mode check as
   pwa-detect.js. */
@media not all and (display-mode: standalone) {
    .main {
        max-width: 100%;
    }
}

/* ─── Desktop Header Controls (non-PWA) ─────── */

.header-desktop-controls {
    flex-shrink: 0;
}

.desktop-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.desktop-theme-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    background: transparent;
    color: white;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.desktop-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.6);
}

/* ─── Drop Zone ─────────────────────────────── */

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    background: var(--surface);
    margin-bottom: 16px;
}

.drop-zone:hover,
.drop-zone-active {
    border-color: var(--primary-green);
    background: rgba(22, 163, 106, 0.04);
}

.drop-zone-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    color: var(--text-muted);
}

.drop-zone-active .drop-zone-icon {
    color: var(--primary-green);
}

.drop-zone-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.drop-zone-subtext {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.drop-zone-browse {
    background: none;
    border: none;
    color: var(--primary-green);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    font-size: 14px;
    padding: 0;
}

.drop-zone-formats {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* ─── Email Body (collapsible) ────────────────── */

.email-body-details {
    margin-bottom: 12px;
}

.email-body-summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 0;
    user-select: none;
}

.email-body-summary:hover {
    color: var(--text-primary);
}

.email-body-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    resize: vertical;
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
    margin-top: 6px;
    box-sizing: border-box;
}

/* ─── Queue ──────────────────────────────────── */

.queue-container {
    margin-top: 16px;
}

.queue-heading {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 10px;
}

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

.queue-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.queue-card-done:hover {
    border-color: var(--primary-green);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.queue-card-error {
    border-color: var(--red, #ef4444);
}

.queue-card-submitted {
    opacity: 0.7;
    cursor: default !important;
}

.queue-card-multi-parent {
    background: var(--surface-hover);
    border-style: dashed;
}

.queue-card-sub {
    margin-left: 24px;
}

.queue-card-thumb {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.queue-card-thumb svg {
    width: 28px;
    height: 28px;
}

.queue-card-thumb-sub {
    background: var(--primary-green);
    border-radius: 50%;
    color: white;
    font-size: 12px;
    font-weight: 700;
}

.sub-order-num {
    font-size: 11px;
    font-weight: 700;
}

.queue-card-info {
    flex: 1;
    min-width: 0;
}

.queue-card-filename {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-card-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.queue-card-file-name {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.queue-card-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.status-error { color: var(--red, #ef4444); font-weight: 500; }
.status-success { color: var(--primary-green); font-weight: 600; }
.status-multi { color: var(--primary-green); font-weight: 600; }

.so-link {
    color: var(--primary-green);
    text-decoration: underline;
    font-size: 12px;
}

/* ─── Confidence Badges ──────────────────────── */

.confidence-pill, .confidence-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.confidence-high { background: #dcfce7; color: #166534; }
.confidence-medium { background: #fef3c7; color: #92400e; }
.confidence-low { background: #fee2e2; color: #991b1b; }

body.theme-dark .confidence-high { background: #166534; color: #dcfce7; }
body.theme-dark .confidence-medium { background: #78350f; color: #fef3c7; }
body.theme-dark .confidence-low { background: #7f1d1d; color: #fee2e2; }
@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .confidence-high { background: #166534; color: #dcfce7; }
    body:not(.theme-light) .confidence-medium { background: #78350f; color: #fef3c7; }
    body:not(.theme-light) .confidence-low { background: #7f1d1d; color: #fee2e2; }
}

/* ═══════════════════════════════════════════════
   SCREEN 2: Review (Side-by-Side)
   ═══════════════════════════════════════════════ */

.review-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.review-order-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.review-panels {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 160px);
}

.review-panel-left {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    transition: flex-basis 0.2s ease;
}

.review-panel-left.pdf-hidden {
    display: none;
}

.review-panel-right {
    flex: 1 1 50%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

/* ─── Panel Resizer (drag handle) ────────────── */

.panel-resizer {
    flex-shrink: 0;
    width: 8px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 2;
}

.panel-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 40px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.15s;
}

.panel-resizer:hover::after,
.panel-resizer.dragging::after {
    background: var(--primary-green);
}

.panel-resizer.pdf-hidden {
    display: none;
}

/* ─── Toggle PDF Button ──────────────────────── */

.toggle-pdf-btn {
    margin-left: auto;
    white-space: nowrap;
}

.panel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-hover);
    flex-shrink: 0;
}

.panel-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
}

.panel-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.panel-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-primary);
    line-height: 1;
}

.panel-btn:hover {
    background: var(--surface-hover);
}

.zoom-level, .page-info {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
}

.doc-viewer {
    flex: 1;
    overflow: auto;
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #525659;
}

.doc-viewer canvas {
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.doc-viewer img {
    max-width: 100%;
    height: auto;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.doc-error {
    color: var(--red, #ef4444);
    text-align: center;
    padding: 24px;
}

/* ─── Review Form ─────────────────────────────── */

.review-form {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.form-section {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--surface);
    color: var(--text-primary);
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 2px rgba(22, 163, 106, 0.15);
}

.form-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--surface);
    color: var(--text-primary);
    box-sizing: border-box;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-col {
    flex: 1;
}

/* ─── Match Status ────────────────────────────── */

.match-status {
    margin-top: 4px;
    font-size: 12px;
}

.match-ok { color: var(--primary-green); font-weight: 600; }
.match-guess { color: #d97706; font-weight: 500; }
.match-none { color: var(--red, #ef4444); font-weight: 500; }
.match-nla { color: #ea580c; font-weight: 600; }
.match-replacement { color: var(--text-muted); font-size: 11px; }

.item-match-wrap {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 3px;
}
.item-match-wrap .ta-wrapper {
    flex: 1;
    min-width: 0;
}
.item-match-wrap .item-search-btn {
    width: 26px;
    height: 26px;
    margin-left: 0;
    flex-shrink: 0;
}

/* Customer match area — flex layout for typeahead + search button */
#customerMatchArea .ta-wrapper {
    flex: 1;
    min-width: 0;
}
#customerMatchArea {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px;
}
#customerMatchArea .matched-label,
#customerMatchArea .match-status {
    width: 100%;
}

/* API Search Button — sits next to customer typeahead */
.api-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #16a34a;
    border-radius: var(--radius, 6px);
    background: #16a34a;
    color: #fff;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 4px;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}
.api-search-btn:hover {
    background: #15803d;
    border-color: #15803d;
}

/* Credit hold banner — inline at customer field */
.credit-hold-banner {
    margin-top: 8px;
    padding: 10px 14px;
    font-size: 13px;
    border-left: 4px solid #dc2626;
    animation: creditHoldPulse 0.4s ease-out;
}
.credit-hold-banner a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}
@keyframes creditHoldPulse {
    0% { transform: scale(1.02); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3); }
    100% { transform: scale(1); box-shadow: none; }
}

.item-match-status {
    margin-top: 2px;
    font-size: 11px;
}

/* ─── Extracted Address Box ───────────────────── */

.extracted-address-box {
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
}

.extracted-address-box.text-muted {
    color: var(--text-secondary);
    font-style: italic;
}

.extracted-address-box.address-verified {
    border-color: var(--primary-green);
    background: rgba(22, 163, 106, 0.05);
}

.extracted-address-box.address-unverified {
    border-color: #d97706;
    background: rgba(217, 119, 6, 0.05);
}

.address-match-status {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
}

body.theme-dark .extracted-address-box.address-verified {
    background: rgba(22, 163, 106, 0.12);
}
body.theme-dark .extracted-address-box.address-unverified {
    background: rgba(217, 119, 6, 0.12);
}
@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .extracted-address-box.address-verified {
        background: rgba(22, 163, 106, 0.12);
    }
    body:not(.theme-light) .extracted-address-box.address-unverified {
        background: rgba(217, 119, 6, 0.12);
    }
}

/* ─── Pills ───────────────────────────────────── */

.pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.pill-info {
    background: #e0f2fe;
    color: #0c4a6e;
}

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

body.theme-dark .pill-info { background: #0c4a6e; color: #e0f2fe; }
body.theme-dark .pill-warning { background: #78350f; color: #fef3c7; }
@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .pill-info { background: #0c4a6e; color: #e0f2fe; }
    body:not(.theme-light) .pill-warning { background: #78350f; color: #fef3c7; }
}

/* ─── Alerts ──────────────────────────────────── */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

body.theme-dark .alert-warning { background: #78350f; color: #fef3c7; border-color: #92400e; }
body.theme-dark .alert-danger { background: #7f1d1d; color: #fee2e2; border-color: #991b1b; }
@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .alert-warning { background: #78350f; color: #fef3c7; border-color: #92400e; }
    body:not(.theme-light) .alert-danger { background: #7f1d1d; color: #fee2e2; border-color: #991b1b; }
}

/* ─── Line Items Table ────────────────────────── */

.line-items-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.line-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.line-items-table thead th {
    background: var(--surface-hover);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.line-items-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.line-items-table tbody tr:last-child td {
    border-bottom: none;
}

/* Line row confidence colors */
.line-confidence-high { background: rgba(22, 163, 106, 0.04); }
.line-confidence-medium { background: rgba(217, 119, 6, 0.04); }
.line-confidence-low { background: rgba(239, 68, 68, 0.04); }
.line-nla { background: rgba(234, 88, 12, 0.06); }

.line-confidence-high td:first-child { border-left: 3px solid var(--primary-green); }
.line-confidence-medium td:first-child { border-left: 3px solid #d97706; }
.line-confidence-low td:first-child { border-left: 3px solid #ef4444; }
.line-nla td:first-child { border-left: 3px solid #ea580c; }

/* Column widths */
.col-line-num { width: 36px; text-align: center; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.col-item-code { min-width: 120px; max-width: 160px; }
.col-matched { min-width: 180px; }
.col-po-desc { min-width: 140px; max-width: 220px; }
.col-qty { width: 60px; }
.col-case-qty { width: 50px; text-align: center; white-space: nowrap; font-size: 12px; }
.col-po-price { width: 80px; white-space: nowrap; }

.qty-broken-case {
    background: #fef3c7 !important;
}
body.theme-dark .qty-broken-case { background: rgba(217, 119, 6, 0.15) !important; }
@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .qty-broken-case { background: rgba(217, 119, 6, 0.15) !important; }
}
.col-wcs-price { width: 85px; white-space: nowrap; }
.col-price-level { width: 130px; }
.col-avail { width: 80px; white-space: nowrap; }
.col-remember { width: 75px; text-align: center; }
.col-delete { width: 32px; text-align: center; padding: 0 !important; }

.line-delete-btn {
    background: #dc2626; color: #fff; border: none; cursor: pointer;
    padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 700;
    line-height: 1.4; transition: background 0.15s, opacity 0.15s;
}
.line-delete-btn:hover { background: #b91c1c; }

.add-line-btn {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 8px; padding: 6px 14px;
    background: var(--surface-secondary); border: 1px dashed var(--border-color);
    border-radius: var(--radius); color: var(--text-secondary);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.add-line-btn:hover { color: var(--primary-green); border-color: var(--primary-green); background: rgba(22,163,74,0.06); }

.item-code-text {
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 13px;
}

.item-code-sku {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.po-desc-text {
    color: var(--text-primary);
}

.qty-input {
    width: 56px !important;
    padding: 6px 8px !important;
    text-align: center;
}

.item-search-input {
    font-size: 13px !important;
    padding: 6px 8px !important;
}

.wcs-price {
    font-weight: 600;
    color: var(--primary-green);
}

.wcs-price-zero {
    color: var(--error, #dc2626);
}

.price-level-select {
    font-size: 12px !important;
    padding: 4px 6px !important;
    min-width: 110px;
}

.custom-price-input {
    width: 80px !important;
    font-size: 13px !important;
    padding: 4px 6px !important;
}

.remember-check {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-green);
}

/* ─── Stock Pills ─────────────────────────────── */

.stock-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.stock-green { background: #dcfce7; color: #166534; }
.stock-yellow { background: #fef3c7; color: #92400e; }
.stock-red { background: #fee2e2; color: #991b1b; }

body.theme-dark .stock-green { background: #166534; color: #dcfce7; }
body.theme-dark .stock-yellow { background: #78350f; color: #fef3c7; }
body.theme-dark .stock-red { background: #7f1d1d; color: #fee2e2; }
@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .stock-green { background: #166534; color: #dcfce7; }
    body:not(.theme-light) .stock-yellow { background: #78350f; color: #fef3c7; }
    body:not(.theme-light) .stock-red { background: #7f1d1d; color: #fee2e2; }
}

/* ─── Review Footer ───────────────────────────── */

.review-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

.review-footer-info {
    display: flex;
    gap: 12px;
    font-size: 12px;
}

.footer-stat {
    color: var(--text-muted);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--primary-green);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #15803d;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 15px;
}

.line-count {
    font-weight: 400;
    color: var(--text-muted);
}

/* ─── Back Link ───────────────────────────────── */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
}

.back-link:hover {
    color: var(--primary-green);
}

/* ─── Validation Reasons ─────────────────────── */

.validation-reasons {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.validation-reasons ul {
    margin: 4px 0 0;
    padding-left: 18px;
    list-style: disc;
}

.validation-reasons li {
    margin-bottom: 2px;
    color: #d97706;
}

/* ─── SO Result Banner ───────────────────────── */

.so-result-banner {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-top: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.so-result-banner.result-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.so-result-banner.result-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.so-result-banner .so-result-icon {
    flex-shrink: 0;
    font-size: 18px;
}

.so-result-banner .so-result-text {
    flex: 1;
}

.so-result-banner .so-result-link {
    color: #166534;
    font-weight: 600;
    text-decoration: underline;
}

.so-result-banner .so-result-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: inherit;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
}

.so-result-banner .so-result-dismiss:hover {
    opacity: 1;
}

body.theme-dark .so-result-banner.result-success { background: #166534; color: #dcfce7; border-color: #15803d; }
body.theme-dark .so-result-banner.result-error { background: #7f1d1d; color: #fee2e2; border-color: #991b1b; }
body.theme-dark .so-result-banner .so-result-link { color: #bbf7d0; }
@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .so-result-banner.result-success { background: #166534; color: #dcfce7; border-color: #15803d; }
    body:not(.theme-light) .so-result-banner.result-error { background: #7f1d1d; color: #fee2e2; border-color: #991b1b; }
    body:not(.theme-light) .so-result-banner .so-result-link { color: #bbf7d0; }
}

/* ═══════════════════════════════════════════════
   Queue Island Grid (Phase 4)
   ═══════════════════════════════════════════════ */

.queue-islands-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.queue-island {
    background: var(--surface);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 12px;
    padding: 12px;
    min-height: 80px;
}

.queue-island-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.1));
}

.queue-island-name {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--text-primary);
}

.queue-island-count {
    background: #2563eb;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.8em;
    font-weight: 600;
}

.queue-island-count[data-count="0"] {
    background: var(--text-secondary);
    opacity: 0.5;
}

.queue-island-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.queue-island-cards.expanded {
    max-height: none !important;
}

.queue-card-compact {
    background: var(--card-bg, rgba(255,255,255,0.05));
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 8px;
    padding: 10px 12px;
    min-width: 220px;
    max-width: 300px;
    width: 220px;
    flex: 1 0 220px;
    cursor: pointer;
    transition: border-color 0.2s;
    position: relative;
    box-sizing: border-box;
}

.queue-card-compact:hover {
    border-color: #16a34a;
}

.queue-card-compact .card-customer {
    font-weight: 600;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    padding-right: 20px;
}

.queue-card-compact .card-po {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-top: 2px;
}

.queue-card-compact .card-meta {
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.queue-card-compact .card-file {
    font-size: 0.7em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.queue-card-compact .card-decline-x {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.queue-card-compact:hover .card-decline-x {
    opacity: 1;
}

.queue-card-compact .card-decline-x:hover {
    background: var(--red, #ef4444);
    color: white;
    opacity: 1;
}

.queue-island-expand {
    text-align: center;
    padding: 6px;
    color: #2563eb;
    font-size: 0.8em;
    cursor: pointer;
}

.queue-island-expand:hover {
    text-decoration: underline;
}

.queue-island-empty {
    color: var(--text-secondary);
    font-size: 0.85em;
    text-align: center;
    padding: 12px;
    opacity: 0.6;
}

/* Drag & drop reassignment */
.queue-card-compact.dragging { opacity: 0.4; border: 2px dashed var(--text-secondary); }
.queue-card-compact[draggable="true"] { cursor: grab; }
.queue-card-compact[draggable="true"]:active { cursor: grabbing; }
.queue-island.island-drop-target {
    outline: 2px dashed #16a34a;
    outline-offset: -2px;
    background: rgba(22,163,74,0.05);
    transition: outline-color 0.15s, background 0.15s;
}

/* Collapsible sections (Unassigned, Completed, Declined) */
.queue-collapsible-header {
    cursor: pointer;
    padding: 10px;
    background: var(--surface);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.queue-collapsible-header span:first-child {
    font-weight: 600;
    color: var(--text-secondary);
}

.queue-collapsible-cards {
    margin-top: 8px;
}

/* Decline modal */
.decline-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.decline-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.decline-modal h3 {
    margin: 0 0 16px;
    font-size: 1.1em;
    color: var(--text-primary);
}

.decline-modal .decline-info {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.decline-modal select,
.decline-modal textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border, rgba(255,255,255,0.2));
    border-radius: 6px;
    background: var(--surface, #1e293b);
    color: var(--text-primary, #e2e8f0);
    font-size: 0.9em;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
}

.decline-modal select option {
    background: var(--surface, #1e293b);
    color: var(--text-primary, #e2e8f0);
}

.decline-modal textarea {
    margin-top: 12px;
    resize: vertical;
    min-height: 60px;
}

.decline-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.decline-modal .btn-cancel {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    border-radius: var(--radius, 6px);
    cursor: pointer;
}

.decline-modal .btn-decline {
    padding: 8px 16px;
    border: none;
    background: var(--red, #ef4444);
    color: white;
    border-radius: var(--radius, 6px);
    cursor: pointer;
    font-weight: 600;
}

.decline-modal .btn-decline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ═══════════════════════════════════════════════
   Mobile / Responsive
   ═══════════════════════════════════════════════ */

@media (max-width: 768px) {
    .queue-islands-grid {
        grid-template-columns: 1fr;
    }

    .desktop-only { display: none; }

    .review-panels {
        flex-direction: column;
        min-height: auto;
    }

    .review-panel-left {
        max-height: 40vh;
    }

    .panel-resizer {
        display: none;
    }

    .form-row {
        flex-direction: column;
        gap: 8px;
    }

    .line-items-table-wrap {
        font-size: 12px;
    }

    .col-line-num { width: 28px; }
    .col-item-code { min-width: 80px; }
    .col-matched { min-width: 120px; }
    .col-po-desc { min-width: 80px; }
    .col-po-price { width: 65px; }

    .review-footer {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .review-footer-info {
        justify-content: center;
    }

    .btn-lg {
        width: 100%;
    }
}

/* ─── Customer Extracted Display ─────────────── */

.customer-extracted {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
    padding: 6px 10px;
    background: var(--surface-hover);
    border-radius: var(--radius);
    font-size: 13px;
}

.extracted-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.extracted-value {
    font-weight: 600;
    color: var(--text-primary);
}

.matched-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 2px;
    display: block;
}

/* ─── Source Badges (Status Column) ──────────── */

.source-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    text-align: center;
}

.source-premapped { background: #dbeafe; color: #1e40af; }
.source-ai-match { background: #dcfce7; color: #166534; }
.source-guess { background: #fef3c7; color: #92400e; }
.source-no-match { background: #fee2e2; color: #991b1b; }
.source-manual { background: #f3f4f6; color: #374151; }

body.theme-dark .source-premapped { background: #1e3a5f; color: #93c5fd; }
body.theme-dark .source-ai-match { background: #166534; color: #dcfce7; }
body.theme-dark .source-guess { background: #78350f; color: #fef3c7; }
body.theme-dark .source-no-match { background: #7f1d1d; color: #fee2e2; }
body.theme-dark .source-manual { background: #374151; color: #d1d5db; }
@media (prefers-color-scheme: dark) {
    body:not(.theme-light) .source-premapped { background: #1e3a5f; color: #93c5fd; }
    body:not(.theme-light) .source-ai-match { background: #166534; color: #dcfce7; }
    body:not(.theme-light) .source-guess { background: #78350f; color: #fef3c7; }
    body:not(.theme-light) .source-no-match { background: #7f1d1d; color: #fee2e2; }
    body:not(.theme-light) .source-manual { background: #374151; color: #d1d5db; }
}

.status-cell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.remember-label {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ─── Post-Creation: Process Next Button ─────── */

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

/* ─── Custom Ship-To Confirmation ────────────── */

.custom-shipto-confirm {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.custom-shipto-confirm input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #d97706;
    cursor: pointer;
}

.so-result-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

@media (max-width: 480px) {
    .drop-zone {
        padding: 32px 16px;
    }

    .queue-card {
        padding: 10px 12px;
    }

    .queue-card-sub {
        margin-left: 12px;
    }
}
