:root {
    color-scheme: dark;
    --bg: #090a10;
    --surface: #11121c;
    --surface-strong: #151624;
    --surface-soft: #0d0e16;
    --ink: #f2f1f8;
    --muted: #aaa8b8;
    --faint: #82808f;
    --line: #2a2938;
    --line-strong: #45415b;
    --accent: #a98cff;
    --accent-strong: #bea9ff;
    --cyan: #70dcea;
    --danger: #ff7b9e;
    --warning: #f3c775;
    --success: #79ddb6;
    --radius-surface: 8px;
    --radius-control: 6px;
    --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-width: 320px;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    color: var(--ink);
    background: var(--bg);
    font-family: "Segoe UI Variable Display", "Segoe UI", "Microsoft YaHei UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input {
    font: inherit;
}

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

.auth-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 40px;
}

.access-layout {
    width: min(100%, 1120px);
    min-height: 680px;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(390px, .75fr);
    align-items: stretch;
}

.access-intro {
    position: relative;
    isolation: isolate;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 48px 56px;
    background: var(--surface-soft);
    border-left: 1px solid rgba(169, 140, 255, .58);
}

.access-intro::before {
    position: absolute;
    inset: 0 0 auto;
    height: 1px;
    background: rgba(169, 140, 255, .48);
    content: "";
}

.brand-lockup {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    background: var(--accent);
    border: 1px solid var(--accent-strong);
    border-radius: var(--radius-control);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28);
}

.brand-glyph {
    width: 13px;
    height: 13px;
    display: block;
    background: #171322;
    border: 2px solid #171322;
    transform: rotate(45deg);
}

.brand-glyph::after {
    width: 5px;
    height: 5px;
    display: block;
    margin: 2px;
    background: var(--accent);
    content: "";
}

.brand-name {
    color: #d8d5e3;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 12px;
    font-weight: 650;
}

.intro-copy {
    position: relative;
    z-index: 2;
    margin-top: 112px;
}

.intro-copy h1 {
    max-width: 8ch;
    margin: 0;
    color: #f4f2f8;
    font-size: 52px;
    font-weight: 650;
    line-height: 1.12;
}

.intro-copy p {
    max-width: 22ch;
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.75;
}

.signal-visual {
    position: absolute;
    right: 34px;
    bottom: 20px;
    width: 360px;
    height: 360px;
    opacity: .92;
}

.signal-frame,
.signal-axis,
.signal-core {
    position: absolute;
    inset: 50% auto auto 50%;
    display: block;
}

.signal-frame {
    border: 1px solid rgba(169, 140, 255, .4);
    transform: translate(-50%, -50%) rotate(45deg);
}

.signal-frame-outer {
    width: 246px;
    height: 246px;
}

.signal-frame-middle {
    width: 172px;
    height: 172px;
    border-color: rgba(112, 220, 234, .38);
}

.signal-frame-inner {
    width: 96px;
    height: 96px;
    background: rgba(169, 140, 255, .055);
    border-color: rgba(169, 140, 255, .7);
}

.signal-axis {
    background: rgba(169, 140, 255, .26);
    transform: translate(-50%, -50%);
}

.signal-axis-horizontal {
    width: 318px;
    height: 1px;
}

.signal-axis-vertical {
    width: 1px;
    height: 318px;
}

.signal-core {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: var(--accent);
    border: 1px solid var(--accent-strong);
    transform: translate(-50%, -50%) rotate(45deg);
    box-shadow: 0 14px 40px rgba(89, 67, 158, .28);
}

.signal-core span {
    width: 15px;
    height: 15px;
    background: var(--surface-soft);
    border: 3px solid #242033;
}

.auth-card {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 52px 48px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-surface);
    box-shadow: 0 28px 80px rgba(5, 5, 11, .42);
}

.auth-heading {
    margin-bottom: 30px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 700;
}

.auth-heading h2,
.status-intro h1 {
    margin: 0;
    color: var(--ink);
    font-size: 34px;
    font-weight: 650;
    line-height: 1.2;
}

.subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
}

.subtitle strong {
    color: var(--accent-strong);
    font-weight: 700;
}

.auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    margin-bottom: 24px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.auth-tab {
    min-height: 40px;
    padding: 8px 12px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 650;
    transition: color .22s var(--ease-out), background-color .22s var(--ease-out), transform .18s var(--ease-out);
}

.auth-tab:hover {
    color: var(--ink);
}

.auth-tab:active {
    transform: scale(.98);
}

.auth-tab.active {
    color: #181421;
    background: var(--accent);
}

.auth-tab:focus-visible,
.password-toggle:focus-visible,
.btn:focus-visible,
.action-logout:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
    box-shadow: none;
}

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

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

.form-label {
    margin: 0;
    color: #d7d4df;
    font-size: 13px;
    font-weight: 650;
}

.form-control,
.form-select {
    width: 100%;
    min-height: 50px;
    padding: 11px 13px;
    color: var(--ink);
    background-color: #0b0c13;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    font-size: 15px;
    transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out), background-color .2s var(--ease-out);
}

.form-control::placeholder {
    color: var(--faint);
}

.form-control:hover,
.form-select:hover {
    border-color: #5a5570;
}

.form-control:focus,
.form-select:focus {
    color: var(--ink);
    background-color: #0d0e17;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(112, 220, 234, .13);
}

.form-control[readonly] {
    opacity: 1;
}

.auth-form.was-validated .form-control:valid,
.auth-form.was-validated .form-control:invalid {
    background-image: none;
}

.auth-form.was-validated .form-control:valid {
    padding-right: 13px;
    border-color: var(--line-strong);
}

.auth-form.was-validated .password-field .form-control:valid {
    padding-right: 68px;
}

.auth-form.was-validated .form-control:valid:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(112, 220, 234, .13);
}

.auth-form.was-validated .form-control:invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(255, 123, 158, .1);
}

.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--ink);
    box-shadow: 0 0 0 1000px #0b0c13 inset;
    transition: background-color 9999s ease-out;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 68px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    min-width: 48px;
    min-height: 34px;
    padding: 5px 8px;
    color: var(--accent-strong);
    background: transparent;
    border: 0;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    transform: translateY(-50%);
}

.password-toggle:hover {
    color: var(--ink);
    background: rgba(169, 140, 255, .1);
}

.credential-input,
.token-field {
    font-family: "Cascadia Code", Consolas, monospace;
}

.btn-primary {
    min-height: 50px;
    color: #17131f;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-control);
    font-weight: 750;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22);
    transition: color .2s var(--ease-out), background-color .2s var(--ease-out), border-color .2s var(--ease-out), transform .18s var(--ease-out);
}

.btn-primary:hover,
.btn-primary:focus {
    color: #17131f;
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-primary:active,
.btn-primary:active:focus {
    color: #17131f;
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    transform: scale(.985);
}

.btn-primary:disabled {
    color: #7c7887;
    background: #292936;
    border-color: #343342;
    box-shadow: none;
    opacity: 1;
}

.submit-button {
    position: relative;
    width: 100%;
    margin-top: 4px;
    overflow: hidden;
    white-space: nowrap;
}

.button-progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--cyan);
    opacity: 0;
    transform: translateX(-100%);
}

.submit-button.is-loading .button-progress {
    opacity: 1;
}

.alert {
    margin: 0 0 20px;
    padding: 12px 14px;
    color: #ffd8e3;
    background: #2c1520;
    border: 1px solid #713248;
    border-radius: var(--radius-control);
    font-size: 13px;
    line-height: 1.55;
}

.alert-warning {
    color: #ffe6b8;
    background: #2c2416;
    border-color: #6b5429;
}

/* Authenticated credential view */
.dashboard-shell {
    align-items: center;
    padding: 48px 32px;
}

.status-card {
    width: min(100%, 980px);
}

.status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}

.session-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    padding: 7px 12px;
    color: var(--success);
    background: rgba(121, 221, 182, .08);
    border: 1px solid rgba(121, 221, 182, .32);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.pulse-dot,
.status-indicator {
    width: 7px;
    height: 7px;
    display: inline-block;
    flex: 0 0 auto;
    background: var(--success);
    border-radius: 50%;
}

.status-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(250px, .75fr);
    gap: 52px;
    padding-top: 48px;
}

.status-intro {
    margin-bottom: 28px;
}

.status-intro h1 {
    font-size: 42px;
}

.status-intro .subtitle {
    max-width: 46ch;
    margin-top: 14px;
    font-size: 15px;
}

.token-panel {
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-surface);
    box-shadow: 0 24px 72px rgba(5, 5, 11, .35), inset 3px 0 0 rgba(169, 140, 255, .78);
}

.token-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.token-heading h2 {
    margin: 0;
    color: var(--ink);
    font-size: 22px;
    font-weight: 650;
}

.token-version {
    padding-top: 5px;
    color: var(--cyan);
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

.token-input-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
}

.token-field {
    min-width: 0;
    min-height: 48px;
    color: var(--accent-strong);
    font-size: 12px;
}

.btn-ghost,
.btn-copy {
    min-width: 62px;
    min-height: 48px;
    padding: 8px 12px;
    border-radius: var(--radius-control);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
    transition: color .2s var(--ease-out), background-color .2s var(--ease-out), border-color .2s var(--ease-out), transform .18s var(--ease-out);
}

.btn-ghost {
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--line-strong);
}

.btn-ghost:hover {
    color: var(--ink);
    background: #171823;
    border-color: var(--accent);
}

.btn-copy {
    color: #16121e;
    background: var(--accent);
    border: 1px solid var(--accent);
}

.btn-copy:hover {
    color: #16121e;
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn-ghost:active,
.btn-copy:active {
    transform: scale(.97);
}

.token-meta {
    display: grid;
    gap: 6px;
    margin-top: 16px;
    color: var(--faint);
    font-size: 12px;
    line-height: 1.45;
}

.token-meta strong {
    color: var(--accent-strong);
    font-family: "Cascadia Code", Consolas, monospace;
    font-weight: 700;
}

.status-sidebar {
    min-width: 0;
}

.status-group {
    border-top: 1px solid var(--line);
}

.status-panel {
    padding: 20px 0;
    border-bottom: 1px solid var(--line);
}

.panel-label {
    display: block;
    color: var(--faint);
    font-size: 12px;
    font-weight: 650;
}

.panel-value {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 9px 0 6px;
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
}

.panel-value.is-ok {
    color: var(--success);
}

.panel-value.is-muted {
    color: var(--muted);
}

.status-panel small {
    display: block;
    overflow-wrap: anywhere;
    color: var(--faint);
    font-size: 12px;
    line-height: 1.5;
}

.status-actions {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.status-actions form {
    margin: 0;
}

.status-card .btn-outline-danger,
.status-card .action-logout {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: var(--radius-control);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: color .2s var(--ease-out), background-color .2s var(--ease-out), border-color .2s var(--ease-out), transform .18s var(--ease-out);
}

.status-card .btn-outline-danger {
    color: var(--danger);
    background: transparent;
    border: 1px solid rgba(255, 123, 158, .48);
}

.status-card .btn-outline-danger:hover {
    color: #241018;
    background: var(--danger);
    border-color: var(--danger);
}

.status-card .action-logout {
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line-strong);
}

.status-card .action-logout:hover {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--accent);
}

.status-card .btn-outline-danger:active,
.status-card .action-logout:active {
    transform: scale(.98);
}

@media (max-width: 900px) {
    .auth-shell {
        padding: 24px;
    }

    .access-layout {
        grid-template-columns: minmax(0, .9fr) minmax(370px, 1fr);
    }

    .access-intro {
        padding: 40px;
    }

    .intro-copy h1 {
        font-size: 44px;
    }

    .signal-visual {
        right: -34px;
        bottom: -4px;
        transform: scale(.86);
    }

    .auth-card {
        padding: 44px 36px;
    }

    .status-layout {
        grid-template-columns: minmax(0, 1.3fr) minmax(220px, .7fr);
        gap: 34px;
    }
}

@media (max-width: 767px) {
    .auth-shell,
    .dashboard-shell {
        display: block;
        min-height: 100dvh;
        padding: 20px 16px;
    }

    .access-layout {
        width: 100%;
        min-height: 0;
        grid-template-columns: 1fr;
    }

    .access-intro {
        min-height: 210px;
        padding: 26px 24px;
        border-left: 0;
        border-top: 1px solid rgba(169, 140, 255, .58);
        border-radius: var(--radius-surface) var(--radius-surface) 0 0;
    }

    .access-intro::before {
        display: none;
    }

    .intro-copy {
        margin-top: 42px;
    }

    .intro-copy h1 {
        max-width: none;
        font-size: 32px;
    }

    .intro-copy p {
        max-width: 18ch;
        margin-top: 10px;
        font-size: 14px;
    }

    .signal-visual {
        right: -80px;
        bottom: -92px;
        width: 280px;
        height: 280px;
        opacity: .66;
        transform: scale(.72);
    }

    .auth-card {
        padding: 32px 24px;
        border-radius: 0 0 var(--radius-surface) var(--radius-surface);
        box-shadow: none;
    }

    .auth-heading h2 {
        font-size: 30px;
    }

    .dashboard-shell {
        padding-top: 28px;
        padding-bottom: 32px;
    }

    .status-header {
        padding-bottom: 20px;
    }

    .status-layout {
        grid-template-columns: 1fr;
        gap: 34px;
        padding-top: 32px;
    }

    .status-intro h1 {
        font-size: 34px;
    }

    .token-panel {
        padding: 22px;
    }

    .status-sidebar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(180px, .7fr);
        gap: 28px;
        align-items: start;
    }

    .status-actions {
        margin-top: 0;
    }
}

@media (max-width: 520px) {
    .auth-shell,
    .dashboard-shell {
        padding-right: 12px;
        padding-left: 12px;
    }

    .brand-name {
        font-size: 11px;
    }

    .auth-card {
        padding: 28px 20px 30px;
    }

    .token-heading {
        display: block;
    }

    .token-version {
        display: block;
        margin-top: 8px;
        padding-top: 0;
    }

    .token-input-group {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .token-field {
        grid-column: 1 / -1;
    }

    .btn-ghost,
    .btn-copy {
        width: 100%;
    }

    .status-sidebar {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .access-intro {
        animation: intro-in .72s var(--ease-out) both;
    }

    .auth-card {
        animation: card-in .66s .08s var(--ease-out) both;
    }

    .auth-form:not(.d-none) {
        animation: form-in .3s var(--ease-out) both;
    }

    .signal-frame-outer {
        animation: signal-turn 18s linear infinite;
    }

    .signal-frame-middle {
        animation: signal-turn-reverse 12s linear infinite;
    }

    .signal-core {
        animation: core-pulse 3.6s var(--ease-out) infinite;
    }

    .submit-button.is-loading .button-progress {
        animation: button-progress 1.05s ease-in-out infinite;
    }

    .pulse-dot {
        animation: status-pulse 2.4s var(--ease-out) infinite;
    }

    @keyframes intro-in {
        from { opacity: 0; transform: translateX(-18px); }
        to { opacity: 1; transform: translateX(0); }
    }

    @keyframes card-in {
        from { opacity: 0; transform: translateY(16px); }
        to { opacity: 1; transform: translateY(0); }
    }

    @keyframes form-in {
        from { opacity: 0; transform: translateY(6px); }
        to { opacity: 1; transform: translateY(0); }
    }

    @keyframes signal-turn {
        from { transform: translate(-50%, -50%) rotate(45deg); }
        to { transform: translate(-50%, -50%) rotate(405deg); }
    }

    @keyframes signal-turn-reverse {
        from { transform: translate(-50%, -50%) rotate(45deg); }
        to { transform: translate(-50%, -50%) rotate(-315deg); }
    }

    @keyframes core-pulse {
        0%, 100% { opacity: .9; transform: translate(-50%, -50%) rotate(45deg) scale(1); }
        50% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scale(1.08); }
    }

    @keyframes button-progress {
        from { transform: translateX(-100%); }
        to { transform: translateX(100%); }
    }

    @keyframes status-pulse {
        0%, 100% { opacity: .55; transform: scale(.86); }
        50% { opacity: 1; transform: scale(1.12); }
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
