/* ============================================================
   RTScoreV2 — Unified Design System
   Glassmorphism Dark Theme
   ============================================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
  /* Colors */
  --color-bg-start: #0f0c29;
  --color-bg-mid: #1a1a3e;
  --color-bg-end: #24243e;
  --color-surface: rgba(255,255,255,0.06);
  --color-surface-hover: rgba(255,255,255,0.10);
  --color-surface-active: rgba(255,255,255,0.14);
  --color-border: rgba(255,255,255,0.10);
  --color-border-light: rgba(255,255,255,0.06);
  --color-border-hover: rgba(255,255,255,0.18);
  --color-text: #fff;
  --color-text-secondary: rgba(255,255,255,0.7);
  --color-text-muted: rgba(255,255,255,0.5);
  --color-text-faint: rgba(255,255,255,0.4);
  --color-text-ghost: rgba(255,255,255,0.25);
  --color-text-placeholder: rgba(255,255,255,0.25);

  /* Gradients */
  --gradient-bg: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-mid) 40%, var(--color-bg-end) 100%);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);

  /* Semantic Colors */
  --color-primary: #667eea;
  --color-primary-glow: rgba(102,126,234,0.6);
  --color-success: #6ee7b7;
  --color-success-bg: rgba(74,222,128,0.15);
  --color-success-border: rgba(74,222,128,0.5);
  --color-danger: #f87171;
  --color-danger-bg: rgba(239,68,68,0.15);
  --color-danger-border: rgba(239,68,68,0.25);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(251,191,36,0.15);
  --color-info: #60a5fa;
  --color-info-bg: rgba(96,165,250,0.15);

  /* Blur */
  --blur: blur(24px);
  --blur-overlay: blur(6px);

  /* Border Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-3xl: 28px;
  --radius-full: 50%;

  /* Shadows */
  --shadow-card: 0 25px 50px -12px rgba(0,0,0,0.5);
  --shadow-modal: 0 20px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 4px rgba(250,204,21,0.15);

  /* Font */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Z-index layers */
  --z-dropdown: 50;
  --z-modal: 100;
  --z-toast: 1000;
}

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

html {
  -webkit-text-size-adjust: 100%;
  /* Senza questo, il browser assume tema chiaro per gli elementi nativi
     controllati dal sistema (popup di <select>, scrollbar, ecc.), anche
     se il resto della UI è scuro — causa testo illeggibile/contrasto
     rotto nel menu a tendina dei <select>. */
  color-scheme: dark;
}

body {
  font-family: var(--font-family);
  min-height: 100vh;
  background: var(--gradient-bg);
  padding: 20px;
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Dashboard Container --- */
.dashboard {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  background: var(--color-surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-3xl);
  padding: 28px 24px 24px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}

.dashboard--narrow {
  max-width: 640px;
}

.dashboard--compact {
  max-width: 720px;
}

/* --- Top Bar --- */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.top-bar__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: .85em;
  font-weight: 500;
  transition: color var(--transition-base);
}

.top-bar__link:hover {
  color: var(--color-text);
}

.top-bar__title {
  font-size: 1.2em;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-left: auto;
}

.top-bar__date {
  font-size: .78em;
  color: var(--color-text-faint);
  background: var(--color-surface);
  padding: 6px 12px;
  border-radius: var(--radius-md);
}

.top-bar__clock {
  font-family: var(--font-mono);
  font-size: .9em;
  font-weight: 700;
  letter-spacing: .15em;
  color: var(--color-warning);
  background: #111;
  padding: 4px 12px;
  border-radius: var(--radius-md);
  min-width: 8ch;
  text-align: center;
  box-shadow: var(--shadow-glow);
}

/* --- Cards --- */
.card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  padding: 18px 16px;
  margin-bottom: 14px;
}

.card:last-child {
  margin-bottom: 0;
}

.card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85em;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 14px;
}

.card__title i {
  font-size: .9em;
}

.card--clickable {
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
}

.card--clickable:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}

/* --- Buttons --- */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: .82em;
  cursor: pointer;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-family);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  opacity: .4;
  cursor: default;
  pointer-events: none;
}

.btn--primary {
  background: var(--gradient-primary);
  color: var(--color-text);
}
.btn--primary:hover { opacity: .9; }

.btn--success {
  background: var(--gradient-success);
  color: var(--color-text);
}
.btn--success:hover { opacity: .9; }

.btn--outline {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn--outline:hover {
  background: var(--color-surface-active);
  color: var(--color-text);
}

.btn--ghost {
  background: var(--color-surface);
  color: var(--color-text-secondary);
}
.btn--ghost:hover {
  background: var(--color-surface-active);
}

.btn--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}
.btn--danger:hover {
  background: rgba(239,68,68,0.25);
}

.btn--xs {
  padding: 4px 10px;
  font-size: .72em;
  border-radius: var(--radius-sm);
}

.btn--sm {
  padding: 5px 12px;
  font-size: .75em;
  border-radius: 7px;
}

/* --- Button Bar --- */
.btn-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn-bar--end {
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-light);
}

/* --- Forms --- */
.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-row label {
  font-size: .82em;
  color: var(--color-text-muted);
  font-weight: 500;
  min-width: 60px;
}

input, select, textarea {
  padding: 9px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: .85em;
  outline: none;
  transition: border-color var(--transition-base);
  font-family: var(--font-family);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary-glow);
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-placeholder);
}

select option {
  background: var(--color-bg-mid);
  color: var(--color-text);
}

input[type="file"] {
  padding: 6px;
}

input[type="file"]::file-selector-button {
  padding: 4px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-surface-hover);
  color: var(--color-text);
  cursor: pointer;
  font-size: .82em;
  font-family: var(--font-family);
}

input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: none;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.bulk-textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: .85em;
  font-family: 'Courier New', monospace;
  outline: none;
  resize: vertical;
  transition: border-color var(--transition-base);
  line-height: 1.5;
}

.bulk-textarea:focus {
  border-color: var(--color-primary-glow);
}

.bulk-textarea::placeholder {
  color: var(--color-text-placeholder);
}

/* --- Filters --- */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filters label {
  font-size: .78em;
  color: var(--color-text-muted);
  font-weight: 500;
}

.filters select,
.filters input {
  padding: 8px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: .82em;
  outline: none;
  font-family: var(--font-family);
  transition: border-color var(--transition-base);
}

.filters select:focus,
.filters input:focus {
  border-color: var(--color-primary-glow);
}

.filters select option {
  background: var(--color-bg-mid);
  color: var(--color-text);
}

.filters .search-box {
  flex: 1;
  min-width: 150px;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border-light);
}

.pagination__info {
  font-size: .8em;
  color: var(--color-text-faint);
  white-space: nowrap;
}

/* --- Stats Bar --- */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
}

.stat-item__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.stat-item__value {
  font-size: 1.1em;
  font-weight: 700;
}

.stat-item__label {
  font-size: .72em;
  color: var(--color-text-muted);
}

.stat-icon--total { background: var(--gradient-primary); }
.stat-icon--prematch { background: var(--color-info-bg); color: var(--color-info); }
.stat-icon--live { background: var(--color-success-bg); color: var(--color-success); }
.stat-icon--created { background: rgba(168,85,247,0.2); color: #c084fc; }

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82em;
}

th, td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--color-border-light);
}

th {
  color: var(--color-text-faint);
  font-weight: 600;
  font-size: .75em;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: rgba(255,255,255,0.03);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255,255,255,0.03);
}

td.actions {
  white-space: nowrap;
}

td img {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  object-fit: contain;
  background: #fff;
  padding: 3px;
  border: 1px solid rgba(255,255,255,0.15);
  display: block;
}

td input[type="text"],
td select {
  padding: 5px 8px;
  font-size: .82em;
  border-radius: var(--radius-sm);
  width: auto;
  max-width: 120px;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge--admin {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge--operator {
  background: var(--color-info-bg);
  color: #93c5fd;
}

.badge--auto {
  font-size: .7em;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge--auto.off {
  background: var(--color-surface);
  color: var(--color-text-faint);
}

/* --- Toggle Buttons --- */
.toggle-btn {
  background: none;
  border: 1.5px solid rgba(239,68,68,0.4);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  font-size: .68em;
  font-weight: 700;
  color: var(--color-danger);
  transition: all var(--transition-base);
  line-height: 1;
  letter-spacing: .04em;
  font-family: var(--font-family);
  text-transform: uppercase;
}

.toggle-btn:hover {
  border-color: rgba(239,68,68,0.7);
  background: rgba(239,68,68,0.08);
}

.toggle-btn.on {
  border-color: var(--color-success-border);
  color: var(--color-success);
  background: var(--color-success-bg);
}

.toggle-btn.on:hover {
  border-color: rgba(74,222,128,0.8);
  background: rgba(74,222,128,0.14);
}

.toggle-btn.warn {
  border-color: rgba(251,191,36,0.5);
  color: var(--color-warning);
  background: var(--color-warning-bg);
}

.toggle-btn.warn:hover {
  border-color: rgba(251,191,36,0.8);
  background: rgba(251,191,36,0.14);
}

/* --- Toggle Small (for score/event cards) --- */
.toggle-sm {
  background: none;
  border: 1.5px solid rgba(239,68,68,0.4);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: .6em;
  font-weight: 700;
  color: var(--color-danger);
  transition: all var(--transition-base);
  line-height: 1;
  letter-spacing: .03em;
  font-family: var(--font-family);
  text-transform: uppercase;
  white-space: nowrap;
}

.toggle-sm:hover {
  border-color: rgba(239,68,68,0.7);
  background: rgba(239,68,68,0.08);
}

.toggle-sm.on {
  border-color: var(--color-success-border);
  color: var(--color-success);
  background: var(--color-success-bg);
}

.toggle-sm.on:hover {
  border-color: rgba(74,222,128,0.8);
  background: rgba(74,222,128,0.14);
}

/* --- Tabs primari (navigazione principale di pagina) ---
   Distinti da .toggle-sm (badge/switch piccoli dentro una card): qui
   sono il controllo di navigazione primario di admin/manage.php,
   servono grandi e facilmente cliccabili anche su schermo compatto/
   touch (introdotti 2026-08-19 dopo feedback: i tab con .toggle-sm
   erano troppo piccoli per essere raggiungibili comodamente). */
.tabs-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.tabs-primary__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  min-height: 44px; /* area cliccabile touch-friendly */
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.75);
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.tabs-primary__item i {
  font-size: 1.05em;
}

.tabs-primary__item:hover {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.tabs-primary__item.on {
  border-color: var(--color-primary);
  background: rgba(102,126,234,0.18);
  color: #fff;
  box-shadow: 0 0 0 1px var(--color-primary-glow) inset;
}

@media (max-width: 640px) {
  .tabs-primary__item {
    flex: 1 1 calc(50% - 10px);
    justify-content: center;
    padding: 14px 12px;
  }
}

/* --- Period Badges --- */
.period-badge {
  font-size: .62em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

.period-badge.prematch { background: #1e3a5f; color: var(--color-info); }
.period-badge.firsthalf,
.period-badge.secondhalf,
.period-badge.halftime { background: #1a4a3a; color: var(--color-success); }
.period-badge.fulltime { background: #2a2a2a; color: var(--color-text-faint); }
.period-badge.extratime,
.period-badge.penalties { background: #4a3a1a; color: var(--color-warning); }
.period-badge.error { background: #4a1a1a; color: var(--color-danger); }

/* --- Source Badges --- */
.badge-source {
  display: inline-block;
  font-size: .72em;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.badge-opta { background: rgba(102,126,234,0.2); color: #93a8ff; }
.badge-gazzetta { background: rgba(52,211,153,0.2); color: var(--color-success); }

/* --- Competition Groups (Today page) --- */
.competition-group {
  margin-bottom: 20px;
}

.competition-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  cursor: pointer;
  transition: background var(--transition-base);
}

.competition-header:hover {
  background: rgba(255,255,255,0.07);
}

.competition-header .comp-name {
  font-weight: 600;
  font-size: .9em;
  flex: 1;
}

.competition-header .comp-count {
  font-size: .75em;
  color: var(--color-text-faint);
  background: var(--color-surface);
  padding: 3px 8px;
  border-radius: 12px;
}

.competition-header .comp-created {
  font-size: .72em;
  color: var(--color-success);
  background: var(--color-success-bg);
  padding: 3px 8px;
  border-radius: 12px;
}

.competition-header .toggle-icon {
  color: var(--color-text-faint);
  transition: transform var(--transition-base);
}

.competition-header.expanded .toggle-icon {
  transform: rotate(180deg);
}

/* --- Match Card --- */
.matches-grid {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.matches-grid.show {
  display: flex;
}

.match-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border-light);
  border-radius: 10px;
  transition: all var(--transition-base);
}

.match-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
}

.match-card.already-created {
  border-color: rgba(74,222,128,0.3);
  background: rgba(74,222,128,0.05);
}

.match-card .match-time {
  font-size: .72em;
  color: var(--color-text-faint);
  min-width: 50px;
  text-align: center;
}

.match-card .match-teams {
  flex: 1;
  min-width: 0;
}

.match-card .match-teams .home,
.match-card .match-teams .away {
  font-weight: 600;
  font-size: .88em;
}

.match-card .match-teams .vs {
  color: var(--color-text-ghost);
  font-size: .75em;
  margin: 0 6px;
}

.match-card .match-status {
  font-size: .65em;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  min-width: 70px;
  text-align: center;
}

.match-card .match-status.prematch { background: var(--color-info-bg); color: var(--color-info); }
.match-card .match-status.live { background: var(--color-success-bg); color: var(--color-success); }
.match-card .match-status.finished { background: var(--color-surface); color: var(--color-text-faint); }

.match-card .match-score {
  font-weight: 700;
  font-size: .9em;
  color: var(--color-text-secondary);
  min-width: 40px;
  text-align: center;
}

.match-card .match-actions {
  display: flex;
  gap: 6px;
}

.match-card .created-badge {
  font-size: .72em;
  color: var(--color-success);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- Event Card (Scores page) --- */
.event-card {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  position: relative;
}

.event-card.dimmed {
  opacity: 0.5;
  filter: grayscale(0.4);
}

.event-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.event-header .ev-name {
  font-weight: 700;
  flex: 1;
  font-size: .9em;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.event-header .toggles {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #333;
  border-radius: 6px;
  padding: 3px 5px;
  flex-shrink: 0;
}

.event-body {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.side-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.side-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: #fff;
  padding: 5px;
  object-fit: contain;
  border: 1.5px solid #999;
}

.side-name {
  font-weight: 700;
  font-size: .6em;
}

.team-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.team-col button {
  width: 56px;
  height: 48px;
  font-size: 1.3em;
  cursor: pointer;
  border: 1px solid #5a5;
  border-radius: 8px;
  background: #b5e7b5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.team-col button:hover { background: #a0d8a0; }
.team-col button:active { background: #8cc88c; }

.team-col .score {
  font-size: 2em;
  font-weight: 700;
  min-width: 44px;
  text-align: center;
  line-height: 1.3;
  color: #fff;
  background: #222;
  border-radius: 6px;
  padding: 2px 8px;
  letter-spacing: 1px;
  margin: 4px 0;
}

.event-divider {
  font-size: 1.4em;
  font-weight: 300;
  color: #999;
  flex-shrink: 0;
}

/* --- Card Teams (Events manager) --- */
.card-teams {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.card-teams .team {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: .9em;
}

.card-teams .team img {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: #fff;
  padding: 2px;
  object-fit: contain;
  border: 1px solid rgba(255,255,255,0.15);
}

.card-teams .vs {
  color: rgba(255,255,255,0.25);
  font-size: .75em;
  font-weight: 500;
}

.card-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  background: #444444;
  border-radius: 8px;
  padding: 4px 6px;
}

.card-timetable {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: .78em;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
  padding: 6px 8px;
  margin-top: 2px;
}

.card-timetable input[type="time"] {
  padding: 4px 6px;
  font-size: .95em;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}

.card-timetable .timetable-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .85em;
  font-weight: 700;
  color: #6ee7b7;
  background: rgba(74,222,128,0.18);
  border: 1px solid rgba(74,222,128,0.4);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.card-timetable .timetable-hint::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6ee7b7;
  flex-shrink: 0;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: var(--blur-overlay);
  -webkit-backdrop-filter: var(--blur-overlay);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #1e1e3a;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: 28px 24px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow-modal);
}

.modal-box--wide {
  max-width: 420px;
  text-align: left;
}

.modal-box p {
  font-size: .95em;
  margin-bottom: 20px;
  color: var(--color-text);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-btn {
  padding: 10px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-size: .85em;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  font-family: var(--font-family);
}

.modal-btn--yes {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}

.modal-btn--yes:hover {
  background: rgba(239,68,68,0.25);
}

.modal-btn--no {
  background: var(--color-surface);
  color: var(--color-text-secondary);
}

.modal-btn--no:hover {
  background: var(--color-surface-active);
}

/* --- Log Box --- */
.log-box {
  margin-top: 16px;
  background: #0a0a0a;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.log-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: .78em;
  font-weight: 600;
  color: var(--color-text-muted);
}

.log-header .log-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: log-pulse 2s infinite;
}

@keyframes log-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

.log-body {
  height: 200px;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: .72em;
  line-height: 1.6;
  color: var(--color-text-secondary);
  scroll-behavior: smooth;
}

.log-body::-webkit-scrollbar { width: 4px; }
.log-body::-webkit-scrollbar-track { background: transparent; }
.log-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.log-line { white-space: pre; }
.log-line .lt { color: var(--color-text-faint); }
.log-line .lreq { color: var(--color-info); }
.log-line .lres { color: var(--color-success); }
.log-line .lerr { color: var(--color-danger); }

/* --- Match List (Extractions) --- */
.match-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.15);
}

.match-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: .8em;
}

.match-row:last-child { border-bottom: none; }
.match-row:hover { background: rgba(255,255,255,0.04); }

.match-status {
  font-size: .7em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
  min-width: 50px;
  text-align: center;
}

.match-status.prematch { background: var(--color-info-bg); color: var(--color-info); }
.match-status.live,
.match-status.inplay { background: var(--color-success-bg); color: var(--color-success); }
.match-status.full,
.match-status.finished { background: var(--color-surface); color: var(--color-text-faint); }

.match-teams {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-teams .score {
  font-weight: 700;
  color: var(--color-text-secondary);
}

.match-comp {
  font-size: .72em;
  color: var(--color-text-faint);
  flex-shrink: 0;
}

.match-cb {
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.source-field {
  transition: opacity var(--transition-base);
}

.source-hint {
  font-size: .72em;
  color: var(--color-text-faint);
  margin-left: 4px;
}

/* --- Settings Rows --- */
.settings-grid {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.settings-grid label {
  font-size: .82em;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.settings-grid input[type="number"] {
  padding: 9px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: .85em;
  outline: none;
  transition: border-color var(--transition-base);
  width: 100px;
  font-family: var(--font-family);
}

.settings-grid input[type="number"]:focus {
  border-color: var(--color-primary-glow);
}

.settings-grid .check-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .82em;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.settings-grid .btn-save {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: .82em;
  cursor: pointer;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gradient-primary);
  color: var(--color-text);
  font-family: var(--font-family);
  margin-left: auto;
}

.settings-grid .btn-save:hover { opacity: .9; }

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.settings-row:last-child { border-bottom: none; }

.backup-list {
  margin-top: 10px;
  max-height: 160px;
  overflow-y: auto;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.backup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 2px;
  font-size: .78em;
  color: var(--color-text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.backup-item__meta {
  color: var(--color-text-faint);
  white-space: nowrap;
}

.settings-row .label {
  min-width: 140px;
  font-size: .82em;
  color: var(--color-text-secondary);
}

.settings-row input[type="number"] {
  padding: 9px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: .85em;
  outline: none;
  transition: border-color var(--transition-base);
  width: 110px;
  font-family: var(--font-family);
}

.settings-row input[type="number"]:focus {
  border-color: var(--color-primary-glow);
}

.save-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-light);
}

.save-bar .btn-save {
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: .82em;
  cursor: pointer;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gradient-primary);
  color: var(--color-text);
  font-family: var(--font-family);
}

.save-bar .btn-save:hover { opacity: .9; }

.bulk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.bulk-row select {
  padding: 9px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: .85em;
  outline: none;
  font-family: var(--font-family);
  min-width: 140px;
}

.bulk-row select option { background: var(--color-bg-mid); color: var(--color-text); }

.bulk-row input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: none;
}

.bulk-status {
  font-size: .78em;
  color: var(--color-text-muted);
  margin-top: 8px;
  min-height: 1.2em;
}

.bulk-status.success { color: var(--color-success); }
.bulk-status.error { color: var(--color-danger); }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: .85em;
  font-weight: 500;
  z-index: var(--z-toast);
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-slow);
  max-width: 400px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: rgba(16,185,129,0.9);
  color: #fff;
}

.toast.error {
  background: rgba(239,68,68,0.9);
  color: #fff;
}

.toast.info {
  background: rgba(96,165,250,0.9);
  color: #fff;
}

/* --- Loading / Empty States --- */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--color-text-faint);
}

.loading i {
  font-size: 2em;
  margin-bottom: 10px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--color-text-faint);
}

.empty-state i {
  font-size: 3em;
  margin-bottom: 10px;
}

/* --- Note / Helper Text --- */
.note {
  font-size: .75em;
  color: var(--color-text-faint);
  line-height: 1.5;
  margin-top: 12px;
}

.note code {
  background: var(--color-surface);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: .9em;
}

.file-name-hint {
  font-size: .78em;
  color: var(--color-text-faint);
  padding: 0 4px;
  line-height: 1.4;
}

/* --- HTMX Styles --- */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

.htmx-settling {
  transition: opacity var(--transition-base);
}

.htmx-swapping {
  opacity: 0;
  transition: opacity var(--transition-fast);
}

/* --- Autocomplete Dropdown --- */
.autocomplete-wrap {
  position: relative;
  flex: 1;
  min-width: 150px;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1e1e3a;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.autocomplete-close {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  padding: 4px 8px;
  background: #1e1e3a;
  color: var(--color-text-faint);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-light);
}

.autocomplete-close:hover {
  color: var(--color-text);
}

.autocomplete-item {
  padding: 8px 12px;
  font-size: .82em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition-fast);
}

.autocomplete-item:hover {
  background: rgba(255,255,255,0.08);
}

.autocomplete-item img {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: #fff;
  padding: 2px;
  object-fit: contain;
}

.autocomplete-item .ac-name {
  font-weight: 600;
}

.autocomplete-item .ac-tournament {
  font-size: .85em;
  color: var(--color-text-faint);
}

.autocomplete-empty {
  padding: 10px 12px;
  font-size: .82em;
  color: var(--color-text-faint);
  text-align: center;
}

/* --- Login Page --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-bg);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-3xl);
  padding: 36px 28px 28px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.login-card h1 {
  font-size: 1.4em;
  margin-bottom: 8px;
  font-weight: 700;
}

.login-card .subtitle {
  font-size: .85em;
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

.login-card .form-row {
  flex-direction: column;
  gap: 12px;
}

.login-card input {
  width: 100%;
  padding: 12px 14px;
  font-size: .9em;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: .9em;
  margin-top: 8px;
}

.login-error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: .82em;
  margin-bottom: 12px;
  display: none;
}

/* --- Overlay specific --- */
.overlay-container {
  width: 100%;
  min-height: 100vh;
  background: transparent;
  font-family: var(--font-family);
  color: #fff;
  overflow: hidden;
}

.overlay-card {
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.1);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  .dashboard {
    padding: 20px 16px;
    border-radius: var(--radius-2xl);
  }

  .stats-bar {
    gap: 8px;
  }

  .stat-item {
    padding: 8px 10px;
    flex: 1;
    min-width: 0;
  }
}

@media (max-width: 500px) {
  body {
    padding: 10px;
  }

  .dashboard {
    padding: 16px 12px;
    border-radius: 20px;
  }

  .top-bar {
    flex-wrap: wrap;
  }

  .top-bar__title {
    margin-left: 0;
    width: 100%;
    order: -1;
  }

  .match-card {
    flex-wrap: wrap;
    gap: 8px;
  }

  .match-card .match-teams {
    flex: 1 1 100%;
  }

  .match-card .match-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .card {
    flex-wrap: wrap;
    gap: 8px;
  }

  .card-teams {
    flex: 1 1 100%;
  }

  .form-row input,
  .form-row select {
    flex: 1;
    min-width: 100px;
  }

  td input[type="text"],
  td select {
    max-width: 80px;
    font-size: .78em;
  }

  .settings-row .label {
    min-width: 100px;
  }

  .settings-row input[type="number"] {
    width: 90px;
  }

  table {
    font-size: .72em;
  }

  th, td {
    padding: 6px 4px;
  }
}

/* --- Mobile Scores (400px viewport) --- */
@media (max-width: 420px) {
  body {
    width: 400px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .side-icon {
    width: 68px;
    height: 68px;
    padding: 6px;
  }

  .side-name {
    font-size: .7em;
  }

  .team-col .score {
    font-size: 1.4em;
    min-width: 32px;
  }

  .team-col button {
    width: 39px;
    height: 34px;
    font-size: .98em;
  }

  .event-body {
    gap: 6px;
  }

  .event-divider {
    font-size: 1.1em;
  }
}

@media (min-width: 600px) {
  #events-container {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    max-width: none;
    margin: 0;
  }

  .event-card {
    flex: 1 1 240px;
    max-width: 320px;
    padding: 6px 8px;
    margin-bottom: 0;
  }
}

/* --- Print --- */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .dashboard {
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: none;
  }

  .btn, .toggle-btn, .toggle-sm, .modal-overlay {
    display: none;
  }
}

/* ============================================================
   Layout — Sidebar Navigation
   ============================================================ */

.layout {
  display: flex;
  min-height: 100vh;
  margin: -20px;
  padding: 0;
}

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: rgba(15,12,41,0.95);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: 12px;
}

.sidebar__brand i {
  font-size: 1.4em;
  color: var(--color-primary);
}

.sidebar__brand-text {
  font-size: 1.1em;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.sidebar__menu {
  flex: 1;
  padding: 0 10px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: .88em;
  font-weight: 500;
  transition: all var(--transition-base);
  margin-bottom: 2px;
  text-decoration: none;
}

.sidebar__link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--color-text);
}

.sidebar__link.active {
  background: rgba(102,126,234,0.15);
  color: var(--color-primary);
}

.sidebar__link.active i {
  color: var(--color-primary);
}

.sidebar__link i {
  width: 18px;
  text-align: center;
  font-size: .9em;
}

.sidebar__divider {
  height: 1px;
  background: var(--color-border-light);
  margin: 10px 14px;
}

.sidebar__footer {
  padding: 12px 10px 0;
  border-top: 1px solid var(--color-border-light);
  margin-top: 12px;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: .82em;
  color: var(--color-text-secondary);
}

.sidebar__user i {
  font-size: 1.1em;
  color: var(--color-text-faint);
}

.sidebar__link--logout {
  color: var(--color-danger);
  font-size: .82em;
}

.sidebar__link--logout:hover {
  background: var(--color-danger-bg);
}

.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 20px;
  min-height: 100vh;
}

/* Mobile sidebar */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    padding: 12px 0;
  }

  .sidebar__brand-text,
  .sidebar__link span,
  .sidebar__user span {
    display: none;
  }

  .sidebar__brand {
    justify-content: center;
    padding: 0 0 12px;
  }

  .sidebar__link {
    justify-content: center;
    padding: 12px;
  }

  .sidebar__user {
    justify-content: center;
  }

  .main-content {
    margin-left: 60px;
    padding: 12px;
  }
}

@media (max-width: 500px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 10px;
  }
}
