:root {
  --bg: #0a0e0c;
  --surface: #151a18;
  --surface-2: #1e2422;
  --border: #262d2a;
  --text: #f1f5f3;
  --muted: #8b968f;
  --accent: #00e5b8;
  --accent-dim: #00b892;
  --positive: #00e5b8;
  --negative: #ef4444;
  --warn: #eab308;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.accent { color: var(--accent); }
.muted { color: var(--muted); }

/* Auth */
.auth-card {
  max-width: 380px;
  margin: 15vh auto 0;
  padding: 2rem 1.5rem;
  text-align: center;
}
.auth-card h1 { font-size: 2rem; margin-bottom: 0.25rem; }
.tagline { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.95rem; }
.auth-card input {
  width: 100%;
  margin-bottom: 0.75rem;
}

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #04120e;
  font-weight: 600;
  padding: 0.7rem;
  font-size: 0.95rem;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-danger {
  background: transparent;
  color: var(--negative);
  border: 1px solid var(--negative);
  padding: 0.5rem 1rem;
  margin-top: 1rem;
  width: 100%;
}

.status-text { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.user-chip { font-size: 0.8rem; color: var(--muted); }

#main {
  padding: 1rem;
  padding-bottom: 5rem;
  max-width: 720px;
  margin: 0 auto;
}

/* Tabbar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  padding: 0.85rem 0;
  font-size: 0.85rem;
  border-radius: 0;
}
.tab.selected { color: var(--accent); font-weight: 600; }

/* Stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
}
.stat-label { color: var(--muted); font-size: 0.78rem; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.35rem; font-weight: 700; }
.stat-value.positive { color: var(--positive); }
.stat-value.negative { color: var(--negative); }

/* Breakdown */
.breakdown-block { margin-top: 1.5rem; }
.breakdown-block h2 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--muted); }
.breakdown-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 1fr 0.9fr 0.7fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}
.bd-name { font-weight: 600; }
.bd-count, .bd-staked { color: var(--muted); font-size: 0.78rem; }
.bd-profit, .bd-roi { text-align: right; font-weight: 600; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* Form */
.bet-form { display: flex; flex-direction: column; gap: 0.9rem; max-width: 480px; }
.bet-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.optional { font-weight: 400; font-size: 0.75rem; }

/* Filters */
.filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters select { flex: 1; min-width: 120px; }

/* History */
.history-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.history-row:hover { border-color: var(--accent-dim); }
.hr-main { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.hr-event { font-weight: 600; }
.hr-sub { display: flex; gap: 0.6rem; flex-wrap: wrap; color: var(--muted); font-size: 0.78rem; }
.hr-profit { text-align: right; font-weight: 700; margin-top: 0.3rem; }

.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-pending { background: #2a2f1c; color: var(--warn); }
.badge-win { background: #0d2b24; color: var(--positive); }
.badge-loss { background: #2b1414; color: var(--negative); }
.badge-push, .badge-void { background: var(--surface-2); color: var(--muted); }
.badge-cashout { background: #1c2733; color: #60a5fa; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 1.25rem;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h3 { margin-top: 0; }

.grade-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 1rem 0; }
.btn-grade {
  flex: 1;
  min-width: 80px;
  padding: 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.btn-grade.win { border-color: var(--positive); color: var(--positive); }
.btn-grade.loss { border-color: var(--negative); color: var(--negative); }

/* Support link (anchor styled like a button) */
a.btn-ghost { text-decoration: none; }

/* Upgrade card */
.upgrade-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--accent-dim);
  border-radius: 12px;
  padding: 1.25rem;
  margin-top: 0.5rem;
  text-align: center;
}
.upgrade-card h3 { margin: 0 0 0.4rem; color: var(--accent); }
.upgrade-card p { color: var(--muted); font-size: 0.88rem; margin-bottom: 1rem; }
.upgrade-card .btn-primary { max-width: 260px; margin: 0 auto; }

/* Closing-line editor inside the bet modal */
.clv-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
}
.clv-row input {
  flex: 1;
}
.clv-row button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
}
.clv-result { font-size: 0.85rem; font-weight: 600; margin: 0.25rem 0 0.75rem; }
