/* Planilha de saídas — lançamento item por item (tokens em instituto.css / isv.css) */

.log-main {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px 96px;
}

.log-top {
  display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px;
  margin-bottom: 16px;
}
.log-title { font-size: 20px; color: var(--title); }
.log-sub { font-size: 14px; color: var(--text-soft); margin-top: 2px; }
.unit-label { font-weight: 700; color: var(--title); }

.log-select, .log-search input {
  min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--input-bd); border-radius: 10px;
  background: var(--input-bg); color: var(--instituto-text);
  font: inherit; font-size: 14px;
}

.log-toolbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 12px;
}
.log-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.log-tab {
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--borda-controle); border-radius: 10px;
  background: var(--instituto-surface); color: var(--text-soft);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.log-tab[aria-selected="true"] { background: var(--tint); border-color: var(--title); color: var(--title); }
.log-tab .count { font-weight: 600; opacity: .8; }
.log-search input { width: min(360px, 100%); }
.log-search { flex: 1; display: flex; justify-content: flex-end; }
.log-toolbar { gap: 10px 12px; }

/* tabela */
.log-table-wrap { overflow: auto; max-height: calc(100vh - 300px); min-height: 320px; border: 1px solid var(--instituto-border); }
.log-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.log-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--instituto-surface);
  padding: 10px 12px; text-align: right; white-space: nowrap;
  font-size: 13px; font-weight: 700; color: var(--text-soft);
  border-bottom: 2px solid var(--instituto-border);
}
.log-table th:first-child, .log-table td:first-child { text-align: left; }
.log-table th.col-aberto { color: var(--title); background: var(--tint); }
.log-table td {
  padding: 6px 12px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--instituto-border);
  font-variant-numeric: tabular-nums; color: var(--text-soft);
}
.log-table td.produto {
  white-space: normal; min-width: 260px; max-width: 460px;
  color: var(--instituto-text); font-weight: 600; overflow-wrap: anywhere;
}
/* produto fixo à esquerda: ao rolar para os campos, o nome do item continua à vista */
.log-table th:first-child, .log-table td.produto {
  position: sticky; left: 0; z-index: 1;
  background: var(--instituto-surface);
  border-right: 1px solid var(--instituto-border);
}
.log-table th:first-child { z-index: 3; }
.log-table tr:hover td.produto { background: var(--soft); }
.log-table td.col-aberto { background: var(--tint); }
.log-table tr:hover td { background: var(--soft); }
.log-table tr:hover td.col-aberto { background: var(--tint); }
.log-table tr.alterado td.produto { box-shadow: inset 4px 0 0 var(--c-warn); }

.num-input {
  width: 84px; min-height: 36px; padding: 4px 8px;
  border: 1px solid var(--input-bd); border-radius: 8px;
  background: var(--input-bg); color: var(--instituto-text);
  font: inherit; font-size: 14px; text-align: right;
}
.num-input:focus { border-color: var(--instituto-secondary); }
.num-input.subiu { border-color: var(--c-ok); border-width: 2px; }
.num-input.desceu { border-color: var(--c-err); border-width: 2px; }
.num-input.invalido { border: 2px dashed var(--c-err); background: var(--err-bg); }

.log-empty { padding: 24px; text-align: center; color: var(--text-soft); }

/* cobertura: quantos meses o estoque dura no ritmo do CMM */
.log-table th.col-cob, .log-table td.col-cob { text-align: left; min-width: 118px; }
.log-table td.cob { padding-block: 8px; }
.cob-txt { display: block; font-size: 13px; font-weight: 700; color: var(--instituto-text); }
.cob-barra { display: block; height: 5px; margin-top: 5px; border-radius: 5px; overflow: hidden; background: var(--instituto-border); }
.cob-barra i { display: block; height: 100%; width: calc(var(--w, 0) * 1%); border-radius: inherit; background: var(--c-ok); }
.cob.warn .cob-txt { color: var(--alert-warn-text); }
.cob.warn .cob-barra i { background: var(--c-warn); }
.cob.bad .cob-txt { color: var(--c-err); }
.cob.bad .cob-barra i { background: var(--c-err); }
.cob.na .cob-txt { color: var(--text-soft); font-weight: 600; }
.log-table tr[data-critico="1"] td.produto::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%;
  background: var(--c-err); vertical-align: 1px;
}
.log-table tr.esqueleto td { padding: 10px 12px; border-bottom: 1px solid var(--instituto-border); }

.log-tools { display: flex; align-items: center; }
.log-filtro {
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--borda-controle); border-radius: 10px;
  background: var(--instituto-surface); color: var(--text-soft);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.log-filtro .count { font-weight: 600; }
.log-filtro[aria-pressed="true"] { background: var(--err-bg); border-color: var(--c-err); color: var(--c-err); }
.log-filtro:disabled { background: var(--soft); border-color: var(--instituto-border); color: var(--text-soft); cursor: default; }

/* barra de salvar, fixa no rodapé da janela */
.save-bar {
  position: sticky; bottom: 0; z-index: 50;
  display: flex; justify-content: flex-end; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 32px;
  background: var(--instituto-surface);
  border-top: 1px solid var(--instituto-border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}
#save-info { font-size: 14px; color: var(--text-soft); }
#save-info.pendente { color: var(--alert-warn-text); font-weight: 700; }
#save-info.salvo { color: var(--c-ok); font-weight: 700; }
.log-dica { font-size: 13px; color: var(--text-soft); margin: -4px 0 12px; }
#btnSalvar:disabled { background: var(--soft); border: 1px solid var(--instituto-border); color: var(--text-soft); opacity: 1; cursor: not-allowed; transform: none; box-shadow: none; }

/* celular: cada item vira um bloco (nome em cima, três campos lado a lado), sem rolagem lateral */
@media (max-width: 700px) {
  .log-toolbar { position: sticky; top: 0; z-index: 20; padding: 8px 0; background: var(--instituto-bg); }
  .log-table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .log-table, .log-table tbody { display: block; }
  .log-table thead { display: none; }
  .log-table tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px;
    margin-bottom: 10px; padding: 14px;
    background: var(--instituto-surface); border: 1px solid var(--instituto-border); border-radius: 14px;
  }
  .log-table tr.alterado { border-color: var(--c-warn); }
  .log-table tr.esqueleto { display: block; }
  .log-table td { display: block; padding: 0; border: 0; text-align: left; background: transparent; }
  .log-table td.produto {
    grid-column: 1 / -1; position: static; min-width: 0; max-width: none; padding-bottom: 4px;
    background: transparent; border: 0; box-shadow: none; font-size: 14px;
  }
  .log-table tr.alterado td.produto { box-shadow: none; }
  .log-table .mes-anterior { display: none; }
  .log-table td.col-aberto::before, .log-table td.col-cob::before {
    content: attr(data-label); display: block; margin-bottom: 3px;
    font-size: 12px; font-weight: 600; color: var(--text-soft);
  }
  .log-table td.col-aberto { background: transparent; }
  .num-input { width: 100%; }
  .log-table td.col-cob { grid-column: 1 / -1; min-width: 0; padding-top: 2px; }
  .log-table tr:hover td, .log-table tr:hover td.produto, .log-table tr:hover td.col-aberto { background: transparent; }
}

@media (max-width: 768px) {
  .log-main { padding: 20px 16px 96px; }
  .save-bar { padding: 12px 16px; }
  .log-search { justify-content: stretch; }
  .log-search input { width: 100%; }
  .log-table td.produto { min-width: 140px; max-width: 180px; font-size: 13px; }
  .log-table .mes-anterior { display: none; } /* no celular, só os campos do mês aberto */
  .num-input { width: 76px; min-height: 44px; }
  .log-table-wrap { max-height: none; }
}

/* ordenar pela coluna de cobertura */
.log-filtro#btn-ordem-cob.ativo { background: var(--info-bg, var(--soft)); border-color: var(--instituto-secondary); color: var(--title); }
.log-tools { gap: 8px; flex-wrap: wrap; }

/* migalhas de pão: caminho de volta para o início e para o acompanhamento mensal */
.migalhas { margin-bottom: 8px; font-size: 13px; }
.migalhas ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; }
.migalhas li + li::before { content: "›"; margin: 0 8px; color: var(--text-soft); }
.migalhas a { color: var(--instituto-secondary); font-weight: 600; text-decoration: none; padding: 4px 2px; border-radius: 4px; }
.migalhas a:hover { text-decoration: underline; }
.migalhas a:focus-visible { outline: 2px solid var(--instituto-secondary); outline-offset: 1px; }
.migalhas [aria-current="page"] { color: var(--text-soft); font-weight: 700; }

@media (max-width: 700px) {
  .migalhas a { display: inline-block; padding: 12px 6px; }
  #btnSalvar { min-height: 44px; }
}
.migalhas a { color: var(--title); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--title) 40%, transparent); }
