/* Tela Custos API: paleta categórica das finalidades e dos modelos, gráfico, extrato, previsão e sugestões.
   Carregado depois de layout.css. Sem estilos inline (CSP): cores por classes, posições por CSSOM em costs.js.
   Paleta (--cp-1 a --cp-8, mais --cp-0 para "Outros"): contraste mínimo de 4,5:1 contra o fundo da página (#0a0a0b), do cartão (#121316)
   e da superfície elevada (#17181b) e distância de cor (CIE94) de ao menos 6 entre qualquer par, inclusive sob simulação de
   protanopia, deuteranopia e tritanopia (simulações de Machado e de Viénot, incluindo "Outros"). A regra é verificada em tests/test_comop_costs.py. A mesma finalidade ou modelo usa a mesma
   cor no gráfico, na legenda, na dica, na tabela e nas sugestões. O tema do console é escuro; não há tema claro. */
:root{
  --cp-0:#8a919b;   /* outros */
  --cp-1:#4fd8ff;   /* Classificação e extração de evento */
  --cp-2:#ff9a5c;   /* Comparação de eventos */
  --cp-3:#ffd93b;   /* Etiquetador de indicadores */
  --cp-4:#2bd99f;   /* Extração de territórios */
  --cp-5:#ff4d94;   /* Síntese de audiência */
  --cp-6:#8080ff;   /* Análise SCAME */
  --cp-7:#b8873a;   /* Assistente */
  --cp-8:#80b820;   /* Teste de conexão da IA */
  --cp-9:#e8e0ff;   /* Defesa & Narrativa (autoria e forense agrupadas no gráfico geral) */
}
.cp-0{--c:var(--cp-0)}.cp-1{--c:var(--cp-1)}.cp-2{--c:var(--cp-2)}.cp-3{--c:var(--cp-3)}.cp-4{--c:var(--cp-4)}
.cp-5{--c:var(--cp-5)}.cp-6{--c:var(--cp-6)}.cp-7{--c:var(--cp-7)}.cp-8{--c:var(--cp-8)}.cp-9{--c:var(--cp-9)}
.sw{display:inline-block;flex:none;width:10px;height:10px;border-radius:2px;margin-right:7px;vertical-align:-1px;background:var(--c,var(--cp-0))}
.chart-legend i.sw{background:var(--c,var(--cp-0))}
.cost-name{display:inline-flex;align-items:center;min-width:0}
.bar{fill:var(--c,var(--cp-0));stroke:var(--bg);stroke-width:.8}
.hit{fill:transparent;cursor:crosshair}
.band{fill:rgba(255,255,255,.08);pointer-events:none}
.band.off{display:none}
.mini-chart>svg:focus-visible{outline:2px solid var(--ice);outline-offset:2px;border-radius:6px}

/* barra de abas e resumo */
.cost-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px}
.cost-bar .tabs{margin:0}
.cost-bar .note{margin:0;flex:1 1 240px;min-width:0}
.cost-panel[hidden]{display:none}
.cost-panel{display:grid;gap:16px}
.cost-controls{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px;margin-bottom:8px}
.cost-controls h2{margin:0;flex:1 1 160px}
.cost-controls .segmented{align-self:center}
.cost-controls .seg,.cost-tips-head .seg{padding:4px 12px;font-size:12px}

/* dica do gráfico */
.cost-tip{position:absolute;z-index:5;pointer-events:none;min-width:200px;max-width:300px;padding:8px 10px;border-radius:10px;border:1px solid var(--glass-edge);background:var(--glass-sheen),var(--glass-tint-strong);-webkit-backdrop-filter:var(--glass-blur);backdrop-filter:var(--glass-blur);box-shadow:var(--glass-shadow);font:12px/1.5 var(--sans);color:var(--ink)}
.cost-tip[hidden]{display:none}
.cost-tip header{font:600 11px var(--mono);letter-spacing:.04em;color:var(--ink-2);margin-bottom:2px}
.cost-tip .tip-total{color:var(--ink-2);margin-bottom:4px}
.cost-tip div:not(.tip-total){display:flex;justify-content:space-between;gap:14px}
.cost-tip b{font:600 12px var(--mono);font-variant-numeric:tabular-nums;white-space:nowrap}
.cost-tip div span{min-width:0}

/* tabela de valores do gráfico (sob demanda) */
.cost-values{width:100%;border-collapse:collapse;font-size:12px}
.cost-values th,.cost-values td{padding:4px 8px;text-align:right;white-space:nowrap;border-bottom:1px solid var(--line)}
.cost-values th:first-child,.cost-values td:first-child{text-align:left}
.cost-values th{font:600 10px var(--mono);letter-spacing:.06em;color:var(--ink-3);text-transform:uppercase}

/* extrato */
#stmt-table td,#stmt-table th{white-space:nowrap}
#stmt-filters.filterbar{flex-wrap:wrap}
.unpriced{color:var(--amber);font-size:11px}

/* previsão */
.fc-tiles{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-bottom:12px}
.fc-tile{display:flex;flex-direction:column;gap:2px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--card-tint);min-width:0}
.fc-tile span{font:500 10px var(--mono);letter-spacing:.1em;color:var(--ink-3);text-transform:uppercase}
.fc-tile strong{font-weight:400;font-size:clamp(16px,2.4vh,22px);letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.fc-tile small{font-size:11px;color:var(--ink-3)}
.fc-proj{display:flex;flex-direction:column;gap:2px;margin-bottom:6px}
.fc-proj span{font:500 10px var(--mono);letter-spacing:.1em;color:var(--ink-3);text-transform:uppercase}
.fc-proj strong{font-weight:300;font-size:clamp(26px,4.4vh,40px);letter-spacing:-.03em;font-variant-numeric:tabular-nums}
.fc-proj small{font-size:11.5px;color:var(--ink-2)}
.fc-chart-box{margin:6px 0 10px}
.fc-chart{display:block;width:100%;height:84px}
.fc-track{fill:rgba(255,255,255,.07)}
.fc-spent{fill:var(--ice)}
.fc-range{fill:rgba(163,163,167,.28);stroke:var(--steel);stroke-width:1}
.fc-mid{stroke:var(--ink);stroke-width:2}
.fc-budget{stroke:var(--amber);stroke-width:1.5;stroke-dasharray:4 3}
.fc-status{display:flex;flex-wrap:wrap;align-items:flex-start;gap:6px 10px;font-size:12.5px;line-height:1.5;color:var(--ink-2)}
.fc-status .badge{flex:none}
.fc-msg{margin:0 0 8px;font-size:12.5px;color:var(--amber)}
.fc-step{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--ink-2)}

/* sugestões */
.cost-tips-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px}
.cost-tips-head .note{margin:0;flex:1 1 280px;min-width:0}
.cost-tips{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,340px),1fr));gap:var(--gap,12px);align-content:start}
.cost-tips[hidden],#tips-unit[hidden]{display:none}
.tip{display:flex;flex-direction:column;gap:6px;min-width:0;padding:12px 14px;border:1px solid var(--line);border-radius:14px;background:var(--card-tint)}
.tip-head{display:flex;align-items:flex-start;gap:10px}
.tip-head h3{margin:0;font:600 13px/1.35 var(--sans);color:var(--ink);min-width:0}
.tip-head .badge{flex:none;white-space:nowrap}
.badge.prio-alta{background:var(--red-bg);border-color:var(--red-edge);color:#ff8f8a}
.badge.prio-media{background:var(--amber-bg);border-color:var(--amber-edge);color:#f2c46f}
.badge.prio-baixa{background:var(--steel-bg);border-color:var(--steel-edge);color:var(--steel)}
.tip-gain{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px}
.tip-gain strong{font:600 12.5px var(--mono);font-variant-numeric:tabular-nums}
.chip{display:inline-block;padding:1px 8px;border:1px solid var(--line-2);border-radius:999px;font-size:10.5px;color:var(--ink-3)}
.tip p{margin:0;font-size:12.5px;line-height:1.5;color:var(--ink-2)}
.tip p.calc{font-size:11px;line-height:1.45;color:var(--ink-3)}

/* aba Defesa & Narrativa */
.narr-view[hidden]{display:none}
.narr-tiles{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:0}
.narr-overview,.narr-statement,.narr-tips{display:grid;gap:var(--gap,12px);align-content:start}
.narr-side{display:grid;gap:var(--gap,12px);min-width:0}
.narr-what{display:flex;flex-direction:column;gap:1px;min-width:0}
.narr-model{color:var(--ink-3);font-size:11px;overflow-wrap:anywhere}
#narr-conn td,#narr-conn th,#narr-ia td,#narr-ia th{padding-left:5px;padding-right:5px}
#narr-conn th,#narr-ia th{letter-spacing:.03em;white-space:normal}

/* aba ScrapeCreators */
.sc-view[hidden]{display:none}
.sc-tiles{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:0}
.cost-batch-tiles{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:8px}
.cost-batch-card[hidden]{display:none}
.cost-usage>.cost-batch-card{grid-column:1/-1}
.sc-overview,.sc-params,.sc-cadence{display:grid;gap:var(--gap,12px);align-content:start}
.fc-tile.sc-low{border-color:var(--amber-edge);background:var(--amber-bg)}
.sc-est{stroke:var(--c);stroke-width:1.8;stroke-dasharray:6 4;fill:none}
.sc-recharge{fill:var(--steel)}
.sc-form{display:grid;gap:10px;min-width:0}
.sc-ptable{width:100%;border-collapse:collapse;font-size:12.5px}
.sc-ptable th{font:600 10px var(--mono);letter-spacing:.06em;color:var(--ink-3);text-transform:uppercase;text-align:left;padding:4px 6px;white-space:normal}
.sc-ptable td{padding:4px 6px;border-bottom:1px solid var(--line);white-space:nowrap}
.sc-ptable td:first-child{display:flex;align-items:center;min-width:96px}
.sc-ptable td.sc-per{font-variant-numeric:tabular-nums;color:var(--ink-2)}
.sc-ptable input,.sc-general input{width:100%;min-width:64px;height:28px;padding-top:2px;padding-bottom:2px}
.sc-general{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px 12px}
.sc-general label,.sc-apply-fields label{display:flex;flex-direction:column;gap:3px;font-size:12px;color:var(--ink-2);min-width:0}
.sc-apply-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 12px}
.sc-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px}
.sc-actions .note{margin:0;flex:1 1 200px}
.sc-apply-result{margin:0;font-size:12.5px;line-height:1.5;color:var(--ink-2);overflow-wrap:anywhere}
.sc-params-card,.sc-apply-card{min-width:0}

/* ajuste à janela (mesma regra de layout.css, largura >= 1024 px) */
@media(min-width:1024px){
  #view-costs{display:flex;flex-direction:column;gap:var(--gap);min-height:0}
  #view-costs>*{flex:none}
  #view-costs>.cost-panel:not([hidden]){flex:1 1 0;min-height:0;min-width:0}
  #view-costs>p.note{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;text-overflow:ellipsis;margin:0}
  .cost-bar .tabs button{padding:clamp(4px,.7vh,7px) 16px}
  .cost-panel:not([hidden]){gap:var(--gap)}

  .cost-usage:not([hidden]){display:grid;grid-template-columns:minmax(0,1.6fr) minmax(300px,1fr);grid-template-rows:minmax(0,1fr)}
  .cost-chart-card{display:flex;flex-direction:column;min-height:0;min-width:0}
  #cost-chart,#narr-chart{flex:1 1 0;min-height:0}
  .cost-usage>#cost-table{min-height:0;min-width:0}

  .cost-statement:not([hidden]){display:flex;flex-direction:column}
  .cost-statement>*{flex:none}
  .cost-statement>#stmt-table{flex:1 1 0;min-height:0}
  #stmt-table{padding-top:0;padding-bottom:0}
  .cost-statement .note{margin:0}

  .cost-forecast:not([hidden]){display:grid;grid-template-columns:minmax(0,1.5fr) minmax(300px,1fr);grid-template-rows:auto minmax(0,1fr)}
  .cost-fc-card{grid-column:1;grid-row:1/3;min-height:0;min-width:0;overflow:hidden}
  .cost-budget-card{grid-column:2;grid-row:1;min-width:0}
  .cost-method-card{grid-column:2;grid-row:2;display:flex;flex-direction:column;min-height:0;min-width:0}
  #fc-method{flex:1 1 0;min-height:0}
  .cost-budget-card .budget-bar{margin:8px 0}
  .cost-budget-card .note{margin:0 0 4px}

  .cost-narr:not([hidden]){display:flex;flex-direction:column}
  .cost-narr>*{flex:none}
  .cost-narr>.narr-view:not([hidden]){flex:1 1 0;min-height:0;min-width:0}
  .narr-overview:not([hidden]){display:grid;grid-template-columns:minmax(0,1.3fr) minmax(330px,1fr);grid-template-rows:auto minmax(0,1fr)}
  .narr-overview>.narr-tiles{grid-column:1/-1}
  .narr-chart-card{grid-column:1;grid-row:2}
  .narr-side{grid-column:2;grid-row:2;grid-template-rows:minmax(0,1fr) minmax(0,1.4fr);min-height:0}
  .narr-side>.table-card{min-height:0;min-width:0}
  .narr-statement:not([hidden]){display:flex;flex-direction:column}
  .narr-statement>*{flex:none}
  .narr-statement>#narr-stmt-table{flex:1 1 0;min-height:0;padding-top:0;padding-bottom:0}
  .narr-statement .note{margin:0}
  .narr-tips:not([hidden]){display:flex;flex-direction:column}
  .narr-tips>#narr-tips-list{flex:1 1 0;min-height:0;overflow:hidden}
  #narr-filters.filterbar{flex-wrap:wrap}
  .cost-sc:not([hidden]){display:flex;flex-direction:column}
  .cost-sc>*{flex:none}
  .cost-sc>.sc-view:not([hidden]){flex:1 1 0;min-height:0;min-width:0}
  .sc-overview:not([hidden]){display:grid;grid-template-columns:minmax(0,1fr) minmax(380px,1fr);grid-template-rows:auto minmax(0,1fr)}
  .sc-overview>.sc-tiles{grid-column:1/-1}
  .sc-chart-card{grid-column:1;grid-row:2}
  .sc-nets{grid-column:2;grid-row:2;min-height:0;min-width:0}
  #sc-chart{flex:1 1 0;min-height:0}
  .sc-params:not([hidden]){display:grid;grid-template-columns:minmax(0,1.7fr) minmax(300px,1fr);grid-template-rows:minmax(0,1fr)}
  .sc-cadence:not([hidden]){grid-template-columns:minmax(0,1fr)}
  .sc-params>.card{min-height:0;min-width:0;overflow:hidden}
  .sc-params .sc-form{gap:clamp(6px,1.1vh,10px)}
  .sc-ptable td{padding-top:clamp(1px,.3vh,3px);padding-bottom:clamp(1px,.3vh,3px)}
  .sc-params-card h2,.sc-apply-card h2{margin-bottom:4px}
  .cost-tips-panel:not([hidden]){display:flex;flex-direction:column}
  .cost-tips-panel>*{flex:none}
  .cost-tips-panel>#tips-list:not([hidden]),.cost-tips-panel>#tips-unit:not([hidden]){flex:1 1 0;min-height:0}
  .cost-tips-panel>#tips-list{overflow:hidden}
  .cost-tips-head .note{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;text-overflow:ellipsis}
  .tip{padding:clamp(8px,1.3vh,14px) 14px;gap:clamp(3px,.6vh,6px)}
}
@media(min-width:1024px) and (max-width:1200px){
  .cost-bar .tabs button{padding-left:11px;padding-right:11px}
  .cost-bar .note{flex-basis:120px}
}
@container (max-width:900px){
  #stmt-table .c-cache,#tips-unit .c-participacao{display:none}
  /* Extrato: a finalidade nunca quebra linha (a altura das linhas não pode depender de quais finalidades caem na página); texto cortado
     por reticências traz o conteúdo integral em title (costs.js, named). */
  #stmt-table td.c-finalidade{white-space:nowrap;width:34%;max-width:0;min-width:130px;overflow:hidden;text-overflow:ellipsis}
}
@container (max-width:800px){
  #stmt-table .c-entrada,#tips-unit .c-entrada-media,#tips-unit .c-saida-media{display:none}
}
@container (max-width:640px){
  #sc-nets .c-falhas,#sc-nets .c-req-dia-est,#sc-nets .c-creditos-24-h-est,#sc-nets .c-execucoes-24-h{display:none}
  #stmt-table .c-modelo,#tips-unit .c-cache,#tips-unit .c-falhas{display:none}
  #cost-table .c-chamadas{display:none}
}
@media(max-width:1023px){
  .cost-usage,.cost-forecast,.narr-overview,.sc-overview,.sc-params{grid-template-columns:minmax(0,1fr)}
  .narr-tiles,.sc-tiles,.cost-batch-tiles{grid-template-columns:repeat(2,minmax(0,1fr))}
  .sc-general{grid-template-columns:minmax(0,1fr)}
  #cost-chart,#narr-chart,#sc-chart{min-height:260px}
}
