/* =====================================================================
   Estilos comunes: sitio público, panel de administración e instalador
   ===================================================================== */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --border: #e3e5ea;
  --accent: #ea580c;
  --accent-dark: #c2410c;
  --accent-soft: #fff1e8;
  --ok: #16a34a;
  --danger: #dc2626;
  --live: #e11d48;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d24;
    --text: #e8eaf0;
    --muted: #9aa0ad;
    --border: #2c313c;
    --accent-soft: #3a2012;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 19px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Estructura ---------- */
.topbar {
  background: #111318;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar a { color: #fff; }
.topbar .brand { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.topbar .brand small { font-weight: 500; color: #b8bcc6; font-size: 13px; }
.container { max-width: 1150px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin: 40px auto; }
.center-page { min-height: 100vh; padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.breadcrumb { font-size: 14px; color: var(--muted); margin-bottom: 8px; }

/* ---------- Botones y formularios ---------- */
.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
}
.btn:hover, button:hover { border-color: var(--muted); }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, button.primary:hover { background: var(--accent-dark); }
button.danger { color: var(--danger); }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.form { display: grid; gap: 12px; }
.form.cols { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input[type="color"] { padding: 2px; height: 38px; }
input[type="checkbox"] { width: auto; }
textarea { min-height: 110px; resize: vertical; }
.alert { padding: 10px 12px; border-radius: 8px; margin: 8px 0; }
.alert.error { background: #fde8e8; color: #9b1c1c; }
.alert.ok { background: #e6f6ec; color: #166534; }
.alert.info { background: var(--accent-soft); color: var(--text); }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: none;
  background: none;
  border-radius: 8px 8px 0 0;
  padding: 10px 14px;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
td.num, th.num { text-align: center; }
tr.qualify td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.team-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- Partidos ---------- */
.match {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.match:last-child { border-bottom: none; }
.match .team { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.match .team.home { text-align: right; }
.match .team.win { color: var(--accent); }
.match .score {
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 18px;
  min-width: 90px;
  text-align: center;
}
.match .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); text-align: center; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.live { background: var(--live); color: #fff; border-color: var(--live); animation: pulse 1.5s infinite; }
.badge.done { background: var(--ok); color: #fff; border-color: var(--ok); }
@keyframes pulse { 50% { opacity: 0.6; } }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal { background: var(--card); border-radius: 12px; padding: 20px; width: 100%; max-width: 560px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #111318;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  z-index: 100;
  max-width: 90vw;
}
.toast.error { background: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 24px; }
.leader-list { list-style: none; margin: 0; padding: 0; }
.leader-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.leader-list li:first-child { font-weight: 700; }
.leader-list .val { font-family: "Arial Black", Arial, sans-serif; }

/* ---------- Llave de eliminación ---------- */
.bracket { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.bracket .round { min-width: 220px; display: flex; flex-direction: column; justify-content: space-around; gap: 12px; }
.bracket .round h3 { text-align: center; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.bracket .slot { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.bracket .slot div { display: flex; justify-content: space-between; padding: 6px 10px; gap: 8px; }
.bracket .slot div + div { border-top: 1px solid var(--border); }
.bracket .slot .win { font-weight: 700; color: var(--accent); }

@media (max-width: 600px) {
  .container { padding: 10px; }
  .card { padding: 12px; }
  .match .score { min-width: 70px; font-size: 16px; }
  .hide-sm { display: none; }
  th, td { padding: 8px 6px; }
}
