/* ─────────────────────────────────────────────────────────
   QR 스캔 (모바일)
   현장 폰 사용 기준: 좁은 폭 고정 + 카드 세로 스택 + 큰 터치 타깃
   화면1 품목 · 화면2 로트목록 · 화면3 로트상세
   ───────────────────────────────────────────────────────── */

.qrs {
    max-width: 480px;
    margin: 0 auto;
    /* 하단 모바일 탭바(고정, ~56px+safe-area)에 마지막 카드가 가리지 않도록 충분히 띄움 */
    padding: 4px 0 calc(84px + env(safe-area-inset-bottom, 0px));
}

.qrs .page-header {
    margin-bottom: 14px;
}

/* 화면 전환 — 한 번에 하나만 보임 */
.qrs-screen.hidden {
    display: none;
}

.qrs-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qrs-card {
    padding: 16px 18px;
}

/* ── 서브 헤더 (화면2·3) ── */
.qrs-subhead {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    min-height: 40px;
}

.qrs-back {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    font-size: 15px;
}

.qrs-subhead__title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.qrs-subhead__sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-left: auto;
}

/* ════════ 화면 1 — 품목 정보 ════════ */

.qrs-itemcode {
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 0.02em;
}

.qrs-itemname {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    margin-top: 2px;
    word-break: keep-all;
}

.qrs-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.qrs-spec {
    font-size: 13px;
    color: var(--text-muted);
    word-break: keep-all;
}

.qrs-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.qrs-total__label { font-size: 14px; color: var(--text-muted); }
.qrs-total__value { font-size: 30px; font-weight: 800; color: var(--brand); }
.qrs-total__unit  { font-size: 15px; font-weight: 600; color: var(--text-dim); margin-left: 2px; }

.qrs-card__title {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.qrs-whlist { display: flex; flex-direction: column; }

.qrs-whlist li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 2px;
    border-bottom: 1px solid var(--border);
}
.qrs-whlist li:last-child { border-bottom: 0; }

.qrs-wh-name { font-size: 14px; color: var(--text); }
.qrs-wh-qty  { font-size: 15px; font-weight: 700; color: var(--text); }
.qrs-wh-qty .qrs-wh-unit { font-size: 12px; font-weight: 500; color: var(--text-dim); margin-left: 3px; }
.qrs-whempty { font-size: 13px; color: var(--text-dim); padding: 8px 2px; }

/* ── 추적 진입 버튼 ── */
.qrs-track-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}
.qrs-track-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.qrs-track-btn:not(:disabled):active { background: rgba(255, 255, 255, 0.05); }
.qrs-track-btn > span:first-of-type { flex: 1; text-align: left; }
.qrs-track-go { color: var(--text-dim); }

.qrs-soon {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 8px;
}

/* ════════ 화면 2 — 로트 목록 ════════ */

/* 필터 칩 */
.qrs-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.qrs-chip {
    flex: 1;
    min-height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}
.qrs-chip.is-on {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--text);
}

/* 로트 카드 */
.qrs-lot {
    padding: 14px 16px;
    cursor: pointer;
}
.qrs-lot:active { background: rgba(255, 255, 255, 0.04); }

.qrs-lot__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.qrs-lot__no {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

/* 잔여율 게이지 */
.qrs-gauge {
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    margin: 10px 0 8px;
}
.qrs-gauge__bar { height: 100%; border-radius: 999px; }
.qrs-gauge__bar.g-hi  { background: var(--green); }
.qrs-gauge__bar.g-mid { background: var(--amber); }
.qrs-gauge__bar.g-lo  { background: var(--red); }

.qrs-lot__qty {
    font-size: 13px;
    color: var(--text);
}
.qrs-lot__qty b { font-weight: 700; }
.qrs-lot__qty .qrs-lot__pct { color: var(--text-dim); margin-left: 6px; }

.qrs-lot__sub {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-dim);
}

/* 페이지네이션 */
.qrs-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 14px;
}
.qrs-pager__btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
}
.qrs-pager__btn:disabled { opacity: 0.4; }
.qrs-pager__info { font-size: 13px; color: var(--text-muted); min-width: 56px; text-align: center; }

/* ════════ 화면 3 — 로트 상세 ════════ */

.qrs-d-rows {
    display: flex;
    flex-direction: column;
}
.qrs-d-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 2px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.qrs-d-row:last-child { border-bottom: 0; }
.qrs-d-row__k { color: var(--text-muted); flex: 0 0 auto; }
.qrs-d-row__v { color: var(--text); text-align: right; word-break: break-all; }

/* 이력 타임라인 */
.qrs-hist {
    display: flex;
    flex-direction: column;
}
.qrs-hist__row {
    display: flex;
    gap: 10px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--border);
}
.qrs-hist__row:last-child { border-bottom: 0; }
.qrs-hist__date {
    flex: 0 0 64px;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.4;
}
.qrs-hist__body { flex: 1; min-width: 0; }
.qrs-hist__line1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.qrs-hist__type { font-size: 13px; font-weight: 600; color: var(--text); }
.qrs-hist__qty  { font-size: 13px; font-weight: 700; }
.qrs-hist__qty.q-plus  { color: var(--green); }
.qrs-hist__qty.q-minus { color: var(--red); }
.qrs-hist__meta {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
    word-break: break-all;
}
.qrs-hist__empty { font-size: 13px; color: var(--text-dim); padding: 8px 2px; }

/* ════════ 화면 1 — 입고 대기 (4차) ════════ */

.qrs-pend-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.qrs-pend-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--amber);
    background: var(--amber-soft);
    border-radius: 999px;
    padding: 2px 9px;
}

.qrs-pend-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.qrs-pend {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.015);
}
.qrs-pend__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.qrs-pend__no  { font-size: 14px; font-weight: 700; color: var(--text); }
.qrs-pend__po  { font-size: 12px; color: var(--text-dim); }
.qrs-pend__vendor { font-size: 14px; color: var(--text); margin-top: 5px; }
.qrs-pend__line   { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.qrs-pend__line b { font-weight: 700; color: var(--text); }
.qrs-pend__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

.qrs-pend__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    min-height: 46px;
    margin-top: 11px;
    border-radius: 10px;
    border: 0;
    background: var(--green);
    color: #06120b;
    font-size: 15px;
    font-weight: 700;
}
.qrs-pend__btn:not(:disabled):active { filter: brightness(0.9); }
.qrs-pend__btn:disabled {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-weight: 600;
}

/* ── 긴급 입고 확정 — 확인 모달 ── */
.qrs-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 90;
}
.qrs-modal {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    overflow-y: auto;
    z-index: 91;
    background: var(--card);
    border: 1px solid var(--border);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
.qrs-modal.hidden,
.qrs-modal-overlay.hidden { display: none; }

.qrs-modal__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}
.qrs-modal__body { margin-bottom: 12px; }
.qrs-confirm__no  { font-size: 15px; font-weight: 700; color: var(--text); }
.qrs-confirm__sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.6;
}

.qrs-modal__warn {
    display: flex;
    gap: 8px;
    font-size: 12.5px;
    color: var(--amber);
    background: var(--amber-soft);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.qrs-modal__actions { display: flex; gap: 10px; }
.qrs-modal__btn {
    flex: 1;
    min-height: 50px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 15px;
    font-weight: 700;
}
.qrs-modal__btn--ghost {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}
.qrs-modal__btn--go {
    background: var(--green);
    border-color: var(--green);
    color: #06120b;
}
.qrs-modal__btn--go:disabled { opacity: 0.6; }

/* ════════ 화면 1 — 재고 신청 (5차) ════════ */

.qrs-req-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}
.qrs-req-btns {
    display: flex;
    gap: 10px;
}
.qrs-req-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 1;
    min-height: 52px;
    border-radius: 11px;
    border: 1.5px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}
.qrs-req-btn--in  { border-color: rgba(92, 194, 141, 0.45); color: var(--green); }
.qrs-req-btn--out { border-color: rgba(232, 112, 113, 0.45); color: var(--red); }
.qrs-req-btn:active { background: rgba(255, 255, 255, 0.05); }

/* 내 신청 현황 */
.qrs-myreq-list {
    display: flex;
    flex-direction: column;
}
.qrs-myreq {
    padding: 11px 2px;
    border-bottom: 1px solid var(--border);
}
.qrs-myreq:last-child { border-bottom: 0; }
.qrs-myreq__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.qrs-myreq__dir {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}
.qrs-myreq__dir .fa-arrow-up   { color: var(--green); margin-right: 4px; }
.qrs-myreq__dir .fa-arrow-down { color: var(--red);   margin-right: 4px; }
.qrs-myreq__no {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 3px;
}
.qrs-myreq__reason {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 3px;
    word-break: break-all;
}
.qrs-myreq__reject {
    font-size: 12px;
    color: var(--red);
    background: var(--red-soft);
    border-radius: 7px;
    padding: 6px 9px;
    margin-top: 5px;
}
.qrs-myreq__date {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ── 재고 신청 입력 모달 ── */
.qrs-req-item {
    font-size: 14px;
    color: var(--text);
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    word-break: keep-all;
}
.qrs-req-item .qrs-req-item__code {
    font-size: 12px;
    color: var(--text-dim);
    margin-right: 6px;
}

.qrs-req-field { margin-bottom: 14px; }
.qrs-req-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 7px;
}
.qrs-req-req {
    font-size: 11px;
    font-weight: 700;
    color: var(--red);
    margin-left: 2px;
}

/* 창고 칩 — 줄바꿈 허용 */
.qrs-req-wh {
    flex-wrap: wrap;
    margin-bottom: 0;
}
.qrs-req-wh .qrs-chip {
    flex: 0 1 auto;
    padding: 0 13px;
}
.qrs-req-wh .qrs-wh-stock {
    font-size: 11px;
    color: var(--text-dim);
    margin-left: 5px;
}
.qrs-req-wh .qrs-chip.is-on .qrs-wh-stock { color: var(--text-muted); }

.qrs-req-qtyrow {
    display: flex;
    align-items: center;
    gap: 10px;
}
.qrs-req-input,
.qrs-req-textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 15px;
    padding: 11px 13px;
}
.qrs-req-input { min-height: 46px; }
.qrs-req-input:focus,
.qrs-req-textarea:focus {
    outline: none;
    border-color: var(--brand);
}
.qrs-req-textarea { resize: none; line-height: 1.5; }
.qrs-req-unit {
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
}

/* ── 공통 안내 / 오류 ── */
.qrs-msg { margin-top: 36px; }

/* ─────────────────────────────────────────────────────────
   카메라 QR 스캐너
   ───────────────────────────────────────────────────────── */

/* 안내 화면 CTA 버튼 */
.qrs-scan-cta {
    margin-top: 22px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 14px 26px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    box-shadow: 0 10px 28px rgb(139 149 255 / 0.38);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.qrs-scan-cta:active { transform: scale(0.96); box-shadow: 0 6px 18px rgb(139 149 255 / 0.3); }
.qrs-scan-cta i { font-size: 17px; }

/* 플로팅 스캔 버튼 (좌측 하단 — AI 버튼과 겹치지 않게)
   ★ 하단 모바일 탭바(고정, z-50) 위로 띄우고 z-index 를 탭바보다 높여 잘리지 않게 한다. */
.qrs-scan-fab {
    position: fixed;
    left: 16px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    box-shadow: 0 8px 22px rgb(139 149 255 / 0.42);
    cursor: pointer;
    z-index: 51;          /* 탭바(z-50) 위 — 잘림 방지 */
    transition: transform 0.12s ease;
}
.qrs-scan-fab:active { transform: scale(0.92); }
@media (min-width: 520px) {
    /* 데스크톱 미리보기 시 컨테이너 옆에 붙도록 */
    .qrs-scan-fab { left: calc(50% - 240px - 16px); }
}

/* 전체화면 스캐너 */
.qrs-scanner {
    position: fixed;
    inset: 0;
    z-index: 95;
    background: #000;
    overflow: hidden;
}
.qrs-scanner.hidden { display: none; }
#qrsVideo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.qrs-scanner__ui {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* 어둡게 마스킹 — 가운데 프레임만 강조 */
    background: radial-gradient(circle at center,
        rgb(0 0 0 / 0) 0,
        rgb(0 0 0 / 0) 130px,
        rgb(0 0 0 / 0.55) 230px);
}
.qrs-scanner__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: rgb(255 255 255 / 0.14);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}
.qrs-scanner__close:active { background: rgb(255 255 255 / 0.25); }
.qrs-scanner__frame {
    position: relative;
    width: 248px;
    height: 248px;
}
.qrs-scanner__corner {
    position: absolute;
    width: 34px;
    height: 34px;
    border: 4px solid var(--brand);
}
.qrs-scanner__corner.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.qrs-scanner__corner.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 12px; }
.qrs-scanner__corner.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 12px; }
.qrs-scanner__corner.br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }
.qrs-scanner__laser {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 8px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--brand-light), transparent);
    box-shadow: 0 0 12px 2px rgb(139 149 255 / 0.7);
    animation: qrsLaser 2s ease-in-out infinite;
}
@keyframes qrsLaser {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(224px); }
    100% { transform: translateY(0); }
}
.qrs-scanner__hint {
    position: absolute;
    bottom: 12%;
    left: 24px;
    right: 24px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 6px rgb(0 0 0 / 0.8);
    line-height: 1.5;
}

/* 스캐너 오류(권한 거부 등) 안내 + 재시도 버튼 */
.qrs-scan-error {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 16%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}
.qrs-scan-error.hidden { display: none; }
.qrs-scan-error__msg {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    line-height: 1.6;
    text-shadow: 0 1px 6px rgb(0 0 0 / 0.85);
}
.qrs-scan-error__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 22px;
    border: 0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    box-shadow: 0 8px 22px rgb(139 149 255 / 0.45);
    cursor: pointer;
}
.qrs-scan-error__btn:active { transform: scale(0.96); }
.qrs-scan-error__detail {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    color: rgb(255 255 255 / 0.5);
    word-break: break-all;
    line-height: 1.5;
}
