:root {
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-dark: #6d28d9;
    --accent-glow: rgba(139, 92, 246, 0.45);
    --accent-soft: rgba(139, 92, 246, 0.12);
    --cyan: #22d3ee;
    --cyan-glow: rgba(34, 211, 238, 0.25);
    --bg-deep: #07070d;
    --bg-base: #0c0c14;
    --bg-elevated: rgba(255, 255, 255, 0.04);
    --bg-card: rgba(255, 255, 255, 0.03);
    --border: rgba(139, 92, 246, 0.22);
    --border-soft: rgba(255, 255, 255, 0.07);
    --text: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-dim: #71717a;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --radius: 20px;
    --radius-sm: 14px;
    --radius-lg: 28px;
    --shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    --shadow-accent: 0 8px 32px rgba(139, 92, 246, 0.22);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-deep);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    line-height: 1.5;
    position: relative;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(90px);
    z-index: 0;
    animation: floatGlow 8s ease-in-out infinite;
}

.bg-glow-1 {
    width: 320px;
    height: 320px;
    background: var(--accent-glow);
    top: -100px;
    right: -80px;
    opacity: 0.35;
}

.bg-glow-2 {
    width: 260px;
    height: 260px;
    background: var(--cyan-glow);
    bottom: 100px;
    left: -100px;
    opacity: 0.3;
    animation-delay: -4s;
}

@keyframes floatGlow {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-12px, 16px) scale(1.05); }
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.header {
    flex-shrink: 0;
    padding: 16px 20px 14px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    background: linear-gradient(165deg, rgba(109, 40, 217, 0.95) 0%, rgba(7, 7, 13, 0.98) 100%);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(20px);
}

.header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-logo {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
    ring: 1px solid rgba(255,255,255,0.1);
}

.brand-text { min-width: 0; }

.header h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 2px;
}

.user-chip {
    flex-shrink: 0;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.screen {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px 24px;
    -webkit-overflow-scrolling: touch;
}

.screen-inner {
    animation: screenIn 0.4s var(--ease-out) both;
}

@keyframes screenIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.bottom-nav {
    flex-shrink: 0;
    display: flex;
    background: rgba(12, 12, 20, 0.92);
    border-top: 1px solid var(--border-soft);
    padding: 6px 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(20px);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 2px;
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.25s, transform 0.2s;
    border-radius: 14px;
    position: relative;
}

.nav-item.active {
    color: var(--accent-light);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), var(--cyan));
    animation: navDot 0.3s var(--ease-out);
}

@keyframes navDot {
    from { width: 0; opacity: 0; }
    to { width: 28px; opacity: 1; }
}

.nav-svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    transition: filter 0.25s;
}

.nav-item.active .nav-svg {
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.card {
    background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    transition: border-color 0.25s, transform 0.25s;
}

.card-highlight {
    border-color: var(--border);
    box-shadow: var(--shadow-accent);
    position: relative;
    overflow: hidden;
}

.card-highlight::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--cyan), var(--accent));
    background-size: 200% 100%;
    animation: shimmer 4s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--accent-light);
    margin-bottom: 14px;
}

.card-title .hint-icon {
    font-size: 14px;
    opacity: 0.85;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 14px rgba(52, 211, 153, 0.7);
    animation: pulseDot 2s ease-in-out infinite;
}

.status-dot.trial {
    background: var(--warning);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
}

.status-dot.suspended { background: var(--warning); }

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.85; }
}

.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: 14px;
}

.row:last-child { border-bottom: none; padding-bottom: 0; }

.row .label {
    color: var(--text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.row .value {
    font-weight: 600;
    text-align: right;
    max-width: 58%;
    word-break: break-all;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s, opacity 0.2s;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-dark) 100%);
    color: #fff;
    box-shadow: 0 8px 24px rgba(109, 40, 217, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid var(--border-soft);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border-soft);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(248, 113, 113, 0.25);
}

.btn-sm {
    padding: 10px 14px;
    font-size: 13px;
    width: auto;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.plan-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-soft);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.25s var(--ease-out);
    animation: cardStagger 0.45s var(--ease-out) both;
}

.plan-card:nth-child(2) { animation-delay: 0.05s; }
.plan-card:nth-child(3) { animation-delay: 0.1s; }
.plan-card:nth-child(4) { animation-delay: 0.15s; }

@keyframes cardStagger {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.plan-card:active {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: scale(0.98);
}

.plan-name { font-weight: 700; font-size: 16px; }

.plan-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.plan-price {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-light), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.device-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-soft);
}

.device-card:last-child { border-bottom: none; }

.device-name { font-weight: 600; font-size: 15px; }

.device-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.balance-hero {
    text-align: center;
    padding: 24px 0 16px;
}

.balance-amount {
    font-size: 46px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--accent-light) 50%, var(--cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -2px;
}

.balance-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.deposit-custom {
    display: flex;
    gap: 10px;
    margin: 14px 0;
}

.deposit-custom .input { flex: 1; }

.amount-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 14px 0;
}

.amount-btn {
    padding: 14px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    background: var(--accent-soft);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.amount-btn:active {
    background: rgba(139, 92, 246, 0.25);
    border-color: var(--accent);
    transform: scale(0.96);
}

.payment-methods {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 14px 0;
}

.pay-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-soft);
    background: rgba(255,255,255,0.02);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.pay-option.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px var(--accent);
}

.pay-option-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.pay-option-body { flex: 1; min-width: 0; }

.pay-option-title { font-weight: 700; font-size: 15px; }

.pay-option-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.tx-item {
    padding: 13px 0;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.tx-item:last-child { border-bottom: none; }

.tx-emoji {
    font-size: 16px;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: 12px;
}

.tx-body { flex: 1; min-width: 0; }

.tx-amount { font-weight: 700; font-size: 15px; }

.tx-amount.positive { color: var(--success); }

.tx-amount.negative { color: #fca5a5; }

.tx-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.tx-date {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 3px;
}

.referral-link {
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 12px;
    word-break: break-all;
    margin: 12px 0;
    border: 1px dashed var(--border);
    color: var(--accent-light);
    font-family: ui-monospace, monospace;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-box {
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border-soft);
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-light);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.55;
}

.alert-warning {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: #fcd34d;
}

.alert-info {
    background: var(--accent-soft);
    border: 1px solid var(--border);
    color: var(--accent-light);
}

.alert-danger {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: #fca5a5;
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 18px;
}

.loader-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    object-fit: cover;
    box-shadow: var(--shadow-accent);
    animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--accent-soft);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 36px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 52px;
    margin-bottom: 14px;
    opacity: 0.85;
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 7, 13, 0.8);
    backdrop-filter: blur(6px);
    animation: fadeBackdrop 0.3s ease;
}

@keyframes fadeBackdrop {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-sheet {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    background: linear-gradient(180deg, #12121c 0%, var(--bg-deep) 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 8px 20px 28px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    animation: slideUp 0.35s var(--ease-out);
    border-top: 1px solid var(--border-soft);
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    margin: 6px auto 18px;
}

.modal-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 18px;
    letter-spacing: -0.4px;
}

.input-group { margin-bottom: 16px; }

.input-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.input {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.price-breakdown {
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 16px 0;
    border: 1px solid var(--border-soft);
}

.toast {
    position: fixed;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 28, 0.95);
    color: #fff;
    padding: 13px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    z-index: 200;
    box-shadow: var(--shadow-accent);
    max-width: 90%;
    text-align: center;
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    animation: toastIn 0.3s var(--ease-out);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.95); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.help-section { margin-bottom: 18px; }

.help-section h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--accent-light);
}

.help-section p, .help-section li {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.65;
}

.help-section ul, .help-section ol { padding-left: 18px; }

[hidden] { display: none !important; }
