/* =====================================================================================
   Gym Keyper authentication pages — Staff Login, Company Registration, Member Login,
   Member Registration. Same design tokens as Views/Shared/_Layout.cshtml (Inter, slate
   #0f172a, blue #3b82f6, blue→violet gradient, #f0f4f8 background, radius 20/12) so the
   sign-in pages look like the rest of the application.
   MOBILE FIRST: base = phone; min-width layers add tablet, desktop split screen, ultra-wide.
   ONE logo per page: phone/tablet → top banner only; desktop → brand panel only.
   ===================================================================================== */

:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #3b82f6;
    --accent-dark: #2563eb;
    --accent-gradient: linear-gradient(135deg, #2563eb, #7c3aed);
    --surface: rgba(255, 255, 255, .85);
    --surface-solid: #ffffff;
    --bg: #f0f4f8;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;
    --faint: #94a3b8;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --soft: #f8fafc;
    --shadow: 0 8px 32px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .02);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, .08);
    --radius: 20px;
    --radius-sm: 12px;
    --transition: .3s cubic-bezier(.4, 0, .2, 1);
    --danger: #dc2626; --success: #16a34a; --warning: #d97706; --info: #2563eb;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.mg-auth {
    margin: 0; min-height: 100vh; min-height: 100dvh;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg);
    -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
.mg-auth a { color: var(--accent-dark); text-decoration: none; font-weight: 600; }
.mg-auth a:hover { text-decoration: underline; }

/* ---------- shell ---------- */
.mg-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.mg-main { flex: 1 1 auto; display: flex; flex-direction: column; }

/* ---------- phone / tablet banner (the page's ONLY logo below 1024px) ---------- */
.mg-banner {
    position: relative; overflow: hidden; color: #fff;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 22px;
    background: radial-gradient(120% 140% at 100% 0%, #334155 0%, #1e293b 45%, #0f172a 100%);
    border-radius: 0 0 24px 24px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
}
.mg-banner::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
                    background: radial-gradient(circle, rgba(99, 102, 241, .45), transparent 70%); pointer-events: none; }
.mg-banner > * { position: relative; z-index: 1; }
.mg-banner-row { display: flex; align-items: center; gap: 12px; }
.mg-tagline { margin: 14px 0 0; font-weight: 800; font-size: 1.35rem; line-height: 1.15; letter-spacing: -.01em; }
.mg-tagline em { font-style: normal; background: linear-gradient(135deg, #93c5fd, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* logo */
.mg-logo { width: 48px; height: 48px; border-radius: 14px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden;
           background: #fff; box-shadow: 0 4px 14px rgba(15, 23, 42, .25); }
.mg-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.mg-logo.mg-logo--mark { background: var(--accent-gradient); color: #fff; font-weight: 800; font-size: 1.05rem; }
.mg-brand-name { font-weight: 800; font-size: 1.05rem; line-height: 1.2; }
.mg-brand-sub { font-size: .75rem; color: #cbd5e1; }

/* ---------- form side ---------- */
.mg-form-side { flex: 1 1 auto; padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px)); }
.mg-card { width: 100%; max-width: 480px; margin: 0 auto; background: var(--surface-solid); border: 1px solid var(--line);
           border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 18px; }
.mg-card.wide { max-width: 680px; }
.mg-h1 { font-weight: 800; font-size: 1.5rem; line-height: 1.2; letter-spacing: -.01em; margin: 0 0 4px; color: var(--primary); }
.mg-lead { color: var(--text-secondary); margin: 0 0 18px; font-size: .92rem; }

/* tabs (Staff / Member) */
.mg-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: #e2e8f0; margin-bottom: 18px; }
.mg-tabs a, .mg-tabs span { display: grid; place-items: center; min-height: 44px; border-radius: 11px; font-weight: 700; font-size: .88rem;
                            color: var(--text-secondary); text-decoration: none !important; transition: background var(--transition), color var(--transition); }
.mg-tabs a:hover { color: var(--primary); }
.mg-tabs .on { background: #fff; color: var(--primary); box-shadow: 0 3px 10px rgba(15, 23, 42, .1); }

/* fields */
.mg-field { margin-bottom: 12px; }
.mg-label { display: flex; align-items: baseline; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.mg-label .req { color: var(--danger); }
.mg-label .push { margin-left: auto; font-weight: 700; color: var(--primary); }
.mg-control { position: relative; }
.mg-control > .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: .95rem; pointer-events: none; }
.mg-input {
    width: 100%; min-height: 48px; padding: 11px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
    background: #fff; color: var(--text); font: inherit; font-size: 16px;   /* 16px stops iOS zoom */
    transition: border-color var(--transition), box-shadow var(--transition);
}
.mg-control > .ico ~ .mg-input { padding-left: 42px; }
.mg-input::placeholder { color: var(--faint); }
.mg-input:hover { border-color: var(--line-strong); }
.mg-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(59, 130, 246, .15); }
select.mg-input { appearance: none; padding-right: 38px;
                  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
                  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
.mg-input.is-bad, .mg-input.input-validation-error { border-color: var(--danger); }
.mg-input.is-bad:focus { box-shadow: 0 0 0 4px rgba(220, 38, 38, .12); }
.mg-help { min-height: 18px; margin-top: 4px; font-size: .74rem; color: var(--muted); }      /* reserved: no layout shift */
.mg-help.bad, .mg-help .field-validation-error { color: var(--danger); font-weight: 600; }
.mg-eye { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: none;
          color: var(--muted); border-radius: 10px; cursor: pointer; }
.mg-eye:hover { color: var(--primary); }
.mg-input.has-eye { padding-right: 48px; }

.mg-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0; cursor: pointer; font-size: .86rem; color: var(--text-secondary); }
.mg-check input { width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--accent-dark); flex: 0 0 auto; }
.mg-row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: -2px 0 8px; }

/* buttons — same look as the app's primary actions */
.mg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; padding: 12px 20px;
    border-radius: var(--radius-sm); border: 1.5px solid transparent; font: inherit; font-weight: 700; font-size: .98rem;
    cursor: pointer; text-decoration: none !important; transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
}
.mg-btn:active { transform: translateY(1px); }
.mg-btn-primary { background: var(--accent-gradient); color: #fff !important; box-shadow: 0 4px 14px rgba(59, 130, 246, .3); }
.mg-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(59, 130, 246, .35); }
.mg-btn-ghost { background: #fff; color: var(--primary) !important; border-color: var(--line-strong); }
.mg-btn-ghost:hover { border-color: var(--primary); background: var(--soft); }
.mg-btn[disabled] { opacity: .7; cursor: progress; transform: none; }
.mg-btn .spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: mg-spin .7s linear infinite; }
.mg-btn .when-busy { display: none; }
.mg-btn.busy .when-busy { display: inline-flex; align-items: center; gap: 8px; }
.mg-btn.busy .when-idle { display: none; }
.mg-auth :focus-visible { outline: 3px solid rgba(59, 130, 246, .55); outline-offset: 2px; border-radius: 8px; }

.mg-divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: .74rem; font-weight: 700; text-transform: uppercase;
              letter-spacing: .06em; margin: 18px 0 12px; }
.mg-divider::before, .mg-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* server messages */
.mg-note { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--soft);
           margin-bottom: 14px; font-size: .86rem; color: var(--text); }
.mg-note i { margin-top: 3px; }
.mg-note b { display: block; margin-bottom: 2px; }   /* <b> = title line; <strong> = inline bold */
.mg-note.ok { border-color: #bbf7d0; background: #f0fdf4; } .mg-note.ok i { color: var(--success); }
.mg-note.bad { border-color: #fecaca; background: #fef2f2; } .mg-note.bad i { color: var(--danger); }
.mg-note.warn { border-color: #fde68a; background: #fffbeb; } .mg-note.warn i { color: var(--warning); }
.mg-note.info { border-color: #bfdbfe; background: #eff6ff; } .mg-note.info i { color: var(--info); }
.mg-note .mg-btn { width: auto; min-height: 40px; margin-top: 8px; font-size: .84rem; padding: 8px 14px; }

.mg-status { display: inline-flex; align-items: center; gap: 8px; font-size: .76rem; color: var(--muted); margin-top: 12px; }
.mg-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.mg-status.on .dot { background: var(--success); box-shadow: 0 0 0 4px rgba(22, 163, 74, .15); }
.mg-status.off .dot { background: var(--danger); }
.mg-center { text-align: center; }
.mg-foot { margin-top: 18px; text-align: center; font-size: .74rem; color: var(--faint); }

@keyframes mg-shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
.mg-shake { animation: mg-shake .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes mg-spin { to { transform: rotate(360deg); } }
@keyframes mg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.mg-step { animation: mg-in .28s ease; }

/* stepper */
.mg-stepper { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin: 2px 0 18px; padding: 0; list-style: none; }
.mg-stepper li { min-width: 0; }
.mg-stepper button { width: 100%; border: 0; background: none; padding: 0; text-align: left; color: var(--faint); font: inherit; cursor: pointer; }
.mg-stepper button[disabled] { cursor: not-allowed; }
.mg-stepper .bar { display: block; height: 5px; border-radius: 99px; background: var(--line); margin-bottom: 7px; overflow: hidden; }
.mg-stepper .bar::after { content: ""; display: block; height: 100%; width: 0; background: var(--accent-gradient); transition: width .35s ease; }
.mg-stepper .done .bar::after, .mg-stepper .cur .bar::after { width: 100%; }
.mg-stepper .lbl { display: block; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-stepper .cur .lbl, .mg-stepper .done .lbl { color: var(--primary); }
.mg-step-title { font-weight: 800; font-size: 1.05rem; margin: 0 0 12px; color: var(--primary); }
.mg-wiz-nav { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 8px; }
.mg-wiz-nav .mg-btn-ghost { width: auto; padding: 12px 18px; }
.mg-wiz-nav .only { grid-column: 1 / -1; }
.mg-saved { font-size: .74rem; color: var(--faint); text-align: center; margin-top: 10px; min-height: 18px; }

.mg-grid { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 14px; }

/* strength meter */
.mg-strength { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
.mg-strength i { height: 4px; border-radius: 99px; background: var(--line); transition: background var(--transition); }
.mg-strength[data-level="1"] i:nth-child(1) { background: var(--danger); }
.mg-strength[data-level="2"] i:nth-child(-n+2) { background: var(--warning); }
.mg-strength[data-level="3"] i { background: var(--success); }

/* photo / logo picker */
.mg-photo { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: 16px;
            background: var(--soft); margin-bottom: 14px; transition: border-color var(--transition), background var(--transition); }
.mg-photo.drag { border-color: var(--accent); background: #eff6ff; }
.mg-photo img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; background: #e2e8f0; flex: 0 0 auto; border: 3px solid #e0e7ff; }
.mg-photo.logo img { border-radius: 16px; object-fit: contain; background: #fff; padding: 6px; }
.mg-photo .acts { display: flex; flex-wrap: wrap; gap: 8px; }
.mg-photo .mg-btn { width: auto; min-height: 44px; padding: 8px 14px; font-size: .84rem; }
.mg-photo small { display: block; color: var(--muted); font-size: .73rem; margin-top: 6px; }
.mg-camera { margin: -4px 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--soft); }
.mg-camera video { width: 100%; max-width: 320px; aspect-ratio: 4 / 3; display: block; margin: 0 auto 10px; border-radius: 12px; background: #000; object-fit: cover; }
.mg-camera .acts { display: flex; gap: 8px; justify-content: center; }
.mg-camera .mg-btn { width: auto; min-height: 44px; }

.mg-hero { display: none; }

.mg-toast { position: fixed; left: 16px; right: 16px; top: calc(14px + env(safe-area-inset-top, 0px)); margin: 0 auto; max-width: 420px; z-index: 50;
            padding: 13px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem; color: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, .25);
            animation: mg-in .25s ease; }
.mg-toast.success { background: var(--success); } .mg-toast.error { background: var(--danger); } .mg-toast.info { background: var(--info); }

/* ===================================================================================
   ≥ 640px — tablet: two-column fields, form centred
   =================================================================================== */
@media (min-width: 640px) {
    .mg-banner { padding: 20px 28px 26px; margin: 0 16px; border-radius: 0 0 24px 24px; }
    .mg-tagline { font-size: 1.6rem; }
    .mg-form-side { padding: 28px 24px 40px; }
    .mg-card { padding: 28px 28px; }
    .mg-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mg-grid .full { grid-column: 1 / -1; }
    .mg-h1 { font-size: 1.7rem; }
}
@media (min-width: 640px) and (max-width: 1023.98px) {
    .mg-form-side { display: flex; flex-direction: column; justify-content: center; }
}

/* ===================================================================================
   ≥ 1024px — desktop: TWO EQUAL CARDS side by side (form | brand panel), same width and the
   same height, centred on the page; copyright line underneath. The brand panel is the page's
   ONLY logo here (the phone banner is hidden).
   Grid trick: .mg-form-side becomes "display: contents", so the form card, the brand card and
   the footer are all items of one grid - row 1 = the two cards (stretched to equal height).
   =================================================================================== */
@media (min-width: 1024px) {
    .mg-banner { display: none; }
    .mg-main {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto;
        align-content: center; align-items: stretch; column-gap: 24px; row-gap: 14px;
        width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px;
    }
    .mg-form-side { display: contents; }
    .mg-card, .mg-card.wide {
        grid-column: 1; grid-row: 1; max-width: none; margin: 0;
        display: flex; flex-direction: column; justify-content: center; padding: 32px 34px;
    }
    .mg-foot { grid-column: 1 / -1; grid-row: 2; margin: 0; }

    /* Brand card: 3 rows — header (top) · message (centred in the free space) · footer (bottom).
       Same height as the form card; equal padding on all sides; sizes scale with the screen. */
    .mg-hero {
        grid-column: 2; grid-row: 1;
        display: grid; grid-template-rows: auto 1fr auto; row-gap: 24px;
        position: relative; overflow: hidden; margin: 0; padding: clamp(26px, 2.4vw, 36px);
        border-radius: var(--radius); color: #fff;
        background: radial-gradient(120% 140% at 100% 0%, #334155 0%, #1e293b 45%, #0f172a 100%);
        box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
    }
    .mg-hero::before { content: ""; position: absolute; right: -110px; top: -110px; width: 340px; height: 340px; border-radius: 50%;
                       background: radial-gradient(circle, rgba(99, 102, 241, .45), transparent 70%); pointer-events: none; }
    .mg-hero::after { content: ""; position: absolute; left: -110px; bottom: -150px; width: 340px; height: 340px; border-radius: 50%;
                      background: radial-gradient(circle, rgba(59, 130, 246, .22), transparent 70%); pointer-events: none; }
    .mg-hero > * { position: relative; z-index: 1; min-width: 0; }

    /* 1 · header: logo beside name (like the app header) */
    .mg-hero-head { display: flex; align-items: center; gap: 14px; }
    .mg-hero .mg-logo { width: clamp(48px, 3.6vw, 56px); height: clamp(48px, 3.6vw, 56px); border-radius: 14px; }
    .mg-hero-id { min-width: 0; }
    .mg-hero-name { font-weight: 800; font-size: clamp(.98rem, 1.1vw, 1.1rem); line-height: 1.25; margin: 0;
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .mg-hero-sub { font-size: .76rem; color: #94a3b8; margin-top: 2px; letter-spacing: .01em; }

    /* 2 · message: optically centred (slightly above the middle) in the free space */
    .mg-hero-body { align-self: center; padding-bottom: 4%; }
    .mg-hero h2 { font-weight: 800; font-size: clamp(2.1rem, 3.1vw, 3.1rem); line-height: 1.04; letter-spacing: -.025em; margin: 0; }
    .mg-hero h2 em { font-style: normal; display: block; background: linear-gradient(135deg, #93c5fd, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
    .mg-hero p { color: #cbd5e1; max-width: 36ch; margin: 14px 0 0; font-size: clamp(.88rem, .95vw, .96rem); line-height: 1.55; }

    /* 3 · footer: thin divider, then ONE row of equal-width badges spanning the card */
    /* footer: badges size to their label and together fill the full row (no wrapping, nothing cut) */
    .mg-hero-foot { display: flex; flex-wrap: nowrap; gap: 8px;
                    padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .10); }
    .mg-badge { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; padding: 9px 10px;
                border-radius: 11px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12);
                font-size: clamp(.68rem, .74vw, .78rem); font-weight: 600; color: #e2e8f0; white-space: nowrap; }
    .mg-badge > span { overflow: hidden; text-overflow: ellipsis; }
    .mg-badge i { color: #93c5fd; flex: 0 0 auto; }
}

/* ≥ 1440px — ultra-wide: the same two cards, a little roomier */
@media (min-width: 1440px) {
    .mg-main { max-width: 1180px; column-gap: 28px; }
    .mg-card, .mg-card.wide { padding: 36px 40px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- success pages (registration received / gym created) ---------- */
.mg-success { text-align: center; }
.mg-success .tick { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center;
                    background: #f0fdf4; color: var(--success); font-size: 1.8rem; border: 1px solid #bbf7d0; }
.mg-success .mg-lead { margin-bottom: 14px; }
.mg-code { display: inline-block; padding: 10px 22px; margin: 4px 0 16px; border-radius: 14px; background: var(--soft); border: 1.5px dashed var(--line-strong);
           font-size: 1.6rem; font-weight: 800; letter-spacing: .08em; color: var(--primary); font-variant-numeric: tabular-nums; }
