#scan-overlay {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    background: #0f172a;
    z-index: 1035;
    padding: 0;
    padding-bottom: 70px;
}
#scan-overlay.active {
    display: flex;
}
#scan-overlay .scan-top {
    padding: 16px 20px 8px;
    color: #fff;
    flex-shrink: 0;
}
#scan-overlay .scan-top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
#scan-overlay .scan-top-left {
    display: flex;
    align-items: center;
    gap: 6px;
}
#scan-overlay .scan-top-left h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}
#scan-overlay .scan-subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
}
#scan-overlay .scan-close {
    border: none;
    background: rgba(255,255,255,0.15);
    color: #dc2626;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
#scan-overlay .scan-close:hover {
    background: rgba(220,38,38,0.2);
}

/* ---- Body ---- */
#scan-overlay .scan-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    margin-top: 0;
    gap: 14px;
}
#scan-overlay .scan-body--hidden {
    display: none;
}

/* ---- Modo manual: ícone circular ---- */
.scan-icon-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(20, 184, 166, 0.15);
    border: 2px solid rgba(20, 184, 166, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.scan-icon-circle i {
    font-size: 2.4rem;
    color: #14b8a6;
}

/* ---- Modo manual: label ---- */
.scan-manual-label {
    margin: 0;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.8);
    text-align: center;
}

/* ---- Input do código ---- */
.scan-input-group {
    width: 100%;
    max-width: 340px;
}
.scan-qr-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.07);
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
    letter-spacing: 0.5px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}
.scan-qr-input::placeholder {
    color: rgba(255,255,255,0.35);
}
.scan-qr-input:focus {
    border-color: #14b8a6;
    background: rgba(20, 184, 166, 0.08);
}

/* ---- Botão primário (Buscar) ---- */
.scan-btn-primary {
    width: 100%;
    max-width: 340px;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    background: #14b8a6;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
}
.scan-btn-primary:hover:not(:disabled) {
    background: #0d9488;
}
.scan-btn-primary:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ---- Divisor ---- */
.scan-divider {
    width: 100%;
    max-width: 340px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.3);
    font-size: 0.8rem;
}
.scan-divider::before,
.scan-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.12);
}

/* ---- Botão secundário (Câmera) ---- */
.scan-btn-camera {
    width: 100%;
    max-width: 340px;
    padding: 14px 20px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    background: transparent;
    color: rgba(255,255,255,0.8);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}
.scan-btn-camera:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.25);
}

/* ---- Modo câmera: área de vídeo ---- */
#scan-overlay #scan-qr-view {
    width: min(100%, 360px);
    aspect-ratio: 1;
    max-height: 50vh;
    background: #000;
    border-radius: 18px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.12);
}
#scan-overlay .scan-status {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
    text-align: center;
    min-height: 1.2em;
}
#scan-overlay .scan-error {
    display: none;
    background: rgba(255, 71, 87, 0.2);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: #ff6b7a;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.85rem;
    text-align: center;
    width: min(100%, 360px);
}
#scan-overlay .scan-error p {
    color: #ff6b7a;
}
.scan-btn-retry,
.scan-btn-manual {
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}
.scan-btn-retry {
    background: #14b8a6;
    color: #fff;
}
.scan-btn-retry:hover {
    background: #0d9488;
}
.scan-btn-manual {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.85);
}
.scan-btn-manual:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ---- Botões do modo câmera ---- */
.scan-camera-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 360px;
}
.scan-btn-back {
    flex: 1;
    height: 44px;
    border: none;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    border-radius: 10px;
    padding: 0 14px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.scan-btn-back:hover {
    background: rgba(255,255,255,0.18);
}
.scan-switch-cam {
    flex: 1;
    height: 44px;
    border: none;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    border-radius: 10px;
    padding: 0 14px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.scan-switch-cam:hover {
    background: rgba(255,255,255,0.18);
}
.scan-switch-cam:disabled {
    opacity: 0.4;
    cursor: default;
}

@media (max-height: 640px) {
    #scan-overlay #scan-qr-view {
        max-height: 35vh;
    }
    .scan-icon-circle {
        width: 72px;
        height: 72px;
    }
    .scan-icon-circle i {
        font-size: 1.8rem;
    }
}

/* Scanner Laser Overlay */
.qr-scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.qr-scanner-box {
    width: 220px;
    height: 220px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    position: relative;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    margin: auto;
}

.qr-scanner-laser {
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #00ffaa, transparent);
    box-shadow: 0 0 12px #00ffaa, 0 0 4px #00ffaa;
    position: absolute;
    top: 0;
    animation: qrScanAnimation 2s infinite ease-in-out;
}

@keyframes qrScanAnimation {
    0% { top: 0%; }
    50% { top: 98%; }
    100% { top: 0%; }
}
