:root {
    --brand-950: #071d4d;
    --brand-900: #092b72;
    --brand-800: #0b3b9e;
    --brand-600: #1d5df5;
    --brand-500: #2868ff;
    --ink-950: #101828;
    --ink-700: #344054;
    --ink-500: #667085;
    --ink-400: #98a2b3;
    --line: #d9dee8;
    --line-soft: #e9edf3;
    --surface-muted: #f8fafc;
    --danger: #d92d20;
    --success: #087a55;
    --radius-control: 13px;
    --shadow-focus: 0 0 0 4px rgba(29, 93, 245, 0.12);
    --font-ui: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    min-width: 320px;
    color: var(--ink-950);
    background: #fff;
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button { border: 0; }

a {
    color: var(--brand-600);
    text-decoration: none;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(600px, 57%) minmax(460px, 43%);
    background: #fff;
}

.brand-pane {
    position: relative;
    min-height: 100vh;
    padding: clamp(34px, 4.2vw, 64px) clamp(38px, 5vw, 78px) 32px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    color: #173767;
    background:
        radial-gradient(circle at 84% 16%, rgba(255, 255, 255, 0.92), transparent 38%),
        linear-gradient(145deg, #f2f7ff 0%, #e8f1ff 56%, #dceaff 100%);
}

.brand-grid {
    position: absolute;
    inset: 18% -15% -22% 38%;
    opacity: 0.08;
    pointer-events: none;
    transform: perspective(700px) rotateY(-12deg) rotateX(60deg);
    transform-origin: center bottom;
    background-image:
        linear-gradient(rgba(147, 197, 253, 0.35) 1px, transparent 1px),
        linear-gradient(90deg, rgba(147, 197, 253, 0.35) 1px, transparent 1px);
    background-size: 54px 54px;
    mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 72%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 72%, transparent);
}

.brand-main,
.brand-copyright {
    position: relative;
    z-index: 1;
}

.brand-lockup,
.mobile-brand {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 13px;
    color: inherit;
}

.brand-lockup img {
    width: 48px;
    height: 48px;
    display: block;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(37, 86, 166, 0.18);
}

.brand-lockup span {
    font-size: 25px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.brand-copy { margin-top: clamp(54px, 8vh, 88px); }

.brand-copy h1 {
    max-width: 680px;
    margin: 0;
    color: #163869;
    font-size: clamp(36px, 3.25vw, 52px);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.035em;
}

.brand-copy p {
    margin: 20px 0 0;
    color: rgba(23, 55, 103, 0.68);
    font-size: clamp(15px, 1.25vw, 18px);
    line-height: 1.8;
}

.product-preview {
    position: relative;
    width: min(100%, 700px);
    margin-top: clamp(16px, 3vh, 28px);
    border: 0;
    background: transparent;
}

.product-preview img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.brand-copyright,
.auth-copyright {
    margin: 24px 0 0;
    color: rgba(23, 55, 103, 0.48);
    font-size: 12px;
    line-height: 1.5;
}

.auth-pane {
    position: relative;
    min-height: 100vh;
    padding: 40px clamp(36px, 5vw, 78px) 28px;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.mobile-brand { display: none; }

.auth-container {
    width: min(100%, 436px);
    margin: auto;
}

.auth-heading h2 {
    margin: 0;
    color: var(--ink-950);
    font-size: clamp(31px, 2.5vw, 38px);
    font-weight: 700;
    line-height: 1.24;
    letter-spacing: -0.035em;
}

.auth-heading p {
    margin: 13px 0 0;
    color: var(--ink-500);
    font-size: 14px;
    line-height: 1.7;
}

.login-tabs {
    margin-top: 44px;
    display: flex;
    align-items: center;
    gap: 46px;
    border-bottom: 1px solid var(--line-soft);
}

.login-tab {
    position: relative;
    padding: 0 0 13px;
    color: var(--ink-500);
    background: transparent;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;
    transition: color 0.18s ease;
}

.login-tab::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--brand-600);
    opacity: 0;
    transform: scaleX(0.6);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.login-tab:hover,
.login-tab:focus-visible,
.login-tab.is-active { color: var(--brand-600); }

.login-tab.is-active::after {
    opacity: 1;
    transform: scaleX(1);
}

.login-tab:focus-visible,
.password-toggle:focus-visible,
.code-button:focus-visible,
.submit-button:focus-visible,
.register-prompt button:focus-visible {
    outline: 3px solid rgba(29, 93, 245, 0.2);
    outline-offset: 3px;
}

.auth-message {
    min-height: 24px;
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--danger);
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.auth-message svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-message.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.auth-message.is-success { color: var(--success); }

.auth-form {
    display: grid;
    gap: 20px;
}

.field-group {
    display: grid;
    gap: 9px;
}

.field-group > label {
    color: var(--ink-700);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}

.field-control {
    position: relative;
    height: 52px;
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field-control:hover { border-color: #c5ccda; }

.field-control:focus-within {
    border-color: var(--brand-500);
    box-shadow: var(--shadow-focus);
}

.field-icon {
    position: absolute;
    left: 15px;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--ink-400);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.field-control input {
    width: 100%;
    height: 100%;
    padding: 0 46px;
    border: 0;
    outline: 0;
    color: var(--ink-950);
    background: transparent;
    font-size: 14px;
    line-height: 52px;
}

.field-control input::placeholder { color: var(--ink-400); }

.field-control input:-webkit-autofill,
.field-control input:-webkit-autofill:hover,
.field-control input:-webkit-autofill:focus,
.field-control input:-webkit-autofill:active {
    border-radius: inherit;
    -webkit-text-fill-color: var(--ink-950);
    caret-color: var(--ink-950);
    -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
    box-shadow: 0 0 0 1000px #fff inset !important;
    transition: background-color 9999s ease-out 0s;
}

.field-control input:autofill {
    color: var(--ink-950);
    background: #fff;
    border-radius: inherit;
}

.password-toggle {
    position: absolute;
    right: 8px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--ink-500);
    background: transparent;
    cursor: pointer;
}

.password-toggle:hover {
    color: var(--brand-600);
    background: var(--surface-muted);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.password-toggle .eye-closed,
.password-toggle[aria-pressed="true"] .eye-open { display: none; }

.password-toggle[aria-pressed="true"] .eye-closed { display: block; }

.form-meta {
    margin-top: -4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--ink-500);
    font-size: 13px;
}

.remember-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.remember-check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand-600);
}

.form-meta a:hover,
.form-meta a:focus-visible,
.agreement a:hover,
.agreement a:focus-visible,
.help-link:hover,
.help-link:focus-visible {
    color: var(--brand-800);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.submit-button {
    width: 100%;
    height: 52px;
    margin-top: 2px;
    border-radius: var(--radius-control);
    color: #fff;
    background: var(--brand-600);
    box-shadow: 0 10px 22px rgba(29, 93, 245, 0.18);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.submit-button:hover {
    background: #164fdd;
    box-shadow: 0 13px 26px rgba(29, 93, 245, 0.24);
    transform: translateY(-1px);
}

.submit-button:active { transform: translateY(0); }

.submit-button:disabled {
    cursor: wait;
    opacity: 0.7;
    transform: none;
}

.code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 124px;
    gap: 12px;
}

.code-button {
    height: 52px;
    border: 1px solid rgba(29, 93, 245, 0.28);
    border-radius: var(--radius-control);
    color: var(--brand-600);
    background: #f5f8ff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.code-button:hover {
    border-color: rgba(29, 93, 245, 0.5);
    background: #edf3ff;
}

.code-button:disabled {
    color: var(--ink-400);
    border-color: var(--line-soft);
    background: var(--surface-muted);
    cursor: not-allowed;
}

.register-prompt {
    margin: 22px 0 0;
    color: var(--ink-500);
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
}

.register-prompt button {
    padding: 0;
    color: var(--brand-600);
    background: transparent;
    font-weight: 600;
    cursor: pointer;
}

.register-view { margin-top: 32px; }
.register-view .auth-message { margin-top: 0; }
.register-form { gap: 16px; }

.auth-footer {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--line-soft);
    text-align: center;
}

.agreement {
    margin: 0;
    color: var(--ink-400);
    font-size: 11px;
    line-height: 1.8;
}

.help-link {
    width: fit-content;
    margin: 14px auto 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-500);
    background: transparent;
    font-size: 12px;
    line-height: 1.5;
    cursor: pointer;
    transition: color 0.18s ease;
}

.help-link span { color: var(--brand-600); }

.help-link:hover,
.help-link:focus-visible { color: var(--brand-600); }

.help-link:focus-visible {
    outline: 2px solid rgba(29, 93, 245, 0.32);
    outline-offset: 4px;
    border-radius: 4px;
}

.help-link svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-copyright {
    margin-top: 28px;
    color: var(--ink-400);
    text-align: center;
}

body.is-service-modal-open { overflow: hidden; }

.service-qr-modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    padding: 20px;
    display: grid;
    place-items: center;
    background: rgba(7, 29, 77, 0.34);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.service-qr-dialog {
    position: relative;
    width: min(100%, 340px);
    padding: 28px 28px 24px;
    border: 1px solid rgba(29, 93, 245, 0.12);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(7, 29, 77, 0.22);
    text-align: center;
    animation: service-qr-enter 0.2s ease-out;
}

.service-qr-dialog img {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 18px;
    border-radius: 12px;
}

.service-qr-title {
    margin: 0;
    color: var(--ink-950);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.5;
}

.service-qr-dialog p {
    margin: 14px 0 0;
    color: var(--ink-500);
    font-size: 13px;
    line-height: 1.6;
}

.service-qr-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--ink-500);
    background: var(--surface-muted);
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease;
}

.service-qr-close:hover,
.service-qr-close:focus-visible {
    color: var(--brand-600);
    background: #edf3ff;
}

.service-qr-close:focus-visible {
    outline: 2px solid rgba(29, 93, 245, 0.3);
    outline-offset: 2px;
}

.service-qr-close svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

@keyframes service-qr-enter {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

[hidden] { display: none !important; }

@media (max-width: 1120px) {
    .login-shell { grid-template-columns: 1fr; }
    .brand-pane { display: none; }

    .auth-pane { padding: 34px 24px 24px; }

    .mobile-brand {
        display: inline-flex;
        color: var(--brand-950);
    }

    .mobile-brand img {
        width: 42px;
        height: 42px;
        border-radius: 9px;
    }

    .mobile-brand span {
        font-size: 23px;
        font-weight: 700;
        letter-spacing: 0.03em;
    }

    .auth-container {
        margin-top: clamp(52px, 9vh, 86px);
        margin-bottom: 0;
    }

    .auth-copyright { display: none; }
}

@media (max-width: 600px) {
    .auth-pane { padding: 24px 20px 26px; }
    .mobile-brand img { width: 40px; height: 40px; }
    .mobile-brand span { font-size: 22px; }

    .auth-container {
        width: 100%;
        margin-top: 58px;
    }

    .auth-heading h2 { font-size: 32px; }
    .auth-heading p { margin-top: 10px; font-size: 13px; }

    .service-qr-dialog {
        width: min(100%, 320px);
        padding: 24px 24px 21px;
    }
    .login-tabs { margin-top: 38px; gap: 40px; }
    .auth-form { gap: 18px; }
    .auth-footer { margin-top: 30px; padding-top: 20px; }
}

@media (max-width: 380px) {
    .auth-pane { padding-right: 16px; padding-left: 16px; }
    .code-row { grid-template-columns: minmax(0, 1fr) 112px; gap: 10px; }
}

@media (max-height: 800px) and (min-width: 1121px) {
    .brand-pane {
        padding-top: 34px;
        padding-bottom: 24px;
    }

    .brand-copy {
        margin-top: 46px;
    }

    .brand-copy p {
        margin-top: 14px;
    }

    .product-preview {
        margin-top: 28px;
    }

    .brand-copyright,
    .auth-copyright {
        display: none;
    }

    .auth-pane {
        padding-top: 30px;
        padding-bottom: 22px;
    }

    .login-tabs {
        margin-top: 32px;
    }

    .auth-message {
        margin-top: 8px;
    }

    .auth-form {
        gap: 16px;
    }

    .auth-footer {
        margin-top: 24px;
        padding-top: 18px;
    }
}

@media (max-height: 760px) and (max-width: 1120px) {
    .auth-pane { padding-top: 18px; }
    .mobile-brand img { width: 34px; height: 34px; }
    .mobile-brand span { font-size: 20px; }
    .auth-container { margin-top: 30px; }
    .auth-heading h2 { font-size: 28px; }
    .auth-heading p { margin-top: 6px; }
    .login-tabs { margin-top: 24px; }
    .auth-message { margin-top: 8px; }
    .auth-form { gap: 13px; }
    .field-group { gap: 6px; }
    .field-control,
    .code-button,
    .submit-button { height: 48px; }
    .register-prompt { margin-top: 14px; }
    .auth-footer { margin-top: 18px; padding-top: 14px; }
    .help-link { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
