:root {
  --brand: #f9401c;
  --brand-light: rgba(249,64,28,0.08);
  --brand-border: rgba(249,64,28,0.2);
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-alt: #fafaf9;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --text-secondary: #44403c;
  --text-muted: #78716c;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 6px;
  --radius-lg: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* -- Navigation ------------------------------------------------- */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
}
nav .nav-left {
  display: flex;
  align-items: center;
  gap: 24px;
}
nav .logo {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
nav .logo:hover { text-decoration: none; }
nav .logo-mark {
  width: 6px;
  height: 18px;
  background: var(--brand);
  border-radius: 2px;
}
nav .nav-links { display: flex; gap: 4px; font-size: 13px; }
nav .nav-links a {
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
nav .nav-links a:hover {
  color: var(--text);
  background: var(--surface-alt);
  text-decoration: none;
}
nav .nav-links a.active {
  color: var(--text);
  background: var(--surface-alt);
  font-weight: 500;
}

/* -- Main ------------------------------------------------------- */
main { padding: 28px 0 40px; }

/* -- Typography ------------------------------------------------- */
h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.4px; line-height: 1.3; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 8px; letter-spacing: -0.2px; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.page-header { margin-bottom: 24px; }
.page-header .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

/* -- Cards ------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.card-flush { padding: 0; overflow: hidden; }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-body { padding: 20px; }

/* -- Badges ----------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-active, .badge-live { background: rgba(22,163,74,0.1); color: var(--success); }
.badge-completed { background: rgba(120,113,108,0.1); color: var(--text-muted); }
.badge-upcoming { background: rgba(217,119,6,0.1); color: var(--warning); }
.badge-connected { background: rgba(22,163,74,0.1); color: var(--success); }
.badge-disconnected { background: rgba(120,113,108,0.1); color: var(--text-muted); }
.badge-error { background: rgba(220,38,38,0.1); color: var(--danger); }
.badge-in-progress { background: rgba(217,119,6,0.1); color: var(--warning); }
.badge-finalized { background: rgba(22,163,74,0.1); color: var(--success); }
.badge-forecast { background: var(--brand-light); color: var(--brand); }

/* -- Tables ----------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.4px;
  background: var(--surface-alt);
}
td { font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }

/* -- Buttons ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #e03818; }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 7px 10px; }
.btn-ghost:hover { color: var(--text); background: var(--surface-alt); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* -- Forms ------------------------------------------------------ */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}
.form-check input[type="checkbox"] { width: auto; accent-color: var(--brand); }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* -- Alerts ----------------------------------------------------- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-error { background: rgba(220,38,38,0.06); color: var(--danger); border: 1px solid rgba(220,38,38,0.15); }
.alert-success { background: rgba(22,163,74,0.06); color: var(--success); border: 1px solid rgba(22,163,74,0.15); }

/* -- Utilities -------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 16px; }

/* -- Scoring-specific ------------------------------------------- */
.rank-cell { font-weight: 700; color: var(--text-muted); width: 40px; font-variant-numeric: tabular-nums; }
.score-cell { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.team-logo { width: 24px; height: 24px; object-fit: contain; margin-right: 8px; vertical-align: middle; flex-shrink: 0; }
.team-name-cell { display: flex; align-items: center; gap: 8px; }
.inline-form { display: inline; }

/* -- Federation icon -------------------------------------------- */
.fed-icon { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; filter: brightness(0); }
.fed-icon-sm { width: 16px; height: 16px; object-fit: contain; flex-shrink: 0; filter: brightness(0); }
.fed-icon-lg { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; filter: brightness(0); }
.meet-logo { width: 40px; height: 40px; object-fit: contain; border-radius: var(--radius); flex-shrink: 0; }

/* -- Separator -------------------------------------------------- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* -- Code/monospace --------------------------------------------- */
code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: var(--surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* -- Empty state ------------------------------------------------ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state p { font-size: 14px; }

/* -- Flash messages --------------------------------------------- */
.flash-message {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 10px 40px 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: opacity 0.3s;
  max-width: 480px;
  width: calc(100% - 32px);
}
.flash-success {
  background: rgba(22, 163, 74, 0.06);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.2);
}
.flash-error {
  background: rgba(220, 38, 38, 0.06);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}
.flash-close {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: 0.5;
  line-height: 1;
  padding: 2px 6px;
}
.flash-close:hover { opacity: 1; }

/* -- Confirmation modal ----------------------------------------- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.confirm-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.confirm-modal h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}
.confirm-modal p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* -- Footer ----------------------------------------------------- */
.site-footer {
  margin-top: 40px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.site-footer .footer-social {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.site-footer .footer-social:hover {
  color: var(--text-secondary);
  text-decoration: none;
}

/* -- Responsive ------------------------------------------------- */
@media (max-width: 768px) {
  .form-row { flex-direction: column; gap: 0; }
  .container { padding: 0 16px; }
  th, td { padding: 8px 10px; }
  nav .nav-links { gap: 2px; }
  nav .nav-links a { padding: 6px 8px; font-size: 12px; }
  h1 { font-size: 20px; }
}
