.projeto-efatura,
.simol-projeto-despesas-declaradas,
.simol-despesas-criar-declaracao {
  max-width: 1080px;
  margin-inline: auto;
}

.simol-despesas-resumo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px 20px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid #d6e1ea;
  background: #f5f8fb;
}

.simol-despesas-ano,
.simol-despesas-total {
  display: grid;
  gap: 4px;
  color: #334c63;
  font-weight: 600;
}

.simol-despesas-anos { display: flex; align-items: center; gap: 8px; }
.simol-despesas-anos button { min-width: 32px; min-height: 32px; }
.simol-despesas-ano-valor { font-size: 18px; }
.simol-despesas-total { text-align: end; }
.simol-despesas-total output { padding: 0; color: #165980; font-size: 22px; font-weight: 700; }
.simol-despesas-ano-valor,
.simol-despesas-total output,
.simol-despesas-tabela td,
.simol-despesas-exigencia strong { font-variant-numeric: tabular-nums; }

.projeto-efatura-rodape-ficha { display: contents; }
.projeto-efatura .projeto-efatura-contexto { grid-column: 1 / -1; margin: 0; color: #475c6d; }
.projeto-efatura .projeto-efatura-contexto:empty { display: none; }
.projeto-efatura-acoes-ficha { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 12px; }
.projeto-efatura-acoes-ficha:not(:has(button:not([hidden]))) { display: none; }
.projeto-efatura-acoes-ficha button { padding-inline: 0; text-align: start; text-transform: none; white-space: normal; }
.projeto-efatura-iva-curto { display: none; }

.simol-projeto-despesas-declaradas {
  margin-block: 0 12px;
  padding: 8px 12px;
  border-inline-start: 3px solid #9bb8ce;
  background: #f5f8fb;
}
.simol-projeto-despesas-declaradas > summary { cursor: pointer; font-weight: 600; }
.simol-projeto-despesas-declaradas > p { margin: 8px 0; }
.simol-despesas-criar-declaracao { margin-bottom: 12px; }
.simol-efatura-declaracoes { display: grid; gap: 8px; margin-block: 8px; }
.simol-efatura-declaracoes li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.simol-efatura-declaracoes .btn { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: start; }

.simol-despesas-tabela { width: 100%; border-collapse: collapse; table-layout: fixed; }
.simol-despesas-tabela :is(th, td) { padding: 10px 12px; border-bottom: 1px solid #dbe5ed; }
.simol-despesas-tabela thead { background: #e9f1f7; color: #25455f; }
.simol-despesas-tabela thead th { font-weight: 600; }
.simol-despesas-tabela tbody th { font-weight: 600; }
.simol-despesas-rotulo-movel { display: none; }
.simol-despesas-tabela :where(th, td):not(:first-child) { text-align: end; }
.simol-despesas-tabela thead th:nth-child(2),
.simol-despesas-tabela thead th:nth-child(3) { width: 20%; }
.simol-despesas-tabela thead th:last-child { width: 108px; }
.simol-despesas-tabela td:nth-child(3) { color: #165980; font-weight: 600; }
.projeto-efatura-editar { text-transform: none; }

.simol-despesas-exigencia { margin-top: 12px; border: 1px solid #d6e1ea; }
.simol-despesas-exigencia > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 10px;
  align-items: center;
  gap: 6px 16px;
  padding: 10px 12px;
  color: #25455f;
  background: #f5f8fb;
  cursor: pointer;
}
.simol-despesas-exigencia > summary::-webkit-details-marker { display: none; }
.simol-despesas-exigencia > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.simol-despesas-exigencia[open] > summary::after { transform: rotate(225deg); }
.simol-despesas-exigencia > summary > span:first-of-type { font-weight: 700; }
.simol-despesas-exigencia strong { color: #165980; }
.simol-despesas-exigencia tr:last-child > :is(th, td) { border-bottom: 0; }
.projeto-efatura :is(button, input, summary):focus-visible,
.simol-projeto-despesas-declaradas > summary:focus-visible { outline: 2px solid #1670a6; outline-offset: 2px; }

.projeto-efatura .projeto-efatura-editor {
  width: min(460px, calc(100% - 24px));
  max-height: min(85vh, 760px);
  overflow: auto;
  padding: 16px;
  border: 1px solid #c1d2df;
  border-radius: 8px;
  color: #333;
}
.projeto-efatura .projeto-efatura-editor::backdrop { background: #112d4790; }
.projeto-efatura .projeto-efatura-editor h3 { margin: 0 0 12px; font-size: 20px; }
.projeto-efatura .projeto-efatura-instrucao { color: #475c6d; }
.projeto-efatura .projeto-efatura-rubrica {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 9em);
  align-items: center;
  gap: 6px 10px;
  margin-block: 0 10px;
}
.projeto-efatura .projeto-efatura-rubrica legend { margin: 0 0 5px; font-size: 15px; font-weight: 600; }
.projeto-efatura .projeto-efatura-rubrica label { margin: 0; font-weight: 400; }
.projeto-efatura .projeto-efatura-rubrica .projeto-efatura-instrucao { grid-column: 1 / -1; margin: 0 0 4px; }
.projeto-efatura .projeto-efatura-montante {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 2px 6px;
  border: 1px solid #9eafbd;
  border-radius: 4px;
  font-size: 16px;
  text-align: right;
}
.projeto-efatura .projeto-efatura-montante[aria-invalid="true"] { border-color: #a52216; }
.projeto-efatura .projeto-efatura-rendas-interior { grid-column: 1 / -1; }
.projeto-efatura .projeto-efatura-rendas-interior input[type="checkbox"] {
  position: static;
  clip: auto;
  width: 1em;
  height: 1em;
  margin: 0;
  opacity: 1;
  appearance: auto;
}
.projeto-efatura .projeto-efatura-editor-acoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
}
.projeto-efatura .projeto-efatura-editor-acoes .btn-link { margin-inline-end: auto; }
@media (max-width: 767px), (max-width: 991px) and (pointer: coarse) {
  .simol-despesas-resumo {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px 10px;
    padding: 8px 10px;
  }
  .simol-despesas-ano > span { display: none; }
  .simol-despesas-anos { gap: 5px; white-space: nowrap; }
  .projeto-efatura .simol-despesas-anos button {
    min-width: 32px;
    padding-inline: 6px;
    border: 1px solid #c9dce9;
    border-radius: 4px;
    background: #fff;
    box-shadow: none;
    color: #25455f;
  }
  .simol-despesas-total {
    display: flex;
    align-items: baseline;
    justify-content: end;
    gap: 8px;
    font-size: 13px;
    line-height: 1.25;
  }
  .simol-despesas-total output { font-size: 20px; white-space: nowrap; }
  .projeto-efatura .projeto-efatura-contexto { font-size: 13px; line-height: 1.3; }
  .projeto-efatura-rodape-ficha {
    display: flex;
    grid-column: 1 / -1;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding-top: 6px;
    border-top: 1px solid #d6e1ea;
  }
  #projeto-efatura-contexto { flex: 1 1 145px; min-width: 0; overflow-wrap: anywhere; }
  .projeto-efatura-acoes-ficha { gap: 4px 8px; }
  .projeto-efatura .projeto-efatura-acoes-ficha .btn {
    min-height: 30px;
    padding: 4px 6px;
    border: 1px solid #c9dce9;
    border-radius: 4px;
    background: #fff;
    color: #165980;
    font-size: 12px;
    text-transform: none;
  }
  .projeto-efatura .projeto-efatura-acoes-ficha .projeto-efatura-eliminar { color: #902a20; }
  .simol-despesas-resumo :is(button:hover:not(:disabled), button:focus-visible) { background: #e7f0f7; }
  .simol-despesas-resumo button:focus-visible { outline: 2px solid #1670a6; outline-offset: 1px; }
}
@media (max-width: 479px) {
  .projeto-efatura-iva-curto { display: inline; }
  .projeto-efatura-iva-completo { display: none; }
  .simol-despesas-total {
    flex-direction: column;
    align-items: end;
    gap: 2px;
    font-size: 12px;
    text-align: end;
  }
  .simol-despesas-total output { font-size: 18px; line-height: 1.15; }
}

@media (max-width: 540px) {
  .simol-despesas-criar-declaracao .btn,
  .simol-projeto-despesas-declaradas .btn { min-height: 32px; text-transform: none; }
  .simol-projeto-despesas-declaradas > summary { min-height: 28px; align-content: center; }
  .simol-despesas-tabela, .simol-despesas-tabela tbody { display: block; }
  .simol-despesas-tabela thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .simol-despesas-tabela tbody tr:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: 3px 8px;
    padding: 6px 10px;
    border-bottom: 1px solid #dbe5ed;
  }
  .simol-despesas-tabela tbody tr > :is(th, td) {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: start;
    overflow-wrap: anywhere;
  }
  .simol-despesas-tabela tbody th { grid-column: 1 / -1; }
  .simol-despesas-tabela tbody td:nth-child(3) { font-weight: 700; }
  .simol-despesas-rotulo-movel { display: block; color: #475c6d; font-size: 11px; font-weight: 400; line-height: 1.15; }
  .simol-despesas-rotulo-movel::before { content: attr(data-rotulo); }
  .simol-despesas-valor { display: block; margin-top: 2px; }
  .simol-despesas-tabela tbody td:last-child:not(:empty) { align-self: center; grid-column: 3; grid-row: 1 / span 2; }
  .simol-despesas-tabela tbody td:last-child:empty { display: none; }
  .simol-despesas-tabela tbody tr:has(.projeto-efatura-editar) > th { grid-column: 1 / 3; }
  .projeto-efatura .simol-despesas-tabela .btn {
    min-height: 32px;
    padding-inline: 8px;
    border: 1px solid #c9dce9;
    border-radius: 5px;
    background: #f5f8fb;
    color: #165980;
    text-transform: none;
  }
  .simol-despesas-exigencia > summary { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 10px; gap: 3px 8px; min-height: 36px; }
  .simol-despesas-exigencia > summary > span:first-of-type { grid-column: 1 / 3; }
  .simol-despesas-exigencia > summary > span:not(:first-of-type) { font-size: 13px; }
  .simol-despesas-exigencia > summary::after { grid-area: 1 / 3; }
}

@media (max-width: 540px), (max-height: 540px) and (pointer: coarse) {
  .projeto-efatura .projeto-efatura-editor {
    width: calc(100% - 18px);
    max-height: min(92vh, 760px);
    max-height: min(92dvh, 760px);
    padding: 12px;
  }
}

@media (max-width: 540px), (max-height: 540px) {
  .projeto-efatura .projeto-efatura-editor[open] { display: flex; flex-direction: column; overflow: hidden; }
  .projeto-efatura .projeto-efatura-editor h3 { flex: none; margin-bottom: 8px; }
  .projeto-efatura .projeto-efatura-editor form { display: flex; flex-direction: column; min-height: 0; }
  .projeto-efatura .projeto-efatura-editor-corpo { min-height: 0; overflow: auto; padding: 3px; }
  .projeto-efatura .projeto-efatura-editor-acoes { flex: none; gap: 4px 6px; padding-top: 6px; border-top: 1px solid #d6e1ea; }
  .projeto-efatura .projeto-efatura-editor-acoes .btn { min-height: 36px; padding-inline: 8px; font-size: 13px; text-transform: none; }
  .projeto-efatura .projeto-efatura-editor-acoes .btn-link { padding-inline-start: 0; }
}

@media (pointer: coarse) {
  .projeto-efatura .projeto-efatura-editar { min-height: 32px; }
}
