:root {
  --bg: #0a0b0d; --card: #131518; --card-2: #1b1e23; --line: #262a31; --text: #f2f3f0; --muted: #8b9098;
  --accent: #c8f031; --accent-2: #c8f031; --on-accent: #0a0b0d; --ok: #4ade80; --danger: #f87171;
  --c1: rgba(255, 255, 255, .13); --c2: #38bdf8; --c3: #c8f031;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 Manrope, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
a { color: var(--accent-2); text-decoration: none; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.03em; font-weight: 800; }
h2 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--muted); font-weight: 400; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }

/* top bar + bottom tabs (mobile first) */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: rgba(10, 11, 13, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.wordmark { font-weight: 800; font-size: 19px; letter-spacing: -.04em; color: var(--text); line-height: 1; }
.wordmark span { color: var(--accent); }
.wordmark.lg { font-size: 30px; }
.me { display: flex; align-items: center; gap: 4px; }
.me .who { font-size: 13px; color: var(--muted); }
.me form { margin: 0; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; padding: 6px 8px calc(6px + var(--safe-b));
  background: rgba(19, 21, 24, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabbar a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-size: 11px; font-weight: 500; border-radius: 12px; }
.tabbar a.on { color: var(--text); }
.tabbar a.on svg { color: var(--accent-2); }
main { padding: 16px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

header.page { margin: 4px 0 16px; }
header.page p { margin: 2px 0 0; font-size: 14px; }
.back { display: inline-block; color: var(--muted); padding: 6px 0; margin-bottom: 4px; font-size: 14px; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); font-weight: 600; flex: none; }
.person { display: flex; align-items: center; gap: 12px; }
.person.lg .avatar { width: 52px; height: 52px; font-size: 20px; background: var(--accent); color: var(--on-accent); border: 0; font-weight: 800; }
.person.lg p { margin: 2px 0 0; font-size: 13px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.empty { color: var(--muted); text-align: center; padding: 20px 8px; margin: 0; }
.collapsible > summary { list-style: none; cursor: pointer; padding: 2px 0; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary h2 { color: var(--accent-2); }
.collapsible[open] > summary { margin-bottom: 14px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 2px; min-width: 0; }
.kpi span { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi b { font-size: 22px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.kpi.accent span, .kpi.accent small { color: rgba(10, 11, 13, .65); }

/* chart */
.chart { position: relative; height: 220px; }
.legend { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-left: 6px; }
.legend .c1 { background: var(--c1); } .legend .c2 { background: var(--c2); } .legend .c3 { background: var(--c3); }

/* forms: 16px inputs stop iOS zoom */
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
input, select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px; font: inherit; font-size: 16px; min-width: 0; outline: none; -webkit-appearance: none; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, select:focus { border-color: var(--accent); }
button { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 10px; padding: 12px 18px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; min-height: 44px; }
button:active { transform: scale(.98); }
button.wide { width: 100%; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.danger { background: var(--danger); color: #fff; }
button.danger.ghost { background: transparent; color: var(--danger); border-color: rgba(248, 113, 113, .45); }
button.small { min-height: 36px; padding: 6px 14px; font-size: 13px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); color: var(--text); flex: none; }
button.small.done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.link { background: none; padding: 0; min-height: 0; color: var(--muted); font-weight: 500; font-size: 13px; }
button.link.danger { color: var(--danger); }
button.icon { background: none; padding: 8px; min-height: 0; color: var(--muted); }
.stack { display: grid; gap: 12px; }
.stack form { margin: 0; }

.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; font-size: 14px; }
.flash.ok { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .5); }
.flash.error { background: rgba(244, 63, 94, .12); border: 1px solid rgba(244, 63, 94, .5); }

/* lists */
.list { display: grid; gap: 10px; }
.item { display: grid; gap: 10px; padding: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; color: var(--text); }
.item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-top form { margin: 0; }
.item-title { display: grid; min-width: 0; }
.item-title span { font-size: 13px; }
.person-row { grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.person-row:active { background: var(--card-2); }
.copy-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.copy-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
code { background: var(--card); border: 1px solid var(--line); padding: 8px 10px; border-radius: 10px; font-size: 12px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.stats > div { background: var(--card); padding: 8px 10px; display: grid; }
.stats span { color: var(--muted); font-size: 11px; font-weight: 500; }
.stats b { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* activity feed */
.feed { display: grid; }
.event { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--muted); }
.dot.registration { background: var(--c2); box-shadow: 0 0 0 4px rgba(56, 189, 248, .15); }
.dot.ftd { background: var(--c3); box-shadow: 0 0 0 4px rgba(200, 240, 49, .15); }
.dot.deposit { background: #fbbf24; box-shadow: 0 0 0 4px rgba(251, 191, 36, .15); }
.event-main { min-width: 0; }
.event-line { display: flex; justify-content: space-between; gap: 10px; }
.event-line b:first-child { text-transform: capitalize; }
.amt { color: var(--accent); font-variant-numeric: tabular-nums; }
.event-meta { font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
details.raw { margin-top: 6px; font-size: 12px; }
details.raw summary { color: var(--muted); cursor: pointer; }
details.raw code { display: block; margin-top: 6px; white-space: pre-wrap; word-break: break-all; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--card-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.registration { color: #7dd3fc; border-color: rgba(56, 189, 248, .4); background: rgba(56, 189, 248, .1); text-transform: capitalize; }
.tag.ftd { color: var(--accent); border-color: rgba(200, 240, 49, .4); background: rgba(200, 240, 49, .08); }
.tag.deposit { color: #fcd34d; border-color: rgba(251, 191, 36, .4); background: rgba(251, 191, 36, .08); text-transform: capitalize; }
.tag.ok { color: #86efac; border-color: rgba(34, 197, 94, .4); }
.tag.off { color: #fda4af; border-color: rgba(244, 63, 94, .4); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* campaigns */
.campaign { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; background: var(--bg); }
.campaign summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; cursor: pointer; list-style: none; }
.campaign summary::-webkit-details-marker { display: none; }
.chev { font-size: 22px; color: var(--muted); transition: transform .15s; }
.campaign[open] .chev { transform: rotate(90deg); }
.campaign-body { padding: 0 14px 14px; display: grid; gap: 12px; }
.campaign-body p { margin: 0; font-size: 13px; }
.campaign-body form { margin: 0; }
.field { display: grid; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 600; }

/* period + sort chips */
.periods { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.periods::-webkit-scrollbar { display: none; }
.periods a { flex: none; padding: 8px 14px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; }
.periods a.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.filters { display: grid; gap: 8px; margin-bottom: 10px; }

.notice { display: block; color: var(--text); font-size: 14px; }
.notice b { color: var(--accent); margin-right: 4px; }
.kpi.wide { grid-column: 1 / -1; }
.kpi.earn { border-color: rgba(200, 240, 49, .45); }
.kpi.earn b { color: var(--accent); font-size: 26px; }
.neg { color: var(--danger) !important; }
.pos { color: var(--accent); }

/* ranking */
.rank-row { grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.rank-row.dim { opacity: .7; }
.place { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--card-2); font-weight: 800; font-size: 13px; color: var(--muted); }
.place.p1 { background: var(--accent); color: var(--on-accent); }
.place.p2 { background: #e5e7eb; color: var(--bg); }
.place.p3 { background: #d97706; color: var(--bg); }
.rank-val { display: grid; justify-items: end; }
.rank-val b { font-size: 16px; font-variant-numeric: tabular-nums; }
.rank-val span { font-size: 11px; }

/* players */
.player .stats b { font-size: 14px; }
.player-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.progress { position: relative; height: 22px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.progress i { position: absolute; inset: 0 auto 0 0; background: rgba(200, 240, 49, .22); }
.progress span { position: relative; display: block; padding: 0 8px; font-size: 11px; line-height: 22px; color: var(--muted); }
.vip { flex: none; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--card-2); border: 1px solid var(--line); color: var(--muted); }
.vip.bronze { color: #f59e0b; border-color: rgba(245, 158, 11, .45); }
.vip.silver { color: #e5e7eb; border-color: rgba(229, 231, 235, .45); }
.vip.gold { color: #facc15; border-color: rgba(250, 204, 21, .5); }
.vip.platinum, .vip[class*="platinum"] { color: #67e8f9; border-color: rgba(103, 232, 249, .45); }
.vip.diamond, .vip.obsidian, .vip.opal { color: #c4b5fd; border-color: rgba(196, 181, 253, .5); }

/* sync */
.steps ol { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 14px; }
.steps a { color: var(--accent); }
.drop { display: grid; justify-items: center; gap: 4px; padding: 26px 16px; border: 1.5px dashed var(--line); border-radius: 12px; text-align: center; cursor: pointer; color: var(--text); }
.drop input { display: none; }
.drop b { font-size: 16px; color: var(--accent); }
.sync-row { gap: 2px; }
.dot.err { background: var(--danger); }

/* login */
body.auth main { max-width: 440px; min-height: 100vh; min-height: 100dvh; padding: calc(28px + env(safe-area-inset-top, 0px)) 24px calc(24px + var(--safe-b)); }
body.auth main { display: flex; flex-direction: column; }
.login { flex: 1; display: flex; flex-direction: column; }
.login-tag { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.login-form { margin-top: auto; display: grid; gap: 16px; padding-bottom: 8px; }
.login-form h1 { font-size: 34px; line-height: 1.05; margin-bottom: 8px; padding-bottom: 16px; border-bottom: 2px solid var(--accent); width: fit-content; }
.login-foot { margin: 24px 0 0; color: var(--muted); font-size: 13px; }
body.auth .flash { position: absolute; left: 24px; right: 24px; top: calc(80px + env(safe-area-inset-top, 0px)); max-width: 392px; }

/* larger screens */
@media (min-width: 760px) {
  main { padding-top: 24px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .chart { height: 280px; }
  .stats { grid-template-columns: repeat(6, 1fr); }
}
