/* ============================================================
   Panel sign-in family (login, forgot / reset password, invitation, forced password change,
   sign-up, waiting and closed screens). One file; markup in resources/views/workspace/auth.
   Panel language: white surface, hairline borders, 10-14px radius, ~13px text, micro uppercase
   headings, one slate accent (#1e293b), light and dark (html[data-theme="dark"]).
   The auth card has a fixed reading width (exception allowed by the brief).
   ============================================================ */

:root {
    color-scheme: light;
    --au-page: #f8fafc;
    --au-card: #ffffff;
    --au-inset: #f8fafc;
    --au-hover: #f1f5f9;
    --au-line: #e2e8f0;
    --au-line-2: #f1f5f9;
    --au-text-1: #0f172a;
    --au-text-2: #334155;
    --au-text-3: #64748b;
    --au-text-4: #94a3b8;
    --au-accent: #1e293b;
    --au-accent-hover: #0f172a;
    --au-accent-text: #ffffff;
    --au-ring: rgba(30, 41, 59, .14);
    --au-grid: rgba(15, 23, 42, .045);
    --au-danger: #dc2626;
    --au-danger-bg: #fef2f2;
    --au-danger-line: #fecaca;
    --au-warn: #b45309;
    --au-warn-bg: #fffbeb;
    --au-warn-line: #fde68a;
    --au-ok: #047857;
    --au-ok-bg: #ecfdf5;
    --au-ok-line: #a7f3d0;
    --au-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px -12px rgba(15, 23, 42, .12);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --au-page: #0b1220;
    --au-card: #111a2c;
    --au-inset: #0d1526;
    --au-hover: #182338;
    --au-line: #243350;
    --au-line-2: #1b2740;
    --au-text-1: #e8eef8;
    --au-text-2: #c3cede;
    --au-text-3: #94a3b8;
    --au-text-4: #6b7a90;
    --au-accent: #e8eef8;
    --au-accent-hover: #ffffff;
    --au-accent-text: #0b1220;
    --au-ring: rgba(232, 238, 248, .16);
    --au-grid: rgba(232, 238, 248, .035);
    --au-danger: #f87171;
    --au-danger-bg: rgba(248, 113, 113, .08);
    --au-danger-line: rgba(248, 113, 113, .3);
    --au-warn: #fbbf24;
    --au-warn-bg: rgba(251, 191, 36, .08);
    --au-warn-line: rgba(251, 191, 36, .28);
    --au-ok: #34d399;
    --au-ok-bg: rgba(52, 211, 153, .08);
    --au-ok-line: rgba(52, 211, 153, .28);
    --au-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -16px rgba(0, 0, 0, .6);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px 32px;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--au-text-2);
    background-color: var(--au-page);
    /* hairline ledger grid fading out from the top: the panel's table rhythm as a backdrop */
    background-image:
        linear-gradient(var(--au-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--au-grid) 1px, transparent 1px);
    background-size: 28px 28px;
    background-position: center top;
    -webkit-font-smoothing: antialiased;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, transparent 0%, var(--au-page) 70%);
    z-index: 0;
}
body > * { position: relative; z-index: 1; }

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ── Brand bar (top left on wide screens, centred above the card on narrow ones) ── */
.auth-top {
    width: 100%;
    max-width: 1200px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.auth-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--au-text-1); }
.auth-brand:focus-visible { outline: 2px solid var(--au-accent); outline-offset: 3px; border-radius: 8px; }
.auth-brand-mark {
    width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--au-accent); color: var(--au-accent-text);
    font-size: 14px; font-weight: 800; letter-spacing: -.04em; line-height: 1;
}
.auth-brand-word { font-size: 16px; font-weight: 750; letter-spacing: -.035em; line-height: 1; }
.auth-brand-num { font-weight: 450; color: var(--au-text-4); margin-left: .04em; }
.auth-top-link { font-size: 12px; font-weight: 600; color: var(--au-text-3); text-decoration: none; }
.auth-top-link:hover { color: var(--au-text-1); }

/* ── Card ── */
.auth-main { flex: 1; width: 100%; display: flex; justify-content: center; align-items: flex-start; padding-top: 7vh; }
.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--au-card);
    border: 1px solid var(--au-line);
    border-radius: 14px;
    box-shadow: var(--au-shadow);
    padding: 28px 28px 22px;
    animation: au-rise .32s cubic-bezier(.2, .7, .2, 1) both;
}
.login-container.wide { max-width: 560px; }
body:not(.auth-shell) { justify-content: center; padding-top: 32px; }
body.auth-scroll:not(.auth-shell) { justify-content: flex-start; padding-top: 40px; }

@keyframes au-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .login-container { animation: none; } }

.login-header { margin-bottom: 20px; }
.logo-section { margin-bottom: 14px; }
.logo-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--au-inset); border: 1px solid var(--au-line);
    color: var(--au-text-1); font-size: 14px;
}
.auth-eyebrow, .login-header .auth-eyebrow {
    display: block;
    font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
    color: var(--au-text-4); margin: 0 0 6px;
}
.login-header h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; color: var(--au-text-1); }
.login-header p { margin: 0; font-size: 13px; color: var(--au-text-3); }

/* ── Fields ── */
.form-group { margin: 0 0 14px; position: relative; border: 0; padding: 0; }
.form-group > label, .label-row label {
    display: block; margin: 0 0 5px;
    font-size: 12px; font-weight: 600; color: var(--au-text-2);
}
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 5px; }
.label-row label { margin: 0; }
.switch-account, .label-link { font-size: 12px; font-weight: 600; color: var(--au-text-3); text-decoration: none; white-space: nowrap; background: none; border: 0; padding: 0; cursor: pointer; }
.switch-account:hover, .label-link:hover { color: var(--au-text-1); text-decoration: underline; }

.input-wrapper { position: relative; }
.form-control {
    width: 100%; height: 38px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--au-line); border-radius: 10px;
    background: var(--au-card); color: var(--au-text-1);
    font-size: 13px;
    transition: border-color .14s, box-shadow .14s, background-color .14s;
}
.form-control::placeholder { color: var(--au-text-4); }
.form-control:hover { border-color: var(--au-text-4); }
.form-control:focus { outline: none; border-color: var(--au-accent); box-shadow: 0 0 0 3px var(--au-ring); }
.form-control[aria-invalid="true"] { border-color: var(--au-danger); }
.input-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    font-size: 12px; color: var(--au-text-4); pointer-events: none; transition: color .14s;
}
.form-control:focus + .input-icon, .form-control:focus ~ .input-icon { color: var(--au-text-1); }
.input-wrapper.has-toggle .form-control { padding-right: 40px; }
.pw-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent;
    color: var(--au-text-4); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.pw-toggle:hover { color: var(--au-text-1); background: var(--au-hover); }
.pw-toggle:focus-visible { outline: 2px solid var(--au-accent); outline-offset: -2px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.form-hint { font-size: 12px; color: var(--au-text-3); margin: 5px 0 0; line-height: 1.5; }

/* password strength meter (change / reset screens) */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 7px; }
.pw-meter span { height: 3px; border-radius: 3px; background: var(--au-line); transition: background-color .2s; }
.pw-meter[data-level="1"] span:nth-child(-n+1) { background: var(--au-danger); }
.pw-meter[data-level="2"] span:nth-child(-n+2) { background: var(--au-warn); }
.pw-meter[data-level="3"] span:nth-child(-n+3) { background: var(--au-text-3); }
.pw-meter[data-level="4"] span { background: var(--au-ok); }

/* ── Remember / forgot row ── */
.remember-forgot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 2px 0 16px; }
.remember-me { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--au-text-3); }
.remember-me label { cursor: pointer; }
.remember-me input, .check-line input { width: 15px; height: 15px; margin: 0; accent-color: var(--au-accent); cursor: pointer; }
.forgot-password { font-size: 12px; font-weight: 600; color: var(--au-text-2); text-decoration: none; }
.forgot-password:hover { color: var(--au-text-1); text-decoration: underline; }

/* ── Buttons ── */
.btn-login {
    width: 100%; height: 38px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--au-accent); border-radius: 10px;
    background: var(--au-accent); color: var(--au-accent-text);
    font-size: 13px; font-weight: 650; letter-spacing: -.005em;
    cursor: pointer; text-decoration: none;
    transition: background-color .14s, box-shadow .14s, transform .06s;
}
.btn-login:hover { background: var(--au-accent-hover); }
.btn-login:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--au-ring); }
.btn-login:active { transform: translateY(1px); }
.btn-login[disabled], .btn-login.loading { cursor: progress; opacity: .8; }
.btn-login .loading {
    display: none; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: au-spin .7s linear infinite;
}
.btn-login.loading .loading { display: inline-block; }
@keyframes au-spin { to { transform: rotate(360deg); } }

.btn-ghost {
    width: 100%; height: 36px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--au-line); border-radius: 10px;
    background: var(--au-card); color: var(--au-text-2);
    font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: border-color .14s, color .14s, background-color .14s;
}
.btn-ghost:hover { border-color: var(--au-text-4); color: var(--au-text-1); background: var(--au-hover); }
.btn-ghost:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--au-ring); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row form { margin: 0; }
button[aria-busy="true"] { opacity: .65; cursor: progress; }

/* ── Alerts ── */
.alert {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 9px 12px; margin: 0 0 14px;
    border: 1px solid; border-radius: 10px;
    font-size: 12.5px; font-weight: 500; line-height: 1.45;
}
.alert i { margin-top: 2px; font-size: 12px; }
.alert-danger { color: var(--au-danger); background: var(--au-danger-bg); border-color: var(--au-danger-line); }
.alert-warning { color: var(--au-warn); background: var(--au-warn-bg); border-color: var(--au-warn-line); }
.alert-success { color: var(--au-ok); background: var(--au-ok-bg); border-color: var(--au-ok-line); }

/* ── Footer inside the card ── */
.footer-links {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px;
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--au-line-2);
}
.footer-links:empty { display: none; }
.footer-links a { font-size: 12px; font-weight: 600; color: var(--au-text-3); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.footer-links a:hover { color: var(--au-text-1); }
.footer-links i { font-size: 11px; }

.auth-foot { margin-top: 18px; font-size: 11px; color: var(--au-text-4); text-align: center; }

/* ── Sign-up / invitation / waiting extras ── */
.chip-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-picker label { margin: 0; cursor: pointer; }
.chip-picker input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-picker span {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
    border: 1px solid var(--au-line); border-radius: 8px;
    font-size: 12px; font-weight: 600; color: var(--au-text-2); background: var(--au-card);
    transition: border-color .14s, background-color .14s, color .14s;
}
.chip-picker span i { font-size: 11px; color: var(--chip, var(--au-text-4)); }
.chip-picker input:checked + span { border-color: var(--au-accent); background: var(--au-accent); color: var(--au-accent-text); }
.chip-picker input:checked + span i { color: var(--au-accent-text); }
.chip-picker input:focus-visible + span { box-shadow: 0 0 0 3px var(--au-ring); }
.check-line { display: flex; gap: 9px; align-items: flex-start; font-size: 12px; color: var(--au-text-3); line-height: 1.5; margin: 4px 0 16px; }
.check-line input { margin-top: 2px; flex: none; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.state-box {
    border: 1px solid var(--au-line); border-radius: 10px; padding: 11px 13px;
    background: var(--au-inset); margin-bottom: 14px; font-size: 12.5px; color: var(--au-text-2); line-height: 1.55;
}
.state-box strong { color: var(--au-text-1); }
.state-meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; }
.state-meta dt { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--au-text-4); padding-top: 2px; }
.state-meta dd { margin: 0; color: var(--au-text-1); font-weight: 600; overflow-wrap: anywhere; }
.state-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.state-steps li { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--au-text-3); }
.state-steps li .dot {
    width: 22px; height: 22px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; border: 1px solid var(--au-line); color: var(--au-text-4);
}
.state-steps li.done { color: var(--au-text-1); font-weight: 600; }
.state-steps li.done .dot { background: var(--au-accent); border-color: var(--au-accent); color: var(--au-accent-text); }
.state-steps li.now .dot { border-color: var(--au-accent); color: var(--au-text-1); }

/* ── Narrow screens (390 px) ── */
@media (max-width: 480px) {
    body { padding: 0 12px 24px; }
    .auth-top { justify-content: center; height: 56px; }
    .auth-top-link { display: none; }
    .auth-main { padding-top: 2vh; }
    .login-container { padding: 22px 18px 18px; border-radius: 12px; }
    .remember-forgot { flex-wrap: wrap; }
    .btn-row { grid-template-columns: 1fr; }
}
