/* ==========================================================================
   Tools ML — sistema de design
   Tokens, casca (barra lateral + topo), tipografia e componentes base.
   app.css tem os componentes de página; painel.css, o que é de uma tela só.
   ========================================================================== */

/* Fonte local (sem Google): Plus Jakarta Sans variável 400–800. */
@font-face {
  font-family: 'Jakarta';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fontes/jakarta-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Jakarta';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fontes/jakarta-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;

  /* Paleta (azul do Mercado Livre, um tom mais fechado pra texto branco ler bem) */
  --azul-400: #3483fa;
  --azul-500: #2a6fd6;
  --azul-600: #1f5ab3;
  --azul-700: #1a4b94;
  --verde-500: #00a650;
  --verde-600: #008f45;
  --vermelho-500: #e0243a;
  --vermelho-600: #c21d31;
  --ambar-500: #f5a524;
  --ambar-700: #a85f06;
  --roxo-500: #7c4dff;

  /* Superfícies e texto (claro) */
  --fundo: #f3f5f9;
  --superficie: #ffffff;
  --superficie-2: #f8fafc;
  --superficie-3: #eef2f7;
  --borda: #e4e9f0;
  --borda-forte: #cfd7e1;
  --texto: #10203a;
  --texto-suave: #4d5b6e;
  --texto-fraco: #8591a3;

  /* Semânticos */
  --primaria: var(--azul-500);
  --primaria-forte: var(--azul-600);
  --primaria-texto: var(--azul-700);
  --primaria-suave: #eaf2ff;
  --sucesso: var(--verde-500);
  --sucesso-botao: #0a7a3f;
  --sucesso-botao-forte: #066631;
  --sucesso-texto: #0a7a3f;
  --sucesso-suave: #e6f7ee;
  --erro: var(--vermelho-500);
  --erro-texto: #b31a2c;
  --erro-suave: #fdecee;
  --alerta: var(--ambar-500);
  --alerta-texto: var(--ambar-700);
  --alerta-suave: #fff5e3;
  --info-suave: var(--primaria-suave);
  --info-texto: var(--primaria-texto);

  /* Espaçamento */
  --e1: 0.25rem;
  --e2: 0.5rem;
  --e3: 0.75rem;
  --e4: 1rem;
  --e5: 1.5rem;
  --e6: 2rem;
  --e7: 3rem;

  --raio: 10px;
  --raio-sm: 6px;
  --raio-lg: 14px;

  --sombra: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 6px -2px rgba(0, 0, 0, 0.05);
  --sombra-md: 0 6px 16px -6px rgba(0, 0, 0, 0.12), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --sombra-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.24), 0 6px 12px -6px rgba(0, 0, 0, 0.08);

  --sidebar-w: 244px;
  --topo-h: 84px; /* topo com ícone e subtítulo em toda tela (nav-auth.js) */
  --largura-max: 1480px;
  --transicao: 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.sidebar-oculta { --sidebar-w: 70px; }

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0d1526;
    --superficie: #141e33;
    --superficie-2: #192540;
    --superficie-3: #1f2d4b;
    --borda: #26344f;
    --borda-forte: #35476a;
    --texto: #e9eef7;
    --texto-suave: #a9b5c9;
    --texto-fraco: #8290a8;

    /* Botões cheios no escuro levam texto escuro: branco sobre azul claro não lê. */
    --botao-texto: #0d1526;
    --primaria: #5a9bff;
    --primaria-forte: #7fb1ff;
    --primaria-texto: #8db8ff;
    --primaria-suave: #16305a;
    --sucesso: #2fc46e;
    --sucesso-botao: #2fc46e;
    --sucesso-botao-forte: #5ad48c;
    --sucesso-texto: #6fe0a0;
    --sucesso-suave: #10321f;
    --erro: #ff5a6a;
    --erro-texto: #ff9aa3;
    --erro-suave: #3b1620;
    --alerta: #ffb84d;
    --alerta-texto: #ffcf80;
    --alerta-suave: #3a2a0d;

    --sombra: 0 1px 2px rgba(0, 0, 0, 0.35);
    --sombra-md: 0 6px 16px -6px rgba(0, 0, 0, 0.5);
    --sombra-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.65);
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

* { scrollbar-width: thin; scrollbar-color: var(--borda-forte) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--borda-forte); border-radius: 99px; border: 2px solid var(--fundo); }
*::-webkit-scrollbar-thumb:hover { background: var(--texto-fraco); }

::selection { background: var(--primaria-suave); color: var(--texto); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--primaria); outline-offset: 2px; border-radius: var(--raio-sm); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Jakarta', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--texto);
  background: var(--fundo);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topo-h) 1fr;
  transition: grid-template-columns var(--transicao);
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; color: var(--texto); }
h1 { font-size: 1.125rem; }
h2 { font-size: 0.9375rem; }
h3 { font-size: 0.9375rem; }
p { margin: 0 0 var(--e3); }
a { color: var(--primaria-texto); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
strong { font-weight: 700; }
small, .sku { font-size: 0.75rem; color: var(--texto-fraco); }
.numero, td.numero, th.numero { text-align: right; font-variant-numeric: tabular-nums; }
.valor-negativo { color: var(--erro-texto); }
.valor-positivo { color: var(--sucesso-texto); }
.sem-dado { color: var(--texto-fraco); font-style: italic; }
[hidden] { display: none !important; }

/* ==========================================================================
   Casca: barra lateral
   ========================================================================== */

.sidebar {
  grid-row: 1 / -1;
  grid-column: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--superficie);
  border-right: 1px solid var(--borda);
  overflow: hidden;
  z-index: 30;
}

.sidebar-marca {
  display: flex;
  align-items: center;
  justify-content: center; /* logo centralizado (pedido dele, 29/10/2026) */
  gap: var(--e3);
  height: var(--topo-h);
  padding: 0 var(--e4);
  border-bottom: 1px solid var(--borda);
  flex: 0 0 auto;
  color: var(--texto);
  text-decoration: none;
}
.sidebar-marca:hover { text-decoration: none; }
/* Logo dele (29/10/2026): o inteiro com o menu aberto, só o símbolo recolhido. */
.sidebar-marca .sidebar-logo { width: auto; height: 58px; max-width: 100%; object-fit: contain; }
.sidebar-marca .sidebar-logo-mini { display: none; width: 54px; height: 54px; object-fit: contain; }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: var(--e3) var(--e3) var(--e4); }
.sidebar-secao { margin-bottom: var(--e3); }
.sidebar-secao-titulo {
  display: block;
  padding: var(--e3) var(--e3) var(--e1);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texto-fraco);
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--texto-suave);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transicao), color var(--transicao);
}
.nav-item:hover { background: var(--superficie-3); color: var(--texto); text-decoration: none; }
.nav-item.ativo { background: var(--primaria-suave); color: var(--primaria-texto); }
.nav-icone { width: 20px; height: 20px; flex: 0 0 auto; }
.nav-rotulo { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--erro);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sidebar-rodape { flex: 0 0 auto; border-top: 1px solid var(--borda); padding: var(--e2) var(--e3); }
.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--texto-fraco);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.sidebar-toggle:hover { background: var(--superficie-3); color: var(--texto); }
.sidebar-toggle svg { width: 18px; height: 18px; transition: transform var(--transicao); }

/* Colapsada: só ícones, com o rótulo em tooltip */
body.sidebar-oculta .sidebar-marca { padding: 0; justify-content: center; }
body.sidebar-oculta .sidebar-marca .sidebar-logo { display: none; }
body.sidebar-oculta .sidebar-marca .sidebar-logo-mini { display: block; }
body.sidebar-oculta .sidebar-secao-titulo,
body.sidebar-oculta .nav-rotulo,
body.sidebar-oculta .sidebar-toggle span { display: none; }
body.sidebar-oculta .sidebar-nav { padding-left: var(--e3); padding-right: var(--e3); }
body.sidebar-oculta .sidebar-secao { border-top: 1px solid var(--borda); padding-top: var(--e2); }
body.sidebar-oculta .sidebar-secao:first-child { border-top: 0; padding-top: 0; }
body.sidebar-oculta .nav-item { justify-content: center; padding: 0; }
body.sidebar-oculta .nav-item .nav-badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; line-height: 16px; font-size: 0.625rem; padding: 0 4px; }
body.sidebar-oculta .sidebar-toggle { justify-content: center; }
body.sidebar-oculta .sidebar-toggle svg { transform: rotate(180deg); }
/* Recolhido, o menu rola como aberto (com muitos itens ele não cabe numa tela
   de 768 px e o botão de expandir sumia). O nome do item aparece num balão
   que o nav-auth.js desenha fora da barra (position: fixed), pra a rolagem
   não cortar. */
.sidebar-dica {
  position: fixed;
  transform: translateY(-50%) translateX(-4px);
  background: var(--texto);
  color: var(--fundo);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transicao), transform var(--transicao);
  z-index: 60;
}
.sidebar-dica.visivel { opacity: 1; transform: translateY(-50%) translateX(0); }

/* ==========================================================================
   Casca: barra do topo e conteúdo
   ========================================================================== */

.app-bar {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--e4);
  height: var(--topo-h);
  padding: 0 var(--e5);
  background: color-mix(in srgb, var(--superficie) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--borda);
}
.app-bar h1 { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.015em; white-space: nowrap; }
/* Topo com ícone e subtítulo (padrão dos modelos dele, 26/10/2026), montado pelo nav-auth.js. */
.app-titulo { display: flex; align-items: center; gap: var(--e3); min-width: 0; margin-right: auto; }
.app-icone { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--primaria); color: var(--botao-texto, #fff); }
.app-icone svg { width: 26px; height: 26px; }
.app-bar-grande h1 { font-size: 1.625rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.app-titulo-textos { min-width: 0; }
.app-subtitulo { margin: 2px 0 0; font-size: 0.875rem; color: var(--texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-mobile {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  background: var(--superficie);
  color: var(--texto);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.menu-mobile svg { width: 20px; height: 20px; }

.usuario-info { margin-left: auto; display: flex; align-items: center; gap: var(--e3); min-width: 0; }
.seletor-conta { display: flex; align-items: center; gap: var(--e2); }
.seletor-conta-rotulo { font-size: 0.75rem; font-weight: 600; color: var(--texto-fraco); }
.seletor-conta select { margin: 0; height: 36px; max-width: 240px; font-weight: 600; }
.aviso-teste {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 99px;
  background: var(--alerta-suave);
  color: var(--alerta-texto);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.empresa-nome { font-size: 0.8125rem; color: var(--texto-fraco); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.usuario-chip { display: flex; align-items: center; gap: var(--e2); padding-left: var(--e3); border-left: 1px solid var(--borda); }
.usuario-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primaria-suave);
  color: var(--primaria-texto);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}
.usuario-nome { font-weight: 600; font-size: 0.8125rem; white-space: nowrap; }
.usuario-chip .btn-link { font-size: 0.8125rem; }

main {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  max-width: var(--largura-max);
  padding: var(--e5);
  display: flex;
  flex-direction: column;
  gap: var(--e4);
  min-width: 0;
}
main > .card:not(:last-child) { margin-bottom: 0; }
.sidebar-backdrop { display: none; }
/* Plataforma (operador): topo e conteúdo, sem barra lateral. */
body.sem-sidebar { grid-template-columns: 1fr; }
body.sem-sidebar .app-bar, body.sem-sidebar main { grid-column: 1; }
/* Páginas sem a casca (login, cadastro, bloqueado) não usam a grade. */
body:not(:has(> .app-bar)) { display: block; }
body:not(:has(> .app-bar)) main { max-width: none; padding: 0; }

/* Barra fina de carregamento no topo */
.barra-carregando {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--primaria);
  z-index: 100;
  transition: width 0.4s ease, opacity 0.3s ease;
}
.barra-carregando.completa { opacity: 0; }

/* "Processando…" (util.js `processando`): anel por cima de tudo, menos dos avisos. */
.processando {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: var(--e4);
  background: rgb(0 6 20 / 0.72);
  backdrop-filter: blur(2px);
  animation: processando-entra 160ms ease-out;
}
.processando[hidden] { display: none; }
.processando-caixa { display: grid; justify-items: center; gap: 6px; text-align: center; color: #fff; max-width: 360px; }
.processando-anel { position: relative; width: 132px; height: 132px; margin-bottom: var(--e3); }
.processando-anel svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.processando-trilho { fill: none; stroke: rgb(255 255 255 / 0.08); stroke-width: 11; }
.processando-arco { fill: none; stroke: url(#processando-cor); stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset 400ms ease; }
.processando:not(.com-total) .processando-anel svg { animation: processando-gira 1.1s linear infinite; }
.processando-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.75rem; font-weight: 300; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.processando-titulo { font-size: 1.0625rem; font-weight: 600; letter-spacing: 0.01em; }
.processando-detalhe { font-size: 0.875rem; color: rgb(255 255 255 / 0.78); line-height: 1.4; }
.processando-detalhe:empty, .processando-conta:empty { display: none; }
.processando-conta { font-size: 0.8125rem; color: #7fe9f5; font-variant-numeric: tabular-nums; }
.processando-esconder { margin-top: var(--e3); background: none; border: 1px solid rgb(255 255 255 / 0.3); color: #fff; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 0.8125rem; cursor: pointer; }
.processando-esconder:hover { border-color: #7fe9f5; }
@keyframes processando-gira { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }
@keyframes processando-entra { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .processando:not(.com-total) .processando-anel svg { animation-duration: 3s; }
  .processando { animation: none; }
}

/* ==========================================================================
   Cartões
   ========================================================================== */

.card {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: var(--e5);
  box-shadow: var(--sombra);
}
.card + .card { margin-top: 0; }
.card-titulo {
  display: flex;
  align-items: center;
  gap: var(--e3);
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: var(--e4);
}
.card-titulo .btn-link, .card-titulo a { margin-left: auto; font-size: 0.8125rem; font-weight: 600; }
.card-subtitulo { font-size: 0.8125rem; font-weight: 700; color: var(--texto-suave); margin: var(--e4) 0 var(--e2); }
.card .ajuda, .ajuda { font-size: 0.8125rem; color: var(--texto-suave); margin: 0 0 var(--e4); line-height: 1.5; }
.card-titulo + .ajuda { margin-top: calc(-1 * var(--e2)); }

/* ==========================================================================
   Formulários
   ========================================================================== */

label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--texto-suave); margin-bottom: 4px; }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
input:not([type='checkbox']):not([type='radio']), select, textarea {
  width: 100%;
  height: 36px;
  padding: 0 var(--e3);
  margin: 0;
  border: 1px solid var(--borda-forte);
  border-radius: 8px;
  background: var(--superficie);
  color: var(--texto);
  transition: border-color var(--transicao), box-shadow var(--transicao);
}
textarea { height: auto; min-height: 90px; padding: var(--e2) var(--e3); resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--texto-fraco); }
input:hover, select:hover, textarea:hover { border-color: var(--texto-fraco); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primaria);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primaria) 22%, transparent);
}
input:disabled, select:disabled, textarea:disabled { background: var(--superficie-3); color: var(--texto-fraco); cursor: not-allowed; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='none' stroke='%238591a3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
input[type='checkbox'], input[type='radio'] { width: 16px; height: 16px; margin: 0; accent-color: var(--primaria); cursor: pointer; }
input[type='date'] { min-width: 150px; }
input[type='number'] { font-variant-numeric: tabular-nums; }
input[type='search']::-webkit-search-cancel-button { cursor: pointer; }

.campo { display: flex; flex-direction: column; min-width: 140px; flex: 1 1 160px; }
.campo-largo { flex: 2 1 260px; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--e2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--texto);
  cursor: pointer;
  margin: 0;
  user-select: none;
}
.toggle input { flex: 0 0 auto; }

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: var(--e3) var(--e4);
  align-items: flex-end;
  margin-bottom: var(--e4);
}
.filtros .botoes { margin: 0; align-items: flex-end; }
.linha-form { display: flex; flex-wrap: wrap; gap: var(--e3) var(--e4); margin-bottom: var(--e3); }

/* Campo editável dentro da tabela */
.input-tabela {
  height: 32px !important;
  width: 110px !important;
  padding: 0 var(--e2) !important;
  text-align: right;
  font-weight: 600;
  background: transparent !important;
  border-color: transparent !important;
}
.input-tabela:hover, .input-tabela:focus { background: var(--superficie) !important; border-color: var(--borda-forte) !important; }
.input-tabela.alterado { background: var(--alerta-suave) !important; border-color: var(--alerta) !important; color: var(--alerta-texto); }

/* ==========================================================================
   Botões
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--borda-forte);
  border-radius: 8px;
  background: var(--superficie);
  color: var(--texto);
  font-weight: 600;
  font-size: 0.8125rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transicao), border-color var(--transicao), color var(--transicao), box-shadow var(--transicao), transform 80ms ease;
}
.btn:hover { background: var(--superficie-2); border-color: var(--texto-fraco); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primario { background: var(--primaria); border-color: var(--primaria); color: var(--botao-texto, #fff); }
.btn-primario:hover { background: var(--primaria-forte); border-color: var(--primaria-forte); color: var(--botao-texto, #fff); }
.btn-sucesso { background: var(--sucesso-botao); border-color: var(--sucesso-botao); color: var(--botao-texto, #fff); }
.btn-sucesso:hover { background: var(--sucesso-botao-forte); border-color: var(--sucesso-botao-forte); color: var(--botao-texto, #fff); }
.btn-perigo { background: var(--erro); border-color: var(--erro); color: #fff; }
.btn-perigo:hover { background: var(--vermelho-600); border-color: var(--vermelho-600); color: #fff; }
.btn-pequeno { height: 30px; padding: 0 10px; font-size: 0.75rem; }
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primaria-texto);
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: none;
  border-radius: 4px;
}
.btn-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.btn-link:disabled { color: var(--texto-fraco); cursor: not-allowed; text-decoration: none; }
.btn-cancelar-link { color: var(--erro-texto); }
.botoes { display: flex; flex-wrap: wrap; gap: var(--e2) var(--e3); align-items: center; margin-top: var(--e4); }
.botoes:first-child { margin-top: 0; }

/* ==========================================================================
   Mensagens, pills, vazios
   ========================================================================== */

.mensagem {
  padding: var(--e3) var(--e4);
  border-radius: 10px;
  border: 1px solid var(--borda);
  background: var(--superficie-2);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.mensagem.ok { background: var(--sucesso-suave); border-color: color-mix(in srgb, var(--sucesso) 35%, transparent); color: var(--sucesso-texto); }
.mensagem.erro { background: var(--erro-suave); border-color: color-mix(in srgb, var(--erro) 35%, transparent); color: var(--erro-texto); }
.mensagem.info { background: var(--info-suave); border-color: color-mix(in srgb, var(--primaria) 35%, transparent); color: var(--info-texto); }
.mensagem a { font-weight: 600; color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px 0 7px;
  border-radius: 99px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--superficie-3);
  color: var(--texto-suave);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.pill-neutro { background: var(--superficie-3); color: var(--texto-suave); }
.pill-ok, .pill-pago, .pill-concluida { background: var(--sucesso-suave); color: var(--sucesso-texto); }
.pill-alerta, .pill-atencao, .pill-aberta { background: var(--alerta-suave); color: var(--alerta-texto); }
.pill-perigo, .pill-cancelada, .pill-vencido { background: var(--erro-suave); color: var(--erro-texto); }
.pill-info { background: var(--info-suave); color: var(--info-texto); }

.vazio {
  padding: var(--e6) var(--e4);
  text-align: center;
  color: var(--texto-fraco);
  font-size: 0.8125rem;
}
td.vazio { padding: var(--e6) var(--e4) !important; }
.vazio::before {
  content: '';
  display: block;
  width: 36px;
  height: 36px;
  margin: 0 auto var(--e2);
  background: currentColor;
  opacity: 0.5;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 13h4l2 3h4l2-3h4'/%3E%3Cpath d='M5 6h14l2 7v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5l2-7Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 13h4l2 3h4l2-3h4'/%3E%3Cpath d='M5 6h14l2 7v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5l2-7Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.vazio-grande { padding: var(--e7) var(--e5); text-align: center; max-width: 520px; margin: 0 auto; }
.vazio-grande h3 { font-size: 1.125rem; margin-bottom: var(--e2); }
.vazio-grande p { color: var(--texto-suave); margin-bottom: var(--e4); }

/* ==========================================================================
   Tabelas
   ========================================================================== */

/* A página é quem rola: assim o cabeçalho gruda logo abaixo do topo. Tabela
   larga demais pra caber (.rolavel) rola dentro do próprio quadro. */
.tabela-wrap {
  border: 1px solid var(--borda);
  border-radius: 10px;
  background: var(--superficie);
}
.tabela-wrap.rolavel { overflow: auto; max-height: calc(100vh - var(--topo-h) - 2rem); }
.tabela-wrap.rolavel thead th { top: 0; }
@media (max-width: 600px) {
  :root { --topo-h: 64px; }
  .app-bar-grande .app-subtitulo, .app-bar-grande .app-icone { display: none; }
  .app-bar-grande h1 { font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; }
}
/* Dentro de janela a rolagem é a do corpo dela: o cabeçalho gruda no alto dela, não abaixo do topo da página. */
.modal-corpo thead th { top: 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.8125rem; }
thead th {
  position: sticky;
  top: var(--topo-h);
  z-index: 1;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--texto-suave);
  background: var(--superficie-2);
  border-bottom: 1px solid var(--borda);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--transicao); }
tbody tr:hover td { background: var(--superficie-2); }
tbody td.titulo, .tabela-densa td.titulo { font-weight: 600; }
td .sku { display: block; margin-top: 2px; }
.tabela-densa tbody td { padding: 9px 10px; }
.tabela-densa thead th { padding: 10px; }
.link-linha { font-weight: 600; color: var(--texto); }
.link-linha:hover { color: var(--primaria-texto); }
tr.linha-selecionada td { background: var(--primaria-suave) !important; }
th input[type='checkbox'], td input[type='checkbox'] { display: block; }

/* Abas */
.abas { display: flex; gap: 2px; border-bottom: 1px solid var(--borda); margin-bottom: var(--e4); overflow-x: auto; }
.aba {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--texto-suave);
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transicao), border-color var(--transicao);
}
.aba:hover { color: var(--texto); }
.aba.ativa { color: var(--primaria-texto); border-bottom-color: var(--primaria); }
.aba-qtd {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--superficie-3);
  color: var(--texto-suave);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.aba.ativa .aba-qtd { background: var(--primaria); color: #fff; }

/* Paginação */
.paginacao { display: flex; align-items: center; gap: var(--e3); margin-top: var(--e4); font-size: 0.8125rem; color: var(--texto-suave); }
.paginacao-info { font-variant-numeric: tabular-nums; }
.paginacao .btn-link { height: 30px; padding: 0 10px; border: 1px solid var(--borda-forte); border-radius: 8px; background: var(--superficie); color: var(--texto); }
.paginacao .btn-link:hover { text-decoration: none; background: var(--superficie-2); }
.paginacao .btn-link:disabled { opacity: 0.45; }
.botoes > .paginacao { margin-top: 0; }

/* ==========================================================================
   Modal
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh var(--e4);
  background: rgba(10, 20, 40, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: modal-fundo 160ms ease-out;
  overflow-y: auto;
}
.modal-conteudo {
  width: min(760px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--superficie);
  border-radius: 14px;
  box-shadow: var(--sombra-lg);
  animation: modal-entra 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-cabecalho {
  display: flex;
  align-items: center;
  gap: var(--e4);
  padding: var(--e4) var(--e5);
  border-bottom: 1px solid var(--borda);
}
.modal-cabecalho h2 { font-size: 0.9375rem; flex: 1 1 auto; line-height: 1.3; }
/* Cabeçalho com ícone e subtítulo (abrirModal com `icone`/`subtitulo`). */
.modal-cabecalho-grande { align-items: center; padding: var(--e5) var(--e5) var(--e4); }
.modal-icone { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--primaria); color: var(--botao-texto, #fff); }
.modal-icone svg { width: 24px; height: 24px; }
.modal-titulos { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.modal-cabecalho-grande h2 { font-size: 1.1875rem; font-weight: 800; letter-spacing: -0.015em; line-height: 1.25; text-wrap: balance; }
.modal-subtitulo { margin: 0; font-size: 0.875rem; color: var(--texto-suave); }
.modal-fechar {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--texto-fraco);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.modal-fechar svg { width: 18px; height: 18px; }
.modal-fechar:hover { background: var(--superficie-3); color: var(--texto); }
.modal-corpo { padding: var(--e5); overflow-y: auto; }
@keyframes modal-fundo { from { opacity: 0; } }
@keyframes modal-entra { from { opacity: 0; transform: translateY(8px) scale(0.985); } }

/* ==========================================================================
   Esqueleto enquanto carrega
   ========================================================================== */

@keyframes brilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.indicadores:empty, #painel-kpis:empty, .tabela-wrap:has(tbody:empty)::after {
  display: block;
  content: '';
  border-radius: 12px;
  background: linear-gradient(90deg, var(--superficie-3) 25%, var(--superficie-2) 50%, var(--superficie-3) 75%);
  background-size: 200% 100%;
  animation: brilho 1.4s linear infinite;
}
.indicadores:empty, #painel-kpis:empty { min-height: 104px; }
.tabela-wrap:has(tbody:empty)::after { height: 160px; border-radius: 0; }

/* ==========================================================================
   Responsivo
   ========================================================================== */

@media (max-width: 960px) {
  body { grid-template-columns: 1fr; }
  body.sidebar-oculta { --sidebar-w: 244px; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: none;
  }
  body.menu-aberto .sidebar { transform: translateX(0); box-shadow: var(--sombra-lg); }
  /* No celular o menu recolhido não existe: tudo volta ao tamanho cheio. */
  body.sidebar-oculta .sidebar, body.sidebar-oculta .sidebar-nav { overflow: hidden; }
  body.sidebar-oculta .sidebar-nav { overflow-y: auto; }
  body.sidebar-oculta .sidebar-marca { padding: 0 var(--e4); justify-content: center; }
  body.sidebar-oculta .sidebar-marca .sidebar-logo { display: block; }
  body.sidebar-oculta .sidebar-marca .sidebar-logo-mini { display: none; }
  body.sidebar-oculta .sidebar-secao-titulo { display: block; }
  body.sidebar-oculta .nav-rotulo { display: inline; }
  body.sidebar-oculta .sidebar-secao { border-top: 0; padding-top: 0; }
  body.sidebar-oculta .nav-item { justify-content: flex-start; padding: 0 10px; }
  body.sidebar-oculta .nav-item .nav-badge { position: static; min-width: 20px; height: 20px; line-height: 20px; font-size: 0.6875rem; padding: 0 6px; }
  body.sidebar-oculta .nav-item::after { display: none; }
  .sidebar-rodape { display: none; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(10, 20, 40, 0.4); opacity: 0; pointer-events: none; transition: opacity 200ms; }
  body.menu-aberto .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .app-bar, main { grid-column: 1; }
  .tabela-wrap { overflow-x: auto; }
  thead th { top: 0; }
  .app-bar { padding: 0 var(--e4); gap: var(--e3); }
  .menu-mobile { display: inline-flex; }
  .empresa-nome, .seletor-conta-rotulo { display: none; }
  .seletor-conta select { max-width: 150px; }
  main { padding: var(--e4); }
  .card { padding: var(--e4); }
  .modal { padding: var(--e3); }
  .modal-corpo, .modal-cabecalho { padding: var(--e4); }
}

@media (max-width: 600px) {
  .usuario-nome { display: none; }
  .aviso-teste { display: none; }
}

@media print {
  .sidebar, .app-bar, .barra-carregando, .avisos { display: none !important; }
  body { display: block; background: #fff; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
