/* "Indicadores do mês" (js/features/portal-insights.js): cartões claros abaixo dos cartões escuros do dia. */
.portal-insights { margin: -0.25rem 0 1.5rem; }
.portal-insights[hidden] { display: none; }
.portal-insights > summary { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .8rem; color: var(--portal-navy, #00142d); cursor: pointer; list-style: none; user-select: none; }
.portal-insights > summary::-webkit-details-marker { display: none; }
.portal-insights-title { font-size: 1.05rem; font-weight: 800; }
.portal-insights > summary small { color: #617188; font-size: .82rem; font-weight: 600; }
.portal-insights-toggle { margin-left: auto; color: #1769aa; font-size: .8rem; font-weight: 700; }
.portal-insights-toggle::after { content: "Recolher ▴"; }
.portal-insights:not([open]) .portal-insights-toggle::after { content: "Mostrar mais informações ▾"; }
.portal-insights > summary:focus-visible { outline: 2px solid rgba(245, 130, 13, .55); outline-offset: 4px; border-radius: .3rem; }

.insights-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }

.insight-card { --tone: #1769aa; --tone-soft: #e8f1fa; position: relative; display: flex; flex-direction: column; min-width: 0; padding: 1rem 1.1rem 1.05rem; border: 1px solid #dfe7f0; border-radius: 1rem; background: #fff; color: #16283d; box-shadow: 0 2px 10px rgba(0, 20, 45, .05); overflow: hidden; }
.insight-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--tone); }
.insight-card header { display: flex; align-items: center; gap: .55rem; }
.insight-icon { flex: none; width: 2rem; height: 2rem; padding: .38rem; border-radius: .6rem; color: var(--tone); background: var(--tone-soft); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.insight-card h3 { margin: 0; color: #31465e; font-size: .86rem; font-weight: 700; line-height: 1.25; }
.insight-value { display: block; margin: .6rem 0 .1rem; color: #00142d; font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.insight-note { margin: 0; color: #617188; font-size: .8rem; line-height: 1.35; }
.insight-details { margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed #dfe7f0; }
.insight-details small { display: block; color: #4a5d73; font-size: .76rem; line-height: 1.45; }
.insight-empty { margin: .7rem 0 0; color: #8a97a8; font-size: .78rem; font-style: italic; }

.insight-rows-title { margin: .8rem 0 .35rem; color: #8a97a8; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.insight-rows { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.insight-rows-title + .insight-rows { margin-top: 0; }
.insight-card > .insight-rows:not(.insight-rows-title + .insight-rows) { margin-top: .8rem; }
.insight-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: .6rem; row-gap: .2rem; font-size: .8rem; }
.insight-row-label { min-width: 0; overflow: hidden; color: #16283d; text-overflow: ellipsis; white-space: nowrap; }
.insight-row-label small { margin-left: .35rem; color: #8a97a8; font-size: .7rem; }
.insight-rows b { color: #00142d; font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.insight-row-bar { grid-column: 1 / -1; display: block; height: 5px; border-radius: 999px; background: #eef2f6; overflow: hidden; }
.insight-row-bar::before { content: ""; display: block; width: var(--w, 0%); height: 100%; border-radius: inherit; background: var(--tone); opacity: .8; }

/* Tarefa x Particular: barra dividida + legenda */
.insight-split { display: flex; height: 10px; margin-top: .8rem; border-radius: 999px; background: #eef2f6; overflow: hidden; }
.insight-split i { display: block; width: var(--w, 0%); height: 100%; }
.insight-split-a { background: var(--tone); }
.insight-split-b { background: #f5820a; }
.insight-legend { display: grid; gap: .3rem; margin: .6rem 0 0; padding: 0; list-style: none; font-size: .8rem; }
.insight-legend li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .45rem; }
.insight-legend li::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--tone); }
.insight-legend .insight-legend-b::before { background: #f5820a; }
.insight-legend b { color: #00142d; font-variant-numeric: tabular-nums; }
.insight-legend small { min-width: 2.6rem; color: #617188; text-align: right; }

/* Cores de cada indicador */
.insight-violet { --tone: #7b4bd1; --tone-soft: #f1ebfc; }
.insight-green { --tone: #1e9e5a; --tone-soft: #e7f6ee; }
.insight-orange { --tone: #e2760a; --tone-soft: #fff1e0; }
.insight-red { --tone: #c8414c; --tone-soft: #fcebec; }
.insight-blue { --tone: #1769aa; --tone-soft: #e8f1fa; }
.insight-teal { --tone: #13877f; --tone-soft: #e3f5f3; }
.insight-indigo { --tone: #3f51b5; --tone-soft: #eaecfa; }
.insight-amber { --tone: #b7791f; --tone-soft: #fbf2e1; }

/* ===== Gráficos (js/features/portal-insights-charts.js) ===== */
.insights-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.insights-charts[hidden] { display: none; }
.chart-card { min-width: 0; padding: 1rem 1.1rem 1.1rem; border: 1px solid #dfe7f0; border-radius: 1rem; background: #fff; box-shadow: 0 2px 10px rgba(0, 20, 45, .05); }
.chart-head h3 { margin: 0; color: #00142d; font-size: .95rem; font-weight: 800; }
.chart-head p { margin: .15rem 0 .7rem; color: #617188; font-size: .8rem; }
.chart-host { width: 100%; min-height: 190px; }
/* O gráfico ocupa a largura toda do cartão (o desenho é feito na largura medida e ajusta se o cartão mudar). */
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
/* Números e horas dos eixos legíveis no celular: mais escuros e um pouco maiores. */
.chart-tick { fill: #52514e; font: 600 12px system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
.chart-col .chart-hit { cursor: pointer; outline: none; }
.chart-col:has(.chart-hit.is-hover) path, .chart-col:has(.chart-hit.is-hover) rect:not(.chart-hit) { filter: brightness(1.12); }
.chart-col .chart-hit.is-hover { fill: rgba(0, 20, 45, .045); }

.chart-legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: 0 0 .6rem; padding: 0; list-style: none; font-size: .78rem; color: #52514e; }
.chart-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend b { color: #0b0b0b; font-variant-numeric: tabular-nums; }
.chart-legend small { color: #898781; font-size: .72rem; }
.chart-swatch { flex: none; width: .7rem; height: .7rem; border-radius: 3px; }

/* Barras horizontais (quem mais criou) */
.chart-hbars { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.chart-hbars li { display: grid; grid-template-columns: minmax(70px, 30%) 1fr; align-items: center; gap: .6rem; padding: .1rem .2rem; border-radius: .4rem; cursor: pointer; outline: none; }
.chart-hbars li.is-hover, .chart-hbars li:focus-visible { background: #f3f6fa; }
.chart-hbar-label { overflow: hidden; color: #52514e; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.chart-hbar-track { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.chart-hbar { display: block; height: 14px; border-radius: 0 4px 4px 0; }
.chart-hbar-value { flex: none; color: #0b0b0b; font-size: .8rem; font-variant-numeric: tabular-nums; }

/* Barra dividida (situação do mês): 2px de folga entre os pedaços, pontas arredondadas */
.chart-stack { display: flex; gap: 2px; height: 22px; margin: .2rem 0 .8rem; border-radius: 4px; overflow: hidden; }
.chart-stack-seg { display: block; min-width: 3px; flex-basis: 0; cursor: pointer; outline: none; }
.chart-stack-seg.is-hover, .chart-stack-seg:focus-visible { filter: brightness(1.12); }
.chart-stack + .chart-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem 1rem; }
.chart-stack + .chart-legend li { display: grid; grid-template-columns: auto 1fr auto auto; }
.chart-stack + .chart-legend small { min-width: 2.4rem; text-align: right; }

/* Dica ao passar o mouse/tocar */
.chart-tip { position: absolute; z-index: 3000; min-width: 140px; max-width: 260px; padding: .55rem .7rem; border-radius: .55rem; color: #0b0b0b; background: #fff; box-shadow: 0 6px 22px rgba(0, 20, 45, .18); border: 1px solid rgba(11, 11, 11, .08); font-size: .78rem; pointer-events: none; }
.chart-tip[hidden] { display: none; }
.chart-tip-title { display: block; margin-bottom: .3rem; color: #52514e; font-size: .74rem; font-weight: 600; }
.chart-tip-row { display: flex; align-items: center; gap: .4rem; }
.chart-tip-row b { font-size: .9rem; font-variant-numeric: tabular-nums; }
.chart-tip-row span { color: #52514e; }
.chart-tip-key { flex: none; width: 10px; height: 2px; border-radius: 1px; }

@media (max-width: 900px) { .insights-charts { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .chart-stack + .chart-legend { grid-template-columns: 1fr; } .chart-card { padding: .9rem; } }

@media (max-width: 600px) {
  /* Celular: faixa branca com título e mês em cima e o botão "Mostrar mais informações" na largura toda embaixo. */
  .portal-insights > summary { display: grid; grid-template-columns: 1fr; gap: .15rem; padding: .85rem .9rem; border: 1px solid #dfe7f0; border-radius: .9rem; background: #fff; box-shadow: 0 2px 10px rgba(0, 20, 45, .05); }
  .portal-insights-title { font-size: 1rem; }
  .portal-insights > summary small { font-size: .78rem; }
  .portal-insights-toggle { margin: .55rem 0 0; padding: .55rem .7rem; border-radius: .6rem; background: #eef4fb; text-align: center; font-size: .85rem; }
  .portal-insights[open] > summary { margin-bottom: .7rem; }
  .insights-grid { grid-template-columns: 1fr; gap: .7rem; }
  .insight-card { padding: .9rem .9rem .95rem; }
  .insight-value { font-size: 1.6rem; }
}
@media print { .portal-insights { display: none !important; } }

/* ---------- BI Dados: período, placar do topo e barras novas ---------- */
.insights-toolbar { display: flex; align-items: center; gap: .6rem; margin: 0 0 .9rem; }
.insights-toolbar label { color: #52606f; font-size: .9rem; font-weight: 600; }
.insights-toolbar select { min-width: 0; max-width: 100%; padding: .5rem 2rem .5rem .75rem; border: 1px solid #dfe7f0; border-radius: .6rem; color: #16283d; background-color: #fff; font: inherit; font-weight: 600; }
/* Placar: 5 números do período, com a comparação com o mês anterior embaixo */
.insights-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .7rem; margin: 0 0 1rem; }
.insights-kpi { display: flex; flex-direction: column; min-width: 0; padding: .85rem .9rem; border: 1px solid #dfe7f0; border-radius: 1rem; color: #16283d; background: #fff; }
.insights-kpi span { color: #3b4d63; font-size: .8rem; font-weight: 600; }
.insights-kpi strong { margin: .15rem 0 .1rem; color: #0e1f33; font-family: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif; font-size: 1.9rem; font-weight: 700; line-height: 1.05; }
.insights-kpi small { color: #66768a; font-size: .74rem; line-height: 1.3; }
.insights-kpi em { margin-top: .45rem; padding-top: .4rem; border-top: 1px solid #e6ebf0; color: #3b4d63; font-size: .74rem; font-style: normal; font-weight: 600; }
@media (max-width: 1199.98px) { .insights-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .insights-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .insights-kpis .insights-kpi:last-child:nth-child(odd) { grid-column: span 2; } }
/* Barras com rótulo longo (tempo de cada etapa) e barra dividida (abonado | não abonado) */
.chart-hbars-wide li { grid-template-columns: minmax(130px, 50%) 1fr; }
.chart-hbars-wide .chart-hbar-label { white-space: normal; }
.chart-hbar-stack { gap: 2px; }
.chart-hbar-stack .chart-hbar { border-radius: 0; }
.chart-hbar-stack .chart-hbar:last-of-type { border-radius: 0 4px 4px 0; }
.chart-hbar-stack .chart-hbar-value { margin-left: .4rem; }
