:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --accent: #0f766e;
  --accent-soft: #e6f4f1;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

svg { width: 18px; height: 18px; flex: none; }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  display: flex;
  align-items: center;
}
.logo img {
  height: 46px;
  width: auto;
  max-width: 170px;
  object-fit: contain;
  display: block;
}

.brand-text h1 { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.brand-text p { margin: 0; font-size: 12.5px; color: var(--muted); }

.topbar-actions { display: flex; gap: 8px; }

/* ---------------- botões ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .12);
}
.btn.primary:hover { background: #115e59; }
.btn.ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: #344054;
}
.btn.ghost:hover { background: #f9fafb; border-color: #98a2b3; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #912018; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ok:hover { background: #05603a; }
.btn.info { background: var(--info); color: #fff; }
.btn.info:hover { background: #1447ad; }
.btn.mini { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-acao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.btn-acao svg { width: 15px; height: 15px; }
.btn-acao:hover { background: #f9fafb; color: var(--ink); border-color: var(--line-strong); }
.btn-acao.aprovar:hover { color: var(--ok); border-color: #abefc6; background: var(--ok-soft); }
.btn-acao.reprovar:hover { color: var(--danger); border-color: #fecdca; background: var(--danger-soft); }
.btn-acao.enviar:hover { color: var(--info); border-color: #b2ddff; background: var(--info-soft); }
.btn-acao.concluir:hover { color: var(--accent); border-color: #99e0d6; background: var(--accent-soft); }
.btn-acao.excluir:hover { color: var(--danger); border-color: #fecdca; background: var(--danger-soft); }

/* ---------------- layout ---------------- */
main { max-width: 1440px; margin: 0 auto; padding: 22px 28px 60px; }

/* ---------------- KPIs ---------------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.kpi:hover { border-color: var(--line-strong); box-shadow: 0 4px 18px rgba(16,24,40,.09); }
.kpi.ativo { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kpi::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--kpi-cor, var(--line-strong));
}
.kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kpi-cor); }
.kpi-valor { font-size: 27px; font-weight: 700; letter-spacing: -.8px; margin: 6px 0 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); }

/* ---------------- painel / tabela ---------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.tabs { display: flex; gap: 4px; background: #f2f4f7; padding: 3px; border-radius: 10px; flex-wrap: wrap; }
.tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all .15s;
}
.tab:hover { color: var(--ink); }
.tab.ativo { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.1); }
.tab .pill {
  font-size: 11px;
  font-weight: 700;
  background: #e4e7ec;
  color: #475467;
  border-radius: 20px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.tab.ativo .pill { background: var(--accent-soft); color: var(--accent); }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; }

.campo-busca { position: relative; }
.campo-busca svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #98a2b3;
  pointer-events: none;
}
.campo-busca input { padding-left: 32px; min-width: 260px; }

input, select, textarea {
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 11px 16px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f2f4f7;
  vertical-align: middle;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.acoes-col { text-align: right; }

.mono { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.atraso { color: var(--danger); font-weight: 600; }
.loja-nome { font-weight: 600; }
.suave { color: var(--muted); }
.total { font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.aguardando { background: var(--warn-soft); color: var(--warn); border-color: #fedf89; }
.badge.aprovado { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }
.badge.reprovado { background: var(--danger-soft); color: var(--danger); border-color: #fecdca; }
.badge.enviado { background: var(--info-soft); color: var(--info); border-color: #b2ddff; }
.badge.concluido { background: var(--accent-soft); color: var(--accent); border-color: #99e0d6; }

.prioridade { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.prioridade::before { content: ""; width: 7px; height: 7px; border-radius: 2px; }
.prioridade.urgente { color: var(--danger); }
.prioridade.urgente::before { background: var(--danger); }
.prioridade.alta { color: var(--warn); }
.prioridade.alta::before { background: #f79009; }
.prioridade.normal { color: var(--muted); }
.prioridade.normal::before { background: #98a2b3; }
.prioridade.baixa { color: #98a2b3; }
.prioridade.baixa::before { background: #d0d5dd; }

.acoes { display: flex; gap: 5px; justify-content: flex-end; }

.vazio { text-align: center; padding: 56px 20px; color: var(--muted); }
.vazio-icone { font-size: 34px; opacity: .5; }
.vazio p { margin: 10px 0 2px; font-weight: 600; color: #344054; }
.vazio span { font-size: 13px; }

/* ---------------- modais ---------------- */
dialog.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: auto;
}
dialog.modal::backdrop { background: rgba(16, 24, 40, .5); backdrop-filter: blur(2px); }

.modal-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: min(760px, calc(100% - 32px));
  margin: 5vh auto;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}
.modal-card.wide { width: min(880px, calc(100% - 32px)); }
.modal-card.narrow { width: min(460px, calc(100% - 32px)); }

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.modal-head .badge { margin-top: 6px; }

.fechar {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 6px;
}
.fechar:hover { color: var(--ink); background: #f2f4f7; }

.modal-body { padding: 20px 22px; overflow-y: auto; display: grid; gap: 14px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
  flex-wrap: wrap;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.campo { display: grid; gap: 5px; }
.campo > span { font-size: 12.5px; font-weight: 600; color: #344054; }

.campo-copiar { display: flex; gap: 8px; }
.campo-copiar input { flex: 1; min-width: 0; }
.campo-copiar .btn { white-space: nowrap; }

@media (max-width: 520px) {
  .campo-copiar { flex-direction: column; }
}

.dica { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------------- lojas ---------------- */
.linha-add { display: flex; gap: 8px; }
.linha-add input { flex: 1; }

.lista-lojas { display: grid; gap: 6px; }

.loja-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fcfcfd;
  font-size: 13.5px;
}
.loja-item strong { font-weight: 600; }
.loja-item .remover {
  border: 0;
  background: transparent;
  color: #98a2b3;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}
.loja-item .remover:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------------- itens do pedido ---------------- */
.itens-head { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.itens-head h3 { margin: 0; font-size: 14px; }

.itens { display: grid; gap: 8px; }

.item-linha {
  display: grid;
  grid-template-columns: 1fr 92px 76px 116px 112px 34px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfcfd;
}
.item-linha input { padding: 7px 9px; font-size: 13px; }
.item-subtotal {
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #344054;
}
.item-remover {
  border: 0;
  background: transparent;
  color: #98a2b3;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  border-radius: 6px;
  padding: 4px;
}
.item-remover:hover { color: var(--danger); background: var(--danger-soft); }

.total-linha {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px 0;
  border-top: 1px dashed var(--line-strong);
  font-size: 13px;
  color: var(--muted);
}
.total-linha strong { font-size: 19px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------------- detalhe ---------------- */
.detalhe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.detalhe-grid div { display: grid; gap: 2px; }
.detalhe-grid dt { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.detalhe-grid dd { margin: 0; font-weight: 600; font-size: 13.5px; }

.secao-titulo { margin: 6px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }

.tabela-itens { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabela-itens th { text-align: left; padding: 7px 10px; background: #f9fafb; border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.tabela-itens td { padding: 8px 10px; border-bottom: 1px solid #f2f4f7; }
.tabela-itens tfoot td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--line-strong); }

.motivo-box {
  background: var(--danger-soft);
  border: 1px solid #fecdca;
  color: #912018;
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 13px;
}
.motivo-box strong { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }

.linha-tempo { display: grid; gap: 10px; }
.evento { display: grid; grid-template-columns: 14px 1fr; gap: 10px; align-items: start; }
.evento-ponto { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); margin-top: 5px; }
.evento:first-child .evento-ponto { background: var(--accent); }
.evento-texto { font-size: 13px; }
.evento-texto strong { text-transform: capitalize; }
.evento-data { font-size: 12px; color: var(--muted); }
.evento-obs { color: #475467; font-style: italic; }

/* ---------------- toasts ---------------- */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 100;
  max-width: 360px;
}
.toast {
  background: #101828;
  color: #fff;
  border-radius: 10px;
  padding: 11px 15px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: entrar .22s ease-out;
  display: flex;
  align-items: center;
  gap: 9px;
}
.toast.erro { background: var(--danger); }
.toast.sucesso { background: #05603a; }
@keyframes entrar { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- gráficos ---------------- */
.graficos {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
  margin-bottom: 18px;
}

.graficos-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.graficos-head h2 { margin: 0; font-size: 16px; letter-spacing: -.2px; }
.graficos-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.campo-inline { display: flex; align-items: center; gap: 8px; }
.campo-inline > span { font-size: 12.5px; font-weight: 600; color: #344054; white-space: nowrap; }
.campo-inline select { min-width: 190px; }

.graficos-filtros {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.graficos-filtros input[type="date"] { padding: 7px 9px; font-size: 12.5px; }

.card-historico { grid-column: 1 / -1; }

.historico-controles {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
}
.historico-nota { font-size: 12px; color: var(--muted); }

.historico-corpo {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
.historico-tabela { max-height: 190px; overflow-y: auto; }

.tabela-historico { width: 100%; border-collapse: collapse; font-size: 12px; }
.tabela-historico th {
  position: sticky;
  top: 0;
  padding: 6px 8px;
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: #fcfcfd;
  border-bottom: 1px solid var(--line);
}
.tabela-historico td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tabela-historico th:nth-child(2), .tabela-historico td:nth-child(2) { text-align: right; }
.tabela-historico th:last-child, .tabela-historico td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tabela-historico tfoot td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--line-strong); }

.graficos-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 14px;
}

.grafico-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px 14px 12px;
  background: #fcfcfd;
  min-width: 0;
}
.grafico-topo { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.grafico-topo h3 { margin: 0; font-size: 13px; letter-spacing: -.1px; }
.grafico-topo .suave { font-size: 11.5px; }

.grafico-meses {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 160px;
  padding-top: 6px;
}
.mes { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; }
.mes-trilho {
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 2px;
  border-bottom: 1px solid var(--line-strong);
  background: #f7f8fa;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}
.seg { display: block; width: 100%; border-radius: 3px; min-height: 2px; }
.seg-zero { display: block; width: 100%; height: 1px; background: var(--line); }
.mes-rotulo {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grafico-legenda {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}
.legenda-item { display: inline-flex; align-items: center; gap: 5px; }
.legenda-cor { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.legenda-nota { margin-left: auto; font-style: italic; }

.grafico-barras { display: grid; gap: 8px; max-height: 200px; overflow-y: auto; padding-right: 2px; }
.barra-linha { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
.barra-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #344054; font-weight: 600; }
.barra-trilho { height: 8px; background: #eef1f5; border-radius: 99px; overflow: hidden; }
.barra-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #0f766e, #2dd4bf); min-width: 2px; transition: width .3s; }
.barra-valor { font-variant-numeric: tabular-nums; font-size: 11.5px; color: var(--ink); white-space: nowrap; }
.grafico-vazio { margin: 0; padding: 18px 0; text-align: center; font-size: 12.5px; color: var(--muted); }

#tabela { min-width: 1060px; }

/* ---------------- login ---------------- */
.tela-login {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, #d9efeb 0%, transparent 60%),
    var(--bg);
}

.login { width: 100%; max-width: 400px; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 26px 26px 22px;
}

.login-marca { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-marca img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px;
}
.login-marca h1 { margin: 0; font-size: 18px; letter-spacing: -.3px; }
.login-marca p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.login-texto { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }

.login-card .campo { margin-bottom: 14px; }

.login-erro {
  margin: 0 0 12px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #fecdca;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}

.login-btn { width: 100%; justify-content: center; padding: 10px 14px; }

.login-dica { margin: 14px 0 0; font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.45; }

/* ---------------- responsivo ---------------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .graficos-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  main { padding: 16px 14px 50px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .campo-busca input { min-width: 0; width: 100%; }
  .filtros { width: 100%; }
  .filtros > * { flex: 1 1 140px; }
  .grid-2 { grid-template-columns: 1fr; }
  .item-linha { grid-template-columns: 1fr 1fr; }
  .item-subtotal { text-align: left; }
  .ocultar-mobile { display: none; }
  .graficos-grid { grid-template-columns: 1fr; }
  .grafico-meses { height: 140px; }
  .campo-inline { width: 100%; }
  .campo-inline select { flex: 1; min-width: 0; }
  .campo-inline input[type="date"] { flex: 1; min-width: 0; }
  .graficos-filtros { width: 100%; }
  .graficos-filtros .campo-inline { width: auto; flex: 1 1 160px; }
  .historico-corpo { grid-template-columns: 1fr; }
  .legenda-nota { margin-left: 0; flex-basis: 100%; }
}
