* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0a0a0f;
    --card: #141420;
    --card-border: #1e1e32;
    --accent: #6366f1;
    --accent-dim: rgba(99,102,241,0.15);
    --green: #10b981;
    --green-dim: rgba(16,185,129,0.15);
    --red: #ef4444;
    --red-dim: rgba(239,68,68,0.15);
    --orange: #f59e0b;
    --orange-dim: rgba(245,158,11,0.15);
    --text: #f1f1f4;
    --text-dim: #6b6b8a;
    --radius: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
    background: var(--bg); color: var(--text);
    min-height: 100vh; overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 1000; transition: opacity 0.3s; }
.loading.hidden { opacity: 0; pointer-events: none; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--card-border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page { display: none; padding: 16px 16px 90px; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Nav */
.nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--card-border); display: flex; justify-content: space-around; padding: 6px 0 max(10px, env(safe-area-inset-bottom)); z-index: 100; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-dim); font-size: 9px; cursor: pointer; padding: 5px 8px; border-radius: 10px; transition: all 0.2s; }
.nav-item i { width: 18px; height: 18px; }
.nav-item.active { color: var(--accent); }

/* Header */
.page-header { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.page-header h1 { font-size: 20px; font-weight: 700; flex: 1; }
.badge { font-size: 11px; background: var(--accent-dim); color: var(--accent); padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.back-btn { background: var(--card); border: 1px solid var(--card-border); color: var(--text); width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.back-btn i { width: 16px; height: 16px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card-title { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.card-title i { width: 14px; height: 14px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat-box { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat-box .value { font-size: 18px; font-weight: 700; margin-bottom: 3px; color: var(--green); }
.stat-box .value.red { color: var(--red); }
.stat-box .value.accent { color: var(--accent); }
.stat-box .value.orange { color: var(--orange); }
.stat-box .label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.3px; }

/* Chart */
.chart-box { position: relative; height: 160px; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { padding: 6px 14px; border-radius: 8px; font-size: 11px; font-weight: 600; background: var(--card-border); color: var(--text-dim); cursor: pointer; transition: all 0.2s; }
.tab.active { background: var(--accent); color: #fff; }

/* Leaderboard */
.leader-item { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--card-border); cursor: pointer; }
.leader-item:last-child { border-bottom: none; }
.leader-rank { width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; margin-right: 10px; background: var(--card-border); color: var(--text-dim); flex-shrink: 0; }
.leader-rank.r1 { background: linear-gradient(135deg, #ffd700, #ffaa00); color: #000; }
.leader-rank.r2 { background: linear-gradient(135deg, #c0c0c0, #a0a0a0); color: #000; }
.leader-rank.r3 { background: linear-gradient(135deg, #cd7f32, #a06020); color: #fff; }
.leader-info { flex: 1; min-width: 0; }
.leader-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader-sub { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.leader-amount { font-weight: 700; font-size: 13px; color: var(--green); flex-shrink: 0; }

/* Profile */
.profile-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 18px; text-align: center; margin-bottom: 12px; }
.profile-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--accent-dim); display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; }
.profile-avatar i { width: 24px; height: 24px; color: var(--accent); }
.profile-name { font-size: 16px; font-weight: 700; }
.profile-role { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Poves */
.poves-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--card-border); }
.poves-item:last-child { border-bottom: none; }
.poves-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--card-border); flex-shrink: 0; }
.poves-info { flex: 1; min-width: 0; }
.poves-caption { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poves-date { font-size: 10px; color: var(--text-dim); margin-top: 1px; }
.poves-amount { font-weight: 700; font-size: 13px; color: var(--green); flex-shrink: 0; }

/* Detail actions */
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-actions button { display: flex; align-items: center; gap: 4px; padding: 7px 12px; border-radius: 8px; font-size: 11px; font-weight: 600; background: var(--card); border: 1px solid var(--card-border); color: var(--text); cursor: pointer; }
.detail-actions button:active { transform: scale(0.95); }
.detail-actions button i { width: 13px; height: 13px; }

/* Accounting grid */
.acc-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.acc-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--card-border); color: var(--text); cursor: pointer; font-size: 11px; font-weight: 600; transition: all 0.15s; }
.acc-btn:active { transform: scale(0.95); background: var(--accent-dim); }
.acc-btn i { width: 20px; height: 20px; color: var(--accent); }

/* Transactions */
.tx-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--card-border); }
.tx-item:last-child { border-bottom: none; }
.tx-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tx-icon i { width: 14px; height: 14px; }
.tx-icon.green { background: var(--green-dim); color: var(--green); }
.tx-icon.red { background: var(--red-dim); color: var(--red); }
.tx-icon.accent { background: var(--accent-dim); color: var(--accent); }
.tx-icon.orange { background: var(--orange-dim); color: var(--orange); }
.tx-info { flex: 1; min-width: 0; }
.tx-desc { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: 10px; color: var(--text-dim); }
.tx-amount { font-weight: 700; font-size: 12px; flex-shrink: 0; }
.tx-amount.pos { color: var(--green); }
.tx-amount.neg { color: var(--red); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; backdrop-filter: blur(4px); }
.modal.active { display: flex; }
.modal-form { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 320px; }
.modal-form h3 { font-size: 15px; margin-bottom: 14px; }
.modal-form select, .modal-form input { width: 100%; padding: 10px 12px; margin-bottom: 8px; border-radius: 8px; border: 1px solid var(--card-border); background: var(--bg); color: var(--text); font-size: 13px; outline: none; }
.modal-form select:focus, .modal-form input:focus { border-color: var(--accent); }
.modal-form button { width: 100%; padding: 11px; border-radius: 8px; border: none; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; margin-top: 4px; }
.modal-form button:active { opacity: 0.8; }
.modal-form button.cancel { background: transparent; border: 1px solid var(--card-border); color: var(--text-dim); margin-top: 6px; }

/* Admin visibility */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: block !important; }
body.is-admin .admin-only.page { display: none !important; }
body.is-admin .admin-only.page.active { display: block !important; }
body.is-admin .nav .admin-only { display: flex !important; }

.empty-state { text-align: center; padding: 24px; color: var(--text-dim); font-size: 13px; }
