/* ============================================================
   QueryVPN — личный кабинет
   App-like: экран не листается, прокручивается только контент.
   Mobile-first, оптимизация под iPhone (safe-area, 100dvh).
   ============================================================ */

:root {
    --lk-bg: #f5f5f7;
    --lk-card: #ffffff;
    --lk-ink: #1d1d1f;
    --lk-ink-2: #6e6e73;
    --lk-ink-3: #aeaeb2;
    --lk-line: rgba(0, 0, 0, .08);
    --lk-accent: #0071e3;
    --lk-accent-press: #0077ed;
    --lk-soft-btn: #e9e9ec;
    --lk-soft-btn-press: #dfdfe4;

    --lk-ok-soft: rgba(52, 199, 89, .14);
    --lk-ok-text: #1d8a3e;
    --lk-warn-soft: rgba(255, 159, 10, .16);
    --lk-warn-text: #b25000;
    --lk-danger: #e02d23;
    --lk-danger-soft: rgba(255, 59, 48, .12);
    --lk-danger-text: #d70015;

    --lk-tabbar-bg: rgba(249, 249, 251, .84);
    --lk-radius: 20px;
    --ease: cubic-bezier(.28, .11, .32, 1);

    --lk-grid: rgba(0, 0, 0, .05);
    --lk-glow-1: rgba(0, 113, 227, .08);
    --lk-glow-2: rgba(125, 92, 255, .07);
}

@media (prefers-color-scheme: dark) {
    :root {
        --lk-bg: #000000;
        --lk-card: #1c1c1e;
        --lk-ink: #f5f5f7;
        --lk-ink-2: #98989d;
        --lk-ink-3: #636366;
        --lk-line: rgba(255, 255, 255, .12);
        --lk-accent: #0a84ff;
        --lk-accent-press: #2997ff;
        --lk-soft-btn: #2c2c2e;
        --lk-soft-btn-press: #3a3a3c;

        --lk-ok-soft: rgba(48, 209, 88, .16);
        --lk-ok-text: #30d158;
        --lk-warn-soft: rgba(255, 159, 10, .18);
        --lk-warn-text: #ffb340;
        --lk-danger: #ff453a;
        --lk-danger-soft: rgba(255, 69, 58, .16);
        --lk-danger-text: #ff6961;

        --lk-tabbar-bg: rgba(18, 18, 20, .84);

        --lk-grid: rgba(255, 255, 255, .06);
        --lk-glow-1: rgba(41, 151, 255, .14);
        --lk-glow-2: rgba(125, 92, 255, .12);
    }
}

*, *::before, *::after { box-sizing: border-box; }

html.lk-html { height: 100%; -webkit-text-size-adjust: 100%; }

.lk-body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--lk-bg);
    color: var(--lk-ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.45;
    letter-spacing: -.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

svg { display: block; }

:focus-visible {
    outline: 2px solid var(--lk-accent);
    outline-offset: 3px;
    border-radius: 6px;
}

/* ---------- Каркас приложения ---------- */
.app {
    position: relative;
    height: 100vh;
    height: 100dvh;
    max-width: 560px;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    background: var(--lk-bg);
}

@media (min-width: 600px) {
    .app { border-inline: 1px solid var(--lk-line); }
}

/* Фоновая фактура: едва заметная клетка, тающая книзу… */
.app::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(var(--lk-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--lk-grid) 1px, transparent 1px);
    background-size: 48px 48px;
    -webkit-mask-image: radial-gradient(130% 62% at 50% 0%, #000 0%, transparent 80%);
    mask-image: radial-gradient(130% 62% at 50% 0%, #000 0%, transparent 80%);
}

/* …и мягкое фирменное свечение сверху (сине-фиолетовое, как на лендинге). */
.app::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(420px 280px at 16% -70px, var(--lk-glow-1), transparent 70%),
        radial-gradient(480px 300px at 88% -90px, var(--lk-glow-2), transparent 70%);
}

.app__screen {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: calc(14px + env(safe-area-inset-top)) 20px calc(108px + env(safe-area-inset-bottom));
}

/* ---------- Нижний таб-бар ---------- */
.tabbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    background: var(--lk-tabbar-bg);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border-top: .5px solid var(--lk-line);
}

.tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 0 2px;
    color: var(--lk-ink-3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .01em;
    transition: color .2s var(--ease), transform .2s var(--ease);
}

.tabbar__item:active { transform: scale(.92); }
.tabbar__item.is-active { color: var(--lk-accent); }

/* ---------- Типографика экрана ---------- */
.screen-head { padding: 10px 0 2px; }

.screen-title {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -.022em;
}

.screen-sub {
    margin: 6px 0 0;
    font-size: 15px;
    color: var(--lk-ink-2);
}

.section-label {
    margin: 26px 0 10px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--lk-ink-2);
}

.backlink {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 2px 0 6px -8px;
    padding: 6px 8px;
    color: var(--lk-accent);
    text-decoration: none;
    font-size: 17px;
    border-radius: 10px;
}
.backlink:active { opacity: .6; }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5em;
    font-family: inherit;
    font-size: 17px;
    font-weight: 500;
    line-height: 1;
    padding: 16px 22px;
    border-radius: 980px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: -.01em;
    transition: transform .22s var(--ease), background-color .22s var(--ease), opacity .22s var(--ease);
}

.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.is-loading { opacity: .6; pointer-events: none; }

.btn--primary { background: var(--lk-accent); color: #fff; }
.btn--primary:active { background: var(--lk-accent-press); }

.btn--soft { background: var(--lk-soft-btn); color: var(--lk-ink); }
.btn--soft:active { background: var(--lk-soft-btn-press); }

.btn--danger { background: var(--lk-danger-soft); color: var(--lk-danger-text); }

.btn--block { display: flex; width: 100%; }
.btn--sm { font-size: 15px; padding: 10px 16px; }

.mt { margin-top: 14px; }

/* ---------- Карточки и списки ---------- */
.card {
    background: var(--lk-card);
    border: 1px solid var(--lk-line);
    border-radius: var(--lk-radius);
    padding: 18px 20px;
}

.stack { display: grid; gap: 12px; margin-top: 16px; }

a.card {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: transform .2s var(--ease);
}
a.card:active { transform: scale(.98); }

.card.sub-card, .sub-card { display: flex; align-items: center; gap: 12px; }
.sub-card__body { flex: 1; min-width: 0; }

.sub-card__name {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-card__meta { margin: 3px 0 0; font-size: 13px; color: var(--lk-ink-2); }

.chevron { flex: none; color: var(--lk-ink-3); }

/* строки внутри карточки */
.rows { padding: 4px 0; }

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 20px;
    border-bottom: .5px solid var(--lk-line);
    font-size: 16px;
}
.row:last-child { border-bottom: 0; }

.row__label { color: var(--lk-ink-2); flex: none; }
.row__value { text-align: right; min-width: 0; overflow-wrap: anywhere; }

.card--flush { padding: 0; overflow: hidden; }

/* ---------- Бейджи ---------- */
.pill {
    flex: none;
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 980px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
}

.pill--ok { background: var(--lk-ok-soft); color: var(--lk-ok-text); }
.pill--soon { background: var(--lk-warn-soft); color: var(--lk-warn-text); }
.pill--expired { background: var(--lk-danger-soft); color: var(--lk-danger-text); }

/* ---------- Баланс ---------- */
.balance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding: 18px 20px;
    background: var(--lk-card);
    border: 1px solid var(--lk-line);
    border-radius: var(--lk-radius);
    text-decoration: none;
    color: inherit;
    transition: transform .2s var(--ease);
}
.balance:active { transform: scale(.98); }

.balance__label { margin: 0 0 3px; font-size: 13px; color: var(--lk-ink-2); }

.balance__value {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.balance--hero { margin-top: 18px; }
.balance--hero .balance__value { font-size: 40px; }

/* ---------- Формы ---------- */
.form-card {
    background: var(--lk-card);
    border: 1px solid var(--lk-line);
    border-radius: var(--lk-radius);
    overflow: hidden;
    margin-top: 16px;
}

.form-row { padding: 12px 20px 13px; border-bottom: .5px solid var(--lk-line); }
.form-row:last-child { border-bottom: 0; }

.form-row label {
    display: block;
    margin-bottom: 3px;
    font-size: 12px;
    font-weight: 500;
    color: var(--lk-ink-2);
    transition: color .2s var(--ease);
}
.form-row:focus-within label { color: var(--lk-accent); }

.input {
    width: 100%;
    padding: 2px 0;
    border: 0;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 17px;
    letter-spacing: -.01em;
    color: var(--lk-ink);
    caret-color: var(--lk-accent);
}
.input::placeholder { color: var(--lk-ink-3); }

.form-actions { margin-top: 14px; display: grid; gap: 10px; }

.form-errors { margin-top: 14px; }
.form-errors ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.form-errors li {
    padding: 12px 16px;
    border-radius: 14px;
    background: var(--lk-danger-soft);
    color: var(--lk-danger-text);
    font-size: 14px;
}
.validation-summary-valid { display: none; }

.field-error { display: block; margin-top: 6px; font-size: 13px; color: var(--lk-danger-text); }

/* инлайн-форма (переименование, промокод) */
.inline-form { display: flex; gap: 10px; align-items: stretch; }
.inline-form .form-card { flex: 1; margin-top: 0; }
.inline-form .btn { flex: none; }

/* ---------- Суммы-чипы ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.chip {
    padding: 10px 18px;
    border-radius: 980px;
    border: 1px solid var(--lk-line);
    background: var(--lk-card);
    color: var(--lk-ink);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.chip:active { transform: scale(.95); }
.chip.is-active { background: var(--lk-accent); border-color: var(--lk-accent); color: #fff; }

/* ---------- Тосты ---------- */
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 10px;
    padding: 13px 16px;
    border-radius: 16px;
    font-size: 15px;
    transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.toast.is-hide { opacity: 0; transform: translateY(-6px); }
.toast svg { flex: none; }

.toast--ok { background: var(--lk-ok-soft); color: var(--lk-ok-text); }
.toast--err { background: var(--lk-danger-soft); color: var(--lk-danger-text); }

/* ---------- Пустое состояние ---------- */
.empty { text-align: center; padding: 46px 18px 30px; }

.empty__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    margin: 0 auto 18px;
    border-radius: 24px;
    background: var(--lk-card);
    border: 1px solid var(--lk-line);
    color: var(--lk-accent);
}

.empty__title { margin: 0 0 6px; font-size: 21px; font-weight: 700; letter-spacing: -.015em; }
.empty__text { margin: 0 auto 22px; max-width: 300px; font-size: 15px; color: var(--lk-ink-2); }

/* ---------- Тарифы ---------- */
.card.tariff, .tariff { display: flex; align-items: center; gap: 12px; }
.tariff__body { flex: 1; min-width: 0; }
.tariff__title { margin: 0; font-size: 17px; font-weight: 600; }
.tariff__per { margin: 3px 0 0; font-size: 13px; color: var(--lk-ink-2); }
.tariff__price { font-size: 17px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- История платежей ---------- */
.history__amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.history__date { font-size: 13px; color: var(--lk-ink-2); margin-top: 2px; }

/* ---------- Экран авторизации ---------- */
.auth {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px 2px 30px;
}

.auth__logo { display: flex; justify-content: center; margin-bottom: 16px; }

.auth__title {
    margin: 0;
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.auth__sub { margin: 6px 0 4px; text-align: center; font-size: 15px; color: var(--lk-ink-2); }

.auth__switch { margin: 20px 0 0; text-align: center; font-size: 15px; color: var(--lk-ink-2); }
.auth__switch a { color: var(--lk-accent); text-decoration: none; font-weight: 500; }

.auth__hint { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--lk-ink-3); }

.auth__home {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top));
    left: 14px;
    z-index: 10;
}

/* ---------- Переход к оплате ---------- */
.pay-wait { text-align: center; padding-top: 18vh; }

.spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 22px;
    border-radius: 50%;
    border: 3px solid var(--lk-line);
    border-top-color: var(--lk-accent);
    animation: lk-spin .8s linear infinite;
}

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

/* ---------- Прочее ---------- */
.fine {
    margin-top: 26px;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: var(--lk-ink-3);
}
.fine a { color: var(--lk-ink-2); text-decoration: none; }
.fine--left { text-align: left; margin-top: 12px; }

.card__lead { margin: 0 0 10px; font-size: 15px; color: var(--lk-ink-2); }

.link-accent { color: var(--lk-accent); text-decoration: none; font-weight: 500; }

.copy-value {
    display: block;
    font-size: 14px;
    color: var(--lk-ink-2);
    overflow-wrap: anywhere;
    margin-top: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition-duration: .01ms !important;
    }
}
