:root {
  --bg: #0c0e12;
  --surface: #151820;
  --surface-2: #1c2029;
  --surface-3: #252a35;
  --border: #2a303c;
  --text: #eef1f6;
  --muted: #8d95a5;
  --faint: #5d6576;
  --accent: #35e08f;
  --accent-ink: #062615;
  --accent-soft: rgba(53, 224, 143, 0.12);
  --danger: #ff5d6c;
  --danger-soft: rgba(255, 93, 108, 0.12);
  --warn: #ffb547;
  --warn-soft: rgba(255, 181, 71, 0.13);
  --info: #62a8ff;
  --info-soft: rgba(98, 168, 255, 0.13);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100svh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.pos { color: var(--accent); }
.neg { color: var(--danger); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(12, 14, 18, 0.86);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(42, 48, 60, 0.6);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -0.01em; font-size: 17px; color: var(--text); text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.brand-mark svg { width: 18px; height: 18px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-weight: 650; font-size: 14px; color: var(--text); text-decoration: none;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); text-decoration: none;
}
.icon-btn { position: relative; }
.icon-btn .badge-dot {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 750; line-height: 17px; text-align: center;
}
.icon-btn.on { color: var(--warn); border-color: rgba(255, 181, 71, 0.45); }
.icon-btn svg { width: 18px; height: 18px; }

main {
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
}

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(16, 18, 24, 0.94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.nav a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); text-decoration: none; font-size: 11px; font-weight: 600;
  transition: color 0.25s var(--ease);
}
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--text); }
.nav a.on::before {
  content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}
.nav a.plus span.plus-bg {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); margin-top: -6px;
  box-shadow: 0 6px 22px rgba(53, 224, 143, 0.28);
}
.nav a.plus span.plus-bg svg { width: 24px; height: 24px; }
.nav .badge-dot {
  position: absolute; top: 9px; left: calc(50% + 6px);
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 750; line-height: 17px; text-align: center;
}

/* ---------- typography / sections ---------- */
h1 { font-size: 24px; letter-spacing: -0.02em; margin: 4px 0 16px; }
h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  margin: 26px 0 10px; font-weight: 700;
}
h2 .count { background: var(--surface-3); color: var(--text); border-radius: 999px; padding: 1px 8px; font-size: 12px; letter-spacing: 0; }
.section-note { color: var(--muted); font-size: 13.5px; margin: -4px 0 12px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
main.anim .card, main.anim .list, main.anim .stats, main.anim .empty { animation: rise 0.45s var(--ease) both; }
main.anim > :nth-child(2) { animation-delay: 0.04s; }
main.anim > :nth-child(3) { animation-delay: 0.08s; }
main.anim > :nth-child(n+4) { animation-delay: 0.12s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.balance-card {
  position: relative; overflow: hidden;
  background: linear-gradient(145deg, #17221d 0%, #151820 55%);
  border-color: rgba(53, 224, 143, 0.22);
  padding: 20px;
}
.balance-card::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(53, 224, 143, 0.18), transparent 70%);
}
.balance-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.balance-big { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0 14px; }
.balance-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13.5px; color: var(--muted); }
.balance-row b { color: var(--text); font-weight: 650; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; text-align: center; }
.stat .v { font-size: 20px; font-weight: 750; }
.stat .l { font-size: 12px; color: var(--muted); }

.empty {
  text-align: center; color: var(--muted); padding: 26px 16px;
  border: 1px dashed var(--border); border-radius: var(--radius); font-size: 14px;
}

/* ---------- bet card ---------- */
.bet { padding: 14px 16px 16px; }
.bet.attention { border-color: rgba(255, 181, 71, 0.5); box-shadow: 0 0 0 1px rgba(255, 181, 71, 0.12) inset; }
.bet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.bet-id { color: var(--faint); font-size: 12.5px; font-weight: 650; margin-right: 8px; }
.bet-time { color: var(--faint); font-size: 12.5px; }
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
  background: var(--surface-3); color: var(--muted);
}
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.active { background: var(--info-soft); color: var(--info); }
.badge.disputed { background: var(--danger-soft); color: var(--danger); }
.badge.resolved { background: var(--accent-soft); color: var(--accent); }
.vs { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.vs .x { color: var(--faint); font-size: 12px; font-weight: 700; }
.vs .me { color: var(--accent); }
.bet-desc { margin: 8px 0 12px; font-size: 15.5px; line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere; }
.stakes { display: flex; gap: 8px; flex-wrap: wrap; }
.stake {
  flex: 1 1 0; min-width: 120px;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px;
}
.stake .who { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stake .amt { font-weight: 750; font-size: 15px; }
.bet-info { margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.bet-info b { color: var(--text); }
.result { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; font-weight: 600; }
.result.win { background: var(--accent-soft); color: var(--accent); }
.result.loss { background: var(--danger-soft); color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .label { width: 100%; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface-2);
  padding: 10px 14px; border-radius: 12px; font-weight: 650; font-size: 14.5px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s;
  text-decoration: none; color: var(--text); min-height: 42px;
}
.btn:active { transform: scale(0.97); }
.btn:hover { border-color: #3a4150; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #4ff0a2; }
.btn.danger { color: var(--danger); border-color: rgba(255, 93, 108, 0.35); background: var(--danger-soft); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.grow { flex: 1 1 0; }
.btn.picked { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 650; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 13px; font-size: 16px; outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 84px; }
.money-input { position: relative; }
.money-input .input { padding-right: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.money-input::after { content: "€"; position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 2px 0 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px;
  padding: 8px 14px; font-weight: 650; font-size: 14px; cursor: pointer;
  transition: all 0.2s var(--ease);
}
.chips.filter { margin-bottom: 14px; }
.auth-note { text-align: center; color: var(--faint); font-size: 13.5px; margin: 14px 0 0; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; word-break: break-all; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.quick { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.quick .chip { padding: 5px 11px; font-size: 13px; }
.summary {
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin: 4px 0 16px;
  display: grid; gap: 4px;
}
.summary .line { display: flex; justify-content: space-between; gap: 10px; }
.form-error { color: var(--danger); font-size: 13.5px; margin: -4px 0 12px; }

/* ---------- segmented ---------- */
.seg { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px; font-weight: 650; font-size: 13.5px; color: var(--muted); cursor: pointer;
  transition: all 0.2s var(--ease);
}
.seg button.on { background: var(--surface-3); color: var(--text); }

/* ---------- lists ---------- */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); }
.li:first-child { border-top: 0; }
.li .main { flex: 1; min-width: 0; }
.li .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .r { text-align: right; flex-shrink: 0; }
.li .r .t { font-variant-numeric: tabular-nums; }
.li.me { background: var(--accent-soft); }
.rank {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-3); font-weight: 750; font-size: 13.5px; color: var(--muted);
}
.rank.r1 { background: #ffcf4a; color: #3b2a00; }
.rank.r2 { background: #cfd6e2; color: #252a33; }
.rank.r3 { background: #d99a63; color: #3a1d06; }
.tx-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-3); color: var(--muted); }
.tx-ico svg { width: 17px; height: 17px; }
.tx-ico.in { background: var(--accent-soft); color: var(--accent); }
.tx-ico.out { background: var(--danger-soft); color: var(--danger); }

/* ---------- admin ---------- */
.user-row { padding: 14px; border-top: 1px solid var(--border); }
.user-row:first-child { border-top: 0; }
.user-row .top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.user-row .name { font-weight: 700; }
.user-row .tag { font-size: 11px; font-weight: 700; color: var(--warn); margin-left: 6px; }
.user-row .tag.off { color: var(--danger); }
.user-row .bal { font-weight: 750; font-variant-numeric: tabular-nums; }
.user-row .sub { font-size: 12.5px; color: var(--muted); }
.user-row .actions { margin-top: 10px; }
.user-row.inactive .name, .user-row.inactive .bal { opacity: 0.5; }
details.card summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: "+"; font-size: 20px; color: var(--muted); line-height: 1; }
details.card[open] summary::after { content: "−"; }
details.card[open] summary { margin-bottom: 14px; }

/* ---------- auth ---------- */
.auth { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
.auth-brand .brand-mark { width: 58px; height: 58px; border-radius: 18px; box-shadow: 0 10px 40px rgba(53, 224, 143, 0.25); }
.auth-brand .brand-mark svg { width: 32px; height: 32px; }
.auth-brand h1 { margin: 0; font-size: 28px; }
.auth-brand p { margin: 0; color: var(--muted); }

/* ---------- toast & modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text);
  padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: calc(100% - 32px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  transition: all 0.35s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255, 93, 108, 0.5); color: #ffd0d5; }
.toast.ok { border-color: rgba(53, 224, 143, 0.45); }

.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(5, 6, 9, 0.66);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.25s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  animation: up 0.4s var(--ease) both;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 0 0 14px; color: var(--muted); }
.modal .actions { margin-top: 6px; }
@media (min-width: 600px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 20px; }
}

/* ---------- wider screens: keep bars aligned with the content column ---------- */
@media (min-width: 700px) {
  .topbar { padding-left: calc((100% - 640px) / 2 + 16px); padding-right: calc((100% - 640px) / 2 + 16px); }
  .nav { padding-left: calc((100% - 640px) / 2); padding-right: calc((100% - 640px) / 2); }
}

.card > p:first-child { margin-top: 0; }
