/* ── Variables ───────────────────────────────────────── */
:root {
    --bg: #0a0a14;
    --bg2: #10101f;
    --card-bg: #161628;
    --card-border: #1e1e3a;
    --text: #eaeaf5;
    --text2: #8888a8;
    --text3: #5a5a78;
    --accent: #7c3aed;
    --accent2: #a855f7;
    --accent-glow: rgba(124, 58, 237, 0.25);
    --green: #22c55e;
    --green-glow: rgba(34, 197, 94, 0.2);
    --yellow: #f59e0b;
    --pink: #ec4899;
    --radius: 16px;
    --radius-sm: 12px;
    --tab-height: 60px;
}

/* ── Reset ───────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    user-select: none;
}

/* ── Loading ─────────────────────────────────────────── */
.loading {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: var(--bg); z-index: 999;
}
.loading p { color: var(--text2); margin-top: 16px; font-size: 14px; }
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--card-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ── App container ───────────────────────────────────── */
.app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ── Tab Content ─────────────────────────────────────── */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px calc(var(--tab-height) + 16px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
}
.tab-content.active { display: block; }

/* ── Profile Header ──────────────────────────────────── */
.profile-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--card-border);
    margin-bottom: 16px;
}
.avatar-wrap { flex-shrink: 0; }
.avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.avatar svg { width: 36px; height: 36px; }
.profile-name {
    font-family: 'Courier New', Courier, monospace;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.profile-id {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: var(--text3);
    margin-top: 2px;
}

/* ── Balance Card ────────────────────────────────────── */
.balance-card {
    background: linear-gradient(135deg, #0d1a0d 0%, #0a1a0a 50%, #0d140d 100%);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.balance-label {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.balance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.balance-value {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 36px;
    font-weight: 700;
    color: var(--green);
}
.sp-icon { display: flex; align-items: center; }
.btn-buy {
    background: var(--green);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s, opacity .15s;
}
.btn-buy:active { transform: scale(0.95); opacity: 0.8; }

/* ── Action Row ──────────────────────────────────────── */
.action-row {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}
.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text2);
    font-size: 11px;
    cursor: pointer;
    transition: transform .15s, background .2s;
}
.action-btn:active { transform: scale(0.95); background: var(--bg2); }
.action-btn svg { color: var(--accent); }

/* ── Section Title ───────────────────────────────────── */
.section-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* ── Bot Balances ────────────────────────────────────── */
.bot-balances {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 24px;
}
.bot-balance-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.bot-balance-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.bot-balance-info { flex: 1; min-width: 0; }
.bot-balance-name {
    font-size: 12px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bot-balance-value {
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

/* ── Bot Preview Cards (Profile tab) ─────────────────── */
.bots-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.bot-preview-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform .15s, background .15s;
}
.bot-preview-card:active { transform: scale(0.98); background: var(--bg2); }
.bot-preview-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}
.bot-preview-info { flex: 1; min-width: 0; }
.bot-preview-name {
    font-family: 'Courier New', Courier, monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}
.bot-preview-desc {
    font-size: 12px;
    color: var(--text2);
    margin-top: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Page Title ──────────────────────────────────────── */
.page-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* ── Partnership ─────────────────────────────────────── */
.partner-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.partner-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s, background .15s;
}
.partner-btn:active { transform: scale(0.96); background: var(--bg2); }
.partner-btn svg { color: var(--accent); flex-shrink: 0; }

.ref-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 16px;
    margin-bottom: 16px;
}
.ref-card-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    color: var(--text2);
    margin-bottom: 12px;
}
.ref-link-box {
    background: var(--bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 12px;
    overflow: hidden;
}
.ref-link-text {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: var(--text);
    word-break: break-all;
}
.btn-copy {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s, opacity .15s;
}
.btn-copy:active { transform: scale(0.97); opacity: 0.8; }

.info-card {
    background: linear-gradient(135deg, rgba(124,58,237,0.08), rgba(124,58,237,0.02));
    border: 1px solid rgba(124,58,237,0.15);
    border-radius: var(--radius);
    padding: 20px;
}
.info-card-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent2);
    margin-bottom: 12px;
}
.info-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.info-list li {
    font-size: 13px;
    color: var(--text2);
    padding-left: 20px;
    position: relative;
}
.info-list li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--accent);
}

/* ── Marketplace ─────────────────────────────────────── */
.marketplace-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.market-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .15s;
}
.market-card:active { transform: scale(0.98); }
.market-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
}
.market-card-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}
.market-card-info { flex: 1; min-width: 0; }
.market-card-name {
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.market-card-desc {
    font-size: 13px;
    color: var(--text2);
    margin-top: 4px;
    line-height: 1.4;
}
.market-card-features {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 18px 14px;
}
.feature-tag {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent2);
    border: 1px solid rgba(124, 58, 237, 0.15);
}
.market-card-actions {
    display: flex;
    gap: 8px;
    padding: 0 18px 18px;
}
.market-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: transform .15s, opacity .15s;
    border: none;
}
.market-btn:active { transform: scale(0.95); opacity: 0.8; }
.market-btn-primary {
    background: var(--accent);
    color: #fff;
}
.market-btn-secondary {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text2);
}

/* ── Settings ────────────────────────────────────────── */
.settings-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--card-border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row.clickable { cursor: pointer; }
.settings-row.clickable:active { background: var(--bg2); }
.settings-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    color: var(--text);
}
.settings-label svg { color: var(--accent); }
.settings-select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
}

/* Toggle switch */
.toggle { position: relative; width: 48px; height: 28px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--text3);
    border-radius: 14px;
    cursor: pointer;
    transition: background .2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px; top: 3px;
    width: 22px; height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.app-version {
    text-align: center;
    font-size: 12px;
    color: var(--text3);
    margin-top: 24px;
}

/* ── Tariffs Overlay ─────────────────────────────────── */
.overlay-page {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: slideUp .3s ease;
}
.overlay-page.hidden { display: none; }
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.overlay-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--card-border);
}
.overlay-close {
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 4px;
}
.overlay-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 22px;
    font-weight: 700;
}
.tariffs-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 16px;
    -webkit-overflow-scrolling: touch;
}
.tariff-card {
    flex-shrink: 0;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
}
.tariff-card.popular {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}
.tariff-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.tariff-name {
    font-family: 'Courier New', Courier, monospace;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
}
.tariff-sp {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 20px;
    font-weight: 700;
}
.tariff-sp svg { flex-shrink: 0; }
.tariff-popular-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.tariff-section-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    margin-top: 4px;
}
.tariff-limits {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    margin-bottom: 20px;
}
.tariff-limit {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}
.tariff-limit-name { color: var(--text2); }
.tariff-limit-value {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 600;
    color: var(--text);
}
.tariff-price {
    font-family: 'Courier New', Courier, monospace;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
}
.tariff-price .currency { font-size: 16px; color: var(--text2); }
.tariff-buy-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s, opacity .15s;
}
.tariff-buy-btn:active { transform: scale(0.97); opacity: 0.8; }

/* ── Bot Detail Overlay ─────────────────────────────── */
.bot-detail-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 16px 32px;
    -webkit-overflow-scrolling: touch;
}
.bot-detail-hero {
    text-align: center;
    padding: 24px 0 20px;
}
.bot-detail-icon {
    width: 80px; height: 80px;
    border-radius: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 40px;
    margin-bottom: 14px;
}
.bot-detail-name {
    font-family: 'Courier New', Courier, monospace;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.bot-detail-username {
    font-size: 13px;
    color: var(--text3);
    margin-bottom: 16px;
}
.bot-detail-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.bot-detail-btn {
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform .15s, opacity .15s;
}
.bot-detail-btn:active { transform: scale(0.95); opacity: 0.8; }
.bot-detail-btn-primary { background: var(--accent); color: #fff; }
.bot-detail-btn-secondary { background: transparent; border: 1px solid var(--card-border); color: var(--text2); }

.bot-detail-section {
    margin-top: 20px;
}
.bot-detail-section-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}
.bot-detail-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text2);
}
.bot-detail-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.bot-detail-list li {
    font-size: 14px;
    color: var(--text2);
    line-height: 1.5;
    padding-left: 24px;
    position: relative;
}
.bot-detail-list li::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 7px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
}
.bot-detail-list.how-list li::before {
    content: attr(data-num);
    width: auto; height: auto;
    border-radius: 0;
    background: none;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    top: 0;
    left: 0;
}
.bot-detail-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.bot-detail-features .feature-tag {
    font-size: 12px;
    padding: 6px 14px;
}
.bot-detail-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text3);
    padding-bottom: 16px;
}

/* ── Tab Bar ─────────────────────────────────────────── */
.tab-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--tab-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg2);
    border-top: 1px solid var(--card-border);
    display: flex;
    z-index: 50;
}
.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 10px;
    cursor: pointer;
    padding: 8px 2px;
    transition: color .2s;
}
.tab-btn.active { color: var(--accent); }
.tab-btn svg { transition: color .2s; }
.tab-btn.active svg { stroke: var(--accent); }

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.tab-content.active > * {
    animation: fadeIn .3s ease both;
}
.tab-content.active > *:nth-child(1) { animation-delay: 0s; }
.tab-content.active > *:nth-child(2) { animation-delay: .04s; }
.tab-content.active > *:nth-child(3) { animation-delay: .08s; }
.tab-content.active > *:nth-child(4) { animation-delay: .12s; }
.tab-content.active > *:nth-child(5) { animation-delay: .16s; }
.tab-content.active > *:nth-child(6) { animation-delay: .20s; }
.tab-content.active > *:nth-child(7) { animation-delay: .24s; }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 0; height: 0; }
