.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background-color: var(--primary-deep);
    background-image: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.02) 0px,
        rgba(255, 255, 255, 0.02) 1px,
        transparent 1px,
        transparent 3px
    );
}
.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.login-bg span {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
}
.login-bg span:nth-child(1) {
    width: 420px;
    height: 420px;
    background: var(--accent);
    opacity: 0.28;
    top: -120px;
    left: -100px;
}
.login-bg span:nth-child(2) {
    width: 380px;
    height: 380px;
    background: var(--primary);
    opacity: 0.5;
    bottom: -140px;
    right: -80px;
}
.login-bg span:nth-child(3) {
    width: 260px;
    height: 260px;
    background: var(--accent-deep);
    opacity: 0.2;
    bottom: 10%;
    left: 12%;
}

.paper-card.login-card {
    max-width: 880px;
    position: relative;
    z-index: 1;
}
.login-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
}
.login-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.login-welcome {
    border-bottom: 1px dashed var(--line);
    padding-bottom: 14px;
}
.login-welcome h2 {
    font-family: var(--font-editorial);
    font-weight: 700;
    font-size: 26px;
    letter-spacing: -0.005em;
    color: var(--heading);
}
.login-welcome p {
    font-size: 13.5px;
    color: var(--ink-soft);
    margin-top: 4px;
}

.lf-field {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--line);
    transition: border-color var(--dur-fast) var(--ease);
}
.lf-field:focus-within {
    border-color: var(--accent);
}
.lf-field > i {
    color: var(--ink-soft);
    font-size: 15px;
    flex-shrink: 0;
}
#loginForm .lf-field input {
    flex: 1;
    width: auto;
    min-width: 0;
    border: none;
    padding: 10px 2px;
}
#loginForm .lf-field input:focus {
    border: none;
}
#loginForm .lf-field input::placeholder {
    color: var(--ink-soft);
    opacity: 0.55;
    font-style: italic;
}
.lf-eye {
    background: none;
    border: none;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 6px;
    font-size: 15px;
    flex-shrink: 0;
}
.lf-eye:hover {
    color: var(--ink);
}
.lf-caps {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--warn-fg);
}

.qr-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 34px 28px;
    border-left: 4px double var(--line);
    background: color-mix(in srgb, var(--ink) 3%, var(--surface));
    min-width: 0;
}
.qr-or {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translate(-50%, -50%);
}
.qr-or span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.qr-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.qr-head i {
    font-size: 30px;
    color: var(--accent-fg);
}
.qr-head h3 {
    font-family: var(--font-editorial);
    font-weight: 800;
    font-size: 20px;
    line-height: 1.2;
    color: var(--ink);
}
.qr-sub {
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-soft);
    margin-top: 10px;
}
.qr-box {
    position: relative;
    width: 196px;
    height: 196px;
    margin: 16px 0 12px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
}
.qr-img {
    position: absolute;
    inset: 10px;
}
.qr-img svg {
    width: 100%;
    height: 100%;
    display: block;
}
.qr-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.94);
    color: #16181c;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur-fast) var(--ease);
}
.qr-box[data-state="loading"] .qr-overlay,
.qr-box[data-state="expired"] .qr-overlay,
.qr-box[data-state="error"] .qr-overlay,
.qr-box[data-state="done"] .qr-overlay {
    opacity: 1;
    visibility: visible;
}
.qr-overlay-text {
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
}
.qr-spin {
    display: none;
    width: 26px;
    height: 26px;
    border: 3px solid #d8d5cc;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: qr-spin 0.8s linear infinite;
}
.qr-box[data-state="loading"] .qr-spin {
    display: block;
}
.qr-refresh {
    display: none;
    align-items: center;
    gap: 6px;
    border: none;
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-head);
    font-size: 12.5px;
    letter-spacing: 0.04em;
    cursor: pointer;
}
.qr-refresh:hover {
    background: var(--accent-deep);
}
.qr-box[data-state="expired"] .qr-refresh,
.qr-box[data-state="error"] .qr-refresh {
    display: inline-flex;
}
.qr-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 18px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.qr-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warn);
}
.qr-status.is-ok::before {
    background: var(--good);
}
.qr-steps {
    list-style: none;
    counter-reset: qrstep;
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: 100%;
    text-align: left;
    font-size: 12.5px;
    color: var(--ink-soft);
}
.qr-steps li {
    counter-increment: qrstep;
    display: flex;
    align-items: center;
    gap: 10px;
}
.qr-steps li::before {
    content: counter(qrstep);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--ink);
}
.qr-steps strong {
    color: var(--ink);
}

.login-card.no-qr {
    max-width: 460px;
}
.login-card.no-qr .login-grid {
    grid-template-columns: 1fr;
}
.login-card.no-qr .qr-panel {
    display: none;
}

.qr-approve {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}
.qr-approve > i {
    font-size: 40px;
    color: var(--good-fg);
}
.qr-approve p {
    font-size: 14.5px;
    line-height: 1.5;
}
.qr-device {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-alt);
    border: 1px dashed var(--line);
    font-family: var(--font-mono);
    font-size: 11.5px;
    word-break: break-word;
}

.qr-scan {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.qr-scan-view {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 60vh;
    background: #0b0d11;
    border-radius: 8px;
    overflow: hidden;
}
.qr-scan-view video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.qr-scan-frame {
    position: absolute;
    inset: 16%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 10px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
.qr-scan-frame::after {
    content: "";
    position: absolute;
    left: 6%;
    right: 6%;
    top: 6%;
    height: 2px;
    background: var(--accent);
    animation: qr-sweep 2s ease-in-out infinite alternate;
}
.qr-scan-hint {
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-soft);
    text-align: center;
}
.qr-scan-error {
    min-height: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-fg);
    text-align: center;
}
@keyframes qr-spin {
    to {
        transform: rotate(360deg);
    }
}
@keyframes qr-sweep {
    from {
        top: 6%;
    }
    to {
        top: 92%;
    }
}

@media (max-width: 760px) {
    .paper-card.login-card {
        max-width: 460px;
    }
    .login-grid {
        grid-template-columns: 1fr;
    }
    .qr-panel {
        display: none;
    }
    .paper-title {
        font-size: 36px;
    }
}