/* layout-v20.css · correções de enquadramento e legibilidade em todas as abas.
   Só ajusta espaçamento, quebra de linha e largura; não muda dados nem cálculos. */

/* ---- KPIs: o rótulo quebra em até 2 linhas em vez de ser cortado com reticências ---- */
.kpi-label span{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;line-height:1.2;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden!important}
.kpi-card .kpi-label{align-items:flex-start}
.kpi-card .kpi-label i{margin-top:.3em;flex:none}

/* ---- Tabelas dentro de cartões: compactam conforme a largura real do cartão ---- */
.card .table-scroll{container-type:inline-size}
@container (max-width:760px){
  .data-table thead th{padding-left:8px!important;padding-right:8px!important}
  .data-table tbody td{padding-left:8px!important;padding-right:8px!important}

  .data-table{font-size:11.5px!important}
  .data-table tbody td .tk-badge,.data-table tbody td .status-pill,.data-table tbody td .pill{font-size:11px}
}
@container (max-width:660px){
  .data-table thead th,.data-table tbody td{padding-left:6px!important;padding-right:6px!important}
}
/* coluna do nome do projeto: quebra em até 2 linhas em vez de empurrar as demais */
.card .data-table tbody td:first-child strong,.card .data-table tbody td .project-name{white-space:normal;display:block;max-width:15rem;line-height:1.25}
.card .data-table tbody td:first-child small,.card .data-table tbody td:first-child .muted{white-space:normal}

/* ---- Projetos críticos: valores nunca quebram de linha ---- */
.critical-row{grid-template-columns:minmax(0,1.5fr) repeat(3,minmax(4.5rem,auto))!important;gap:6px 10px!important}
.critical-row strong{min-width:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.25;word-break:break-word}
.critical-row>span{white-space:nowrap;text-align:right}
.critical-row.header>span{text-align:right}
.critical-row.header>span:first-child{text-align:left}

/* ---- Listas de barras (hbar): rótulo e valor com espaço próprio, sem sobrepor ---- */
.bar-row-head{align-items:flex-start!important}
.bar-row-head strong{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;max-width:none!important;line-height:1.25}
.bar-row-head span{max-width:none!important}

/* ---- Campos de filtro: o texto do campo não é cortado no meio da palavra ---- */
.section-controls label,.filter-grid label{min-width:0}
.section-controls input::placeholder{overflow:hidden;text-overflow:ellipsis}

/* ---- Painéis nunca geram rolagem horizontal da página ---- */
.panel{min-width:0;max-width:100%}
.panel .card{min-width:0}

/* ---- Pareto / listas de composição: o nome quebra linha, o valor fica à direita sem cortar ---- */
.pareto-item{align-items:start}
.pareto-item>span{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;text-align:right;line-height:1.25}
.pareto-item>strong,.pareto-item>div:first-child{white-space:normal;min-width:0;line-height:1.25}
.project-name strong{white-space:normal;display:block;line-height:1.25;max-width:min(22rem,100%)}
/* meta dos KPIs do construtor/executivo: 2 linhas em vez de reticências */
.exec-widget .kpi-meta{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;line-height:1.25}

/* ---- Componentes do Executivo: conteúdo longo rola dentro do cartão, nunca é cortado ---- */
.exec-widget{overflow:hidden}
.exec-widget>.exec-hbar,.exec-widget>.exec-insights,.exec-widget>.v19-body{flex:1 1 auto;min-height:0;overflow-y:auto;scrollbar-width:thin}
.exec-hbar{gap:.3rem!important;align-content:start}
.exec-hbar .bar-row{padding:.05rem 0}
.exec-hbar .bar-track{height:1rem}
.exec-hbar .bar-row-head strong,.exec-hbar .bar-row-head span{font-size:.875rem}
.exec-hbar .bar-row-head strong{white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
.exec-insights{gap:.4rem!important}
.exec-insight{padding:.5rem .65rem!important}
.exec-insight p{font-size:.875rem!important;line-height:1.4!important}

/* ---- Análise por Projeto ---- */
.pa-cards{grid-template-columns:repeat(auto-fit,minmax(min(100%,9.5rem),1fr))}
.pa-card{container-type:inline-size;min-width:0}
.pa-card strong{font-size:clamp(1.15rem,12cqi,1.6rem)}
.pa-card span{align-items:flex-start;line-height:1.25}
.pa-card span::before{margin-top:.3em}
.pa-toolbar{align-items:flex-start}
.pa-seg{max-width:100%}
.pa-tools{max-width:100%}
.pa-table .pa-name{min-width:12rem}
.pa-table .pa-name small{white-space:normal}
.pa-alerts{min-width:0}
.pa-table td .pa-chip{white-space:nowrap}
.pa-tools input[type="search"]{min-width:15rem}
.project-focus-field input,#detailSearch{text-overflow:ellipsis}

/* ===== Volume e frete por projeto (volume-frete-projeto.js) ===== */
.pi-block{display:grid;gap:var(--gap,1rem);min-width:0;container-type:inline-size}
.pi-note{margin:0;padding:.6rem .9rem;border:1px solid var(--line);border-left:4px solid var(--ink-2);border-radius:var(--radius-md,8px);background:var(--surface);font-size:.9375rem;line-height:1.5;color:var(--ink)}
.pi-note.is-warn{border-left-color:var(--warning,#c98a00);background:var(--warn-soft,#fff8e6)}
.pi-tiles{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.6rem}
@container (min-width:32rem){.pi-tiles{grid-template-columns:repeat(3,minmax(0,1fr))}}
@container (min-width:56rem){.pi-tiles{grid-template-columns:repeat(6,minmax(0,1fr))}}
.pi-tile{--tc:var(--ink-2);display:flex;flex-direction:column;gap:.15rem;min-width:0;padding:.7rem .8rem;border:1px solid var(--line);border-top:3px solid var(--tc);border-radius:var(--radius-md,8px);background:var(--surface)}
.pi-tile.tone-warn{--tc:var(--warning,#c98a00)}
.pi-tile.tone-serious{--tc:var(--danger,#b3261e)}
.pi-tile.tone-ok{--tc:var(--ok,#1a7f37)}
.pi-t-label{font-size:.8125rem;font-weight:600;color:var(--ink-2)}
.pi-tile b{font-family:var(--font-num);font-variant-numeric:tabular-nums;font-size:clamp(1.2rem,1.9vw,1.55rem);line-height:1.1;color:var(--ink)}
.pi-tile small{font-size:.8125rem;color:var(--muted)}
.pi-t-cmp{margin-top:.2rem;font-size:.8125rem;line-height:1.3;color:var(--ink-2)}
.pi-badge{align-self:flex-start;display:inline-flex;align-items:center;gap:.3rem;margin-top:.3rem;padding:.1rem .5rem;border-radius:999px;border:1px solid var(--line);background:var(--surface-2,#f4f6f5);font-size:.75rem;line-height:1.3;color:var(--ink-2);white-space:nowrap}
.pi-badge i{width:.5rem;height:.5rem;border-radius:50%;background:var(--ink-2)}
.pi-badge.tone-ok i{background:var(--ok,#1a7f37)}
.pi-badge.tone-warn i{background:var(--warning,#c98a00)}
.pi-badge.tone-serious i{background:var(--danger,#b3261e)}
.pi-charts{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,22rem),1fr));gap:var(--gap,1rem)}
.pi-charts>.pi-chart:first-child{grid-column:1/-1}
.pi-chart{display:flex;flex-direction:column;height:25rem;min-width:0}
.pi-chart .v19-card,.pi-chart.v19-card{flex:1 1 auto;min-height:0}
.pi-table-wrap{display:grid;gap:.4rem;min-width:0}
.pi-table-wrap h4{margin:0;font-size:1rem;font-weight:600;color:var(--ink)}
.pi-table-wrap h4 span{margin-left:.4rem;font-size:.8125rem;font-weight:400;color:var(--muted)}
.pi-help{margin:0;font-size:.8125rem;line-height:1.45;color:var(--muted);max-width:100ch}
.pi-table-scroll{overflow:auto;max-height:24rem;border:1px solid var(--line);border-radius:var(--radius-md,8px);background:var(--surface);scrollbar-width:thin}
.pi-table{width:100%;border-collapse:separate;border-spacing:0;font-size:.8125rem;font-variant-numeric:tabular-nums}
.pi-table thead th{position:sticky;top:0;z-index:2;padding:.5rem .55rem;background:var(--surface-2,#f4f6f5);border-bottom:1px solid var(--line-strong,var(--line));font-weight:600;color:var(--ink-2);text-align:left;white-space:nowrap}
.pi-table th.num,.pi-table td.num{text-align:right;font-family:var(--font-num);white-space:nowrap}
.pi-table tbody th{position:sticky;left:0;padding:.4rem .55rem;background:var(--surface);border-bottom:1px solid var(--line);font-weight:600;text-align:left;white-space:nowrap;color:var(--ink)}
.pi-table tbody td{padding:.4rem .55rem;border-bottom:1px solid var(--line);color:var(--ink)}
.pi-table td.is-muted{color:var(--muted)}
.pi-table td.tone-warn{background:var(--warn-soft,#fff3d6);font-weight:600}
.pi-table td.tone-serious{background:var(--crit-soft,#fde4e1);font-weight:600;color:var(--crit-text,#8f1d14)}
.pi-table tr.pi-total th,.pi-table tr.pi-total td{background:var(--surface-2,#f4f6f5);font-weight:700;border-top:1px solid var(--line-strong,var(--line))}
/* dentro da gaveta de Análise por Projeto e da aba Projetos */
.pa-sec .pi-block,.project-focus-card .pi-block{margin-top:.25rem}
.project-focus-card .pi-section{margin:0 var(--pad-card) var(--pad-card);padding-top:var(--gap,1rem);border-top:1px solid var(--line);min-width:0}
.project-focus-card .pi-section>h4{margin:0 0 .6rem;font-size:1rem}
/* seção Projeto a projeto da aba Volume e Frete */
.ins-project-grid{display:grid!important;grid-template-columns:minmax(0,1fr)!important;grid-auto-rows:auto!important;gap:var(--gap,1rem)}
.ins-pick{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .75rem;padding:.7rem var(--pad-card,16px);border:1px solid var(--line);border-radius:var(--radius-lg,12px);background:var(--surface)}
.ins-pick label{font-weight:600;font-size:.9375rem}
.ins-pick select{flex:1 1 18rem;min-width:0;max-width:34rem;min-height:2.25rem;padding:0 .6rem;border:1px solid var(--control-border);border-radius:var(--radius-md,8px);background:var(--surface);color:var(--ink);font-size:.9375rem}
.ins-pick input{flex:0 1 12rem;min-width:0;min-height:2.25rem;padding:0 .7rem;border:1px solid var(--control-border);border-radius:var(--radius-md,8px);background:var(--surface);color:var(--ink);font-size:.9375rem}
.ins-pick-count{font-size:.8125rem;color:var(--muted)}
.ins-project-body{min-width:0}
@container (max-width:660px){.data-table .type-tag{max-width:7.5rem;font-size:10.5px;padding:3px 6px}}

/* ===== Ordenação por cabeçalho (table-sort-v20.js) ===== */
.data-table thead th.is-sortable,.pi-table thead th.is-sortable,.pa-mini thead th.is-sortable{position:sticky;cursor:pointer;user-select:none;padding-right:1.5rem!important}
.pi-table thead th.is-sortable::after,.pa-mini thead th.is-sortable::after{content:"";position:absolute;right:.55rem;top:50%;width:.45rem;height:.45rem;margin-top:-.3rem;border-right:1.5px solid var(--muted);border-bottom:1.5px solid var(--muted);transform:rotate(45deg);opacity:.35;transition:opacity .14s}
.data-table thead th.is-sortable::after{opacity:.35}
.data-table thead th.is-sortable:hover::after,.pi-table thead th.is-sortable:hover::after,.pa-mini thead th.is-sortable:hover::after{opacity:.8}
.pi-table thead th.sort-asc::after,.pa-mini thead th.sort-asc::after{opacity:1;transform:rotate(-135deg);margin-top:-.1rem;border-color:var(--ink)}
.pi-table thead th.sort-desc::after,.pa-mini thead th.sort-desc::after{opacity:1;transform:rotate(45deg);border-color:var(--ink)}
th.is-sortable:focus-visible{outline:2px solid var(--focus,var(--brand-text,#1a7b56));outline-offset:-2px}
th.is-sortable[aria-sort="ascending"],th.is-sortable[aria-sort="descending"]{color:var(--ink)}
.pi-table thead th:first-child{z-index:3}
.exec-table-foot{flex:none;display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:.5rem var(--pad-card,16px);border-top:1px solid var(--line);font-size:.8125rem;color:var(--muted)}
.v19-body .exec-table-foot{padding-inline:0;margin-top:.4rem}
.exec-widget>.exec-table-scroll{flex:1 1 auto;min-height:0;overflow:auto}

@container (max-width:760px){
  .data-table thead th.is-sortable{padding-right:15px!important}
  .data-table thead th.is-sortable::after{right:.3rem}
}

/* cartão compacto do Executivo e de Volume e Frete: duas variações lado a lado e tendência no canto */
.exec-widget.kpi-card:has(.kpi-cmp){position:relative;padding-top:.6rem;padding-bottom:.45rem}
.exec-widget .kpi-cmp{flex-direction:row;flex-wrap:wrap;gap:0 .75rem;margin-top:.3rem}
.exec-widget.kpi-card:has(.kpi-cmp) .kpi-label{padding-right:4.75rem;white-space:nowrap!important}
.exec-widget.kpi-card:has(.kpi-cmp) .kpi-label span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap!important}
.exec-widget.kpi-card:has(.kpi-cmp) .kpi-spark{position:absolute;top:.5rem;right:.9rem;width:4rem;height:1.1rem;min-height:1.1rem;margin:0}
.exec-widget.kpi-card:has(.kpi-cmp) .kpi-spark svg,.exec-widget.kpi-card:has(.kpi-cmp) .kpi-spark>*{height:1.1rem!important;min-height:1.1rem}
.kpi-cmp b{font-variant-numeric:normal}
