<div style="max-width:420px;margin:60px auto;padding:0 16px">
<div style="background:var(--card-bg);border:1px solid var(--border);border-radius:16px;padding:32px">
<h2 style="font-size:20px;font-weight:700;margin:0 0 24px;text-align:center">Вход</h2>
<form action="/auth/login" method="post">
<input type="hidden" name="return_to" value="/items/9083">
<div style="margin-bottom:14px">
<label style="display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.04em">Email</label>
<input type="email" name="email" value="" required autocomplete="email"
style="width:100%;box-sizing:border-box;background:var(--bg);border:1.5px solid var(--border);border-radius:8px;padding:9px 12px;font-size:14px;color:var(--text);outline:none;transition:border-color .15s"
onfocus="this.style.borderColor='var(--accent)'" onblur="this.style.borderColor='var(--border)'">
</div>
<div style="margin-bottom:8px">
<label style="display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.04em">Пароль</label>
<input type="password" name="password" required autocomplete="current-password"
style="width:100%;box-sizing:border-box;background:var(--bg);border:1.5px solid var(--border);border-radius:8px;padding:9px 12px;font-size:14px;color:var(--text);outline:none;transition:border-color .15s"
onfocus="this.style.borderColor='var(--accent)'" onblur="this.style.borderColor='var(--border)'">
</div>
<div style="text-align:right;margin-bottom:16px">
<a href="/auth/forgot-password" style="font-size:12px;color:var(--text-muted);text-decoration:none">Забыли пароль?</a>
</div>
<button type="submit"
style="width:100%;background:var(--accent);color:#fff;border:none;border-radius:8px;padding:10px;font-size:14px;font-weight:600;cursor:pointer;transition:opacity .15s"
onmouseover="this.style.opacity='.85'" onmouseout="this.style.opacity='1'">
Войти
</button>
</form>
<div style="margin-top:20px;padding-top:20px;border-top:1px solid var(--border);text-align:center;font-size:13px;color:var(--text-muted)">
Нет аккаунта?
<a href="/auth/register" style="color:var(--accent);text-decoration:none;font-weight:600">Зарегистрироваться</a>
</div>
<div style="margin-top:20px;padding-top:20px;border-top:1px solid var(--border)">
<div style="font-size:12px;color:var(--text-muted);text-align:center;margin-bottom:14px;text-transform:uppercase;letter-spacing:.04em">или через Telegram</div>
<a href="https://t.me/p1_sun_bot?start=login_d388225107e6cc09"
id="tg-open-btn"
style="display:flex;align-items:center;justify-content:center;gap:8px;background:var(--bg);border:1.5px solid var(--border);color:var(--text);border-radius:8px;padding:9px 12px;font-size:13px;font-weight:600;text-decoration:none;transition:border-color .15s;cursor:pointer"
onmouseover="this.style.borderColor='var(--accent)'" onmouseout="this.style.borderColor='var(--border)'">
<svg viewBox="0 0 24 24" fill="var(--accent)" width="16" height="16"><path d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.894 8.221-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.447 1.394c-.16.16-.295.295-.605.295l.213-3.053 5.56-5.023c.242-.213-.054-.333-.373-.12l-6.871 4.326-2.962-.924c-.643-.204-.657-.643.136-.953l11.57-4.461c.537-.194 1.006.131.833.941z"/></svg>
@p1_sun_bot
</a>
<div id="auth-status" style="font-size:12px;color:var(--text-muted);text-align:center;margin-top:10px;min-height:16px">Ожидание подтверждения…</div>
</div>
</div>
</div>
<script>
(function() {
var token = 'd388225107e6cc09';
var returnTo = "\/items\/9083";
var statusEl = document.getElementById('auth-status');
var attempts = 0;
var maxAttempts = 300;
var btn = document.getElementById('tg-open-btn');
if (btn) {
btn.addEventListener('click', function(e) {
e.preventDefault();
var w = 600, h = 680;
var left = Math.round((screen.width - w) / 2);
var top = Math.round((screen.height - h) / 2);
window.open(btn.href, 'tg_login', 'width=' + w + ',height=' + h + ',left=' + left + ',top=' + top + ',noopener');
});
}
function check() {
fetch('/api/auth/check?token=' + token)
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.status === 'ok') {
statusEl.style.color = '#22c55e';
statusEl.textContent = 'Telegram подтверждён! Перенаправление…';
setTimeout(function() { window.location.href = returnTo || '/'; }, 800);
return;
}
if (data.status === 'expired') {
statusEl.style.color = '#f05050';
statusEl.textContent = 'Время вышло. Обновите страницу';
return;
}
if (data.status === 'blocked') {
statusEl.style.color = '#f05050';
statusEl.textContent = 'Ваш аккаунт заблокирован';
return;
}
attempts++;
if (attempts >= maxAttempts) {
statusEl.style.color = '#f05050';
statusEl.textContent = 'Время вышло. Обновите страницу';
return;
}
setTimeout(check, 2000);
})
.catch(function() { if (attempts++ < maxAttempts) setTimeout(check, 2000); });
}
setTimeout(check, 2000);
})();
</script>