:root {
    --bg-main: #0b0f19;
    --bg-card: #151c2c;
    --bg-card-hover: #1e283d;
    --bg-glass: rgba(21, 28, 44, 0.75);
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.3);
    --secondary: #10b981;
    --secondary-hover: #059669;
    --accent-gold: #f59e0b;
    --danger: #ef4444;
    
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --text-muted: #64748b;
    
    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(59, 130, 246, 0.5);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --font: 'Kantumruuy Pro', 'Plus Jakarta Sans', sans-serif;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-layout {
    width: 100%;
    max-width: 600px;
    background: var(--bg-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

/* NAVBAR */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.brand-info {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.2px;
}

.brand-tag {
    font-size: 0.75rem;
    color: var(--accent-gold);
    font-weight: 600;
}

.user-widgets {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.balance-pill {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 30px;
    padding: 0.35rem 0.6rem 0.35rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--secondary);
}

.btn-add-funds {
    background: var(--secondary);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.2s;
}

.btn-add-funds:hover {
    background: var(--secondary-hover);
}

.lang-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
}

/* MAIN CONTENT CONTAINER */
.main-content {
    padding: 1rem 1.25rem 3rem;
    flex: 1;
}

/* USER CARD */
.user-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.user-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-display-name {
    font-size: 1.05rem;
    font-weight: 700;
}

.rank-badge {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--accent-gold);
    font-size: 0.725rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
}

.user-id-text {
    font-size: 0.8rem;
    color: var(--text-sub);
}

.user-id-text code {
    color: var(--primary);
}

/* NAVIGATION TABS */
.nav-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.3rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-sub);
    padding: 0.6rem 0.3rem;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s ease;
}

.tab-icon {
    font-size: 1.2rem;
}

.tab-label {
    font-size: 0.725rem;
    font-weight: 600;
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* TAB CONTENTS */
.tab-content {
    display: none;
    animation: fadeIn 0.25s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    margin-bottom: 0.75rem;
    margin-top: 0.5rem;
}

.section-title h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* PLATFORM GRID */
.platform-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.platform-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.platform-card:hover {
    background: var(--bg-card-hover);
}

.platform-card.active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 15px var(--primary-glow);
}

.platform-icon {
    font-size: 1.6rem;
    margin-bottom: 0.3rem;
}

.platform-title {
    font-size: 0.85rem;
    font-weight: 700;
}

.platform-sub {
    font-size: 0.7rem;
    color: var(--text-sub);
}

/* CATEGORY SELECTOR */
.category-selector {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.25rem;
    scrollbar-width: thin;
}

.cat-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-sub);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.85rem;
    font-size: 0.825rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s ease;
}

.cat-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ORDER FORM BOX */
.order-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.form-select, .form-input {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    color: var(--text-main);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-select:focus, .form-input:focus {
    border-color: var(--primary);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* SUMMARY CARD */
.summary-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-sub);
}

.summary-row strong {
    color: var(--text-main);
}

.price-tag {
    font-size: 1.1rem !important;
    color: var(--secondary) !important;
    font-weight: 800 !important;
}

.alert-banner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.825rem;
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

.btn-submit-order {
    width: 100%;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    box-shadow: 0 4px 15px var(--primary-glow);
    transition: transform 0.15s ease, background 0.2s ease;
}

.btn-submit-order:active {
    transform: scale(0.98);
}

/* DEPOSIT BOX & KHQR */
.deposit-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.deposit-desc {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin-bottom: 1.25rem;
}

.quick-amounts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.amount-btn {
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s ease;
}

.amount-btn.active {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.margin-top {
    margin-top: 1rem;
}

.btn-generate-qr {
    width: 100%;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.85rem;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    margin-top: 0.5rem;
}

.qr-display-card {
    background: #ffffff;
    color: #0f172a;
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    text-align: center;
    margin-top: 1.25rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.khqr-badge {
    background: #e11d48;
    color: white;
    font-weight: 800;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

.qr-canvas-wrapper {
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin-bottom: 0.75rem;
}

#qrCanvas {
    width: 200px !important;
    height: 200px !important;
}

.qr-amount-label {
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.3rem;
}

.qr-timer {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 1rem;
}

.btn-sim-pay {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
}

/* HISTORY LIST */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-id {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
}

.order-status {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
}

.status-processing {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-gold);
}

.status-completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--secondary);
}

.history-body {
    font-size: 0.85rem;
    color: var(--text-main);
}

.history-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.775rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 0.4rem;
    margin-top: 0.2rem;
}

/* SUPPORT CARD */
.support-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.25rem;
    text-align: center;
}

.support-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.support-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.support-card p {
    font-size: 0.875rem;
    color: var(--text-sub);
    margin-bottom: 1.5rem;
}

.support-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.support-btn {
    background: var(--primary);
    color: white;
    text-decoration: none;
    padding: 0.85rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.support-btn:hover {
    background: var(--primary-hover);
}

.support-btn.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.support-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* TOAST NOTIFICATION */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    color: white;
    border: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    font-size: 0.875rem;
    font-weight: 600;
    pointer-events: auto;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

.toast.success {
    border-left: 4px solid var(--secondary);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

/* ========== LOGIN GATE (Telegram Login Widget) ========== */
.login-gate {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    z-index: 100;
    padding: 24px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 40px 32px;
    max-width: 380px;
    width: 100%;
    text-align: center;
}

.login-card h2 {
    margin: 12px 0 8px;
    color: var(--text-main);
}

.login-card p {
    color: var(--text-sub);
    font-size: 0.92rem;
    margin-bottom: 20px;
}

#telegramLoginContainer {
    display: flex;
    justify-content: center;
    min-height: 40px;
}

.login-hint {
    margin-top: 16px !important;
    font-size: 0.8rem !important;
    color: var(--text-muted) !important;
}
