/* ==========================================================================
   DASHBOARD DE ESTATÍSTICAS — página separada (/dashboard.html)
   Reaproveita as variáveis de tema do styles.css (cores, fontes, sombra).
   ========================================================================== */

/* A pagina do dashboard PRECISA rolar: o styles.css trava html/body (height:100%;
   overflow:hidden) para o jogo em tela cheia. Sem isto o dashboard aparece cortado. */
html.dash-doc {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

body.dash-body {
  height: auto;
  min-height: 100%;
  /* Precisa ser "visible": qualquer overflow no <body> o torna o container de
     rolagem e quebra o cabecalho sticky (.dash-head). Quem rola e o <html>. */
  overflow: visible;
  user-select: text;
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(18, 64, 143, .55), transparent 72%),
    radial-gradient(900px 560px at 92% 4%, rgba(11, 157, 78, .22), transparent 70%),
    radial-gradient(1000px 700px at 50% 108%, rgba(227, 54, 47, .18), transparent 72%),
    linear-gradient(180deg, #05060f, #080b18 60%, #05060f);
  background-attachment: fixed;
}

/* ------------------------------- CABEÇALHO ------------------------------- */

.dash-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(12px, 3vw, 28px);
  background: linear-gradient(180deg, rgba(8, 11, 24, .96), rgba(8, 11, 24, .78));
  border-bottom: 1px solid rgba(120, 145, 200, .22);
  backdrop-filter: blur(8px);
}

.dash-back {
  flex: 0 0 auto;
  color: var(--papel);
  text-decoration: none;
  font-weight: 800;
  font-size: 14px;
  padding: 7px 13px;
  border-radius: 11px;
  border: 2px solid rgba(120, 145, 200, .38);
  background: rgba(255, 255, 255, .05);
  transition: transform .1s ease, background .15s ease;
}
.dash-back:hover { background: rgba(255, 255, 255, .12); transform: translateX(-2px); }

.dash-logo {
  flex: 1 1 auto;
  margin: 0;
  text-align: center;
  font-family: var(--fonte-titulo);
  font-size: clamp(17px, 3.4vw, 30px);
  letter-spacing: 1.5px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-logo .dash-x { color: #8899bb; margin: 0 .22em; -webkit-text-stroke: 0; font-size: .8em; }

.dash-head-right { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.dash-src {
  font-size: 12px;
  font-weight: 700;
  color: #b9c4de;
  background: rgba(120, 145, 200, .14);
  border: 1px solid rgba(120, 145, 200, .28);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.dash-refresh {
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  color: var(--papel);
  background: rgba(120, 145, 200, .16);
  border: 1px solid rgba(120, 145, 200, .3);
  border-radius: 11px;
  padding: 7px 11px;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.dash-refresh:hover { background: rgba(120, 145, 200, .3); transform: rotate(-40deg); }

/* --------------------------------- LAYOUT -------------------------------- */

.dash {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(14px, 2.6vw, 26px) clamp(12px, 3vw, 28px) 60px;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.2vw, 22px);
}

.panel-card,
.dash-bar-card,
.kpi,
.dcard,
.plcard {
  background: linear-gradient(180deg, rgba(23, 30, 56, .92), rgba(14, 19, 38, .92));
  border: 1px solid rgba(120, 145, 200, .22);
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .05);
}

/* ------------------------------- FILTROS --------------------------------- */

.dash-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
  padding: 14px 16px;
  background: rgba(12, 16, 32, .8);
  border: 1px solid rgba(120, 145, 200, .2);
  border-radius: 16px;
}
.df { display: flex; flex-direction: column; gap: 5px; min-width: 132px; flex: 1 1 132px; }
.df > span { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: #93a2c4; }
.df select {
  font-family: var(--fonte);
  font-weight: 700;
  font-size: 13.5px;
  background: #141a30;
  color: var(--papel);
  border: 2px solid #3b4467;
  border-radius: 10px;
  padding: 7px 8px;
  cursor: pointer;
  width: 100%;
}
.df select:focus { outline: 2px solid var(--amarelo); outline-offset: 1px; }
.df-clear {
  font-family: var(--fonte);
  font-weight: 800;
  font-size: 13.5px;
  color: var(--papel);
  background: rgba(227, 54, 47, .22);
  border: 2px solid rgba(227, 54, 47, .5);
  border-radius: 11px;
  padding: 8px 14px;
  cursor: pointer;
  align-self: flex-end;
  transition: background .15s ease;
}
.df-clear:hover { background: rgba(227, 54, 47, .4); }

/* ------------------------------- STATUS --------------------------------- */

.dash-status {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 13.5px;
  font-weight: 700;
  color: #c3cde5;
  padding: 11px 15px;
  border-radius: 13px;
  background: rgba(18, 64, 143, .18);
  border: 1px solid rgba(120, 145, 200, .24);
}
.dash-status.is-error { background: rgba(227, 54, 47, .16); border-color: rgba(227, 54, 47, .45); color: #ffd9d5; }
.dash-status.is-loading { color: #dfe6f7; }
.ds-dot { width: 9px; height: 9px; border-radius: 50%; background: #31d07a; box-shadow: 0 0 10px #31d07a; flex: 0 0 auto; }
.ds-spin {
  width: 15px; height: 15px; border-radius: 50%; flex: 0 0 auto;
  border: 2.5px solid rgba(255, 255, 255, .25);
  border-top-color: var(--amarelo);
  animation: dash-spin .8s linear infinite;
}
@keyframes dash-spin { to { transform: rotate(360deg); } }
.ds-btn {
  font-family: var(--fonte); font-weight: 800; font-size: 13px;
  color: var(--tinta); background: var(--amarelo);
  border: 2px solid rgba(0, 0, 0, .4); border-radius: 9px; padding: 5px 11px; cursor: pointer;
}

/* -------------------------- BARRA DE VITÓRIAS ---------------------------- */

.dash-bar-card { padding: clamp(14px, 2.4vw, 22px); }
.db-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.db-head h2 { margin: 0; font-family: var(--fonte-titulo); font-size: clamp(17px, 2.6vw, 25px); letter-spacing: 1px; color: var(--amarelo); }
.db-total { font-size: 13.5px; font-weight: 800; color: #c3cde5; }
.db-total b { color: #fff; font-size: 1.1em; }

.db-bar {
  display: flex;
  gap: 6px;
  height: clamp(38px, 7vw, 62px);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, .05);
}
.db-seg {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  transition: flex-grow .6s cubic-bezier(.22, .9, .28, 1), filter .2s ease;
  filter: saturate(.75) brightness(.86);
}
.db-seg.is-ahead { filter: saturate(1.1) brightness(1.06); box-shadow: inset 0 0 18px rgba(255, 255, 255, .22); }
.db-pct {
  font-family: var(--fonte-titulo);
  font-size: clamp(15px, 2.4vw, 22px);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55);
  letter-spacing: 1px;
}
.db-bar-card.is-empty .db-bar { opacity: .45; }

.db-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; }
.db-leg { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: #ccd6ee; flex-wrap: wrap; }
.db-leg b { color: #fff; }
.db-leg small { color: #8b98b8; font-size: 11.5px; }
.db-dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; display: inline-block; }
.db-leg-nome { font-family: var(--fonte-titulo); letter-spacing: .6px; }
.db-note { margin: 10px 0 0; font-size: 12px; color: #8b98b8; line-height: 1.5; }

/* --------------------------------- KPIs ---------------------------------- */

.dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(146px, 1fr));
  gap: 12px;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 15px;
  position: relative;
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease;
}
.kpi::after {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--verde), var(--amarelo), var(--vermelho));
  opacity: .55;
}
.kpi:hover { transform: translateY(-3px); border-color: rgba(255, 214, 10, .45); }
.kpi-ico { font-size: 20px; line-height: 1; }
.kpi-num { font-family: var(--fonte-titulo); font-size: clamp(24px, 3.4vw, 34px); color: #fff; line-height: 1.05; letter-spacing: 1px; }
.kpi-rot { font-size: 13px; font-weight: 800; color: #d5deef; }
.kpi-sub { font-size: 11px; color: #8b98b8; }

/* ---------------------------- CARDS DE GRÁFICO --------------------------- */

.dash-grid2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: clamp(12px, 2vw, 18px); }
@media (max-width: 820px) { .dash-grid2 { grid-template-columns: 1fr; } }

.panel-card { padding: clamp(14px, 2.2vw, 20px); }
.panel-card > h3 {
  margin: 0 0 4px;
  font-family: var(--fonte-titulo);
  font-size: clamp(15px, 2.1vw, 19px);
  letter-spacing: .8px;
  color: var(--amarelo);
}
.panel-note { margin: 0 0 14px; font-size: 11.5px; color: #8b98b8; }
.chart { animation: dash-fade .35s ease both; }
@keyframes dash-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chart-vazio {
  display: flex; align-items: center; justify-content: center;
  min-height: 130px; text-align: center;
  color: #8b98b8; font-size: 13.5px; font-weight: 700;
  border: 2px dashed rgba(120, 145, 200, .24); border-radius: 14px; padding: 18px;
}

/* Barras horizontais */
.brow { display: grid; grid-template-columns: minmax(112px, 30%) 1fr auto; align-items: center; gap: 10px; margin-bottom: 10px; }
.brow-nome { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; color: #dde5f6; }
.brow-ava { font-style: normal; font-size: 14px; }
.chip-pro {
  font-style: normal; font-size: 9.5px; font-weight: 900; letter-spacing: .5px;
  background: rgba(255, 214, 10, .22); color: var(--amarelo);
  border: 1px solid rgba(255, 214, 10, .45); border-radius: 6px; padding: 1px 5px;
}
.brow-track { height: 20px; background: rgba(255, 255, 255, .07); border-radius: 8px; overflow: hidden; }
.brow-fill {
  display: block; height: 100%; width: var(--w, 0%);
  border-radius: 8px;
  transition: width .7s cubic-bezier(.22, .9, .28, 1);
  min-width: 3px;
}
.brow-val { font-family: var(--fonte-titulo); font-size: 15px; color: #fff; min-width: 34px; text-align: right; }

/* Rosca */
.svg-donut { width: 100%; max-width: 230px; height: auto; display: block; margin: 0 auto; }
.donut-arco { transition: stroke-dasharray .7s ease, opacity .18s ease; cursor: pointer; }
.donut-arco:hover { opacity: .82; }
.donut-num { text-anchor: middle; font-family: var(--fonte-titulo); font-size: 25px; fill: #fff; }
.donut-rot { text-anchor: middle; font-size: 9.5px; font-weight: 800; fill: #93a2c4; letter-spacing: .4px; }
.chart-legend { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.dleg { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ccd6ee; }
.dleg b { color: #fff; margin-left: auto; }
.dleg small { color: #8b98b8; }

/* ---------------------- PAINEL DOS PERSONAGENS --------------------------- */

.dash-chars > h3, .dash-platforms > h3 {
  margin: 0 0 12px;
  font-family: var(--fonte-titulo);
  font-size: clamp(16px, 2.3vw, 21px);
  letter-spacing: .8px;
  color: var(--amarelo);
}
.dc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(238px, 1fr)); gap: 14px; }
.dcard { padding: 15px 15px 12px; border-top: 4px solid var(--cor, #8899bb); }
.dcard-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dcard-ava {
  font-size: 20px; width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(120, 145, 200, .28);
  border-radius: 12px;
}
.dcard-head b { font-family: var(--fonte-titulo); font-size: 15px; letter-spacing: .6px; }
.dcard-bar { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.dcard-bar > span {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--cor), var(--cor-clara));
  transition: width .7s cubic-bezier(.22, .9, .28, 1);
}
.dcard-taxa { margin: 8px 0 10px; font-size: 12.5px; color: #bcc7e2; }
.dcard-taxa b { font-size: 15px; color: #fff; }
.dcard-stats { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.dcard-stats li { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: #aeb9d6; padding: 2px 0; border-bottom: 1px dashed rgba(120, 145, 200, .16); }
.dcard-stats li:last-child { border-bottom: 0; }
.dcard-stats b { color: #fff; }
.dcard-mini { margin-top: 10px; }
.dcard-mini small { display: block; font-size: 10.5px; color: #8b98b8; margin-top: 2px; }
.svg-mini { width: 100%; height: 44px; display: block; }
.mini-area { fill: rgba(255, 255, 255, .1); }
.mini-linha { fill: none; stroke: var(--cor, #8899bb); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.dcard-semserie { color: #6f7c9c; }

/* --------------------------- EVOLUÇÃO (linhas) --------------------------- */

.svg-line { width: 100%; height: auto; display: block; touch-action: pan-y; }
.grid-line { stroke: rgba(120, 145, 200, .2); stroke-width: 1; stroke-dasharray: 4 6; }
.grid-rot { fill: #8b98b8; font-size: 11px; font-weight: 700; text-anchor: end; }
.grid-rot-x { text-anchor: middle; }
.linha { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.pt { transition: r .15s ease; }
.pt:hover { r: 6; }
.guia { stroke: rgba(255, 255, 255, .5); stroke-width: 1.5; stroke-dasharray: 3 4; }

/* ---------------------------- POR PLATAFORMA ----------------------------- */

.dp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr)); gap: 14px; }
.plcard { padding: 15px; }
.plcard-desktop { border-left: 4px solid var(--azul-claro); }
.plcard-mobile { border-left: 4px solid var(--roxo); }
.plcard-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.plcard-ico {
  font-size: 20px; width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 12px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(120, 145, 200, .28);
}
.plcard-head b { font-family: var(--fonte-titulo); font-size: 15px; letter-spacing: .5px; }
.plcard-head small { display: block; font-size: 11px; color: #8b98b8; }
.plcard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plcard-grid > div { background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 7px 8px; display: flex; flex-direction: column; gap: 1px; }
.plcard-grid span { font-size: 10.5px; color: #93a2c4; font-weight: 700; }
.plcard-grid b { font-family: var(--fonte-titulo); font-size: 17px; color: #fff; }
.plcard-grid b.ok { color: #58e08e; }
.plcard-grid b.ruim { color: #ff8a7d; }
.plcard-bar { height: 9px; border-radius: 6px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 12px; }
.plcard-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--verde), var(--amarelo)); transition: width .7s ease; }

/* --------------------------------- RODAPÉ -------------------------------- */

.dash-foot { margin: 4px 0 0; font-size: 11.5px; line-height: 1.6; color: #7d89a8; }

/* -------------------------------- TOOLTIP -------------------------------- */

.dash-tip {
  position: fixed;
  z-index: 60;
  max-width: 260px;
  pointer-events: none;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.45;
  color: #eef2fb;
  background: rgba(9, 12, 24, .96);
  border: 1px solid rgba(255, 214, 10, .45);
  border-radius: 11px;
  padding: 8px 11px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .55);
}
.dash-tip .db-dot { margin-right: 4px; }

/* ------------------------------ RESPONSIVO ------------------------------- */

@media (max-width: 640px) {
  .dash-head { flex-wrap: wrap; gap: 8px; }
  .dash-logo { order: -1; flex-basis: 100%; }
  .dash-src { font-size: 11px; padding: 3px 9px; }
  .kpi-num { font-size: 26px; }
  .brow { grid-template-columns: minmax(88px, 38%) 1fr auto; }
  .plcard-grid { grid-template-columns: repeat(2, 1fr); }
  .dcard-stats li { font-size: 12px; }
}

/* Acessibilidade: respeita "reduzir animações". */
@media (prefers-reduced-motion: reduce) {
  .db-seg, .brow-fill, .dcard-bar > span, .plcard-bar > span, .donut-arco, .chart { transition: none !important; animation: none !important; }
}

/* ----------------------- TOP 100 (apoiadores) ----------------------- */
.dash-apoio .top-stats { margin-bottom: 12px; }
.dash-apoio .top-list { margin: 0; }
.dash-apoio-note { margin: 12px 0 0; font-size: 13px; color: #a9b3cc; text-align: center; }
