:root {
  --bg: #0e1117;
  --bg-card: #161b26;
  --bg-hover: #1c2333;
  --border: #262d3d;
  --text: #e6e9f0;
  --text-subtle: #8b93a7;
  --accent: #4ade80;
  --accent-dim: rgba(74, 222, 128, 0.15);
  --red: #f87171;
  --amber: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 1.5rem 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 0.25rem 0; }
h3 { font-size: 1rem; margin: 0.75rem 0 0.5rem; color: var(--text); }
h4 { font-size: 0.85rem; margin: 0.75rem 0 0.25rem; color: var(--text-subtle); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---- layout ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.topbar nav { display: flex; gap: 0.25rem; flex: 1; }
.topbar nav a {
  color: var(--text-subtle);
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-weight: 500;
}
.topbar nav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--bg-hover); }

.refresh-form button {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.4rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
.refresh-form button:hover { background: var(--accent); color: #08110b; }
.refresh-form button:disabled {
  opacity: 0.6;
  cursor: wait;
}

main { max-width: 1440px; margin: 0 auto; padding: 0.5rem 1.5rem 3rem; }

footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  color: var(--text-subtle);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ---- components ---- */

.subtle { color: var(--text-subtle); }
.small { font-size: 0.8rem; }
.pos { color: var(--accent); }
.neg { color: var(--red); }

.banner {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}
.banner.info { background: rgba(96, 165, 250, 0.12); border: 1px solid #3b82f6; }
.banner.warn { background: rgba(251, 191, 36, 0.1); border: 1px solid var(--amber); }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--text-subtle); font-size: 0.82rem; margin-top: 0.15rem; }

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1rem 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.data-table tbody tr:last-child td:first-child { border-bottom-left-radius: 12px; }
.data-table tbody tr:last-child td:last-child { border-bottom-right-radius: 12px; }
.data-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.data-table th .sort-link {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
}
.data-table th .sort-link:hover,
.data-table th .sort-link.is-sorted {
  color: var(--accent);
}
.data-table th .sort-ind {
  font-size: 0.65rem;
  opacity: 0.9;
}
.data-table td { padding: 0.55rem 0.85rem; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table.compact td { padding: 0.35rem 0.6rem; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.bar-cell { width: 35%; }
.bar {
  height: 8px;
  background: linear-gradient(90deg, var(--accent), #22c55e);
  border-radius: 4px;
  min-width: 2px;
}

.edge-badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.1rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}

.flag-badge {
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
  padding: 0.05rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-left: 0.4rem;
}

.empty-state {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  color: var(--text-subtle);
  margin: 1.5rem 0;
}

/* ---- match page ---- */

.match-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1.5rem 0;
  text-align: center;
}
.team-logo { width: 48px; height: 48px; object-fit: contain; }
.match-info .kickoff { font-weight: 600; }
.match-info .score { font-size: 1.4rem; font-weight: 700; margin-top: 0.25rem; }

.form-string { display: flex; gap: 3px; justify-content: center; margin-top: 0.35rem; }
.form-string span {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  font-size: 0.7rem; font-weight: 700;
}
.form-W { background: var(--accent-dim); color: var(--accent); }
.form-D { background: rgba(139, 147, 167, 0.2); color: var(--text-subtle); }
.form-L { background: rgba(248, 113, 113, 0.15); color: var(--red); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.card > h3:first-child { margin-top: 0; }

.plain-list { list-style: none; padding: 0; margin: 0.25rem 0; }
.plain-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: none; }

.lineup-list { font-size: 0.85rem; color: var(--text-subtle); }

.status-won { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; }
.status-lost { color: var(--red); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; }
.status-void { color: var(--text-subtle); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; }

/* ---- login ---- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: 320px;
}
.login-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-button {
  width: 100%;
  padding: 0.6rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.login-button:hover { background: var(--accent); color: #08110b; }

.logout-link {
  color: var(--text-subtle);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

/* ---- placed bets ---- */

.placed-row { background: rgba(74, 222, 128, 0.04); }

.mybet-cell { white-space: nowrap; }

.place-form { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.mini-input {
  width: 58px;
  padding: 0.25rem 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.82rem;
  text-align: right;
}
.mini-odds { width: 64px; text-align: center; }
.mini-input:focus { outline: none; border-color: var(--accent); }
.table-wrap { overflow-x: auto; }
.odds-edit-cell { white-space: nowrap; vertical-align: middle; }
.odds-form { display: inline-flex; gap: 6px; align-items: center; }
.live-odds-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}
.update-button {
  padding: 0.28rem 0.7rem;
  background: var(--amber);
  color: #1a1403;
  border: none;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.update-button:hover { filter: brightness(1.08); }
.place-button {
  padding: 0.25rem 0.6rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.skip-button {
  padding: 0.25rem 0.55rem;
  background: transparent;
  color: var(--text-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.skip-button:hover { color: var(--amber); border-color: var(--amber); }

.placed-badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
}
.inline-form { display: inline; }
.link-button {
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0 0.2rem;
}
.link-button:hover { color: var(--red); }

.league-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 0.25rem;
}
.league-chip {
  color: var(--text-subtle);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}
.league-chip:hover {
  color: var(--text);
  border-color: var(--text-subtle);
  text-decoration: none;
}
.league-chip.active {
  color: #08110b;
  background: var(--accent);
  border-color: var(--accent);
}
.model-badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--bg-hover);
  color: var(--text);
}
.model-badge.likely {
  display: inline-block;
  background: rgba(74, 222, 128, 0.18);
  color: var(--accent);
  padding: 0.12rem 0.55rem;
  border-radius: 6px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.edge-badge.edge-bad {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}
.xi-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.18);
  color: var(--amber);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
.faded-table { opacity: 0.85; }
.status-awaiting {
  display: inline-block;
  margin-left: 6px;
  color: var(--amber);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.league-tag {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-subtle);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.05rem 0.4rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- settings ---- */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}
.form-input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}
.form-input:focus { outline: none; border-color: var(--accent); }
select.form-input { appearance: auto; }
.field-help {
  color: var(--text-subtle);
  font-size: 0.78rem;
  margin: 0.3rem 0 0;
  line-height: 1.4;
}
.save-button {
  width: auto;
  padding: 0.6rem 2rem;
  margin-bottom: 1rem;
}

/* ---- tooltips ---- */

.tip {
  border-bottom: 1px dotted var(--text-subtle);
  cursor: help;
  position: relative;
}
.tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: #0a0d14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  text-align: left;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
/* right-anchored variant for columns near the table's right edge */
.tip.tip-end:hover::after {
  left: auto;
  right: 0;
}
