/* ==========================================================================
   Craft 登录页
   左：品牌区（深色，讲清产品定位）  右：登录卡（SSO 扫码为主）
   ========================================================================== */
:root {
    --a-bg: #f5f6fa;
    --a-surface: #ffffff;
    --a-text: #0f172a;
    --a-text-2: #5b6474;
    --a-text-3: #98a1b0;
    --a-border: #e6e8ef;
    --a-accent: #2563eb;
    --a-accent-hover: #1d4ed8;
    --a-accent-soft: rgba(37, 99, 235, .1);
    --a-success: #16a34a;
    --a-danger: #dc2626;
    --a-brand-bg: #0b1220;
    --a-radius: 20px;
    --a-radius-sm: 12px;
    --a-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --a-ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body.auth {
    margin: 0;
    font-family: var(--a-font);
    color: var(--a-text);
    background: var(--a-bg);
    -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
a { color: var(--a-accent); text-decoration: none; }

.auth-shell {
    display: grid;
    grid-template-columns: minmax(380px, 44%) minmax(0, 1fr);
    min-height: 100vh;
}

/* ---------- 品牌区 ---------- */
.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 48px;
    color: #e2e8f0;
    background:
        radial-gradient(600px 400px at 15% 10%, rgba(59, 130, 246, .28), transparent 60%),
        radial-gradient(500px 420px at 90% 85%, rgba(139, 92, 246, .22), transparent 60%),
        var(--a-brand-bg);
    overflow: hidden;
}
.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, .07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, .07) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(ellipse at 40% 40%, #000 30%, transparent 75%);
    mask-image: radial-gradient(ellipse at 40% 40%, #000 30%, transparent 75%);
    pointer-events: none;
}
.auth-brand > * { position: relative; }
.auth-brand-top { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.auth-logo { width: 36px; height: 36px; border-radius: 10px; }
.auth-brand-main h2 {
    margin: 0 0 36px;
    font-size: clamp(30px, 3.2vw, 42px);
    line-height: 1.22;
    font-weight: 750;
    letter-spacing: -.03em;
    color: #fff;
}
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; max-width: 420px; }
.auth-points li { display: flex; gap: 14px; align-items: flex-start; }
.auth-points i {
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: rgba(148, 163, 184, .12);
    border: 1px solid rgba(148, 163, 184, .16);
    color: #93c5fd;
    font-size: 15px;
}
.auth-points strong { display: block; color: #f8fafc; font-size: 15px; font-weight: 650; margin-bottom: 3px; }
.auth-points span { color: #94a3b8; font-size: 13.5px; line-height: 1.5; }
.auth-brand-foot { color: #64748b; font-size: 12.5px; }

/* ---------- 登录卡 ---------- */
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}
.auth-card {
    width: 100%;
    min-width: 0;
    max-width: 400px;
    animation: auth-in .45s var(--a-ease) both;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.auth-card-head { text-align: center; margin-bottom: 24px; }
.auth-card-head h1 { margin: 0 0 6px; font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.auth-card-head p { margin: 0; color: var(--a-text-2); font-size: 14px; }
.auth-logo-mobile { display: none; width: 52px; height: 52px; border-radius: 14px; margin-bottom: 14px; box-shadow: 0 8px 24px rgba(37, 99, 235, .25); }

.auth-alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 14px;
    margin-bottom: 16px;
    border-radius: var(--a-radius-sm);
    background: rgba(220, 38, 38, .08);
    color: #b91c1c;
    font-size: 13.5px;
    line-height: 1.5;
}
.auth-alert i { margin-top: 2px; }

/* SSO 扫码 */
.auth-sso,
.auth-unbound {
    background: var(--a-surface);
    border: 1px solid var(--a-border);
    border-radius: var(--a-radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px rgba(15, 23, 42, .06);
    padding: 26px 24px 20px;
    text-align: center;
}
.auth-qr {
    position: relative;
    width: 196px;
    height: 196px;
    margin: 0 auto 14px;
    padding: 12px;
    border-radius: 16px;
    background: #fff;
}
.auth-qr img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: none;
    border-radius: 8px;
}
.auth-qr-placeholder {
    position: absolute;
    inset: 12px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(110deg, #f1f3f8 30%, #e7eaf2 50%, #f1f3f8 70%);
    background-size: 200% 100%;
    animation: auth-shimmer 1.4s linear infinite;
    color: #c4cad6;
    font-size: 40px;
}
@keyframes auth-shimmer { to { background-position: -200% 0; } }
.auth-qr-corner { position: absolute; width: 22px; height: 22px; border: 3px solid var(--a-accent); z-index: 2; }
.auth-qr-corner.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.auth-qr-corner.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.auth-qr-corner.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.auth-qr-corner.br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.auth-qr-status { margin: 0 0 4px; font-size: 14.5px; font-weight: 600; color: var(--a-text); }
.auth-qr-error { margin: 0 0 4px; font-size: 13px; color: var(--a-danger); }
.auth-qr-actions { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; }
.auth-dot { color: var(--a-text-3); }
.auth-link-btn {
    border: 0;
    background: none;
    padding: 0;
    color: var(--a-accent);
    font-size: 13px;
    font-weight: 550;
}
.auth-link-btn:hover { color: var(--a-accent-hover); text-decoration: underline; }

/* 未绑定状态卡 */
.auth-unbound { text-align: left; animation: auth-in .35s var(--a-ease) both; }
.auth-unbound-id {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 14px;
    border-radius: var(--a-radius-sm);
    background: var(--a-bg);
}
.auth-unbound-avatar {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 17px;
}
.auth-unbound-name { font-weight: 650; font-size: 15px; }
.auth-unbound-id > div:nth-child(2) { min-width: 0; }
.auth-unbound-email { color: var(--a-text-3); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-card.is-unbound .auth-divider,
.auth-card.is-unbound .auth-alt { display: none; }
.auth-badge {
    margin-left: auto;
    flex: none;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(22, 163, 74, .1);
    color: var(--a-success);
    font-size: 12px;
    font-weight: 600;
}
.auth-unbound-msg { margin: 0 0 16px; color: var(--a-text-2); font-size: 14px; line-height: 1.65; }
.auth-unbound .auth-btn + .auth-btn { margin-top: 10px; }
.auth-unbound-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--a-border);
    color: var(--a-text-3);
    font-size: 12.5px;
}

/* 按钮 */
.auth-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 46px;
    border-radius: var(--a-radius-sm);
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 600;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.auth-btn:active { transform: translateY(1px); }
.auth-btn:disabled { opacity: .55; cursor: not-allowed; }
.auth-btn-primary { background: var(--a-accent); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .24); }
.auth-btn-primary:hover:not(:disabled) { background: var(--a-accent-hover); }
.auth-btn-secondary { background: var(--a-surface); color: var(--a-text); border-color: var(--a-border); }
.auth-btn-secondary:hover:not(:disabled) { background: var(--a-bg); }
.auth-btn.is-loading,
.auth-alt-btn.is-loading { color: transparent !important; pointer-events: none; }
.auth-btn.is-loading::after,
.auth-alt-btn.is-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin .7s linear infinite;
}
.auth-btn-secondary.is-loading::after,
.auth-alt-btn.is-loading::after { border-color: rgba(15, 23, 42, .15); border-top-color: var(--a-accent); }
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* 其他登录方式 */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 14px;
    color: var(--a-text-3);
    font-size: 12.5px;
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--a-border); }
.auth-alt { display: flex; gap: 10px; }
.auth-alt-btn {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    border-radius: var(--a-radius-sm);
    border: 1px solid var(--a-border);
    background: var(--a-surface);
    color: var(--a-text);
    font-size: 14px;
    font-weight: 550;
    transition: border-color .15s, background .15s, color .15s;
}
.auth-alt-btn i { color: var(--a-text-2); }
.auth-alt-btn:hover { border-color: #cfd4e0; background: #fafbfd; }
.auth-alt-btn.is-active { border-color: var(--a-accent); color: var(--a-accent); background: var(--a-accent-soft); }
.auth-alt-btn.is-active i { color: var(--a-accent); }

/* 账号密码 */
.auth-password { margin-top: 16px; animation: auth-in .3s var(--a-ease) both; }
.auth-bind-hint {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: var(--a-radius-sm);
    background: var(--a-accent-soft);
    color: #1e40af;
    font-size: 13px;
}
.auth-field { display: block; margin-bottom: 14px; }
.auth-field > span {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--a-text);
}
.auth-field-link { font-weight: 500; font-size: 12.5px; }
.auth-input {
    position: relative;
    display: flex;
    align-items: center;
    height: 46px;
    border-radius: var(--a-radius-sm);
    border: 1px solid var(--a-border);
    background: var(--a-surface);
    transition: border-color .15s, box-shadow .15s;
}
.auth-input:focus-within { border-color: var(--a-accent); box-shadow: 0 0 0 4px var(--a-accent-soft); }
.auth-input > i { width: 42px; text-align: center; color: var(--a-text-3); font-size: 14px; }
.auth-input input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: var(--a-text);
    padding-right: 12px;
}
.auth-input input::placeholder { color: var(--a-text-3); }
.auth-eye { border: 0; background: none; width: 42px; height: 100%; color: var(--a-text-3); }
.auth-eye:hover { color: var(--a-text-2); }
.auth-password .auth-btn { margin-top: 6px; }

.auth-secure { margin: 22px 0 0; text-align: center; color: var(--a-text-3); font-size: 12.5px; }
.auth-secure i { color: var(--a-success); margin-right: 4px; }

/* 验证码弹窗 */
.auth-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.auth-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.auth-modal-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    padding: 26px 24px 22px;
    border-radius: var(--a-radius);
    background: var(--a-surface);
    box-shadow: 0 30px 80px rgba(15, 23, 42, .25);
    text-align: center;
    animation: auth-in .25s var(--a-ease) both;
}
.auth-modal-card h3 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.auth-modal-card > p { margin: 0 0 18px; color: var(--a-text-2); font-size: 13.5px; }
#turnstile-modal { display: flex; justify-content: center; min-height: 65px; }
.auth-captcha-row { display: flex; gap: 10px; align-items: center; justify-content: center; margin-bottom: 12px; }
.auth-captcha-row img { height: 52px; min-width: 150px; border-radius: 10px; border: 1px solid var(--a-border); background: var(--a-bg); }
.auth-icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--a-border); background: var(--a-surface); color: var(--a-text-2); }
#customCaptchaInput {
    width: 100%;
    height: 46px;
    border-radius: var(--a-radius-sm);
    border: 1px solid var(--a-border);
    text-align: center;
    font-size: 18px;
    letter-spacing: .3em;
    font-weight: 600;
    outline: 0;
}
#customCaptchaInput:focus { border-color: var(--a-accent); box-shadow: 0 0 0 4px var(--a-accent-soft); }
.auth-captcha-tip { margin-top: 8px; font-size: 12.5px; color: var(--a-text-3); }
.auth-captcha-tip.is-error { color: var(--a-danger); }
.auth-modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.auth-modal-actions .auth-btn { height: 42px; font-size: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    .auth-brand { display: none; }
    .auth-logo-mobile { display: inline-block; }
    .auth-panel { align-items: flex-start; padding: 48px 20px 32px; }
}
@media (max-width: 420px) {
    .auth-sso, .auth-unbound { padding: 22px 18px 18px; }
    .auth-qr { width: 180px; height: 180px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 多账号选择卡（登录页） */
.auth-choose-head { text-align: center; margin-bottom: 16px; }
.auth-choose-head .auth-badge { margin: 0 auto 10px; display: inline-flex; gap: 4px; align-items: center; }
.auth-choose-head h2 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.auth-choose-head p { margin: 0; color: var(--a-text-2); font-size: 13.5px; }
.auth-choose-list { display: grid; gap: 10px; }
.auth-choose-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--a-radius-sm);
    border: 1px solid var(--a-border);
    background: var(--a-surface);
    text-align: left;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.auth-choose-item:hover:not(:disabled) { border-color: var(--a-accent); box-shadow: 0 0 0 4px var(--a-accent-soft); }
.auth-choose-item:disabled { opacity: .55; cursor: default; }
.auth-choose-item.is-loading { opacity: 1; border-color: var(--a-accent); }
.auth-choose-item.is-loading .fa-chevron-right { animation: auth-spin .8s linear infinite; }
.auth-choose-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.auth-choose-info strong { font-size: 15px; font-weight: 650; color: var(--a-text); }
.auth-choose-info small { font-size: 12.5px; color: var(--a-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-choose-role { flex: none; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--a-bg); color: var(--a-text-2); }
.auth-choose-role.is-admin { background: rgba(79, 70, 229, .1); color: #4338ca; }
.auth-choose-role.is-developer { background: rgba(22, 163, 74, .1); color: #15803d; }
.auth-choose-role.is-client { background: rgba(37, 99, 235, .1); color: #1d4ed8; }
.auth-choose-item .fa-chevron-right { color: var(--a-text-3); font-size: 12px; }

/* 通用账号选择器（未接管的页面，如邀请页） */
.sso-account-chooser { display: grid; gap: 8px; margin: 4px 0 8px; text-align: left; }
.sso-chooser-title { font-weight: 650; font-size: 14px; text-align: center; margin-bottom: 4px; }
.sso-chooser-btn {
    display: flex; flex-direction: column; gap: 2px; width: 100%;
    padding: 10px 14px; border-radius: var(--a-radius-sm); border: 1px solid var(--a-border);
    background: var(--a-surface); text-align: left; cursor: pointer;
}
.sso-chooser-btn:hover { border-color: var(--a-accent); box-shadow: 0 0 0 4px var(--a-accent-soft); }
.sso-chooser-name { font-weight: 650; font-size: 14.5px; color: var(--a-text); }
.sso-chooser-meta { font-size: 12.5px; color: var(--a-text-3); }
