html, body {
    height: 100%;
    width: 100%;
}
body.no-scroll {
    overflow: hidden;
}

/* Login design tokens — wired to the org palette so the login page follows the
   active organisation's brand (the page background is .bg-surgerly-primary).
   Previously these were referenced (.btn-accent, focus rings, --ink) but never
   defined anywhere, so the submit button had no resolved background. */
:root {
    --accent: var(--surgerly-primary);
    --accent-600: color-mix(in srgb, var(--surgerly-primary) 85%, var(--surgerly-black));
    --ink: var(--surgerly-text);
}

.bg-surgerly-primary{
    background-color: var(--surgerly-primary);
    color: var(--surgerly-black);
}

.surgerly-search::placeholder {
    color: var(--surgerly-primary)
}
.surgerly-search:focus {
    outline: none;
    box-shadow: none;
}

.transition-slide {
    transition: 0.3s;
}

#search_container {
    transition: 0.3s;
}

.remember-me {
    margin-top: 0.75rem;
}

/* Main control */
.remember-me-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--checkbox-label-color, var(--surgerly-white));
}

/* Hide native checkbox but keep it accessible */
.remember-me-control input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Custom box */
.remember-me-box {
    --size: 16px;

    position: relative;
    width: var(--size);
    height: var(--size);
    border-radius: 4px;
    border: 2px solid var(--checkbox-border-color, var(--surgerly-white));
    background: var(--checkbox-bg, transparent);
    box-sizing: border-box;
    transition:
        background 0.18s ease-out,
        border-color 0.18s ease-out,
        box-shadow 0.18s ease-out;
}

/* Tick */
.remember-me-box::after {
    content: "";
    position: absolute;
    inset: 3px 4px 3px 4px;
    border-right: 2px solid var(--checkbox-tick-color, var(--surgerly-primary));
    border-bottom: 2px solid var(--checkbox-tick-color, var(--surgerly-primary));
    transform: rotate(45deg) scale(0);
    transform-origin: 80% 40%;
    transition: transform 0.18s ease-out;
}

/* Checked state */
.remember-me-control input[type="checkbox"]:checked + .remember-me-box {
    background: var(--checkbox-bg-checked, var(--surgerly-white));
    border-color: var(--checkbox-border-checked, var(--surgerly-white));
    box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}

.remember-me-control input[type="checkbox"]:checked + .remember-me-box::after {
    transform: rotate(45deg) scale(1);
}

/* Keyboard focus */
.remember-me-control input[type="checkbox"]:focus-visible + .remember-me-box {
    box-shadow: 0 0 0 2px var(--surgerly-black);
}

/* Label text */
.remember-me-label {
    line-height: 1;
    user-select: none;
}

/* ── Credentials-step error ──────────────────────────────────────────────────
   The login pages have no card — the form sits directly on the org's brand fill
   (body.bg-surgerly-primary -> --surgerly-primary), an arbitrary white-label hex.
   This message used to be Bootstrap's .text-danger, i.e. a fixed #dc3545:
   palette.css maps --bs-primary and --bs-link-* onto the Surgerly tokens but
   never --bs-danger-rgb, and getOrganisationBranding only ever emits --surgerly-*
   ones. That measured ~1.7:1 against the default gold — effectively invisible,
   and worse on a warm brand.

   So the message carries its own danger surface rather than tinting text against
   an unknown backdrop: the bg/text pair below is fixed at ~8:1 and no org setting
   can weaken it (the branding editor exposes the `danger` base token only, not
   -bg/-text/-border). Keep the literal fallbacks — a branded patient login inlines
   its own :root block and does NOT link palette.css, so the tokens are undefined
   there. Don't reduce this back to a bare text colour. */
.login-error {
    display: block;
    max-height: 0;
    margin: 0;
    padding: 0 0.9rem;
    overflow: hidden;
    opacity: 0;
    /* Width 0 (not a transparent 1px) so the collapsed box is truly 0-height —
       max-height can't crush a border, and 1px top+bottom would keep reserving 2px. */
    border: 0 solid var(--surgerly-danger-border, #f5c2c7);
    border-radius: 999px;
    background: var(--surgerly-danger-bg, #fde7e9);
    color: var(--surgerly-danger-text, #842029);
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: center;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease,
                margin 0.3s ease, border-width 0.3s ease;
}

/* Height is capped, not fixed, so the lockout message can wrap on a narrow screen
   instead of being clipped by a hard 32px box. 8rem clears ~5 wrapped lines. */
.login-error.is-visible {
    max-height: 8rem;
    margin-bottom: 0.75rem;
    padding: 0.55rem 0.9rem;
    opacity: 1;
    border-width: 1px;
}

.btn-primary {
  background: var(--surgerly-black);
  color: var(--surgerly-white);
  border: none;
  transition: 0.2s;
  font-size: 0.82rem;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary:disabled,
.btn-primary.disabled {
  background: color-mix(in srgb, var(--surgerly-black) 80%, #ffffff);
  color: color-mix(in srgb, var(--surgerly-white) 80%, #000000);
  cursor: not-allowed;
  opacity: 0.55;
  border-color: transparent;
  box-shadow: none;
}

.btn-primary:hover {
  filter: brightness(1.2);
}

.btn-primary:disabled:hover,
.btn-primary.disabled:hover {
  filter: none;
}

.btn-outline {
  background: var(--surgerly-primary);
  border: none;
  color: var(--surgerly-white);
  transition: 0.2s;
  font-size: 0.82rem;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-outline:hover {
  filter: brightness(0.95);
}

/* Subtle gradient + grain background */
.auth-body{
  background:
    radial-gradient(1200px 800px at 10% -10%, #ffffff 0, var(--surgerly-grey-50, #faf9f7) 60%, var(--surgerly-light-gray, #f3f2ef) 100%),
    radial-gradient(900px 600px at 110% 110%, #ffffff 0, var(--surgerly-grey-50, #faf9f7) 50%, var(--surgerly-light-gray, #f3f2ef) 100%);
  position: relative;
  color: var(--ink);
}
.auth-body::before{
  /* ultra-subtle grain */
  content:"";
  position: fixed; inset:0; pointer-events:none; z-index:0;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 0 0 0 .02 .03 .02 0 0 0'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/%3E%3C/svg%3E");
  mix-blend-mode:multiply;
}

/* Shell width */
.auth-shell{ width:min(440px, 92vw); position:relative; z-index:1; }

/* Brand */
.brand-mark{
  width:10rem; height:auto; display:block; margin:0 auto .35rem;
  filter: drop-shadow(0 2px 4px rgba(var(--surgerly-shadow-rgb, 0,0,0), .08));
}

/* Card */
.auth-card{
  background: var(--card);
  border-radius: 18px;
  box-shadow:
    0 10px 30px rgba(var(--surgerly-shadow-rgb, 0,0,0), .06),
    0 1px 0 rgba(255,255,255,.6) inset;
}

/* Typography + links */
h1, .h5 { font-family: 'Playfair Display', serif; }
.text-muted{ color: var(--muted) !important; }
.link-muted{ color: var(--muted); text-decoration: none; }
.link-muted:hover{ color: var(--ink); }

/* Inputs */
.form-control{
  border-radius: 12px;
  border-color: var(--line);
}
.form-control:focus{
  border-color: var(--accent);
  box-shadow: 0 0 0 .25rem rgba(194,163,107,.15);
}

/* Floating labels spacing */
.form-floating > label{ color:var(--surgerly-dark-gray, #8a8f98); }

/* Password toggle */
.password-toggle{
  position:absolute; right:.5rem; top:50%; transform:translateY(-50%);
  color:var(--surgerly-dark-gray, #8a8f98); padding:.25rem .5rem;
}
.password-toggle:hover{ color:var(--ink); }

/* Buttons */
.btn-accent{
  background: var(--accent); border:none; color:#fff;
  border-radius: 12px; font-weight:700; letter-spacing:.04em;
  padding:.7rem 1rem;
}
.btn-accent:hover{ background: var(--accent-600); border-color: var(--accent-600); }

/* Keep the gold when disabled */
.btn-accent:disabled,
.btn-accent.disabled{
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color:#fff !important;
  opacity: 1 !important;             /* stop Bootstrap from greying it out */
  cursor: not-allowed;
  filter: saturate(.25) brightness(.98); /* tiny tone-down while disabled */
}

.btn-outline-dark{ border-radius:12px; }

/* Divider */
.divider{
  position:relative; text-align:center; color:var(--muted); font-size:.9rem;
  margin: 1.25rem 0;
}
.divider::before, .divider::after{
  content:""; display:block; height:1px; background:var(--line);
  position:absolute; top:50%; width:40%;
}
.divider::before{ left:0; } .divider::after{ right:0; }
.divider > span{ background:var(--card); padding:0 .5rem; position:relative; z-index:1; }

/* Nice focus ring for all buttons */
.btn:focus-visible{ box-shadow: 0 0 0 .25rem rgba(194,163,107,.25); }

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce){
  .btn, .form-control, .login-error{ transition:none !important; }
}

/* put in /static/css/login.css */
.btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.offcanvas.offcanvas-bottom {
    height: auto!important;
}

.offcanvas-body {
    transition: 0.3s;
    min-height: 0px;
}

#sidebarContainer {
    flex: 0 0 auto;
    overflow: auto;
    min-height: 0;
}

.sidebarList {
    padding: 0;
    margin: 0;
    list-style-type: none;
}
.sidebarItem {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.sidebarItem:has(> ul) .surgerly-dropdown {
    margin-left: 0.5rem;
    width: 1.25rem;
    line-height: 100%;
    transform: rotate(-90deg);
    transition: transform .35s ease;
    transform-origin: .5em 50%;
}
.sidebarItem:has(> ul) .surgerly-dropdown[aria-expanded=true] {
    transform: rotate(0deg);
}
.sidebarItem + .sidebarItem {
    padding-top: 0.5rem;
}
.sidebarDropdownList {
    padding: 0;
    margin: 0;
    margin-left: 3rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--surgerly-black);
    list-style-type: none;
}
.sidebarItem > .btn, .sidebarDropdownItem > .btn {
    color: var(--surgerly-black);
    border: 0!important;
    opacity: 0.7;
}
.sidebarItem > .btn:hover, .sidebarItem > .btn.active, .sidebarDropdownItem > .btn:hover, .sidebarDropdownItem > .btn.active {
    color: var(--surgerly-primary);
    border: 0;
    opacity: 1;
}

/* ── Authenticator-app (TOTP) MFA cards ──────────────────────────────────────
   Shared by the enrol wizard (login_mfa_enrol.html) and the verify screen
   (login_mfa.html): a light card on the branded background. "Grey" fills use the
   org's faded primary (palette --surgerly-primary-soft), so they follow white-label. */
#mfa-pages { overflow: hidden; transition: height .28s ease; }
.mfa-submit:hover:not(:disabled) { opacity:.92; }
.mfa-back:hover { background:#f4f5f8; }
.mfa-store-btn:hover { opacity:.92; }
.mfa-card { background:#fff; border-radius:18px; padding:26px 22px; box-shadow:0 18px 50px rgba(0,0,0,.18); color:#1f2330; text-align:left; font-family:'Inter', system-ui, -apple-system, "Segoe UI", sans-serif; }
.mfa-card h1, .mfa-card h2 { font-family: inherit; }
.mfa-card-title { font-size:1.4rem; font-weight:700; margin:0 0 4px; text-align:center; }
.mfa-card-sub { font-size:.92rem; color:#5a6072; margin:0 0 18px; text-align:center; }
.mfa-progress { display:flex; align-items:center; justify-content:center; gap:7px; margin:0 0 18px; }
.mfa-dot { width:8px; height:8px; border-radius:50%; background:#e0e3ea; transition:all .2s; }
.mfa-dot.is-done { background:var(--surgerly-primary); }
.mfa-dot.is-active { background:var(--surgerly-primary); width:22px; border-radius:4px; }
.mfa-progress-text { margin-left:6px; font-size:.78rem; font-weight:600; color:#8a90a2; }
.mfa-page { display:flex; flex-direction:column; }
.mfa-page > .mfa-step-title:first-child { margin-top:0; }
.mfa-nav { display:flex; gap:10px; margin-top:18px; }
.mfa-nav .mfa-submit { flex:1 1 auto; margin-top:0; }
.mfa-back { flex:0 0 auto; padding:13px 18px; border:1.5px solid #e6e8ef; border-radius:12px; background:#fff; color:#5a6072; font-weight:600; font-size:1rem; cursor:pointer; }
.mfa-step { display:flex; gap:14px; padding:18px 0; border-top:1px solid #eef0f4; }
.mfa-step:first-of-type { border-top:none; padding-top:0; }
.mfa-step-num { flex:0 0 28px; width:28px; height:28px; border-radius:50%; background:var(--surgerly-primary); color:var(--surgerly-white); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:.85rem; }
.mfa-step-body { flex:1 1 auto; min-width:0; }
.mfa-step-title { font-size:1rem; font-weight:600; margin:2px 0 4px; }
.mfa-step-text { font-size:.88rem; color:#5a6072; margin:0 0 10px; }
.mfa-details { margin:6px 0 0; }
.mfa-details > summary { cursor:pointer; color:var(--surgerly-primary); font-size:.86rem; font-weight:600; list-style:none; }
.mfa-details > summary::-webkit-details-marker { display:none; }
.mfa-details > summary::before { content:'\25be\00a0'; }
.mfa-details[open] > summary::before { content:'\25b4\00a0'; }
.mfa-details-body { padding:12px 0; font-size:.88rem; color:#5a6072; }
.mfa-store-btn { display:inline-flex; align-items:center; gap:8px; background:var(--surgerly-primary); color:var(--surgerly-white); text-decoration:none; padding:10px 16px; border-radius:10px; font-weight:600; font-size:.9rem; }
.mfa-store-btn .material-symbols-outlined { font-size:1.15rem; }
.mfa-hint { font-size:.78rem; color:#8a90a2; margin-bottom:0; }
.mfa-qr-wrap { display:flex; justify-content:center; margin:4px 0 10px; }
.mfa-qr { padding:10px; background:#fff; border:1px solid #eef0f4; border-radius:12px; line-height:0; }
.mfa-key-row { display:flex; align-items:stretch; gap:8px; }
.mfa-key { flex:1 1 auto; min-width:0; display:flex; align-items:center; background:var(--surgerly-primary-soft); border-radius:8px; padding:8px 12px; letter-spacing:1px; word-break:break-all; color:#1f2330; font-size:.82rem; }
.mfa-copy { flex:0 0 auto; display:flex; align-items:center; justify-content:center; padding:0 13px; border:none; border-radius:8px; background:var(--surgerly-primary); color:var(--surgerly-white); cursor:pointer; }
.mfa-copy .material-symbols-outlined { font-size:1.1rem; }
.mfa-copy:hover { opacity:.92; }
.mfa-advisory { margin:14px 0; background:var(--surgerly-primary-soft); border-radius:12px; padding:12px; font-size:.84rem; color:#5a6072; text-align:center; }
.mfa-advisory-sub { font-size:.78rem; opacity:.85; }
.mfa-entry-mock { display:flex; align-items:center; gap:10px; background:#fff; border:1px solid #e6e8ef; border-radius:10px; padding:10px 12px; margin-top:8px; text-align:left; }
.mfa-entry-mock .material-symbols-outlined { color:var(--surgerly-primary); }
.mfa-entry-mock strong { display:block; color:#1f2330; font-size:.88rem; }
.mfa-entry-mock span { display:block; color:#8a90a2; font-size:.78rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mfa-input { width:100%; text-align:center; font-size:1.4rem; letter-spacing:8px; padding:12px; border:1.5px solid #e6e8ef; border-radius:12px; margin-top:4px; color:#1f2330; font-weight:600; }
.mfa-input:focus { outline:none; border-color:var(--surgerly-primary); }
.mfa-recovery { display:flex; align-items:center; justify-content:center; gap:8px; margin-top:4px; }
.mfa-recovery-box { flex:1 1 0; min-width:0; max-width:130px; height:54px; text-align:center; font-size:1.15rem; font-weight:600; letter-spacing:1px; color:#1f2330; border:1.5px solid #e6e8ef; border-radius:12px; background:#fff; font-family:ui-monospace, SFMono-Regular, Menlo, monospace; text-transform:lowercase; }
.mfa-recovery-box:focus { outline:none; border-color:var(--surgerly-primary); box-shadow:0 0 0 3px var(--surgerly-primary-soft); }
.mfa-recovery-dash { color:#8a90a2; font-weight:600; }
.mfa-otp { display:flex; gap:8px; justify-content:center; margin-top:4px; }
.mfa-otp-box { flex:1 1 0; min-width:0; max-width:52px; height:54px; text-align:center; font-size:1.5rem; font-weight:600; color:#1f2330; border:1.5px solid #e6e8ef; border-radius:12px; background:#fff; }
.mfa-otp-box:focus { outline:none; border-color:var(--surgerly-primary); box-shadow:0 0 0 3px var(--surgerly-primary-soft); }
.mfa-error { color:#d33; font-size:.82rem; min-height:18px; text-align:center; margin-top:6px; }
.mfa-submit { width:100%; margin-top:10px; padding:13px; border:none; border-radius:12px; background:var(--surgerly-black,#1f2330); color:#fff; font-weight:600; font-size:1rem; cursor:pointer; }
.mfa-submit:disabled { opacity:.6; }
.mfa-recovery-list { list-style:none; padding:16px; margin:0 0 14px; background:var(--surgerly-primary-soft); border-radius:12px; display:grid; grid-template-columns:1fr 1fr; gap:8px 16px; font-family:monospace; font-size:1rem; letter-spacing:1px; color:#1f2330; text-align:center; }
.mfa-link { display:block; width:100%; margin-top:10px; padding:8px; border:none; background:none; color:var(--surgerly-primary); font-weight:600; font-size:.9rem; cursor:pointer; text-align:center; }
.mfa-link:hover { text-decoration:underline; }