*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body.auth-page {
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg-panel);
    -webkit-font-smoothing: antialiased;
}

.auth-layout {
    display: flex;
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.auth-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    background: var(--color-bg-panel);
    padding: clamp(40px, 8vh, 68px) clamp(20px, 18%, 48px) clamp(24px, 4vh, 40px);
    overflow-x: hidden;
    overflow-y: auto;
}

.auth-panel__inner {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1 1 auto;
    width: min(100%, var(--form-inner-width));
    margin: 0 auto;
}

.auth-panel__header {
    flex-shrink: 0;
}

.auth-panel__brand {
    margin-bottom: var(--gap-logo-title);
}

.auth-panel__brand img,
.auth-panel__brand svg {
    display: block;
    max-width: 140px;
    max-height: 34px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left center;
}

.auth-panel__title {
    margin: 0;
    font-size: clamp(28px, 6vw, var(--font-size-title));
    font-weight: 700;
    line-height: 1.1;
    color: var(--color-text);
}

.auth-panel__intro {
    margin: 0;
    font-size: var(--font-size-label);
    font-weight: 500;
    line-height: 1.4;
    color: var(--color-text);
}

.auth-panel__main > .auth-panel__intro {
    margin-bottom: var(--gap-fields);
}

.auth-panel__main {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: var(--gap-header-form);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--gap-form-sections);
}

.auth-fields {
    display: flex;
    flex-direction: column;
    gap: var(--gap-fields);
}

.auth-fields[hidden] {
    display: none;
}

.auth-form__actions .auth-button[hidden] {
    display: none;
}

.auth-form > .auth-button[hidden] {
    display: none;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: var(--gap-label-input);
}

.auth-field__label {
    font-size: var(--font-size-label);
    font-weight: 600;
    line-height: 1;
    color: var(--color-text);
}

.auth-field__control {
    position: relative;
    display: flex;
    align-items: center;
    height: var(--input-height);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    background: var(--color-bg-panel);
    overflow: hidden;
}

.auth-field__control:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.auth-field__control--error {
    border-color: var(--color-error);
}

.auth-field__control--error:focus-within {
    border-color: var(--color-error);
    box-shadow: 0 0 0 1px var(--color-error);
}

.auth-field__input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 8px 16px;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-family);
    font-size: var(--font-size-input);
    font-weight: 500;
    font-style: italic;
    color: var(--color-text);
}

.auth-field__input::placeholder {
    color: var(--color-text-muted);
    font-style: italic;
}

.auth-field__input:not(:placeholder-shown) {
    font-style: normal;
    font-weight: 500;
}

.auth-field__toggle {
    flex-shrink: 0;
    margin-right: 8px;
    padding: 0;
    border: none;
    background: none;
    font-family: var(--font-family);
    font-size: var(--font-size-link);
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-primary);
    cursor: pointer;
}

.auth-field__toggle:hover {
    text-decoration: underline;
}

.auth-field__error {
    display: block;
    font-size: var(--font-size-label);
    line-height: 1.4;
    color: var(--color-error);
    min-height: calc(var(--font-size-label) * 1.4);
}

.auth-field-group {
    display: flex;
    flex-direction: column;
    gap: var(--gap-password-group);
}

.auth-link {
    font-size: var(--font-size-link);
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.auth-link:hover {
    opacity: 0.85;
}

.auth-form__actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
}

.auth-form__actions .auth-button {
    width: 100%;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-link);
    font-weight: 600;
    line-height: 1;
    color: var(--color-primary);
    text-decoration: none;
}

.auth-back-link:hover {
    text-decoration: underline;
}

.auth-back-link__icon {
    font-size: 14px;
    line-height: 1;
}

.auth-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-button);
    background: var(--color-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-button);
    font-weight: 600;
    line-height: 1.15;
    color: var(--color-button-text);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.auth-button:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.auth-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.auth-button--loading {
    pointer-events: none;
    gap: 8px;
    background: var(--color-primary-loading);
    opacity: 1;
}

.auth-button--loading:hover {
    background: var(--color-primary-loading);
}

.auth-button--loading::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(249, 249, 251, 0.35);
    border-top-color: var(--color-button-text);
    border-radius: 50%;
    animation: auth-button-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes auth-button-spin {
    to {
        transform: rotate(360deg);
    }
}

.auth-button--secondary {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.auth-button--secondary:hover:not(:disabled) {
    border-color: var(--color-text-muted);
    opacity: 1;
}

.auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.auth-actions .auth-button {
    width: auto;
    flex: 1;
    min-width: 120px;
}

.auth-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: var(--color-notice-bg);
    border: 1px solid var(--color-notice-border);
    border-radius: var(--radius-input);
}

.auth-notice[hidden] {
    display: none;
}

.auth-notice__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--color-primary);
}

.auth-notice__icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.auth-notice__body {
    flex: 1;
    min-width: 0;
}

.auth-notice__title {
    margin: 0 0 4px;
    font-size: var(--font-size-label);
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-notice-text);
}

.auth-notice__body > .auth-notice__title:last-child {
    margin-bottom: 0;
}

.auth-notice__text {
    margin: 0;
    font-size: var(--font-size-label);
    font-weight: 500;
    line-height: 1.4;
    color: var(--color-notice-text);
}

.auth-notice + .auth-form__actions {
    margin-top: var(--gap-header-form);
}

.auth-panel__main > .auth-form + .auth-form__actions {
    margin-top: var(--gap-header-form);
}

.auth-panel__main > .auth-notice {
    margin-bottom: 0;
}

.company-message {
    font-size: var(--font-size-label);
    font-style: italic;
    color: var(--color-text-muted);
    padding: 4px 0;
}

.auth-panel__footer {
	padding-top: clamp(24px, 4vh, 48px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap-footer-items);
    flex-shrink: 0;
    margin-top: auto;
    text-align: center;
}

.auth-panel__footer-logo {
    width: 113px;
    height: 28px;
}

.auth-panel__cookies {
    margin: 0;
    font-size: var(--font-size-footer);
    font-weight: 500;
    line-height: 1.4;
    color: var(--color-text);
}

.auth-panel__cookies a {
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

@media (max-width: 767px) {
    .auth-panel {
        min-height: 100dvh;
    }

    .auth-panel__inner {
        flex: 1 1 auto;
    }
}

@media (min-width: 768px) {
    body.auth-page {
        background: var(--color-bg-page);
    }

    .auth-panel {
        flex: 0 0 min(var(--panel-width-desktop), 39.5vw);
        width: min(var(--panel-width-desktop), 39.5vw);
        max-width: var(--panel-width-desktop);
        padding: clamp(32px, 8vh, var(--panel-padding-top-desktop))
            clamp(24px, 8vw, var(--panel-padding-x-desktop))
            clamp(32px, 8vh, var(--panel-padding-bottom-desktop));
    }

    .auth-panel__inner {
        margin: 0;
        max-width: 100%;
        width: 100%;
    }
}
