/* Palm VPN Mini App — единый стиль с website/app.css */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

:root {
    --bg: #f6f7f6;
    --card: #fff;
    --border: #ececeb;
    --border2: #dededc;
    --accent: #16a34a;
    --accent-d: #15803d;
    --adim: rgba(22, 163, 74, 0.08);
    --ab: rgba(22, 163, 74, 0.22);
    --red: #dc2626;
    --rdim: rgba(220, 38, 38, 0.08);
    --amber: #d97706;
    --adim2: rgba(217, 119, 6, 0.08);
    --ink: #121413;
    --text: #1b1d1b;
    --t2: #5d625e;
    --t3: #8b908c;
    --font:
        "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI",
        sans-serif;
    --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
    --r: 16px;
    --r2: 12px;
    --pill: 999px;
    --sh: 0 1px 2px rgba(18, 20, 19, 0.05), 0 1px 1px rgba(18, 20, 19, 0.03);
    --sh2: 0 8px 24px rgba(18, 20, 19, 0.08), 0 2px 6px rgba(18, 20, 19, 0.04);
    --bnav: 62px;
    --hdr: 56px;
    --max: 640px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    letter-spacing: -0.005em;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    overscroll-behavior-y: none;
}
h1,
h2,
h3,
.card-title,
.big {
    color: var(--ink);
    letter-spacing: -0.025em;
}
.hidden {
    display: none !important;
}
.mono {
    font-family: var(--mono);
    font-size: 12px;
}
.t2 {
    color: var(--t2);
}
.t3 {
    color: var(--t3);
}
.fs12 {
    font-size: 12px;
}
.fs13 {
    font-size: 13px;
}
.mt16 {
    margin-top: 16px;
}
.spin {
    animation: spinR 1s linear infinite;
    display: inline-block;
}
@keyframes spinR {
    to {
        transform: rotate(360deg);
    }
}
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ─── BOOT / ERROR ─── */
.boot {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
}
/* Анимированная эмодзи-заглушка загрузки. Двигается сама, поэтому ни рамки,
   ни pulse-анимации ей не нужно — плитка вокруг только мешала бы.

   Картинка отдаётся 256px под 112px CSS (2x под retina): исходные 512px
   декодировались вчетверо дороже на каждом из 45 кадров и заметно лагали.
   Появление живёт на обёртке и только по opacity — transform на самом
   <img> выбрасывал закешированный кадр анимации каждый тик. */
.boot-emoji-wrap {
    animation: bootIn 0.35s ease both;
    will-change: opacity;
}
.boot-emoji {
    width: 112px;
    height: 112px;
    object-fit: contain;
    /* Свой слой компоновки: анимация картинки не трогает остальной экран. */
    transform: translateZ(0);
    backface-visibility: hidden;
}
@keyframes bootIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.boot-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--adim);
    border: 1px solid var(--ab);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1.6s ease-in-out infinite;
}
.boot-logo.err {
    background: var(--rdim);
    border-color: rgba(220, 38, 38, 0.22);
    color: var(--red);
    animation: none;
}
.boot-logo svg {
    width: 26px;
    height: 26px;
}
@keyframes pulse {
    50% {
        transform: scale(1.07);
        opacity: 0.75;
    }
}
.boot-txt {
    color: var(--t2);
    font-size: 13.5px;
    text-align: center;
    max-width: 300px;
    line-height: 1.5;
}

/* ─── TOPBAR ─── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--hdr);
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--hdr) + env(safe-area-inset-top));
    background: rgba(246, 247, 246, 0.86);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--adim);
    border: 1px solid var(--ab);
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.topbar-meta {
    min-width: 0;
}
.topbar-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-sub {
    font-size: 11.5px;
    color: var(--t3);
    font-family: var(--mono);
}
.balance {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: var(--pill);
    background: var(--card);
    border: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    color: var(--ink);
    box-shadow: var(--sh);
}

/* ─── LAYOUT / CARDS ─── */
.wrap {
    max-width: var(--max);
    margin: 0 auto;
    padding: 16px 16px calc(var(--bnav) + env(safe-area-inset-bottom) + 20px);
}
.tab {
    animation: fadeUp 0.22s ease;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px;
    box-shadow: var(--sh);
    margin-bottom: 12px;
}
.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}
.card-title svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
    flex-shrink: 0;
}
.card-desc {
    font-size: 13px;
    color: var(--t2);
    line-height: 1.55;
}
.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}
.row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}
.row:first-of-type {
    padding-top: 0;
}
.row-k {
    color: var(--t2);
}
.row-v {
    font-weight: 600;
    color: var(--ink);
    text-align: right;
}

/* ─── HERO (подписка) ─── */
.hero {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px;
    box-shadow: var(--sh2);
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: "";
    position: absolute;
    inset: 0 0 auto auto;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle at 70% 30%, var(--adim), transparent 70%);
    pointer-events: none;
}
.hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.hero-label {
    font-size: 12px;
    color: var(--t3);
    margin-bottom: 4px;
}
.big {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.05;
}
.big-unit {
    font-size: 14px;
    font-weight: 500;
    color: var(--t2);
    margin-left: 4px;
}
.chip {
    flex-shrink: 0;
    padding: 5px 11px;
    border-radius: var(--pill);
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid;
}
.chip.ok {
    background: var(--adim);
    border-color: var(--ab);
    color: var(--accent-d);
}
.chip.warn {
    background: var(--adim2);
    border-color: rgba(217, 119, 6, 0.22);
    color: var(--amber);
}
.chip.bad {
    background: var(--rdim);
    border-color: rgba(220, 38, 38, 0.22);
    color: var(--red);
}
.bar {
    height: 6px;
    border-radius: var(--pill);
    background: var(--border);
    overflow: hidden;
    margin-top: 12px;
}
.bar-fill {
    height: 100%;
    border-radius: var(--pill);
    background: var(--accent);
    transition: width 0.5s ease;
}
.bar-fill.warn {
    background: var(--amber);
}
.bar-fill.bad {
    background: var(--red);
}

/* ─── BUTTONS ─── */
.btn {
    width: 100%;
    padding: 13px 16px;
    border-radius: var(--r2);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition:
        transform 0.12s ease,
        background 0.15s ease,
        border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.btn:active {
    transform: scale(0.975);
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:active {
    background: var(--accent-d);
}
.btn-ghost {
    background: var(--card);
    border-color: var(--border2);
    color: var(--ink);
}
.btn-danger {
    background: var(--rdim);
    border-color: rgba(220, 38, 38, 0.22);
    color: var(--red);
}
.btn-row {
    display: flex;
    gap: 8px;
}

/* ─── УСТРОЙСТВА ─── */
.dev {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.dev:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}
.dev-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--border2);
}
.dev-dot.on {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--adim);
}
.dev-body {
    min-width: 0;
    flex: 1;
}
.dev-ip {
    font-size: 13.5px;
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dev-meta {
    font-size: 11.5px;
    color: var(--t3);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── ТАРИФЫ ─── */
.plans {
    display: grid;
    gap: 8px;
}
.plan {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: var(--r2);
    border: 1.5px solid var(--border);
    background: var(--card);
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        background 0.15s ease,
        transform 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}
.plan:active {
    transform: scale(0.985);
}
.plan.sel {
    border-color: var(--accent);
    background: var(--adim);
}
.plan-days {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--ink);
}
.plan-note {
    font-size: 11.5px;
    color: var(--t3);
    margin-top: 2px;
}
.plan-price {
    font-weight: 700;
    font-size: 16px;
    color: var(--ink);
    flex-shrink: 0;
}
.plan-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: var(--pill);
    background: var(--adim);
    border: 1px solid var(--ab);
    color: var(--accent-d);
    font-size: 10px;
    font-weight: 600;
    vertical-align: middle;
}

/* ─── EMPTY ─── */
.empty {
    text-align: center;
    padding: 26px 16px;
    color: var(--t3);
    font-size: 13px;
    line-height: 1.55;
}
.empty svg {
    width: 30px;
    height: 30px;
    margin-bottom: 10px;
    color: var(--border2);
}

/* ─── BOTTOM NAV ─── */
.bnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: calc(var(--bnav) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    background: rgba(255, 255, 255, 0.93);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
}
.bnav-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--t3);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
}
.bnav-item svg {
    width: 21px;
    height: 21px;
    stroke-width: 1.8;
    transition: transform 0.18s ease;
}
.bnav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bnav-item.active {
    color: var(--accent);
}
.bnav-item.active svg {
    transform: scale(1.12);
}
.bnav-item:active svg {
    transform: scale(0.9);
}

/* ─── TOAST ─── */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--bnav) + env(safe-area-inset-bottom) + 16px);
    transform: translate(-50%, 16px);
    z-index: 50;
    max-width: calc(100% - 32px);
    padding: 11px 16px;
    border-radius: var(--pill);
    background: var(--ink);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--sh2);
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.22s ease,
        transform 0.22s ease;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}
.toast.bad {
    background: var(--red);
}

/* ─── ПАРТНЁРКА ─── */
.ref-stats {
    display: flex;
    gap: 8px;
    margin: 14px 0 12px;
}
.ref-stat {
    flex: 1;
    padding: 12px;
    border-radius: var(--r2);
    background: var(--adim);
    border: 1px solid var(--ab);
    text-align: center;
}
.ref-stat-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-d);
    letter-spacing: -0.02em;
}
.ref-stat-k {
    font-size: 11.5px;
    color: var(--t2);
    margin-top: 2px;
}
.ref-link {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--t2);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 11px 12px;
    margin-bottom: 10px;
    word-break: break-all;
    line-height: 1.45;
}

/* ─── СТЕППЕР УСТРОЙСТВ ─── */
.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 0 10px;
    padding: 10px 12px;
    border-radius: var(--r2);
    background: var(--bg);
    border: 1px solid var(--border);
}
.step-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px solid var(--border2);
    background: var(--card);
    color: var(--ink);
    font-size: 22px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        transform 0.12s ease,
        border-color 0.15s ease;
}
.step-btn:active:not(:disabled) {
    transform: scale(0.92);
    border-color: var(--accent);
}
.step-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.step-val {
    text-align: center;
    flex: 1;
    min-width: 0;
}
.step-num {
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.step-k {
    font-size: 11.5px;
    color: var(--t3);
}
.step-sum {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-d);
    margin-bottom: 12px;
    min-height: 18px;
}

/* ── MODAL GUIDE ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 20, 19, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal-overlay.show {
    opacity: 1;
}
.modal-content {
    background: var(--card);
    border-radius: var(--r) var(--r) 0 0;
    width: 100%;
    max-width: var(--max);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--sh2);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.show .modal-content {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border2);
    background: var(--bg);
    color: var(--t2);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}
.modal-close:active {
    transform: scale(0.9);
}
.modal-body {
    padding: 20px;
}
.guide-hint {
    font-size: 14px;
    color: var(--t2);
    margin-bottom: 16px;
}
.guide-subtitle {
    font-size: 13px;
    color: var(--t3);
    margin-bottom: 20px;
    text-align: center;
}
.guide-divider {
    text-align: center;
    color: var(--t3);
    font-size: 12px;
    margin: 20px 0 16px;
    position: relative;
}
.guide-divider::before,
.guide-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: calc(50% - 30px);
    height: 1px;
    background: var(--border);
}
.guide-divider::before {
    left: 0;
}
.guide-divider::after {
    right: 0;
}

.app-card {
    background: var(--card);
    border: 1.5px solid var(--border2);
    border-radius: var(--r2);
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
}
.app-card:active {
    transform: scale(0.98);
    border-color: var(--accent);
    background: var(--adim);
}
.app-info {
    flex: 1;
}
.app-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}
.app-desc {
    font-size: 13px;
    color: var(--t3);
}
.app-arrow {
    font-size: 20px;
    color: var(--t3);
    font-weight: 300;
}

.step {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
    align-items: flex-start;
}
.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--adim);
    color: var(--accent-d);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.step-content {
    flex: 1;
    padding-top: 2px;
}
.step-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}
.step-desc {
    font-size: 13px;
    color: var(--t2);
    line-height: 1.5;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}
.btn-block {
    width: 100%;
}
.mt8 {
    margin-top: 8px;
}

/* ── PAYMENT METHOD MODAL ── */
.payment-price {
    text-align: center;
    font-size: 16px;
    color: var(--t2);
    margin-bottom: 20px;
    padding: 12px;
    background: var(--adim);
    border-radius: var(--r2);
}
.payment-price strong {
    color: var(--accent-d);
    font-weight: 700;
    font-size: 20px;
}
.payment-method {
    background: var(--card);
    border: 1.5px solid var(--border2);
    border-radius: var(--r2);
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.payment-method:active {
    transform: scale(0.98);
    border-color: var(--accent);
    background: var(--adim);
}
.payment-icon {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: 10px;
    flex-shrink: 0;
}
.payment-info {
    flex: 1;
}
.payment-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 2px;
}
.payment-desc {
    font-size: 13px;
    color: var(--t3);
}
.payment-arrow {
    font-size: 20px;
    color: var(--t3);
    font-weight: 300;
}
}
