*, *::before, *::after {
    box-sizing: border-box;
    margin: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg:       #0f0f0f;
    --card:     #1a1a1a;
    --card2:    #222222;
    --border:   #2a2a2a;
    --accent:   #6c63ff;
    --accentL:  #8b85ff;
    --glow:     rgba(108,99,255,0.25);
    --text:     #ffffff;
    --muted:    #777777;
    --gold:     #fbbf24;
    --green:    #22c55e;
    --r:        16px;
    --rs:       10px;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
}

/* ── LOADER ── */
.loader {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; background: var(--bg); z-index: 999;
    transition: opacity .3s;
}
.loader-spinner {
    width: 44px; height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.loader p { color: var(--muted); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── APP ── */
.app {
    padding: 18px 14px;
    display: flex; flex-direction: column; gap: 14px;
    animation: fadeUp .3s ease;
    min-height: 100vh;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── HEADER CARD ── */
.header-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px 16px;
}
.user-row {
    display: flex; align-items: center; gap: 12px;
}
.avatar {
    width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), var(--accentL));
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
    box-shadow: 0 0 18px var(--glow);
}
.user-info {
    display: flex; flex-direction: column; gap: 3px; flex: 1;
}
.balance-info {
    display: flex; flex-direction: column; gap: 3px; align-items: flex-end;
}
.info-label {
    font-size: 11px; color: var(--muted);
    text-transform: uppercase; letter-spacing: .4px;
}
.user-name  { font-size: 16px; font-weight: 600; }
.balance-val { font-size: 16px; font-weight: 700; color: var(--gold); }

/* ── TOPUP BUTTON ── */
.btn-topup {
    width: 100%; padding: 17px;
    background: linear-gradient(135deg, var(--accent), var(--accentL));
    border: none; border-radius: var(--r);
    color: #fff; font-size: 16px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center;
    justify-content: center; gap: 10px;
    box-shadow: 0 4px 20px var(--glow);
    transition: transform .15s, box-shadow .15s;
}
.btn-topup:active { transform: scale(.97); }

/* ── INFO CARD ── */
.info-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 4px 8px;
}
.info-row {
    display: flex; align-items: center; gap: 14px; padding: 14px 8px;
}
.icon { font-size: 22px; width: 32px; text-align: center; }
.info-val { font-size: 15px; font-weight: 600; }
.info-val.gold { color: var(--gold); }
.sep { height: 1px; background: var(--border); }

/* ── OVERLAY ── */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(5px);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 100;
    opacity: 0; visibility: hidden;
    transition: opacity .25s, visibility .25s;
}
.overlay.open { opacity: 1; visibility: visible; }

/* ── SHEET ── */
.sheet {
    width: 100%; max-width: 480px;
    background: var(--card);
    border-radius: var(--r) var(--r) 0 0;
    border: 1px solid var(--border); border-bottom: none;
    padding: 12px 18px 32px;
    display: flex; flex-direction: column; gap: 16px;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1);
    max-height: 90vh; overflow-y: auto;
}
.overlay.open .sheet { transform: translateY(0); }

.sheet-center {
    border-radius: var(--r);
    margin: 20px;
    align-items: center;
    text-align: center;
    padding: 32px 20px;
}
.overlay.open .sheet-center { transform: translateY(0); }

.sheet-handle {
    width: 36px; height: 4px;
    background: var(--border); border-radius: 2px;
    align-self: center;
}
.sheet-header {
    display: flex; align-items: center; justify-content: space-between;
}
.sheet-header h2 { font-size: 19px; font-weight: 700; }
.btn-close {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--card2); border: none;
    color: var(--muted); font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.btn-close:hover { background: var(--border); color: var(--text); }

/* ── INPUT ── */
.input-wrap {
    display: flex; align-items: center;
    background: var(--card2); border: 1px solid var(--border);
    border-radius: var(--rs); overflow: hidden;
    transition: border-color .15s;
}
.input-wrap:focus-within { border-color: var(--accent); }
.input-wrap input {
    flex: 1; background: transparent; border: none; outline: none;
    padding: 14px 16px; color: var(--text);
    font-size: 18px; font-weight: 600;
}
.input-wrap input::placeholder { color: var(--muted); font-weight: 400; }
.input-unit {
    padding: 0 14px; color: var(--muted); font-size: 13px;
    border-left: 1px solid var(--border);
    height: 52px; display: flex; align-items: center;
}
.input-hint { font-size: 12px; color: var(--muted); margin-top: -8px; }

/* ── QUICK ── */
.quick-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.quick {
    padding: 10px; background: var(--card2);
    border: 1px solid var(--border); border-radius: var(--rs);
    color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all .15s;
}
.quick.active, .quick:hover {
    border-color: var(--accent); color: var(--accentL);
    background: rgba(108,99,255,.15);
}

/* ── METHOD ── */
.method-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--card2); border: 1px solid var(--accent);
    border-radius: var(--rs); padding: 14px;
}
.method-icon { font-size: 26px; }
.method-name { font-size: 14px; font-weight: 600; }
.method-sub  { font-size: 12px; color: var(--muted); }
.method-check {
    margin-left: auto; width: 24px; height: 24px;
    background: var(--accent); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}

/* ── PAY BUTTON ── */
.btn-pay {
    width: 100%; padding: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accentL));
    border: none; border-radius: var(--rs);
    color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 16px var(--glow);
    transition: transform .15s, box-shadow .15s;
}
.btn-pay:active  { transform: scale(.98); }
.btn-pay:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── SUCCESS ── */
.success-icon { font-size: 60px; animation: pop .4s ease; }
@keyframes pop {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.success-sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.balance-new {
    width: 100%; background: var(--card2);
    border-radius: var(--rs); padding: 14px;
    display: flex; justify-content: space-between; align-items: center;
}
.balance-new span { color: var(--muted); font-size: 13px; }
.balance-new strong { color: var(--gold); font-size: 17px; }

/* ── TOAST ── */
.toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--card2); border: 1px solid var(--border);
    border-radius: 24px; padding: 11px 20px;
    font-size: 14px; white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
    z-index: 999; transition: transform .25s;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err  { border-color: #ef4444; color: #ef4444; }
.toast.ok   { border-color: var(--green); color: var(--green); }