/* ============================ DESIGN TOKENS START =================================== */

:root {
    /* fonts */
    --heading-font: "Urbanist", sans-serif;
    --body-font: "Inter", sans-serif;

    /* colours are bare HSL channels: use as hsl(var(--x) / alpha) */
    --white: 0 0% 100%;
    --black: 0 0% 0%;
    --gray-50: 210 20% 98%;
    --gray-100: 220 14% 96%;
    --gray-200: 220 13% 91%;
    --gray-400: 218 11% 65%;
    --gray-500: 220 9% 46%;
    --gray-600: 215 14% 34%;
    --gray-700: 217 19% 27%;
    --base-h: 25;
    --base-s: 100%;
    --base-l: 50%;
    --base: var(--base-h) var(--base-s) var(--base-l);
    --success: 152 65% 42%;
    --danger: 358 80% 57%;
    --warning: 36 95% 50%;
    --info: 199 92% 46%;

    /* colour roles */
    --heading-color: var(--black);
    --body-color: var(--gray-600);
    --border-color: var(--gray-200);
    --border-subtle: var(--gray-100);
    --section-bg: var(--gray-50);
    /* lightness factor for a state colour used as text on white */
    --text-shade: 0.68;

    /* sizes: fields are taller here than in the dashboard because the form is the whole page */
    --control-h: 44px;
    --avatar-sm: 28px;
    --radius: 4px;
    --radius-lg: 8px;

    /* shadows */
    --shadow-md: 0 4px 12px -2px hsl(var(--black) / 0.1), 0 2px 4px -2px hsl(var(--black) / 0.05);
    --shadow-lg: 0 12px 28px -6px hsl(var(--black) / 0.1), 0 4px 8px -4px hsl(var(--black) / 0.05);
    --shadow-xl: 0 24px 48px -12px hsl(var(--black) / 0.2);

    /* type */
    --fs-12: 0.75rem;
    --fs-14: 0.875rem;
    --fs-20: 1.25rem;
    --fs-24: 1.5rem;
    --fs-28: 1.75rem;
    --fw-500: 500;
    --fw-600: 600;
    --fw-700: 700;

    /* motion */
    --dur-fast: 0.15s;
    --dur-slow: 0.3s;
    --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ============================ DESIGN TOKENS END =================================== */


/* ============================ BASE START =================================== */

* {
    margin: 0;
    padding: 0;
}

/* break-word also wraps long addresses and messages everywhere on the page */
body {
    font-family: var(--body-font);
    color: hsl(var(--body-color));
    word-break: break-word;
    background-color: hsl(var(--section-bg));
}

p { margin: 0; }
span { display: inline-block; }

a {
    display: inline-block;
    text-decoration: none;
    color: hsl(var(--base));
}

a:hover { color: hsl(var(--base)); }
button:focus { outline: none; }

/* the font size is for the alt text of an image that failed to load */
img {
    max-width: 100%;
    font-size: var(--fs-12);
}

::selection {
    color: hsl(var(--white));
    background: hsl(from hsl(var(--base)) h s calc(l * 0.9));
}

/* ============================ BASE END =================================== */


/* ============================ LAYOUT START =================================== */

.auth {
    --auth-card-w: 400px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 28px 24px 20px;
    overflow: hidden;

    @media (max-width: 575px) {
        padding: 20px 16px 16px;
    }
}

/* the column fills the page so the body centres between logo and footer */
.auth__main {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

/* the logo sits just above the card: the two are centred on the page as one group */
.auth__head {
    display: flex;
    justify-content: center;
    margin-top: auto;
}

.auth__logo img {
    height: 34px;

    @media (max-width: 575px) {
        height: 30px;
    }
}

.auth__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-block: 28px 32px;

    @media (max-width: 575px) {
        padding-block: 24px;
    }
}

.auth__foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 20px;
    margin-top: auto;
    font-size: var(--fs-12);
    color: hsl(var(--gray-400));

    & a {
        color: hsl(var(--gray-500));
        transition: color var(--dur-fast) ease;
    }

    & a:hover { color: hsl(var(--base)); }
}

/* the line under the card */
.auth-switch {
    font-size: var(--fs-14);
    text-align: center;
    color: hsl(var(--gray-500));

    & a { font-weight: var(--fw-600); }
}

/* card-less variant on white: logo, message and footer share one left-aligned column */
.auth--split {
    flex-direction: row;
    padding: 0;
    background-color: hsl(var(--white));

    & .auth__main {
        padding: 40px 40px 24px;

        @media (max-width: 575px) {
            padding: 20px 16px 16px;
        }
    }

    & :is(.auth__head, .auth__body > *, .auth__foot) {
        width: min(100%, var(--auth-card-w));
        margin-inline: auto;
    }

    & .auth__head {
        justify-content: flex-start;
        margin-top: auto;
        margin-bottom: 48px;
    }

    & .auth__foot {
        justify-content: flex-start;
        padding-top: 40px;
    }

    & .auth__body {
        align-items: stretch;
        padding-block: 0;
    }

    & .auth__logo img { height: 30px; }

    & .auth-card {
        gap: 28px;
        padding: 0;
        background: none;
        border: 0;
        box-shadow: none;
        animation: none;
    }

    & .auth-heading {
        align-items: flex-start;
        gap: 6px;
        text-align: left;
    }

    & .auth-heading__title {
        font-size: var(--fs-24);
        font-weight: var(--fw-600);
    }

    & .auth-heading__text { max-width: none; }
    & :is(.auth-switch, .auth-note) { text-align: left; }
}

/* ============================ LAYOUT END =================================== */


/* ============================ COMPONENT: BUTTONS START =================================== */

/* the 1px border comes from Bootstrap's .btn, its colour from the variant */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-600);
    line-height: 1.3;
    white-space: nowrap;
    color: hsl(var(--white)) !important;
    border-radius: var(--radius);
    transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.btn:disabled { opacity: 0.6; }
.btn:active { transform: translateY(1px); }

.btn--md {
    height: var(--control-h);
    padding: 8px 14px;
    font-size: var(--fs-14);
}

.btn--base {
    --btn: hsl(var(--base));
    background-color: var(--btn) !important;
    border-color: var(--btn) !important;
}

.btn--base:hover { --btn: hsl(from hsl(var(--base)) h s calc(l * 0.9)); }

/* ============================ COMPONENT: BUTTONS END =================================== */


/* ============================ COMPONENT: FORMS START =================================== */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form--label {
    display: block;
    margin-bottom: 6px;
    font-size: var(--fs-14);
    font-weight: var(--fw-500);
    line-height: 1.3;
    color: hsl(var(--gray-700));
}

label.required::after {
    content: "*";
    margin-left: 2px;
    color: hsl(from hsl(var(--danger)) h s calc(l * var(--text-shade)));
}

.form--control {
    width: 100%;
    height: var(--control-h);
    padding: 0 14px;
    font-size: var(--fs-14);
    line-height: 1.4;
    color: hsl(var(--heading-color));
    background-color: hsl(var(--white) / 0.8);
    border: 1px solid hsl(var(--gray-200));
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, background-color var(--dur-fast) ease;
}

.form--control::placeholder { color: hsl(var(--gray-400)); }
.form--control:hover { border-color: hsl(var(--gray-400) / 0.6); }

.form--control:focus {
    background-color: hsl(var(--white));
    border-color: hsl(var(--base));
}

.form--control:read-only {
    color: hsl(var(--gray-500));
    background-color: hsl(var(--gray-100) / 0.6);
}

.form--control[type="password"] { color: hsl(var(--black) / 0.5); }
.form--control[type="password"]:focus { color: hsl(var(--black)); }

/* bigger, spaced dots once something is typed */
.form--control[type="password"]:not(:placeholder-shown) {
    font-size: var(--fs-20);
    letter-spacing: 0.08em;
}

/* keep autofilled fields on the field's own background */
input:-webkit-autofill {
    -webkit-text-fill-color: hsl(var(--black)) !important;
    caret-color: hsl(var(--black));
}

input:-webkit-autofill:is(:hover, :focus, :active) { transition: background-color 5000s ease-in-out 0s; }

/* icon in front of the input, show/hide button behind a password */
.auth-field {
    position: relative;

    & .form--control { padding-left: 42px; }

    & .auth-field__icon {
        position: absolute;
        top: 50%;
        left: 14px;
        width: 18px;
        height: 18px;
        color: hsl(var(--gray-400));
        pointer-events: none;
        transform: translateY(-50%);
        transition: color var(--dur-fast) ease;
    }

    &:focus-within .auth-field__icon { color: hsl(var(--base)); }
}

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

.auth-field__toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: hsl(var(--gray-400));
    background: none;
    border: 0;
    border-radius: var(--radius);
    transform: translateY(-50%);
    transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;

    &:hover {
        color: hsl(var(--gray-700));
        background-color: hsl(var(--gray-100));
    }

    &:focus-visible { outline: 2px solid hsl(var(--base) / 0.5); }

    & svg {
        width: 18px;
        height: 18px;
    }

    /* eye while hidden, crossed eye once revealed */
    &:not(.is-revealed) .auth-field__hide,
    &.is-revealed .auth-field__show {
        display: none;
    }
}

.form--check {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.form--check .form-check-input {
    position: relative;
    width: 18px;
    height: 18px;
    margin-top: 0;
    border: 1.5px solid hsl(var(--black) / 0.25);
    border-radius: var(--radius);
    cursor: pointer;
}

.form--check .form-check-input:focus {
    border-color: hsl(var(--black) / 0.2);
    box-shadow: none;
}

.form--check .form-check-input:checked {
    background-color: hsl(var(--base));
    background-image: none;
    border-color: hsl(var(--base));
}

.form--check .form-check-input:checked::before {
    --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
    content: "";
    position: absolute;
    inset: 0;
    width: var(--fs-12);
    height: var(--fs-12);
    margin: auto;
    background-color: hsl(var(--white));
    -webkit-mask: var(--tick);
    mask: var(--tick);
}

.form--check .form-check-label {
    flex: 1;
    padding-left: 12px;
    font-size: var(--fs-12);
    font-weight: var(--fw-500);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

/* remember me on the left, forgot password on the right */
.auth-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    font-size: var(--fs-14);
}

/* ============================ COMPONENT: FORMS END =================================== */


/* ============================ COMPONENT: CARD START =================================== */

.auth-card {
    display: flex;
    flex-direction: column;
    gap: 26px;
    width: min(100%, var(--auth-card-w));
    padding: 36px 32px 32px;
    background-color: hsl(var(--white));
    border: 1px solid hsl(var(--border-color));
    border-radius: var(--radius);
    box-shadow: 0 1px 2px hsl(var(--black) / 0.04);
    animation: auth-card-in 0.5s var(--ease-out) both;

    @media (max-width: 575px) {
        padding: 28px 20px 24px;
    }
}

.auth-heading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.auth-heading__icon {
    --tone: var(--base);
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 8px;
    color: hsl(var(--tone));
    background-color: hsl(var(--tone) / 0.1);
    border-radius: 50%;

    & svg {
        width: 24px;
        height: 24px;
    }
}

.auth-heading__icon--danger { --tone: var(--danger); }

/* the organization's logo above the heading */
.auth-heading__org {
    width: 56px;
    height: 56px;
    margin-bottom: 8px;
    overflow: hidden;
    border: 1px solid hsl(var(--border-color));
    border-radius: 50%;
    box-shadow: var(--shadow-md);

    & img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

.auth-heading__title {
    margin: 0;
    font-family: var(--heading-font);
    font-size: var(--fs-28);
    font-weight: var(--fw-700);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: hsl(var(--heading-color));

    @media (max-width: 575px) {
        font-size: var(--fs-24);
    }
}

.auth-heading__text {
    max-width: 34ch;
    font-size: var(--fs-14);
    line-height: 1.6;
    color: hsl(var(--gray-500));

    & strong {
        font-weight: var(--fw-600);
        color: hsl(var(--gray-700));
    }
}

.auth-note {
    margin-top: -6px;
    font-size: var(--fs-14);
    line-height: 1.6;
    text-align: center;
    color: hsl(var(--gray-500));
}

.auth-link { font-weight: var(--fw-600); }

/* ============================ COMPONENT: CARD END =================================== */


/* ============================ COMPONENT: VERIFICATION CODE START =================================== */

/* the six boxes share the row equally */
.verification-code .code-input {
    flex: 1 1 0;
    min-width: 0;
    height: 54px;
    padding-inline: 0;
    font-family: var(--heading-font);
    font-size: var(--fs-24);
    font-weight: var(--fw-700);
    appearance: textfield;

    &::-webkit-outer-spin-button,
    &::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
}

/* ============================ COMPONENT: VERIFICATION CODE END =================================== */


/* ============================ COMPONENT: TOAST START =================================== */

.td-toasts {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;

    @media (max-width: 575px) {
        top: 12px;
        right: 16px;
    }
}

.td-toast {
    --td-accent: hsl(var(--success));
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 14px 18px;
    overflow: hidden;
    border: 1px solid hsl(var(--border-subtle));
    border-radius: var(--radius-lg);
    background: hsl(var(--white));
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    transform: translateX(16px) scale(0.98);
    opacity: 0;
    transition: transform var(--dur-slow) cubic-bezier(0.2, 0.8, 0.2, 1), opacity var(--dur-slow) ease, box-shadow var(--dur-fast) ease;
}

/* status colour rail */
.td-toast::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--td-accent);
}

.td-toast:hover { box-shadow: var(--shadow-xl); }

.td-toast.is-in {
    transform: none;
    opacity: 1;
}

.td-toast--error { --td-accent: hsl(var(--danger)); }
.td-toast--warning { --td-accent: hsl(var(--warning)); }
.td-toast--info { --td-accent: hsl(var(--info)); }

.td-toast__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--avatar-sm);
    height: var(--avatar-sm);
    border-radius: 50%;
    color: var(--td-accent);
    background: color-mix(in srgb, var(--td-accent) 12%, hsl(var(--white)));
}

.td-toast__icon svg {
    width: 15px;
    height: 15px;
    stroke-width: 2.4;
}

.td-toast__body {
    flex: 1 1 auto;
    min-width: 0;
    padding-top: 1px;
    font-size: var(--fs-14);
}

.td-toast__title {
    font-weight: var(--fw-600);
    line-height: 1.3;
    color: hsl(var(--black));
}

.td-toast__msg {
    margin-top: 3px;
    line-height: 1.45;
}

.td-toast__close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: -2px -2px 0 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: hsl(var(--gray-400));
    transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.td-toast__close:hover {
    background: hsl(var(--gray-100));
    color: hsl(var(--gray-700));
}

.td-toast__close svg {
    width: 14px;
    height: 14px;
}

/* countdown line: starts after the 4px colour rail */
.td-toast__bar {
    position: absolute;
    inset: auto 0 0 4px;
    height: 2px;
    background: var(--td-accent);
    opacity: 0.35;
    transform-origin: left;
    animation: td-toast-bar linear forwards;
}

.td-toast:hover .td-toast__bar { animation-play-state: paused; }

/* ============================ COMPONENT: TOAST END =================================== */


/* ============================ COMPONENT: UTILITY START =================================== */

.svg-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    flex-shrink: 0;
    overflow: visible;
}

/* ============================ COMPONENT: UTILITY END =================================== */


/* ============================ COMPONENT: ANIMATION START =================================== */

@keyframes auth-card-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.99);
    }
}

@keyframes td-toast-bar {
    to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card { animation: none; }

    .td-toast {
        transform: none;
        transition: opacity var(--dur-fast) ease;
    }
}

/* ============================ COMPONENT: ANIMATION END =================================== */


/* ============================ PAGE: MESSAGE START =================================== */

/* the reason a team gave for turning a client's access off */
.auth-reason {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    background-color: hsl(var(--gray-50));
    border: 1px solid hsl(var(--border-color));
    border-radius: var(--radius);
}

.auth-reason__label {
    font-size: var(--fs-12);
    font-weight: var(--fw-600);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: hsl(var(--gray-400));
}

.auth-reason__text {
    font-size: var(--fs-14);
    line-height: 1.6;
    color: hsl(var(--gray-700));
}

/* ============================ PAGE: MESSAGE END =================================== */
