/* Dashboard Vonin - tema escuro */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #2b2b2b;
  color: #ffffff;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- cabecalho ---------- */
.cabecalho {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 18px;
  flex-wrap: wrap;
  position: relative;
  z-index: 500;
}

.logo {
  display: flex;
  align-items: center;
  padding-right: 6px;
}

.logo img {
  height: 36px;
  width: auto;
  display: block;
}

.kpi {
  display: flex;
  flex-direction: column;
  min-width: 170px;
}

.kpi-rotulo {
  font-size: 11px;
  color: #cfcfcf;
  margin-bottom: 2px;
}

.kpi-valor {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
}

.filtros {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

/* quadro de informacoes (canto superior direito) */
.cartao-info {
  margin-left: auto;
  min-width: 170px;
  background: #3a3a3a;
  border: 1px solid #5a5a5a;
  border-radius: 4px;
  padding: 8px 14px;
  text-align: right;
  align-self: flex-start;
}

.info-rotulo {
  font-size: 10px;
  color: #b0b0b0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-valor {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  margin: 2px 0 6px;
}

.info-nome {
  font-size: 11px;
  color: #d8d8d8;
  border-top: 1px solid #5a5a5a;
  padding-top: 5px;
}

/* ---------- filtros ---------- */
.filtro {
  position: relative;
  min-width: 165px;
  max-width: 220px;
  flex: 1 1 165px;
}

.filtro-titulo {
  font-size: 11px;
  color: #e8e8e8;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filtro-caixa {
  width: 100%;
  height: 30px;
  background: #333333;
  border: 1px solid #9a9a9a;
  border-radius: 4px;
  color: #d8d8d8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}

.filtro-caixa:hover { border-color: #ffffff; }

.filtro-valor {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.filtro-chev { margin-left: 6px; color: #bbbbbb; }

.filtro-painel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  width: 260px;
  margin-top: 4px;
  background: #3a3a3a;
  border: 1px solid #6a6a6a;
  border-radius: 4px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  padding: 8px;
}

.filtro-painel.aberto { display: block; }

.filtro-busca {
  width: 100%;
  height: 28px;
  background: #2b2b2b;
  border: 1px solid #6a6a6a;
  border-radius: 3px;
  color: #fff;
  padding: 0 8px;
  font-family: inherit;
  font-size: 12px;
}

.filtro-busca:focus { outline: 1px solid #ffffff; }

.filtro-acoes {
  display: flex;
  gap: 6px;
  margin: 7px 0 5px;
}

.filtro-acao {
  background: #4a4a4a;
  border: 1px solid #6a6a6a;
  border-radius: 3px;
  color: #eaeaea;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  font-family: inherit;
}

.filtro-acao:hover { background: #5a5a5a; }

.filtro-lista {
  max-height: 190px;
  overflow-y: auto;
  border-top: 1px solid #4f4f4f;
  border-bottom: 1px solid #4f4f4f;
  padding: 4px 0;
}

.filtro-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 6px;
  cursor: pointer;
  font-size: 12px;
  color: #e6e6e6;
}

.filtro-item:hover { background: #4a4a4a; }

.filtro-item-cor {
  border-radius: 3px;
  margin: 1px 2px;
  font-weight: 600;
}

.filtro-item-cor:hover { filter: brightness(1.15); }

.filtro-item-cor .filtro-cb { accent-color: #1e1e1e; }

.filtro-item-txt {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filtro-vazio {
  padding: 8px 6px;
  color: #9a9a9a;
  font-size: 12px;
}

.filtro-rodape {
  margin-top: 7px;
  display: flex;
  justify-content: flex-end;
}

.filtro-fechar {
  background: #d2232a;
  border: 0;
  border-radius: 3px;
  color: #fff;
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
  font-family: inherit;
}

.filtro-fechar:hover { background: #b81c22; }

/* ---------- grafico ---------- */
.cartao {
  background: #333333;
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  margin: 0 12px 12px;
}

.cartao-titulo {
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px 2px;
}

.cartao-subtitulo {
  font-size: 11px;
  color: #b0b0b0;
  padding: 0 14px 8px;
}

.area-grafico {
  height: 340px;
  padding: 4px 12px 12px;
}

/* ---------- tabela ---------- */
.cartao-tabela {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  border-radius: 3px 3px 0 0;
}

.tabela-topo {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 14px 4px;
}

.tabela-info {
  font-size: 11px;
  color: #b0b0b0;
}

.contorno-tabela {
  overflow: auto;
  flex: 1;
  min-height: 220px;
  max-height: 420px;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

thead th {
  position: sticky;
  top: 0;
  background: #8c8c8c;
  color: #ffffff;
  text-align: left;
  font-weight: 700;
  padding: 7px 10px;
  border-bottom: 1px solid #7a7a7a;
  white-space: nowrap;
  z-index: 2;
}

tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #e0e0e0;
  color: #2b2b2b;
  background: #ffffff;
  font-weight: 400;
  vertical-align: top;
}

tbody tr:nth-child(even) td { background: #e8e8e8; }

tbody tr:hover td { background: #d9e4f2; }

thead th.col-cod, thead th.col-desc, thead th.col-qtd, thead th.col-um,
thead th.col-grupo, thead th.col-metodo, thead th.col-mp, thead th.col-mpdesc,
thead th.col-est {
  color: #ffffff;
  font-weight: 700;
}

tbody td.col-cod { font-weight: 400; color: #2b2b2b; white-space: nowrap; }
.col-qtd { text-align: right; white-space: nowrap; }
.col-um { white-space: nowrap; }
.col-grupo { white-space: nowrap; }
.col-metodo { white-space: nowrap; }
.col-est { text-align: right; white-space: nowrap; }
.col-desc { min-width: 220px; }
.col-mpdesc { min-width: 160px; }

.funil {
  width: 0;
  height: 0;
  margin-top: 4px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #ffffff;
}

/* ---------- rodape ---------- */
.rodape {
  padding: 8px 18px;
  font-size: 11px;
  color: #9a9a9a;
  background: #262626;
  border-top: 1px solid #3d3d3d;
}

/* scrollbar discreta */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: #2b2b2b; }
::-webkit-scrollbar-thumb { background: #5a5a5a; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #6f6f6f; }

@media (max-width: 1100px) {
  .cabecalho { gap: 14px; }
  .filtro { min-width: 150px; }
}

/* ---------- painel de perguntas (IA) ---------- */
.cartao-ia { padding: 12px 16px; }

.ia-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ia-linha {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 280px;
}

.ia-input {
  flex: 1;
  height: 34px;
  background: #2b2b2b;
  border: 1px solid #6a6a6a;
  border-radius: 4px;
  color: #ffffff;
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
}

.ia-input:focus { outline: 1px solid #ffffff; }

.ia-botao {
  height: 34px;
  padding: 0 18px;
  background: #d2232a;
  border: 0;
  border-radius: 4px;
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.ia-botao:hover { background: #b81c22; }
.ia-botao:disabled { background: #6a6a6a; cursor: default; }

.ia-resposta { margin-top: 10px; }

.ia-texto {
  background: #2f2f2f;
  border: 1px solid #4a4a4a;
  border-left: 3px solid #d2232a;
  border-radius: 4px;
  padding: 10px 12px;
  color: #f0f0f0;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.ia-aviso {
  background: #3a3a2a;
  border: 1px solid #6a6a3a;
  border-radius: 4px;
  padding: 8px 12px;
  color: #f1e6a8;
  font-size: 12px;
  margin-top: 8px;
}

.ia-carregando {
  color: #b0b0b0;
  font-size: 13px;
  padding: 8px 0;
}

.ia-tit-cards {
  font-size: 11px;
  color: #b0b0b0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 12px 0 6px;
}

.ia-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.ia-card {
  background: #2f2f2f;
  border: 1px solid #4a4a4a;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 11px;
}

.ia-card-topo {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.ia-card-cod { font-weight: 700; color: #ffffff; }
.ia-card-qtd { color: #d8d8d8; white-space: nowrap; }
.ia-card-desc { color: #e4e4e4; line-height: 1.35; }
.ia-card-maq { color: #a8c8e8; margin-top: 3px; }
.ia-card-grupo { color: #b0b0b0; margin-top: 2px; }

/* ================= MOBILE ================= */
@media (max-width: 768px) {
  .cabecalho {
    gap: 8px 10px;
    padding: 8px 10px;
    align-items: center;
  }

  /* logo e KPI pequenos */
  .logo img { height: 20px; }
  .kpi { min-width: 0; }
  .kpi-rotulo { font-size: 8px; }
  .kpi-valor { font-size: 18px; }

  /* quadro de informacoes compacto */
  .cartao-info {
    min-width: 118px;
    padding: 5px 9px;
  }
  .info-rotulo { font-size: 7px; }
  .info-valor { font-size: 10px; margin: 1px 0 3px; }
  .info-nome { font-size: 9px; padding-top: 3px; }

  /* filtros em linha com rolagem horizontal */
  .filtros {
    order: 5;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding: 2px 0 8px;
    scrollbar-width: thin;
  }
  .filtro {
    flex: 0 0 155px;
    min-width: 155px;
    max-width: 155px;
  }
  .filtro-titulo { font-size: 9px; }
  .filtro-caixa { height: 28px; font-size: 11px; }
  .filtro-painel { margin-top: 0; }
  .filtro-lista { max-height: 40vh; }
  .filtro-item { font-size: 11px; }

  /* grafico enxuto */
  .cartao { margin: 0 8px 8px; }
  .cartao-titulo { font-size: 12px; padding: 8px 10px 1px; }
  .cartao-subtitulo { font-size: 10px; padding: 0 10px 5px; }
  .area-grafico { height: 200px; padding: 2px 4px 6px; }

  /* painel IA compacto */
  .cartao-ia { padding: 10px 10px; }
  .ia-topo { gap: 8px; }
  .ia-linha { min-width: 100%; }
  .ia-input { height: 36px; font-size: 16px; }
  .ia-botao { height: 36px; padding: 0 12px; }
  .ia-cards { grid-template-columns: 1fr; }

  /* tabela compacta (foco principal) */
  .tabela-topo { padding: 6px 10px 2px; }
  .tabela-info { font-size: 10px; }
  .contorno-tabela {
    flex: 1;
    max-height: none;
    min-height: 0;
  }
  table { font-size: 10px; }
  thead th { padding: 5px 6px; font-size: 10px; }
  tbody td { padding: 3px 6px; }
  .col-desc { min-width: 150px; }
  .col-mpdesc { min-width: 110px; }
  .funil { margin-top: 2px; border-top-width: 5px; }

  .rodape { padding: 6px 10px; font-size: 9px; }
}
