*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         var(--tg-theme-bg-color, #0d0d0f);
    --bg2:        var(--tg-theme-secondary-bg-color, #1c1c1e);
    --text:       var(--tg-theme-text-color, #ffffff);
    --hint:       var(--tg-theme-hint-color, #8e8e93);
    --link:       var(--tg-theme-link-color, #3b82f6);
    --btn:        var(--tg-theme-button-color, #3b82f6);
    --btn-text:   var(--tg-theme-button-text-color, #ffffff);
    --radius:     18px;
}

/* ─── Background with gradient blobs ──────────────────────────── */
html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 15% 10%, rgba(99,102,241,0.28) 0%, transparent 70%),
        radial-gradient(ellipse 50% 40% at 85% 20%, rgba(59,130,246,0.22) 0%, transparent 65%),
        radial-gradient(ellipse 40% 50% at 50% 85%, rgba(139,92,246,0.18) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* everything on top of blobs */
header, .tabs, main, #maintenance-overlay { position: relative; z-index: 1; }

/* ─── Glass mixin (reused via custom props) ────────────────────── */
/* glass card */
.gc {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.13);
    box-shadow: 0 8px 32px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.12);
}

/* ─── Header ───────────────────────────────────────────────────── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(32px) saturate(200%);
    -webkit-backdrop-filter: blur(32px) saturate(200%);
    border-bottom: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 4px 20px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100000;
}

.balance-wrap { display: flex; flex-direction: column; gap: 1px; }

.balance-label {
    font-size: 11px;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.balance-value {
    font-size: 18px;
    font-weight: 700;
}

.balance-held {
    font-size: 12px;
    font-weight: 400;
    color: var(--hint);
    margin-top: 2px;
}

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
    background: linear-gradient(135deg, var(--btn) 0%, color-mix(in srgb, var(--btn) 75%, #7c3aed) 100%);
    color: var(--btn-text);
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    box-shadow: 0 4px 16px rgba(59,130,246,0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:active { opacity: .8; transform: scale(.97); }
.btn-primary:disabled { opacity: .4; cursor: default; box-shadow: none; }

.btn-sm   { padding: 8px 18px; font-size: 13px; border-radius: 20px; }
.btn-full { width: 100%; padding: 16px; font-size: 16px; border-radius: var(--radius); margin-top: 4px; }

/* ─── Tabs ─────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-bottom: 1px solid rgba(255,255,255,0.09);
}

.tab {
    flex: 1;
    padding: 11px 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--hint);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}

.tab.active {
    color: var(--btn);
    border-bottom-color: var(--btn);
    font-weight: 700;
}

/* ─── Content ──────────────────────────────────────────────────── */
main { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Gift grid ────────────────────────────────────────────────── */
.gifts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}

.gift-card {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.13);
    box-shadow: 0 8px 32px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.14);
    border-radius: 22px;
    padding: 20px 14px 16px;
    text-align: center;
    cursor: pointer;
    transition: transform .14s, box-shadow .14s;
    user-select: none;
}
.gift-card:active {
    transform: scale(.95);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.12);
}

.gift-icon { font-size: 52px; line-height: 1; margin-bottom: 10px; }

.gift-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}

.gift-price {
    font-size: 13px;
    color: var(--hint);
    margin-bottom: 10px;
}

.gift-card .btn-primary {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    border-radius: 12px;
}

/* ─── Gift sticker ─────────────────────────────────────────────── */
.gift-sticker { width: 90px; height: 90px; margin: 0 auto 6px; display: block; }

/* ─── Checks section ───────────────────────────────────────────── */
.checks-toggle-btn {
    width: 100%;
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.13);
    box-shadow: 0 4px 16px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    margin: 10px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: opacity .15s;
}
.checks-toggle-btn:active { opacity: .75; }
.checks-toggle-btn::after { content: '▸'; color: var(--hint); transition: transform .2s; font-size: 20px; line-height: 1; display: flex; align-items: center; transform-origin: center center; }
.checks-toggle-btn.checks-open::after { transform: rotate(90deg); }

#checks-list { margin-top: 8px; }

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 4px 16px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.10);
    border-radius: 16px;
    padding: 10px 12px;
    margin-bottom: 8px;
}
.check-icon { width: 40px; height: 40px; object-fit: contain; }
.check-info { flex: 1; min-width: 0; }
.check-name { font-size: 14px; font-weight: 600; }
.check-sub { font-size: 12px; color: var(--hint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.check-price { font-size: 13px; font-weight: 600; color: var(--link); white-space: nowrap; }
.check-cancel-btn { font-size: 11px; color: #ff453a; background: none; border: none; padding: 0; cursor: pointer; opacity: .75; }
.check-cancel-btn:active { opacity: 1; }

/* ─── History ───────────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.11);
    box-shadow: 0 6px 24px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.12);
    border-radius: var(--radius);
    padding: 14px;
}

.hi-gift  { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.hi-icon  { width: 28px !important; height: 28px !important; max-width: 28px !important; max-height: 28px !important; object-fit: contain; flex-shrink: 0; }
.hi-to    { font-size: 13px; color: var(--link); margin-bottom: 3px; }
.hi-msg   { font-size: 13px; color: var(--hint); font-style: italic; margin-bottom: 4px; }
.hi-date  { font-size: 11px; color: var(--hint); }
.hi-topup { border-left: 3px solid #f7c948; }
.hi-received { border-left: 3px solid var(--btn); }
.hi-topup-icon { font-size: 20px; line-height: 1; }
.hi-inline-badge { font-size: 11px; color: var(--hint); margin-bottom: 2px; }

/* ─── Utils ────────────────────────────────────────────────────── */
.empty   { text-align: center; color: var(--hint); padding: 48px 0; font-size: 15px; }
.loading { text-align: center; color: var(--hint); padding: 40px 0; }

/* ─── Overlay + sheet ──────────────────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    align-items: flex-end;
}
.overlay.hidden { display: none; }

.sheet {
    background: rgba(20,20,25,0.82);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    border: 1px solid rgba(255,255,255,0.12);
    border-bottom: none;
    box-shadow: 0 -12px 48px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
    border-radius: 26px 26px 0 0;
    padding: 10px 20px calc(28px + env(safe-area-inset-bottom));
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.sheet-handle {
    width: 36px; height: 4px;
    background: rgba(255,255,255,0.25);
    border-radius: 2px;
    margin: 2px auto 18px;
}

.sheet h2 { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.sheet-sub { text-align: center; color: var(--hint); font-size: 13px; margin-bottom: 18px; }

/* ─── Form ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; position: relative; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 7px;
}

.hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

.form-group input,
.form-group textarea {
    width: 100%;
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 13px 14px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    font-family: inherit;
    resize: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group textarea:focus {
    border-color: rgba(59,130,246,0.7);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 3px rgba(59,130,246,0.18);
}

.form-group textarea { height: 84px; padding-bottom: 24px; }

.qty-row { display: -webkit-flex !important; display: flex !important; -webkit-flex-wrap: nowrap; flex-wrap: nowrap; -webkit-align-items: center; align-items: center; gap: 8px; width: 100%; }
.qty-row input[type=number] { -webkit-flex: 1 1 auto !important; flex: 1 1 auto !important; width: auto !important; min-width: 0; text-align: center; font-size: 16px; font-weight: 600; -webkit-appearance: none; -moz-appearance: textfield; }
.qty-row input[type=number]::-webkit-outer-spin-button,
.qty-row input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
.qty-btn { display: -webkit-flex !important; display: flex !important; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; width: 44px !important; height: 44px; min-width: 44px; -webkit-flex-shrink: 0 !important; flex-shrink: 0 !important; border-radius: 10px; border: none; background: linear-gradient(135deg, var(--btn), #7c3aed); color: #fff; font-size: 22px; cursor: pointer; -webkit-appearance: none; appearance: none; box-shadow: 0 3px 12px rgba(59,130,246,0.35); }
.qty-btn:active { opacity: .75; }

.char-count { position: absolute; right: 11px; bottom: 10px; font-size: 11px; color: var(--hint); }

/* ─── Amounts ──────────────────────────────────────────────────── */
.amounts-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 4px; }

.amount-btn {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
    border-radius: var(--radius);
    padding: 15px 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all .15s;
}
.amount-btn:active, .amount-btn:hover {
    border-color: rgba(59,130,246,0.6);
    color: var(--btn);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), 0 0 0 2px rgba(59,130,246,0.2);
}

.custom-amount-row { display: flex; gap: 10px; }

.custom-amount-row input {
    flex: 1;
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 13px 14px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color .15s;
}
.custom-amount-row input:focus { border-color: rgba(59,130,246,0.7); }
.custom-amount-row .btn-primary { padding: 13px 18px; font-size: 14px; white-space: nowrap; }

/* ─── Fragment: payment method ─────────────────────────────────── */
.frag-payment-method {
    margin: -16px -16px 16px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-bottom: 1px solid rgba(255,255,255,0.09);
    position: sticky;
    top: 100px;
    z-index: 4;
}
.frag-payment-method.hidden { display: none; }

.frag-payment-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 8px;
}

.frag-payment-options {
    display: flex;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 12px;
    padding: 3px;
    gap: 2px;
}

.payment-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 9px 6px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--hint);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.payment-btn.active {
    background: linear-gradient(135deg, var(--btn), #7c3aed);
    color: #fff;
    box-shadow: 0 2px 10px rgba(59,130,246,0.35);
}
.payment-btn-icon { font-size: 14px; }

.frag-cb-currency { display: flex; gap: 8px; margin-top: 8px; }
.frag-cb-currency.hidden { display: none; }

.cb-cur-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: var(--hint);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}
.cb-cur-btn.active { background: linear-gradient(135deg, var(--btn), #7c3aed); color: #fff; border-color: transparent; }

/* ─── Fragment tabs ─────────────────────────────────────────────── */
.frag-subtabs {
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.09);
    margin: -16px -16px 20px;
    padding: 0 16px;
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: sticky;
    top: 54px;
    z-index: 5;
    overflow: hidden;
}

.frag-subtab {
    flex: 1;
    padding: 11px 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--hint);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
}
.frag-subtab.active { color: var(--text); border-bottom-color: var(--btn); font-weight: 700; }

.frag-content { display: none; }
.frag-content.active { display: block; }

.frag-features { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.frag-features-single { grid-template-columns: 1fr; }

.frag-card {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 6px 24px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 14px 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.frag-card-wide { flex-direction: row; align-items: center; font-size: 14px; gap: 14px; }
.frag-card-icon { font-size: 20px; line-height: 1; opacity: .75; }
.frag-icon-nokyc { font-size: 14px; line-height: 1.1; }

.frag-price-row {
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 700;
    color: var(--btn);
    text-align: center;
    margin-bottom: 14px;
}
.frag-price-row.hidden { display: none; }

.frag-periods { display: flex; flex-direction: column; gap: 8px; }

.frag-period {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.11);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.frag-period.active {
    border-color: rgba(59,130,246,0.7);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), 0 0 0 2px rgba(59,130,246,0.2);
}

.frag-period input[type="radio"] { width: 18px; height: 18px; accent-color: var(--btn); flex-shrink: 0; cursor: pointer; }
.frag-period-label { flex: 1; font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.frag-discount { background: linear-gradient(135deg, var(--btn), #7c3aed); color: #fff; border-radius: 20px; padding: 2px 7px; font-size: 11px; font-weight: 700; }
.frag-period-price { font-size: 13px; font-weight: 700; color: var(--btn); white-space: nowrap; }

.frag-connect-wrap { margin-bottom: 8px; }
.frag-buy-btn { margin-top: 8px; }

/* ─── Send modal ───────────────────────────────────────────────── */
.send-header { display: flex; flex-direction: column; align-items: center; margin-bottom: 6px; }
.send-sticker { width: 100px; height: 100px; }
.send-header h2 { margin-bottom: 14px; }

/* ─── Maintenance overlay ──────────────────────────────────────── */
#maintenance-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--text);
    font-size: 16px;
    text-align: center;
    padding: 32px;
}
