:root {
    --mmco-login-bg: #0f172a;
    --mmco-login-bg-soft: #1e293b;
    --mmco-login-card-bg: #ffffff;
    --mmco-login-card-text: #0f172a;
    --mmco-login-card-muted: #64748b;
    --mmco-login-accent: #229ed9;
    --mmco-login-accent-hover: #1a8bc4;
    --mmco-login-accent-text: #ffffff;
    --mmco-login-radius: 16px;
    --mmco-login-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

body.mmco-login-page {
    background: linear-gradient(165deg, var(--mmco-login-bg) 0%, var(--mmco-login-bg-soft) 100%);
    min-height: 100vh;
    min-height: 100dvh;
    height: auto !important;
    overflow-y: auto;
}

body.mmco-login-page main {
    flex: 1 0 auto;
    width: 100%;
}

body.mmco-login-page main .container {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

.mmco-login {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}

body.mmco-tg-webapp .mmco-login {
    justify-content: center;
}

.mmco-login__inner {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.mmco-login__card {
    background: var(--mmco-login-card-bg);
    border-radius: var(--mmco-login-radius);
    box-shadow: var(--mmco-login-shadow);
    padding: 20px;
    margin-bottom: 16px;
}

body.mmco-tg-webapp .mmco-login__card {
    box-shadow: none;
    border: 1px solid rgba(127, 127, 127, 0.25);
}

.mmco-login__card-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--mmco-login-card-text);
}

.mmco-login__card-hint {
    font-size: 0.875rem;
    color: var(--mmco-login-card-muted);
    margin: 0 0 16px;
    line-height: 1.45;
}

.mmco-tg-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    background: var(--mmco-login-accent);
    color: var(--mmco-login-accent-text);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.mmco-tg-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.mmco-tg-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

.mmco-tg-btn__icon {
    font-size: 1.25rem;
}

.mmco-tg-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 0;
    color: var(--mmco-login-card-muted);
    font-size: 0.875rem;
}

.mmco-tg-loading__spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(34, 158, 217, 0.2);
    border-top-color: var(--mmco-login-accent);
    border-radius: 50%;
    animation: mmco-spin 0.7s linear infinite;
}

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

.mmco-tg-alert {
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.875rem;
    line-height: 1.45;
    margin-bottom: 12px;
}

.mmco-tg-alert--danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.mmco-tg-alert--info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.mmco-tg-pending {
    border-radius: 10px;
    padding: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.mmco-tg-widget-wrap {
    display: flex;
    justify-content: center;
}

.mmco-tg-widget-wrap iframe {
    border-radius: 12px !important;
}

body.mmco-tg-webapp .mmco-tg-widget-wrap {
    display: none !important;
}

.mmco-login__divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 16px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.8125rem;
}

.mmco-login__divider::before,
.mmco-login__divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.mmco-login__card--password .form-group {
    margin-bottom: 1rem;
}

.mmco-login__card--password label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--mmco-login-card-text);
}

.mmco-login__card--password .form-control {
    min-height: 44px;
    border-radius: 10px;
    font-size: 16px;
}

.mmco-login__card--password .btn-secondary {
    min-height: 48px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    background: var(--mmco-login-bg-soft);
    border: none;
}

.mmco-login__card--password .captcha {
    margin-bottom: 0.5rem;
}

.mmco-login__card--password .captcha img {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

body.mmco-tg-webapp .mmco-login__divider,
body.mmco-tg-webapp .mmco-login__password-block {
    display: none !important;
}

/* После ошибки TG-входа в Mini App — запасной вход по паролю */
body.mmco-tg-webapp.mmco-tg-auth-failed .mmco-login__divider,
body.mmco-tg-webapp.mmco-tg-auth-failed .mmco-login__password-block {
    display: block !important;
}

body.mmco-login-page:not(.mmco-tg-webapp) .mmco-login__password-block {
    display: block !important;
}

body.mmco-login-page:not(.mmco-tg-webapp) #tg-webapp-login-btn,
body.mmco-login-page:not(.mmco-tg-webapp) #tg-webapp-loading {
    display: none !important;
}

body.mmco-tg-webapp .mmco-login__card-hint--browser {
    display: none;
}

body.mmco-tg-webapp .mmco-login__card-hint--webapp {
    display: block;
}

.mmco-login__card-hint--webapp {
    display: none;
}

/* Пока ждём initData в Mini App — не показываем пустую карточку */
body.mmco-tg-webapp #tg-login-card #tg-webapp-loading:not(.d-none) ~ .mmco-tg-widget-wrap,
body.mmco-tg-webapp #tg-login-card .mmco-tg-widget-wrap {
    display: none !important;
}

@media (min-width: 768px) {
    .mmco-login__card {
        padding: 24px;
    }
}
