/* dash.css — dashboard do painel (pagina_ml). Só usa os tokens de tokens.css. */
.dash { display: flex; flex-direction: column; gap: 14px; }
.dash-muted { color: var(--ink-3); font-size: 10.5px; }

/* filtros */
.dash-filtros { padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.dash-filtros-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dash-seg .seg-btn.active { background: var(--overlay); color: var(--ink); border-color: var(--line-strong); }
.dash-datas { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2); }
.dash-datas input, .dash-sel select { background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 12px; outline: none; max-width: 260px; }
.dash-datas input:focus, .dash-sel select:focus { border-color: var(--focus); }
.dash-sel { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-3); }
.dash-live { margin-left: auto; font-size: 10.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.dash-live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #35d07f; box-shadow: 0 0 0 0 rgba(53, 208, 127, .5); animation: dash-pulse 2s infinite; }
@keyframes dash-pulse { 0% { box-shadow: 0 0 0 0 rgba(53, 208, 127, .5); } 70% { box-shadow: 0 0 0 7px rgba(53, 208, 127, 0); } 100% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0); } }
.dash-periodo-txt { margin-left: auto; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dash-seg { flex: 0 1 auto; min-width: 0; }
@media (max-width: 700px) {
  .dash-filtros { padding: 10px 12px; }
  .dash-sel { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .dash-sel select { flex: 1; min-width: 0; max-width: none; width: 100%; }
  .dash-sel span { flex: none; }
  .dash-live, .dash-periodo-txt { flex-basis: 100%; margin-left: 0; }
  .dash-filtros-row .btn-mini { flex-basis: 100%; }
  .dash-datas { flex-wrap: wrap; }
  .dash-datas input { flex: 1; min-width: 0; }
}

/* tiles */
.dash-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dash .tile .value { font-size: clamp(20px, 2vw, var(--fs-metric)); }
@media (max-width: 1100px) { .dash-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dash .tile { padding: 12px 14px; }
  .dash .tile .value { font-size: clamp(18px, 5.5vw, 26px); }
  /* 5 tiles em 2 colunas: o último ocupa a linha inteira em vez de ficar órfão */
  .dash-tiles > .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* funil */
.dash-funil-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 12px 14px 14px; }
@media (max-width: 800px) { .dash-funil-grid { grid-template-columns: 1fr; } }
.dash-funil-col { background: var(--glass); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; }
.dash-funil-h { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.dash-funil-h b { color: var(--ink); font-weight: 600; }
.dash-funil-n { margin: 8px 0 6px; font-size: 12px; color: var(--ink-3); }
.dash-funil-n b { font-size: 22px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-funil-bar { height: 5px; border-radius: 3px; background: var(--field); overflow: hidden; }
.dash-funil-bar i { display: block; height: 100%; background: linear-gradient(90deg, #7c3aed, #35d07f); border-radius: 3px; }
.dash-funil-f { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* gráfico — o SVG é desenhado na largura real do card (viewBox = px), então os textos
   ficam legíveis em qualquer tela; redesenha quando o card muda de largura. */
.dash-chart-wrap { position: relative; padding: 8px 10px 4px; min-height: 120px; }
.dash-svg { width: 100%; height: auto; display: block; }
.dash-grid { stroke: var(--line-soft); stroke-width: 1; shape-rendering: crispEdges; }
.dash-tick { fill: var(--ink-3); font-size: 10.5px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.dash-tick.is-r { fill: #35d07f; }
.dash-bar { fill: rgba(157, 78, 221, .45); transition: fill var(--t-fast) var(--ease); }
.dash-area { fill: #35d07f; opacity: .07; }
.dash-line { fill: none; stroke: #35d07f; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dash-dot { fill: #35d07f; stroke: var(--console); stroke-width: 1.5; }
.dash-hit { fill: transparent; cursor: default; }
.dash-hit:hover, .dash-hit.is-on { fill: rgba(255, 255, 255, .035); }
.dash-slot-on .dash-bar { fill: rgba(157, 78, 221, .8); }
.dash-chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: var(--fs-body-sm); pointer-events: none; }
.dash-tip { position: absolute; pointer-events: none; background: var(--overlay); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 11px; color: var(--ink-2); min-width: 150px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.dash-tip b { display: block; color: var(--ink); margin-bottom: 4px; }
.dash-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--ink-3); }
.dash-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.dash-legend .lg-ger { background: rgba(157, 78, 221, .6); }
.dash-legend .lg-apr { background: #35d07f; border-radius: 50%; }

/* tabelas */
.dash-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.dash-grid2 .table-card { display: flex; flex-direction: column; min-width: 0; }
.dash-grid2 .table-head { flex: none; }
/* 1ª coluna (produto / estado) encurta com reticências em vez de forçar rolagem horizontal */
.dash-grid2 table.domains { table-layout: auto; }
.dash-grid2 td:first-child { max-width: 0; width: 52%; }
.dash-grid2 .sale-name, .dash-grid2 .uf-nome { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-grid2 .uf-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dash-grid2 .uf-cell .uf-flag { margin-right: 0; }
.dash-grid2 .uf-cell .uf-badge { flex: none; }
.dash-grid2 .uf-cell .uf-nome { flex: 1; }
@media (max-width: 1000px) { .dash-grid2 { grid-template-columns: 1fr; } }
/* tela estreita: a tabela rola de lado, então a 1ª coluna precisa de largura mínima legível */
@media (max-width: 700px) { .dash-grid2 td:first-child, .dash-utm td:first-child { min-width: 150px; } }
.dash .table-head { flex-wrap: wrap; row-gap: 6px; }
.dash .table-head > span:first-child { white-space: nowrap; }
.dash tr.is-sel td { background: rgba(157, 78, 221, .12); }
.dash tbody tr[class=""], .dash tbody tr.is-sel { cursor: pointer; }
.dash tr.dash-group td { color: var(--ink-2); font-size: 11px; font-weight: 600; background: var(--glass); letter-spacing: .02em; }
.dash tr.is-best td { background: rgba(53, 208, 127, .08); }
.dash tr.is-best td:first-child { color: #35d07f; font-weight: 600; }
/* campanhas e criativos (UTM): fatia de vendas por linha + líder em destaque */
.dash-utm tbody tr { cursor: pointer; }
.dash-utm td:first-child, .dash-utm th:first-child { max-width: 0; width: 38%; min-width: 160px; }
.dash-utm .sale-name, .dash-utm .sale-mail { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-utm tr.is-best td:first-child { color: inherit; font-weight: inherit; }
.dash-utm tr.is-best td { background: rgba(53, 208, 127, .07); }
.dash-utm tr.is-best .sale-name { color: #35d07f; }
.dash-rank { white-space: nowrap; }
.dash-fraco { color: var(--watch); }
.dash-sku { font-size: 11px; padding: 2px 7px; margin-right: 4px; letter-spacing: .02em; user-select: all; }
.dash-utm td:first-child, .dash-utm th:first-child { width: 22%; }
.dash-utm td:nth-child(2) { white-space: nowrap; }
.dash-utm td:nth-child(3) { max-width: 0; width: 22%; min-width: 150px; }
.dash-medal { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 999px; background: rgba(53, 208, 127, .16); color: #35d07f; font-size: 10px; font-weight: 700; letter-spacing: .04em; vertical-align: 1px; }
.dash-share { display: inline-flex; align-items: center; gap: 8px; width: 150px; max-width: 100%; }
.dash-share i { display: block; flex: 1; height: 6px; border-radius: 3px; background: var(--field); overflow: hidden; }
.dash-share i b { display: block; height: 100%; border-radius: 3px; background: var(--iris); }
.dash-share .mono { flex: none; min-width: 42px; text-align: right; color: var(--ink-2); font-size: 11px; }
.dash-share.is-best i b { background: linear-gradient(90deg, #7c3aed, #35d07f); }
.dash-sort { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.dash-sort.is-on { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.uf-badge { display: inline-block; min-width: 26px; text-align: center; padding: 1px 5px; border-radius: 5px; background: var(--overlay); color: var(--ink); font-size: 10.5px; font-weight: 600; font-family: var(--font-mono, monospace); }

/* contadores finais */
.dash-contadores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: 0; }
@media (max-width: 900px) { .dash-contadores { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dash-cont { padding: 14px 16px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dash-cont:nth-child(3n) { border-right: 0; }
.dash-cont:nth-last-child(-n+3) { border-bottom: 0; }
@media (max-width: 900px) {
  .dash-cont:nth-child(3n) { border-right: 1px solid var(--line-soft); }
  .dash-cont:nth-child(2n) { border-right: 0; }
  .dash-cont:nth-last-child(-n+3) { border-bottom: 1px solid var(--line-soft); }
  .dash-cont:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 480px) {
  .dash-contadores { grid-template-columns: 1fr; }
  .dash-cont, .dash-cont:nth-child(2n) { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .dash-cont:last-child { border-bottom: 0; }
}
.dash-cont b { font-size: 20px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.dash-cont span { font-size: 11px; color: var(--ink-3); }
.dash-cont.is-ok b { color: #35d07f; }

/* bandeiras locais dos estados (cidades usam a bandeira da UF) */
.uf-flag { width: 20px; height: 14px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px var(--line-soft); vertical-align: -2px; margin-right: 6px; }
.dash-local-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
