/* Informações legado · CSS do protótipo aprovado (smart_pricing-prototipos/app/legado.html + legado.css) com os tokens
   de Indicadores (--ind-*; indicadores.css cobre #tab-legado e a área de impressão #lg-print). Prefixo lg-.
   A gaveta mora dentro de #tab-legado (herda os tokens); a área de impressão vai no body. */
#tab-legado { padding-bottom: 32px; }
.lg-mut { color: var(--ind-mut); }
.lg-mono { font-family: var(--ind-mono); }
.lg-ro { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ind-mut); }
.lg-ro svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.lg-top { display: flex; justify-content: flex-end; margin: -6px 0 12px; }

/* KPIs do topo (peças .ind-kpis/.ind-kpi de indicadores.css) */
#tab-legado .ind-kpis { margin-bottom: 18px; }
#tab-legado .ind-kpi { min-width: 0; }
.lg-kpi-foot { margin-top: 4px; font-size: 12.5px; color: var(--ind-mut); display: block; }

/* Filtros */
.lg-filters { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.lg-f { display: grid; gap: 4px; min-width: 0; max-width: 100%; }
.lg-f > span { font-size: 12px; font-weight: 600; color: var(--ind-mut); }
.lg-f select { height: 38px; border: 1px solid var(--ind-line); border-radius: 10px; background: var(--ind-card); color: var(--ind-ink); padding: 0 10px; font: 400 14px var(--ind-font); max-width: 100%; }
#tab-legado .lg-f .ind-seg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
#tab-legado .lg-f .ind-seg button { min-height: 32px; white-space: nowrap; flex: none; }
.lg-count { margin-left: auto; font-size: 13px; color: var(--ind-mut); align-self: center; }

/* Cartões */
.lg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 14px; }
#tab-legado .lg-card { min-width: 0; text-align: left; color: var(--ind-ink); font: inherit; background: var(--ind-card); border: 1px solid var(--ind-line); border-radius: 16px; padding: 16px; display: grid; gap: 10px; grid-template-rows: auto 1fr auto auto auto; box-shadow: var(--ind-shadow); transition: border-color .18s var(--ind-ease), transform .18s var(--ind-ease); }
/* nome longo ocupa mais linhas: o resto do cartão desce para a base, alinhado com os vizinhos da fileira */
.lg-card > .lg-chart { align-self: end; }
#tab-legado .lg-card:hover { border-color: var(--ind-ink); }
@media (prefers-reduced-motion: no-preference) { #tab-legado .lg-card:hover { transform: translateY(-1px); } }
#tab-legado .lg-card.is-decide { box-shadow: inset 0 0 0 1px var(--ind-ink), var(--ind-shadow); }
#tab-legado .lg-ctop { display: grid; gap: 6px; justify-items: start; min-width: 0; }
#tab-legado .lg-ctop > span:first-child { display: block; min-width: 0; max-width: 100%; }
#tab-legado .lg-ctop strong { display: block; font-size: 16px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; overflow-wrap: break-word; }
#tab-legado .lg-ctop small { display: block; font-size: 12.5px; color: var(--ind-mut); margin-top: 2px; }
#tab-legado .lg-nums { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
#tab-legado .lg-nums > span { display: block; min-width: 0; }
#tab-legado .lg-nums span span { display: block; font-size: 11.5px; color: var(--ind-mut); }
#tab-legado .lg-nums b { font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.lg-card .lg-chart .bar { opacity: .55; }
#tab-legado .lg-exp { display: flex; justify-content: space-between; gap: 8px; font: 400 11px var(--ind-mono); color: var(--ind-mut); white-space: nowrap; }
.lg-empty { grid-column: 1 / -1; text-align: center; padding: 30px; color: var(--ind-mut); }

/* Status da retenção: texto + forma, nunca só cor */
#tab-legado .lg-st { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; box-shadow: inset 0 0 0 1px var(--ind-line); color: var(--ind-ink-2); }
.lg-st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; }
#tab-legado .lg-st.is-warn { background: var(--ind-ink); color: var(--ind-card); box-shadow: none; }
.lg-st.is-warn::before { opacity: 1; background: #FF585D; }
#tab-legado .lg-st.is-over { background: transparent; color: var(--ind-ink); box-shadow: inset 0 0 0 1.5px var(--ind-ink); }
.lg-st.is-over::before { border-radius: 2px; opacity: 1; }
#tab-legado .lg-st.is-ext { color: var(--ind-up); box-shadow: inset 0 0 0 1px currentColor; }

/* Régua de retenção (congelou → hoje → expira) */
.lg-ret { display: grid; gap: 4px; min-width: 0; }
.lg-ret-bar { display: block; position: relative; height: 8px; border-radius: 999px; background: var(--ind-soft); box-shadow: inset 0 0 0 1px var(--ind-line-2); overflow: hidden; }
.lg-ret-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--ind-ink-2); opacity: .55; }
.lg-ret-bar b { position: absolute; top: 0; bottom: 0; right: 0; background: repeating-linear-gradient(135deg, var(--ind-mkt) 0 3px, transparent 3px 6px); opacity: .8; }
.lg-ret.is-warn .lg-ret-bar i { background: var(--ind-ink); opacity: 1; }
.lg-ret-lbl { display: flex; justify-content: space-between; gap: 8px; font: 400 11px var(--ind-mono); color: var(--ind-mut); }

/* Gaveta: fechada fica fora do layout (display none), senão cria rolagem lateral no celular.
   Acima da sidebar do app (z-index 1100), como a do Suporte. */
.lg-scrim { position: fixed; inset: 0; z-index: 1200; background: rgba(26, 26, 46, .4); opacity: 0; pointer-events: none; transition: opacity .2s; }
.lg-scrim.is-on { opacity: 1; pointer-events: auto; }
.lg-drawer { position: fixed; top: var(--banner-h, 0px); right: 0; bottom: 0; z-index: 1210; width: min(720px, 100vw); background: var(--ind-card); color: var(--ind-ink); box-shadow: -24px 0 60px -30px rgba(0, 0, 0, .6); transform: translateX(102%); transition: transform .28s var(--ind-ease); display: none; flex-direction: column; }
.lg-drawer.is-shown { display: flex; }
.lg-drawer.is-on { transform: none; }
/* cabeçalho fixo (nome, situação, prazo e ações); só o corpo rola */
.lg-dh { flex: none; display: grid; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--ind-line-2); }
.lg-dh-top { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; min-width: 0; }
.lg-dh-top > div { min-width: 0; }
#tab-legado .lg-dh h2 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; overflow-wrap: break-word; }
#tab-legado .lg-dh p { color: var(--ind-mut); font-size: 13px; margin-top: 2px; }
#tab-legado .lg-x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; display: grid; place-items: center; flex: none; }
#tab-legado .lg-x:hover { background: var(--ind-soft); }
.lg-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.lg-db { flex: 1; min-height: 0; overflow-y: auto; padding: 0 22px 28px; display: flex; flex-direction: column; gap: 16px; }
.lg-db > * { flex: none; } /* em grid, a faixa de abas (que rola na horizontal) encolhia até sumir */
.lg-tabbar { position: sticky; top: 0; z-index: 2; background: var(--ind-card); padding: 14px 0 10px; margin-bottom: -6px; }
#tab-legado .lg-tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
#tab-legado .lg-tabs button { white-space: nowrap; flex: none; }

/* Ações */
.lg-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#tab-legado .lg-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 11px; border: 1px solid var(--ind-line); border-radius: 9px; background: var(--ind-card); color: var(--ind-ink); font-weight: 600; font-size: 13px; transition: border-color .18s var(--ind-ease); }
#tab-legado .lg-btn:hover:not(:disabled) { border-color: var(--ind-ink); }
#tab-legado .lg-btn:disabled { opacity: .45; cursor: not-allowed; }
#tab-legado .lg-btn.is-risk { box-shadow: inset 0 0 0 1px var(--ind-ink); }

/* Dossiê (resumo em caixa + seções); também na impressão */
.lg-box { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; margin: 0; padding: 16px 18px; border-radius: 14px; background: var(--ind-soft); box-shadow: inset 0 0 0 1px var(--ind-line-2); }
.lg-box dt { font-size: 12px; color: var(--ind-mut); }
.lg-box dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; overflow-wrap: break-word; }
.lg-sec { display: grid; gap: 12px; }
.lg-sec + .lg-sec { margin-top: 22px; }
:is(#tab-legado, #lg-print) .lg-sec h3 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.lg-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lg-kpi { padding: 10px 12px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--ind-line); min-width: 0; }
:is(#tab-legado, #lg-print) .lg-kpi span { display: block; font-size: 12px; color: var(--ind-mut); }
:is(#tab-legado, #lg-print) .lg-kpi strong { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; }
.lg-chart { width: 100%; height: auto; display: block; overflow: visible; }
.lg-chart .bar { fill: var(--ind-own); opacity: .85; }
.lg-chart .bar:hover { opacity: 1; }
.lg-chart .occ { fill: none; stroke: var(--ind-mkt); stroke-width: 2; }
.lg-chart text { font: 400 10.5px var(--ind-mono); fill: var(--ind-mut); }
.lg-chart .gl { stroke: var(--ind-line-2); }
.lg-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ind-mut); }
.lg-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg-scroll { overflow-x: auto; }
:is(#tab-legado, #lg-print) .lg-tbl { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 13.5px; }
:is(#tab-legado, #lg-print) .lg-tbl th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ind-mut); padding: 7px 10px; border-bottom: 1px solid var(--ind-line); white-space: nowrap; }
:is(#tab-legado, #lg-print) .lg-tbl td { padding: 7px 10px; border-bottom: 1px solid var(--ind-line-2); }
:is(#tab-legado, #lg-print) .lg-tbl .num { text-align: right; }
:is(#tab-legado, #lg-print) .lg-tbl tfoot td { font-weight: 700; border-top: 1px solid var(--ind-line); border-bottom: 0; }
.lg-ch { display: grid; grid-template-columns: 120px minmax(0, 1fr) 80px; align-items: center; gap: 10px; font-size: 13.5px; }
.lg-ch-bar { display: block; height: 8px; border-radius: 999px; background: var(--ind-soft); overflow: hidden; }
.lg-ch-bar i { display: block; height: 100%; background: var(--ind-mkt); border-radius: 999px; }
:is(#tab-legado, #lg-print) .lg-ch > span:last-child { text-align: right; font-family: var(--ind-mono); font-size: 12px; }
.lg-int { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lg-int > div { padding: 12px 14px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--ind-line); font-size: 13.5px; }
:is(#tab-legado, #lg-print) .lg-int strong { display: block; font-size: 14.5px; }
.lg-ev { list-style: none; margin: 0; padding: 0; display: grid; }
.lg-ev li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--ind-line-2); font-size: 13.5px; }
.lg-ev time { font: 400 11.5px var(--ind-mono); color: var(--ind-mut); padding-top: 2px; }
:is(#tab-legado, #lg-print) .lg-ev small { display: block; color: var(--ind-mut); font-size: 12.5px; }
:is(#tab-legado, #lg-print) .lg-na { font-size: 13.5px; color: var(--ind-mut); padding: 10px 12px; border-radius: 10px; background: var(--ind-soft); }

/* Janelas (sp-dialog do dialog.js): o protótipo tinha um seletor e um campo de texto longo */
.lg-dialog .sp-dialog-field select, .lg-dialog .sp-dialog-field textarea { min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--sp-line); background: var(--c-bg); color: var(--sp-ink); font: 400 15px var(--sp-font); }
.lg-dialog .sp-dialog-field textarea { min-height: 84px; padding: 9px 12px; resize: vertical; }
.lg-dialog .sp-dialog-field small { font-weight: 400; font-size: 12.5px; color: var(--sp-mut); }
.lg-dialog .lg-err { color: var(--sp-ink); font-weight: 600; }
.lg-dialog .lg-err:empty { display: none; }

/* Impressão do dossiê (Exportar PDF): só a área #lg-print sai no papel */
#lg-print { display: none; }
@media print {
  body.lg-printing > *:not(#lg-print) { display: none !important; }
  body.lg-printing { background: #FBFAF8 !important; }
  /* papel é sempre claro, mesmo com o app no escuro */
  body.lg-printing #lg-print {
    display: block; padding: 0;
    --ind-ink: #1A1A2E; --ind-ink-2: #2E2E3A; --ind-mut: #52525E; --ind-card: #FBFAF8; --ind-soft: #F4F2ED;
    --ind-line: rgba(26, 26, 46, .13); --ind-line-2: rgba(26, 26, 46, .08); --ind-up: #0B6F68;
    color: #1A1A2E; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  #lg-print h1 { font-size: 22px; margin: 0 0 4px; }
  #lg-print .lg-scroll { overflow: visible; }
  #lg-print .lg-tbl { min-width: 0; }
  .lg-sec { break-inside: avoid; }
}

@media (max-width: 900px) {
  .lg-box { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg-int { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  #tab-legado .ind-kpi-value { font-size: 18px; }
  .lg-count { margin-left: 0; }
  .lg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg-ch { grid-template-columns: 84px minmax(0, 1fr) 64px; }
  .lg-dh, .lg-db { padding-left: 16px; padding-right: 16px; }
}
.lg-dialog .sp-dialog-btn:disabled { opacity: .45; cursor: not-allowed; }
