/* Revisão de registros preparados pelo chat; usa os temas do aplicativo. */
dialog.chl-modal {
  width: min(880px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  background: var(--superficie);
  color: var(--tinta);
  border: 1px solid var(--linha);
  border-radius: var(--raio-lg);
  box-shadow: var(--sombra-lg);
}
.chl-modal *, .chl-modal *::before, .chl-modal *::after { box-sizing: border-box; }
.chl-modal[open] { display: flex; }
.chl-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-height: inherit;
  overflow: hidden;
  margin: 0;
  font: inherit;
}
.chl-cabecalho { flex: 0 0 auto; padding: var(--e-5); border-bottom: 1px solid var(--linha); }
.chl-cabecalho h2 { margin: 0; font-family: var(--fonte-titulo); font-size: var(--txt-xl); font-weight: 650; }
.chl-instrucao { margin: var(--e-2) 0 0; color: var(--tinta-suave); font-size: 1rem; line-height: 1.5; }
.chl-modal .chl-modal-corpo {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  padding: var(--e-5);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding: var(--e-4);
}
.chl-linha { min-width: 0; padding: 0 0 var(--e-5); }
.chl-linha + .chl-linha { padding-top: var(--e-5); border-top: 1px solid var(--linha); }
.chl-linha-cabecalho { display: flex; align-items: center; justify-content: space-between; gap: var(--e-3); margin-bottom: var(--e-3); }
.chl-linha h3 { min-width: 0; margin: 0; font-size: var(--txt-lg); font-weight: 650; }
.chl-remover { flex: 0 0 auto; }
.chl-campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--e-4); }
.chl-modal .chl-campo { display: flex; flex-direction: column; min-width: 0; gap: var(--e-2); font-size: 1rem; font-weight: 600; }
.chl-modal .chl-campo :is(input, select, textarea) {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: var(--alvo-interface, 44px);
  padding: var(--e-3);
  border: 1px solid var(--linha);
  border-radius: var(--raio-sm);
  background: var(--fundo);
  color: var(--tinta);
  font: inherit;
  font-weight: 400;
  line-height: 1.4;
}
.chl-modal .chl-campo textarea { resize: vertical; }
.chl-modal :is(button, summary) { min-height: var(--alvo-interface, 44px); }
.chl-modal :is(input, select, textarea, button, summary):focus-visible { outline: 3px solid var(--verde-600); outline-offset: 2px; }
.chl-modal :is(input, select, textarea, button):disabled { opacity: .65; cursor: default; }
.chl-detalhes { min-width: 0; margin-top: var(--e-4); }
.chl-detalhes summary { padding: var(--e-3) 0; font-size: 1rem; font-weight: 600; cursor: pointer; }
.chl-campos-detalhes { padding-top: var(--e-3); }
.chl-dica-campo { display: block; margin: 0; color: var(--tinta-suave); font-size: var(--txt-md); font-weight: 400; line-height: 1.45; }
.chl-rodape { flex: 0 0 auto; min-width: 0; padding: var(--e-4) var(--e-5); border-top: 1px solid var(--linha); background: var(--superficie); }
.chl-quantidade { margin: 0 0 var(--e-2); font-weight: 600; }
.chl-totais { display: flex; flex-wrap: wrap; gap: var(--e-3) var(--e-5); margin-bottom: var(--e-2); }
.chl-totais > div { display: flex; flex-wrap: wrap; align-items: baseline; min-width: 0; gap: var(--e-2); }
.chl-totais span { color: var(--tinta-suave); font-size: var(--txt-md); }
.chl-totais strong { font-size: var(--txt-lg); font-variant-numeric: tabular-nums; }
.chl-acoes { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--e-3); margin-top: var(--e-3); }
.chl-acoes .btn { margin: 0; }
.chl-erro { margin: var(--e-3) 0 0; color: var(--vermelho); font-size: 1rem; line-height: 1.5; }
.chl-erro[hidden] { display: none; }
.chl-linha-invalida h3 { color: var(--vermelho); }
.chl-dados-anteriores { margin-top: var(--e-4); padding: var(--e-3); background: var(--atencao-suave); border-radius: var(--raio-sm); }
.chl-dados-anteriores p { margin: 0; line-height: 1.5; }
.chl-dados-anteriores ul { padding-left: var(--e-5); line-height: 1.5; }
.chl-dados-anteriores li { min-width: 0; overflow-wrap: anywhere; }
.chl-status { margin: var(--e-2) 0 0; color: var(--tinta-suave); font-size: 1rem; line-height: 1.45; }
.chl-status:empty { display: none; }
.chl-modal :is(label, span, p, h2, h3, strong, summary, button) { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  dialog.chl-modal { width: calc(100vw - 16px); max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .chl-cabecalho, .chl-modal .chl-modal-corpo { padding: var(--e-4); }
  .chl-rodape { padding: var(--e-3) var(--e-4); }
  .chl-campos { grid-template-columns: minmax(0, 1fr); gap: var(--e-3); }
  .chl-cabecalho h2 { font-size: var(--txt-lg); }
  .chl-acoes .btn { flex: 1 1 120px; }
}
@media (max-height: 560px) {
  .chl-cabecalho { padding-block: var(--e-3); }
  .chl-instrucao, .chl-rodape > .chl-dica-campo { display: none; }
  .chl-rodape { padding-block: var(--e-2); }
  .chl-quantidade, .chl-totais { margin-bottom: var(--e-1); }
}
:root[data-viewport-baixo] .chl-cabecalho { padding-block: var(--e-2); }
:root[data-viewport-baixo] .chl-instrucao,
:root[data-viewport-baixo] .chl-rodape > .chl-dica-campo { display: none; }
:root[data-viewport-baixo] .chl-rodape { padding-block: var(--e-2); }
:root[data-viewport-baixo] .chl-quantidade,
:root[data-viewport-baixo] .chl-totais { margin-bottom: var(--e-1); }
@media (prefers-reduced-motion: reduce) {
  .chl-modal, .chl-modal * { scroll-behavior: auto; transition: none; animation: none; }
}
