:root {
    --page: #f3f7fb;
    --page-alt: #e8f3f8;
    --surface: #ffffff;
    --surface-soft: #f7faff;
    --navy: #0d2236;
    --navy-soft: #143a59;
    --text: #0b1d33;
    --muted: #70839a;
    --line: #d4e0ea;
    --line-strong: #b9ccdc;
    --primary: #2f86d8;
    --primary-dark: #2473bd;
    --accent: #27c4c9;
    --danger: #d84e61;
    --danger-soft: #fff1f3;
    --shadow: 0 28px 70px rgba(21, 55, 83, .18);
}

:root[data-theme="dark"] {
    --page: #071421;
    --page-alt: #0a1c2c;
    --surface: #0d1d2d;
    --surface-soft: #11263a;
    --navy: #081522;
    --navy-soft: #12344f;
    --text: #eef6ff;
    --muted: #91a7bd;
    --line: #29445c;
    --line-strong: #3a5b75;
    --primary: #3b93e5;
    --primary-dark: #2d7fc9;
    --accent: #32ccd0;
    --danger: #ff7888;
    --danger-soft: rgba(120, 28, 43, .28);
    --shadow: 0 30px 80px rgba(0, 0, 0, .4);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 14%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 31%),
        radial-gradient(circle at 88% 84%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 29%),
        linear-gradient(145deg, var(--page), var(--page-alt));
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.login-page {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 34px 18px;
}

.login-page::before,
.login-page::after {
    content: "";
    position: fixed;
    z-index: -1;
    width: min(56vw, 680px);
    aspect-ratio: 1;
    border: 1px solid color-mix(in srgb, var(--primary) 16%, transparent);
    border-radius: 50%;
    pointer-events: none;
    will-change: transform;
}

.login-page::before {
    top: -35%;
    left: -20%;
    box-shadow:
        0 0 0 70px color-mix(in srgb, var(--primary) 3%, transparent),
        0 0 0 140px color-mix(in srgb, var(--accent) 2%, transparent);
    animation: portal-drift-a 20s ease-in-out infinite alternate;
}

.login-page::after {
    right: -24%;
    bottom: -42%;
    box-shadow:
        0 0 0 76px color-mix(in srgb, var(--accent) 3%, transparent),
        0 0 0 152px color-mix(in srgb, var(--primary) 2%, transparent);
    animation: portal-drift-b 24s ease-in-out infinite alternate;
}

@keyframes portal-drift-a {
    to { transform: translate3d(5vw, 4vh, 0); }
}

@keyframes portal-drift-b {
    to { transform: translate3d(-4vw, -3vh, 0); }
}

@keyframes login-enter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.theme-toggle {
    position: fixed;
    z-index: 10;
    top: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--navy-soft);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    box-shadow: 0 10px 26px rgba(17, 53, 82, .12);
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, transform .16s ease;
}

:root[data-theme="dark"] .theme-toggle {
    color: #d6e8f8;
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.theme-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-icon-moon,
:root[data-theme="dark"] .theme-icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-icon-moon {
    display: block;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(320px, .9fr) minmax(400px, 1.1fr);
    width: min(880px, calc(100vw - 48px));
    min-height: 520px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
    animation: login-enter .38s cubic-bezier(.2, .76, .24, 1) both;
}

.brand-panel {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 520px;
    padding: 48px;
    color: #f4f9ff;
    background:
        radial-gradient(circle at 86% 10%, rgba(50, 204, 208, .18), transparent 34%),
        linear-gradient(135deg, var(--navy), var(--navy-soft));
}

.portal-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 24px;
}

.brand-mark {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    color: #62e0e2;
    border: 1px solid rgba(158, 222, 235, .3);
    border-radius: 13px;
    background: rgba(255, 255, 255, .08);
}

.brand-mark svg {
    width: 25px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.portal-brand h1 {
    margin: 0;
    color: #ffffff;
    font-size: clamp(22px, 5vw, 28px);
    line-height: 1.05;
    letter-spacing: .035em;
}

.brand-kicker {
    display: block;
    margin-top: 7px;
    color: #71dfe2;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .16em;
}

.form-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 56px;
    background: var(--surface);
}

.security-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.security-strip span,
.security-strip strong {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.security-strip strong {
    color: var(--primary);
}

.security-strip svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.security-strip i {
    width: 17px;
    height: 17px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--primary);
    font-size: 10px;
    font-style: normal;
}

.form-heading {
    text-align: center;
}

.staff-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    margin: 0 auto 12px;
    color: #fff;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--primary), #536ed4);
    box-shadow: 0 12px 24px rgba(47, 134, 216, .22);
}

.staff-icon svg {
    width: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.form-heading h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
}

.form-heading p {
    margin: 7px 0 22px;
    color: var(--muted);
    font-size: 13px;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 16px;
    padding: 11px 12px;
    border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
    border-radius: 10px;
    color: var(--danger);
    background: var(--danger-soft);
    font-size: 12px;
    font-weight: 600;
}

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

.field-label {
    display: block;
    margin: 0 0 7px;
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .045em;
}

.field-label:not(:first-of-type) {
    margin-top: 16px;
}

.field-control {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.field-control:focus-within {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.field-control > svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-left: 14px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.field-control input {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 13px;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    font-size: 13px;
    font-weight: 500;
}

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

.password-toggle {
    flex: 0 0 auto;
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    margin-right: 2px;
    border: 0;
    border-radius: 9px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.password-toggle:hover {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.password-toggle svg {
    width: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
}

.submit-button {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin-top: 22px;
    border: 1px solid #54a2e8;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 13px 26px rgba(47, 134, 216, .22);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

.submit-button:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(47, 134, 216, .28);
}

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

.submit-button svg {
    width: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.login-submit-spinner {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border: 2px solid rgba(255, 255, 255, .42);
    border-top-color: #fff;
    border-radius: 50%;
    animation: login-submit-spin .72s linear infinite;
}

body.is-authenticating .login-shell,
body.is-authenticating .theme-toggle {
    pointer-events: none;
}

body.is-authenticating .login-shell {
    transform: translateZ(0);
}

@keyframes login-submit-spin {
    to {
        transform: rotate(360deg);
    }
}

.access-note {
    margin-top: 18px;
    color: var(--muted);
    text-align: center;
    font-size: 10px;
    line-height: 1.5;
}

.access-note p {
    margin: 0;
}

.access-note strong {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 500;
}

@media (min-width: 561px) and (max-width: 820px) {
    .login-shell {
        grid-template-columns: minmax(260px, .82fr) minmax(360px, 1.18fr);
        width: min(740px, calc(100vw - 32px));
    }

    .brand-panel {
        padding: 34px;
    }

    .form-panel {
        padding: 36px;
    }
}

@media (max-width: 560px) {
    .login-page {
        align-items: start;
        overflow-y: auto;
        padding: 72px 14px 24px;
    }

    .theme-toggle {
        top: 14px;
        right: 14px;
    }

    .login-shell {
        display: block;
        width: min(470px, 100%);
        min-height: 0;
        border-radius: 18px;
    }

    .brand-panel {
        justify-content: center;
        min-height: 116px;
        padding: 24px 18px;
    }

    .portal-brand {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 11px;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
    }

    .portal-brand h1 {
        font-size: 22px;
    }

    .form-panel {
        display: block;
        padding: 22px 18px 24px;
    }
}

@media (max-height: 700px) and (min-width: 561px) {
    .login-page {
        align-items: start;
        overflow-y: auto;
        padding-top: 26px;
    }

    .login-shell {
        min-height: 480px;
    }

    .brand-panel {
        min-height: 480px;
        padding: 32px;
    }

    .form-panel {
        padding: 28px 40px;
    }

    .security-strip {
        margin-bottom: 16px;
    }

    .staff-icon {
        width: 42px;
        height: 42px;
        margin-bottom: 8px;
    }

    .form-heading p {
        margin-bottom: 15px;
    }
}

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