:root {
  color-scheme: light dark;
  --green: #0f3d2e;
  --green-light: #1a5c46;
  --danger: #b3261e;
  --surface: #ffffff;
  --text: #1a1a1a;
  --border: #d9d9d9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #1e1e1e;
    --text: #f0f0f0;
    --border: #3a3a3a;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--surface);
  color: var(--text);
}
.view[hidden] { display: none; }

.login-card {
  max-width: 22rem;
  margin: 15vh auto 0;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-card h1 { margin: 0 0 0.5rem; font-size: 1.4rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.75rem; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
input, select, textarea {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.btn {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.btn:hover { filter: brightness(0.95); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-light); filter: none; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-icon { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.3rem; }
.topbar-actions { display: flex; gap: 0.6rem; align-items: center; }
.user-email { font-size: 0.85rem; opacity: 0.7; margin-right: 0.5rem; }

main { padding: 1.5rem; }
.games-table { width: 100%; border-collapse: collapse; }
.games-table th, .games-table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.games-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; }
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}
.status-live { background: var(--green); color: #fff; border-color: var(--green); }

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  min-width: min(26rem, 90vw);
  padding: 1.5rem;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog form { display: flex; flex-direction: column; gap: 0.75rem; }
dialog h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.form-row { display: flex; gap: 0.75rem; }
.form-row label { flex: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.5rem; }

.toasts {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}
.toast {
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.2s ease-out;
}
.toast-error { background: var(--danger); }
@keyframes toast-in {
  from { transform: translateY(0.5rem); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --- analytics dashboard --- */
:root {
  --chart-1: #2a78d6;
  --chart-2: #eb6834;
  --chart-3: #1baf7a;
  --ink-muted: #6b6b6b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --chart-1: #3987e5;
    --chart-2: #d95926;
    --chart-3: #199e70;
    --ink-muted: #9a9a9a;
  }
}
.topnav { display: flex; gap: 1rem; align-items: center; }
.topnav a { color: var(--text); text-decoration: none; font-size: 1.05rem; padding: 0.25rem 0; }
.topnav a.active { font-weight: 700; border-bottom: 2px solid var(--green); }

main h2 { font-size: 1.05rem; margin: 1.5rem 0 0.75rem; }
.range-note { font-size: 0.8rem; font-weight: 400; color: var(--ink-muted); margin-left: 0.5rem; }

.tiles { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  min-width: 8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.tile strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.tile span { font-size: 0.8rem; color: var(--ink-muted); }

.chart-grid, .table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.card { border: 1px solid var(--border); border-radius: 10px; padding: 0.9rem 1rem; }
.card h3 { margin: 0 0 0.6rem; font-size: 0.9rem; }

.chart { position: relative; }
.line-chart { width: 100%; height: auto; display: block; }
.line-chart .grid { stroke: var(--border); stroke-width: 1; }
.line-chart .axis { fill: var(--ink-muted); font-size: 10px; }
.line-chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; }
.line-chart .crosshair { stroke: var(--ink-muted); stroke-dasharray: 3 3; }
.chart-tooltip {
  position: absolute;
  background: var(--text);
  color: var(--surface);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th, .data-table td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); }
.data-table td:not(:first-child), .data-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td:first-child { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-note { color: var(--ink-muted); font-size: 0.85rem; }
