.inbound-body {
    display: flex;
    height: calc(100% - var(--title-h));
    min-height: 0;
    position: relative;
    background: var(--pane);
}

/* 识别/查询等待遮罩：覆盖整个视口，期间阻断一切操作 */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(2px);
    cursor: wait;
}

.search-overlay[hidden] {
    display: none;
}

.search-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 28px 40px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(28, 43, 40, 0.12);
}

.search-overlay-content .spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

.search-overlay-text {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.inbound-sidebar {
    width: 320px;
    min-width: 280px;
    max-width: 420px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.inbound-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.inbound-sidebar-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.scan-section {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.scan-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 8px;
}

.scan-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scan-input-group .scan-input {
    flex: 1;
    width: auto;
    height: 36px;
    font-size: 13px;
    padding: 0 12px;
}

.scan-input {
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    width: 180px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.scan-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-soft);
}

.scan-input::placeholder {
    color: var(--muted);
}

.scan-btn {
    height: 36px;
    padding: 0 16px;
    white-space: nowrap;
    flex-shrink: 0;
}

.scan-hint {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.scan-hint.is-error {
    color: #d93025;
    font-weight: 600;
    background: #fdecea;
    border: 1px solid #f5c2bd;
    border-radius: 6px;
    padding: 8px 10px;
}

.scan-hint.is-warn {
    color: #b06000;
    font-weight: 600;
    background: #fef7e0;
    border: 1px solid #f0d58c;
    border-radius: 6px;
    padding: 8px 10px;
}

.gallery-search-btn {
    width: 40px;
    height: 36px;
    flex-shrink: 0;
    border-color: var(--line);
    background: var(--surface);
    color: var(--text-2);
    border-radius: 6px;
    transition: all 0.15s;
}

.gallery-search-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: var(--blue-softer);
}

.gallery-search-btn:active {
    background: var(--blue-soft);
}

.gallery-search-btn svg {
    display: block;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 4px;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
}

.icon-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: var(--blue-softer);
}

.icon-btn:active {
    background: var(--blue-soft);
}

/* Order Card */
.inbound-result {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.inbound-result[hidden] {
    display: none;
}

.order-card {
    margin: 12px;
    padding: 14px;
    border: 1px solid var(--blue-soft);
    border-radius: 8px;
    background: var(--blue-softer);
}

.order-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.order-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e6f4ea;
    color: #1a7f37;
}

.order-status.is-active {
    background: var(--blue-soft);
    color: var(--blue);
}

.order-status.is-done {
    background: #f0f0f0;
    color: var(--muted);
}

.order-barcode {
    font-size: 12px;
    color: var(--muted);
    font-family: monospace;
}

.order-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--blue);
}

.order-products-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

/* Product list in sidebar */
.inbound-products {
    padding: 0 12px 12px;
}

.inbound-product-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    margin-bottom: 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.inbound-product-item:hover {
    background: #f5f8fb;
    border-color: var(--blue-soft);
}

.inbound-product-item.is-active {
    background: var(--blue-softer);
    border-color: var(--blue);
}

.inbound-product-thumb {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
}

.inbound-product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.inbound-product-info {
    flex: 1;
    min-width: 0;
}

.inbound-product-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.inbound-product-desc {
    font-size: 11px;
    color: var(--text-2);
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbound-product-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--muted);
    flex-wrap: wrap;
}

.inbound-product-meta span {
    white-space: nowrap;
}

.barcode-btn {
    padding: 1px 6px;
    font-family: monospace;
    font-size: 11px;
    color: var(--blue);
    background: rgba(15, 108, 189, 0.08);
    border: 1px solid rgba(15, 108, 189, 0.24);
    border-radius: 4px;
    cursor: pointer;
}

.barcode-btn:hover {
    background: rgba(15, 108, 189, 0.16);
}

/* Barcode graphic dialog */
.barcode-card {
    width: min(520px, 100%);
}

.barcode-product {
    margin: 0 16px 12px;
    padding: 12px 14px;
    background: #fafafa;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.barcode-product[hidden] {
    display: none;
}

.barcode-product-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    word-break: break-all;
}

.barcode-product-row {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-2);
    word-break: break-all;
}

.barcode-product-label {
    color: var(--muted);
}

.barcode-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 88px;
    margin: 0 16px;
    padding: 12px;
    font-size: 13px;
    color: var(--text-2);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-x: auto;
}

.barcode-body svg {
    display: block;
    width: 100%;
    max-width: 300px;
    height: auto;
}

.barcode-code {
    margin: 6px 16px 18px;
    text-align: center;
    font-size: 12px;
    letter-spacing: 1px;
}

.barcode-footer label {
    font-size: 13px;
    color: var(--text-2);
}

.barcode-footer input {
    width: 72px;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

/* Product image lightbox */
.inbound-product-thumb img,
.image-container img {
    cursor: zoom-in;
}

.image-modal-card {
    width: min(1200px, 94vw);
    max-height: 92vh;
}

.image-modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    padding: 0 16px 16px;
}

.image-modal-body img {
    max-width: 100%;
    /* 撑满弹窗剩余高度，避免百分比高度在弹性布局下失效 */
    max-height: calc(92vh - 70px);
    object-fit: contain;
    border-radius: 6px;
}

/* Empty result */
.inbound-empty-result {
    padding: 20px 16px;
    margin: 12px;
    font-size: 13px;
    color: var(--text-2);
    background: #f9f9f9;
    border: 1px dashed var(--line);
    border-radius: 6px;
    text-align: center;
    line-height: 1.6;
}

.inbound-empty-result[hidden] {
    display: none;
}

/* 历史扫码记录（扫码前占位左侧列表区） */
.scan-history {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.scan-history[hidden] {
    display: none;
}

.scan-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.scan-history-head span:last-child {
    font-weight: 400;
    color: var(--muted);
}

.scan-history-list {
    padding: 0 12px 12px;
}

.scan-history-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    margin-bottom: 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    transition: background 0.15s, border-color 0.15s;
}

.scan-history-item:hover {
    background: #f5f8fb;
    border-color: var(--blue-soft);
}

.scan-history-bill {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    cursor: pointer;
    text-align: left;
    word-break: break-all;
}

.scan-history-meta {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-size: 11px;
    color: var(--muted);
}

.scan-history-empty {
    padding: 16px;
    margin: 0 12px;
    font-size: 12px;
    color: var(--text-2);
    background: #f9f9f9;
    border: 1px dashed var(--line);
    border-radius: 6px;
    text-align: center;
}

/* Main area */
.inbound-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--pane);
}

.inbound-main-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    gap: 10px;
    padding: 24px;
    text-align: center;
}

.inbound-main-empty[hidden] {
    display: none;
}

.inbound-main-empty svg {
    opacity: 0.3;
}

.inbound-main-empty p {
    margin: 0;
    font-size: 16px;
    color: var(--text-2);
}

.inbound-main-empty span {
    font-size: 13px;
}

/* Detail */
.inbound-detail {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: var(--pane);
}

.inbound-detail[hidden] {
    display: none;
}

.inbound-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.inbound-detail-basic {
    flex: 1;
    min-width: 200px;
}

.inbound-detail-name {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.inbound-detail-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.product-category {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--blue);
    background: var(--blue-softer);
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.product-code {
    font-size: 12px;
    color: var(--muted);
    font-family: monospace;
}

.product-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.inbound-detail-content {
    margin-bottom: 24px;
}

.image-viewer {
    display: flex;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.image-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.image-panel.original-panel {
    flex: 0 0 320px;
    max-width: 360px;
    min-width: 200px;
    border-right: 1px solid var(--line);
}

.image-panel[hidden] {
    display: none;
}

.image-panel-header {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    background: #fafafa;
    border-bottom: 1px solid var(--line);
}

.image-container {
    flex: 1;
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 16px;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-info {
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
    background: #fafafa;
}

.product-info-section {
    padding: 16px;
    margin-bottom: 24px;
    flex: 1;
    min-width: 0;
}

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

.section-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.info-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
}

.info-item-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.info-item-value {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    word-break: break-word;
    white-space: pre-line;
}

.info-item-value.price {
    color: var(--blue);
    font-weight: 600;
    font-size: 14px;
}

.info-item-value.stock {
    color: #1a7f37;
    font-weight: 600;
}

.section-header-sub {
    margin-top: 18px;
}

/* 无权限时商品管理信息整块隐藏，商品信息顶上，不留空档 */
.managed-info-section[hidden] + .section-header-sub {
    margin-top: 0;
}

.edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.edit-item label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.edit-item.is-wide {
    grid-column: 1 / -1;
}

.edit-item input,
.edit-item textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.edit-item textarea {
    resize: vertical;
    min-height: 54px;
}

.edit-item input:focus,
.edit-item textarea:focus {
    outline: none;
    border-color: var(--blue);
}

.detail-save-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
}

.save-status {
    font-size: 12px;
    color: var(--muted);
}

.save-status.is-error {
    color: #cf222e;
}

.inbound-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    gap: 12px;
    color: var(--muted);
}

.inbound-loading[hidden] {
    display: none;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--line);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.mobile-back-btn {
    display: none;
}

@media (max-width: 900px) {
    .inbound-body {
        flex-direction: column;
        position: relative;
        overflow: hidden;
        overscroll-behavior-x: none;
        touch-action: pan-y;
    }

    .inbound-sidebar {
        width: 100%;
        max-width: none;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--line);
        flex: 1;
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
        transform: translateX(0);
        transition: transform 0.3s ease;
    }

    .inbound-body.show-detail .inbound-sidebar {
        transform: translateX(-100%);
        z-index: 5;
    }

    .inbound-main {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        z-index: 5;
        display: flex;
        flex-direction: column;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow: hidden;
        overscroll-behavior-x: none;
    }

    .inbound-body.show-detail .inbound-main {
        transform: translateX(0);
        z-index: 15;
    }

    .mobile-back-btn {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 8px 12px;
        margin-bottom: 12px;
        width: auto;
        align-self: flex-start;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: var(--surface);
        color: var(--text);
        font-size: 13px;
        cursor: pointer;
        font-family: inherit;
    }

    .mobile-back-btn:hover {
        background: var(--blue-softer);
        border-color: var(--blue);
        color: var(--blue);
    }

    .inbound-detail-header {
        flex-direction: column;
        align-items: stretch;
    }

    .product-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .image-viewer {
        flex-direction: column;
    }

    .image-panel.original-panel {
        flex: none;
        max-width: 100%;
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .splitter {
        display: none;
    }
}

@media (max-width: 600px) {
    .inbound-sidebar {
        padding: 8px;
    }

    .inbound-detail {
        padding: 16px;
        overflow-x: hidden;
        overscroll-behavior-x: none;
    }

    .inbound-detail-name {
        font-size: 18px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}