.camera-module-wrap { min-height: 0; height: calc(100vh - 220px); display: flex; align-items: center; justify-content: center; padding: 6px 0 0; }
.camera-module { width: min(760px, 100%); max-height: 100%; border: 1px solid #aeb1b8; border-radius: 16px; background: #fff; padding: 18px 22px 20px; box-shadow: 0 10px 24px rgba(21, 32, 54, .08); display: flex; flex-direction: column; }
.camera-module h3 { margin: 0 0 6px; color: #171717; font-size: 1.18rem; font-weight: 700; text-align: center; }
.camera-module p { margin: 0; color: #4a4a50; font-size: .9rem; text-align: center; }
.scan-pending-note { margin: 8px 0 0; color: #6d4b08; font-size: .83rem; font-weight: 700; }
.camera-frame-wrap { margin-top: 12px; display: flex; justify-content: center; flex: 1; min-height: 0; }
.camera-frame {
    width: min(340px, 90%, 38vh);
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    border: 2px solid #0c4fa7;
    background: radial-gradient(circle at 18% 20%, rgba(70, 95, 135, .42) 0%, rgba(32, 38, 52, .9) 44%, #0f1119 100%);
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
}
.camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
}
.camera-canvas { display: none; }
.camera-frame::before { content: ""; position: absolute; inset: 14% 14%; border: 2px dashed rgba(255,255,255,.72); border-radius: 14px; }
.camera-frame::after { content: ""; position: absolute; left: 14%; right: 14%; top: 50%; height: 2px; background: rgba(106, 222, 255, .92); box-shadow: 0 0 14px rgba(106, 222, 255, .75); }
.camera-frame span { position: relative; z-index: 1; color: #dfefff; font-size: 1rem; font-weight: 600; background: rgba(5, 13, 30, .48); padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.26); }

.camera-module-footer { margin-top: 10px; display: flex; justify-content: center; align-items: center; gap: 10px; color: #5c5d65; font-size: .84rem; }
.camera-dot { width: 8px; height: 8px; border-radius: 50%; background: #0c4fa7; }

.scan-session-counters {
    margin-top: 8px;
    border: 1px solid #d8e2f0;
    border-radius: 14px;
    background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
    padding: 8px 9px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.scan-session-counters-head {
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    gap: 10px;
}
.scan-session-counters-title {
    margin: 0;
    color: #2f5188;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: left;
}
.scan-session-counters-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-top: 6px;
}
.scan-counter-card {
    border: 1px solid #cdd8e8;
    border-radius: 11px;
    background: #ffffff;
    padding: 6px 7px;
    color: #30445f;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 62px;
    box-shadow: 0 8px 16px rgba(31, 52, 84, .06);
}
.scan-counter-icon {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .54rem;
    font-weight: 800;
    letter-spacing: .03em;
}
.scan-counter-label {
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .01em;
}
.scan-counter-card b {
    font-size: 1.12rem;
    line-height: 1;
    color: #163a6b;
}
.scan-counter-card.is-ok {
    border-color: #a8d8b5;
    background: linear-gradient(180deg, #effbf3 0%, #e6f7ec 100%);
    color: #1f6936;
}
.scan-counter-card.is-ok .scan-counter-icon {
    background: #b8ebc6;
    color: #17632f;
}
.scan-counter-card.is-ok b {
    color: #17632f;
}
.scan-counter-card.is-warn {
    border-color: #ebd39b;
    background: linear-gradient(180deg, #fff9ea 0%, #fff4dc 100%);
    color: #7b5a00;
}
.scan-counter-card.is-warn .scan-counter-icon {
    background: #f4deac;
    color: #6d5000;
}
.scan-counter-card.is-warn b {
    color: #6d5000;
}
.scan-counter-card.is-error {
    border-color: #e6b0b9;
    background: linear-gradient(180deg, #fff3f5 0%, #ffe9ec 100%);
    color: #8d2633;
}
.scan-counter-card.is-error .scan-counter-icon {
    background: #f1c0c8;
    color: #7c1e2a;
}
.scan-counter-card.is-error b {
    color: #7c1e2a;
}
.scan-counter-card.is-total {
    border-color: #b4c8e6;
    background: linear-gradient(180deg, #eef5ff 0%, #e3edfc 100%);
    color: #274d86;
}
.scan-counter-card.is-total .scan-counter-icon {
    background: #c9d9f3;
    color: #214579;
}
.scan-counter-card.is-total b {
    color: #1a4278;
}

.scan-toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 620;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 24px));
}
.scan-toast {
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 11px 14px;
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.3;
    box-shadow: 0 10px 20px rgba(12, 24, 42, .18);
    opacity: 1;
    transform: translateY(0);
    transition: opacity .25s ease, transform .25s ease;
}
.scan-toast.is-success {
    background: #e8f8ed;
    border-color: #84cf98;
    color: #155c2d;
}
.scan-toast.is-warn {
    background: #fff8e4;
    border-color: #e7c776;
    color: #6f4e00;
}
.scan-toast.is-error {
    background: #ffecee;
    border-color: #e5a4ad;
    color: #8f2231;
}
.scan-toast.is-leaving {
    opacity: 0;
    transform: translateY(8px);
}

.scan-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 18, 40, 0.54);
    z-index: 500;
}
.scan-modal {
    position: fixed;
    inset: 0;
    z-index: 510;
    display: grid;
    place-items: center;
    padding: 24px;
}
.scan-modal-card {
    width: min(720px, calc(100vw - 32px));
    border: 1px solid #d7dce6;
    border-radius: 18px;
    background: #f9fbff;
    box-shadow: 0 18px 44px rgba(8, 24, 52, 0.22);
    overflow: hidden;
}
.scan-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px 10px;
    background: linear-gradient(180deg, #eef4ff 0%, #f9fbff 100%);
    border-bottom: 1px solid #dce4f1;
}
.scan-modal-kicker {
    margin: 0 0 2px;
    color: #5874a4;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.scan-modal-head h3 {
    margin: 0;
    color: #173c74;
    font-size: 1rem;
    font-weight: 700;
}
.scan-modal-body {
    padding-bottom: 12px;
}
.scan-modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid #c8d5ea;
    border-radius: 10px;
    background: #fff;
    color: #20457f;
    font-size: 1.35rem;
    line-height: 1;
}
.scan-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
    padding: 12px 16px 8px;
}
.scan-modal-field {
    border: 1px solid #dde5f1;
    border-radius: 10px;
    background: #fff;
    padding: 7px 10px;
    min-width: 0;
}
.scan-modal-field-highlight {
    border-color: #f0c36b;
    background: linear-gradient(180deg, #fff8ea 0%, #fff2d7 100%);
    box-shadow: 0 8px 18px rgba(208, 148, 31, 0.14);
}
.scan-modal-field-wide { grid-column: 1 / -1; }
.scan-modal-field b {
    display: block;
    margin-bottom: 2px;
    color: #5874a4;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.scan-modal-field span {
    display: block;
    color: #20314c;
    font-size: .84rem;
    line-height: 1.25;
    word-break: break-word;
}
.scan-modal-field-highlight b {
    color: #9a5a00;
}
.scan-modal-field-highlight span {
    color: #4c2d00;
    font-size: .92rem;
    font-weight: 700;
}
.scan-modal-footer {
    padding: 0 16px 14px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.scan-driver-select {
    min-width: 220px;
    border: 1px solid #c9d6ea;
    border-radius: 10px;
    background: #fff;
    color: #183f75;
    font-size: .86rem;
    padding: 8px 10px;
}
.scan-driver-preset-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 2px 0 10px;
}
.scan-driver-preset-row label {
    font-size: .82rem;
    font-weight: 700;
    color: #244574;
}
.scan-driver-preset-row .choices {
    width: 100%;
}
.scan-driver-preset-row .choices__inner {
    min-height: 36px;
    border-radius: 10px;
    border-color: #c9d6ea;
    padding: 6px 10px;
}
.scan-driver-preset-row .choices__list--single {
    padding: 1px 18px 1px 0;
}
.scan-driver-preset-row .choices__input {
    font-size: .92rem;
}
.scan-modal-footer .choices {
    flex: 1 1 300px;
    min-width: 280px;
    max-width: 420px;
}
.scan-modal-footer .choices__inner {
    min-height: 36px;
    border-radius: 10px;
    border-color: #c9d6ea;
    padding: 6px 10px;
}
.scan-modal-footer .choices__list--single {
    padding: 1px 18px 1px 0;
}
.scan-modal-footer .choices__list--dropdown {
    z-index: 20;
}
.scan-modal-footer .choices.is-open .choices__list--dropdown {
    top: auto;
    bottom: calc(100% + 6px);
}
.scan-modal-footer .choices__input {
    font-size: .92rem;
}
.scan-modal-action {
    border: 1px solid #0c56b4;
    border-radius: 999px;
    background: #0c56b4;
    color: #fff;
    font-size: .86rem;
    font-weight: 700;
    padding: 7px 14px;
    white-space: nowrap;
}
.scan-modal-action-secondary {
    background: #fff;
    color: #0c56b4;
}
.scan-modal-action-obs {
    background: #eff6ff;
    color: #0c56b4;
    border-color: #9ab9e6;
}
.scan-modal-action[disabled] {
    opacity: .65;
    cursor: not-allowed;
}
.scan-obs-form {
    margin: 2px 16px 12px;
    border: 1px solid #d5e1f2;
    border-radius: 12px;
    background: #f8fbff;
    padding: 10px;
}
.scan-obs-textarea {
    width: 100%;
    min-height: 78px;
    border: 1px solid #c9d6ea;
    border-radius: 10px;
    background: #fff;
    color: #1f293b;
    padding: 8px 10px;
    font: inherit;
    resize: vertical;
}
.scan-obs-actions {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.scan-obs-feedback {
    margin-right: auto;
    font-size: .78rem;
    font-weight: 700;
}
.scan-obs-feedback.is-error { color: #9b2f2f; }
.scan-obs-feedback.is-success { color: #1f6a37; }
.scan-modal-note {
    margin: 0;
    padding: 6px 16px 8px;
    color: #1e4f92;
    font-size: .8rem;
    text-align: left;
}
.scan-modal-note.is-error { color: #9b2f2f; }
.scan-modal-note.is-success { color: #1f6a37; }
.scan-modal-observation {
    margin: 4px 16px 12px;
    border: 1px solid #d5e1f2;
    border-radius: 12px;
    background: #f8fbff;
    padding: 10px;
}
.scan-modal-observation label {
    display: block;
    color: #244574;
    font-size: .8rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.scan-modal-observation textarea {
    width: 100%;
    min-height: 82px;
    border: 1px solid #c9d6ea;
    border-radius: 10px;
    background: #fff;
    color: #1f293b;
    padding: 8px 10px;
    font: inherit;
    resize: vertical;
}
.scan-modal-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}
.scan-modal-feedback {
    margin: 8px 0 0;
    font-size: .78rem;
    font-weight: 700;
}
.scan-modal-feedback.is-error { color: #9b2f2f; }
.scan-modal-feedback.is-success { color: #1f6a37; }
.scan-obs-history {
    margin: 0 16px;
    border: 1px solid #d5e1f2;
    border-radius: 12px;
    background: #fff;
    padding: 10px;
}
.scan-obs-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.scan-obs-history-head h4 {
    margin: 0;
    color: #173c74;
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.scan-obs-history-head span {
    color: #5d6f8e;
    font-size: .74rem;
    font-weight: 700;
}
.scan-obs-history-empty {
    margin: 0;
    color: #5d6f8e;
    font-size: .8rem;
}
.scan-obs-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}
.scan-obs-history-item {
    border: 1px solid #e1e9f6;
    border-radius: 10px;
    background: #f9fbff;
    padding: 8px 10px;
}
.scan-obs-history-item-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}
.scan-obs-history-item-head strong {
    color: #1f3f70;
    font-size: .76rem;
}
.scan-obs-history-item-head span {
    color: #607596;
    font-size: .7rem;
}
.scan-obs-history-item p {
    margin: 0;
    color: #223651;
    font-size: .82rem;
    line-height: 1.3;
    white-space: pre-wrap;
    word-break: break-word;
}
.scan-api-banner {
    margin: 0 16px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 8px 10px;
    font-size: .78rem;
    line-height: 1.3;
    font-weight: 700;
}
.scan-api-banner.is-api {
    background: #fff6e9;
    border-color: #efc170;
    color: #7b4a00;
}
.scan-api-banner.is-local {
    background: #ffeef0;
    border-color: #e7a9b1;
    color: #8d1f2f;
}
body.scan-modal-open { overflow: hidden; }

@media (max-width: 840px) {
    .scan-session-counters {
        margin-top: 7px;
        padding: 6px;
    }

    .scan-session-counters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
        margin-top: 5px;
    }

    .scan-session-counters-head {
        gap: 0;
    }

    .scan-counter-card {
        min-height: 46px;
        padding: 4px 5px;
        gap: 1px;
        border-radius: 10px;
    }

    .scan-counter-card b {
        font-size: .88rem;
    }

    .scan-counter-icon {
        width: 12px;
        height: 12px;
        font-size: .44rem;
    }

    .scan-counter-label {
        font-size: .58rem;
    }

    .scan-modal {
        padding: 12px;
        align-items: center;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }

    .scan-modal-card {
        width: 100%;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        min-height: 0;
    }

    .scan-modal-grid {
        grid-template-columns: 1fr;
        padding: 10px 12px 8px;
        gap: 8px;
        padding-bottom: 10px;
        overflow: visible;
    }

    .scan-modal-note {
        padding: 8px 12px 10px;
    }

    .scan-modal-observation {
        margin: 0 12px 12px;
    }

    .scan-obs-history {
        margin: 0 12px;
    }

    .scan-api-banner {
        margin: 0 12px 10px;
    }

    .scan-modal-footer {
        padding: 0 12px 12px;
        justify-content: stretch;
        align-items: stretch;
        gap: 10px;
    }

    .scan-obs-form {
        margin: 0 12px 12px;
    }

    .scan-modal-footer .choices {
        flex: 1 1 100%;
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    .scan-modal-action {
        width: 100%;
        text-align: center;
        white-space: normal;
        padding: 9px 12px;
    }

}

@media (max-width: 840px) and (display-mode: standalone) {
    .scan-modal {
        padding-top: calc(12px + env(safe-area-inset-top));
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .scan-modal-card {
        max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }

    .scan-modal-footer {
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }
}
