/* ==========================================================================
   Aiden Design System – component styles for the login flow (Razor Pages).
   Load after tokens.css. Every rule is scoped under .aiden-auth, so pages
   that do not use _AuthLayout (admin screens, consent, device, ...) are not
   affected. Values come from tokens.css; only geometry that has no token
   (control heights, icon sizes, panel widths) is written as a literal.
   ========================================================================== */


/* ---- Fonts (self-hosted, covered by font-src 'self') ---- */
@font-face { font-family: "Jost"; font-style: normal; font-weight: 300; font-display: swap; src: url("../../fonts/jost/jost-latin-300-normal.woff2") format("woff2"); }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 400; font-display: swap; src: url("../../fonts/jost/jost-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 500; font-display: swap; src: url("../../fonts/jost/jost-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 600; font-display: swap; src: url("../../fonts/jost/jost-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Jost"; font-style: normal; font-weight: 700; font-display: swap; src: url("../../fonts/jost/jost-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Material Symbols Outlined"; font-style: normal; font-weight: 400; font-display: block; src: url("../../fonts/material-symbols/material-symbols-outlined-latin-400-normal.woff2") format("woff2"); }

/* ---- Component-level tokens that tokens.json cannot hold ---- */
.aiden-auth {
    --ds-ring: 0 0 0 3px rgba(60, 82, 121, 0.35); /* border-focus at 35%; color-mix version below */
    --ds-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ds-dur: 120ms;
    --ds-control-h: 48px;
}

/* A custom property cannot fall back on its own, so the color-mix() ring is only
   set where it is supported. Older WebViews keep the rgba() ring above. */
@supports (color: color-mix(in srgb, red 50%, blue)) {
    .aiden-auth { --ds-ring: 0 0 0 3px color-mix(in srgb, var(--border-focus) 35%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
    .aiden-auth { --ds-dur: 0ms; }
}

/* ---- Base ---- */
.aiden-auth {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 100dvh;
    display: flex;
    flex-wrap: wrap;
    background: var(--surface-page);
    color: var(--text-body);
    font-family: var(--font-sans);
    font-size: var(--fs-small);
    font-weight: var(--fw-light);
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
}

.aiden-auth *,
.aiden-auth *::before,
.aiden-auth *::after { box-sizing: border-box; }

.aiden-auth h1, .aiden-auth h2, .aiden-auth h3, .aiden-auth h4 {
    font-family: var(--font-display);
    color: var(--text-strong);
}

.aiden-auth strong, .aiden-auth b { font-weight: var(--fw-semibold); color: var(--text-strong); }

.aiden-auth hr {
    border: 0;
    border-top: var(--bw-hair) solid var(--border-subtle);
    opacity: 1;
    margin: var(--space-4) 0;
}

/* ---- Icons (Material Symbols Outlined) ---- */
.aiden-auth .ds-icon {
    font-family: "Material Symbols Outlined";
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
    display: inline-block;
    vertical-align: middle;
    -webkit-font-feature-settings: "liga";
    font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Layout: brand panel + content
   ========================================================================== */
.aiden-auth .aa-brand {
    flex: 1 1 480px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-7);
    min-height: 280px;
    padding: var(--space-8) var(--page-margin) var(--space-7);
    background: var(--surface-inverse);
    color: var(--text-on-blue);
}

.aiden-auth .aa-brand__mark {
    position: absolute;
    right: -140px;
    bottom: -180px;
    height: 640px;
    width: auto;
    opacity: 0.08;
    pointer-events: none;
}

.aiden-auth .aa-brand__logo {
    position: relative;
    align-self: flex-start;
    height: 40px;
    width: auto;
}

.aiden-auth .aa-brand__claim {
    position: relative;
    max-width: 520px;
    margin: 0;
    color: var(--text-on-blue);
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-heading);
    letter-spacing: var(--ls-heading);
}

.aiden-auth .aa-brand__dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 6px;
    border-radius: var(--radius-dot);
    background: var(--brand-accent);
}

.aiden-auth .aa-content {
    flex: 999 1 560px;
    min-width: 0;
    display: flex;
    align-items: center;
    padding: var(--space-8) var(--page-margin);
}

.aiden-auth .aa-panel {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

/* Handheld: compact header instead of the full brand panel */
@media (max-width: 767.98px) {
    .aiden-auth { flex-direction: column; flex-wrap: nowrap; }

    .aiden-auth .aa-brand {
        flex: 0 0 auto;
        min-height: 0;
        padding: var(--space-6) var(--space-5);
        gap: 0;
    }

    .aiden-auth .aa-brand__mark { right: -60px; top: -40px; bottom: auto; height: 260px; }
    .aiden-auth .aa-brand__logo { height: 30px; }
    .aiden-auth .aa-brand__claim { display: none; }

    .aiden-auth .aa-content {
        flex: 1 1 auto;
        align-items: flex-start;
        padding: var(--space-6) var(--space-5) var(--space-5);
    }

    .aiden-auth .aa-panel { max-width: none; }
}

/* ==========================================================================
   Typography helpers
   ========================================================================== */
.aiden-auth .ds-h2 {
    margin: 0;
    color: var(--text-strong);
    font-family: var(--font-display);
    font-size: var(--fs-h3);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-heading);
    letter-spacing: var(--ls-heading);
}

@media (max-width: 767.98px) {
    .aiden-auth .ds-h2 { font-size: 1.75rem; }
}

/* Subtitle inside a page title (LoggedOut: "Logout <small>You are now logged out</small>") */
.aiden-auth .ds-h2 small {
    display: block;
    margin-top: var(--space-2);
    color: var(--text-body);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    font-weight: var(--fw-light);
    line-height: var(--lh-body);
    letter-spacing: 0;
}

.aiden-auth .ds-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    align-self: flex-start;
    color: var(--brand-primary);
    font-size: var(--fs-caption);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-eyebrow);
    text-transform: uppercase;
    text-decoration: none;
}

.aiden-auth .ds-text { margin: 0; max-width: var(--measure); }

.aiden-auth .ds-lead {
    margin: 0;
    color: var(--text-body);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    font-weight: var(--fw-light);
    line-height: var(--lh-body);
}
.aiden-auth .ds-text--muted { color: var(--text-muted); }

/* ---- Links ---- */
.aiden-auth .ds-link,
.aiden-auth .aa-panel a:not([class]) {
    color: var(--text-link);
    font-weight: var(--fw-medium);
    text-decoration: underline;
    text-underline-offset: 2px;
    border-radius: var(--radius-xs);
    transition: color var(--ds-dur) var(--ds-ease);
}

.aiden-auth .ds-link:hover,
.aiden-auth .aa-panel a:not([class]):hover { color: var(--action-bg-hover); }

/* ==========================================================================
   Focus: Royal Blue ring on every interactive element
   ========================================================================== */
.aiden-auth a:focus-visible,
.aiden-auth button:focus-visible,
.aiden-auth input:focus-visible,
.aiden-auth select:focus-visible,
.aiden-auth textarea:focus-visible,
.aiden-auth [tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--ds-ring);
}

/* ==========================================================================
   Buttons (.ds-btn) – used on <button> and <a>
   ========================================================================== */
.aiden-auth .ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--ds-control-h);
    padding: var(--space-3) var(--space-5);
    border: var(--bw-line) solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: var(--fs-small);
    font-weight: var(--fw-medium);
    line-height: var(--lh-snug);
    letter-spacing: var(--ls-label);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--ds-dur) var(--ds-ease), color var(--ds-dur) var(--ds-ease), border-color var(--ds-dur) var(--ds-ease);
}

.aiden-auth .ds-btn--block { width: 100%; }

.aiden-auth .ds-btn--primary {
    background: var(--action-bg);
    border-color: var(--action-bg);
    color: var(--action-fg);
}

.aiden-auth .ds-btn--primary:hover,
.aiden-auth .ds-btn--primary:active {
    background: var(--action-bg-hover);
    border-color: var(--action-bg-hover);
    color: var(--action-fg);
}

.aiden-auth .ds-btn--secondary {
    background: transparent;
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.aiden-auth .ds-btn--secondary:hover,
.aiden-auth .ds-btn--secondary:active {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--action-fg);
}

.aiden-auth .ds-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--brand-primary);
}

.aiden-auth .ds-btn--ghost:hover,
.aiden-auth .ds-btn--ghost:active {
    background: var(--surface-sunken);
    color: var(--brand-primary);
}

.aiden-auth .ds-btn:disabled,
.aiden-auth .ds-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.aiden-auth .ds-btn .ds-icon { font-size: 20px; }

/* "or" divider between primary and secondary actions */
.aiden-auth .ds-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-muted);
    font-size: var(--fs-caption);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-eyebrow);
    text-transform: uppercase;
}

.aiden-auth .ds-divider::before,
.aiden-auth .ds-divider::after {
    content: "";
    flex: 1 1 0;
    height: var(--bw-hair);
    background: var(--border-subtle);
}

/* ==========================================================================
   Form fields: label above input, helper and error text
   ========================================================================== */
.aiden-auth .ds-stack { display: flex; flex-direction: column; gap: var(--space-4); }

.aiden-auth .ds-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.aiden-auth .ds-label {
    margin: 0;
    color: var(--text-strong);
    font-size: var(--fs-small);
    font-weight: var(--fw-medium);
    line-height: var(--lh-snug);
}

.aiden-auth .ds-input {
    display: block;
    width: 100%;
    min-height: var(--ds-control-h);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-card);
    border: var(--bw-line) solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-strong);
    font-family: var(--font-sans);
    font-size: max(16px, var(--fs-small)); /* below 16px iOS zooms in on focus */
    font-weight: var(--fw-regular);
    line-height: var(--lh-snug);
    box-shadow: none;
    transition: border-color var(--ds-dur) var(--ds-ease), box-shadow var(--ds-dur) var(--ds-ease);
}

.aiden-auth .ds-input::placeholder { color: var(--text-muted); opacity: 1; }

.aiden-auth .ds-input:hover { border-color: var(--ink-60); }

.aiden-auth .ds-input:focus,
.aiden-auth .ds-input:focus-visible {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--ds-ring);
}

.aiden-auth .ds-input:disabled {
    background: var(--surface-sunken);
    border-color: var(--border-subtle);
    color: var(--text-body);
    cursor: not-allowed;
    opacity: 1;
}

/* Error state: ASP.NET adds .input-validation-error to invalid inputs */
.aiden-auth .ds-input.input-validation-error,
.aiden-auth .ds-input.is-invalid {
    border-color: var(--status-error);
}

.aiden-auth .ds-input.input-validation-error:focus,
.aiden-auth .ds-input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(214, 31, 38, 0.25);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-error) 25%, transparent);
}

.aiden-auth .ds-helper {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--fs-caption);
    line-height: var(--lh-snug);
}

.aiden-auth .field-validation-error,
.aiden-auth .ds-error {
    display: block;
    margin: 0;
    color: var(--status-error);
    font-size: var(--fs-caption);
    font-weight: var(--fw-medium);
    line-height: var(--lh-snug);
}

/* ==========================================================================
   Switch – reuses the existing markup:
   <label class="checkbox ds-switch"><input type="checkbox"><div class="switch"></div><span>…</span></label>
   ========================================================================== */
.aiden-auth .ds-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    color: var(--text-body);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    cursor: pointer;
}

.aiden-auth .ds-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
}

.aiden-auth .ds-switch .switch {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 24px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--ink-40);
    background-image: none;
    transition: background-color var(--ds-dur) var(--ds-ease);
}

.aiden-auth .ds-switch .switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-dot);
    background: var(--surface-card);
    box-shadow: var(--shadow-xs);
    transition: transform var(--ds-dur) var(--ds-ease);
}

.aiden-auth .ds-switch input:checked ~ .switch {
    border: 0;
    background: var(--brand-primary);
}

/* left/top/background are repeated so the legacy .checkbox-switch rules (style.css) do not move the thumb */
.aiden-auth .ds-switch input:checked ~ .switch::after {
    left: 3px;
    top: 3px;
    background: var(--surface-card);
    transform: translateX(20px);
}

/* Text label next to a switch when it is a separate <label> (2FA "Remember this machine") */
.aiden-auth .ds-switch__text {
    margin: 0;
    color: var(--text-body);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    cursor: pointer;
}

.aiden-auth .ds-switch input:focus-visible ~ .switch { box-shadow: var(--ds-ring); }

.aiden-auth .ds-switch .label-unchecked { opacity: 1; }

/* ==========================================================================
   Checkbox – <label class="ds-check"><input type="checkbox" class="ds-check__input"> text</label>
   ========================================================================== */
.aiden-auth .ds-check {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    color: var(--text-body);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    cursor: pointer;
}

.aiden-auth .ds-check__input,
.aiden-auth .ds-check input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin: 0;
    border: var(--bw-line) solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-card) no-repeat center / 14px 14px;
    cursor: pointer;
    transition: background-color var(--ds-dur) var(--ds-ease), border-color var(--ds-dur) var(--ds-ease);
}

.aiden-auth .ds-check__input:checked,
.aiden-auth .ds-check input[type="checkbox"]:checked {
    border-color: var(--brand-primary);
    background-color: var(--brand-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.5l3 3 6-7' stroke='%23F5F6F2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Alerts – 3px accent bar on the left in the variant colour
   ========================================================================== */
.aiden-auth .ds-alert {
    position: relative;
    margin: 0;
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-5);
    border: var(--bw-hair) solid var(--border-subtle);
    border-left: var(--bw-accent) solid var(--status-info);
    border-radius: var(--radius-md);
    background: var(--surface-card);
    color: var(--text-strong);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    line-height: var(--lh-snug);
}

.aiden-auth .ds-alert > strong:first-child,
.aiden-auth .ds-alert__title {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: var(--fw-semibold);
}

/* A heading used as alert title (Lockout) keeps the alert title size */
.aiden-auth .ds-alert h1.ds-alert__title,
.aiden-auth .ds-alert h2.ds-alert__title {
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-snug);
    letter-spacing: 0;
}

/* A status message rendered as <h4> inside an alert (ConfirmEmail) reads as alert text */
.aiden-auth .ds-alert h4 {
    margin: 0;
    color: var(--text-strong);
    font-family: var(--font-sans);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    line-height: var(--lh-snug);
}

.aiden-auth .ds-alert ul { margin: 0; padding-left: var(--space-5); }
.aiden-auth .ds-alert p:last-child { margin-bottom: 0; }

.aiden-auth .ds-alert--info { border-left-color: var(--status-info); }

.aiden-auth .ds-alert--success {
    border-color: var(--lime-40);
    border-left-color: var(--status-success);
    background: var(--lime-20);
}

.aiden-auth .ds-alert--error {
    border-color: rgba(214, 31, 38, 0.3);
    border-color: color-mix(in srgb, var(--status-error) 30%, transparent);
    border-left-color: var(--status-error);
    background: var(--surface-card);
}

.aiden-auth .ds-alert--error > strong:first-child,
.aiden-auth .ds-alert--error .ds-alert__title { color: var(--status-error); }

/* Inline validation summary (<div asp-validation-summary class="ds-summary">):
   ASP.NET toggles validation-summary-valid / -errors; only the error state is shown. */
.aiden-auth .ds-summary.validation-summary-valid { display: none; }

.aiden-auth .ds-summary.validation-summary-errors {
    margin: 0;
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-5);
    border: var(--bw-hair) solid rgba(214, 31, 38, 0.3);
    border: var(--bw-hair) solid color-mix(in srgb, var(--status-error) 30%, transparent);
    border-left: var(--bw-accent) solid var(--status-error);
    border-radius: var(--radius-md);
    background: var(--surface-card);
    color: var(--text-strong);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    line-height: var(--lh-snug);
}

.aiden-auth .ds-summary ul { margin: 0; padding-left: var(--space-5); }

/* Bootstrap .alert inside the auth layout takes the DS look */
.aiden-auth .ds-alert.alert { color: var(--text-strong); }
.aiden-auth .ds-alert.alert-danger { background: var(--surface-card); }

/* ==========================================================================
   Selection list (Tenants / Stores, AIDENADP-5113)
   Header with title + small Logout button, search field, list of tiles.
   The page script toggles .is-selected on tiles and .is-visible on the
   empty state; those classes are styled here.
   ========================================================================== */
.aiden-auth .ds-btn--sm {
    min-height: 36px;
    padding: var(--space-2) var(--space-4);
}

.aiden-auth .ds-select-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.aiden-auth .ds-select-head .ds-h2 { min-width: 0; overflow-wrap: anywhere; }
.aiden-auth .ds-select-head .ds-btn { flex: 0 0 auto; }

.aiden-auth .ds-select-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
}

.aiden-auth .ds-select-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
}

.aiden-auth .ds-select-meta .ds-eyebrow { margin: 0; line-height: var(--lh-snug); }

.aiden-auth .ds-select-count {
    color: var(--text-muted);
    font-size: var(--fs-caption);
    font-weight: var(--fw-medium);
    white-space: nowrap;
}

/* Search: input with a leading icon */
.aiden-auth .ds-search {
    position: relative;
    display: block;
    margin: 0;
}

.aiden-auth .ds-search .ds-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.aiden-auth .ds-search .ds-input { padding-left: calc(var(--space-3) + 20px + var(--space-2)); }

/* List: scrolls inside its own area on tablet/desktop */
.aiden-auth .ds-select-region {
    min-width: 0;
    max-height: min(50vh, 440px);
    overflow-y: auto;
    padding: 3px; /* room for the focus ring */
    margin: -3px;
}

.aiden-auth .ds-select-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.aiden-auth .ds-select-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    width: 100%;
    min-height: 56px;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-card);
    border: var(--bw-line) solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-strong);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    font-weight: var(--fw-regular);
    line-height: var(--lh-snug);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--ds-dur) var(--ds-ease), background-color var(--ds-dur) var(--ds-ease);
}

.aiden-auth .ds-select-item > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.aiden-auth .ds-select-item .ds-icon { flex: 0 0 auto; color: var(--text-muted); }

.aiden-auth .ds-select-item:hover,
.aiden-auth .ds-select-item:focus-visible,
.aiden-auth .ds-select-item.is-selected {
    border-color: var(--brand-accent);
    background: var(--lime-20);
}

.aiden-auth .ds-select-item:hover .ds-icon,
.aiden-auth .ds-select-item.is-selected .ds-icon { color: var(--brand-primary); }

/* Empty state: hidden until the script adds .is-visible */
.aiden-auth .ds-select-empty { display: none; }
.aiden-auth .ds-select-empty.is-visible { display: block; }

/* Handheld: no nested scroll, the page scrolls */
@media (max-width: 767.98px) {
    .aiden-auth .ds-select-region { max-height: none; overflow: visible; }
}

/* Compact mode (see below): smaller tiles */
@media (max-width: 767.98px) and (max-height: 700px) {
    .aiden-auth .ds-select-item { min-height: 44px; padding: var(--space-2) var(--space-3); }
    .aiden-auth .ds-select-body { gap: var(--space-2); }
}

/* ==========================================================================
   Compact mode: small and short screens (handhelds in landscape, 320x500 etc.)
   Only spacing and control size change; markup and behaviour stay the same.
   The pages use Bootstrap gap utilities (which are !important), so the
   overrides for those are !important as well, scoped to .aa-panel.
   ========================================================================== */
@media (max-width: 767.98px) and (max-height: 700px) {
    .aiden-auth { --ds-control-h: 40px; }

    .aiden-auth .aa-brand { padding: var(--space-3) var(--space-5); }
    .aiden-auth .aa-brand__logo { height: 22px; }
    .aiden-auth .aa-brand__mark { top: -30px; right: -40px; height: 160px; }

    .aiden-auth .aa-content { padding: var(--space-3) var(--space-5) var(--space-2); }
    .aiden-auth .aa-panel { gap: var(--space-3); }

    .aiden-auth .ds-h2 { font-size: 1.5rem; }

    .aiden-auth .aa-panel .gap-4 { gap: var(--space-3) !important; }
    .aiden-auth .aa-panel .gap-3 { gap: var(--space-2) !important; }
    .aiden-auth .aa-panel .gap-2 { gap: var(--space-1) !important; }

    .aiden-auth .ds-stack { gap: var(--space-2); }
    .aiden-auth .ds-field { gap: var(--space-1); }

    .aiden-auth .ds-input,
    .aiden-auth .ds-btn {
        padding-top: var(--space-2);
        padding-bottom: var(--space-2);
    }

    .aiden-auth .ds-divider { line-height: 1; }
}

/* ==========================================================================
   Auth pages: Login, Company/Store selection, Forgot/Reset password, ...
   Scoped through .aa-panel (rendered by _AuthLayout), so every page on that
   layout gets the card, brand panel, fields, buttons and dark mode below.
   Presentation only: ids, names, forms and page scripts are not touched.
   Browsers without :has() get the shared auth styling above.
   The entrance animation only runs when .aa-login carries data-animate.
   The page sets it on a first load and leaves it off after a failed login,
   so a retry does not replay the whole intro.
   Translucent colours are written as rgba() so they also work on older
   Android WebViews without color-mix() support.
   ========================================================================== */

/* ---- Login-only tokens. TODO: move into tokens.json (e.g. blue-110 / blue-130). ---- */
.aiden-auth:has(.aa-panel) {
    --aa-blue-110: #46608c;                 /* light end of the brand panel gradient */
    --aa-blue-130: #26344f;                 /* deep end of the brand panel gradient */
    --aa-shadow-rgb: 38, 52, 79;            /* aa-blue-130 as channels, for shadows */
    --aa-lift: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 1px 2px rgba(var(--aa-shadow-rgb), 0.2), 0 6px 14px -6px rgba(var(--aa-shadow-rgb), 0.45);
    --aa-lift-hover: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 1px 2px rgba(var(--aa-shadow-rgb), 0.2), 0 10px 20px -8px rgba(var(--aa-shadow-rgb), 0.5);
    --aa-lift-press: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 1px rgba(var(--aa-shadow-rgb), 0.25);
    /* Focus: the border thickens to 2px in its own colour (1px border + 1px solid ring) */
    --aa-field-ring: 0 0 0 1px var(--border-focus), 0 6px 16px -8px rgba(var(--aa-shadow-rgb), 0.35);
}

/* ==========================================================================
   Layout: brand panel and form side by side from tablet width up.
   Below that the brand panel becomes a bar on top; the form stays a centred
   card, except on really small screens (narrower than 380px or lower than
   560px), where it runs flat and full width to save room.
   ========================================================================== */
.aiden-auth:has(.aa-panel) .aa-content { justify-content: center; }

.aiden-auth:has(.aa-panel) .aa-panel {
    max-width: 416px;
    gap: var(--space-6);
}

@media (min-width: 768px) {
    .aiden-auth:has(.aa-panel) { flex-wrap: nowrap; }

    .aiden-auth:has(.aa-panel) .aa-brand {
        flex: 0 0 clamp(300px, 36vw, 560px);
        padding: var(--space-7) clamp(var(--space-6), 4.5vw, var(--space-8));
    }

    /* "Technology / made human." on two balanced lines at every width */
    .aiden-auth:has(.aa-panel) .aa-brand__claim {
        max-width: 7.2em;
        font-size: clamp(1.75rem, 2.4vw + 0.5rem, var(--fs-h2));
    }

    /* Watermark as tall as the panel, so the dot of the "A" sits mid-panel, clear of logo and claim */
    .aiden-auth:has(.aa-panel) .aa-brand__mark {
        top: 0;
        right: -35%;
        bottom: auto;
        height: 100%;
    }

    .aiden-auth:has(.aa-panel) .aa-content {
        flex: 1 1 auto;
        padding: var(--space-7) clamp(var(--space-6), 5vw, var(--space-8));
    }
}

/* ---- Large screens: scale the whole login page in steps ----
   Without this the card and the brand panel keep their laptop size on 2K/4K screens.
   zoom scales every length (type, radius, shadows, spacing) evenly; fixed steps keep
   hairlines on whole pixels. Both width and height must be large, so a wide but low
   window is not blown up. Viewport units inside a zoomed element are zoomed as well,
   hence the division by --aa-zoom wherever vw/dvh decide a size. */
.aiden-auth:has(.aa-panel) {
    --aa-zoom: 1;
    min-height: calc(100dvh / var(--aa-zoom));
}

@media (min-width: 2400px) and (min-height: 1300px) {
    .aiden-auth:has(.aa-panel) { --aa-zoom: 1.25; zoom: 1.25; }
}

@media (min-width: 3200px) and (min-height: 1800px) {
    .aiden-auth:has(.aa-panel) { --aa-zoom: 1.5; zoom: 1.5; }
}

/* Brand panel keeps about 36% of the width on wide screens, up to about 30% on 4K
   (also in a wide but low window, where it is not zoomed) */
@media (min-width: 2400px) {
    .aiden-auth:has(.aa-panel) .aa-brand {
        flex-basis: clamp(300px, calc(36vw / var(--aa-zoom)), 760px);
    }
}

/* ---- The form as a floating card (all sizes except really small screens) ---- */
@media (min-width: 380px) and (min-height: 560px) {
    .aiden-auth:has(.aa-panel) .aa-panel {
        position: relative;
        overflow: hidden; /* clips the stripe to the rounded corners */
        max-width: 464px;
        padding: var(--space-7) var(--space-6) var(--space-6);
        border-radius: 20px;
        background: var(--surface-card);
        /* hairline as a shadow, so it follows the radius exactly; then contact, near and far shadow */
        box-shadow:
            0 0 0 1px rgba(var(--aa-shadow-rgb), 0.08),
            0 1px 2px rgba(var(--aa-shadow-rgb), 0.06),
            0 12px 24px -12px rgba(var(--aa-shadow-rgb), 0.14),
            0 32px 64px -24px rgba(var(--aa-shadow-rgb), 0.22);
    }

    /* Brand stripe flush along the top edge, cut off by the card corners */
    .aiden-auth:has(.aa-panel) .aa-panel::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: linear-gradient(90deg, var(--aiden-royal-blue), var(--aiden-limelight));
    }
}

/* Under the brand bar: a slightly tighter card */
@media (min-width: 380px) and (min-height: 560px) and (max-width: 767.98px) {
    .aiden-auth:has(.aa-panel) .aa-panel {
        padding: var(--space-6) var(--space-5) var(--space-5);
        border-radius: 16px;
    }
}

/* Short handhelds that still get the card: tighter again */
@media (min-width: 380px) and (min-height: 560px) and (max-width: 767.98px) and (max-height: 700px) {
    .aiden-auth:has(.aa-panel) .aa-panel { padding: var(--space-5) var(--space-4) var(--space-4); }
}

/* ==========================================================================
   Brand panel: flat Aiden Royal Blue with a fine dot grid
   ========================================================================== */
.aiden-auth:has(.aa-panel) .aa-brand {
    isolation: isolate;
    background: var(--aiden-royal-blue);
}

/* Dot grid, fading out towards the claim */
.aiden-auth:has(.aa-panel) .aa-brand::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    background-image: radial-gradient(rgba(245, 246, 242, 0.22) 1px, transparent 1.5px);
    background-size: 22px 22px;
    -webkit-mask-image: linear-gradient(170deg, #000 0%, transparent 65%);
    mask-image: linear-gradient(170deg, #000 0%, transparent 65%);
    pointer-events: none;
}

/* Flat white: the limelight dot of the mark would otherwise turn olive at this opacity */
.aiden-auth:has(.aa-panel) .aa-brand__mark {
    filter: brightness(0) invert(1);
    opacity: 0.06;
    animation: aa-float 14s ease-in-out infinite alternate;
}

/* The brand dot breathes */
.aiden-auth:has(.aa-panel) .aa-brand__dot {
    position: relative;
    box-shadow: 0 0 10px rgba(191, 215, 48, 0.45);
}

.aiden-auth:has(.aa-panel) .aa-brand__dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius-dot);
    border: 2px solid var(--aiden-limelight);
    animation: aa-ping 2.8s cubic-bezier(0, 0, 0.2, 1) 1.2s infinite;
}

/* ---- Content side: soft light behind the card ---- */
.aiden-auth:has(.aa-panel) .aa-content {
    background:
        radial-gradient(60% 50% at 50% 45%, rgba(216, 220, 228, 0.7) 0%, transparent 70%),
        var(--surface-page);
}

/* ==========================================================================
   Header: title dot and client label
   ========================================================================== */
.aiden-auth .aa-login__title::after {
    content: "";
    display: inline-block;
    width: 0.2em;
    height: 0.2em;
    margin-left: 0.08em;
    border-radius: var(--radius-dot);
    background: var(--brand-accent);
}

/* "CLIENT  Name  (i)"; a click shows the client description */
.aiden-auth .aa-client {
    align-items: baseline;
    gap: var(--space-2);
    max-width: 100%;
    padding: 0;
    border-radius: var(--radius-xs);
    color: var(--text-strong);
    letter-spacing: 0;
    text-transform: none;
}

.aiden-auth .aa-client:hover { color: var(--text-strong); }
.aiden-auth .aa-client:hover .aa-client__info,
.aiden-auth .aa-client[aria-expanded="true"] .aa-client__info { color: var(--brand-primary); }

/* ink-80 instead of text-muted: ink-60 is only 3.6:1 at this size */
.aiden-auth .aa-client__label {
    flex: 0 0 auto;
    margin-right: calc(-1 * var(--ls-eyebrow)); /* tracking adds space after the last letter */
    color: var(--ink-80);
    font-size: 0.6875rem;
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-eyebrow);
    text-transform: uppercase;
}

.aiden-auth .aa-client__name {
    min-width: 0;
    overflow: hidden;
    color: var(--text-strong);
    font-weight: var(--fw-medium);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aiden-auth .aa-client__info {
    flex: 0 0 auto;
    align-self: center;
    color: var(--text-muted);
    font-size: 16px;
    transition: color var(--ds-dur) var(--ds-ease);
}

.aiden-auth .aa-client__description {
    padding-left: var(--space-3);
    border-left: var(--bw-line) solid var(--brand-accent);
    font-size: var(--fs-small);
    line-height: var(--lh-snug);
}

/* ==========================================================================
   Fields
   ========================================================================== */
.aiden-auth:has(.aa-panel) .ds-label { transition: color var(--ds-dur) var(--ds-ease); }
.aiden-auth:has(.aa-panel) .ds-field:focus-within .ds-label { color: var(--brand-primary); }

/* ink-60 border: at least 3:1 against both the white card and the sunken fill (WCAG 1.4.11) */
.aiden-auth:has(.aa-panel) .ds-input {
    border-width: var(--bw-hair);
    border-color: var(--ink-60);
    background: var(--grey-500);
    padding-left: calc(var(--space-4) + 1px);
}

.aiden-auth:has(.aa-panel) .ds-input:hover {
    border-color: var(--blue-80);
    background: var(--surface-card);
}

.aiden-auth:has(.aa-panel) .ds-input:focus,
.aiden-auth:has(.aa-panel) .ds-input:focus-visible {
    border-color: var(--border-focus);
    background: var(--surface-card);
    box-shadow: var(--aa-field-ring);
}

/* Error state stays visible on top of the login field styling */
.aiden-auth:has(.aa-panel) .ds-input.input-validation-error,
.aiden-auth:has(.aa-panel) .ds-input.is-invalid,
.aiden-auth:has(.aa-panel) .ds-input[aria-invalid="true"] {
    border-color: var(--status-error);
}

.aiden-auth:has(.aa-panel) .ds-input.input-validation-error:focus,
.aiden-auth:has(.aa-panel) .ds-input.is-invalid:focus,
.aiden-auth:has(.aa-panel) .ds-input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 1px var(--status-error), 0 6px 16px -8px rgba(var(--aa-shadow-rgb), 0.35);
}

/* Autofill: keep the field colours and dark text */
.aiden-auth:has(.aa-panel) .ds-input:-webkit-autofill {
    -webkit-text-fill-color: var(--text-strong);
    caret-color: var(--text-strong);
    box-shadow: inset 0 0 0 100px var(--grey-500);
}

.aiden-auth:has(.aa-panel) .ds-input:-webkit-autofill:hover {
    box-shadow: inset 0 0 0 100px var(--surface-card);
}

.aiden-auth:has(.aa-panel) .ds-input:-webkit-autofill:focus {
    box-shadow: inset 0 0 0 100px var(--surface-card), var(--aa-field-ring);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.aiden-auth:has(.aa-panel) .ds-btn {
    transition:
        background-color var(--ds-dur) var(--ds-ease),
        color var(--ds-dur) var(--ds-ease),
        border-color 200ms var(--ds-ease),
        transform 200ms var(--ds-ease),
        box-shadow 200ms var(--ds-ease);
}

.aiden-auth:has(.aa-panel) .ds-btn:active { transform: translateY(1px); }

/* Login: solid Aiden Royal Blue (action tokens), a little darker on hover and press */
.aiden-auth:has(.aa-panel) .ds-btn--primary {
    border: 0;
    background: var(--action-bg);
    box-shadow: var(--aa-lift);
}

.aiden-auth:has(.aa-panel) .ds-btn--primary:hover {
    background: var(--action-bg-hover);
}

.aiden-auth:has(.aa-panel) .ds-btn--primary:active {
    background: var(--action-bg-active);
    transform: translateY(1px);
    box-shadow: var(--aa-lift-press);
}

/* Microsoft Entra: quiet outline; hover and press add a light grey fill */
.aiden-auth:has(.aa-panel) .ds-btn--secondary {
    border-width: var(--bw-hair);
    border-color: var(--border-subtle);
    background: var(--surface-card);
    color: var(--text-strong);
}

.aiden-auth:has(.aa-panel) .aa-ms-logo { flex: 0 0 auto; display: block; }

.aiden-auth:has(.aa-panel) .ds-btn--secondary:hover {
    border-color: var(--blue-40);
    background: var(--grey-500);
    color: var(--text-strong);
}

.aiden-auth:has(.aa-panel) .ds-btn--secondary:active {
    border-color: var(--blue-60);
    background: var(--grey-400);
}

/* Keyboard focus. Placed after the hover/active rules (same specificity),
   so the decorative shadows never hide the focus ring. */
.aiden-auth:has(.aa-panel) .ds-btn:focus-visible { box-shadow: var(--ds-ring); }
.aiden-auth:has(.aa-panel) .ds-btn--primary:focus-visible { box-shadow: var(--ds-ring), var(--aa-lift); }

/* "or" divider: ink-80 for AA contrast at caption size */
.aiden-auth:has(.aa-panel) .ds-divider { color: var(--ink-80); }
.aiden-auth:has(.aa-panel) .ds-divider::after { margin-left: calc(-1 * var(--ls-eyebrow)); } /* optical centre */

/* Field rhythm: more air between fields than between a label and its field */
.aiden-auth:has(.aa-panel) .ds-stack { gap: var(--space-5); }

/* Error alert: uniform hairline with an inset accent bar, so the bar does not
   taper in the rounded corner; a faint tint; a single message without bullet */
.aiden-auth:has(.aa-panel) .ds-alert--error,
.aiden-auth:has(.aa-panel) .ds-summary.validation-summary-errors {
    border: var(--bw-hair) solid rgba(214, 31, 38, 0.28);
    background: rgba(214, 31, 38, 0.04);
    box-shadow: inset 3px 0 0 var(--status-error);
}

.aiden-auth:has(.aa-panel) .ds-alert--error ul { padding-left: 0; list-style: none; }

/* "Forgot your password?" reads as a quiet secondary link */
.aiden-auth:has(.aa-panel) #forgot-password {
    color: var(--text-body);
    font-weight: var(--fw-regular);
    text-decoration-color: var(--border-strong);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color var(--ds-dur) var(--ds-ease), text-decoration-color var(--ds-dur) var(--ds-ease);
}

.aiden-auth:has(.aa-panel) #forgot-password:hover {
    color: var(--text-link);
    text-decoration-color: currentColor;
}

/* ==========================================================================
   Entrance (first load only, see data-animate above)
   The card fades and the rows rise. Containers that hold animated rows
   (the form, the field stack) do not move themselves, so offsets never add up.
   ========================================================================== */
.aiden-auth:has(.aa-login[data-animate]) .aa-brand__logo { animation: aa-fade 700ms var(--ds-ease) both; }
.aiden-auth:has(.aa-login[data-animate]) .aa-brand__claim { animation: aa-rise 900ms var(--ds-ease) 150ms both; }

@media (min-width: 380px) and (min-height: 560px) {
    .aiden-auth:has(.aa-login[data-animate]) .aa-panel { animation: aa-fade 500ms var(--ds-ease) both; }
}

.aiden-auth:has(.aa-login[data-animate]) .aa-panel > :not(form),
.aiden-auth:has(.aa-login[data-animate]) .aa-panel form > :not([type="hidden"]):not(.ds-stack),
.aiden-auth:has(.aa-login[data-animate]) .aa-panel .ds-stack > * {
    animation: aa-rise 600ms var(--ds-ease) both;
}

.aiden-auth:has(.aa-login[data-animate]) .aa-panel > :nth-child(1) { animation-delay: 120ms; }
.aiden-auth:has(.aa-login[data-animate]) .aa-panel > :nth-child(2) { animation-delay: 180ms; }
.aiden-auth:has(.aa-login[data-animate]) .aa-panel .ds-stack > :nth-child(1) { animation-delay: 220ms; }
.aiden-auth:has(.aa-login[data-animate]) .aa-panel .ds-stack > :nth-child(2) { animation-delay: 280ms; }
.aiden-auth:has(.aa-login[data-animate]) .aa-panel .ds-stack > :nth-child(3) { animation-delay: 340ms; }
.aiden-auth:has(.aa-login[data-animate]) .aa-panel form > :nth-child(3) { animation-delay: 400ms; }
.aiden-auth:has(.aa-login[data-animate]) .aa-panel form > :nth-child(4) { animation-delay: 460ms; }
.aiden-auth:has(.aa-login[data-animate]) .aa-panel form > :nth-child(5) { animation-delay: 520ms; }

/* ---- Keyframes ---- */
@keyframes aa-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes aa-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes aa-float { from { transform: translateY(0); } to { transform: translateY(-18px); } }
@keyframes aa-ping { 0% { transform: scale(1); opacity: 0.8; } 80%, 100% { transform: scale(2.6); opacity: 0; } }

/* ---- Reduced motion: no animation and no lift/press movement ---- */
@media (prefers-reduced-motion: reduce) {
    .aiden-auth:has(.aa-panel) *,
    .aiden-auth:has(.aa-panel) *::before,
    .aiden-auth:has(.aa-panel) *::after {
        animation: none !important;
    }


    .aiden-auth:has(.aa-panel) .ds-btn:hover,
    .aiden-auth:has(.aa-panel) .ds-btn:active { transform: none; }
}

/* ---- Compact mode (small, short screens): keep the tighter rhythm ---- */
@media (max-width: 767.98px) and (max-height: 700px) {
    .aiden-auth:has(.aa-panel) .aa-panel { gap: var(--space-3); }
    .aiden-auth:has(.aa-panel) .ds-stack { gap: var(--space-3); }
}

/* ---- Low screens (under 515px high): client label to the right of "Login" ----
   The client wrapper is dissolved (display: contents), so its link and its
   description become items of the header row. The link sits beside the title on
   the title's baseline; the description, when opened, takes a full row below.
   !important is needed against the Bootstrap utility classes in the markup. */
@media (max-height: 514.98px) {
    .aiden-auth .aa-login {
        flex-direction: row !important;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: var(--space-4);
    }

    .aiden-auth .aa-login > div:has(> .aa-client) { display: contents !important; }

    .aiden-auth .aa-login__title { order: 1; flex: 0 0 auto; margin: 0; }

    .aiden-auth .aa-login .aa-client {
        order: 2;
        flex: 0 1 auto;
        min-width: 0;
        margin-left: auto;
    }

    .aiden-auth .aa-login #collapseDescription { order: 3; flex: 1 0 100%; }
}

/* ==========================================================================
   Selection list (Tenants / Stores): tiles in the same quiet style as the
   Microsoft Entra button; the chevron turns blue on hover, a press or the
   chosen tile gets a slightly darker fill.
   ========================================================================== */
.aiden-auth:has(.aa-panel) .ds-select-item {
    border-width: var(--bw-hair);
    border-color: var(--border-subtle);
    background: var(--surface-card);
}

.aiden-auth:has(.aa-panel) .ds-select-item:hover {
    border-color: var(--blue-40);
    background: var(--grey-500);
}

.aiden-auth:has(.aa-panel) .ds-select-item:active,
.aiden-auth:has(.aa-panel) .ds-select-item.is-selected {
    border-color: var(--blue-60);
    background: var(--grey-400);
}

.aiden-auth:has(.aa-panel) .ds-select-item:focus-visible {
    outline: none;
    border-color: var(--border-focus);
    background: var(--surface-card);
    box-shadow: var(--ds-ring);
}

.aiden-auth:has(.aa-panel) .ds-select-item:hover .ds-icon,
.aiden-auth:has(.aa-panel) .ds-select-item:focus-visible .ds-icon,
.aiden-auth:has(.aa-panel) .ds-select-item.is-selected .ds-icon { color: var(--brand-primary); }

/* Body text on the auth pages (intros, confirmations): regular weight at 16px,
   the light 300 weight reads too thin at small sizes. Muted text keeps its own style. */
.aiden-auth:has(.aa-panel) .ds-text:not(.ds-text--muted) {
    color: var(--text-body);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    line-height: var(--lh-body);
}

/* Alerts that carry a sentence or a heading: same type as body text */
.aiden-auth:has(.aa-panel) .ds-alert .ds-text,
.aiden-auth:has(.aa-panel) .ds-alert h4 {
    margin: 0;
    color: var(--text-strong);
    font-family: var(--font-sans);
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    line-height: var(--lh-snug);
}

/* Search field: keep room for the leading icon (the field rule above resets padding-left) */
.aiden-auth:has(.aa-panel) .ds-search .ds-input { padding-left: calc(var(--space-3) + 20px + var(--space-2) + 1px); }

/* List height from the viewport: corrected for the large-screen zoom */
@media (min-width: 768px) {
    .aiden-auth:has(.aa-panel) .ds-select-region {
        max-height: min(calc(50vh / var(--aa-zoom, 1)), 440px);
    }
}

/* ==========================================================================
   Dark mode: follows the operating system (prefers-color-scheme).
   tokens.json has no dark values yet; these are derived from the light palette:
   neutrals become navy greys in the Royal Blue hue, text becomes off-white, and
   blues used as text or focus get lighter so they keep AA contrast on dark.
   The card stripe keeps its exact brand colours; the brand panel is muted so it does not glare.
   data-theme="light" or "dark" on <html> overrides the system setting.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        /* Neutral ramps, inverted: 500 is the lightest fill in light mode, here the raised fill */
        --ink-100: #eceee9;
        --ink-80: #aab2bf;   /* 7.3:1 on the card */
        --ink-60: #737d8e;   /* field border: 3.7:1 on the card, 3.2:1 on the field fill */
        --ink-40: #566174;
        --ink-20: #3a4454;
        --grey-100: #445166;
        --grey-200: #3a4659;
        --grey-300: #323d4f;
        --grey-400: #2c3748;
        --grey-500: #252f3f;
        --blue-80: #8a9bb8;
        --blue-60: #7487a8;
        --blue-40: #5a6a85;
        --blue-20: #34405a;

        --surface-page: #131922;
        --surface-card: #1c2431;
        --surface-sunken: #252f3f;
        --text-strong: #eceee9;   /* 13.4:1 on the card */
        --text-body: #c5cbd4;
        --text-muted: #98a1af;    /* 6.0:1 on the card */
        --text-link: #9fb2d6;
        --brand-primary: #9fb2d6; /* Royal Blue lightened, for text and icons on dark */
        --border-subtle: #343f52;
        --border-strong: #566174;
        --border-focus: #9fb2d6;

        /* Login button: exact Royal Blue (off-white text 7.9:1); hover lightens, as usual on dark */
        --action-bg: #3c5279;
        --action-bg-hover: #46608c;
        --action-bg-active: #324465;
        --surface-inverse: #25334a; /* brand panel: Royal Blue muted towards the page (45%) */
        --action-fg: #f5f6f2;

        --status-error: #ff6b70;  /* Blaze Red lightened: 5.6:1 on the card */
        --status-info: #9fb2d6;
        --status-success: #a3c93a;

        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
    }

    :root:not([data-theme="light"]) .aiden-auth {
        --ds-ring: 0 0 0 3px rgba(159, 178, 214, 0.35);
    }

    :root:not([data-theme="light"]) .aiden-auth:has(.aa-panel) .aa-brand {
        background: var(--surface-inverse);
    }

    :root:not([data-theme="light"]) .aiden-auth:has(.aa-panel) {
        --aa-shadow-rgb: 0, 0, 0;
    }

    /* Page glow behind the card: a faint Royal Blue light instead of the light-grey one */
    :root:not([data-theme="light"]) .aiden-auth:has(.aa-panel) .aa-content {
        background:
            radial-gradient(60% 50% at 50% 45%, rgba(60, 82, 121, 0.35) 0%, transparent 70%),
            var(--surface-page);
    }

    /* Switch: off-white thumb (the card colour would vanish), checked track in the button blue */
    :root:not([data-theme="light"]) .aiden-auth .ds-switch .switch::after,
    :root:not([data-theme="light"]) .aiden-auth .ds-switch input:checked ~ .switch::after {
        background: var(--aiden-off-white);
    }

    :root:not([data-theme="light"]) .aiden-auth .ds-switch input:checked ~ .switch {
        background: var(--action-bg);
    }

    :root:not([data-theme="light"]) .aiden-auth .ds-alert--success {
        border-color: rgba(163, 201, 58, 0.35);
        background: rgba(163, 201, 58, 0.1);
    }

    :root:not([data-theme="light"]) .aiden-auth:has(.aa-panel) .ds-alert--error,
    :root:not([data-theme="light"]) .aiden-auth:has(.aa-panel) .ds-summary.validation-summary-errors {
        border-color: rgba(255, 107, 112, 0.35);
        background: rgba(255, 107, 112, 0.08);
    }
}

/* Card edge on dark: black shadows disappear, so the hairline becomes a faint light line */
@media (prefers-color-scheme: dark) and (min-width: 380px) and (min-height: 560px) {
    :root:not([data-theme="light"]) .aiden-auth:has(.aa-panel) .aa-panel {
        box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.07),
            0 1px 2px rgba(0, 0, 0, 0.3),
            0 12px 24px -12px rgba(0, 0, 0, 0.45),
            0 32px 64px -24px rgba(0, 0, 0, 0.6);
    }
}

/* Forced dark: the same rules for data-theme="dark" on <html>, for the preview toggle
   or a theme switch in the app. Without the attribute the system setting decides. */
:root[data-theme="dark"] {
    color-scheme: dark;

    /* Neutral ramps, inverted: 500 is the lightest fill in light mode, here the raised fill */
    --ink-100: #eceee9;
    --ink-80: #aab2bf;   /* 7.3:1 on the card */
    --ink-60: #737d8e;   /* field border: 3.7:1 on the card, 3.2:1 on the field fill */
    --ink-40: #566174;
    --ink-20: #3a4454;
    --grey-100: #445166;
    --grey-200: #3a4659;
    --grey-300: #323d4f;
    --grey-400: #2c3748;
    --grey-500: #252f3f;
    --blue-80: #8a9bb8;
    --blue-60: #7487a8;
    --blue-40: #5a6a85;
    --blue-20: #34405a;

    --surface-page: #131922;
    --surface-card: #1c2431;
    --surface-sunken: #252f3f;
    --text-strong: #eceee9;   /* 13.4:1 on the card */
    --text-body: #c5cbd4;
    --text-muted: #98a1af;    /* 6.0:1 on the card */
    --text-link: #9fb2d6;
    --brand-primary: #9fb2d6; /* Royal Blue lightened, for text and icons on dark */
    --border-subtle: #343f52;
    --border-strong: #566174;
    --border-focus: #9fb2d6;

    /* Login button: exact Royal Blue (off-white text 7.9:1); hover lightens, as usual on dark */
    --action-bg: #3c5279;
    --action-bg-hover: #46608c;
    --action-bg-active: #324465;
    --surface-inverse: #25334a; /* brand panel: Royal Blue muted towards the page (45%) */
    --action-fg: #f5f6f2;

    --status-error: #ff6b70;  /* Blaze Red lightened: 5.6:1 on the card */
    --status-info: #9fb2d6;
    --status-success: #a3c93a;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
}

:root[data-theme="dark"] .aiden-auth {
    --ds-ring: 0 0 0 3px rgba(159, 178, 214, 0.35);
}

:root[data-theme="dark"] .aiden-auth:has(.aa-panel) .aa-brand {
    background: var(--surface-inverse);
}

:root[data-theme="dark"] .aiden-auth:has(.aa-panel) {
    --aa-shadow-rgb: 0, 0, 0;
}

/* Page glow behind the card: a faint Royal Blue light instead of the light-grey one */
:root[data-theme="dark"] .aiden-auth:has(.aa-panel) .aa-content {
    background:
        radial-gradient(60% 50% at 50% 45%, rgba(60, 82, 121, 0.35) 0%, transparent 70%),
        var(--surface-page);
}

/* Switch: off-white thumb (the card colour would vanish), checked track in the button blue */
:root[data-theme="dark"] .aiden-auth .ds-switch .switch::after,
:root[data-theme="dark"] .aiden-auth .ds-switch input:checked ~ .switch::after {
    background: var(--aiden-off-white);
}

:root[data-theme="dark"] .aiden-auth .ds-switch input:checked ~ .switch {
    background: var(--action-bg);
}

:root[data-theme="dark"] .aiden-auth .ds-alert--success {
    border-color: rgba(163, 201, 58, 0.35);
    background: rgba(163, 201, 58, 0.1);
}

:root[data-theme="dark"] .aiden-auth:has(.aa-panel) .ds-alert--error,
:root[data-theme="dark"] .aiden-auth:has(.aa-panel) .ds-summary.validation-summary-errors {
    border-color: rgba(255, 107, 112, 0.35);
    background: rgba(255, 107, 112, 0.08);
}

@media (min-width: 380px) and (min-height: 560px) {
    :root[data-theme="dark"] .aiden-auth:has(.aa-panel) .aa-panel {
        box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.07),
            0 1px 2px rgba(0, 0, 0, 0.3),
            0 12px 24px -12px rgba(0, 0, 0, 0.45),
            0 32px 64px -24px rgba(0, 0, 0, 0.6);
    }
}

/* ==========================================================================
   Below the card: e.g. "Back to login" (section belowPanel in _AuthLayout).
   The content column stacks card and this block, both the same width.
   ========================================================================== */
.aiden-auth:has(.aa-below) .aa-content {
    flex-direction: column;
    gap: var(--space-4);
}

.aiden-auth .aa-below {
    width: 100%;
    max-width: 416px;
    display: flex;
    flex-direction: column;
}

@media (min-width: 380px) and (min-height: 560px) {
    .aiden-auth .aa-below { max-width: 464px; }
}

/* Handheld: keep the content at the top, as on the other auth pages */
@media (max-width: 767.98px) {
    .aiden-auth:has(.aa-below) .aa-content { justify-content: flex-start; align-items: stretch; }
    .aiden-auth .aa-below { max-width: none; }
}

/* ---- Short desktop windows (e.g. 900x600, laptops with a toolbar): tighter card, no scrolling ----
   Same idea as compact mode on handhelds: only spacing and control height change.
   !important is needed against the Bootstrap gap utilities in the markup. */
@media (min-width: 768px) and (max-height: 759.98px) {
    .aiden-auth:has(.aa-panel) { --ds-control-h: 40px; }

    .aiden-auth:has(.aa-panel) .aa-content { padding-top: var(--space-3); padding-bottom: var(--space-3); }
    .aiden-auth:has(.aa-panel) .aa-panel { gap: var(--space-3); padding: var(--space-5) var(--space-6) var(--space-5); }

    .aiden-auth:has(.aa-panel) .ds-h2 { font-size: 1.75rem; }

    .aiden-auth:has(.aa-panel) .aa-panel .gap-4 { gap: var(--space-3) !important; }
    .aiden-auth:has(.aa-panel) .aa-panel .gap-3 { gap: var(--space-2) !important; }
    .aiden-auth:has(.aa-panel) .aa-panel .gap-2 { gap: var(--space-1) !important; }

    .aiden-auth:has(.aa-panel) .ds-stack { gap: var(--space-3); }
    .aiden-auth:has(.aa-panel) .ds-field { gap: var(--space-1); }

    .aiden-auth:has(.aa-panel) .ds-input,
    .aiden-auth:has(.aa-panel) .ds-btn {
        padding-top: var(--space-2);
        padding-bottom: var(--space-2);
    }
}

/* ---- Phones in landscape and other low, wide screens (768px+ wide, under 515px high) ----
   A: narrow brand panel (logo only), Login and Microsoft Entra side by side,
      "Remember Organization" and "Forgot your password?" on one row.
   B: the brand panel stays in place; only the form scrolls if it still does not fit.
   The form becomes a grid: every block takes a full row, except the switch and the
   forgot link, which share one row above the buttons (order only changes the visual order).
   !important is needed against the Bootstrap utility classes in the markup. */
@media (min-width: 768px) and (max-height: 514.98px) {
    .aiden-auth:has(.aa-panel) .aa-brand {
        flex: 0 0 clamp(160px, 22vw, 220px);
        align-self: flex-start;
        position: sticky;
        top: 0;
        height: 100dvh;
        min-height: 0;
        padding: var(--space-5);
    }

    .aiden-auth:has(.aa-panel) .aa-brand__logo { height: 28px; }
    .aiden-auth:has(.aa-panel) .aa-brand__claim { display: none; }

    .aiden-auth:has(.aa-panel) .aa-content { padding: var(--space-2) var(--space-6); }
    .aiden-auth:has(.aa-panel) .aa-panel { max-width: 480px; }

    .aiden-auth:has(.aa-panel) .aa-panel form {
        display: grid !important;
        grid-template-columns: 1fr auto;
        align-items: center;
        column-gap: var(--space-4);
    }

    .aiden-auth:has(.aa-panel) .aa-panel form > * { grid-column: 1 / -1; }

    .aiden-auth:has(.aa-panel) .aa-panel form > div:has(> .ds-switch),
    .aiden-auth:has(.aa-panel) .aa-panel form > div:has(> #forgot-password) { grid-column: auto; order: 1; }

    .aiden-auth:has(.aa-panel) .aa-panel form > div:has(> .ds-divider) {
        order: 2;
        flex-direction: row !important;
    }

    .aiden-auth:has(.aa-panel) .aa-panel form > div:has(> .ds-divider) > .ds-btn { flex: 1 1 0; }
    .aiden-auth:has(.aa-panel) .aa-panel form > div:has(> .ds-divider) > .ds-divider { display: none; }
}
