html,
body {
    min-height: 100%;
}

:root {
    --tgui-bg-color: #efeff4;
    --tgui-secondary-bg-color: #ffffff;
    --tgui-tertiary-bg-color: #f2f2f7;
    --tgui-text-color: #000000;
    --tgui-subtitle-text-color: #6d6d72;
    --tgui-hint-color: #8e8e93;
    --tgui-link-color: #007aff;
    --tgui-button-color: #007aff;
    --tgui-button-text-color: #ffffff;
    --tgui-outline-color: rgba(60, 60, 67, 0.12);
    --tgui-danger-color: #ff3b30;
}

body.auth-page {
    margin: 0;
    padding: 24px 0 40px;
    background: var(--tgui-bg-color);
    color: var(--tgui-text-color);
    font-family: "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.auth-shell {
    width: min(100%, 480px);
    margin: 0 auto;
    padding: 0 16px;
}

.auth-panel {
    width: 100%;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-header {
    padding: 8px 8px 0;
    text-align: center;
}

.auth-brand {
    display: grid;
    justify-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.auth-logo {
    display: block;
    width: 56px;
    height: auto;
    margin: 0 auto;
}

.auth-app-name {
    color: var(--tgui-hint-color);
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
}

.auth-title {
    margin: 0;
    font-size: 32px;
    line-height: 1.1;
    font-family: "SF Pro Display", "SF Pro Text", "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.auth-subtitle {
    max-width: 28rem;
    margin: 8px auto 0;
    color: var(--tgui-hint-color);
    font-size: 15px;
    line-height: 1.45;
}

.auth-alert {
    margin: 0;
    border-radius: 12px;
    border: 1px solid var(--tgui-outline-color);
    box-shadow: none;
}

.auth-group {
    display: grid;
    gap: 8px;
}

.auth-section-label {
    margin: 0 4px;
    color: var(--tgui-hint-color);
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
}

.auth-list {
    overflow: hidden;
    border-radius: 14px;
    background: var(--tgui-secondary-bg-color);
    box-shadow: 0 0 0 1px var(--tgui-outline-color) inset;
}

.auth-row {
    display: block;
    padding: 10px 16px 12px;
}

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

.auth-row-grid > .auth-row {
    min-width: 0;
}

.auth-row-grid > .auth-row + .auth-row {
    border-top: 0;
    border-left: 1px solid var(--tgui-outline-color);
}

.auth-list > .auth-row-grid + * {
    border-top: 1px solid var(--tgui-outline-color);
}

.auth-row--phone {
    overflow: visible;
    padding-top: 10px;
    padding-bottom: 12px;
}

.auth-row + .auth-row,
.auth-option + .auth-option {
    border-top: 1px solid var(--tgui-outline-color);
}

.auth-row:focus-within {
    background: var(--tgui-tertiary-bg-color);
}

.auth-row--phone:focus-within {
    background: var(--tgui-tertiary-bg-color);
}

.auth-row__label {
    display: block;
    margin-bottom: 4px;
    color: var(--tgui-hint-color);
    font-size: 13px;
    line-height: 18px;
}

.auth-input.form-control {
    min-height: 24px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--tgui-text-color);
    font-size: 17px;
    line-height: 22px;
    box-shadow: none;
}

.auth-input.form-select {
    min-height: 24px;
    padding: 0 28px 0 0;
    border: 0;
    border-radius: 0;
    background-color: transparent;
    color: var(--tgui-text-color);
    font-size: 17px;
    line-height: 22px;
    box-shadow: none;
    background-position: right center;
}

.auth-input.form-control::placeholder {
    color: #b3b3b8;
}

.auth-input.form-control:focus,
.auth-input.form-select:focus,
.auth-input.form-control.is-invalid:focus {
    background: transparent;
    box-shadow: none;
}

.auth-input.form-control.is-invalid,
.auth-input.form-select.is-invalid {
    border: 0;
    background-image: none;
}

.auth-list.tg-list--select-open {
    position: relative;
    z-index: 4;
    overflow: visible;
}

.auth-row.tg-input-cell--select,
.input-group.tg-input-cell--select {
    position: relative;
}

.auth-row.tg-input-cell--select.is-open,
.input-group.tg-input-cell--select.is-open {
    z-index: 5;
}

.tg-native-select {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.tg-select-shell {
    position: relative;
    display: block;
}

.tg-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--tgui-text-color);
    font-size: 17px;
    line-height: 22px;
    text-align: left;
    box-shadow: none;
}

.tg-select-trigger:focus {
    outline: none;
}

.tg-select-trigger__content {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tg-select-trigger__flag,
.tg-select-option__flag {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    object-fit: cover;
}

.tg-select-trigger__value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tg-select-trigger__icon {
    position: relative;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
}

.tg-select-trigger__icon::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 9px;
    height: 9px;
    border-right: 2px solid #8e8e93;
    border-bottom: 2px solid #8e8e93;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.tg-select-shell.is-open .tg-select-trigger__icon::before {
    transform: rotate(225deg);
}

.tg-select-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: -12px;
    right: -12px;
    display: grid;
    gap: 4px;
    padding: 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
    border: 1px solid rgba(60, 60, 67, 0.08);
    backdrop-filter: blur(16px);
    z-index: 20;
    overflow-y: auto;
}

.tg-select-shell--top .tg-select-menu {
    top: auto;
    bottom: calc(100% + 10px);
}

.tg-select-option {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--tgui-text-color);
    font-size: 17px;
    line-height: 22px;
    text-align: left;
}

.tg-select-option__content {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tg-select-option:hover,
.tg-select-option:focus {
    background: var(--tgui-tertiary-bg-color);
    outline: none;
}

.tg-select-option.is-selected {
    background: rgba(0, 122, 255, 0.1);
    color: var(--tgui-link-color);
    font-weight: 600;
}

.auth-row .invalid-feedback {
    display: block;
    margin-top: 6px;
    color: var(--tgui-danger-color);
    font-size: 13px;
    line-height: 18px;
}

.auth-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
}

.auth-option:has(.auth-option__input:checked) {
    background: var(--tgui-tertiary-bg-color);
}

.auth-option__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.auth-option__mark {
    position: relative;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border: 2px solid #c7c7cc;
    border-radius: 50%;
}

.auth-option__input:checked + .auth-option__mark {
    border-color: var(--tgui-link-color);
}

.auth-option__input:checked + .auth-option__mark::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: var(--tgui-link-color);
}

.auth-option__content {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.auth-option__title {
    font-size: 17px;
    line-height: 22px;
    font-weight: 400;
}

.auth-option__hint,
.auth-helper {
    margin: 0;
    color: var(--tgui-hint-color);
    font-size: 13px;
    line-height: 18px;
}

.auth-helper {
    padding: 0 4px;
}

.auth-actions {
    display: grid;
    gap: 12px;
}

.auth-submit {
    min-height: 50px;
    margin: 0;
    border: 0;
    border-radius: 12px;
    background: var(--tgui-button-color);
    color: var(--tgui-button-text-color);
    font-size: 17px;
    line-height: 22px;
    font-weight: 600;
    box-shadow: none;
}

.auth-submit:hover,
.auth-submit:focus {
    background: #006de0;
    color: var(--tgui-button-text-color);
}

.auth-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.auth-link {
    color: var(--tgui-link-color);
    font-size: 15px;
    line-height: 20px;
    font-weight: 500;
    text-decoration: none;
}

.auth-link:hover {
    color: #005fcc;
}

@media (max-width: 575.98px) {
    body.auth-page {
        padding-top: 20px;
    }

    .auth-shell {
        padding: 0 12px;
    }

    .auth-title {
        font-size: 28px;
    }

    .auth-row-grid {
        grid-template-columns: 1fr;
    }

    .auth-row-grid > .auth-row + .auth-row {
        border-left: 0;
        border-top: 1px solid var(--tgui-outline-color);
    }

    .tg-select-menu {
        left: 0;
        right: 0;
        max-height: min(280px, calc(100dvh - 120px));
    }
}
