/* =============================================================
   RealTime 统一身份认证 · SSO 登录页
   书签式 Tab + 中央卡片，复刻 design_handoff_sso_login
   ============================================================= */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --ink: #14161a;
    --ink-2: #3b4048;
    --ink-3: #6b7280;
    --ink-4: #9aa1ab;
    --line: #e6e8ec;
    --line-2: #eef0f3;
    --accent: oklch(0.56 0.16 250);
    --accent-soft: oklch(0.96 0.03 250);
    --accent-ink: oklch(0.42 0.16 250);
    --danger: oklch(0.58 0.18 22);
    --ok: oklch(0.62 0.14 155);
    --radius: 16px;
    --shadow: 0 1px 0 rgba(20, 22, 26, .04), 0 24px 60px -20px rgba(20, 22, 26, .22);
    --tab-w: 132px;
    --tab-h: 92px;

    /* 公司主色 */
    --co-a: oklch(0.62 0.16 235);
    --co-a-accent: oklch(0.55 0.16 235);
    --co-b: oklch(0.58 0.16 155);
    --co-b-accent: oklch(0.5 0.16 155);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC",
                 "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- backdrop ---------- */
.stage {
    min-height: 100vh;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    overflow: hidden;
}
.stage::before {
    content: "";
    position: absolute; inset: 0;
    background:
        radial-gradient(900px 600px at 18% 12%, oklch(0.94 0.04 250) 0%, transparent 60%),
        radial-gradient(900px 700px at 86% 88%, oklch(0.95 0.03 220) 0%, transparent 60%),
        linear-gradient(180deg, #eef1f6 0%, #e7ebf2 100%);
    pointer-events: none;
}
.stage::after {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(to right, rgba(20, 22, 26, .045) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(20, 22, 26, .045) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(60% 60% at 50% 50%, #000 30%, transparent 80%);
    mask-image: radial-gradient(60% 60% at 50% 50%, #000 30%, transparent 80%);
    pointer-events: none;
}

/* ---------- top bar ---------- */
.topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: 22px 28px;
    display: flex; align-items: center; justify-content: space-between;
    z-index: 5;
    color: var(--ink-3);
    font-size: 12px;
}
.topbar .left { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: var(--ink);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 12px;
}
.brand-name { color: var(--ink); font-weight: 600; letter-spacing: -.01em; font-size: 14px; }
.brand-name small { color: var(--ink-3); font-weight: 400; margin-left: 8px; font-size: 12px; }
.topbar .right { display: inline-flex; align-items: center; gap: 16px; white-space: nowrap; }
.env-pill {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-radius: 99px;
    padding: 5px 12px;
    color: var(--ink-2);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.env-pill:hover { color: var(--ink); background: rgba(255, 255, 255, .9); }
.dot {
    width: 7px; height: 7px; border-radius: 99px; background: var(--ok);
    box-shadow: 0 0 0 3px oklch(0.62 0.14 155 / .16);
}
.lang { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); }
.lang-en { opacity: .55; }

/* ---------- center frame ---------- */
.frame {
    position: relative;
    display: flex;
    align-items: stretch;
    z-index: 2;
}

/* bookmarks column */
.bookmarks {
    position: relative;
    width: var(--tab-w);
    display: flex; flex-direction: column;
    gap: 10px;
    padding-top: 36px;
    margin-right: -1px;
}
.bm {
    appearance: none; border: 0; background: none; padding: 0;
    cursor: pointer; font: inherit;
    width: var(--tab-w);
    height: var(--tab-h);
    position: relative;
    text-align: left;
    color: var(--ink-2);
    transition: transform .18s ease;
    outline: none;
}
.bm-shape {
    position: absolute; inset: 0;
    background: oklch(0.97 0.005 250);
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 14px 0 0 14px;
    box-shadow: -8px 6px 20px -10px rgba(20, 22, 26, .08);
    transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.bm:hover .bm-shape { transform: translateX(-4px); background: #fff; }
.bm.active .bm-shape {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: -16px 10px 30px -14px rgba(20, 22, 26, .18);
    transform: translateX(-8px);
}
.bm.active .bm-shape::after {
    content: "";
    position: absolute;
    top: 1px; bottom: 1px; right: -2px;
    width: 4px;
    background: var(--surface);
}
.bm-content {
    position: relative;
    padding: 14px 16px 14px 18px;
    display: flex; flex-direction: row; align-items: center; gap: 10px;
    height: 100%;
    transition: transform .18s ease;
}
.bm:hover .bm-content { transform: translateX(-4px); }
.bm.active .bm-content { transform: translateX(-8px); }

.bm-icon {
    width: 26px; height: 26px;
    border-radius: 7px;
    display: grid; place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .02em;
    flex-shrink: 0;
}
.bm-content > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bm-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    line-height: 1.25;
    white-space: nowrap;
}
.bm.active .bm-label { color: var(--ink); font-weight: 600; }
.bm-sub {
    font-size: 11.5px;
    color: var(--ink-4);
    letter-spacing: 0;
    white-space: nowrap;
}

/* ---------- card ---------- */
.card {
    width: 460px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* ---------- panel & pane animation ---------- */
.panel { padding: 28px 32px; }
.pane { animation: fadeUp .26s ease both; }
.pane[hidden] { display: none; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* ---------- form bits ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
    font-size: 12px; color: var(--ink-3);
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px;
}
.field label .lbl { display: inline-flex; align-items: center; white-space: nowrap; }
.field label .req { color: var(--danger); margin-left: 2px; }

.input-wrap {
    position: relative;
    display: flex; align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 12px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input-wrap:hover { border-color: #d6d9df; }
.input-wrap:focus-within {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 4px oklch(0.56 0.16 250 / .12);
}
.input-wrap.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px oklch(0.58 0.18 22 / .10);
}
.input-wrap .icon { color: var(--ink-4); display: grid; place-items: center; }
.input-wrap input {
    appearance: none; border: 0; outline: 0; background: transparent;
    font: inherit; color: var(--ink);
    padding: 12px 10px;
    width: 100%;
}
.input-wrap input::placeholder { color: var(--ink-4); }

.ghost-btn {
    appearance: none; border: 0; background: transparent;
    color: var(--ink-3); cursor: pointer; padding: 4px 6px; border-radius: 6px;
    font-size: 12px;
    display: inline-flex; align-items: center; gap: 4px;
}
.ghost-btn:hover { color: var(--ink); background: var(--line-2); }

.err-msg {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: flex; align-items: center; gap: 6px;
    min-height: 16px;
}
.err-msg.warn { color: var(--ink-3); }
.err-msg svg { flex-shrink: 0; }

.row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    margin: 2px 0 18px;
    flex-wrap: wrap;
}
.check {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
    color: var(--ink-2); font-size: 13px;
    white-space: nowrap;
}
.check input { display: none; }
.check .box {
    width: 16px; height: 16px; border-radius: 4px;
    border: 1.5px solid #c5c9d0;
    display: grid; place-items: center;
    transition: all .15s ease;
}
.check input:checked + .box { background: var(--ink); border-color: var(--ink); }
.check input:checked + .box svg { opacity: 1; transform: scale(1); }
.check .box svg { opacity: 0; transform: scale(.6); transition: all .15s ease; color: #fff; }

.link {
    color: var(--ink-2); font-size: 13px; text-decoration: none;
    border-bottom: 1px dashed transparent;
    white-space: nowrap;
}
.link:hover { color: var(--ink); border-bottom-color: var(--ink-3); }

/* label-level link (small) */
.field label .link { font-size: 12px; color: var(--ink-3); }
.field label .link:hover { color: var(--ink); }

.btn-primary {
    width: 100%;
    appearance: none; border: 0;
    background: var(--ink);
    color: #fff;
    padding: 13px 16px;
    border-radius: 10px;
    font: inherit; font-weight: 500; font-size: 14px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: transform .08s ease, background .15s ease, box-shadow .15s ease, opacity .15s;
    box-shadow: 0 6px 18px -8px rgba(20, 22, 26, .45);
}
.btn-primary:hover { background: #000; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: #c6cad1; box-shadow: none; cursor: not-allowed; }
.btn-primary .spinner {
    width: 14px; height: 14px; border-radius: 99px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
    width: 100%;
    appearance: none;
    background: var(--surface-2);
    color: var(--ink);
    padding: 11px 14px;
    border-radius: 10px;
    font: inherit; font-weight: 500; font-size: 13px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--line);
    transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: #fff; border-color: #d6d9df; }

/* ---------- SSO mode switcher ---------- */
.sso-mode {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    padding: 4px; background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 16px;
}
.sso-mode button {
    appearance: none; border: 0; background: transparent;
    padding: 9px 10px;
    font: inherit; font-size: 13px; font-weight: 500; color: var(--ink-3);
    cursor: pointer; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    transition: all .15s ease;
}
.sso-mode button.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(20, 22, 26, .05), 0 0 0 1px var(--line);
}
.sso-mode button:hover:not(.active) { color: var(--ink); }

/* ---------- App-launch view ---------- */
.launch-wrap {
    display: flex; flex-direction: column; align-items: stretch; gap: 14px;
    padding: 6px 0 2px;
}
.launch-hero {
    position: relative;
    width: 100%;
    padding: 22px 18px;
    border: 1px dashed var(--line);
    border-radius: 14px;
    background:
        radial-gradient(120px 80px at 30% 20%, oklch(0.95 0.04 250 / .6), transparent 60%),
        var(--surface-2);
    display: flex; align-items: center; gap: 16px;
}
.launch-glyph {
    width: 64px; height: 64px;
    border-radius: 16px;
    display: grid; place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 10px 24px -8px rgba(20, 22, 26, .25);
    position: relative;
}
.launch-glyph::after {
    content: "";
    position: absolute; inset: 0;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .18), transparent 50%);
    pointer-events: none;
}
.launch-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.launch-text h4 { margin: 0; font-size: 14px; font-weight: 600; }
.launch-text p { margin: 0; font-size: 12px; color: var(--ink-3); line-height: 1.5; }

.launch-state {
    display: flex; align-items: center; gap: 8px;
    color: var(--ink-3);
    font-size: 12px;
    min-height: 18px;
}
.launch-state.ok { color: var(--ok); }
.launch-state.warn { color: var(--danger); }
.launch-state .mini-spin {
    width: 12px; height: 12px; border-radius: 99px;
    border: 2px solid var(--line); border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
.launch-state .lstate-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--ink-4); }
.launch-state.ok .lstate-dot { background: var(--ok); }

/* steps */
.steps {
    display: flex; align-items: center; gap: 10px;
    color: var(--ink-3); font-size: 11px;
    flex-wrap: nowrap;
}
.steps .step { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.steps .num {
    width: 18px; height: 18px; border-radius: 99px;
    background: var(--line-2); color: var(--ink-2);
    display: grid; place-items: center;
    font-family: "IBM Plex Mono", monospace; font-size: 10px;
}
.steps .arr { color: var(--ink-4); }

/* ---------- QR ---------- */
.qr-wrap {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    padding: 8px 0 4px;
}
/* 钉钉 oauth2/auth?embedMode=qrcode 渲染的是「logo + 标题 + QR + 底部提示」整页，
   高度大概 600+px。我们把外层视口约束到 360px 高，让 QR 居中显示；用户想看 logo
   或者底部说明都能在窗口里上下拖。 */
.dt-qr-host {
    width: 300px;
    height: 360px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .02), 0 6px 16px rgba(15, 23, 42, .04);
    scrollbar-width: thin;            /* Firefox */
    scrollbar-color: rgba(15, 23, 42, .2) transparent;
    line-height: 0;
    -webkit-overflow-scrolling: touch;/* iOS 顺滑滚动 */
}
.dt-qr-host::-webkit-scrollbar { width: 6px; }
.dt-qr-host::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, .18);
    border-radius: 3px;
}
.dt-qr-host::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, .32); }
.dt-qr-host::-webkit-scrollbar-track { background: transparent; }
.dt-qr-host iframe {
    width: 100%;
    /* 钉钉页面完整高度约 640px：logo(~80) + 标题(~120) + 间距(~20) + QR(240) + 间距 + 底部说明
       给 640px 让全部内容渲染出来，用户拖到任何位置都能看 */
    height: 640px;
    border: 0;
    display: block;
}

.qr-meta {
    display: flex; align-items: center; gap: 8px;
    color: var(--ink-3); font-size: 12px;
}
.qr-meta .pulse {
    width: 6px; height: 6px; border-radius: 99px; background: var(--ok);
    box-shadow: 0 0 0 0 oklch(0.62 0.14 155 / .6);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    70%  { box-shadow: 0 0 0 8px oklch(0.62 0.14 155 / 0); }
    100% { box-shadow: 0 0 0 0  oklch(0.62 0.14 155 / 0); }
}

/* ---------- toast ---------- */
.toast-wrap {
    position: fixed; top: 22px; left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--ink);
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
    display: inline-flex; align-items: center; gap: 10px;
    animation: toastIn .25s ease both;
}
.toast.danger { background: var(--danger); }
.toast.danger .tdot { background: rgba(255, 255, 255, .6); }
.tdot { width: 8px; height: 8px; border-radius: 99px; background: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- footer bar ---------- */
.pagebar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 18px 28px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    color: var(--ink-4);
    font-size: 11px;
    letter-spacing: .04em;
    z-index: 3;
    white-space: nowrap;
}
.pagebar a { color: var(--ink-3); text-decoration: none; }
.pagebar a:hover { color: var(--ink); }

/* ---------- hidden helper ---------- */
[hidden] { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    .topbar { padding: 16px 18px; }
    .topbar .right .lang { display: none; }
    .pagebar { padding: 14px 18px; font-size: 10px; }
    .frame { flex-direction: column; align-items: stretch; }
    .bookmarks {
        flex-direction: row;
        width: auto;
        padding: 0;
        gap: 8px;
        margin: 0 0 -1px 0;
        justify-content: center;
    }
    .bm { width: auto; height: auto; flex: 1; }
    .bm-shape {
        border-radius: 14px 14px 0 0;
        border-right: 1px solid var(--line);
        border-bottom: 0;
    }
    .bm.active .bm-shape::after {
        right: 0; left: 0; bottom: -1px; top: auto;
        height: 2px; width: auto;
    }
    .bm-content { padding: 12px 10px; }
    .bm-sub { display: none; }
    .card { width: 100%; max-width: 460px; }
    .panel { padding: 22px 22px; }
}

/* ─── 修改密码 / 首登强制改密 弹层 ─────────────────────── */
.cp-mask{position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;
    background:rgba(15,18,24,.55);backdrop-filter:blur(3px);padding:20px}
.cp-mask[hidden]{display:none}
.cp-dialog{width:min(420px,94vw);max-height:92vh;overflow:auto;background:#fff;border-radius:14px;
    padding:26px 26px 20px;box-shadow:0 24px 60px rgba(0,0,0,.28);
    border:1px solid rgba(0,0,0,.06);animation:cpIn .18s ease}
@keyframes cpIn{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:none}}
.cp-title{margin:0 0 4px;font-size:18px;font-weight:600;color:var(--ink,#1a2230)}
.cp-tip{margin:0 0 16px;font-size:12.5px;color:#6b7280;line-height:1.5}
.cp-actions{display:flex;gap:12px;margin-top:18px}
.cp-actions .btn-primary{flex:1}
.cp-cancel{flex:0 0 auto;padding:0 18px;height:44px;border-radius:10px;border:1px solid #d7dbe2;
    background:#fff;color:#4b5563;font-size:14px;cursor:pointer}
.cp-cancel:hover{background:#f5f6f8}
.cp-cancel[hidden]{display:none}
