/* ===== Login button in header (silver outline pill) ===== */
.ah-auth-slot {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
    flex-shrink: 0;
}
/* TG-кнопка перенесена в sp-header через JS — absolute прижата справа в углу.
   На мобиле «Вход» в правом углу, TG слева от него с минимальным зазором. */
#sp-header { position: relative; }
#sp-header a.knopkaverh,
#sp-header .sppb-btn.knopkaverh {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) translateY(-4px);
    right: 14px;
    width: 44px;
    height: 44px;
    margin: 0;
    z-index: 99;
}
.ah-btn-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 22px;
    border: 1px solid #C0C0C0;
    border-radius: 999px;
    background: transparent;
    color: #C0C0C0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}
.ah-btn-login:hover {
    background: #C0C0C0;
    color: #0a0a0a;
}

/* User chip (когда залогинен) */
.ah-user-chip-wrap {
    position: relative;
    display: inline-block;
}
.ah-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border: 1px solid #C0C0C0;
    border-radius: 999px;
    background: transparent;
    color: #C0C0C0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    line-height: 1;
}
.ah-user-chip:hover { background: rgba(192,192,192,0.08); }
.ah-user-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}
.ah-user-fullname {
    padding: 10px 14px 6px;
    font-size: 13px;
    font-weight: 600;
    color: #f0f0f0;
    border-bottom: 1px solid rgba(192,192,192,0.12);
    margin-bottom: 4px;
    word-break: break-word;
    line-height: 1.3;
}
.ah-user-chip::after {
    content: '▾';
    margin-left: 4px;
    font-size: 10px;
    opacity: 0.7;
}
.ah-user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #111;
    border: 1px solid rgba(192,192,192,0.2);
    border-radius: 6px;
    min-width: 200px;
    display: none;
    flex-direction: column;
    padding: 6px;
    z-index: 10000;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.ah-user-chip-wrap.is-open .ah-user-menu { display: flex; }

.ah-user-menu a, .ah-user-menu button {
    background: transparent;
    border: none;
    padding: 10px 14px;
    text-align: left;
    color: #c0c0c0;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.15s;
    display: block;
    width: 100%;
    box-sizing: border-box;
    letter-spacing: normal;
    text-transform: none;
    font-weight: 500;
}
.ah-user-menu a.ah-menu-primary {
    color: #f0f0f0;
    font-weight: 600;
}
.ah-user-menu a:hover, .ah-user-menu button:hover {
    background: rgba(192,192,192,0.1);
    color: #fff;
}

/* ===== Modal overlay ===== */
.ah-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(6px);
    z-index: 99998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: ah-fade 0.2s ease;
}
.ah-modal-backdrop.is-open { display: flex; }
@keyframes ah-fade { from { opacity: 0; } to { opacity: 1; } }

.ah-modal {
    background: #0d0d0d;
    border: 1px solid rgba(192,192,192,0.15);
    border-radius: 8px;
    max-width: 420px;
    width: 100%;
    padding: 36px 32px 32px;
    position: relative;
    color: #f0f0f0;
    font-family: 'Inter', sans-serif;
    margin: auto;
}
.ah-modal-close {
    position: sticky;
    top: 0;
    margin-left: auto;
    margin-right: -16px;
    margin-top: -28px;
    margin-bottom: -8px;
    display: block;
    background: rgba(13,13,13,0.92);
    border: none;
    color: #aaa;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 12px 6px;
    border-radius: 999px;
    z-index: 2;
    backdrop-filter: blur(4px);
}
.ah-modal-close:hover { color: #fff; }

.ah-tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid rgba(192,192,192,0.1);
    margin-bottom: 24px;
}
.ah-tab {
    background: transparent;
    border: none;
    padding: 10px 0;
    color: #c0c0c0;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}
.ah-tab:hover { color: #e8e8e8; }
.ah-tab.is-active { color: #fff; }
.ah-tab.is-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #C0C0C0;
}

.ah-form { display: none; flex-direction: column; gap: 14px; }
.ah-form.is-active { display: flex; }
.ah-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #888;
}
.ah-form label.ah-consent {
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.4;
    color: #aaa;
    cursor: pointer;
}
.ah-form label.ah-consent input[type="checkbox"] {
    margin-top: 2px;
    width: 16px; height: 16px;
    accent-color: #c0c0c0;
    flex-shrink: 0;
}
.ah-form label.ah-consent a { color: #d8d8e8; text-decoration: underline; text-decoration-color: rgba(216,216,232,0.4); }
.ah-form label.ah-consent a:hover { color: #fff; text-decoration-color: #fff; }
.ah-form input {
    background: #1a1a1a;
    border: 1px solid rgba(192,192,192,0.15);
    padding: 12px 14px;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    border-radius: 4px;
    letter-spacing: normal;
    text-transform: none;
    transition: border-color 0.2s;
}
.ah-form input:focus {
    outline: none;
    border-color: #C0C0C0;
}
.ah-form button[type="submit"] {
    margin-top: 8px;
    padding: 14px;
    background: #C0C0C0;
    color: #0a0a0a;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
}
.ah-form button[type="submit"]:hover:not(:disabled) { background: #fff; }
.ah-form button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: wait;
}
.ah-form-error {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #ff6b6b;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    display: none;
}
.ah-form-error.is-visible { display: block; }

/* Разделитель «или» между формой и TG-входом */
.ah-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 14px;
    color: #666;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.ah-divider::before,
.ah-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(192,192,192,0.12);
}
.ah-tg-wrap {
    display: flex;
    justify-content: center;
    min-height: 40px;
}

/* TG-кнопка входа через бота */
.ah-tg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 13px 20px;
    background: #229ED9;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s;
}
.ah-tg-btn:hover:not(:disabled) { background: #1d8cc1; }
.ah-tg-btn:disabled { opacity: 0.6; cursor: wait; }

.ah-tg-pending {
    text-align: center;
    padding: 20px 14px;
    background: rgba(34,158,217,0.08);
    border: 1px solid rgba(34,158,217,0.2);
    border-radius: 6px;
}
.ah-tg-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    border: 3px solid rgba(34,158,217,0.2);
    border-top-color: #229ED9;
    border-radius: 50%;
    animation: ah-spin 0.8s linear infinite;
}
@keyframes ah-spin { to { transform: rotate(360deg); } }
.ah-tg-pending-txt {
    color: #c0c0c0;
    font-size: 14px;
    margin-bottom: 14px;
}
.ah-tg-cancel {
    background: transparent;
    border: 1px solid rgba(192,192,192,0.25);
    color: #888;
    padding: 8px 18px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.ah-tg-cancel:hover { color: #fff; border-color: #c0c0c0; }

/* Мобила: «Вход» в самом правом углу, TG ближе к «Входу» с минимальным зазором */
@media (max-width: 991px) {
    .ah-auth-slot {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: 14px;
        margin: 0;
        z-index: 99;
    }
    .ah-btn-login, .ah-user-chip {
        padding: 8px 14px;
        font-size: 11px;
        letter-spacing: 1px;
        line-height: 1;
        min-height: 36px;
    }
    .ah-user-name { max-width: 80px; }
    /* TG прямо слева от «Входа» (зазор 8px) */
    #sp-header a.knopkaverh,
    #sp-header .sppb-btn.knopkaverh {
        right: 100px !important;   /* ~84px кнопка Вход + 14 от края + 8 gap */
        width: 40px !important;
        height: 40px !important;
    }
}
@media (max-width: 480px) {
    .ah-btn-login, .ah-user-chip { padding: 7px 12px; font-size: 10px; }
    .ah-user-name { max-width: 64px; }
    #sp-header a.knopkaverh,
    #sp-header .sppb-btn.knopkaverh { right: 86px !important; width: 36px !important; height: 36px !important; }
}

/* Mobile: модалка прижимается сверху, скроллится по высоте — иначе на iOS
   длинная регистрация уезжает за viewport и × недосягаем. */
@media (max-width: 600px) {
    .ah-modal-backdrop {
        align-items: flex-start;
        padding: 12px;
    }
    .ah-modal {
        padding: 28px 20px 24px;
        margin: 0 auto;
    }
    .ah-modal-close {
        margin-top: -22px;
        margin-right: -10px;
    }
    .ah-form label.ah-consent { font-size: 11px; }
}
