:root {
  --green:      #22c55e;
  --green-dark: #15803d;
  --gold:       #f59e0b;
  --gold-light: #fcd34d;
  --bg:         #0d1117;
  --card-bg:    #161b22;
  --border:     #30363d;
  --text:       #e6edf3;
  --muted:      #8b949e;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', sans-serif;
  min-height: 100vh;
}

/* ── Auth page ─────────────────────────────── */
.auth-page {
  background: radial-gradient(ellipse at top, #0d2a1a 0%, var(--bg) 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-container { width: 100%; max-width: 440px; }
.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ── Navbar ────────────────────────────────── */
.navbar {
  background: linear-gradient(135deg, #0a1a0a, #1a2e1a) !important;
  border-bottom: 1px solid var(--border);
}
.navbar-brand span.text-success { color: var(--green) !important; }

/* ── Cards ─────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.card-header {
  background: rgba(34, 197, 94, 0.08);
  border-bottom: 1px solid var(--border);
}

/* ── Match card ─────────────────────────────── */
.match-card { transition: border-color .2s; }
.match-card:hover { border-color: var(--green); }

.team-col    { flex: 1; min-width: 0; }
.team-flag   { font-size: 1.5rem; line-height: 1; }
.team-name   { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-code   { font-size: .7rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; }

.score-area  { flex-shrink: 0; display: flex; align-items: center; gap: .35rem; }
.score-box   {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1.5rem;
  font-weight: 800;
  width: 2.8rem;
  height: 2.8rem;
  display: flex; align-items: center; justify-content: center;
}
.score-box.vs {
  font-size: .78rem; color: var(--muted); font-weight: 500;
  background: transparent; border-color: transparent;
  width: 1.8rem; height: 1.8rem;
}
.score-sep   { color: var(--muted); font-weight: 600; font-size: 1.1rem; }

.btn-xs {
  padding: .15rem .45rem;
  font-size: .75rem;
  line-height: 1.4;
  border-radius: .25rem;
}

.score-input {
  width: 64px !important;
  height: 48px !important;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  background: rgba(255,255,255,.06) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 10px !important;
}
.score-input:focus {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 2px rgba(34,197,94,.2) !important;
}

/* ── Stage badge ───────────────────────────── */
.stage-badge {
  font-size: .7rem;
  letter-spacing: .04em;
  padding: .25em .65em;
  border-radius: 6px;
}

/* ── Match grid ─────────────────────────────── */
.match-grid { display: grid; gap: .75rem; }
@media (min-width: 576px)  { .match-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .match-grid { grid-template-columns: repeat(3, 1fr); } }

/* ── Leaderboard ────────────────────────────── */
.rank-1 td:first-child { color: var(--gold-light); font-weight: 800; font-size: 1.1rem; }
.rank-2 td:first-child { color: #d1d5db; font-weight: 700; }
.rank-3 td:first-child { color: #cd7f32; font-weight: 700; }
.points-badge-3 { background: #166534; color: #bbf7d0; }
.points-badge-1 { background: #713f12; color: #fde68a; }
.points-badge-0 { background: #450a0a; color: #fca5a5; }

/* ── Group tabs ─────────────────────────────── */
.group-tabs .nav-link {
  color: var(--muted);
  border: 1px solid var(--border);
  margin: 2px;
  border-radius: 6px !important;
  padding: .3rem .7rem;
  font-size: .85rem;
}
.group-tabs .nav-link.active {
  background: var(--green);
  border-color: var(--green);
  color: #000;
  font-weight: 600;
}

/* ── Stats cards ────────────────────────────── */
.stat-card {
  background: linear-gradient(135deg, var(--card-bg), rgba(34,197,94,.05));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
.stat-number { font-size: 2rem; font-weight: 800; color: var(--green); }
.stat-label  { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ── Toast ──────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
  min-width: 260px;
  animation: slideIn .2s ease;
}
.toast-item.success { border-left: 4px solid var(--green); }
.toast-item.error   { border-left: 4px solid #ef4444; }
.toast-item.info    { border-left: 4px solid #3b82f6; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Date header ────────────────────────────── */
.date-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(90deg, rgba(34,197,94,.12) 0%, rgba(34,197,94,.03) 60%, transparent 100%);
  border-left: 4px solid var(--green);
  border-radius: 0 10px 10px 0;
  padding: .65rem 1.1rem;
  margin-bottom: .75rem;
  margin-top: .25rem;
}
.date-day {
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--green);
  line-height: 1;
  min-width: 2.8rem;
  text-align: center;
}
.date-info { display: flex; flex-direction: column; gap: .05rem; }
.date-weekday {
  font-size: .72rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.date-monthyear {
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.date-count {
  margin-left: auto;
  background: rgba(34,197,94,.15);
  border: 1px solid rgba(34,197,94,.3);
  color: var(--green);
  font-size: .72rem;
  font-weight: 700;
  padding: .25rem .65rem;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Misc ───────────────────────────────────── */
.text-gold  { color: var(--gold) !important; }
.bg-saved   { background: rgba(34,197,94,.12) !important; border-color: var(--green) !important; }
.spinner-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 9000;
}
.section-title {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: .5rem;
}

/* ── Match Table (pantalla) ─────────────────────── */
.mt-wrapper {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.mt-table {
  width: 100%;
  border-collapse: collapse;
}
.mt-row {
  border-bottom: 1px solid rgba(48,54,61,.7);
  transition: background .15s;
}
.mt-row:last-child { border-bottom: none; }
.mt-row:nth-child(even) { background: rgba(255,255,255,.02); }
.mt-row:hover { background: rgba(34,197,94,.07) !important; }
.mt-row.live   { background: rgba(239,68,68,.05) !important; }
.mt-row.live:hover { background: rgba(239,68,68,.1) !important; }

.mt-row td {
  padding: .6rem .85rem;
  vertical-align: middle;
  white-space: nowrap;
}

.mt-num {
  width: 2.4rem;
  text-align: center;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.mt-grp { width: 3rem; text-align: center; }
.grp-pill {
  display: inline-block;
  background: rgba(34,197,94,.13);
  border: 1px solid rgba(34,197,94,.28);
  color: var(--green);
  font-size: .67rem;
  font-weight: 800;
  padding: .18rem .48rem;
  border-radius: 20px;
  letter-spacing: .05em;
}

.mt-team   { width: 32%; }
.mt-team.r { text-align: right; }
.mt-team.l { text-align: left; }
.mt-flag   { font-size: 1.25rem; margin: 0 .35rem; display: inline-block; }
.mt-name   { font-weight: 600; font-size: .9rem; }

.mt-score-cell {
  width: 9rem;
  text-align: center;
  padding: .4rem .5rem !important;
}
.mt-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  border-radius: 8px;
  font-weight: 800;
  min-width: 5.8rem;
  padding: .28rem .65rem;
}
.mt-done {
  font-size: 1.15rem;
  background: rgba(34,197,94,.1);
  border: 1px solid rgba(34,197,94,.22);
  color: var(--text);
}
.mt-done .mt-dash { color: var(--muted); font-weight: 400; font-size: .9rem; }
.mt-live {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: #f87171;
  border: 1px solid rgba(239,68,68,.35);
  background: rgba(239,68,68,.1);
  gap: .45rem;
  animation: livePulse 1.6s ease-in-out infinite;
}
.live-dot {
  width: 7px; height: 7px;
  background: #ef4444;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.mt-vs {
  font-size: .75rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  background: transparent;
}
@keyframes livePulse {
  0%,100% { opacity:1; box-shadow: 0 0 0 0 rgba(239,68,68,.3); }
  50%      { opacity:.7; box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

.mt-venue {
  color: var(--muted);
  font-size: .7rem;
  max-width: 13rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mt-badge { text-align: right; padding-right: .9rem !important; }

@media (max-width: 767px) {
  .mt-venue { display: none; }
  .mt-name  { max-width: 5.5rem; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; }
  .mt-flag  { font-size: 1.1rem; margin: 0 .2rem; }
  .mt-row td { padding: .5rem .45rem; }
}

/* ── Countdown ───────────────────────────────────── */
.countdown-banner {
  background: linear-gradient(135deg, rgba(34,197,94,.08) 0%, rgba(245,158,11,.05) 100%);
  border: 1px solid rgba(34,197,94,.3);
  border-radius: 14px;
  padding: .9rem 1.4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  transition: border-color .4s, background .4s;
}
.countdown-banner.warn {
  border-color: rgba(245,158,11,.55);
  background: linear-gradient(135deg, rgba(245,158,11,.1) 0%, rgba(245,158,11,.04) 100%);
}
.countdown-banner.urgent {
  border-color: rgba(239,68,68,.55);
  background: linear-gradient(135deg, rgba(239,68,68,.12) 0%, rgba(239,68,68,.05) 100%);
  animation: cdUrgent 2s ease-in-out infinite;
}
.countdown-banner.expired {
  border-color: rgba(239,68,68,.4);
  background: linear-gradient(135deg, rgba(239,68,68,.08) 0%, rgba(239,68,68,.03) 100%);
}
@keyframes cdUrgent {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.25); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.cd-label-wrap {}
.cd-title    { font-size: .88rem; font-weight: 700; color: var(--text); margin-bottom: .1rem; }
.cd-subtitle { font-size: .7rem;  color: var(--muted); }

.countdown-timer { display: flex; align-items: flex-end; gap: .35rem; }
.cd-unit {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(34,197,94,.28);
  border-radius: 10px;
  padding: .35rem .65rem;
  min-width: 3.3rem;
  transition: border-color .3s, background .3s;
}
.cd-unit span {
  font-size: 1.55rem; font-weight: 900; color: var(--green);
  line-height: 1; font-variant-numeric: tabular-nums;
}
.cd-unit small {
  font-size: .57rem; text-transform: uppercase;
  color: var(--muted); letter-spacing: .08em; margin-top: .1rem;
}
.cd-sep { color: var(--muted); font-weight: 800; font-size: 1.2rem; margin-bottom: .75rem; }

.countdown-banner.warn   .cd-unit { border-color: rgba(245,158,11,.45); }
.countdown-banner.warn   .cd-unit span { color: var(--gold); }
.countdown-banner.urgent .cd-unit { border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.08); }
.countdown-banner.urgent .cd-unit span { color: #f87171; }

.cd-expired-msg {
  font-size: .9rem; font-weight: 700; color: #f87171;
  display: flex; align-items: center; gap: .5rem;
}

/* ── Prediction table extras ────────────────────── */
.pred-input {
  width: 44px !important;
  height: 32px !important;
  text-align: center !important;
  font-size: .95rem !important;
  font-weight: 700 !important;
  padding: 0 !important;
  border-radius: 6px !important;
  background: rgba(255,255,255,.06) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}
.pred-input:focus {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 2px rgba(34,197,94,.2) !important;
  outline: none !important;
}

.pred-result {
  font-weight: 700;
  font-size: .88rem;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .18rem .6rem;
  display: inline-block;
  white-space: nowrap;
  letter-spacing: .03em;
}

.pred-locked {
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.mt-pred-cell { white-space: nowrap; min-width: 10.5rem; }
.mt-pts-cell  { text-align: center; white-space: nowrap; min-width: 5rem; }

.mt-row.pred-saved-row { border-left: 3px solid var(--green); }

@media (max-width: 767px) {
  .mt-pred-cell { min-width: 8rem; }
  .pred-input   { width: 38px !important; }
}

/* ── Print / PDF ─────────────────────────────── */
.no-print   { }
.print-only { display: none !important; }

@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  body {
    background: #fff !important;
    color: #111 !important;
    font-size: 9.5pt;
    margin: 0;
  }

  /* Ocultar navegación, tabs y botones */
  .no-print,
  #navbar,
  #stageTabs,
  #groupFilterRow,
  #matchesContainer,
  #predContainer,
  #predSummary,
  #toast-container,
  .spinner-overlay { display: none !important; }

  /* Mostrar área de impresión */
  .print-only { display: block !important; }

  /* ── Encabezado de impresión ── */
  .print-header {
    text-align: center;
    border-bottom: 3px solid #22c55e;
    padding-bottom: .6rem;
    margin-bottom: 1rem;
  }
  .print-header h2 { font-size: 15pt; color: #111; margin: 0 0 .2rem; font-weight: 800; }
  .print-header p  { font-size: 8pt; color: #555; margin: 0; }

  /* ── Tabla estilo Excel ── */
  .print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8.5pt;
    font-family: 'Segoe UI', Arial, sans-serif;
  }

  .print-table thead tr th {
    background: #15803d !important;
    color: #fff !important;
    padding: 5px 6px;
    border: 1px solid #166534;
    text-align: left;
    font-weight: 700;
    font-size: 7.5pt;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
  }
  .print-table thead tr th.center { text-align: center; }

  .print-table tbody tr.date-row td {
    background: #dcfce7 !important;
    color: #14532d !important;
    font-weight: 700;
    font-size: 8pt;
    padding: 4px 6px;
    border: 1px solid #86efac;
    letter-spacing: .03em;
  }

  .print-table tbody tr.row-even td { background: #fff !important; }
  .print-table tbody tr.row-odd  td { background: #f8fafb !important; }

  .print-table tbody tr td {
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    vertical-align: middle;
    color: #111 !important;
  }

  .print-table .col-num    { text-align: center; color: #6b7280 !important; width: 2rem; }
  .print-table .col-date   { white-space: nowrap; width: 5.5rem; color: #374151 !important; }
  .print-table .col-group  { text-align: center; width: 2.8rem; font-weight: 700; color: #15803d !important; }
  .print-table .col-team   { min-width: 7rem; }
  .print-table .col-score  {
    text-align: center;
    font-weight: 800;
    font-size: 10.5pt;
    white-space: nowrap;
    width: 4.5rem;
    letter-spacing: .05em;
  }
  .print-table .col-score.vs       { color: #9ca3af !important; font-size: 8pt; font-weight: 400; }
  .print-table .col-score.live     { color: #dc2626 !important; font-size: 8pt; }
  .print-table .col-venue  { font-size: 7.5pt; color: #6b7280 !important; }
  .print-table .col-status { white-space: nowrap; font-size: 7.5pt; }
  .print-table .st-done    { color: #16a34a !important; font-weight: 600; }
  .print-table .st-live    { color: #dc2626 !important; font-weight: 600; }
  .print-table .st-soon    { color: #6b7280 !important; }
  .print-table .st-zero    { color: #dc2626 !important; }
  .print-table .col-pts    { text-align: center; font-weight: 700; font-size: 8.5pt; }

  /* Resumen de estadísticas (predicciones) */
  .print-summary-table {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    border-collapse: collapse;
    margin-bottom: .7rem;
    background: #f0fdf4 !important;
  }
  .print-summary-table td {
    padding: 5px 14px;
    font-size: 8.5pt;
    border-right: 1px solid #d1d5db;
    color: #111;
  }
  .print-summary-table td:last-child { border-right: none; }

  .container-fluid { padding: 0 !important; }

  @page {
    margin: 1.2cm 1cm;
    size: A4 landscape;
  }
}
