:root {
    color-scheme: light;
    --brand-blue: #0027a6;
    --brand-blue-hover: #001d7a;
    --brand-wordmark-black: #030404;
    --auth-page: #f4f6f9;
    --auth-border: #d9dee7;
    --auth-text: #1d2433;
    --auth-muted: #657084;
    --danger-color: #b42318;
    --success-color: #15803d;
    font-family: 'Inter', sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--auth-page);
}

body.auth-page {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--auth-page);
    color: var(--auth-text);
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

.auth-layout {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px 20px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 32px;
    border: 1px solid var(--auth-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 32px rgb(18 38 63 / 8%);
}

.auth-card-signup {
    max-width: 500px;
}

.auth-brand {
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 0 auto 22px;
}

.auth-brand-symbol {
    display: block;
    width: 111px;
    height: 56px;
    object-fit: contain;
}

.auth-wordmark {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.045em;
    line-height: 1.02;
}

.auth-wordmark-first {
    color: var(--brand-blue);
}

.auth-wordmark-second {
    color: var(--brand-wordmark-black);
}

.auth-header {
    margin-bottom: 24px;
    text-align: center;
}

.auth-header h1 {
    margin: 0 0 8px;
    color: var(--auth-text);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
}

.auth-header p {
    margin: 0;
    color: var(--auth-muted);
    font-size: 14px;
    line-height: 1.55;
}

.auth-form {
    margin: 0;
}

.form-group {
    min-width: 0;
    margin: 0 0 18px;
}

.form-group label,
.password-label-row label {
    display: block;
    margin: 0 0 7px;
    color: var(--auth-text);
    font-size: 14px;
    font-weight: 500;
}

.form-input {
    display: block;
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--auth-border);
    border-radius: 7px;
    outline: none;
    background: #fff;
    color: var(--auth-text);
    font: inherit;
    font-size: 14px;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.form-input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgb(0 39 166 / 16%);
}

.password-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.password-label-row label {
    margin-bottom: 7px;
}

.auth-link {
    color: var(--brand-blue);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.auth-link:hover {
    color: var(--brand-blue-hover);
    text-decoration: underline;
}

.password-wrapper {
    position: relative;
}

.password-wrapper .form-input {
    padding-right: 64px;
}

.toggle-password {
    position: absolute;
    top: 50%;
    right: 8px;
    min-width: 44px;
    min-height: 36px;
    padding: 4px 7px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--brand-blue);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
}

.remember-option {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 2px 0 20px;
    color: var(--auth-text);
    font-size: 14px;
    cursor: pointer;
}

.remember-option input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand-blue);
}

.auth-button {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--brand-blue);
    border-radius: 7px;
    background: var(--brand-blue);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.auth-button:hover {
    border-color: var(--brand-blue-hover);
    background: var(--brand-blue-hover);
}

.auth-button:disabled,
.auth-button:disabled:hover {
    border-color: var(--brand-blue);
    background: var(--brand-blue);
    cursor: not-allowed;
    opacity: 0.55;
}

/* Live field checks (e.g. group name availability on sign-up) */
.form-input.is-invalid {
    border-color: var(--danger-color);
}

.form-input.is-valid {
    border-color: var(--success-color);
}

.auth-footer {
    margin: 22px 0 0;
    color: var(--auth-muted);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.auth-footer .auth-link {
    margin-left: 3px;
}

.auth-copyright {
    margin: 16px 0 0;
    color: var(--auth-muted);
    font-size: 12px;
    text-align: center;
}

.name-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.password-hint {
    margin: 7px 0 0;
    color: var(--auth-muted);
    font-size: 12px;
    line-height: 1.45;
}

.password-strength-indicator {
    display: none;
    margin-top: 9px;
}

.strength-track {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: #e6eaf0;
}

.strength-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--brand-blue);
    transition: width 180ms ease;
}

.strength-text {
    display: block;
    margin-top: 5px;
    color: var(--auth-muted);
    font-size: 12px;
}

.error-message,
.form-error-main {
    margin-top: 7px;
    color: var(--danger-color);
    font-size: 13px;
    line-height: 1.4;
}

.form-error-main {
    margin: 0 0 16px;
    text-align: center;
}

.auth-alert {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid #f1b8b2;
    border-radius: 7px;
    background: #fff5f4;
    color: var(--danger-color);
    font-size: 13px;
    line-height: 1.45;
}

.alert-success {
    border-color: #b9c9f3;
    background: #f3f6ff;
    color: var(--brand-blue);
}

.alert-info {
    border-color: #b9c9f3;
    background: #f3f6ff;
    color: var(--brand-blue);
}

.alert-warning {
    border-color: #f5d6a0;
    background: #fff8eb;
    color: #92400e;
}

/* One-time code: one field, digits spread out */
.otp-input {
    padding-left: calc(12px + 0.5em);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5em;
    text-align: center;
}

.otp-input::placeholder {
    color: #b6bdc9;
    letter-spacing: 0.5em;
}

.auth-page :focus-visible {
    outline: 3px solid rgb(0 39 166 / 35%);
    outline-offset: 2px;
}

.form-input:focus-visible {
    outline: none;
}

@media (max-width: 480px) {
    .auth-layout {
        justify-content: flex-start;
        padding: 20px 12px;
    }

    .auth-card {
        margin: auto 0;
        padding: 24px 20px;
    }

    .name-fields {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
