/* Embalagens — o que compramos de embalagem, de quem e em que mês.
   Espaçamento em múltiplos de 4. Cor é semântica e sempre vem com texto ou ícone:
   vermelho = compra que não entrou no estoque do produto, verde = sem pendência,
   âmbar = aviso de fonte ou código deduzido, azul = informação e ação.
   O diálogo é filho do <body>: herda as variáveis pela própria classe. */
.emb-page, .emb-dlg {
  --emb-ink:    #24313b;
  --emb-muted:  #6b747b;
  --emb-soft:   #8a949c;
  --emb-line:   #e2e7eb;
  --emb-good:   #147a4b;
  --emb-warn:   #9b6414;
  --emb-danger: #bd3d3a;
  --emb-info:   #2f6f9f;
  --emb-bg:     #f8fafb;
  --emb-identidade: 220px;
  color: var(--emb-ink);
}
.emb-recarregando .emb-corpo { opacity: .55; transition: opacity .15s; pointer-events: none; }

/* ── Cabeçalho + frescor ── */
.emb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 20px; margin-bottom: 12px; flex-wrap: wrap; }
.emb-eyebrow { color: #a23b36; font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.emb-titulo { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.emb-head h2 { margin: 0 0 2px; font-size: 1.4rem; font-weight: 750; }
.emb-head p { margin: 0; color: var(--emb-muted); font-size: .8rem; }
.emb-fresh { display: flex; align-items: center; gap: 12px; font-size: .72rem; color: var(--emb-muted); }
.emb-fontes { position: relative; }
.emb-fontes summary { cursor: pointer; padding: 6px 0; }
.emb-fontes summary::marker { color: var(--emb-info); }
.emb-fontes summary > i { color: var(--emb-info); }
.emb-fontes-link { color: var(--emb-info); }
.emb-fontes summary:focus-visible { outline: 2px solid var(--emb-info); outline-offset: 2px; }
.emb-fresh b { color: var(--emb-ink); font-weight: 650; }
.emb-fresh-linhas { position: absolute; right: 0; top: 100%; z-index: 6; display: flex; flex-direction: column; gap: 6px;
                    width: 400px; max-width: calc(100vw - 48px); padding: 12px; background: #fff; border: 1px solid var(--emb-line);
                    border-radius: 8px; box-shadow: 0 6px 20px #24313b1a; }
.emb-fresh button { white-space: nowrap; }
.emb-carregando { display: flex; align-items: center; gap: 8px; padding: 24px 16px; color: var(--emb-muted); font-size: .86rem; }

/* ── Avisos de fonte ── */
.emb-aviso { display: flex; gap: 12px; align-items: flex-start; padding: 8px 12px; border-radius: 8px; margin-bottom: 8px;
             font-size: .8rem; border: 1px solid; }
.emb-aviso > i { font-size: 1rem; line-height: 1.2; }
.emb-aviso > div { flex: 1 1 0; min-width: 0; }
.emb-aviso.warn { background: #fdf6ea; border-color: #f0dcb4; color: #6d4a10; }

/* ── KPIs: (rótulo, valor, legenda, estado) ── */
.emb-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 10px; }
.emb-kpi { position: relative; text-align: left; background: #fff; border: 1px solid var(--emb-line); border-radius: 10px;
           padding: 8px 10px 8px 14px; overflow: hidden; color: inherit; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
button.emb-kpi { cursor: pointer; }
button.emb-kpi:hover { border-color: #c9d2d9; }
.emb-kpi:focus-visible { outline: 2px solid var(--emb-info); outline-offset: 1px; }
.emb-kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #adb5bd; }
.emb-kpi.good::before { background: var(--emb-good); }
.emb-kpi.warn::before { background: var(--emb-warn); }
.emb-kpi.danger::before { background: var(--emb-danger); }
.emb-kpi.neutral::before { background: var(--emb-info); }
.emb-kpi > span { display: block; color: var(--emb-muted); font-size: .72rem; }
.emb-kpi strong { display: block; margin: 0; font-size: 1.13rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums;
                  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.emb-kpi.danger strong { color: var(--emb-danger); }
.emb-kpi.good strong { color: var(--emb-good); }
.emb-kpi-rodape { margin-top: auto; }
.emb-kpi small { display: block; color: var(--emb-muted); font-size: .68rem; line-height: 1.35; }
.emb-kpi .emb-kpi-acao { display: inline-flex; align-items: center; gap: 2px; color: var(--emb-info); font-size: .7rem; font-weight: 650; }
.emb-kpi-codigos { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.emb-kpi-codigos button { border: 0; background: transparent; color: var(--emb-info); padding: 0; font-size: .68rem; text-decoration: underline; }
.emb-kpi-codigos button[aria-pressed="true"] { color: var(--emb-warn); font-weight: 700; }

/* ── Filtros ── */
.emb-filtros { background: #fff; border: 1px solid var(--emb-line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.emb-filtro-topo { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 8px; }
.emb-atalhos { display: flex; flex-wrap: wrap; gap: 6px; }
.emb-filtro-grade { display: grid; grid-template-columns: 180px auto minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; }
.emb-campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.emb-campo > label, .emb-campo > span { color: var(--emb-muted); font-size: .7rem; font-weight: 650; }
.emb-campo select, .emb-campo input { height: 32px; border: 1px solid #ced4da; border-radius: 6px; padding: 0 8px; font-size: .8rem;
                                      background: #fff; color: var(--emb-ink); max-width: 100%; }
.emb-campo select { width: 100%; padding-right: 28px; text-overflow: ellipsis; }
.emb-campo select:focus, .emb-campo input:focus { outline: 2px solid var(--emb-info); outline-offset: 0; border-color: var(--emb-info); }
.emb-busca { flex: 1 1 240px; }
.emb-busca input { width: 100%; }
.emb-seg { display: inline-flex; border: 1px solid #ced4da; border-radius: 6px; overflow: hidden; height: 32px; }
.emb-seg button { border: 0; background: #fff; color: var(--emb-ink); font-size: .78rem; padding: 0 12px; white-space: nowrap; }
.emb-seg button + button { border-left: 1px solid #ced4da; }
.emb-seg button.emb-on { background: #e9f1f7; color: #1f4f73; font-weight: 650; }
.emb-seg button:focus-visible { outline: 2px solid var(--emb-info); outline-offset: -2px; }
.emb-chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; border: 1px solid #ced4da; border-radius: 6px; background: #fff;
            padding: 4px 9px; font-size: .72rem; color: var(--emb-ink); white-space: nowrap; }
.emb-chip.emb-on { background: #fbeeee; border-color: #e3b3b1; color: #7c2725; font-weight: 650; }
.emb-chip[data-codigo].emb-on { background: #fdf6ea; border-color: #e3c58f; color: #6d4a10; }
.emb-chip:focus-visible { outline: 2px solid var(--emb-info); outline-offset: 1px; }

/* filtro ativo: diz o que está valendo e devolve tudo num clique */
.emb-ativos { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; font-size: .76rem; color: var(--emb-muted); }
.emb-tag-filtro { display: inline-flex; align-items: center; gap: 6px; background: #e9f1f7; color: #1f4f73; border-radius: 14px;
                  padding: 2px 4px 2px 10px; font-weight: 600; max-width: 100%; }
.emb-tag-filtro span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52ch; }
.emb-tag-filtro button { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 11px; line-height: 1; }
.emb-tag-filtro button:hover { background: #d4e4ef; }
.emb-limpar { border: 0; background: transparent; color: var(--emb-info); font-weight: 650; padding: 2px 4px; text-decoration: underline; }

/* ── Cartões das tabelas ── */
.emb-card { background: #fff; border: 1px solid var(--emb-line); border-radius: 10px; margin-bottom: 12px; min-width: 0; }
.emb-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 16px; flex-wrap: wrap;
                 padding: 10px 12px 8px; border-bottom: 1px solid var(--emb-line); }
.emb-card-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.emb-card-head p { margin: 2px 0 0; color: var(--emb-muted); font-size: .76rem; max-width: 92ch; }
.emb-contador { color: var(--emb-muted); font-size: .74rem; white-space: nowrap; padding-top: 2px; }
.emb-contador b { color: var(--emb-ink); }
.emb-card-foot { padding: 8px 16px 12px; color: var(--emb-soft); font-size: .7rem; border-top: 1px solid var(--emb-line); }
.emb-selecao { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 8px 12px; background: #e9f1f7;
               border-radius: 10px 10px 0 0; border-bottom: 1px solid var(--emb-line); font-size: .8rem; }
.emb-selecao > span { min-width: 0; flex: 1; overflow-wrap: anywhere; }

/* tabela rola dentro do próprio cartão; a página nunca */
.emb-rola { overflow: auto; max-height: 70vh; }
.emb-rola--baixo { max-height: 46vh; }
#embForns .emb-rola { max-height: 58vh; }
.emb-tab { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .76rem; }
.emb-tab th, .emb-tab td { padding: 6px 8px; border-bottom: 1px solid #eef1f3; vertical-align: top; background: #fff; }
.emb-tab thead th { position: sticky; top: 0; z-index: 2; background: var(--emb-bg); color: var(--emb-muted); font-weight: 650;
                    font-size: .7rem; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--emb-line); }
.emb-tab .emb-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.emb-tab thead th.emb-num { text-align: right; }
.emb-tab .emb-fixa { position: sticky; left: 0; z-index: 1; width: var(--emb-identidade); min-width: var(--emb-identidade);
                      max-width: var(--emb-identidade); box-shadow: 1px 0 0 var(--emb-line); }
.emb-tab thead th.emb-fixa { z-index: 3; }
.emb-tab .emb-total-fixa { position: sticky; left: var(--emb-identidade); z-index: 1; min-width: 96px; box-shadow: 2px 0 0 var(--emb-line); }
.emb-tab thead th.emb-total-fixa { z-index: 3; }
.emb-tab tbody tr { cursor: pointer; }
.emb-tab tbody tr:hover td { background: #f3f7fa; }
.emb-tab tbody tr.emb-sel td { background: #e9f1f7; }
.emb-tab tbody tr:focus-visible td { background: #e9f1f7; }
.emb-tab tbody tr:focus-visible { outline: 2px solid var(--emb-info); outline-offset: -2px; }
.emb-tab tfoot td { position: sticky; bottom: 0; z-index: 1; background: var(--emb-bg); font-weight: 700; border-top: 1px solid var(--emb-line);
                    border-bottom: 0; }
.emb-tab tfoot td.emb-fixa { z-index: 2; }
.emb-tab tfoot td.emb-total-fixa { z-index: 2; }
.emb-tab .emb-mes { min-width: 72px; }
.emb-tab .emb-total { font-weight: 700; }
.emb-tab .emb-vazio-cel { color: #c3c9ce; }
.emb-ord { border: 0; background: transparent; padding: 0; color: inherit; font: inherit; display: inline-flex; align-items: center; gap: 4px;
           white-space: nowrap; }
.emb-ord.emb-on { color: var(--emb-ink); }
.emb-ord i { font-size: .62rem; opacity: .7; }
.emb-th-sub { display: block; font-weight: 500; color: var(--emb-soft); font-size: .62rem; }

.emb-nome { display: block; font-weight: 600; overflow-wrap: anywhere; }
#embForns .emb-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#embForns .emb-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
#embForns tbody td { padding-top: 5px; padding-bottom: 5px; }
#embForns tbody .emb-sub { line-height: 1.3; }
.emb-sub { display: block; color: var(--emb-muted); font-size: .7rem; overflow-wrap: anywhere; }
.emb-cod { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .72rem; background: #f1f4f6; border-radius: 4px;
           padding: 1px 4px; color: var(--emb-ink); white-space: nowrap; }
.emb-cod--sem { background: transparent; color: var(--emb-soft); font-family: inherit; font-style: italic; padding: 0; }
.emb-lista-cod { display: flex; flex-wrap: wrap; gap: 4px; }
.emb-mais { color: var(--emb-muted); font-size: .68rem; white-space: nowrap; }

/* selos: sempre com texto */
.emb-selo { display: inline-flex; align-items: center; gap: 4px; border-radius: 10px; padding: 1px 8px; font-size: .66rem; font-weight: 650;
            white-space: nowrap; margin-top: 2px; }
.emb-selo.danger { background: #fbeeee; color: #7c2725; }
.emb-selo.good { background: #e8f4ee; color: #0f5c38; }
.emb-selo.warn { background: #fdf6ea; color: #6d4a10; }
.emb-selo.info { background: #e9f1f7; color: #1f4f73; }

/* ── Vazio e erro: resultado, não ausência ── */
.emb-vazio { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 24px 16px; color: var(--emb-muted);
             font-size: .82rem; }
.emb-vazio > i { font-size: 1.4rem; color: var(--emb-soft); }
.emb-vazio b { color: var(--emb-ink); }
.emb-vazio.good > i { color: var(--emb-good); }
.emb-vazio.danger > i { color: var(--emb-danger); }
.emb-solto { background: #fff; border: 1px solid var(--emb-line); border-radius: 10px; }

/* ── Como funciona ── */
.emb-metodo { background: #fff; border: 1px solid var(--emb-line); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: .78rem;
              color: var(--emb-muted); }
.emb-metodo summary { cursor: pointer; color: var(--emb-ink); font-weight: 650; }
.emb-metodo ul { margin: 8px 0 0; padding-left: 18px; }
.emb-metodo li { margin-bottom: 4px; }
.emb-metodo b { color: var(--emb-ink); }

/* ── Diálogo das notas ── */
.emb-dlg .modal-dialog { max-width: min(1100px, calc(100vw - 32px)); }
.emb-dlg .modal-header { align-items: flex-start; gap: 12px; }
.emb-dlg .modal-title { font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.emb-dlg-sub { display: block; color: var(--emb-muted); font-size: .76rem; font-weight: 500; margin-top: 2px; }
.emb-dlg-resumo { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 12px; font-size: .78rem; color: var(--emb-muted); }
.emb-dlg-resumo b { color: var(--emb-ink); font-variant-numeric: tabular-nums; }
.emb-dlg .emb-tab tbody tr { cursor: default; }

@media (max-width: 1000px) {
  .emb-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .emb-filtro-grade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .emb-filtro-topo .emb-busca { flex-basis: 100%; }
}

@media (max-width: 576px) {
  .emb-page, .emb-dlg { --emb-identidade: 140px; }
  .emb-head h2 { font-size: 1.25rem; }
  .emb-head p { display: none; }              /* texto auxiliar não toma a tela pequena; a regra fica em "Como funciona" */
  .emb-fresh { width: 100%; justify-content: space-between; }
  .emb-fresh-linhas { right: auto; left: 0; }
  .emb-card-head .emb-campo { flex: 1 1 100%; }
  .emb-seg { width: 100%; height: auto; min-height: 32px; }
  .emb-seg button { flex: 1 1 0; white-space: normal; padding: 6px 8px; line-height: 1.2; }
  .emb-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .emb-kpi { padding: 8px 8px 8px 12px; }
  .emb-kpi strong { font-size: 1rem; white-space: normal; overflow-wrap: anywhere; }
  .emb-filtros { padding: 12px; gap: 8px 12px; }
  .emb-campo { flex: 1 1 140px; }
  .emb-filtros .emb-busca { flex: 1 1 100%; }
  .emb-filtro-grade > .emb-campo:first-child, .emb-filtro-grade .emb-medida { grid-column: 1 / -1; }
  .emb-campo select { width: 100%; }
  .emb-forn select { max-width: none; }
  .emb-atalhos { width: 100%; }
  .emb-atalhos .emb-chip[data-acao="pend"] { flex-basis: 100%; }
  .emb-atalhos .emb-chip[data-codigo] { flex: 1 1 0; white-space: normal; }
  .emb-tab .emb-total-fixa { min-width: 88px; }
  .emb-tab .emb-cod { white-space: normal; overflow-wrap: anywhere; }
  .emb-card-head { padding: 12px 12px 8px; }
}
