body.adminLoginPage {
    font-family: var(--font-family-base);
    background-color: var(--color-admin-login-tint);
    background-image:
        linear-gradient(to bottom, transparent 40%, var(--color-admin-login-tint) 100%),
        url("../images/login/pattern.svg");
    background-repeat: no-repeat, repeat;
    background-size: 100% 100%, 395px 407px;
    background-position: 0 0, -28px -70px;
    background-attachment: fixed;
}

/* The card never grows past the screen, its sections scroll inside it instead */
#content {
    --card-max-height: calc(100vh - 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}

/* Card */

.loginPageCard {
    display: flex;
    width: 100%;
    max-width: 1211px;
    min-height: min(632px, var(--card-max-height));
    border-radius: var(--border-radius-primary);
    box-shadow: var(--box-shadow-card);
    overflow: hidden;
}

#loginPageLeftSection {
    flex: 590;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    max-height: var(--card-max-height);
    overflow-y: auto;
    position: relative;
    isolation: isolate;
    padding: 40px;
    background: var(--color-admin-login-panel);
    color: var(--color-white);
}

/* The pattern fades in from the top of the panel, as in Figma */
#loginPageLeftSection::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url("../images/login/panel-shape.svg") no-repeat left -14px top 278px / 558px auto;
    -webkit-mask-image: linear-gradient(to bottom, transparent 27%, rgb(0 0 0 / 47%) 100%);
    mask-image: linear-gradient(to bottom, transparent 27%, rgb(0 0 0 / 47%) 100%);
    pointer-events: none;
}

#loginPageRightSection {
    flex: 621;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-height: var(--card-max-height);
    background: var(--color-admin-login-surface);
    color: var(--color-primary);
}

/* About us. Backoffice HTML, so keep it readable on the dark panel */

#loginPagePresentation {
    width: 100%;
}

:where(#loginPagePresentation) {
    --color-tertiary: #ff5800;
}

#loginPagePresentation > .collapsibleInner {
    max-height: 552px;
    overflow-y: auto;
    scrollbar-width: none;
}

#loginPagePresentation,
#loginPagePresentation h1,
#loginPagePresentation h2,
#loginPagePresentation h3,
#loginPagePresentation p {
    color: var(--color-white);
}

/* Header */

.loginCardHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 86px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--color-light);
}

.loginCardLogo {
    height: 45px;
    max-width: 180px;
    object-fit: contain;
}

/* Form */

#adminLoginForm {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 32px 40px 40px;
}

.loginWelcome {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.loginSubtitle {
    margin: 4px 0 32px;
    font-size: var(--font-size-body);
    color: var(--color-primary);
}

.loginLabel {
    display: block;
    margin: 0 0 8px;
    font-size: var(--font-size-body);
    font-weight: 500;
    color: var(--color-primary);
}

#standardLogin .loginLabel {
    margin-top: 16px;
}

.loginInput {
    position: relative;
    display: flex;
    align-items: center;
    height: 48px;
    background: var(--color-white);
    border: 1px solid var(--color-medium);
    border-radius: var(--border-radius-primary);
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition-property: border-color, outline-color, background-color;
    transition-duration: 150ms;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.loginInput.hidden {
    display: none;
}

.loginInput:has(input:focus) {
    border-color: var(--color-tertiary);
    outline: 2px solid var(--color-tertiary);
    outline-offset: 2px;
}

.loginInput input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 16px 0 56px;
    border: none;
    border-radius: var(--border-radius-primary);
    background: transparent;
    font-size: var(--font-size-small);
    color: var(--color-primary);
}

.loginInput input:focus {
    outline: none;
}

.loginInputIcon {
    position: absolute;
    left: 14px;
    width: 24px;
    text-align: center;
    font-size: var(--font-size-large);
    color: var(--color-medium-dark);
    pointer-events: none;
    transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.loginInput .dsIcon {
    font-size: 24px;
}

.loginInputAction {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 100%;
    flex-shrink: 0;
    padding: 0;
    background: none;
    border: none;
    font-size: var(--font-size-large);
    color: var(--color-medium-dark);
    cursor: pointer;
    transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.loginInputAction:hover {
    color: var(--color-primary);
}

.loginInputAction:focus-visible {
    outline: 2px solid var(--color-tertiary);
    outline-offset: -6px;
    border-radius: var(--border-radius-primary);
}

/* Shown from CSS because jQuery .show() sets inline-block and loses the flex centering */
#restartLoginButton {
    display: none;
}

#email-container.locked #restartLoginButton {
    display: flex;
}

#mfa-container {
    margin-top: 16px;
}

/* While the email lookup runs a spinner takes the envelope's place */
.loginInputSpinner,
#email-container.loading .dsIconMail {
    display: none;
}

#email-container.loading .loginInputSpinner {
    display: inline-block;
}

#loginBtn:disabled {
    cursor: progress;
    filter: none;
    opacity: 0.8;
}

#email-container.locked {
    background: var(--color-light);
}

#email-container.locked #email {
    -webkit-box-shadow: 0 0 0 30px var(--color-light) inset !important; /* hides Chrome's autofill background */
}

#password-container.login-failed {
    border-color: var(--color-negative);
}

#password-container.login-failed .loginInputIcon {
    color: var(--color-negative);
}

/* Buttons */

#loginBtn,
#continueBtn,
.loginSsoButton {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 8px 16px;
    border-radius: var(--border-radius-primary);
    font-size: var(--font-size-body);
    text-decoration: none;
    cursor: pointer;
    transition-property: color, background-color, border-color, filter, opacity;
    transition-duration: 150ms;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

#loginBtn,
#continueBtn {
    margin-top: 32px;
    border: 1px solid var(--color-tertiary);
    background: var(--color-tertiary);
    color: var(--color-white);
}

/* Hover keeps each button's identity. The primary darkens slightly and the
   outline one gets a soft tint, so a hovered button never mimics its neighbor. */
#loginBtn:hover,
#loginBtn:active,
#continueBtn:hover,
#continueBtn:active {
    filter: brightness(0.92);
}

.loginSsoButton {
    margin-top: 16px;
    border: 1px solid var(--color-tertiary-text);
    background: transparent;
    color: var(--color-tertiary-text);
}

.loginSsoButton:hover,
.loginSsoButton:focus {
    background: var(--color-tertiary-light);
    color: var(--color-tertiary-text);
}

#loginBtn:focus-visible,
#continueBtn:focus-visible,
.loginSsoButton:focus-visible {
    outline: 2px solid var(--color-tertiary);
    outline-offset: 2px;
}

.loginDivider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    font-size: var(--font-size-small);
    color: var(--color-admin-login-muted);
}

.loginDivider::before,
.loginDivider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--color-medium-dark);
}

#resetPasswordLink {
    display: block;
    margin: 16px 0 0 auto;
    padding: 0;
    background: none;
    border: none;
    font-size: var(--font-size-small);
    color: var(--color-primary);
    cursor: pointer;
}

#resetPasswordLink:hover {
    text-decoration: underline;
}

#resetPasswordLink:focus-visible {
    outline: 2px solid var(--color-tertiary);
    outline-offset: 2px;
    border-radius: var(--border-radius-primary);
}

/* Error message */

#wrongLoginMessage {
    width: fit-content;
    margin: 0 auto;
    padding: 0 20px;
    background: #fdd3d3;
    color: var(--color-negative);
    border-radius: 20px;
    cursor: pointer;
}

#wrongLoginMessage.open {
    margin-bottom: 20px;
    padding: 5px 20px;
}

#wrongLoginMessage:focus-visible {
    outline: 2px solid var(--color-tertiary);
    outline-offset: 2px;
}

/* Companies */

/* 20px gives a 16px gap, the -4px margin of .collapsibleInner takes the rest */
#companyList {
    padding-top: 20px;
}

/* fitCompanyList() caps the height so a long list scrolls instead of the page */
#companyListScroll {
    overflow-y: auto;
    overscroll-behavior: contain;
}

.companyOption {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-left: 3px solid transparent;
    border-radius: 0 var(--border-radius-primary) var(--border-radius-primary) 0;
    font-size: var(--font-size-body);
    color: var(--color-primary);
    cursor: pointer;
    max-height: 60px;
    transition: max-height 200ms ease, opacity 200ms ease, padding 200ms ease, margin 200ms ease, visibility 200ms, background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Spacing goes only between visible rows, so the picked company keeps the
   same gap above and below it once the others collapse. */
.companyOption:not(.collapsed) ~ .companyOption:not(.collapsed) {
    margin-top: 4px;
}

/* The rows of the companies the user did not pick */
.companyOption.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
}

.companyOption:hover,
.companyOption:focus-visible {
    background: var(--color-light);
    outline: none;
}

.companyOption img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

/* Panels that open and close. Animating the grid row from 0fr to 1fr reaches
   the content height without measuring it in JavaScript. The single child
   clips its content while the row is shorter than it. */

.collapsible {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    visibility: hidden;
    transition: grid-template-rows 200ms ease, opacity 200ms ease, visibility 200ms, margin 200ms ease, padding 200ms ease;
}

.collapsible.open {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
}

/* The padding leaves room for the focus rings of the content, which the
   clipping would otherwise cut off. The negative margin keeps the layout. */
.collapsibleInner {
    min-height: 0;
    overflow: hidden;
    padding: 4px;
    margin: -4px;
}

/* No element on the page falls back to the browser's blue ring. :where()
   keeps it weaker than the rings and backgrounds the elements set themselves. */
.adminLoginPage :where(:focus-visible) {
    outline: 2px solid var(--color-tertiary);
}

/* Motion, shared with pareva-tools and the deinSpind portal. The backwards fill
   holds the first frame during the stagger delay and then hands opacity back,
   so .collapsible, .collapsed and :disabled keep owning it afterwards. */

@keyframes loginRevealUp {
    from {
        opacity: 0;
        translate: 0 8px;
    }
}

@keyframes loginFadeIn {
    from {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .loginPageCard {
        animation: loginFadeIn 0.2s ease-out backwards;
    }

    #loginPageLeftSection::before {
        animation: loginFadeIn 0.6s ease-out backwards;
    }

    .loginReveal,
    #noteList .noteSlot > .collapsibleInner {
        animation: loginRevealUp 0.4s ease-out backwards;
        animation-delay: calc(var(--reveal-step, 0) * 0.1s);
    }

    /* The news arrive after the about-us text, which takes step 0 */
    #noteList .noteSlot > .collapsibleInner {
        animation-delay: calc((var(--reveal-step, 0) + 1) * 0.1s);
    }

    #loginBtn,
    #continueBtn,
    .loginSsoButton {
        transition-property: color, background-color, border-color, filter, opacity, scale;
    }

    #loginBtn:active:not(:disabled),
    #continueBtn:active,
    .loginSsoButton:active {
        scale: 0.98;
    }

    /* The login steps are taller than the other panels, so they take longer and
       settle gently instead of snapping */
    #companyLogin,
    #continueStep {
        transition: grid-template-rows 300ms cubic-bezier(0.2, 0, 0, 1), opacity 200ms ease, visibility 300ms, margin 300ms cubic-bezier(0.2, 0, 0, 1), padding 300ms cubic-bezier(0.2, 0, 0, 1);
    }

    /* Waits for the company list so the steps read in order. The fade trails the
       growth so the fields never show half clipped */
    #companyLogin.open {
        transition: grid-template-rows 300ms cubic-bezier(0.2, 0, 0, 1) 150ms, opacity 200ms ease 250ms, visibility 0s 150ms, margin 300ms cubic-bezier(0.2, 0, 0, 1) 150ms, padding 300ms cubic-bezier(0.2, 0, 0, 1) 150ms;
    }
}

@media (prefers-reduced-motion: reduce) {
    .collapsible,
    .companyOption {
        transition: none;
    }
}

@media (max-width: 800px) {
    #loginPageLeftSection {
        display: none;
    }

    .loginPageCard {
        min-height: 0;
    }

    .loginCardHeader {
        padding: 16px;
    }

    #adminLoginForm {
        padding: 24px 16px 32px;
    }
}
