/* ===== KTG1 AUTH/LK WIDGET ===== */
/* Самодостаточный виджет авторизации и привязки ЛК (кружок + пилюля + модалки).
 * Единый источник: подключается на ktg1.ru (через @import в layout.css)
 * и на поддоменах (map.ktg1.ru и др.) кросс-доменным <link>. */

:root {
    --ktg1-color-black: #0a0a0a;
    --ktg1-color-dark: #1a1a1a;
    --ktg1-color-gray: #2a2a2a;
    --ktg1-color-light-gray: #888;
    --ktg1-color-white: #ffffff;
    --ktg1-color-accent: #CE7762;
}

/* ===== AUTH MODAL ===== */

.ktg1-auth { display: none; }
.ktg1-auth.is-open { display: block; }
.ktg1-auth__backdrop {
    position: fixed; inset: 0;
    background: rgba(10,10,10,0.55);
    z-index: 1000;
}
.ktg1-auth__window {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: calc(100% - 40px);
    max-width: 420px;
    padding: 28px 24px 24px;
    z-index: 1001;
    color: #2a2a2a;
}
.ktg1-auth__close {
    position: absolute; top: 8px; right: 12px;
    background: none; border: none;
    font-size: 28px; line-height: 1; cursor: pointer;
    color: #999;
    padding: 4px 10px;
}
.ktg1-auth__close:hover { color: #333; }
.ktg1-auth__title {
    font-size: 20px; font-weight: 700;
    margin-bottom: 18px;
    color: #0a0a0a;
}
.ktg1-auth__view { display: flex; flex-direction: column; gap: 12px; }
.ktg1-auth__view[hidden] { display: none; }
.ktg1-auth__label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 13px; color: #6a6a6a; font-weight: 500;
}
.ktg1-auth__input {
    padding: 11px 14px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font: inherit;
    font-size: 16px;
    color: #2a2a2a;
    background: #fff;
}
.ktg1-auth__input:focus {
    outline: 2px solid #CE7762;
    outline-offset: -1px;
}
.ktg1-auth__input--code {
    letter-spacing: 8px;
    text-align: center;
    font-size: 22px;
    font-weight: 600;
}
.ktg1-auth__check {
    display: flex; gap: 8px; align-items: flex-start;
    font-size: 13px; color: #555;
    cursor: pointer;
    line-height: 1.4;
}
.ktg1-auth__check input { margin-top: 3px; flex-shrink: 0; }
.ktg1-auth__check a { color: #CE7762; }
.ktg1-auth__error {
    color: #9a1f1f;
    font-size: 13px;
    min-height: 16px;
}
.ktg1-auth__btn {
    padding: 12px 18px;
    background: #CE7762;
    color: #fff;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.ktg1-auth__btn:hover:not(:disabled) { filter: brightness(0.95); }
.ktg1-auth__btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ktg1-auth__callnum {
    font-size: 26px;
    font-weight: 700;
    text-align: center;
    color: #0a0a0a;
    padding: 14px 0;
    letter-spacing: 1px;
}
.ktg1-auth__hint { font-size: 13px; color: #6a6a6a; }
.ktg1-auth__status {
    text-align: center;
    font-weight: 500;
    color: #1e3a8a;
    background: #eef4ff;
    padding: 10px;
    border-radius: 8px;
}
.ktg1-auth__fallback {
    text-align: center;
    font-size: 14px;
    color: #6a6a6a;
    margin-top: 4px;
}
.ktg1-auth__fallback a { color: #CE7762; }
.ktg1-auth__optional {
    color: #aaa;
    font-weight: 400;
}

/* ===== AUTH WELCOME TOAST ===== */
.ktg1-auth-toast {
    position: fixed;
    top: 24px; right: 24px;
    background: #3bb554;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    font-weight: 500;
    z-index: 1100;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.25s, transform 0.25s;
}
.ktg1-auth-toast.is-show { opacity: 1; transform: translateY(0); }
@media (max-width: 640px) {
    .ktg1-auth-toast { left: 16px; right: 16px; top: 12px; text-align: center; }
}

/* Шапка: бейдж перевозчика, CTA, аватар */
.ktg1-header__carrier {
    background: rgba(255,255,255,.1); color: #fff; text-decoration: none;
    padding: 5px 12px; border-radius: 14px; font-size: 13px; line-height: 1.2;
}
.ktg1-header__carrier:hover { background: rgba(255,255,255,.18); }
.ktg1-header__cta {
    color: var(--ktg1-color-accent); border: 1px dashed rgba(206,119,98,.6);
    padding: 5px 11px; border-radius: 14px; font-size: 13px; cursor: pointer;
}
.ktg1-header__avatar {
    width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--ktg1-color-accent); color: #fff; display: inline-flex;
    align-items: center; justify-content: center; padding: 0;
}
.ktg1-header__avatar-initials { font-weight: 600; font-size: 13px; }
.ktg1-header__avatar--anon { background: transparent; border: 1px solid #555; color: #aaa; }
.ktg1-header__avatar--anon .ktg1-header__avatar-initials { display: none; }
.ktg1-header__avatar:not(.ktg1-header__avatar--anon) .ktg1-header__avatar-anon { display: none; }

/* Модалка профиля */
.ktg1-profile__avatar {
    width: 62px; height: 62px; border-radius: 50%; margin: 4px auto 6px;
    background: var(--ktg1-color-accent); color: #fff; display: flex;
    align-items: center; justify-content: center; font-size: 24px; font-weight: 600;
}
.ktg1-profile__sec { font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: .4px; margin: 16px 0 6px; }
.ktg1-profile__empty { color: #888; font-size: 13px; margin: 0 0 8px; }
.ktg1-profile__save { width: 100%; margin-top: 8px; padding: 9px; background: #fff; color: var(--ktg1-color-accent);
    border: 1px solid var(--ktg1-color-accent); border-radius: 8px; cursor: pointer; font-size: 14px; }
.ktg1-profile__logout { margin-top: 14px; text-align: center; font-size: 13px; color: #d32f2f; cursor: pointer; }
.ktg1-profile__hint { font-size: 13px; color: #475569; margin: 0 0 12px; }
.ktg1-profile__bindinfo { margin-top: 12px; padding: 10px; background: #f6f6f6; border-radius: 8px; font-size: 13px; color: #2a2a2a; }
.ktg1-profile__shortname { margin-top: 8px; }
.ktg1-profile__cabmeta { font-size: 12px; color: #888; margin: 6px 2px; }
.ktg1-profile__cabrow { display: flex; gap: 10px; align-items: center; margin: 4px 0; }
.ktg1-profile__mkactive { padding: 6px 12px; background: var(--ktg1-color-accent); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ktg1-profile__unlink { margin-left: auto; background: none; border: none; color: #d32f2f; cursor: pointer; font-size: 13px; }
.ktg1-profile__divider { margin: 18px 0 10px; text-align: center; font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: .4px; border-top: 1px solid #eee; padding-top: 14px; }

/* === UI polish: пилюля со статусом, инлайн-правка, кастомный дропдаун кабинетов, табы === */

/* Пилюля перевозчика в шапке: имя + статус-иконка */
.ktg1-header__carrier { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.ktg1-header__carrier-status { display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%; font-size: 11px; font-weight: 700; flex: 0 0 auto; }
.status--ok  { background: #2ea045; color: #fff; }
.status--err { background: #f0ad2e; color: #fff; }
.status--wait { border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: ktg1spin .8s linear infinite; }
/* Спиннер на белом фоне (внутри модалки/списка) виден иначе */
.ktg1-cabsel__icon.status--wait, .ktg1-cabsel__opt .status--wait, .ktg1-cab-dropdown__item .status--wait {
    border-color: rgba(0,0,0,.18); border-top-color: var(--ktg1-color-accent); }
@keyframes ktg1spin { to { transform: rotate(360deg); } }

/* Дропдаун кабинетов по клику на пилюлю */
.ktg1-cab-dropdown { z-index: 10002; background: #fff; border: 1px solid #e5e5e5; border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px; min-width: 220px; max-width: 320px; }
.ktg1-cab-dropdown__item, .ktg1-cab-dropdown__add { display: flex; align-items: center; justify-content: space-between;
    gap: 10px; width: 100%; padding: 9px 12px; background: none; border: none; border-radius: 7px;
    cursor: pointer; font-size: 14px; color: #2a2a2a; text-align: left; }
.ktg1-cab-dropdown__item:hover, .ktg1-cab-dropdown__add:hover { background: #f5f5f5; }
.ktg1-cab-dropdown__item.is-active { font-weight: 600; }
.ktg1-cab-dropdown__add { color: var(--ktg1-color-accent); border-top: 1px solid #eee; border-radius: 0; margin-top: 4px; }

/* Инлайн-правка имени (карандашик/чек) */
.ktg1-profile__editrow { display: flex; align-items: center; gap: 8px; }
.ktg1-profile__editrow .ktg1-auth__input { flex: 1; }
.ktg1-profile__iconbtn { flex: 0 0 auto; width: 38px; height: 38px; border: 1px solid var(--ktg1-color-accent);
    background: #fff; color: var(--ktg1-color-accent); border-radius: 8px; cursor: pointer; font-size: 16px; }

.ktg1-profile__addbtn { display: block; margin: 14px auto 0; }

/* Кастомный виджет кабинета */
.ktg1-cabsel { position: relative; }
.ktg1-cabsel__head { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    border: 1px solid #e5e5e5; border-radius: 8px; background: #fafafa; }
.ktg1-cabsel__name { flex: 1; font-size: 14px; color: #2a2a2a; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ktg1-cabsel__name--edit { border: 1px solid var(--ktg1-color-accent); border-radius: 6px; padding: 5px 8px; background: #fff; }
.ktg1-cabsel__icon { flex: 0 0 auto; width: 24px; height: 24px; display: inline-flex; align-items: center;
    justify-content: center; border-radius: 50%; border: none; cursor: pointer; font-size: 13px; font-weight: 700; }
.ktg1-cabsel__edit { background: #fff; border: 1px solid var(--ktg1-color-accent); color: var(--ktg1-color-accent); }
.ktg1-cabsel__unlink { background: #d32f2f; color: #fff; }
.ktg1-cabsel__arrow { flex: 0 0 auto; color: #999; cursor: pointer; }
.ktg1-cabsel__list { margin-top: 4px; border: 1px solid #e5e5e5; border-radius: 8px; overflow: hidden; }
.ktg1-cabsel__opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
    padding: 9px 12px; background: #fff; border: none; border-bottom: 1px solid #f1f1f1; cursor: pointer; font-size: 14px; color: #2a2a2a; text-align: left; }
.ktg1-cabsel__opt:last-child { border-bottom: none; }
.ktg1-cabsel__opt:hover { background: #f5f5f5; }
.ktg1-cabsel__opt.is-sel { font-weight: 600; }

/* Табы в модалке привязки */
.ktg1-tabs { display: flex; gap: 6px; margin: 4px 0 14px; border-bottom: 1px solid #eee; }
.ktg1-tabs__tab { flex: 1; padding: 10px 8px; background: none; border: none; border-bottom: 2px solid transparent;
    cursor: pointer; font-size: 14px; color: #888; }
.ktg1-tabs__tab { text-align: center; line-height: 1.2; }
.ktg1-tabs__tab.is-active { color: var(--ktg1-color-accent); border-bottom-color: var(--ktg1-color-accent); font-weight: 600; }
/* Плейсхолдеры в модалках — светлее (как подпись «используется только вами…») */
.ktg1-auth__input::placeholder { color: #bdbdbd; opacity: 1; }
/* Крутящееся колесо на кнопке привязки (пока идёт синхронный вход в SR) */
.ktg1-wheel { display: inline-block; animation: ktg1-wheel-spin 0.7s linear infinite; }
@keyframes ktg1-wheel-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ===== FWD WIZARD (путь 3 — привязка через пересылку) ===== */

/* Индикатор шагов */
.ktg1-fwd-step { margin-bottom: 12px; }
.ktg1-fwd-step__label { font-size: 12px; color: #6a6a6a; margin-bottom: 5px; }
.ktg1-fwd-step__dots { display: flex; gap: 4px; }
.ktg1-fwd-dot {
    flex: 1; height: 3px; border-radius: 2px;
    background: #e5e5e5;
}
.ktg1-fwd-dot--done   { background: #CE7762; }
.ktg1-fwd-dot--active { background: #CE7762; opacity: .5; }
.ktg1-fwd-dot--error  { background: #d32f2f; opacity: .7; }

/* Блок адреса пересылки */
.ktg1-fwd-box {
    display: flex; align-items: center; gap: 8px;
    background: #fafafa; border: 1px solid #e5e5e5;
    border-radius: 8px; padding: 10px 12px; margin: 8px 0;
}
.ktg1-fwd-box__addr {
    flex: 1; font-size: 13px; font-weight: 700; color: #CE7762;
    word-break: break-all;
}
.ktg1-fwd-copy {
    flex: 0 0 auto; background: #fff; border: 1px solid #e5e5e5;
    border-radius: 7px; padding: 5px 9px; cursor: pointer;
    color: #6a6a6a; font-size: 11px; font-family: inherit;
}
.ktg1-fwd-copy:hover { background: #f0f0f0; color: #2a2a2a; }

/* Предупреждение */
.ktg1-fwd-warn {
    color: #7a5500; background: rgba(240,173,46,.10);
    border: 1px solid rgba(240,173,46,.35); border-radius: 8px;
    padding: 8px 10px; font-size: 12px; line-height: 1.5; margin: 8px 0;
}

/* Разделитель «Шаг A / Шаг B» */
.ktg1-fwd-divider {
    display: flex; align-items: center; gap: 8px; margin: 12px 0 8px;
}
.ktg1-fwd-divider__line { flex: 1; height: 1px; background: #e5e5e5; }
.ktg1-fwd-divider__label {
    font-size: 11px; color: #CE7762; font-weight: 700;
    background: rgba(206,119,98,.08); border: 1px solid rgba(206,119,98,.2);
    border-radius: 5px; padding: 2px 8px; white-space: nowrap;
}

/* Табы сервисов (Яндекс / Mail.ru / Gmail / Другая) */
.ktg1-fwd-srv-tabs { display: flex; gap: 4px; margin: 8px 0; }
.ktg1-fwd-srv-tab {
    flex: 1; padding: 5px 0; border: 1px solid #e5e5e5; border-radius: 8px;
    background: #fafafa; color: #888; font-size: 11px; cursor: pointer; font-family: inherit;
}
.ktg1-fwd-srv-tab.is-on {
    background: #CE7762; color: #fff; font-weight: 600; border-color: transparent;
}

/* Плашка «код — для ВАШЕЙ почты» */
.ktg1-fwd-dest-banner {
    margin: 0 0 12px; padding: 10px 12px;
    background: rgba(240,173,46,.12);
    border: 2px solid rgba(240,173,46,.5);
    border-radius: 9px;
    font-size: 12px; font-weight: 700;
    color: #7a5500; line-height: 1.5; text-align: center;
}

/* Блок с кодом подтверждения */
.ktg1-fwd-code-block {
    text-align: center; padding: 14px;
    background: #fafafa; border: 2px solid #e5e5e5;
    border-radius: 9px; margin: 10px 0;
}
.ktg1-fwd-code-val {
    font-size: 32px; font-weight: 700; letter-spacing: .15em;
    color: #CE7762; display: block; margin-bottom: 6px;
}

/* Чекбокс «я ввёл код» */
.ktg1-fwd-confirm-cb {
    display: flex; gap: 8px; align-items: flex-start;
    padding: 8px 10px; margin: 8px 0;
    background: #fafafa; border: 1px solid #e5e5e5;
    border-radius: 8px; font-size: 12px; color: #2a2a2a; line-height: 1.5;
    cursor: pointer;
}
.ktg1-fwd-confirm-cb input { margin-top: 2px; flex-shrink: 0; }

/* Спиннер ожидания */
.ktg1-fwd-spinner {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 12px 0; color: #6a6a6a; font-size: 13px;
}

/* Обратный отсчёт */
.ktg1-fwd-countdown {
    text-align: center; padding: 10px; background: #fafafa;
    border: 1px solid #e5e5e5; border-radius: 9px; margin: 8px 0;
}
.ktg1-fwd-countdown__num {
    font-size: 24px; font-weight: 700; color: #CE7762;
    display: block; line-height: 1;
}
.ktg1-fwd-countdown__label { font-size: 11px; color: #888; margin-top: 2px; display: block; }

/* Инфо-блок */
.ktg1-fwd-info {
    background: #f0f4ff; border: 1px solid #dde5ff;
    border-radius: 8px; padding: 7px 10px; font-size: 12px;
    color: #475569; line-height: 1.5; margin: 8px 0;
}

/* Прогресс-бар (шаг 4) */
.ktg1-fwd-progress-wrap {
    width: 100%; background: #e5e5e5; border-radius: 4px;
    height: 6px; overflow: hidden; margin: 8px 0;
}
.ktg1-fwd-progress-fill {
    height: 100%; border-radius: 4px; background: #CE7762;
    transition: width .3s;
}

/* Чек-лист ошибки */
.ktg1-fwd-checklist { list-style: none; padding: 0; margin: 8px 0; }
.ktg1-fwd-checklist li {
    display: flex; gap: 7px; align-items: flex-start;
    font-size: 12px; color: #2a2a2a; margin: 5px 0; line-height: 1.5;
}
.ktg1-fwd-checklist__num {
    flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%;
    background: rgba(211,47,47,.12); border: 1px solid rgba(211,47,47,.3);
    color: #d32f2f; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* Чип «через пересылку» */
.ktg1-fwd-chip {
    display: inline-flex; align-items: center; padding: 1px 6px;
    border-radius: 5px; font-size: 10px; font-weight: 600;
    background: rgba(206,119,98,.12); color: #CE7762;
    border: 1px solid rgba(206,119,98,.25);
    vertical-align: middle; margin-left: 4px;
}
.ktg1-fwd-chip--pending {
    background: rgba(240,173,46,.12); color: #7a5500;
    border-color: rgba(240,173,46,.3);
}

/* Карточка fwd_pending */
.ktg1-fwd-pending-card {
    cursor: default;
}
.ktg1-fwd-pending-card .ktg1-auth__btn { cursor: pointer; }
