.bpm-wrap {
    --bpm-bg: #f4f6f8;
    --bpm-panel: #ffffff;
    --bpm-text: #1f2937;
    --bpm-muted: #64748b;
    --bpm-border: #d9e2ec;
    --bpm-primary: #0f766e;
    --bpm-danger: #b91c1c;
    color: var(--bpm-text);
}

.bpm-wrap h1 {
    font-weight: 700;
    margin: 18px 0;
}

.bpm-panel,
.bpm-scanner {
    background: var(--bpm-panel);
    border: 1px solid var(--bpm-border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    margin: 16px 0;
    padding: 18px;
}

.bpm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.bpm-card {
    background: #ffffff;
    border: 1px solid var(--bpm-border);
    border-left: 6px solid var(--bpm-primary);
    border-radius: 8px;
    padding: 18px;
}

.bpm-card span {
    color: var(--bpm-muted);
    display: block;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.bpm-card strong {
    display: block;
    font-size: 34px;
    line-height: 1.1;
    margin-top: 8px;
}

.btn-xl {
    font-size: 24px;
    min-height: 64px;
    padding: 14px 28px;
}

.bpm-scan-header {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.bpm-scanner {
    display: flex;
    flex-direction: column;
    position: relative;
}

.bpm-scanner > .d-flex.flex-wrap.gap-2.mb-3 {
    display: grid !important;
    gap: 12px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 0 !important;
    order: 5;
}

.bpm-scanner > .row.g-3 {
    --bs-gutter-x: 0;
    --bs-gutter-y: 12px;
    display: flex;
    flex-direction: column;
    margin-top: 0;
    order: 4;
}

.bpm-scanner > .row.g-3 > .col-lg-5,
.bpm-scanner > .row.g-3 > .col-lg-7 {
    width: 100%;
}

.bpm-scanner-camera {
    position: static;
}

#bpm-reader {
    border: 2px solid var(--bpm-border);
    border-radius: 8px;
    min-height: 320px;
    overflow: hidden;
}

.bpm-mobile-scanner {
    display: block;
}

@media (min-width: 783px) {
    .bpm-mobile-scanner {
        display: none;
    }
}

.bpm-status {
    align-items: center;
    background: #0f172a;
    border: 4px solid #38bdf8;
    border-radius: 16px;
    color: #f8fafc;
    display: flex;
    font-size: clamp(38px, 4.4vw, 72px);
    font-weight: 900;
    justify-content: center;
    letter-spacing: -.03em;
    line-height: 1.08;
    min-height: 66vh;
    order: 1;
    padding: 32px;
    text-align: center;
    text-transform: uppercase;
}

.bpm-status.is-success {
    background: #00ff66;
    border-color: #001f0c;
    color: #001f0c;
}

.bpm-status.is-warning {
    background: #ffea00;
    border-color: #1f1300;
    color: #1f1300;
}

.bpm-status.is-error {
    background: #ff1744;
    border-color: #fff5f7;
    color: #fff5f7;
}

.scan-status-panel {
    align-items: center;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    inset: 18px;
    min-height: 0;
    opacity: 0;
    padding: 24px;
    pointer-events: none;
    position: absolute;
    text-align: center;
    transform: scale(.97);
    transition: opacity .18s ease, transform .18s ease;
    width: auto;
    z-index: 20;
}

.scan-status-panel.is-visible {
    opacity: 1;
    transform: scale(1);
}

.scan-status-panel.is-success {
    background: #065f46;
    color: #fff;
}

.scan-status-panel.is-duplicate {
    background: #facc15;
    color: #111827;
}

.scan-status-panel.is-error {
    background: #dc2626;
    color: #fff;
}

.scan-status-panel.is-mismatch {
    background: #7f1d1d;
    color: #fff;
}

.scan-status-title {
    font-size: clamp(42px, 5vw, 72px);
    font-weight: 900;
    line-height: 1.05;
}

.scan-status-line {
    font-size: clamp(22px, 2.6vw, 34px);
    font-weight: 800;
    line-height: 1.15;
    margin-top: 8px;
}

#bpm-manual-scan {
    margin-bottom: 0 !important;
    order: 2;
}

#bpm-manual-scan .form-control,
#bpm-manual-scan .btn,
#bpm-undo,
.bpm-scanner > .d-flex.flex-wrap.gap-2.mb-3 .btn,
.bpm-scanner > .d-flex.flex-wrap.gap-2.mb-3 a {
    min-height: 58px;
}

#bpm-undo {
    margin-bottom: 0 !important;
    order: 3;
    width: 100%;
}

.scan-status-panel.is-blink {
    animation: bpm-scan-blink .28s linear 0s 6 alternate;
}

@keyframes bpm-scan-blink {
    from { filter: brightness(1); }
    to { filter: brightness(1.75); }
}

.bpm-wrap .table th {
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    text-transform: uppercase;
}

.bpm-project-qr-meta {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.bpm-project-qr-meta__line {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    display: flex;
    flex-wrap: wrap;
    font-size: 12px;
    gap: 8px;
    line-height: 1.45;
    padding: 7px 10px;
}

.bpm-project-qr-meta__line span {
    color: #0f172a;
    font-size: 12px;
    font-weight: 700;
}

.bpm-project-qr-meta__line code {
    background: #0f172a;
    border-radius: 6px;
    color: #f8fafc;
    font-size: 12px;
    padding: 4px 8px;
    word-break: break-all;
}

.bpm-board-browser {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.bpm-board-projects {
    align-self: start;
    max-height: calc(100vh - 150px);
    overflow: auto;
}

.bpm-project-list {
    display: grid;
    gap: 10px;
}

.bpm-project-item {
    background: #fff;
    border: 1px solid var(--bpm-border);
    border-left: 5px solid transparent;
    border-radius: 8px;
    color: var(--bpm-text);
    cursor: pointer;
    display: grid;
    gap: 4px;
    padding: 12px;
    text-align: left;
    width: 100%;
}

.bpm-project-item:hover,
.bpm-project-item.is-active {
    border-left-color: var(--bpm-primary);
    box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}

.bpm-project-item strong {
    font-size: 16px;
}

.bpm-project-item span {
    color: var(--bpm-muted);
    font-size: 13px;
}

.bpm-project-progress {
    margin-top: 4px;
}

.bpm-project-progress__bar {
    align-items: center;
    background:
        linear-gradient(90deg, #0f766e 0%, #14b8a6 var(--bpm-progress), #e2e8f0 var(--bpm-progress), #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    display: flex;
    justify-content: center;
    min-height: 26px;
    overflow: hidden;
    position: relative;
}

.bpm-project-progress__bar span {
    color: #0f172a;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .04em;
    position: relative;
    z-index: 1;
}

.bpm-board-toolbar {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(180px, 1fr) 180px 90px 130px;
}

.bpm-loading {
    color: var(--bpm-muted);
    font-size: 18px;
    padding: 20px 0;
}

.bpm-package-title {
    font-weight: 800;
    min-width: 110px;
}

.bpm-package-title + span,
.bpm-package-title + span + span,
.bpm-package-title + span + span + span {
    margin-left: 18px;
}

.bpm-package-row {
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.bpm-wrap .table tbody tr.bpm-package-row--open > td {
    background: #f5fbf8;
}

.bpm-wrap .table tbody tr.bpm-package-row--locked > td {
    background: #f8fafc;
}

.bpm-wrap .table.table-hover tbody tr.bpm-package-row--open:hover > td {
    background: #edf8f2;
}

.bpm-wrap .table.table-hover tbody tr.bpm-package-row--locked:hover > td {
    background: #f1f5f9;
}

.accordion-item.bpm-package-row--open {
    background: linear-gradient(180deg, #fcfffd, #f3faf6);
    border-color: #d6ebe0;
}

.accordion-item.bpm-package-row--locked {
    background: linear-gradient(180deg, #ffffff, #f7f9fc);
    border-color: #dbe4ee;
}

.accordion-item.bpm-package-row--open .accordion-button {
    background: rgba(15, 118, 110, .04);
}

.accordion-item.bpm-package-row--locked .accordion-button {
    background: rgba(148, 163, 184, .08);
}

.bpm-excel-upload-form {
    width: 100%;
}

.bpm-upload-row {
    align-items: stretch;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) 180px;
}

.bpm-upload-customer {
    margin-bottom: 12px;
}

.bpm-upload-customer__label {
    color: var(--bpm-muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.bpm-upload-match-fields {
    margin-top: 12px;
}

.bpm-upload-match-fields__label {
    color: var(--bpm-muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.bpm-upload-match-fields__options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.bpm-upload-match-field {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--bpm-border);
    border-radius: 999px;
    display: inline-flex;
    gap: 8px;
    padding: 8px 12px;
}

.bpm-upload-match-field span {
    font-size: 13px;
    font-weight: 600;
}

.bpm-upload-field {
    align-items: center;
    background: linear-gradient(135deg, #f8fafc, #eef6f4);
    border: 1px solid var(--bpm-border);
    border-radius: 14px;
    display: flex;
    overflow: hidden;
    position: relative;
}

.bpm-upload-progress-bar {
    background: linear-gradient(90deg, #0f766e, #14b8a6);
    bottom: 0;
    left: 0;
    opacity: .18;
    position: absolute;
    top: 0;
    transition: width .18s ease;
    width: 0;
    z-index: 0;
}

.bpm-upload-progress-label {
    color: var(--bpm-muted);
    font-size: 14px;
    font-weight: 600;
    left: 18px;
    pointer-events: none;
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

.bpm-upload-input {
    background: transparent !important;
    border: 0 !important;
    color: transparent !important;
    min-height: 62px;
    opacity: 0;
    padding: 0 !important;
    position: relative;
    width: 100%;
    z-index: 1;
}

.bpm-upload-field.is-has-file .bpm-upload-progress-label {
    color: var(--bpm-text);
}

.bpm-upload-field.is-uploading .bpm-upload-progress-label {
    color: #0f172a;
}

.bpm-upload-field.is-complete .bpm-upload-progress-bar {
    opacity: .26;
}

.bpm-upload-field.is-error {
    border-color: #dc2626;
}

.bpm-upload-field.is-error .bpm-upload-progress-bar {
    background: linear-gradient(90deg, #dc2626, #f87171);
    opacity: .18;
}

.bpm-upload-field.is-error .bpm-upload-progress-label {
    color: #991b1b;
}

@media (prefers-color-scheme: dark) {
    .bpm-wrap {
        --bpm-bg: #101827;
        --bpm-panel: #172033;
        --bpm-text: #e5e7eb;
        --bpm-muted: #a7b4c5;
        --bpm-border: #2b3951;
    }

    .bpm-card,
    .bpm-panel,
    .bpm-scanner,
    .bpm-wrap .table th {
        background: var(--bpm-panel);
        color: var(--bpm-text);
    }
}

@media (max-width: 782px) {
    .bpm-panel,
    .bpm-scanner {
        padding: 12px;
    }

    .bpm-card strong {
        font-size: 28px;
    }

    .bpm-status {
        font-size: 20px;
        min-height: 100px;
    }

    .bpm-mobile-scanner {
        display: block;
    }

    .bpm-scanner {
        padding: 12px;
        display: flex;
        flex-direction: column;
    }

    .bpm-scan-header {
        margin-bottom: 12px;
    }

    .bpm-scanner > .d-flex.flex-wrap.gap-2.mb-3 {
        display: flex !important;
        flex-direction: column;
        gap: 10px !important;
        margin-bottom: 10px !important;
        order: 5;
    }

    .bpm-scanner > .d-flex.flex-wrap.gap-2.mb-3 .btn,
    .bpm-scanner > .d-flex.flex-wrap.gap-2.mb-3 a {
        width: 100%;
    }

    .bpm-scanner .row.g-3 {
        --bs-gutter-y: 12px;
        order: 4;
    }

    .bpm-scanner .col-lg-5,
    .bpm-scanner .col-lg-7 {
        width: 100%;
    }

    .bpm-scanner-camera {
        display: flex;
        flex-direction: column;
        gap: 8px;
        min-height: 33vh;
    }

    #bpm-switch-camera {
        margin-bottom: 0 !important;
        order: 1;
    }

    #bpm-reader {
        min-height: 33vh;
        order: 2;
    }

    .scan-status-panel {
        border-radius: 16px;
        inset: 44px 10px 10px;
        margin-bottom: 0;
        min-height: 0;
        position: absolute;
        transform: scale(.96);
        width: auto;
    }

    .scan-status-panel.is-visible {
        transform: scale(1);
    }

    .scan-status-title {
        font-size: clamp(22px, 6vw, 34px);
    }

    .scan-status-line {
        font-size: clamp(14px, 4vw, 20px);
        margin-top: 6px;
    }

    #bpm-manual-scan {
        margin-bottom: 10px !important;
    }

    #bpm-manual-scan .form-control,
    #bpm-manual-scan .btn,
    #bpm-undo,
    #bpm-scan-result {
        min-height: 54px;
    }

    #bpm-undo {
        margin-bottom: 10px !important;
        width: 100%;
    }

    #bpm-scan-result {
        display: none;
    }

    .bpm-board-browser {
        grid-template-columns: 1fr;
    }

    .bpm-board-projects {
        max-height: none;
    }

    .bpm-board-toolbar {
        grid-template-columns: 1fr;
    }

    .bpm-package-title,
    .bpm-package-title + span,
    .bpm-package-title + span + span,
    .bpm-package-title + span + span + span {
        display: block;
        margin-left: 0;
        width: 100%;
    }

    .bpm-upload-row {
        grid-template-columns: 1fr;
    }

    .bpm-upload-input {
        min-height: 58px;
    }
}
