:root {
    color-scheme: light;
    --auth-color-primary: #488d66;
    --auth-color-primary-hover: #397553;
    --auth-color-primary-active: #2f6245;
    --auth-color-primary-rgb: 72, 141, 102;
    --auth-color-canvas: #f4f8f6;
    --auth-color-surface: #ffffff;
    --auth-color-surface-soft: #f7faf8;
    --auth-color-text: #172033;
    --auth-color-text-secondary: #5f6f65;
    --auth-color-text-muted: #7c8b82;
    --auth-color-placeholder: #89968f;
    --auth-color-border: #d8e2dc;
    --auth-color-border-strong: #b9c9bf;
    --auth-color-on-primary: #ffffff;
    --auth-color-danger: #9f2828;
    --auth-color-danger-surface: #fff1f1;
    --auth-color-danger-border: #f2c7c7;
    --auth-color-success: #17663b;
    --auth-color-success-surface: #edf9f1;
    --auth-color-success-border: #bfdfca;
    --auth-color-info: #245e72;
    --auth-color-info-surface: #eef8fb;
    --auth-color-info-border: #c5e2eb;
    --auth-color-warning: #9a5b0a;
    --auth-color-strength-weak: #c93a3a;
    --auth-color-strength-medium: #bf7200;
    --auth-color-strength-strong: #21834b;
    --auth-shadow-rgb: 23, 32, 51;
    --auth-shadow-card: 0 24px 64px rgba(var(--auth-shadow-rgb), 0.12), 0 6px 20px rgba(var(--auth-shadow-rgb), 0.06);
    --auth-focus-ring: 0 0 0 4px rgba(var(--auth-color-primary-rgb), 0.18);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--auth-color-canvas);
}

body.public-auth-page {
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 32px 18px;
    place-items: center;
    overflow-x: hidden;
    color: var(--auth-color-text);
    background:
        radial-gradient(circle at 12% 8%, rgba(var(--auth-color-primary-rgb), 0.12), transparent 28rem),
        radial-gradient(circle at 92% 94%, rgba(var(--auth-color-primary-rgb), 0.08), transparent 25rem),
        var(--auth-color-canvas);
    font-family: "Open Sans", "Segoe UI", Arial, sans-serif;
}

.auth-container {
    width: min(100%, 480px);
    padding: 38px;
    overflow: hidden;
    border: 1px solid var(--auth-color-border);
    border-radius: 18px;
    background: var(--auth-color-surface);
    box-shadow: var(--auth-shadow-card);
}

.auth-container::before {
    content: "";
    display: block;
    height: 5px;
    margin: -38px -38px 32px;
    background: var(--auth-color-primary);
}

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

.auth-header h1 {
    margin: 0;
    color: var(--auth-color-text);
    font-size: clamp(25px, 5vw, 30px);
    font-weight: 750;
    letter-spacing: -0.025em;
    line-height: 1.18;
}

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

.auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 28px;
    padding: 5px;
    border: 1px solid var(--auth-color-border);
    border-radius: 12px;
    background: var(--auth-color-surface-soft);
}

.tab-button {
    min-height: 42px;
    padding: 9px 14px;
    border: 0;
    border-radius: 8px;
    color: var(--auth-color-text-secondary);
    background: transparent;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.tab-button:hover {
    color: var(--auth-color-text);
}

.tab-button.active {
    color: var(--auth-color-primary-active);
    background: var(--auth-color-surface);
    box-shadow: 0 2px 8px rgba(var(--auth-shadow-rgb), 0.08);
}

.tab-button:focus-visible,
.auth-button:focus-visible,
.login-link a:focus-visible,
.forgot-password a:focus-visible,
.terms a:focus-visible,
.close:focus-visible {
    outline: none;
    box-shadow: var(--auth-focus-ring);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

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

.form-label {
    display: block;
    margin-bottom: 7px;
    color: var(--auth-color-text);
    font-size: 13px;
    font-weight: 700;
}

.form-input {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid var(--auth-color-border);
    border-radius: 9px;
    outline: none;
    color: var(--auth-color-text);
    background: var(--auth-color-surface);
    font: inherit;
    font-size: 16px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.form-input::placeholder {
    color: var(--auth-color-placeholder);
}

.form-input:hover {
    border-color: var(--auth-color-border-strong);
}

.form-input:focus {
    border-color: var(--auth-color-primary);
    box-shadow: var(--auth-focus-ring);
}

.auth-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 47px;
    padding: 11px 18px;
    border: 1px solid var(--auth-color-primary);
    border-radius: 9px;
    color: var(--auth-color-on-primary);
    background: var(--auth-color-primary);
    font: inherit;
    font-size: 15px;
    font-weight: 750;
    cursor: pointer;
    transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.auth-button:not(:disabled):hover {
    border-color: var(--auth-color-primary-hover);
    background: var(--auth-color-primary-hover);
    transform: translateY(-1px);
}

.auth-button:not(:disabled):active {
    border-color: var(--auth-color-primary-active);
    background: var(--auth-color-primary-active);
    transform: none;
}

.auth-button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.error,
.success,
.info {
    position: relative;
    margin-bottom: 20px;
    padding: 12px 38px 12px 13px;
    border: 1px solid;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.45;
}

.error {
    color: var(--auth-color-danger);
    border-color: var(--auth-color-danger-border);
    background: var(--auth-color-danger-surface);
}

.success {
    color: var(--auth-color-success);
    border-color: var(--auth-color-success-border);
    background: var(--auth-color-success-surface);
}

.info {
    color: var(--auth-color-info);
    border-color: var(--auth-color-info-border);
    background: var(--auth-color-info-surface);
}

.password-requirements,
.terms,
.login-link {
    color: var(--auth-color-text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.password-requirements {
    margin-top: 6px;
}

.terms {
    margin: 0 0 20px;
}

.login-link {
    margin-top: 21px;
    text-align: center;
}

.terms a,
.login-link a,
.forgot-password a {
    border-radius: 4px;
    color: var(--auth-color-primary-active);
    font-weight: 700;
    text-decoration: none;
}

.terms a:hover,
.login-link a:hover,
.forgot-password a:hover {
    text-decoration: underline;
}

.forgot-password {
    margin: -3px 0 16px;
    text-align: right;
}

.forgot-password a {
    font-size: 13px;
}

.password-strength {
    height: 5px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--auth-color-border);
}

.password-strength-bar {
    width: 0;
    height: 100%;
    transition: width 180ms ease, background-color 180ms ease;
}

.password-strength-bar.weak {
    width: 33%;
    background: var(--auth-color-strength-weak);
}

.password-strength-bar.medium {
    width: 66%;
    background: var(--auth-color-strength-medium);
}

.password-strength-bar.strong {
    width: 100%;
    background: var(--auth-color-strength-strong);
}

.password-strength-text {
    min-height: 18px;
    margin-top: 5px;
    font-size: 12px;
    font-weight: 700;
}

.password-strength-text.weak { color: var(--auth-color-strength-weak); }
.password-strength-text.medium { color: var(--auth-color-strength-medium); }
.password-strength-text.strong { color: var(--auth-color-strength-strong); }

.spinner,
.loading-spinner {
    border-style: solid;
    border-color: rgba(var(--auth-color-primary-rgb), 0.2);
    border-top-color: var(--auth-color-primary);
    border-radius: 50%;
    animation: auth-spin 800ms linear infinite;
}

.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner.active {
    display: inline-block;
}

.loading-container {
    padding: 32px 0;
    color: var(--auth-color-text-secondary);
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border-width: 3px;
}

.close {
    position: absolute;
    top: 9px;
    right: 11px;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    color: inherit;
    background: transparent;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    opacity: 0.65;
}

.close:hover {
    opacity: 1;
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 575px) {
    body.public-auth-page {
        align-items: start;
        padding: 14px;
    }

    .auth-container {
        padding: 28px 22px;
        border-radius: 15px;
    }

    .auth-container::before {
        margin: -28px -22px 26px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tab-button,
    .form-input,
    .auth-button,
    .password-strength-bar {
        transition: none;
    }
}
