/* ═══════════════════════════════════════════════════════════════════════
   TXI Lead Manager — sign-in.

   Modelled on how Apple builds a sign-in surface, which is less about glass
   effects than about restraint:

   • One accent colour and a lot of near-white. Colour marks the action and
     nothing else.
   • Type set optically — tracking tightens as size grows, loosens as it drops.
   • Motion that is short (200–400ms), eased rather than linear, and only used
     to explain where something came from. Nothing bounces.
   • Depth from large, soft, low-opacity shadows rather than hard borders.
   • A visible focus ring on everything: a sign-in form is the one screen
     people routinely navigate by keyboard.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --ink:        #1d1d1f;      /* near-black; true #000 reads as a hole */
    --ink-2:      #424245;
    --muted:      #86868b;
    --hair:       rgba(0, 0, 0, .09);
    --accent:     #0071e3;
    --accent-ink: #0058b8;
    --surface:    #ffffff;
    --canvas:     #fbfbfd;
    --radius:     18px;
    --ease:       cubic-bezier(.32, .72, 0, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter',
                 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 17px;
    line-height: 1.47;
    letter-spacing: -.022em;
}

.auth { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }

/* ── Brand side ───────────────────────────────────────────────────── */
.auth-brand {
    position: relative;
    display: flex; flex-direction: column; justify-content: center;
    padding: 72px clamp(40px, 6vw, 96px);
    background: linear-gradient(180deg, #f5f5f7 0%, #ebedf0 100%);
    overflow: hidden;
}

/* One soft light source, placed off-centre and static. A gradient animating
   behind a password field is noise, not craft. */
.auth-brand::before {
    content: '';
    position: absolute; top: -22%; left: -12%;
    width: 74%; aspect-ratio: 1; border-radius: 50%;
    background: radial-gradient(circle, rgba(0,113,227,.14), transparent 68%);
    filter: blur(28px);
    pointer-events: none;
}

.brand-mark { position: relative; margin-bottom: 40px; }
.brand-mark img { max-height: 84px; width: auto; display: block; }

.brand-copy { position: relative; }
.brand-copy h1 {
    margin: 0 0 14px;
    font-size: clamp(38px, 4.4vw, 56px);
    line-height: 1.05;
    font-weight: 600;
    letter-spacing: -.03em;
}
.brand-copy h1 em {
    font-style: normal; font-weight: 400; color: var(--muted); display: block;
}
.brand-copy p {
    margin: 0; max-width: 38ch;
    font-size: 19px; color: var(--ink-2); letter-spacing: -.02em;
}

/* Live pipeline — real numbers, quietly presented. */
.pipeline {
    position: relative; margin-top: 52px; max-width: 400px;
    background: rgba(255,255,255,.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: 0 24px 60px -22px rgba(0,0,0,.16);
}
.pipeline-head {
    display: flex; justify-content: space-between;
    font-size: 12px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 16px;
}
.stage { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 12px; margin-bottom: 11px; }
.stage:last-child { margin-bottom: 0; }
.stage-name { font-size: 13px; color: var(--ink-2); letter-spacing: -.01em;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-track { height: 6px; border-radius: 99px; background: rgba(0,0,0,.07); overflow: hidden; }
.stage-fill {
    display: block; height: 100%; border-radius: 99px;
    background: linear-gradient(90deg, #0071e3, #42a5f5);
    transform-origin: left;
    animation: grow .9s var(--ease) both;
}
.stage-val { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.auth-foot { position: relative; margin-top: 48px; font-size: 12px; color: var(--muted); }

/* ── Form side ────────────────────────────────────────────────────── */
.auth-form-wrap {
    display: flex; align-items: center; justify-content: center;
    padding: 48px 28px; background: var(--surface);
}

.auth-form { width: 100%; max-width: 384px; animation: rise .5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.auth-form h2 { margin: 0 0 6px; font-size: 32px; font-weight: 600; letter-spacing: -.028em; }
.auth-form .sub { margin: 0 0 32px; font-size: 15px; color: var(--muted); letter-spacing: -.01em; }

.field { margin-bottom: 16px; }
.field label {
    display: block; margin-bottom: 7px;
    font-size: 12.5px; font-weight: 500; color: var(--ink-2); letter-spacing: -.005em;
}
.field input {
    width: 100%; padding: 14px 16px;
    font-family: inherit; font-size: 16px;   /* 16px stops iOS zooming on focus */
    letter-spacing: -.01em;
    color: var(--ink); background: #fff;
    border: 1px solid var(--hair); border-radius: 12px;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.field input::placeholder { color: #b6b6bb; }
.field input:hover:not(:disabled) { border-color: rgba(0,0,0,.18); }
.field input:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0,113,227,.16);
}
.field input:disabled { background: #f5f5f7; color: var(--muted); cursor: not-allowed; }

.btn-auth {
    width: 100%; margin-top: 10px; padding: 14px 20px;
    font-family: inherit; font-size: 16px; font-weight: 500; letter-spacing: -.01em;
    color: #fff; background: var(--accent);
    border: none; border-radius: 12px; cursor: pointer;
    transition: background .2s var(--ease), transform .12s var(--ease), box-shadow .2s var(--ease);
}
.btn-auth:hover:not(:disabled) { background: var(--accent-ink); box-shadow: 0 8px 24px -8px rgba(0,113,227,.6); }
.btn-auth:active:not(:disabled) { transform: scale(.985); }
.btn-auth:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(0,113,227,.28); }
.btn-auth:disabled { background: #d2d2d7; color: #fff; cursor: not-allowed; }

.msg {
    padding: 12px 15px; border-radius: 12px; font-size: 14px;
    margin-bottom: 20px; letter-spacing: -.01em;
    animation: rise .3s var(--ease) both;
}
.msg-error  { background: #fff1f0; color: #b3261e; }
.msg-notice { background: #eef6ff; color: #0058b8; }

.auth-note {
    margin: 28px 0 0; padding-top: 20px;
    border-top: 1px solid var(--hair);
    font-size: 12.5px; line-height: 1.6; color: var(--muted); letter-spacing: -.005em;
}

/* Install screen reuses these surfaces. */
.auth-form .field + .field { margin-top: 0; }
.auth-form form + .auth-note { margin-top: 24px; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; }
    .auth-brand { padding: 44px 28px 36px; }
    .brand-mark img { max-height: 62px; }
    .brand-copy h1 { font-size: 32px; }
    .brand-copy p { font-size: 16px; }
    .pipeline { display: none; }        /* on a phone the form is the job */
    .auth-foot { margin-top: 26px; }
    .auth-form-wrap { padding: 36px 24px 56px; }
}

/* ── Theme Toggle Button (Identical to main app header button) ───── */
.theme-toggle-btn {
    position: fixed !important;
    top: 24px !important;
    right: 32px !important;
    left: auto !important;
    z-index: 10000 !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all .2s cubic-bezier(.32, .72, 0, 1) !important;
    color: #1d1d1f !important;
}

.theme-toggle-btn:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18) !important;
    border-color: #0071e3 !important;
}

.theme-toggle-btn .sun-icon { display: none !important; }
.theme-toggle-btn .moon-icon { display: flex !important; align-items: center !important; justify-content: center !important; }

body.dark-theme .theme-toggle-btn {
    background: #2c2c2e !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
    color: #f5f5f7 !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4) !important;
}
body.dark-theme .theme-toggle-btn:hover {
    border-color: #0a84ff !important;
}
body.dark-theme .theme-toggle-btn .sun-icon { display: flex !important; align-items: center !important; justify-content: center !important; }
body.dark-theme .theme-toggle-btn .moon-icon { display: none !important; }

/* ── Dark mode support via body.dark-theme or OS preference ─────── */
body.dark-theme {
    --ink: #f5f5f7; --ink-2: #d2d2d7; --muted: #86868b;
    --hair: rgba(255,255,255,.14);
    --accent: #0a84ff; --accent-ink: #409cff;
    --surface: #1d1d1f; --canvas: #000;
}
body.dark-theme .auth-brand { background: linear-gradient(180deg, #1d1d1f, #000); }
body.dark-theme .auth-brand::before { background: radial-gradient(circle, rgba(10,132,255,.2), transparent 68%); }
body.dark-theme .auth-form-wrap { background: var(--surface); }
body.dark-theme .pipeline { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); }
body.dark-theme .stage-track { background: rgba(255,255,255,.12); }
body.dark-theme .field input { background: #2c2c2e; color: var(--ink); border-color: rgba(255,255,255,.15); }
body.dark-theme .field input::placeholder { color: #6e6e73; }
body.dark-theme .field input:disabled { background: #232325; }
body.dark-theme .btn-auth:disabled { background: #3a3a3c; color: #86868b; }
body.dark-theme .msg-error  { background: rgba(255,69,58,.14); color: #ff6961; }
body.dark-theme .msg-notice { background: rgba(10,132,255,.14); color: #64b5ff; }
body.dark-theme .brand-mark img { filter: brightness(0) invert(1); opacity: .92; }

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f5f5f7; --ink-2: #d2d2d7; --muted: #86868b;
        --hair: rgba(255,255,255,.14);
        --accent: #0a84ff; --accent-ink: #409cff;
        --surface: #1d1d1f; --canvas: #000;
    }
    .auth-brand { background: linear-gradient(180deg, #1d1d1f, #000); }
    .auth-brand::before { background: radial-gradient(circle, rgba(10,132,255,.2), transparent 68%); }
    .pipeline { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); }
    .stage-track { background: rgba(255,255,255,.12); }
    .field input { background: #2c2c2e; color: var(--ink); }
    .field input::placeholder { color: #6e6e73; }
    .field input:disabled { background: #232325; }
    .btn-auth:disabled { background: #3a3a3c; color: #86868b; }
    .msg-error  { background: rgba(255,69,58,.14); color: #ff6961; }
    .msg-notice { background: rgba(10,132,255,.14); color: #64b5ff; }
    .brand-mark img { filter: brightness(0) invert(1); opacity: .92; }
}

/* Anyone who asked the system to calm down gets no animation at all. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
