* { box-sizing: border-box; }
:root {
  --bg: #0f1216;
  --surface: #181c22;
  --surface-2: #1f242c;
  --border: #2a313b;
  --text: #e6e8eb;
  --text-2: #9aa3ad;
  --text-3: #6b7380;
  --accent: #4c9aff;
  --success: #3fb950;
  --danger: #f85149;
  --warning: #d29922;
  --gold: #f2c94c;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f5;
    --border: #e1e4e8;
    --text: #1a1d21;
    --text-2: #57606a;
    --text-3: #8c959f;
  }
}
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
h1 { font-size: 20px; font-weight: 600; margin: 0; }
.sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select, button {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500; }
button.primary:disabled { opacity: 0.55; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text-2); }
button:hover:not(:disabled) { filter: brightness(1.15); }
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.stat-label { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.stat-value.small { font-size: 15px; font-weight: 500; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; margin-bottom: 14px;
}
.card-header {
  padding: 10px 14px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 9px 8px; text-align: center; font-weight: 500;
  color: var(--text-2); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px;
  white-space: nowrap;
}
thead th.left { text-align: left; padding-left: 14px; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th.sort-active { color: var(--accent); }
thead th.sort-active::after { margin-left: 3px; font-size: 10px; }
thead th.sort-asc::after { content: '↑'; }
thead th.sort-desc::after { content: '↓'; }
tbody td { padding: 9px 8px; text-align: center; border-bottom: 1px solid var(--border); }
tbody td.left { text-align: left; padding-left: 14px; font-weight: 500; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.rank-1 td { background: linear-gradient(90deg, rgba(242,201,76,0.12), transparent 40%); }
.rank-1 .rank-num { color: var(--gold); font-weight: 700; }
.rank-2 .rank-num { color: #c0c0c0; font-weight: 600; }
.rank-3 .rank-num { color: #cd7f32; font-weight: 600; }
.wr-high { color: var(--success); font-weight: 600; }
.wr-low { color: var(--danger); font-weight: 600; }
.diff-pos { color: var(--success); }
.diff-neg { color: var(--danger); }
.error-cell { color: var(--text-3); font-size: 12px; font-style: italic; }
.loading-row td { color: var(--text-3); }
.spinner {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--text-3); border-top-color: transparent;
  animation: spin 0.8s linear infinite; vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status-bar {
  margin-top: 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; font-size: 12px; color: var(--text-2);
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.progress {
  height: 3px; background: var(--surface-2); border-radius: 2px;
  overflow: hidden; flex: 1; min-width: 150px;
}
.progress-bar { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s; }
details summary {
  cursor: pointer; padding: 10px 14px; list-style: none;
  background: var(--surface-2); border-radius: 8px; font-weight: 500;
  user-select: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '▸ '; color: var(--text-2); display: inline-block; transition: transform 0.2s; }
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { margin-bottom: 8px; }
.error-banner {
  background: rgba(248,81,73,0.1); border: 1px solid rgba(248,81,73,0.3);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 12px; color: var(--danger); display: none;
}
.error-banner.show { display: block; }
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; margin-bottom: 14px;
}
.chart-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.chart-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: 0.3px;
}
.chart-maximize-btn {
  background: transparent; border: none; color: var(--text-3);
  cursor: pointer; padding: 3px 5px; border-radius: 4px;
  display: flex; align-items: center; line-height: 1;
}
.chart-maximize-btn:hover { color: var(--text); background: var(--surface-2); }
.info-banner {
  background: rgba(76,154,255,0.08); border: 1px solid rgba(76,154,255,0.25);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 12px; color: var(--accent); display: none;
}
.info-banner.show { display: block; }
.chart-modal {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.72);
  align-items: center; justify-content: center;
}
.chart-modal.open { display: flex; }
.chart-modal-inner {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px;
  width: min(95vw, 1200px); padding: 16px 18px;
}
.chart-modal-hdr {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.chart-modal-title {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.3px;
}
.chart-modal-close {
  background: transparent; border: 1px solid var(--border); color: var(--text-2);
  border-radius: 6px; cursor: pointer; padding: 4px 8px;
  display: flex; align-items: center; line-height: 1;
}
.chart-modal-close:hover { color: var(--text); background: var(--surface-2); }
.rank-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.2px;
  padding: 1px 5px; border-radius: 3px; vertical-align: middle; margin-right: 5px;
  white-space: nowrap;
}
.rank-1 .rank-badge, .rank-badge.rt-1 { background: rgba(145,142,141,.18); color: #918E8D; border: 1px solid rgba(145,142,141,.3); }
.rank-badge.rt-2 { background: rgba(61,138,120,.18);  color: #3DAA8E; border: 1px solid rgba(61,138,120,.3);  }
.rank-badge.rt-3 { background: rgba(79,128,202,.18);  color: #5B97E0; border: 1px solid rgba(79,128,202,.3);  }
.rank-badge.rt-4 { background: rgba(122,199,123,.18); color: #6DC96E; border: 1px solid rgba(122,199,123,.3); }
.rank-badge.rt-5 { background: rgba(139,95,176,.18);  color: #A86ED0; border: 1px solid rgba(139,95,176,.3);  }
.rank-badge.rt-6 { background: rgba(113,167,204,.18); color: #71A7CC; border: 1px solid rgba(113,167,204,.3); }
.rank-badge.rt-7 { background: rgba(126,182,229,.18); color: #7EB6E5; border: 1px solid rgba(126,182,229,.3); }
.rank-badge.rt-8 { background: rgba(201,127,59,.18);  color: #E0943A; border: 1px solid rgba(201,127,59,.3);  }
.lm-win  { color: var(--success); font-weight: 600; }
.lm-lose { color: var(--danger);  font-weight: 600; }
.streak-w { color: var(--success); font-weight: 600; font-size: 11px; white-space: nowrap; }
.streak-l { color: var(--danger);  font-weight: 600; font-size: 11px; white-space: nowrap; }
.most-active-icon { font-size: 11px; vertical-align: middle; margin-right: 2px; cursor: default; }
.lm-date { color: var(--text-2); font-size: 11px; }
.lm-link { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.lm-link:hover .lm-date { color: var(--accent); }
.lm-ext { vertical-align: middle; color: var(--text-3); }
.lm-link:hover .lm-ext { color: var(--accent); }
.player-link { color: var(--text-3); vertical-align: middle; margin-left: 3px; }
.player-link:hover { color: var(--accent); }
@media (max-width: 600px) {
  thead th, tbody td { padding: 7px 4px; font-size: 11px; }
  thead th.left, tbody td.left { padding-left: 8px; }
  .hide-sm { display: none; }
  h1 { font-size: 17px; }
}

/* ===================== ABAS + IMP ===================== */
.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 9px 14px; font-size: 13px; font-weight: 500;
  color: var(--text-2); cursor: pointer; margin-bottom: -1px;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.view { display: none; }
.view.active { display: block; }

.pct-mini { color: var(--text-3); font-size: 10.5px; }

/* v10.2/v10.3 — memoria de calculo: abre ao CLICAR NA LINHA do membro */
.mem-row { display: none; }
.mem-row.aberta { display: table-row; }
.mem-row td { padding: 2px 8px 8px; background: var(--bg); }
tr.tem-mem { cursor: pointer; }
tr.tem-mem:hover td { background: rgba(76,154,255,0.06); }
.mem-clip { font-size: 10px; margin-left: 4px; opacity: 0.55; }
.mem-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; padding: 4px 6px; }
.mem-cols ul { list-style: none; margin: 2px 0 0; padding: 0; }
.mem-cols li { font-size: 11.5px; padding: 1.5px 0; }
.mem-tit { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.mem-det { color: var(--text-3); font-size: 10.5px; }
.mem-extra {
  font-size: 11.5px; padding: 5px 6px 3px; color: var(--text-2);
  border-top: 1px dashed var(--border); margin-top: 3px;
}
@media (max-width: 560px) { .mem-cols { grid-template-columns: 1fr; } }

/* v10.6 — legenda dos dois eixos + ordenacao clicavel */
.legenda-eixos {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11.5px; color: var(--text-2);
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; margin: 2px 0 10px;
}
.lg-imp { color: var(--gold); }
.lg-forma { color: var(--success); }
.legenda-selos {
  flex-direction: row; flex-wrap: wrap; gap: 5px 18px;
  align-items: center; margin-bottom: 12px;
}
.legenda-selos .badge { margin-left: 0; }
th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
th.th-sort:hover { color: var(--text-1); }
th.th-on { color: var(--text-1); }

/* v10.3 — "em observacao": membros com menos de 20 partidas, fora do ranking */
.obs-box {
  margin-top: 10px; padding: 8px 12px; border: 1px dashed var(--border);
  border-radius: 8px; font-size: 12px;
}
.obs-tit { color: var(--text-3); font-size: 11px; font-weight: 600; margin-bottom: 5px; }
.obs-item { display: inline-block; margin: 2px 14px 2px 0; white-space: nowrap; }

.imp-explica {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px; font-size: 12.5px; color: var(--text-2);
  line-height: 1.55; margin-bottom: 14px;
}
.imp-explica b, .imp-explica strong { color: var(--text); }
.imp-aviso-inline {
  display: block; margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed var(--border); color: var(--text-3); font-size: 12px;
}

/* --- cartao de partida --- */
.pt {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 10px; overflow: hidden;
}
.pt-hdr {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; cursor: pointer; user-select: none;
}
.pt-hdr:hover { background: var(--surface-2); }
.pt-data { font-size: 12.5px; color: var(--text-2); min-width: 108px; }
.pt-dur  { font-size: 12px; color: var(--text-3); }
.pt-res  { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; }
.pt-res.w { background: rgba(63,185,80,0.15); color: var(--success); }
.pt-res.l { background: rgba(248,81,73,0.15); color: var(--danger); }
.pt-awards { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.pt-aw { font-size: 12.5px; white-space: nowrap; }
.pt-aw .nome { color: var(--text); font-weight: 500; }
.pt-aw .heroi { color: var(--text-3); font-size: 11.5px; }
.pt-toggle { color: var(--text-3); font-size: 11px; }

.pt-body { display: none; border-top: 1px solid var(--border); }
.pt.open .pt-body { display: block; }
.pt.open .pt-toggle { transform: rotate(180deg); }
.pt-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pt-tbl th {
  text-align: left; padding: 7px 10px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--text-3); font-weight: 600;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.pt-tbl td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.pt-tbl tr:last-child td { border-bottom: none; }
.pt-tbl tr.membro td { background: rgba(76,154,255,0.06); }
.pt-tbl tr.membro td:nth-child(2) { font-weight: 600; }
.pt-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.pt-tbl .externo { color: var(--text-3); }

.imp-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.imp-pos { color: var(--success); }
.imp-neg { color: var(--danger); }
.imp-zero { color: var(--text-2); }
.badge {
  font-size: 9.5px; font-weight: 700; padding: 1.5px 5px; border-radius: 4px;
  margin-left: 5px; letter-spacing: 0.3px; vertical-align: 1px;
}
.badge.mvp    { background: rgba(242,201,76,0.18); color: var(--gold); }
.badge.ancora { background: rgba(76,154,255,0.18); color: var(--accent); }
.badge.vsmvp  { background: rgba(63,185,80,0.18); color: var(--success); }
.badge.derrota{ background: rgba(210,153,34,0.18); color: var(--warning); }
.badge.topcore{ background: rgba(219,88,88,0.16);  color: #d9777c; }
.badge.topsup { background: rgba(63,185,150,0.16); color: #3fb996; }
.pos-tag {
  font-size: 10px; color: var(--text-3); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 4px;
}

/* --- bloco por jogador --- */
.jg { background: var(--surface); border: 1px solid var(--border);
      border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.jg-hdr { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
          padding: 11px 14px; border-bottom: 1px solid var(--border); }
.jg-nome { font-size: 14.5px; font-weight: 600; }
.jg-meta { font-size: 12px; color: var(--text-2); }
.jg-imp  { margin-left: auto; font-size: 13px; }
.jg-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.jg-tbl th { text-align: left; padding: 6px 10px; font-size: 10.5px;
             text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-3);
             font-weight: 600; border-bottom: 1px solid var(--border); }
.jg-tbl td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.jg-tbl tr:last-child td { border-bottom: none; }
.jg-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.jg-bar { display: inline-block; height: 8px; border-radius: 2px; min-width: 2px; }
.jg-bar.pos { background: var(--success); }
.jg-bar.neg { background: var(--danger); }

@media (max-width: 640px) {
  .pt-awards { margin-left: 0; width: 100%; }
  .pt-tbl th:nth-child(6), .pt-tbl td:nth-child(6),
  .pt-tbl th:nth-child(7), .pt-tbl td:nth-child(7) { display: none; }
  .jg-tbl th:nth-child(5), .jg-tbl td:nth-child(5) { display: none; }
}

/* --- como o IMP e calculado (metodo) --- */
.metodo { margin-top: 14px; padding: 16px 18px; }
.metodo h3 { margin: 0 0 6px; font-size: 15px; }
.metodo .met-sub { margin: 0 0 12px; font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.metodo details { border: 1px solid var(--border); border-radius: 8px;
                  margin-bottom: 8px; background: var(--surface-2); overflow: hidden; }
.metodo summary { cursor: pointer; padding: 10px 13px; font-size: 13px; font-weight: 600;
                  list-style: none; display: flex; align-items: center; gap: 8px; }
.metodo summary::before { content: '▸'; color: var(--text-3); font-size: 11px; transition: transform .15s; }
.metodo details[open] summary::before { transform: rotate(90deg); }
.metodo summary::-webkit-details-marker { display: none; }
.metodo summary:hover { color: var(--accent); }
.metodo .met-body { padding: 2px 14px 12px; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.metodo .met-body p { margin: 8px 0; }
.metodo .met-body b { color: var(--text); }
.metodo .met-body ul { margin: 8px 0; padding-left: 18px; }
.metodo .met-body li { margin-bottom: 7px; }
.met-form { background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
            padding: 10px 12px; font-size: 12px; line-height: 1.7; overflow-x: auto;
            color: var(--text); margin: 8px 0; }
.met-tbl { width: 100%; border-collapse: collapse; font-size: 12px; margin: 10px 0;
           font-variant-numeric: tabular-nums; }
.met-tbl th { text-align: right; padding: 5px 8px; font-size: 10px; text-transform: uppercase;
              letter-spacing: .4px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.met-tbl th.left, .met-tbl td.left { text-align: left; }
.met-tbl td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.met-tbl td.num { text-align: right; }
.met-tbl tr:last-child td { border-bottom: none; }

/* --- medalha oficial de rank (rank_icons/) --- */
.medal { position: relative; display: inline-block; width: 27px; height: 27px;
         vertical-align: -8px; margin-right: 5px; }
.medal img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.medal-sm { width: 21px; height: 21px; vertical-align: -6px; margin-right: 4px; }
.medal-lb { font-size: 10px; color: var(--text-3); margin-right: 5px;
            font-variant-numeric: tabular-nums; }

/* --- Aegis (trofeu do MVP) --- */
.aegis { height: 15px; width: auto; border-radius: 3px; vertical-align: -3px; }
.badge .aegis { height: 11px; vertical-align: -2px; margin-right: 3px; border-radius: 2px; }
.stat-label .aegis { height: 17px; vertical-align: -4px; }
.met-origem { font-size: 10.5px; color: var(--text-3); font-weight: 400; }

/* --- lado Radiant / Dire nas partidas --- */
.pt-tbl tr.time-rad td:first-child  { box-shadow: inset 3px 0 0 rgba(63,185,80,.65); }
.pt-tbl tr.time-dire td:first-child { box-shadow: inset 3px 0 0 rgba(248,81,73,.65); }
.dot-rad  { color: #3fb950; }
.dot-dire { color: #f85149; }
.lado-venc { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.lado-venc.rad  { color: #3fb950; background: rgba(63,185,80,.12); }
.lado-venc.dire { color: #f85149; background: rgba(248,81,73,.12); }

/* --- rolagem do "por jogador": mostra ~10 de 20 --- */
.jg-scroll { max-height: 360px; overflow-y: auto; }
.jg-scroll .jg-tbl thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
