/* ─────────────────────────────────────────────────────────────────────────
   CAZ VPN — Telegram Mini App
   Светлая тема. Токены → компоненты. Без bootstrap, без jQuery.
   ───────────────────────────────────────────────────────────────────────── */

:root {
    /* поверхности */
    --bg:            #F1F3F8;
    --surface:       #FFFFFF;
    --sunken:        #F5F6FA;
    --line:          #E6E9F0;
    --line-strong:   #D6DBE6;

    /* текст */
    --ink:           #0B0E14;
    --ink-2:         #49515F;
    --muted:         #8C94A3;

    /* бренд и статусы */
    --brand:         #2B55F5;
    --brand-press:   #2244D6;
    --brand-soft:    #EBEFFE;
    --brand-ink:     #FFFFFF;

    --ok:            #0E9F6E;
    --ok-soft:       #E6F7F0;
    --warn:          #C77700;
    --warn-soft:     #FEF3E2;
    --danger:        #D93A3F;
    --danger-soft:   #FDECEC;

    /* геометрия */
    --r-xl:          24px;
    --r-lg:          18px;
    --r-md:          14px;
    --r-sm:          10px;
    --r-pill:        999px;

    /* тени */
    --sh-1: 0 1px 2px rgba(11, 14, 20, .04);
    --sh-2: 0 1px 2px rgba(11, 14, 20, .04), 0 10px 28px -14px rgba(11, 14, 20, .18);
    --sh-nav: 0 -1px 0 var(--line), 0 -12px 32px -20px rgba(11, 14, 20, .35);

    /* ритм */
    --gap:      12px;
    --pad:      16px;
    --nav-h:    64px;

    --ease:     cubic-bezier(.2, .8, .3, 1);
    --dur:      200ms;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* авторские display: flex/grid ниже сильнее UA-правила [hidden] — возвращаем */
[hidden] { display: none !important; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

button, input, textarea { font: inherit; color: inherit; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

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

/* ── каркас ──────────────────────────────────────────────────────────────── */

.shell {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 var(--pad);
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
}

.screen { display: none; animation: screen-in 260ms var(--ease) both; }
.screen.is-active { display: block; }

@keyframes screen-in {
    from { opacity: 0; transform: translate3d(0, 8px, 0); }
    to   { opacity: 1; transform: none; }
}

/* ── шапка экрана ────────────────────────────────────────────────────────── */

.head { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; }
.head__text { min-width: 0; flex: 1; }
.head h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -.7px;
    line-height: 1.15;
}
.head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.avatar {
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: var(--r-pill);
    background: var(--brand-soft) center/cover no-repeat;
    display: grid; place-items: center;
    font-size: 15px; font-weight: 600; color: var(--brand);
    overflow: hidden;
}

/* ── заголовок секции ────────────────────────────────────────────────────── */

.section-title {
    margin: 22px 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}
.section-title:first-child { margin-top: 0; }

/* ── карточка ────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-2);
    padding: 18px;
    margin-bottom: var(--gap);
}
.card--flush { padding: 0; overflow: hidden; }
.card__label {
    font-size: 12px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted);
    margin-bottom: 12px;
}

/* ── сегментированный переключатель ──────────────────────────────────────── */

.segmented {
    position: relative;
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--sunken);
    border-radius: var(--r-pill);
    margin-bottom: var(--gap);
}
.segmented__btn {
    flex: 1;
    position: relative;
    z-index: 1;
    min-height: 38px;
    border: 0;
    background: none;
    border-radius: var(--r-pill);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
    transition: color var(--dur) var(--ease);
}
.segmented__btn[aria-selected="true"] { color: var(--ink); }
.segmented__thumb {
    position: absolute;
    top: 3px; bottom: 3px; left: 3px;
    border-radius: var(--r-pill);
    background: var(--surface);
    box-shadow: var(--sh-1);
    transition: transform var(--dur) var(--ease), width var(--dur) var(--ease);
    pointer-events: none;
}

/* ── статус подписки ─────────────────────────────────────────────────────── */

.status {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px 6px 10px;
    border-radius: var(--r-pill);
    background: var(--sunken);
    color: var(--ink-2);
    font-size: 13px; font-weight: 600;
    width: max-content;
    max-width: 100%;
}
.status__dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--muted); flex: 0 0 8px;
}
.status.is-ok     { background: var(--ok-soft);     color: var(--ok); }
.status.is-ok     .status__dot { background: var(--ok); }
.status.is-warn   { background: var(--warn-soft);   color: var(--warn); }
.status.is-warn   .status__dot { background: var(--warn); }
.status.is-danger { background: var(--danger-soft); color: var(--danger); }
.status.is-danger .status__dot { background: var(--danger); }

.hero { display: grid; gap: 16px; }
.hero__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero__days { display: flex; align-items: baseline; gap: 6px; }
.hero__num {
    font-size: 44px; font-weight: 700; letter-spacing: -1.6px; line-height: 1;
}
.hero__unit { font-size: 15px; font-weight: 500; color: var(--muted); }
.hero__sub { margin-top: 4px; font-size: 13px; color: var(--muted); }

/* ── метрика (прогресс) ──────────────────────────────────────────────────── */

.meter { margin-top: 2px; }
.meter__row {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 13px; color: var(--muted); margin-bottom: 7px;
}
.meter__row b { color: var(--ink-2); font-weight: 600; }
.meter__track {
    height: 6px; border-radius: var(--r-pill);
    background: var(--line); overflow: hidden;
}
.meter__fill {
    height: 100%; width: 0;
    border-radius: var(--r-pill);
    background: var(--brand);
    transition: width 600ms var(--ease);
}
.meter__fill.is-warn   { background: var(--warn); }
.meter__fill.is-danger { background: var(--danger); }

/* ── кнопки ──────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px;
    padding: 12px 18px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: var(--sunken);
    color: var(--ink) !important;
    font-size: 15px; font-weight: 600;
    text-align: center; text-decoration: none !important;
    cursor: pointer;
    transition: background var(--dur) var(--ease), transform 120ms var(--ease), opacity var(--dur) var(--ease);
}
.btn:active { transform: scale(.975); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: 0 0 18px; }

.btn--primary { background: var(--brand); color: var(--brand-ink) !important; }
.btn--primary:active { background: var(--brand-press); }
.btn--ghost { background: var(--surface); border-color: var(--line); }
.btn--soft  { background: var(--brand-soft); color: var(--brand) !important; }
.btn--block { display: flex; width: 100%; }
.btn--sm { min-height: 40px; padding: 8px 14px; font-size: 14px; border-radius: var(--r-sm); }

.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; min-width: 0; }

/* ── ссылка подписки ─────────────────────────────────────────────────────── */

.link-card__value {
    display: block;
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: var(--r-md);
    background: var(--sunken);
    border: 1px solid var(--line);
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
    font-size: 13px;
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
}

/* ── список-строки ───────────────────────────────────────────────────────── */

.rows { display: flex; flex-direction: column; }
.row {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    min-height: 58px;
    padding: 14px 18px;
    border: 0;
    background: none;
    text-align: left;
    text-decoration: none !important;
    color: var(--ink) !important;
    cursor: pointer;
    transition: background var(--dur) var(--ease);
}
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row:active { background: var(--sunken); }
.row__icon {
    width: 36px; height: 36px; flex: 0 0 36px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    background: var(--brand-soft);
    color: var(--brand);
}
.row__icon svg { width: 19px; height: 19px; }
.row__icon.is-warn   { background: var(--warn-soft);   color: var(--warn); }
.row__icon.is-ok     { background: var(--ok-soft);     color: var(--ok); }
.row__body { flex: 1; min-width: 0; }
.row__title { display: block; font-size: 15px; font-weight: 500; }
.row__sub { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; }
.row__meta { font-size: 15px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.row__chevron { color: var(--line-strong); flex: 0 0 auto; }
.row__chevron svg { width: 18px; height: 18px; display: block; }

/* ── тарифы ──────────────────────────────────────────────────────────────── */

.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan {
    position: relative;
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform 120ms var(--ease);
}
.plan:active { transform: scale(.98); }
.plan:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.plan[disabled] { opacity: .45; cursor: not-allowed; }
.plan__period { font-size: 13px; color: var(--muted); }
.plan__price { font-size: 24px; font-weight: 700; letter-spacing: -.8px; }
.plan__note { font-size: 12px; color: var(--muted); }
.plan__note--accent { color: var(--ok); font-weight: 600; }
.plan--wide { grid-column: 1 / -1; }

.note { margin: 10px 2px 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ── чипы (платформа / приложение) ───────────────────────────────────────── */

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px var(--pad) 2px;
    margin: 0 calc(var(--pad) * -1) 12px;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    font-size: 14px; font-weight: 600; color: var(--ink-2);
    cursor: pointer;
    scroll-snap-align: start;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"] {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}
.chip__icon { width: 20px; height: 20px; flex: 0 0 20px; display: block; }
.chip__icon svg { width: 100%; height: 100%; display: block; }
.chip[aria-pressed="true"] .chip__icon svg path[fill="#FAFAFA"] { fill: currentColor; }
.chip__icon svg path[fill="#FAFAFA"] { fill: var(--ink-2); }

/* ── шаги установки ──────────────────────────────────────────────────────── */

.steps { position: relative; display: flex; flex-direction: column; gap: 10px; }
.step { position: relative; display: flex; gap: 14px; }
.step__rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 30px; }
.step__num {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--brand-soft); color: var(--brand);
    font-size: 13px; font-weight: 700;
}
.step__num.is-warn { background: var(--warn-soft); color: var(--warn); }
.step__line { flex: 1; width: 2px; background: var(--line); border-radius: 1px; margin: 6px 0 -4px; }
.step:last-child .step__line { display: none; }
.step__card {
    flex: 1; min-width: 0;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    padding: 16px;
    margin-bottom: 4px;
}
.step__title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.step__text { font-size: 14px; color: var(--ink-2); line-height: 1.55; margin: 0; }
.step__btns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* ── реферальная карточка ────────────────────────────────────────────────── */

.promo {
    position: relative;
    overflow: hidden;
    padding: 22px 20px;
    border-radius: var(--r-xl);
    background: linear-gradient(135deg, #2B55F5 0%, #1B36B8 100%);
    color: #fff;
    margin-bottom: var(--gap);
}
.promo::after {
    content: '';
    position: absolute; right: -70px; top: -90px;
    width: 220px; height: 220px; border-radius: 50%;
    background: rgba(255, 255, 255, .09);
}
.promo h3 { margin: 0 0 6px; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.promo p  { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: rgba(255, 255, 255, .82); }
.promo__grid { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.promo__item { background: rgba(255, 255, 255, .14); border-radius: var(--r-md); padding: 12px 8px; text-align: center; }
.promo__item b { display: block; font-size: 21px; font-weight: 700; letter-spacing: -.5px; }
.promo__item span { font-size: 11px; color: rgba(255, 255, 255, .75); }
.promo .btn { position: relative; background: #fff; color: var(--brand) !important; }

/* ── пустое состояние ────────────────────────────────────────────────────── */

.empty { text-align: center; padding: 34px 20px; }
.empty__icon {
    width: 52px; height: 52px; margin: 0 auto 14px;
    display: grid; place-items: center;
    border-radius: var(--r-lg);
    background: var(--brand-soft); color: var(--brand);
}
.empty__icon svg { width: 26px; height: 26px; }
.empty h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.empty p  { margin: 0 auto 18px; font-size: 14px; color: var(--muted); max-width: 300px; line-height: 1.55; }

/* ── ошибка ──────────────────────────────────────────────────────────────── */

.alert {
    display: none;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: var(--gap);
    border-radius: var(--r-lg);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 14px;
    line-height: 1.5;
}
.alert.is-visible { display: flex; }
.alert svg { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 1px; }
.alert__body { min-width: 0; white-space: pre-line; }

/* ── скелетоны ───────────────────────────────────────────────────────────── */

.sk {
    display: inline-block;
    border-radius: var(--r-sm);
    background: linear-gradient(100deg, var(--line) 30%, #F0F2F7 50%, var(--line) 70%);
    background-size: 220% 100%;
    animation: sk 1.3s var(--ease) infinite;
    color: transparent !important;
}
@keyframes sk { from { background-position: 130% 0; } to { background-position: -30% 0; } }

/* ── тост ────────────────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
    z-index: 200;
    display: flex; align-items: center; gap: 8px;
    padding: 11px 18px;
    border-radius: var(--r-pill);
    background: rgba(11, 14, 20, .92);
    color: #fff;
    font-size: 14px; font-weight: 500;
    box-shadow: 0 12px 32px -12px rgba(11, 14, 20, .6);
    opacity: 0;
    transform: translate3d(-50%, 12px, 0);
    transition: opacity 220ms var(--ease), transform 220ms var(--ease);
    pointer-events: none;
    max-width: calc(100% - 32px);
}
.toast.is-visible { opacity: 1; transform: translate3d(-50%, 0, 0); }
.toast svg { width: 17px; height: 17px; flex: 0 0 17px; }

/* ── нижняя навигация ────────────────────────────────────────────────────── */

.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 100;
    display: flex;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .86);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: var(--sh-nav);
}
.tab {
    position: relative;
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    min-width: 0;
    border: 0; background: none;
    padding: 8px 2px;
    color: var(--muted);
    font-size: 10px; font-weight: 600; letter-spacing: -.1px;
    cursor: pointer;
    transition: color var(--dur) var(--ease);
}
.tab svg { width: 23px; height: 23px; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--brand); }
.tab__glyph { transition: transform var(--dur) var(--ease); }
.tab[aria-selected="true"] .tab__glyph { transform: translateY(-1px); }
