:root {
    --bg-color: #0b0e11; --card-bg: #1e2329;
    --text-main: #eaecef; --text-dim: #848e9c;
    --green: #00c076; --red: #cf304a; --accent: #f0b90b; --border: #2b3139;
    --tag-blue: #2962ff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { 
    margin: 0; padding: 0; width: 100%; height: 100vh; height: 100dvh;
    background-color: var(--bg-color); color: var(--text-main); 
    font-family: 'Inter', sans-serif; font-size: 14px; 
    overflow: hidden; 
}

.app-wrapper { width: 100%; max-width: 100%; height: 100vh; height: 100dvh; position: relative; display: flex; flex-direction: column; }

h1, h2, h3, .btn, .brand, .tab, .title { font-family: 'Poppins', sans-serif; }
.screen-active { display: flex; flex-direction: column; height: 100%; width: 100%; }
.screen-hidden, .hidden { display: none !important; }

#custom-alert-overlay, #dynamic-modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 9999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.custom-alert-box { background: var(--card-bg); width: 70%; max-width: 240px; border-radius: 10px; padding: 15px; text-align: center; border: 1px solid var(--border); box-shadow: 0 10px 20px rgba(0,0,0,0.8); animation: popIn 0.2s ease-out forwards; }
.dynamic-modal-box { background: var(--card-bg); width: 85%; max-width: 400px; border-radius: 12px; padding: 20px; border: 1px solid var(--border); position: relative; animation: popIn 0.2s ease-out forwards; max-height: 85vh; overflow-y: auto;}
.modal-close-btn { position: absolute; top: 15px; right: 15px; background: none; border: none; color: var(--text-dim); font-size: 1.2rem; cursor: pointer; }
.custom-alert-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-color); margin: 0 auto 8px auto; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: bold; border: 2px solid; }
#alert-title { margin: 0 0 5px 0; font-size: 1rem; color: white; }
#alert-message { margin: 0; font-size: 0.75rem; color: var(--text-dim); line-height: 1.3; }

#notification-modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 10000; display: flex; align-items: flex-start; justify-content: center; backdrop-filter: blur(3px); padding-top: 70px; }
.notification-modal-box { background: var(--card-bg); width: 90%; max-width: 400px; border-radius: 12px; padding: 20px; border: 1px solid var(--border); animation: popIn 0.2s ease-out forwards; max-height: 70vh; display: flex; flex-direction: column; box-shadow: 0 10px 30px rgba(0,0,0,0.9);}
.notif-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 10px; }
#notification-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; padding-right: 5px; }
.notif-item { background: rgba(255,255,255,0.03); padding: 12px; border-radius: 8px; border-left: 3px solid var(--accent); }
.notif-item.read { border-left-color: var(--border); opacity: 0.6; }
.notif-item-title { font-weight: bold; font-size: 0.85rem; margin-bottom: 4px; color: white; }
.notif-item-desc { font-size: 0.75rem; color: var(--text-dim); line-height: 1.4; }
.notif-empty { text-align: center; color: var(--text-dim); padding: 30px 0; font-size: 0.85rem; font-style: italic; }

@keyframes popIn { 0% { transform: scale(0.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

#sidebar-menu { position: absolute; top: 0; left: 0; width: 280px; height: 100%; background: var(--card-bg); z-index: 9998; border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: transform 0.3s ease; box-shadow: 5px 0 15px rgba(0,0,0,0.5);}
#sidebar-menu.hidden { transform: translateX(-100%); display: flex !important; }
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h2 { margin: 0; color: var(--accent); font-size: 1.2rem;}
.sidebar-links { padding: 20px 0; flex: 1; display: flex; flex-direction: column;}
.menu-link { background: none; border: none; color: white; padding: 15px 20px; text-align: left; font-size: 1rem; font-weight: 600; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05); transition: background 0.2s;}
.menu-link:hover { background: rgba(240, 185, 11, 0.1); color: var(--accent); }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border); }

.auth-container { width: 90%; max-width: 350px; margin: auto; text-align: center; }
.brand-large { font-size: 1.8rem; color: var(--accent); margin-bottom: 15px; font-weight: 700;}
.pro-badge { background: var(--accent); color: #000; padding: 2px 4px; border-radius: 4px; font-size: 0.7rem; font-weight: 700;}
.auth-tabs { display: flex; margin-bottom: 15px; }
.tab { flex: 1; background: none; border: none; color: var(--text-dim); padding: 10px; font-weight: 600; border-bottom: 2px solid transparent; cursor: pointer; font-size: 0.85rem;}
.tab.active { color: var(--text-main); border-bottom: 2px solid var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.clean-input, .auth-form input, .auth-form select, textarea { width: 100%; padding: 10px; background: var(--card-bg); border: 1px solid var(--border); color: white; border-radius: 6px; font-family: 'Inter', sans-serif; font-size: 0.85rem; outline: none; appearance: none; -webkit-appearance: none;}

.input-row { display: block; width: 100%; margin-bottom: 8px; }
.age-gender-row { display: flex; gap: 10px; width: 100%; }

.error-text { color: var(--red); font-size: 0.75rem; text-align: left; min-height: 12px; }
.divider { margin: 10px 0; color: var(--text-dim); font-size: 0.75rem; }
.google-btn { background: #fff; color: #000; font-weight: 600; padding: 10px; border-radius: 6px; border: none; cursor: pointer; font-size: 0.85rem;}
.auth-btn, .btn { padding: 12px; border-radius: 6px; border: none; font-weight: 600; color: #000; cursor: pointer; font-size: 0.85rem; transition: background 0.2s;}
.buy { background: var(--green); } .sell { background: var(--red); color: white;}

.pwd-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.pwd-toggle-icon { position: absolute; right: 12px; cursor: pointer; font-size: 1.1rem; color: var(--text-dim); user-select: none;}

.trade-header { background: var(--card-bg); padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); z-index: 50; position: relative;}
.brand { font-weight: 700; font-size: 0.9rem; }
.balance { font-size: 0.85rem; color: var(--text-dim); }

.header-right { display: flex; align-items: center; gap: 12px; }
.balance-box { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; display: flex; align-items: center; gap: 8px; }
.notification-icon { position: relative; font-size: 1.3rem; cursor: pointer; }
.notif-badge { position: absolute; top: -2px; right: -4px; background: var(--red); color: white; font-size: 0.55rem; padding: 2px 5px; border-radius: 50%; font-weight: bold; }

.custom-select-wrapper { position: relative; cursor: pointer; user-select: none; }
.full-width { width: 100%; }
.custom-select-trigger { font-family: 'Poppins', sans-serif; font-weight: 600; color: white; display: flex; align-items: center; gap: 5px; }
.custom-select-trigger .arrow { font-size: 0.6rem; color: var(--text-dim); }
.custom-options { position: absolute; top: 110%; right: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 10px rgba(0,0,0,0.6); display: none; flex-direction: column; width: 100%; min-width: 150px; max-height: 250px; overflow-y: auto; z-index: 200; }
.custom-options.open { display: flex; }
.custom-option { padding: 12px 15px; font-size: 0.85rem; font-weight: 600; border-bottom: 1px solid var(--border); transition: 0.2s; color: white; }
.custom-option:hover { background: var(--border); color: var(--accent); }
.price-up { color: var(--green); } .price-down { color: var(--red); }

.main-content { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; padding-bottom: 60px; }
.app-view { display: none; flex-direction: column; height: 100%; }
.active-view { display: flex; }

.chart-container { height: 35vh; min-height: 200px; width: 100%; background: #000; flex-shrink: 0; border-bottom: 1px solid var(--border);}
.order-panel { padding: 12px 15px; background: var(--bg-color); flex: 1; overflow-y: auto; }

@media (min-width: 800px) {
    #view-trade { flex-direction: row; }
    .chart-container { height: 100%; flex: 1; border-right: 1px solid var(--border); border-bottom: none; }
    .order-panel { width: 400px; flex-shrink: 0; height: 100%; overflow-y: auto; }
}

.trade-mode-selector { display: flex; gap: 10px; margin-bottom: 12px; font-size: 0.85rem; color: var(--text-dim); font-weight: 600;}
.section-label { font-size: 0.75rem; color: var(--text-dim); display: block; margin-bottom: 6px; font-weight: 600;}
.action-buttons { display: flex; gap: 8px; }

.live-price-box { border: 1px solid var(--border); background: var(--card-bg); border-radius: 6px; padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.live-price-display { font-size: 1.2rem; font-weight: 700; font-family: 'Poppins', sans-serif; }

.timeframe-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.time-preset-btn { background: var(--card-bg); border: 1px solid var(--border); color: var(--text-dim); padding: 10px 0; border-radius: 4px; font-weight: 600; font-size: 0.8rem; cursor: pointer; }
.time-preset-btn.active { background: rgba(240, 185, 11, 0.15); border-color: var(--accent); color: var(--accent); }

.tag-presets { display: flex; gap: 6px; justify-content: space-between;}
.spot-preset-btn, .odd-presets button, .mpesa-preset { flex: 1; background: var(--card-bg); border: 1px solid var(--border); color: var(--text-dim); padding: 10px 0; border-radius: 4px; font-weight: 600; font-size: 0.8rem; cursor: pointer;}
.spot-preset-btn.active, .odd-presets button.active, .mpesa-preset.active { background: rgba(41, 98, 255, 0.15); border-color: var(--tag-blue); color: var(--tag-blue); }

.tagoption-container { display: flex; flex-direction: column; gap: 10px; }
.tag-ribbon { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; width: 100%; padding-bottom: 4px; }
.tag-digit { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; height: 45px; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: 0.2s; }
.tag-digit b { font-size: 0.9rem; color: white; font-weight: 700; }
.tag-digit span { font-size: 0.5rem; color: var(--text-dim); }
.red-digit span { color: var(--red); } .green-digit span { color: var(--green); }
.live-indicator { background: var(--accent) !important; border-color: var(--accent) !important; transform: scale(1.05); z-index: 10;}
.live-indicator b, .live-indicator span { color: #000 !important; font-weight: 700; }

.tag-stake-box { display: flex; align-items: stretch; gap: 8px; }
.stake-ctrl { background: var(--card-bg); border: none; color: white; width: 45px; border-radius: 6px; font-size: 1.4rem; cursor: pointer;}
.stake-center { flex: 1; background: var(--card-bg); border: 2px solid var(--tag-blue); border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 0; }
.stake-label { font-size: 0.6rem; color: var(--tag-blue); font-weight: 700; letter-spacing: 1px;}
.stake-val-row { display: flex; align-items: center; justify-content: center; gap: 4px; }
.stake-val-row .currency { color: var(--tag-blue); font-weight: 700; font-size: 1rem;}
.stake-val-row input { background: transparent; border: none; color: white; font-size: 1.2rem; width: 60px; text-align: center; outline: none; font-weight: 700; padding: 0;}

.tag-action-row { display: flex; gap: 10px; }
.tag-btn { flex: 1; border: none; border-radius: 8px; padding: 12px; color: white; display: flex; flex-direction: column; cursor: pointer; }
.tag-green { background: #10b981; } .tag-red { background: #ef4444; }
.tag-btn-top { display: flex; justify-content: space-between; align-items: center; width: 100%;}
.tag-btn-top .title { font-size: 1.05rem; font-weight: 700; }
.tag-btn-top .payout { font-size: 0.85rem; font-weight: 600;}

.timer-box { background: var(--card-bg); padding: 10px; border-radius: 6px; border: 1px solid var(--border); text-align: center; margin-top: 10px; }
.timer-title { color: var(--accent); font-size: 0.7rem; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }
.timer-clock { font-size: 1.8rem; margin: 4px 0; color: white; }
.timer-details { font-size: 0.8rem; color: var(--text-dim); }

.bot-panel { margin-top: 15px; padding: 12px; background: rgba(240, 185, 11, 0.05); border: 1px solid rgba(240, 185, 11, 0.2); border-radius: 6px; display: flex; flex-direction: column;}
.bot-header { font-size: 0.8rem; font-weight: 700; color: var(--accent); margin-bottom: 8px; display: flex; justify-content: space-between;}

.bot-tier-selector { display: flex; gap: 8px; margin-bottom: 12px; }
.bot-tier-btn { flex: 1; background: var(--card-bg); border: 1px solid var(--border); color: var(--text-dim); border-radius: 6px; padding: 8px 0; font-size: 0.8rem; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center;}
.bot-tier-btn span { font-size: 0.6rem; font-weight: 500; margin-top: 2px; opacity: 0.8;}
.bot-tier-btn.active { background: rgba(240, 185, 11, 0.15); border-color: var(--accent); color: var(--accent); }

.bot-log-box { background: #000; padding: 10px; border-radius: 4px; font-size: 0.75rem; color: var(--green); height: 140px; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--border); font-family: monospace; display: block; scroll-behavior: smooth;}
.log-item { margin-bottom: 5px; line-height: 1.3; }
.badge { padding: 2px 4px; border-radius: 3px; font-size: 0.55rem; font-weight: 800; margin-right: 4px; display: inline-block; vertical-align: middle; }
.new-badge { background: var(--green); color: #000; }
.old-badge { background: var(--border); color: var(--text-dim); }
.dimmed-text { color: var(--text-dim); }

.wallet-container, .profile-container { padding: 20px; }
.profile-wrapper { max-width: 600px; margin: 0 auto; width: 100%; }

.wallet-card { background: var(--card-bg); padding: 20px; border-radius: 8px; text-align: center; margin-bottom: 20px; border: 1px solid var(--border); }
.wallet-card h3 { margin: 0 0 5px 0; font-size: 0.9rem; color: var(--text-dim); }
.wallet-card h1 { margin: 0; font-size: 2.2rem; color: white; font-weight: 700;}
.deposit-box, .withdraw-box { background: var(--card-bg); padding: 20px; border-radius: 8px; margin-bottom: 15px; border: 1px solid var(--border);}
.deposit-box h3, .withdraw-box h3 { margin-top: 0; font-size: 1.1rem; margin-bottom: 15px;}

.wallet-tabs { display: flex; margin-bottom: 15px; gap: 10px;}
.wallet-tab-btn { flex: 1; background: var(--bg-color); border: 1px solid var(--border); color: var(--text-dim); padding: 10px; border-radius: 6px; font-weight: 600; cursor: pointer; transition: 0.2s;}
.wallet-tab-btn.active { background: rgba(0, 192, 118, 0.1); border-color: var(--green); color: var(--green); }
.wallet-tab-btn.active.wit { background: rgba(207, 48, 74, 0.1); border-color: var(--red); color: var(--red); }

.profile-header { text-align: center; margin-bottom: 25px; position: relative;}
.profile-badges { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }
.status-badge { padding: 4px 10px; border-radius: 12px; font-size: 0.65rem; font-weight: 700; border: 1px solid; }
.badge-red { color: var(--red); border-color: var(--red); background: rgba(207, 48, 74, 0.1); }
.badge-green { color: var(--green); border-color: var(--green); background: rgba(0, 192, 118, 0.1); }
.badge-gold { color: var(--accent); border-color: var(--accent); background: rgba(240, 185, 11, 0.1); }

#profile-pic { width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--accent); margin-bottom: 8px; object-fit: cover;}
#profile-name { margin: 0; font-size: 1.3rem; font-weight: 700;}
#profile-email { margin: 2px 0 0 0; color: var(--text-dim); font-size: 0.8rem; }
.menu-item { width: 100%; text-align: left; padding: 16px; background: var(--card-bg); border: none; border-bottom: 1px solid var(--border); color: white; font-weight: 600; font-size: 0.95rem; cursor: pointer;}
.menu-item:first-child { border-radius: 8px 8px 0 0; }
.menu-item:last-child { border-radius: 0 0 8px 8px; border-bottom: none; }
.logout-text { color: var(--red); }

.btn-back { background: transparent; border: none; color: var(--accent); font-weight: 700; font-size: 0.95rem; cursor: pointer; padding: 0; margin-bottom: 15px; text-align: left;}
.history-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; display: flex; justify-content: space-between; align-items: center;}
.history-card .type { font-weight: 700; font-size: 0.9rem;}
.history-card .date { font-size: 0.7rem; color: var(--text-dim); margin-top: 4px;}
.history-card .amt { font-weight: 700; font-size: 1rem;}
.history-card.win .amt { color: var(--green); }
.history-card.loss .amt { color: var(--red); }

.toggle-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; font-size: 0.9rem; color: var(--text-main); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border); transition: .3s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: var(--green); }
input:checked + .slider:before { transform: translateX(20px); }

.bottom-nav { flex-shrink: 0; width: 100%; background: var(--card-bg); display: flex; border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 100; height: 60px;}
.nav-item { flex: 1; background: none; border: none; padding: 0; color: var(--text-dim); font-size: 0.8rem; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;}
.nav-item.active { color: var(--accent); }

/* --- NEW STICKY HEADER CSS FOR ADMIN --- */
.table-container { max-height: 65vh; overflow-y: auto; position: relative; }
th { position: sticky; top: 0; background: #1e2329; z-index: 10; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }


/* NEW REFERRAL & TRADE UI STYLES */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
.ref-stat-card { background: var(--card-bg); border: 1px solid var(--border); padding: 15px; border-radius: 8px; text-align: left; }
.ref-stat-card span { font-size: 0.75rem; color: var(--dim); display: flex; align-items: center; gap: 5px; margin-bottom: 5px; }
.ref-stat-card h2 { margin: 0; font-size: 1.5rem; color: white; }
.ref-stat-card.accent h2 { color: var(--green); }
.ref-stat-card.gold h2 { color: var(--accent); }
.ref-link-box { background: linear-gradient(135deg, #6b21a8, #3b82f6); border-radius: 10px; padding: 20px; text-align: left; }
.ref-tabs { display: flex; background: var(--card-bg); border-radius: 8px; overflow: hidden; margin-top: 15px; }
.ref-tab { flex: 1; padding: 10px; border: none; background: transparent; color: var(--dim); font-size: 0.8rem; font-weight: bold; cursor: pointer; }
.ref-tab.active { background: #8b5cf6; color: white; }
.trade-limits-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.limit-box { background: var(--bg-color); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; display: flex; flex-direction: column; }
.limit-box span { font-size: 0.65rem; color: var(--accent); font-weight: bold; margin-bottom: 2px; }
.limit-box input { background: transparent; border: none; color: white; font-size: 1rem; font-weight: bold; width: 100%; outline: none; }
