/* ===== Пиксельный VPN v4 ===== */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
    --bg: #faf7f0;
    --ink: #0f0f0f;
    --paper: #ffffff;
    --muted: #666;
    --soft: #f1ede2;
    --dash: #ddd;

    --yellow: #ffd23f;
    --blue: #6eb1e6;
    --green: #7cc36c;
    --red: #e86a6a;
    --purple: #b088e0;
    --mint: #8de2cb;

    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);

    --pixel: 'Press Start 2P', monospace;
    --mono: 'VT323', monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

button {
    font-family: inherit;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
}

/* ===== ШАПКА ===== */
#topbar {
    padding: calc(var(--safe-top) + 10px) 12px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    background: var(--bg);
    border-bottom: 2px solid var(--ink);
}

#logo {
    width: 32px;
    height: 32px;
    background: var(--ink);
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    flex-shrink: 0;
}
#logo > div { background: transparent; }
#logo > div.on { background: var(--yellow); }

#topbar .brand {
    font-family: var(--pixel);
    font-size: 10px;
    letter-spacing: 2px;
    flex: 1;
}

.top-btn {
    width: 32px;
    height: 32px;
    background: var(--paper);
    border: 2px solid var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pixel);
    font-size: 10px;
    position: relative;
}

.top-btn .dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    background: var(--red);
    border: 2px solid var(--ink);
}

.lang-btn {
    height: 32px;
    padding: 0 8px;
    background: var(--paper);
    border: 2px solid var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--pixel);
    font-size: 8px;
    letter-spacing: 1px;
}

/* ===== МАКЕТ ===== */
#screen {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 14px 24px;
    -webkit-overflow-scrolling: touch;
}

.page-title {
    font-family: var(--pixel);
    font-size: 14px;
    letter-spacing: 2px;
    margin-bottom: 16px;
    padding: 4px 0;
}

.pixel-label {
    font-family: var(--pixel);
    font-size: 8px;
    letter-spacing: 1px;
    color: var(--muted);
    padding: 8px 4px 10px;
    text-transform: uppercase;
}

.pixel-num {
    font-family: var(--pixel);
    font-size: 13px;
}

/* ===== БАЗОВЫЕ КАРТОЧКИ ===== */
.card {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 5px 5px 0 var(--ink);
    padding: 14px;
    margin-bottom: 14px;
}

.card.tight { padding: 10px 12px; }
.card.yellow { background: var(--yellow); }
.card.green  { background: var(--green); }
.card.blue   { background: var(--blue); }
.card.red    { background: var(--red); color: #fff; }
.card.purple { background: var(--purple); }
.card.mint   { background: var(--mint); }

/* ===== ПРИВЕТСТВИЕ ===== */
.hello {
    padding: 0 4px 12px;
}
.hello .big {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}
.hello .sub {
    font-size: 13px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.hello .tag {
    background: var(--yellow);
    border: 2px solid var(--ink);
    padding: 2px 8px;
    font-family: var(--pixel);
    font-size: 7px;
    letter-spacing: 0.5px;
    color: var(--ink);
}

/* ===== ПРОГРЕСС-БАР ===== */
.progress {
    height: 10px;
    background: var(--soft);
    border: 2px solid var(--ink);
    margin: 8px 0 4px;
    position: relative;
    overflow: hidden;
}
.progress .fill {
    height: 100%;
    background: var(--green);
    transition: width 0.3s;
}
.progress .fill.med { background: var(--yellow); }
.progress .fill.high { background: var(--red); }

.progress-legend {
    display: flex;
    justify-content: space-between;
    font-family: var(--pixel);
    font-size: 7px;
    color: var(--muted);
    margin-bottom: 2px;
}

/* ===== СТАТУС АКТИВНОЙ ПОДПИСКИ ===== */
.status {
    border: 3px solid var(--ink);
    box-shadow: 5px 5px 0 var(--ink);
    padding: 14px 16px;
    margin-bottom: 14px;
    position: relative;
    background: var(--paper);
}
.status.active { background: var(--green); }

.status .row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}
.status .kicker {
    font-family: var(--pixel);
    font-size: 8px;
    letter-spacing: 0.5px;
    color: var(--ink);
    opacity: 0.7;
}
.status .pill {
    background: var(--paper);
    border: 2px solid var(--ink);
    padding: 2px 8px;
    font-family: var(--pixel);
    font-size: 7px;
    letter-spacing: 0.5px;
}
.status .big {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}
.status .small {
    font-size: 13px;
    color: var(--ink);
    opacity: 0.8;
}

/* ===== КНОПКИ ===== */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: 3px solid var(--ink);
    box-shadow: 5px 5px 0 var(--ink);
    font-family: var(--pixel);
    font-size: 11px;
    letter-spacing: 1px;
    text-align: center;
    background: var(--yellow);
    color: var(--ink);
    transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active {
    transform: translate(3px, 3px);
    box-shadow: 2px 2px 0 var(--ink);
}
.btn.sm {
    padding: 8px;
    font-size: 8px;
    box-shadow: 3px 3px 0 var(--ink);
}
.btn.sm:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--ink);
}
.btn.yellow { background: var(--yellow); }
.btn.blue   { background: var(--blue); }
.btn.green  { background: var(--green); }
.btn.red    { background: var(--red); color: #fff; }
.btn.white  { background: var(--paper); }
.btn.purple { background: var(--purple); }

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

/* ===== АКЦИИ (кликабельные строки) ===== */
.action {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    padding: 10px 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.08s, box-shadow 0.08s;
    width: 100%;
    text-align: left;
    color: inherit;
}
.action:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink);
}

.action .icon {
    width: 32px;
    height: 32px;
    border: 2px solid var(--ink);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    flex-shrink: 0;
}
.action .icon > div { background: transparent; }
.action .icon > div.on { background: var(--ink); }

.action .icon.yellow { background: var(--yellow); }
.action .icon.blue   { background: var(--blue); }
.action .icon.green  { background: var(--green); }
.action .icon.red    { background: var(--red); }
.action .icon.purple { background: var(--purple); }
.action .icon.mint   { background: var(--mint); }

.action .body { flex: 1; min-width: 0; }
.action .title { font-size: 15px; font-weight: 600; }
.action .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.action .arrow { font-family: var(--pixel); font-size: 12px; }

/* ===== МИНИ-КАРТОЧКИ (Баланс / Рефералы на главной) ===== */
.mini-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.mini-card {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    padding: 12px;
    cursor: pointer;
    transition: transform 0.08s, box-shadow 0.08s;
    position: relative;
}
.mini-card:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink);
}
.mini-card .tl {
    font-family: var(--pixel);
    font-size: 8px;
    color: var(--muted);
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.mini-card .val {
    font-family: var(--pixel);
    font-size: 16px;
    color: var(--ink);
}
.mini-card .sub {
    font-family: var(--pixel);
    font-size: 7px;
    color: var(--green);
    margin-top: 4px;
    letter-spacing: 0.5px;
}
.mini-card .arr {
    position: absolute;
    top: 12px;
    right: 12px;
    font-family: var(--pixel);
    font-size: 10px;
}

/* ===== ТАРИФЫ ===== */
.tariff {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 5px 5px 0 var(--ink);
    padding: 14px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    cursor: pointer;
    transition: transform 0.08s, box-shadow 0.08s;
}
.tariff:active {
    transform: translate(2px, 2px);
    box-shadow: 3px 3px 0 var(--ink);
}
.tariff.top { background: var(--green); }
.tariff .num {
    width: 38px;
    height: 38px;
    border: 3px solid var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pixel);
    font-size: 11px;
    flex-shrink: 0;
}
.tariff .num.c-yellow { background: var(--yellow); }
.tariff .num.c-blue { background: var(--blue); }
.tariff .num.c-red { background: var(--red); color: #fff; }
.tariff .num.c-paper { background: var(--paper); }
.tariff .info { flex: 1; }
.tariff .name { font-size: 16px; font-weight: 700; }
.tariff .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tariff.top .meta { color: #1a4012; }
.badge-top {
    position: absolute;
    top: -10px;
    right: 10px;
    background: var(--yellow);
    border: 2px solid var(--ink);
    padding: 3px 8px;
    font-family: var(--pixel);
    font-size: 7px;
    letter-spacing: 0.5px;
}

/* ===== URL / КЛЮЧ ===== */
.key-text {
    font-family: var(--mono);
    font-size: 15px;
    color: var(--muted);
    background: var(--soft);
    padding: 8px 10px;
    border: 2px solid var(--ink);
    word-break: break-all;
    line-height: 1.3;
    margin-bottom: 10px;
    user-select: all;
}

/* ===== ТУМБЛЕР (автопродление) ===== */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    margin-bottom: 14px;
}
.toggle-row .body { flex: 1; }
.toggle-row .title { font-size: 15px; font-weight: 600; }
.toggle-row .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.toggle {
    width: 50px;
    height: 26px;
    background: var(--paper);
    border: 3px solid var(--ink);
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s;
}
.toggle .knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--ink);
    transition: left 0.15s;
}
.toggle.on { background: var(--green); }
.toggle.on .knob { left: 26px; }

/* ===== ШАГИ 1-2-3 ===== */
.steps {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    padding: 12px;
    margin-bottom: 16px;
}
.step { display: flex; gap: 12px; padding: 8px 0; align-items: center; }
.step + .step { border-top: 2px dashed var(--dash); }
.step .n {
    width: 26px;
    height: 26px;
    border: 2px solid var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pixel);
    font-size: 10px;
    flex-shrink: 0;
}
.step .n.yellow { background: var(--yellow); }
.step .n.blue { background: var(--blue); }
.step .n.green { background: var(--green); }
.step .t { font-size: 13px; }

/* ===== ТРАНЗАКЦИИ ===== */
.tx {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    padding: 10px 12px;
    margin-bottom: 8px;
}
.tx-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.tx-badge {
    font-family: var(--pixel);
    font-size: 7px;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border: 2px solid var(--ink);
}
.tx-badge.sub     { background: var(--purple); }
.tx-badge.topup   { background: var(--blue); }
.tx-badge.promo   { background: var(--yellow); }
.tx-badge.ref     { background: var(--yellow); }
.tx-badge.device  { background: var(--mint); }
.tx-badge.traffic { background: var(--mint); }
.tx-badge.bonus   { background: var(--green); }

.tx-date { font-size: 11px; color: var(--muted); }
.tx-body {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.tx-desc { font-size: 13px; flex: 1; }
.tx-amt { font-family: var(--pixel); font-size: 11px; flex-shrink: 0; }
.tx-amt.in { color: #2a7a1f; }
.tx-amt.out { color: #a32d2d; }

/* ===== BALANCE HERO ===== */
.balance-hero {
    background: var(--yellow);
    border: 3px solid var(--ink);
    box-shadow: 6px 6px 0 var(--ink);
    padding: 22px 18px;
    margin-bottom: 16px;
    text-align: center;
}
.balance-hero .kicker {
    font-family: var(--pixel);
    font-size: 9px;
    letter-spacing: 1px;
    margin-bottom: 12px;
    opacity: 0.75;
}
.balance-hero .amount {
    font-family: var(--pixel);
    font-size: 30px;
    line-height: 1;
}

/* ===== ПРОМОКОД ===== */
.promo-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}
.input {
    flex: 1;
    padding: 12px;
    border: 3px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    background: var(--paper);
    font-family: var(--mono);
    font-size: 16px;
    outline: none;
    color: var(--ink);
    min-width: 0;
}
.input::placeholder {
    color: var(--muted);
    font-family: var(--sans);
    font-size: 14px;
}
.input:focus {
    background: var(--yellow);
}

/* ===== СТАТИСТИКА (рефералы) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.stat {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    padding: 14px;
}
.stat.green { background: var(--green); }
.stat.yellow { background: var(--yellow); }
.stat.blue { background: var(--blue); }
.stat .big-num {
    font-family: var(--pixel);
    font-size: 20px;
    margin-bottom: 6px;
}
.stat .label {
    font-family: var(--pixel);
    font-size: 7px;
    letter-spacing: 1px;
    color: var(--muted);
}
.stat.green .label,
.stat.yellow .label,
.stat.blue .label { color: var(--ink); }

.stat-wide { grid-column: span 2; }

/* ===== Списки рефералов ===== */
.ref-item {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ref-item .who { flex: 1; }
.ref-item .who .name { font-weight: 600; font-size: 14px; }
.ref-item .who .date { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ref-status {
    font-family: var(--pixel);
    font-size: 7px;
    padding: 3px 8px;
    border: 2px solid var(--ink);
    letter-spacing: 0.5px;
}
.ref-status.active { background: var(--green); }
.ref-status.pending { background: var(--paper); color: var(--muted); }

/* ===== ТАБЛИЦА-ПЛАШКИ (условия программы) ===== */
.plate-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}
.plate {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    padding: 10px;
}
.plate .l {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
}
.plate .v {
    font-family: var(--pixel);
    font-size: 12px;
    color: var(--ink);
}
.plate.green .v { color: #2a7a1f; }

/* ===== ПУСТО ===== */
.empty {
    background: var(--paper);
    border: 3px dashed var(--ink);
    padding: 26px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 12px;
}
.empty .ic {
    width: 36px;
    height: 36px;
    background: var(--soft);
    border: 2px solid var(--ink);
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pixel);
    font-size: 14px;
    color: var(--ink);
}

/* ===== ДЕВАЙСЫ (мини-карточки) ===== */
.device {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.device .dev-ico {
    width: 28px;
    height: 28px;
    background: var(--blue);
    border: 2px solid var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pixel);
    font-size: 10px;
}
.device .dev-name { flex: 1; font-weight: 600; font-size: 14px; }
.device .dev-plat {
    font-family: var(--pixel);
    font-size: 7px;
    color: var(--muted);
    letter-spacing: 1px;
}

/* ===== МОДАЛЬНОЕ ОКНО ===== */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: none;
    align-items: flex-end;
    z-index: 200;
}
#modal-overlay.show { display: flex; }

.modal {
    width: 100%;
    background: var(--bg);
    border-top: 4px solid var(--ink);
    padding: 20px 16px calc(var(--safe-bottom) + 20px);
    animation: slideUp 0.25s ease-out;
    max-height: 90%;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-title {
    font-family: var(--pixel);
    font-size: 12px;
    letter-spacing: 1.5px;
    text-align: center;
    margin-bottom: 6px;
}
.modal-sub {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    margin-bottom: 16px;
}

.counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 16px;
}
.counter .minus, .counter .plus {
    width: 48px;
    height: 48px;
    background: var(--yellow);
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    font-family: var(--pixel);
    font-size: 16px;
    cursor: pointer;
}
.counter .minus:active, .counter .plus:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink);
}
.counter .val {
    font-family: var(--pixel);
    font-size: 32px;
    min-width: 70px;
    text-align: center;
}

.pack-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.pack {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.08s, box-shadow 0.08s;
}
.pack:active, .pack.selected {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink);
}
.pack.selected { background: var(--green); }
.pack .gb {
    font-family: var(--pixel);
    font-size: 14px;
    margin-bottom: 6px;
}
.pack .price {
    font-family: var(--pixel);
    font-size: 10px;
    color: var(--muted);
}
.pack.selected .price { color: var(--ink); }

/* ===== ТАББАР ===== */
#tabbar {
    display: flex;
    background: var(--ink);
    padding: 10px 0 calc(var(--safe-bottom) + 10px);
    flex-shrink: 0;
}
.tab {
    flex: 1;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px;
    font-family: var(--pixel);
}
.tab .glyph { font-size: 12px; }
.tab .name { font-size: 7px; letter-spacing: 1px; }
.tab.active { color: var(--yellow); }

.tab.center { position: relative; }
.tab.center .glyph {
    width: 42px;
    height: 42px;
    background: var(--yellow);
    border: 3px solid var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--ink);
    margin-top: -22px;
    margin-bottom: 2px;
}
.tab.center.active .glyph { background: var(--green); }
.tab.center .name { color: #fff; }
.tab.center.active .name { color: var(--yellow); }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink);
    color: var(--yellow);
    padding: 10px 20px;
    border: 3px solid var(--ink);
    box-shadow: 4px 4px 0 #000;
    font-family: var(--pixel);
    font-size: 9px;
    letter-spacing: 1px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 300;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== АНИМАЦИЯ ===== */
.fade-in { animation: fadeIn 0.18s ease-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Шапка экрана (заголовки секций) ===== */
.sec-title {
    font-size: 18px;
    font-weight: 700;
    margin: 16px 4px 10px;
}

.sec-title:first-child { margin-top: 4px; }

/* ===== Партнёрский блок ===== */
.partner {
    background: var(--purple);
    border: 3px solid var(--ink);
    box-shadow: 5px 5px 0 var(--ink);
    padding: 16px;
    margin-bottom: 14px;
}
.partner .t { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.partner .s { font-size: 13px; margin-bottom: 12px; opacity: 0.9; }
