/* ============================================================
   Stakefy — cards do Dashboard (Ajuste 176)
   Só vale dentro de .kpis-v2 (o Dashboard). Os outros cartões .kpi2 do site (Estatísticas etc.) não mudam.
   Cada card tem as mesmas faixas: cabeçalho (ícone, nome, atalho) · valor · linha de contexto · mini-gráfico · rodapé.
   Vem DEPOIS do tema-v3.css para poder ajustar o que ele define.
============================================================ */

/* ---------- cores dos mini-gráficos (validadas para daltonismo: azul / verde-água / âmbar) ---------- */
.kpis-v2 {
    --k-azul: #3987e5;
    --k-aqua: #199e70;
    --k-ouro: #c98500;
    --k-neutro: #7d8aa3;
    --k-pos: var(--green-fg, #34e0a8);
    --k-neg: var(--red-fg, #ff7487);
    --k-gut: 16px;
}
[data-theme="light"] .kpis-v2 {
    --k-azul: #2a78d6;
    --k-aqua: #1baf7a;
    --k-ouro: #eda100;
    --k-neutro: #8591a8;
}

/* ---------- grade: 5 numa linha, 3 + 2 em telas médias, carrossel no celular ---------- */
.kpis-v2 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1360px) {
    .kpis-v2 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .kpis-v2 > .kpi2-dash { grid-column: span 2; }
    .kpis-v2 > .kpi2-dash:nth-child(n + 4) { grid-column: span 3; }
}
@media (max-width: 700px) {
    .kpis-v2 {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: var(--k-gut);
        margin-inline: calc(-1 * var(--k-gut));
        padding: 4px var(--k-gut) 14px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .kpis-v2::-webkit-scrollbar { display: none; }
    .kpis-v2 > .kpi2-dash { flex: 0 0 min(80vw, 310px); grid-column: auto; scroll-snap-align: start; }
}
@media (max-width: 540px) { .kpis-v2 { --k-gut: 12px; } }

/* ---------- o card ---------- */
.kpis-v2 .kpi2-dash {
    --k-tom: #f6ae10;        /* cor de destaque do card: ícone, brilho e botão de atalho */
    --k-tom-fg: #f6ae10;
    min-height: 184px;
    padding: 15px 16px 14px;
    gap: 12px;
    justify-content: flex-start;
    cursor: pointer;
    container-type: inline-size;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
.kpis-v2 .kpi2-dash[data-tom="azul"] { --k-tom: var(--k-azul); --k-tom-fg: #6aa3ff; }
.kpis-v2 .kpi2-dash[data-tom="verde"] { --k-tom: #2ddba0; --k-tom-fg: #34e0a8; }
[data-theme="light"] .kpis-v2 .kpi2-dash { --k-tom: #f0a500; --k-tom-fg: #9a6200; }
[data-theme="light"] .kpis-v2 .kpi2-dash[data-tom="azul"] { --k-tom: #2a78d6; --k-tom-fg: #1f5fb3; }
[data-theme="light"] .kpis-v2 .kpi2-dash[data-tom="verde"] { --k-tom: #1baf7a; --k-tom-fg: #0a7350; }

.kpis-v2 .kpi2-dash:hover { z-index: 3; border-color: color-mix(in srgb, var(--k-tom) 40%, transparent); }
.kpis-v2 .kpi2-dash:has(.kpi2-ir:focus-visible) { box-shadow: var(--foco), var(--sombra-card); border-color: var(--k-tom); }

/* brilho no canto, na cor do card (substitui o dourado fixo) */
.kpis-v2 .kpi2-dash::after {
    inset: 0;
    right: 0; top: 0; width: auto; height: auto;
    border-radius: inherit;
    opacity: .8;
    background: radial-gradient(120px 100px at 100% 0, color-mix(in srgb, var(--k-tom) 17%, transparent), transparent 70%);
    transition: opacity .25s;
}
.kpis-v2 .kpi2-dash:hover::after { opacity: 1; }

/* ---------- cabeçalho ---------- */
.kpis-v2 .kpi2-dash .kpi2-top { gap: 5px; }
.kpis-v2 .kpi2-dash .kpi2-head { justify-content: flex-start; gap: 8px; }
.kpi2-ico {
    flex: none;
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 8px;
    color: var(--k-tom-fg);
    background: color-mix(in srgb, var(--k-tom) 16%, transparent);
}
.kpi2-ico svg, .kpi2-ir svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.kpi2-ico svg { width: 15px; height: 15px; stroke-width: 1.9; }
.kpis-v2 .kpi2-dash .kpi2-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* card estreito (tela de 1361 a ~1550 px): ícone, botão e nome encolhem um pouco para o nome caber inteiro */
@container (max-width: 250px) {
    .kpi2-ico { width: 24px; height: 24px; }
    .kpi2-ir { width: 22px; height: 22px; }
    .kpis-v2 .kpi2-dash .kpi2-head { gap: 7px; }
    .kpis-v2 .kpi2-dash .kpi2-label { font-size: 9.6px; letter-spacing: .3px; }
}

/* botão de atalho: o link ocupa o card inteiro (::after), os mini-gráficos ficam por cima */
.kpi2-ir {
    flex: none;
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 50%;
    color: var(--muted);
    border: 1px solid var(--linha-clara);
    text-decoration: none;
    transition: background .18s, color .18s, border-color .18s;
}
.kpi2-ir::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.kpi2-ir svg { width: 12px; height: 12px; stroke-width: 2.2; transition: transform .2s; }
.kpis-v2 .kpi2-dash:hover .kpi2-ir, .kpi2-ir:focus-visible {
    color: #10131c;
    background: var(--k-tom);
    border-color: transparent;
    outline: none;
}
.kpis-v2 .kpi2-dash:hover .kpi2-ir svg, .kpi2-ir:focus-visible svg { transform: translate(1px, -1px); }

/* ---------- valor e linha de contexto ---------- */
.kpis-v2 .kpi2-dash h2 { margin: 3px 0 0; font-size: 23px; font-weight: 800; letter-spacing: -.025em; line-height: 1.1; overflow-wrap: anywhere; }
@supports (font-size: 1cqw) { .kpis-v2 .kpi2-dash h2 { font-size: clamp(19px, 10.5cqw, 27px); } }

.kpi2-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; min-height: 21px; }
.kpi2-sub > small { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
html:not(.sk-on) .kpis-v2 .kpi2-sub > small.kpi2-chip,
html:not(.sk-on) .kpis-v2 #capitalTotalVariacao,
html:not(.sk-on) .kpis-v2 #lucroHojeVariacao {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.5;
    background: color-mix(in srgb, currentColor 13%, transparent);
}
.kpis-v2 .kpi2-sub > small.nulo { color: var(--secondary); }
.kpis-v2 #lucroHojeVariacao.yellow { color: var(--accent-fg); }
/* setinha junto do número: o sinal não depende só da cor */
html:not(.sk-on) .kpis-v2 #capitalTotalVariacao::before,
html:not(.sk-on) .kpis-v2 #lucroMesDelta::before { content: "▲"; font-size: 8px; }
html:not(.sk-on) .kpis-v2 #capitalTotalVariacao.red::before,
html:not(.sk-on) .kpis-v2 #lucroMesDelta.red::before { content: "▼"; }
html:not(.sk-on) .kpis-v2 #capitalTotalVariacao.nulo::before,
html:not(.sk-on) .kpis-v2 #lucroMesDelta.nulo::before { content: "•"; font-size: 10px; }
.kpi2-ctx { font-size: 11px; color: var(--muted); }
.kpi2-sub > small[hidden] { display: none; }

/* o atributo hidden precisa vencer os display: flex dos blocos abaixo */
.kpis-v2 [hidden] { display: none !important; }

/* ---------- parte de baixo (mini-gráfico + rodapé) ---------- */
.kpi2-base { margin-top: auto; display: grid; gap: 8px; min-width: 0; }
.kpi2-viz, .kpi2-trilho { position: relative; z-index: 2; min-width: 0; }
.kpi2-viz { height: 52px; border-radius: 8px; cursor: crosshair; touch-action: pan-y; }
.kpi2-viz:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.kpi2-viz svg { display: block; width: 100%; height: 100%; overflow: visible; }
.kpi2-rodape { margin: 0; font-size: 11px; line-height: 1.4; color: var(--muted); min-height: 15px; overflow-wrap: anywhere; }
.kpi2-rodape strong { color: var(--secondary); font-weight: 700; }

/* ---------- linha (Capital total) ---------- */
.kpi2-spark.pos { color: var(--k-pos); }
.kpi2-spark.neg { color: var(--k-neg); }
.kpi2-spark.nada { color: var(--k-neutro); }
.kpi2-linha { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.kpi2-zero { stroke: var(--muted); stroke-opacity: .35; stroke-width: 1; stroke-dasharray: 3 4; }
.kpi2-fim { fill: currentColor; stroke: var(--card); stroke-width: 2; }
.kpi2-cursor { stroke: var(--secondary); stroke-opacity: .55; stroke-width: 1; }
.kpi2-ponto { fill: currentColor; stroke: var(--card); stroke-width: 2; }

/* ---------- barras (Lucro do mês) ---------- */
.kpi2-bars .m.pos { fill: var(--k-pos); }
.kpi2-bars .m.neg { fill: var(--k-neg); }
.kpi2-bars .m.nulo { fill: var(--muted); fill-opacity: .55; }
.kpi2-bars .m.fut { fill: var(--muted); fill-opacity: .22; }
.kpi2-bars .b { transition: opacity .12s; }
.kpi2-bars[data-foco] .b:not(.on) { opacity: .38; }
.kpi2-bars .hit { fill: transparent; }

/* ---------- barra de composição (Capital disponível, Total de apostas) ---------- */
.kpi2-comp { display: flex; gap: 2px; height: 8px; }
.kpi2-comp > * {
    flex: var(--p, 1) 1 0%;
    min-width: 3px;
    display: block;
    background: var(--c);
    border-radius: 2px;
    transition: opacity .15s, transform .15s;
}
.kpi2-comp > :first-child { border-radius: 5px 2px 2px 5px; }
.kpi2-comp > :last-child { border-radius: 2px 5px 5px 2px; }
.kpi2-comp > :only-child { border-radius: 5px; }
.kpi2-comp > .vazio { background: var(--linha-clara); }
.kpi2-comp[data-foco] > :not(.on) { opacity: .32; }
.kpi2-comp > a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.kpi2-leg { list-style: none; display: grid; gap: 1px; margin: 0; padding: 0; }
.kpi2-leg a {
    display: grid; grid-template-columns: 8px minmax(0, 1fr) auto;
    align-items: center; gap: 7px;
    margin: 0 -5px; padding: 3px 5px;
    border-radius: 7px;
    font-size: 11.5px; line-height: 1.3;
    color: var(--secondary);
    text-decoration: none;
    position: relative; z-index: 2;
    transition: background .15s, color .15s;
}
.kpi2-leg a:hover, .kpi2-leg a.on, .kpi2-leg a:focus-visible { background: var(--linha-clara); color: var(--text); outline: none; }
.kpi2-leg a:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.kpi2-leg .sw, .kpi2-leg-linha .sw { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.kpi2-leg em { font-style: normal; color: var(--muted); font-size: 10.5px; margin-left: 4px; }
.kpi2-leg strong { color: var(--text); font-weight: 700; }
.kpi2-leg .sw-ouro { --c: var(--k-ouro); }
.kpi2-leg .sw-azul { --c: var(--k-azul); }
.kpi2-leg .sw-aqua { --c: var(--k-aqua); }

.kpi2-leg-linha { display: flex; flex-wrap: wrap; gap: 3px 4px; margin: 0; }
.kpi2-leg-linha a {
    display: inline-flex; align-items: center; gap: 5px;
    margin: 0 -2px 0 0; padding: 2px 6px;
    border-radius: 7px;
    font-size: 11px; color: var(--secondary); text-decoration: none;
    position: relative; z-index: 2;
    transition: background .15s, color .15s;
}
.kpi2-leg-linha a:hover, .kpi2-leg-linha a.on, .kpi2-leg-linha a:focus-visible { background: var(--linha-clara); color: var(--text); outline: none; }
.kpi2-leg-linha a:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.kpi2-leg-linha strong { color: var(--text); font-weight: 700; }

/* ---------- meta do dia (Lucro hoje) ---------- */
.kpis-v2 .kpi2-dash .kpi2-progress { height: 8px; border-radius: 6px; background: var(--linha-clara); margin: 0; }
.kpis-v2 .kpi2-dash .kpi2-progress-fill { border-radius: 6px; transition: width .5s cubic-bezier(.2, .7, .2, 1); }
.kpi2-escala { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; font-size: 10.5px; color: var(--muted); }
.kpi2-cta {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 11px;
    border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
    border-radius: 9px;
    color: var(--accent-fg);
    font-size: 11.5px; font-weight: 700;
    text-decoration: none;
    position: relative; z-index: 2;
    transition: background .15s, border-color .15s;
}
.kpi2-cta:hover, .kpi2-cta:focus-visible { background: color-mix(in srgb, var(--accent) 12%, transparent); border-style: solid; outline: none; }
.kpi2-cta:focus-visible { box-shadow: var(--foco); }
.kpi2-cta svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* ---------- dica flutuante ---------- */
.kpi2-tip {
    position: absolute; z-index: 8;
    bottom: calc(100% + 7px); left: 0;
    width: max-content; max-width: 190px;
    padding: 6px 9px;
    border-radius: 9px;
    background: var(--card2);
    border: 1px solid var(--border);
    box-shadow: 0 12px 26px -12px rgba(0, 0, 0, .65);
    font-size: 11px; line-height: 1.4; color: var(--text);
    pointer-events: none;
    opacity: 0; transform: translateY(2px);
    transition: opacity .12s, transform .12s;
}
.kpi2-tip.on { opacity: 1; transform: none; }
.kpi2-tip b { display: block; font-size: 10.5px; font-weight: 700; color: var(--secondary); }
.kpi2-tip strong { font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi2-tip .pos { color: var(--k-pos); }
.kpi2-tip .neg { color: var(--k-neg); }

/* ---------- carregando: tudo que é desenho fica apagado até os números chegarem ---------- */
html.sk-on .kpis-v2 .kpi2-viz,
html.sk-on .kpis-v2 .kpi2-trilho,
html.sk-on .kpis-v2 .kpi2-leg,
html.sk-on .kpis-v2 .kpi2-leg-linha,
html.sk-on .kpis-v2 .kpi2-escala,
html.sk-on .kpis-v2 .kpi2-rodape,
html.sk-on .kpis-v2 .kpi2-cta { opacity: .16; pointer-events: none; }
html.sk-on .kpis-v2 .kpi2-ctx { visibility: hidden; }
html.sk-on .kpis-v2 .kpi2-ir { pointer-events: none; }

/* ---------- entrada (uma vez, quando os números chegam) ---------- */
@keyframes k-traco { to { stroke-dashoffset: 0; } }
@keyframes k-surge { to { opacity: 1; } }
@keyframes k-cresce { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes k-largura { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: no-preference) {
    .kpi2-dash.k-entra .kpi2-linha { stroke-dasharray: 1; stroke-dashoffset: 1; animation: k-traco .85s .1s cubic-bezier(.2, .7, .2, 1) forwards; }
    .kpi2-dash.k-entra .kpi2-area { opacity: 0; animation: k-surge .6s .55s ease-out forwards; }
    .kpi2-dash.k-entra .kpi2-fim { opacity: 0; animation: k-surge .3s .85s ease-out forwards; }
    .kpi2-dash.k-entra .kpi2-bars .m { transform-box: fill-box; transform-origin: 50% 100%; animation: k-cresce .5s calc(var(--i, 0) * 14ms) cubic-bezier(.2, .7, .2, 1) both; }
    .kpi2-dash.k-entra .kpi2-bars .m.neg { transform-origin: 50% 0; }
    .kpi2-dash.k-entra .kpi2-comp > * { transform-origin: left center; animation: k-largura .55s calc(var(--i, 0) * 70ms) cubic-bezier(.2, .7, .2, 1) both; }
}
@media (prefers-reduced-motion: reduce) {
    .kpis-v2 .kpi2-dash, .kpi2-ir svg, .kpi2-tip, .kpis-v2 .kpi2-dash .kpi2-progress-fill { transition: none; }
}
@media (hover: none) {
    .kpis-v2 .kpi2-dash:hover { transform: none; }
}
