* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 16px;
}

.login-box {
    background: #fff;
    padding: 32px 28px 26px;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, .15);
    text-align: center;
    width: 100%;
    max-width: 380px;
}

.login-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, #229ed9, #1d6fa5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 6px 20px rgba(34, 158, 217, .35);
}

.login-box h2 {
    margin: 0 0 22px;
    color: #0f172a;
    font-size: 19px;
    font-weight: 700;
}

.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 9px 12px;
    border-radius: 8px;
    margin: 0 0 14px;
    font-size: 13px;
}

.btn-tg {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #229ed9, #1d6fa5);
    color: #fff;
    border: none;
    border-radius: 11px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(34, 158, 217, .35);
    transition: transform .12s, box-shadow .12s;
}
.btn-tg:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(34, 158, 217, .45);
}
.btn-tg i { font-size: 20px; }

.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 14px;
    color: #94a3b8;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.master-form input {
    width: 100%;
    padding: 12px 14px;
    margin: 0 0 10px;
    border-radius: 9px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    font-size: 15px;
    outline: none;
    transition: border .15s, background .15s;
}
.master-form input:focus {
    border-color: #3b82f6;
    background: #fff;
}

.btn-master {
    width: 100%;
    padding: 11px;
    background: #475569;
    color: #fff;
    border: none;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-master:hover { background: #334155; }

/* ===== TG MODAL ===== */
.tg-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 14px;
}
.tg-overlay.open { display: flex; }

.tg-box {
    position: relative;
    background: #fff;
    border-radius: 18px;
    padding: 28px 22px 22px;
    text-align: center;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .26);
}
.tg-icon {
    width: 64px;
    height: 64px;
    margin: 4px auto 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, #229ed9, #1d6fa5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    box-shadow: 0 6px 18px rgba(34, 158, 217, .35);
}
.tg-box h3 {
    margin: 0 0 6px;
    color: #0f172a;
    font-size: 17px;
}
.tg-hint {
    margin: 0 0 16px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}
.tg-hint b { color: #075985; }

.tg-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    font-size: 14px;
}
.tg-close:hover { background: #e2e8f0; }

.tg-reopen {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    background: #e0f2fe;
    border: none;
    border-radius: 9px;
    font-size: 12.5px;
    color: #075985;
    cursor: pointer;
    font-weight: 600;
    transition: background .12s;
}
.tg-reopen:hover { background: #bae6fd; }

.tg-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 9px;
    background: #fff7ed;
    color: #b45309;
    font-size: 13px;
    font-weight: 500;
}
.tg-state.ok {
    background: #ecfdf5;
    color: #047857;
}
.tg-state.err {
    background: #fef2f2;
    color: #b91c1c;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #fed7aa;
    border-top-color: #b45309;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.tg-state.ok .spinner,
.tg-state.err .spinner {
    display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tg-timer {
    margin-top: 10px;
    font-size: 11.5px;
    color: #94a3b8;
}

/* ===== CODE STEP ===== */
.code-hint {
    margin: 0 0 16px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

.code-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 0 0 14px;
}
.code-digit {
    width: 54px;
    height: 60px;
    text-align: center;
    font-size: 26px;
    font-weight: 700;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #0f172a;
    outline: none;
    transition: border .15s, background .15s, transform .1s;
}
.code-digit:focus {
    border-color: #3b82f6;
    background: #fff;
    transform: translateY(-1px);
}
.code-digit.filled {
    border-color: #22c55e;
    background: #f0fdf4;
}

.code-timer {
    margin: 10px 0 6px;
    font-size: 12px;
    color: #64748b;
    text-align: center;
}

.code-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}
.link-btn {
    background: none;
    border: none;
    color: #2563eb;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 4px;
}
.link-btn:disabled {
    color: #cbd5e1;
    cursor: not-allowed;
}
.link-btn:not(:disabled):hover {
    text-decoration: underline;
}
