:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --grid: #d9dde7;
  --text: #0f172a;
  --muted: #475569;
  --accent: #fb5904;
  --header: #eef2ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Ubuntu,
    Cantarell,
    "Helvetica Neue",
    Arial,
    "Noto Sans",
    "Apple Color Emoji",
    "Segoe UI Emoji";
  color: var(--text);

  /* fundo com leve gradiente (charme) */
  background:
    radial-gradient(
      1200px 600px at 20% 0%,
      rgba(251, 89, 4, 0.08),
      transparent 55%
    ),
    radial-gradient(
      900px 500px at 90% 10%,
      rgba(47, 209, 255, 0.1),
      transparent 55%
    ),
    #f6f8fc;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--grid);
}

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px;
}

/* =========================
   NAV (desktop)
   ========================= */

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

a.tab {
  text-decoration: none;
  color: var(--text);
}

/* base dos tabs */
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d7deea;
  background: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  color: #0f172a;
  transition:
    transform 0.08s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  border-color: #c6d1e4;
}

.tab.active {
  border-color: var(--accent);
  box-shadow: 0 12px 22px rgba(251, 89, 4, 0.18);
}

/* diferencia visual leve */
.tab--club {
  letter-spacing: 0.2px;
}
.tab--view {
  background: #f7f9fc;
}

/* =========================
   CARDS / CONTROLS
   ========================= */

.card {
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: 14px;
  overflow: hidden;
}

.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(#fff, #fbfbff);
  border-bottom: 1px solid var(--grid);
  font-weight: 800;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

select,
button,
input {
  font: inherit;
  border: 1px solid var(--grid);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

button {
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 800;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--grid);
  font-size: 12px;
  background: #fff;
}

.legend {
  padding: 12px 14px;
  line-height: 1.5;
}

.legend p {
  margin: 0 0 8px 0;
}

/* =========================
   TABELA: Excel feel
   - sticky header
   - 2 colunas fixas (P e EQUIPE)
   ========================= */

.table-wrap {
  width: 100%;
  overflow: auto;
  max-height: 72vh;
}

/* caixa da tabela com sombra suave */
#tableWrap,
.tableWrap {
  background: #fff;
  border: 1px solid #d7deea;
  border-radius: 14px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.06);
  padding: 14px;
}

table.sheet {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: max-content;
}

table.sheet th,
table.sheet td {
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
}

/* cabeçalho sticky */
.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f7f9fc;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  text-align: left;
}

/* zebra leve (não destrói heatmap, só dá textura) */
.sheet tbody tr:nth-child(even) td {
  background-image: linear-gradient(
    rgba(15, 23, 42, 0.02),
    rgba(15, 23, 42, 0.02)
  );
}

/* hover de linha (sem destruir heatmap: só outline) */
.sheet tbody tr:hover td {
  outline: 2px solid rgba(47, 209, 255, 0.25);
  outline-offset: -2px;
}

/* 1ª coluna: P */
.sheet th:first-child,
.sheet td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #fff;
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.06);
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  text-align: center;
  font-weight: 800;
}

/* 2ª coluna: EQUIPE (depende da largura do P) */
.sheet th:nth-child(2),
.sheet td:nth-child(2) {
  position: sticky;
  left: 44px;
  z-index: 4;
  background: #fff;
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.06);
}

/* ranking */
.sheet td.rank {
  font-weight: 600;
}
.sheet td.rank.top1 {
  color: #0d6efd;
  font-weight: 800;
}
.sheet td.rank.top2 {
  color: #198754;
  font-weight: 800;
}
.sheet td.rank.top3 {
  color: #fd7e14;
  font-weight: 800;
}

/* célula equipe com escudo */
.team-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-crest {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: 0 0 22px;
  filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.18));
}

.rownum {
  color: var(--muted);
}

/* =========================
   MOBILE NAV (FIXO)
   - VIEWS: 3 linhas (ATA / DEF / XG)
   - CLUBES: 4 linhas x 5 colunas
   ========================= */

@media (max-width: 520px) {
  /* centraliza navs */
  #navViews,
  #navClubs {
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
  }

  /* VIEWS: 3 linhas fixas por largura/flex + order */
  #navViews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 460px;
  }

  #navViews .tab {
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.05;
    padding: 7px 8px;
  }

  /* ATA e DEF: 3 por linha */
  #navViews .tab.tab--view[href*="ata"],
  #navViews .tab.tab--view[href*="def"] {
    flex: 0 0 calc((100% - 16px) / 3);
  }

  /* XG/XGS: 4 por linha */
  #navViews .tab.tab--view[href*="xg"] {
    flex: 0 0 calc((100% - 24px) / 4);
    font-size: 11px;
    padding: 6px 6px;
  }

  /* ordem das linhas */
  #navViews .tab.tab--view {
    order: 50;
  }
  #navViews .tab.tab--view[href*="ata"] {
    order: 10;
  }
  #navViews .tab.tab--view[href*="def"] {
    order: 20;
  }
  #navViews .tab.tab--view[href*="xg"] {
    order: 30;
  }

  /* CLUBES: 5 colunas (20 => 4 linhas) */
  #navClubs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    max-width: 460px;
    margin-top: 10px;
  }

  #navClubs .tab {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 7px 8px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
  }
}

/* =========================
   Admin — Modal adversário
   ========================= */
.op-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
}
.op-modal.is-open {
  display: block;
}
.op-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.op-modal__panel {
  position: absolute;
  left: 50%;
  top: 7vh;
  transform: translateX(-50%);
  width: min(900px, calc(100% - 24px));
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #d7deea;
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.25);
}
.op-modal__head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5eaf3;
  background: #fff;
}
.op-modal__title {
  font-weight: 900;
}
.op-modal__close {
  border: 1px solid #d7deea;
  background: #fff;
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

.op-modal__grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

@media (max-width: 720px) {
  .op-modal__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.op-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid #d7deea;
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}
.op-btn:hover {
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}
.op-btn img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.14));
}

/* botão dentro da célula "Adversário" */
.cell-opick {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid #d7deea;
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}
.cell-opick img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}
