.barcode-camera-trigger {
    min-width: 44px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--card, #fffdfa);
    color: var(--text, #211814);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 5px 14px rgba(45, 27, 18, .07);
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.barcode-camera-trigger:hover {
    border-color: var(--orange, #ff6b0f);
    box-shadow: 0 8px 18px rgba(255, 107, 15, .12);
    transform: translateY(-1px);
}

.barcode-camera-trigger svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.barcode-camera-trigger.is-primary {
    background: var(--orange, #ff6b0f);
    border-color: var(--orange, #ff6b0f);
    color: #fff;
}

.barcode-camera-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(9, 8, 8, .78);
    backdrop-filter: blur(8px);
}

.barcode-camera-modal[hidden] { display: none !important; }
body.barcode-camera-open { overflow: hidden !important; }

.barcode-camera-sheet {
    width: min(620px, 100%);
    max-height: min(920px, calc(100dvh - 28px));
    overflow: auto;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 24px;
    background: #fffaf5;
    box-shadow: 0 32px 90px rgba(0,0,0,.42);
}

.barcode-camera-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 14px;
}

.barcode-camera-head small {
    display: block;
    margin-bottom: 3px;
    color: #ff6b0f;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.barcode-camera-head h2 {
    margin: 0;
    color: #211814;
    font-size: clamp(19px, 4vw, 25px);
    line-height: 1.15;
}

.barcode-camera-close {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid #eaded5;
    border-radius: 13px;
    background: #fff;
    color: #665950;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.barcode-camera-view {
    position: relative;
    width: calc(100% - 28px);
    aspect-ratio: 4 / 3;
    margin: 0 14px;
    overflow: hidden;
    border-radius: 19px;
    background: #111;
}

.barcode-camera-view video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.barcode-camera-mask {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    background: linear-gradient(rgba(0,0,0,.40), rgba(0,0,0,.40));
}

.barcode-camera-frame {
    position: relative;
    width: min(82%, 480px);
    height: 38%;
    border: 2px solid rgba(255,255,255,.9);
    border-radius: 16px;
    box-shadow: 0 0 0 999px rgba(0,0,0,.28), 0 0 22px rgba(255,107,15,.28);
}

.barcode-camera-frame::before,
.barcode-camera-frame::after {
    content: '';
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: #ff6b0f;
}

.barcode-camera-frame::before {
    left: -3px;
    top: -3px;
    border-left: 4px solid #ff6b0f;
    border-top: 4px solid #ff6b0f;
    border-radius: 12px 0 0;
}

.barcode-camera-frame::after {
    right: -3px;
    bottom: -3px;
    border-right: 4px solid #ff6b0f;
    border-bottom: 4px solid #ff6b0f;
    border-radius: 0 0 12px;
}

.barcode-camera-frame i {
    position: absolute;
    left: 5%;
    right: 5%;
    top: 50%;
    height: 2px;
    border-radius: 999px;
    background: #ff6b0f;
    box-shadow: 0 0 12px #ff6b0f;
    animation: barcodeScanLine 1.5s ease-in-out infinite alternate;
}

@keyframes barcodeScanLine {
    from { transform: translateY(-42px); }
    to { transform: translateY(42px); }
}

.barcode-camera-wait {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    background: rgba(13, 12, 12, .88);
    color: #fff;
    text-align: center;
}

.barcode-camera-wait[hidden] { display: none; }
.barcode-camera-wait span {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #ff6b0f;
    border-radius: 50%;
    animation: barcodeSpinner .8s linear infinite;
}
@keyframes barcodeSpinner { to { transform: rotate(360deg); } }

.barcode-camera-feedback {
    min-height: 72px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 12px 20px 4px;
    text-align: center;
}

.barcode-camera-feedback p {
    margin: 0;
    color: #6f6259;
    font-size: 14px;
    font-weight: 650;
}
.barcode-camera-feedback p[data-state="success"] { color: #087c42; }
.barcode-camera-feedback p[data-state="error"] { color: #c51d37; }
.barcode-camera-feedback p[data-state="loading"] { color: #c75309; }
.barcode-camera-feedback strong {
    color: #211814;
    font-size: 17px;
    letter-spacing: .04em;
}

.barcode-camera-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 20px;
}

.barcode-camera-actions button,
.barcode-camera-manual button {
    min-height: 42px;
    border: 1px solid #e7dacf;
    border-radius: 12px;
    background: #fff;
    color: #2a201b;
    font: inherit;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}
.barcode-camera-actions button:last-child,
.barcode-camera-manual button {
    background: #ff6b0f;
    border-color: #ff6b0f;
    color: #fff;
}
.barcode-camera-actions button.is-active { background: #fff1d9; color: #a44c00; }
.barcode-camera-actions button[hidden] { display: none; }

.barcode-camera-manual {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
    padding: 5px 20px 10px;
}
.barcode-camera-manual label { display: grid; gap: 5px; }
.barcode-camera-manual label span { color: #786b62; font-size: 11px; font-weight: 700; }
.barcode-camera-manual input {
    width: 100%;
    min-height: 42px;
    border: 1px solid #e5d8cf;
    border-radius: 12px;
    background: #fff;
    padding: 0 12px;
    color: #211814;
    font: inherit;
}
.barcode-camera-manual button { padding: 0 16px; }
.barcode-camera-help {
    display: block;
    padding: 0 20px 18px;
    color: #8a7b71;
    font-size: 10.5px;
    text-align: center;
}

:root[data-theme="dark"] .barcode-camera-sheet { background: #17191e; border-color: #343840; }
:root[data-theme="dark"] .barcode-camera-head h2,
:root[data-theme="dark"] .barcode-camera-feedback strong { color: #f7f3ef; }
:root[data-theme="dark"] .barcode-camera-close,
:root[data-theme="dark"] .barcode-camera-actions button,
:root[data-theme="dark"] .barcode-camera-manual input { background: #22252b; border-color: #383c45; color: #f7f3ef; }
:root[data-theme="dark"] .barcode-camera-feedback p,
:root[data-theme="dark"] .barcode-camera-manual label span,
:root[data-theme="dark"] .barcode-camera-help { color: #b7aea8; }

@media (max-width: 620px) {
    .barcode-camera-modal { padding: 0; align-items: end; }
    .barcode-camera-sheet {
        width: 100%;
        max-height: 100dvh;
        border-radius: 22px 22px 0 0;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }
    .barcode-camera-head { padding: 14px 15px 11px; }
    .barcode-camera-view { width: calc(100% - 20px); margin: 0 10px; aspect-ratio: 3 / 4; max-height: 58dvh; }
    .barcode-camera-frame { width: 88%; height: 27%; }
    .barcode-camera-feedback { min-height: 62px; padding: 10px 14px 2px; }
    .barcode-camera-actions { padding: 8px 12px; }
    .barcode-camera-actions button { min-height: 46px; font-size: 12px; }
    .barcode-camera-manual { padding: 4px 12px 8px; grid-template-columns: minmax(0, 1fr) 104px; }
    .barcode-camera-help { padding: 0 12px 10px; }
    .barcode-camera-trigger .barcode-camera-label-mobile-hide { display: none; }
}
