/* ============================================================================
   EBF Onboarder — login / forgot-password / change-password redesign
   ----------------------------------------------------------------------------
   Ports the ONE-DESIGN login card to the production (HTML + jQuery + migrator.js)
   pages. Only linked from login.html, forgot-password.html and password.html, and
   every rule is scoped under `body.login-redesign` so it cannot leak into the rest
   of the app. Colours/typography come from the shared design tokens in
   colors_and_type.css; dark mode is driven by the `.dark` class on <html>
   (see theme.js), so dark overrides read `.dark .login-redesign …`.
   ========================================================================== */

/* ── Page shell ───────────────────────────────────────────────────────── */
/* Vertical layout is left to the existing mechanisms so we don't fight them:
   register.css handles the navbar pages (flex column, centered main, pinned
   footer); the legacy main{display:table}+container-align{table-cell} handles
   the navbar-less change-password page. We only reset the canvas tone/type. */
body.login-redesign {
    /* Match the dashboard/customers canvas exactly: light = #f1f3f7 (dashboard.css
       `body`), dark = --bg-subtle (ebf-header.css `body.grey-shell`). */
    background: #f1f3f7;
    color: var(--fg-1);
    font-family: var(--font-body);
    margin: 0;
}
.dark body.login-redesign,
[data-theme="dark"] body.login-redesign {
    background: var(--bg-subtle);
}

/* Neutralise the legacy bootstrap navbar/grid look on these pages. */
body.login-redesign .navbar {
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: none;
    padding: 0 32px;
    min-height: 64px;
    display: flex;
    align-items: center;
}
body.login-redesign .navbar .container,
body.login-redesign .navbar .row { margin: 0; padding: 0; width: auto; max-width: none; }
body.login-redesign .migrator-logo a { display: inline-flex; align-items: center; }
body.login-redesign .migrator-logo img { height: 28px; display: block; }

/* Vertical centering is left to the legacy table/table-cell mechanism
   (register.css: main{display:table} + .container-align{display:table-cell}),
   because login()/loginError() toggle `main` between none/table at runtime.
   We only need to size and horizontally center the card inside the section. */
body.login-redesign section.container {
    padding: 56px 24px 72px;
    max-width: none;
    width: 100%;
}
body.login-redesign section.container > div,
body.login-redesign section.container > .login-card {
    margin-left: auto;
    margin-right: auto;
    float: none;
}

/* ── The card ─────────────────────────────────────────────────────────── */
body.login-redesign .login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-page);
    border: 1px solid var(--border-default);
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 1px 2px rgba(22, 31, 41, 0.04), 0 12px 32px -16px rgba(22, 31, 41, 0.12);
}
.dark .login-redesign .login-card { box-shadow: 0 12px 32px -16px rgba(0, 0, 0, 0.6); }

body.login-redesign .login-head { margin-bottom: 22px; }
body.login-redesign .login-head h1 {
    margin: 0;
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 24px;
    letter-spacing: -0.02em;
    color: var(--fg-1);
}
/* Integer line-height keeps .login-head a whole-pixel height, so nothing below lands on a
   half-pixel row (which rendered the input's 1px bottom border across two rows → invisible). */
body.login-redesign .login-head p { margin: 6px 0 0; font-size: 13.5px; line-height: 14px; color: var(--fg-3); }

/* ── Form fields ──────────────────────────────────────────────────────── */
body.login-redesign .login-form { display: flex; flex-direction: column; gap: 18px; }
body.login-redesign .wz-field { display: flex; flex-direction: column; gap: 8px; }
body.login-redesign .login-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
body.login-redesign .wz-label { font-family: var(--font-title); font-weight: 600; font-size: 15px; color: var(--fg-1); }
body.login-redesign .wz-hint { font-family: var(--font-body); font-size: 12.5px; color: var(--fg-3); }

body.login-redesign .login-forgot {
    font-family: var(--font-body);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--fg-link);
    text-decoration: none;
    float: none;
}
body.login-redesign .login-forgot:hover { color: var(--fg-link-hover); text-decoration: underline; }

body.login-redesign .login-input {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border: 1px solid var(--border-default);
    border-radius: 9px;
    background: var(--bg-page);
    transition: border-color 140ms ease-out, box-shadow 140ms ease-out;
}
body.login-redesign .login-input:focus-within {
    border-color: var(--ebf-blue-500);
    box-shadow: 0 0 0 3px rgba(18, 113, 197, 0.14);
}
body.login-redesign .login-input.error { border-color: var(--ebf-red-500); }
body.login-redesign .login-input.error:focus-within { box-shadow: 0 0 0 3px rgba(250, 126, 117, 0.18); }
body.login-redesign .login-input-ico { color: var(--fg-3); flex-shrink: 0; }

/* The real inputs keep their migrator.js hooks (.mail/.password/.captcha) but are
   stripped of their legacy chrome so they sit flush inside .login-input. */
body.login-redesign .login-input input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    padding: 12px 0;
    margin: 0;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--fg-1);
    box-shadow: none;
    height: auto;
}
body.login-redesign .login-input input::placeholder { color: var(--fg-3); }
body.login-redesign .login-input input:focus { outline: none; box-shadow: none; }

/* Browser autofill: register.css forces a hard white bg + black text on
   autofilled inputs, which breaks the field's flush look (and is unreadable in
   dark mode). Re-tone it to the field's own colours so a filled, unfocused field
   matches an empty one (design: the input is uniformly var(--bg-page)). */
body.login-redesign .login-input input:-webkit-autofill,
body.login-redesign .login-input input:-webkit-autofill:hover,
body.login-redesign .login-input input:-webkit-autofill:focus,
body.login-redesign .login-input input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--fg-1);
    -webkit-box-shadow: 0 0 0 1000px var(--bg-page) inset;
    box-shadow: 0 0 0 1000px var(--bg-page) inset;
    caret-color: var(--fg-1);
    background-color: var(--bg-page) !important;
    background-image: none !important;
    transition: background-color 9999s ease-out 0s;
}

body.login-redesign .login-eye {
    appearance: none;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--fg-3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    flex-shrink: 0;
    margin: 0;
}
body.login-redesign .login-eye:hover { color: var(--fg-1); background: var(--bg-subtle); }

/* Red border when migrator.js flags the field (it adds .validation-error to the
   <input>, so match via :has on the wrapper). The legacy general.css rule
   `.validation-error { border: 1px solid red !important }` would otherwise draw a
   second border directly on the inner <input>, so we cancel it here. */
body.login-redesign .login-input:has(input.validation-error) { border-color: var(--ebf-red-500); }
body.login-redesign .login-input:has(input.validation-error):focus-within { box-shadow: 0 0 0 3px rgba(250, 126, 117, 0.18); }
body.login-redesign .login-input input.validation-error { border: none !important; }

/* Inline validation errors (mirrors the design's .wz-error). Shown when the
   field's input carries the legacy .validation-error class. */
body.login-redesign .validation-message {
    display: none;
    align-items: center;
    gap: 5px;
    margin: 0;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--ebf-red-600);
}
.dark .login-redesign .validation-message { color: var(--ebf-red-400); }
body.login-redesign .wz-field:has(input.validation-error) .validation-message { display: flex; }
body.login-redesign .validation-message::before {
    content: "";
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask: var(--icon-alert) center / contain no-repeat;
    mask: var(--icon-alert) center / contain no-repeat;
}

body.login-redesign .login-caps {
    display: none;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--ebf-yellow-700);
}
.dark .login-redesign .login-caps { color: var(--ebf-yellow-400); }
body.login-redesign .login-caps.on { display: inline-flex; }

/* ── Alert banner ─────────────────────────────────────────────────────── */
body.login-redesign .login-alert {
    display: none;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 13px;
    margin-bottom: 18px;
    border-radius: 9px;
    background: var(--ebf-red-100);
    border: 1px solid var(--ebf-red-300);
    color: var(--ebf-red-800);
    font-size: 13px;
    line-height: 1.45;
}
body.login-redesign .login-alert.on { display: flex; }
body.login-redesign .login-alert .svg-icon { flex-shrink: 0; margin-top: 1px; color: var(--ebf-red-600); }
.dark .login-redesign .login-alert {
    background: rgba(250, 126, 117, 0.12);
    border-color: rgba(250, 126, 117, 0.34);
    color: var(--ebf-red-300);
}
.dark .login-redesign .login-alert .svg-icon { color: var(--ebf-red-400); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
body.login-redesign .btn-primary {
    appearance: none;
    cursor: pointer;
    border: 1px solid var(--ebf-blue-500);
    background: var(--ebf-blue-500);
    color: #fff;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 18px;
    border-radius: 9px;
    text-decoration: none;
    transition: background 140ms ease-out, border-color 140ms ease-out, box-shadow 140ms ease-out;
}
body.login-redesign .btn-primary:hover { background: var(--gradient-brand); border-color: transparent; color: #fff; }
body.login-redesign .btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(18, 113, 197, 0.30); }
body.login-redesign .btn-primary[disabled],
body.login-redesign .btn-primary.disabled { opacity: 0.55; cursor: default; pointer-events: none; }
.dark .login-redesign .btn-primary:hover { background: var(--ebf-blue-400); border-color: var(--ebf-blue-400); }

body.login-redesign .btn-quiet {
    appearance: none;
    cursor: pointer;
    border: 1px solid var(--border-default);
    background: var(--bg-page);
    color: var(--fg-1);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 18px;
    border-radius: 9px;
    text-decoration: none;
    transition: border-color 140ms ease-out, background 140ms ease-out;
}
body.login-redesign .btn-quiet:hover { border-color: var(--ebf-blue-400); background: var(--bg-subtle); color: var(--fg-1); }

/* Spinner shown while a request is in flight (added via .loading on the button). */
body.login-redesign .login-spinner {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: login-spin 700ms linear infinite;
}
@keyframes login-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { body.login-redesign .login-spinner { animation-duration: 2s; } }

/* ── Keep me signed in ────────────────────────────────────────────────── */
body.login-redesign .login-remember {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 13.5px;
    color: var(--fg-2);
    user-select: none;
    margin: 0;
}
body.login-redesign .adm-check {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    flex-shrink: 0;
    border: 1.5px solid var(--border-default);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 120ms ease-out, border-color 120ms ease-out;
}
body.login-redesign .adm-check.on { background: var(--ebf-blue-500); border-color: var(--ebf-blue-500); }
body.login-redesign .adm-check .svg-icon { display: none; }
body.login-redesign .adm-check.on .svg-icon { display: block; }

/* ── Alternative sign-in block: one "or" separator, then the available options
   (EBF SSO for eligible domains, passkey when one is registered). The block shows
   only if at least one option is available; each button toggles via .alt-on. ──── */
body.login-redesign .login-alt-block { display: none; }
body.login-redesign .login-alt-block.on { display: block; }
body.login-redesign .login-alt-block .btn-quiet { display: none; }
body.login-redesign .login-alt-block .btn-quiet.alt-on { display: inline-flex; }
/* gap between two stacked visible options */
body.login-redesign .login-alt-block .btn-quiet.alt-on ~ .btn-quiet.alt-on { margin-top: 10px; }
body.login-redesign .login-sep {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 18px;
    color: var(--fg-3);
    font-size: 12px;
}
body.login-redesign .login-sep::before,
body.login-redesign .login-sep::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }

/* ── Helper text / links / back ───────────────────────────────────────── */
body.login-redesign .login-help { margin: 20px 0 0; text-align: center; font-size: 12.5px; color: var(--fg-3); }
body.login-redesign .login-help a { color: var(--fg-link); text-decoration: none; font-weight: 600; }
body.login-redesign .login-help a:hover { color: var(--fg-link-hover); text-decoration: underline; }
body.login-redesign .login-help span { color: var(--fg-link); font-weight: 600; }

body.login-redesign .login-back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: -6px 0 16px -6px;
    padding: 6px;
    border-radius: 7px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--fg-3);
    text-decoration: none;
    float: none;
}
body.login-redesign .login-back:hover { color: var(--ebf-blue-600); background: var(--bg-subtle); }

/* ── reCAPTCHA / legacy image captcha ─────────────────────────────────── */
/* Google reCAPTCHA (revealed by migrator.js when a site key is configured). */
/* Frame the reCAPTCHA like the fields / image-captcha box so the widget sits in a
   tidy container instead of floating misaligned. Tokens keep it theme-aware. */
body.login-redesign .g-recaptcha {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    border-radius: 9px;
    padding: 2px 2px 0 2px;
}

/* Legacy image captcha — mirrors the design's SecurityCode: the code image sits
   in a bordered, rounded box with the refresh button pinned to its top-right
   corner. The image itself is stretched to fill the box. */
body.login-redesign .captcha-block { display: flex; flex-direction: column; gap: 10px; }
body.login-redesign .captcha-box {
    position: relative;
    display: block;
    border: 1px solid var(--border-default);
    border-radius: 9px;
    overflow: hidden;
    background: var(--bg-subtle);
    /* Same horizontal padding as the input fields (.login-input: 0 12px) so the
       code image lines up with them; a bit of vertical breathing room. */
    padding: 8px 12px;
    line-height: 0;
}
body.login-redesign .captcha-box img {
    display: block;
    height: auto;
    /* natural size, left-aligned; cap width so it never runs under the refresh
       button pinned top-right (30px + inset). */
    max-width: calc(100% - 40px);
    border-radius: 5px;
    user-select: none;
    /* neutralise the legacy `div.captcha div img { position:relative; left:10px }`
       (general.css) so the image lines up with the 12px field padding. */
    position: static;
    left: 0;
    top: 0;
}
body.login-redesign .captcha-refresh {
    position: absolute;
    top: 6px;
    right: 6px;
    appearance: none;
    border: 1px solid var(--border-default);
    background: var(--bg-page);
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-2);
    padding: 0;
    transition: color 140ms ease-out, border-color 140ms ease-out;
    /* Neutralise the legacy `div.captcha div button` rule (general.css) which
       masks the button to reload.svg — that clipped our white button + inline
       icon to the glyph shape, leaving an all-but-invisible white mark. */
    -webkit-mask: none;
    mask: none;
}
body.login-redesign .captcha-refresh:hover { color: var(--ebf-blue-600); border-color: var(--ebf-blue-300); background: var(--bg-page); }
body.login-redesign .captcha-refresh .svg-icon { display: block; }

/* ── Password strength (passtrength plugin) — fit the card ────────────── */
body.login-redesign .passtrength-input-holder { width: 100%; }
body.login-redesign .passtrength-bar { border-radius: 3px; }

/* ── Footer ───────────────────────────────────────────────────────────── */
/* The bar itself (59px height, border-top, dark-aware bg) is pinned by
   register.css `body:has(.navbar):has(.container-align) .footer`; here we only
   lay out and re-tone the link row. */
body.login-redesign #dynFooter {
    display: flex;
    align-items: center;
    justify-content: center;
}
body.login-redesign #dynFooter ul {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 12.5px;
    color: var(--fg-3);
}
body.login-redesign #dynFooter a { color: var(--fg-3); text-decoration: none; }
body.login-redesign #dynFooter a:hover { color: var(--fg-link); text-decoration: underline; }

/* ── SVG icon default ─────────────────────────────────────────────────── */
body.login-redesign .svg-icon { flex-shrink: 0; }

/* Data-URI for the small alert triangle used before .validation-message. */
body.login-redesign {
    --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FA7E75' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E");
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 520px) {
    body.login-redesign .navbar { padding: 0 16px; }
    body.login-redesign section.container { padding: 32px 16px 48px; }
    body.login-redesign .login-card { padding: 24px; }
}


/* ============================================================================
   Tenant chooser (selectTenant.html) — part of the login journey, so it lives
   here and inherits the exact login shell (navbar bar, centered main, pinned
   footer, TAN/OTP/error dialogs). Only the card + its searchable, scrollable
   two-column list of rich tenant rows are page-specific. Scoped to
   `body.tenant-select` (that page also carries `.login-redesign`).
   ========================================================================== */

/* Tighter section padding than the login card (the tenant list is tall). */
body.tenant-select section.container {
    padding: 32px 24px 40px;
}

/* register.css puts .container-align (and the sticky-footer .footer) at z-index:1000000,
   which lifts the tenant content above Bootstrap's modal backdrop (1040) so the TAN/OTP
   dialog opens without dimming the list/footer. Raise the backdrop + modal above that
   stacking (scoped to this page) so the dialog dims and sits over everything. */
body.tenant-select .modal-backdrop {
    z-index: 1000040;
}
body.tenant-select .modal {
    z-index: 1000050;
}
/* The MDM mini-tile tooltips are appended to <body> (to escape #tenantsList's overflow clip), so they
   must clear .container-align's z-index:1000000 or they render behind the tenant panel. */
.tooltip.ts-mdm-tip {
    z-index: 1000060;
}

/* The card — centered by `section.container > div { margin:auto }` above.
   Border + subtle backdrop match .login-card exactly (same border/radius/shadow). */
body.tenant-select .ts-card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    /* Cap against the viewport (navbar + footer + section padding + card chrome)
       so the list — not the page — scrolls, and the footer stays visible. */
    max-height: calc(100vh - 200px);
    background: var(--bg-page);
    border: 1px solid var(--border-default);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(22, 31, 41, 0.04), 0 12px 32px -16px rgba(22, 31, 41, 0.12);
    padding: 32px 28px 24px;
    box-sizing: border-box;
}
.dark body.tenant-select .ts-card,
[data-theme="dark"] body.tenant-select .ts-card {
    box-shadow: 0 12px 32px -16px rgba(0, 0, 0, 0.6);
}

/* Logout button, top-right — same affordance as a dialog close button. */
body.tenant-select .ts-logout {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--fg-3, #5C6269);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-control, 9px);
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}
body.tenant-select .ts-logout:hover,
body.tenant-select .ts-logout:focus-visible {
    color: var(--fg-1, #161F29);
    background: var(--bg-subtle, #F1F2F2);
    border-color: var(--border-subtle, #E3E4E5);
    outline: none;
}
body.tenant-select .ts-logout svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Heading + logo. */
body.tenant-select .ts-head {
    flex: 0 0 auto;   /* fixed header — never shrink; the list absorbs the height budget */
    text-align: center;
    margin-bottom: 20px;
}
body.tenant-select .ts-logo {
    display: block;
    width: 44px;
    height: 44px;
    margin: 0 auto 14px;
}
body.tenant-select .ts-title {
    margin: 0;
    font: 700 22px/1.3 var(--font-heading, var(--font-body, 'Source Sans Pro', sans-serif));
    color: var(--fg-1, #161F29);
}

/* Search box. */
body.tenant-select .ts-search {
    flex: 0 0 auto;   /* fixed — never shrink; only #tenantsList flexes */
    margin-bottom: 14px;
}
body.tenant-select .ts-search-input {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    font-size: 15px;
    color: var(--fg-1, #161F29);
    background: var(--bg-page, #fff);
    border: 1px solid var(--border-default, #D5D7D9);
    border-radius: var(--radius-control, 9px);
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
body.tenant-select .ts-search-input:focus {
    outline: none;
    border-color: var(--border-focus, #1271C5);
    box-shadow: 0 0 0 3px var(--bg-brand-subtle, #D0E3F3);
}

/* Two-column scrollable list. */
body.tenant-select #tenantsList {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: max-content;   /* size each row track to its tallest card */
    gap: 12px;
    /* Flex-fill the card's remaining height instead of a hardcoded max-height that
       has to be kept in sync with the header/search/padding heights (it drifted ~60px
       out and spilled past the card border). The card's own max-height caps the total. */
    flex: 1 1 auto;
    min-height: 150px;
    overflow-y: auto;
    padding: 2px;
    margin: 0 -2px;
}

/* A single tenant row (reset <button>). */
body.tenant-select .ts-item {
    display: flex;
    align-items: flex-start;   /* top-align content when the row stretches this card */
    gap: 12px;
    width: 100%;
    min-height: 84px;          /* baseline; grows with the system block below */
    text-align: left;
    padding: 16px 18px;
    font: inherit;
    color: var(--fg-1, #161F29);
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-subtle, #E3E4E5);
    border-radius: var(--radius-card, 12px);
    cursor: pointer;
    transition: border-color 0.18s ease, background-color 0.18s ease,
                transform 0.12s ease, box-shadow 0.18s ease;
}
body.tenant-select .ts-item:hover,
body.tenant-select .ts-item:focus-visible {
    border-color: var(--border-brand, #1271C5);
    background: var(--bg-brand-subtle, #D0E3F3);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(22, 31, 41, 0.08));
    outline: none;
}
body.tenant-select .ts-item-disabled,
body.tenant-select .ts-item-disabled:hover {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    border-color: var(--border-subtle, #E3E4E5);
    background: var(--bg-card, #fff);
}

body.tenant-select .ts-item-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1 1 auto;
    min-width: 0;
}
body.tenant-select .ts-item-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--fg-1, #161F29);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.tenant-select .ts-item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    font-size: 12px;
    color: var(--fg-3, #5C6269);
}
body.tenant-select .ts-meta-muted {
    opacity: 0.75;
    font-style: italic;
}
/* System block, pinned to the bottom of the card, divided from the usage row. */
body.tenant-select .ts-systems {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle, #E3E4E5);
}
body.tenant-select .ts-meta-mdm {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}
/* Square MDM tile — same proportions as the dashboard .plat-tile (36px/9px/12px),
   scaled to ~5mm. Colour comes inline from MDM_COLORS; default is the neutral tile. */
body.tenant-select .ts-mdm-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    background: var(--ebf-gray-600, #8A8F94);
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
body.tenant-select .ts-mdm-arrow {
    color: var(--fg-3, #5C6269);
    font-weight: 700;
    margin: 0 1px;
}
/* Clickable system tiles: open the tenant's dashboard filtered to that MDM system. */
body.tenant-select .ts-mdm-clk {
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}
body.tenant-select .ts-mdm-clk:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 0 2px var(--bg-page, #fff), 0 0 0 3px currentColor;
}
body.tenant-select .ts-item-disabled .ts-mdm-clk {
    cursor: default;
    pointer-events: none;
}
/* The tile matching this tenant's currently-remembered platform filter: a clear ring so the
   operator sees a filter is active. */
body.tenant-select .ts-mdm-tile.ts-mdm-active {
    box-shadow: 0 0 0 2px var(--bg-page, #fff), 0 0 0 4px var(--fg-1, #161F29);
}

/* Device-usage bar (used / licensed), dashboard-style but token-driven. */
body.tenant-select .ts-usage {
    display: block;
    margin-top: 8px;
}
body.tenant-select .ts-usage-track {
    display: block;
    height: 5px;
    width: 100%;
    /* Theme-adaptive track: tint the current card background by a fixed amount so the empty portion
       keeps the same contrast on the white default card AND the light-blue hover card (and in dark
       mode). The flat --bg-muted fallback is near-white and washes out on the blue hover bg. */
    background: var(--bg-muted, #E3E4E5);
    background: color-mix(in srgb, currentColor 16%, transparent);
    border-radius: 999px;
    overflow: hidden;
}
body.tenant-select .ts-usage-fill {
    display: block;
    height: 100%;
    background: var(--bg-brand-green, #2DCE9B);
    border-radius: 999px;
    transition: width 0.3s ease;
}
body.tenant-select .ts-usage-warn .ts-usage-fill {
    background: var(--bg-brand-yellow, #FFBD08);
}
body.tenant-select .ts-usage-over .ts-usage-fill {
    background: var(--bg-brand-danger, #FA7E75);
}
body.tenant-select .ts-usage-text {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: var(--fg-3, #5C6269);
}

body.tenant-select .ts-item-chevron {
    flex: 0 0 auto;
    font-size: 22px;
    line-height: 1;
    color: var(--fg-3, #5C6269);
    transition: color 0.18s ease, transform 0.12s ease;
}
body.tenant-select .ts-item:hover .ts-item-chevron,
body.tenant-select .ts-item:focus-visible .ts-item-chevron {
    color: var(--border-brand, #1271C5);
    transform: translateX(2px);
}

/* No-match message (search). */
body.tenant-select .ts-nomatch {
    text-align: center;
    color: var(--fg-3, #5C6269);
    font-size: 14px;
    padding: 16px 0 4px;
}

/* Below the two-column breakpoint: single column, narrower card. */
@media (max-width: 600px) {
    body.tenant-select #tenantsList {
        grid-template-columns: 1fr;
    }
    body.tenant-select .ts-card {
        max-width: 460px;
    }
}
@media (max-width: 480px) {
    body.tenant-select .ts-card {
        max-height: calc(100vh - 150px);
        padding: 26px 18px 18px;
    }
}
