:root {
    color-scheme: light;
    --app-brand-red: #a41515;
    --app-brand-red-hover: #871010;
    --app-brand-red-active: #670c0c;
    --app-ink: #142033;
    --app-charcoal: #243247;
    --app-accent-blue: #253d66;
    --app-page-background: #f3f6fa;
    --app-surface: #ffffff;
    --app-surface-panel: #f8fafc;
    --app-surface-strong: #eef3f8;
    --app-border: rgb(27 45 71 / 12%);
    --app-border-strong: rgb(27 45 71 / 18%);
    --app-field-outline: rgb(27 45 71 / 32%);
    --app-muted-text: #596579;
    --app-error: #9a1b1b;
    --app-error-surface: #fff0ee;
    --app-success: #0b6b2e;
    --app-success-surface: #edf8f1;
    --app-warning: #795800;
    --app-warning-surface: #fff4d8;
    --app-shadow: 0 20px 46px rgb(13 22 37 / 12%);
    --app-shadow-soft: 0 12px 28px rgb(15 23 39 / 6%);
    font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--app-ink);
    background: var(--app-page-background);
    font-synthesis: none;
    line-height: 1.5;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background:
        linear-gradient(135deg, rgb(164 21 21 / 8%), transparent 36%),
        linear-gradient(315deg, rgb(37 61 102 / 7%), transparent 34%),
        var(--app-page-background);
    color: var(--app-ink);
}

button,
input,
select {
    font: inherit;
}

.registration-form fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.registration-form legend { margin-bottom: 8px; font-weight: 700; }
.salutation-options { display: flex; flex-wrap: wrap; gap: 16px; }
.name-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.name-fields > div { min-width: 0; }
.registration-form .checkbox-label { align-items: flex-start; }
.registration-form input[type="radio"] { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--app-brand-red); flex: 0 0 auto; }
.registration-form .salutation-options .checkbox-label { min-height: 32px; align-items: center; }
.registration-form .salutation-options input[type="radio"] { margin: 0; }
.registration-form ul { padding-left: 20px; color: var(--app-error); }
@media (max-width: 480px) { .name-fields { grid-template-columns: 1fr; } }

button,
a {
    touch-action: manipulation;
}

a {
    color: var(--app-brand-red);
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 12px;
    left: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--app-accent-blue);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(calc(-100% - 24px));
    transition: transform 160ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.site-header {
    position: sticky;
    z-index: 10;
    top: 0;
    min-height: 73px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px clamp(18px, 4vw, 40px);
    border-bottom: 1px solid var(--app-border);
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 4px 20px rgb(13 22 37 / 3%);
    backdrop-filter: blur(12px);
}

.site-header form {
    grid-column: 3;
    margin: 0;
}

.signed-in-identity {
    min-width: 0;
    display: grid;
    gap: 2px;
    justify-self: end;
    margin: 0;
    text-align: right;
    overflow-wrap: anywhere;
}

.signed-in-identity span {
    color: var(--app-muted-text);
    font-size: 0.8125rem;
}

.signed-in-identity strong {
    color: var(--app-ink);
    font-size: 0.875rem;
    font-weight: 600;
}

.brand,
.auth-brand {
    display: flex;
    align-items: center;
    color: var(--app-ink);
}

.brand {
    min-width: 0;
    gap: 14px;
    text-decoration: none;
}

.brand img {
    width: 174px;
    max-width: 48vw;
    height: auto;
}

.brand-product,
.auth-product {
    border-left: 1px solid var(--app-border-strong);
    color: var(--app-charcoal);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.brand-product {
    padding-left: 14px;
}

.auth-brand {
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--app-border);
}

.auth-brand img {
    width: min(190px, 62%);
    height: auto;
}

.auth-product {
    padding-left: 16px;
    font-size: 1.05rem;
}

.page-shell {
    width: min(calc(100% - 32px), 720px);
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    align-items: center;
    margin: 0 auto;
    padding: clamp(28px, 6vw, 64px) 0;
}

.site-header + .page-shell {
    min-height: calc(100vh - 73px);
    min-height: calc(100dvh - 73px);
}

.page-shell--narrow {
    width: min(calc(100% - 32px), 440px);
}
.page-shell--registration { width: min(calc(100% - 32px), 600px); }
.registration-form .name-fields > div { display: grid; gap: 8px; }

.card {
    width: 100%;
    padding: clamp(24px, 5vw, 36px);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--app-brand-red);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--app-ink);
    font-size: clamp(1.75rem, 5vw, 2rem);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h2 {
    margin: 0 0 4px;
    color: var(--app-ink);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.35;
}

p {
    line-height: 1.55;
}

.lede {
    max-width: 62ch;
    margin: 8px 0 24px;
    color: var(--app-muted-text);
}

.lede strong {
    color: var(--app-ink);
}

.stacked-form,
.form-field {
    display: grid;
}

.stacked-form {
    gap: 18px;
}

.stacked-form > div,
.form-field {
    gap: 8px;
}

.registration-form {
    gap: 16px;
}

.registration-form > div {
    display: grid;
}

.registration-form .name-fields {
    gap: 16px;
}

.registration-form .registration-consents {
    gap: 12px;
    padding-top: 4px;
}

.registration-consents .checkbox-label {
    min-height: 32px;
}

.page-shell--registration .account-email {
    display: grid;
    gap: 4px;
    margin: 0 0 24px;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--app-surface-strong);
    overflow-wrap: anywhere;
}

.account-email > span {
    color: var(--app-muted-text);
    font-size: 0.8125rem;
}

.account-email > strong {
    color: var(--app-ink);
    font-size: 1rem;
}

label {
    color: var(--app-ink);
    font-size: 0.875rem;
    font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="text"],
select {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--app-field-outline);
    border-radius: 8px;
    outline: none;
    background: var(--app-surface);
    color: var(--app-ink);
    font-size: 1rem;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background-color 160ms ease;
}

input[type="email"]:hover,
input[type="password"]:hover,
input[type="text"]:hover,
select:hover {
    border-color: var(--app-muted-text);
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
select:focus {
    border-color: var(--app-accent-blue);
    box-shadow: 0 0 0 3px rgb(37 61 102 / 18%);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
    border-color: var(--app-error);
    background: var(--app-error-surface);
}

input[aria-invalid="true"]:focus,
select[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgb(154 27 27 / 16%);
}

input[name="_auth_code"],
input[name$="[code]"] {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
}

.checkbox-label {
    width: fit-content;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--app-muted-text);
    cursor: pointer;
    font-weight: 400;
}

.checkbox-label input {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--app-brand-red);
}

.checkbox-label input:focus-visible {
    outline: 3px solid rgb(37 61 102 / 22%);
    outline-offset: 2px;
}

.button {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid var(--app-brand-red);
    border-radius: 8px;
    background: var(--app-brand-red);
    color: #fff;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease,
        color 160ms ease;
}

.button:hover {
    border-color: var(--app-brand-red-hover);
    background: var(--app-brand-red-hover);
}

.button:active {
    border-color: var(--app-brand-red-active);
    background: var(--app-brand-red-active);
}

.button:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.button-secondary {
    border-color: var(--app-border-strong);
    background: var(--app-surface);
    color: var(--app-charcoal);
}

.button-secondary:hover {
    border-color: var(--app-brand-red);
    background: rgb(164 21 21 / 6%);
    color: var(--app-brand-red);
}

.button-secondary:active {
    background: rgb(164 21 21 / 11%);
}

.button-small {
    min-height: 44px;
    padding: 9px 15px;
    font-size: 0.875rem;
}

.stacked-form > .button,
.secondary-action .button {
    width: 100%;
}

.button:focus-visible,
a:focus-visible {
    outline: 3px solid rgb(37 61 102 / 24%);
    outline-offset: 3px;
}

.notice {
    margin: 0 0 20px;
    padding: 13px 15px;
    border: 1px solid;
    border-radius: 8px;
    font-size: 0.925rem;
    line-height: 1.5;
}

.notice.error {
    border-color: rgb(154 27 27 / 20%);
    background: var(--app-error-surface);
    color: var(--app-error);
}

.notice.success {
    border-color: rgb(11 107 46 / 20%);
    background: var(--app-success-surface);
    color: var(--app-success);
}

.form-error-message,
.form-error-icon {
    color: var(--app-error);
}

ul.form-error-message {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
    list-style: none;
}

.security-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding: 20px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface-panel);
}

.security-row p {
    margin: 0;
    color: var(--app-muted-text);
}

.status {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 4px 0 8px !important;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.status::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.status.enabled {
    background: var(--app-success-surface);
    color: var(--app-success);
}

.status.disabled {
    background: var(--app-warning-surface);
    color: var(--app-warning);
}

.steps {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 22px;
    color: var(--app-muted-text);
}

.steps li::marker {
    color: var(--app-brand-red);
    font-weight: 700;
}

.qr-code {
    width: fit-content;
    margin: 24px auto;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow-soft);
}

.qr-code img {
    display: block;
    max-width: 100%;
    height: auto;
}

.help,
.help-text {
    margin: 20px 0 0;
    color: var(--app-muted-text);
    font-size: 0.875rem;
}

.company-name {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.secondary-action {
    margin-top: 12px;
}

.consent-details {
    display: grid;
    grid-template-columns: 144px minmax(0, 1fr);
    margin: 24px 0;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
}

.consent-details dt,
.consent-details dd {
    padding: 12px 14px;
    border-bottom: 1px solid var(--app-border);
}

.consent-details dt {
    background: var(--app-surface-panel);
    color: var(--app-charcoal);
    font-size: 0.875rem;
    font-weight: 600;
}

.consent-details dd {
    min-width: 0;
    margin: 0;
}

.consent-details dt:last-of-type,
.consent-details dd:last-of-type {
    border-bottom: 0;
}

.consent-details ul {
    margin: 0;
    padding-left: 20px;
}

.breakable {
    overflow-wrap: anywhere;
}

.consent-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

code {
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--app-surface-strong);
    color: var(--app-charcoal);
    font: 500 0.875em/1.5 "Roboto Mono", "SFMono-Regular", Consolas, monospace;
}

@media (max-width: 36rem) {
    .site-header {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 14px;
        padding: 10px 16px;
    }

    .site-header form {
        grid-column: 2;
        grid-row: 1;
    }

    .signed-in-identity {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
        padding-top: 10px;
        border-top: 1px solid var(--app-border);
        text-align: left;
    }

    .brand {
        gap: 10px;
    }

    .brand img {
        width: 145px;
    }

    .brand-product {
        padding-left: 10px;
        font-size: 0.9rem;
    }

    .page-shell {
        width: min(calc(100% - 24px), 720px);
        padding: 20px 0;
    }

    .page-shell--narrow {
        width: min(calc(100% - 24px), 440px);
    }

    .card {
        padding: 24px;
    }

    .auth-brand {
        gap: 12px;
        margin-bottom: 24px;
        padding-bottom: 20px;
    }

    .auth-brand img {
        width: min(172px, 64%);
    }

    .auth-product {
        padding-left: 12px;
        font-size: 0.95rem;
    }

    .security-row {
        align-items: stretch;
        flex-direction: column;
        gap: 16px;
    }

    .security-row .button {
        width: 100%;
    }

    .consent-details {
        grid-template-columns: 1fr;
    }

    .consent-details dt {
        padding-bottom: 4px;
        border-bottom: 0;
    }

    .consent-details dd {
        padding-top: 4px;
    }

    .consent-details dt:last-of-type {
        border-bottom: 0;
    }

    .consent-actions {
        display: grid;
        grid-template-columns: 1fr;
    }
}

@media (max-width: 24rem) {
    .brand-product {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* Password login is an optional alternative to the email-code flow. */
.card details { margin-top: 28px; border-top: 1px solid var(--color-border, #d9dde4); padding-top: 20px; }
.card summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.card summary:focus-visible { outline: 2px solid #a4161a; outline-offset: 4px; }
.card details .stacked-form { margin-top: 20px; }

/* Six visual slots share one native input; the plain input remains usable without JS. */
.code-control { position: relative; cursor: text; }
.code-slots { display: none; }
.code-control[data-enhanced] .code-input {
    position: absolute; inset: 0; z-index: 1; height: 100%; min-height: 0;
    padding: 0; border: 0; border-radius: 0; background: transparent;
    color: transparent; -webkit-text-fill-color: transparent; caret-color: transparent;
    box-shadow: none; outline: 0;
}
.code-control[data-enhanced] .code-slots {
    position: relative; z-index: 2; display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; pointer-events: none;
}
.code-slot {
    display: grid; min-width: 0; height: 56px; place-items: center;
    border: 1px solid var(--app-field-outline); border-radius: 8px;
    background: var(--app-surface); color: var(--app-ink);
    font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.code-slot.is-filled { border-color: var(--app-muted-text); }
.code-slot.is-active { border-color: var(--app-accent-blue); box-shadow: 0 0 0 3px rgb(37 61 102 / 18%); }
.code-control:has([aria-invalid="true"]) .code-slot { border-color: var(--app-error); background: var(--app-error-surface); }
@media (max-width: 420px) { .code-control[data-enhanced] .code-slots { gap: 6px; } .code-slot { height: 48px; } }
