/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg:       #0f1117;
  --c-surface:  #1a1d27;
  --c-surface2: #22263a;
  --c-border:   #2e3352;
  --c-accent:   #4f7cff;
  --c-accent2:  #7c5cfc;
  --c-success:  #22c55e;
  --c-warn:     #f59e0b;
  --c-danger:   #ef4444;
  --c-text:     #e8eaf6;
  --c-muted:    #7b82a8;
  --radius:     10px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
  --trans:      .18s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.navbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--c-text);
  display: flex; align-items: center; gap: .5rem;
}
.navbar .brand span { color: var(--c-accent); }
.nav-links { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav-links a, .nav-links button {
  background: none; border: none; cursor: pointer;
  color: var(--c-muted); font-size: .9rem; padding: .4rem .75rem;
  border-radius: 6px; transition: background var(--trans), color var(--trans);
}
.nav-links a:hover, .nav-links button:hover,
.nav-links a.active, .nav-links button.active {
  background: var(--c-surface2); color: var(--c-text); text-decoration: none;
}
.nav-user { margin-left: auto; font-size: .85rem; color: var(--c-muted);
  display: flex; align-items: center; gap: .75rem; }
.nav-user strong { color: var(--c-text); }

.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1.25rem; }
.card-title {
  font-size: 1rem; font-weight: 600; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: 7px; font-size: .9rem;
  font-weight: 500; cursor: pointer; border: none; transition: all var(--trans);
  line-height: 1.4;
}
.btn-primary { background: var(--c-accent); color: #fff; }
.btn-primary:hover { background: #3a69f0; }
.btn-secondary { background: var(--c-surface2); color: var(--c-text); border: 1px solid var(--c-border); }
.btn-secondary:hover { background: var(--c-border); }
.btn-success { background: var(--c-success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-icon { padding: .4rem; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; color: var(--c-muted); margin-bottom: .35rem; }
input, select, textarea {
  width: 100%; background: var(--c-surface2);
  border: 1px solid var(--c-border); border-radius: 7px;
  color: var(--c-text); padding: .55rem .85rem; font-size: .95rem;
  transition: border-color var(--trans);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c-accent);
}
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  background: var(--c-surface2); color: var(--c-muted);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--c-border); transition: background var(--trans); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--c-surface2); }
td { padding: .65rem .9rem; vertical-align: middle; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 20px;
  font-size: .75rem; font-weight: 600; line-height: 1;
}
.badge-blue    { background: rgba(79,124,255,.2); color: var(--c-accent); }
.badge-green   { background: rgba(34,197,94,.2);  color: var(--c-success); }
.badge-yellow  { background: rgba(245,158,11,.2); color: var(--c-warn); }
.badge-red     { background: rgba(239,68,68,.2);  color: var(--c-danger); }
.badge-purple  { background: rgba(124,92,252,.2); color: var(--c-accent2); }
.badge-gray    { background: rgba(123,130,168,.15); color: var(--c-muted); }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: 8px; font-size: .9rem;
  margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem;
}
.alert-error   { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.35);  color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.15);  border: 1px solid rgba(34,197,94,.35);  color: #86efac; }
.alert-info    { background: rgba(79,124,255,.15); border: 1px solid rgba(79,124,255,.35); color: #93c5fd; }

/* ── Match card ──────────────────────────────────────────────────────────── */
.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.match-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  transition: border-color var(--trans), transform var(--trans);
}
.match-card:hover { border-color: var(--c-accent); transform: translateY(-1px); }
.match-card.locked { opacity: .75; }
.match-card.finished { border-left: 3px solid var(--c-success); }
.match-card.live     { border-left: 3px solid var(--c-warn); }

.match-teams {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; font-size: 1rem; font-weight: 600; margin-bottom: .75rem;
}
.match-teams .team { flex: 1; }
.match-teams .team:last-child { text-align: right; }
.match-score {
  display: flex; align-items: center; gap: .4rem;
  font-size: 1.3rem; font-weight: 700; color: var(--c-accent);
  min-width: 60px; justify-content: center;
}
.match-meta { font-size: .78rem; color: var(--c-muted); margin-bottom: .75rem; }

.prediction-row {
  display: flex; align-items: center; gap: .5rem; margin-top: .75rem;
}
.prediction-row .score-input {
  width: 48px; text-align: center; padding: .4rem;
}
.prediction-row .sep { color: var(--c-muted); font-weight: 700; }

.pts-3 { color: var(--c-success); font-weight: 700; }
.pts-1 { color: var(--c-warn); font-weight: 700; }
.pts-0 { color: var(--c-danger); }

/* ── Phase tabs ─────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.tab-btn {
  background: var(--c-surface); border: 1px solid var(--c-border);
  color: var(--c-muted); padding: .45rem 1rem; border-radius: 20px;
  font-size: .85rem; cursor: pointer; transition: all var(--trans);
}
.tab-btn:hover { border-color: var(--c-accent); color: var(--c-text); }
.tab-btn.active { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }

/* ── Ranking ─────────────────────────────────────────────────────────────── */
.rank-1 td:first-child { color: #fbbf24; font-weight: 700; }
.rank-2 td:first-child { color: #94a3b8; font-weight: 700; }
.rank-3 td:first-child { color: #cd7c3a; font-weight: 700; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 1.75rem; width: 100%;
  max-width: 480px; box-shadow: var(--shadow);
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.25rem; }

/* ── Auth page ───────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--c-bg); padding: 1rem;
}
.auth-box {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center; margin-bottom: 2rem;
  font-size: 1.5rem; font-weight: 800; letter-spacing: .02em;
}
.auth-logo span { color: var(--c-accent); }
.auth-tabs { display: flex; gap: .5rem; margin-bottom: 1.75rem; }
.auth-tab {
  flex: 1; text-align: center; padding: .5rem;
  border-bottom: 2px solid transparent; cursor: pointer;
  color: var(--c-muted); font-size: .9rem; transition: all var(--trans);
}
.auth-tab.active { border-color: var(--c-accent); color: var(--c-text); font-weight: 600; }

/* ── Page titles ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: .9rem; color: var(--c-muted); margin-top: .2rem; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--c-border);
  border-top-color: var(--c-accent); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { text-align: center; padding: 3rem 0; color: var(--c-muted); }

/* ── Print ──────────────────────────────────────────────────────────────── */
@media print {
  .navbar, .btn, .tabs, .prediction-row { display: none !important; }
  body { background: #fff; color: #111; }
  .card { border: 1px solid #ccc; box-shadow: none; }
  .match-card { break-inside: avoid; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .navbar { padding: .6rem 1rem; }
  .container { padding: 1.25rem .85rem; }
  .match-grid { grid-template-columns: 1fr; }
  .nav-links { gap: .1rem; }
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem; z-index: 999;
}
.toast {
  background: var(--c-surface); border: 1px solid var(--c-border);
  padding: .75rem 1.1rem; border-radius: 8px; font-size: .88rem;
  box-shadow: var(--shadow); animation: toastIn .2s ease;
  display: flex; align-items: center; gap: .5rem; max-width: 320px;
}
.toast.success { border-left: 3px solid var(--c-success); }
.toast.error   { border-left: 3px solid var(--c-danger); }
.toast.info    { border-left: 3px solid var(--c-accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; } }

/* ── CSV sample ──────────────────────────────────────────────────────────── */
.code-block {
  background: var(--c-surface2); border: 1px solid var(--c-border);
  border-radius: 7px; padding: .85rem 1rem; font-family: monospace;
  font-size: .78rem; white-space: pre; overflow-x: auto; color: var(--c-muted);
}

/* ── Score result display ────────────────────────────────────────────────── */
.result-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .85rem; font-weight: 600;
}
