/* ==========================================================================
   AdFlow — componentes

   Contrato do sistema:
     • um só jeito de fazer botão, campo, menu, badge, cartão e tabela;
     • altura, raio, fonte, hover, focus, disabled e loading compartilhados;
     • sombra forte só no que flutua (dropdown, popover, modal, gaveta);
     • número tabular, alinhado à direita;
     • transição de 150ms nas propriedades de cor e sombra. Nada além disso.
   ========================================================================== */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--t-ui), transform var(--t-fast) var(--ease);
}

.btn svg { flex: 0 0 auto; }
.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); }

.btn--secondary {
  background: var(--s2);
  border-color: var(--line);
  color: var(--fg);
  box-shadow: var(--shadow-xs);
}

.btn--secondary:hover { background: var(--s2-hover); border-color: var(--line-2); }

.btn--ghost { color: var(--fg-2); font-weight: 500; }
.btn--ghost:hover { background: var(--s2-hover); color: var(--fg); }

.btn--danger-solid { background: var(--down); color: #fff; }
.btn--danger-solid:hover { background: #b42318; }

.btn--sm { height: 34px; padding: 0 11px; font-size: 13px; }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--sm { width: 34px; }
.btn--block { width: 100%; }
.btn--lg { height: 44px; padding: 0 18px; }

/* Botão de ícone solto (linha de tabela, barra de ferramentas). */
.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: var(--r-xs);
  color: var(--fg-3);
  transition: var(--t-ui);
}

.icon-btn:hover { background: var(--s2-hover); color: var(--fg); }
.icon-btn--sm { width: 28px; height: 28px; }
.icon-btn--lg { width: 40px; height: 40px; }
.dropdown.is-open > .icon-btn { background: var(--s2-hover); color: var(--fg); }

/* ==========================================================================
   Campos
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field__label { font-size: 13px; font-weight: 500; color: var(--fg-2); }
.field__hint { font-size: 12px; color: var(--fg-3); line-height: 1.5; }
.field__error { font-size: 12px; color: var(--down-ink); }

.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--fg);
  box-shadow: var(--shadow-xs);
  transition: var(--t-ui);
  appearance: none;
}

.input::placeholder, .textarea::placeholder { color: var(--fg-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-2); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.input.has-error, .select.has-error { border-color: var(--down); }
.input.has-error:focus, .select.has-error:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14); }

.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

.select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.input-group { position: relative; display: flex; align-items: center; }

.input-group__icon {
  position: absolute;
  left: 12px;
  display: grid;
  place-items: center;
  color: var(--fg-3);
  pointer-events: none;
}

.input-group .input { padding-left: 38px; }

.input-group__clear {
  position: absolute;
  right: 6px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-xs);
  color: var(--fg-3);
  transition: var(--t-ui);
}

.input-group__clear:hover { background: var(--s2-hover); color: var(--fg); }

.input-prefix { position: relative; display: flex; align-items: center; }

.input-prefix__text {
  position: absolute;
  left: 12px;
  font-family: var(--font-num);
  font-size: 13px;
  color: var(--fg-3);
  pointer-events: none;
}

.input-prefix .input { padding-left: 36px; }

/* Interruptor -------------------------------------------------------------- */

.switch { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__track {
  position: relative;
  width: 36px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: var(--r-pill);
  background: var(--line-2);
  transition: background var(--t) var(--ease);
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t) var(--ease);
}

.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus); }
.switch__label { font-size: 14px; }

/* Caixa de seleção --------------------------------------------------------- */

.check {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
  background: var(--s2);
  color: transparent;
  cursor: pointer;
  transition: var(--t-ui);
}

.check:hover { border-color: var(--accent); }
.check.is-checked,
.check.is-indeterminate { background: var(--accent); border-color: var(--accent); color: #fff; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }

/* Indeterminado: um traço no lugar do tique. */
.check.is-indeterminate svg { display: none; }

.check.is-indeterminate::after {
  content: '';
  width: 9px;
  height: 2px;
  border-radius: 1px;
  background: #fff;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }

/* ==========================================================================
   Cartões de indicador (KPI)

   Cinco no desktop, sempre com rótulo, valor, variação e uma linha de
   referência. Ícone em ladrilho de cor suave, discreto.
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-4);
}

.kpi-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: 104px;
  padding: var(--sp-4) 18px;
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}

.kpi-card__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: var(--s2-sunk);
  color: var(--fg-2);
}

.kpi-card__icon--accent  { background: var(--accent-soft);   color: var(--accent); }
.kpi-card__icon--info    { background: var(--st-running-bg); color: var(--st-running-ink); }
.kpi-card__icon--warn    { background: var(--st-testing-bg); color: var(--st-testing-ink); }
.kpi-card__icon--success { background: var(--st-winner-bg);  color: var(--st-winner-ink); }
.kpi-card__icon--purple  { background: #f4f0ff;              color: var(--purple); }

.kpi-card__main { min-width: 0; flex: 1 1 auto; }

.kpi-card__label {
  font-size: 13px;
  color: var(--fg-3);
  line-height: 1.35;
}

.kpi-card__row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin-top: 4px;
  flex-wrap: wrap;
}

.kpi-card__value {
  font-family: var(--font-num);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-card__foot {
  margin-top: 6px;
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.35;
}

/* Variação: seta + número, na cor do resultado. Sem fundo, sem pílula. */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.delta svg { flex: 0 0 auto; }
.delta--up { color: var(--up-ink); }
.delta--down { color: var(--down-ink); }
.delta--flat { color: var(--fg-3); font-weight: 500; }

/* ==========================================================================
   Faixa de KPI contínua — usada pelo dashboard e pelas prévias de modal.
   ========================================================================== */

.kpis {
  display: grid;
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

/* Quando a faixa é filha direta do conteúdo, ela respeita a mesma margem
   lateral das seções: encostada na janela, o raio das quinas não teria onde
   aparecer. Vale para a faixa de KPI, a barra de distribuição e os líderes
   do ranking, que ficam fora do .pad. */
.content > .kpis,
.content > .dist,
.content > .table-wrap { margin: var(--sp-5) var(--gutter) 0; }

/* .table-wrap nasce com width:100%; somado à margem lateral isso estoura a
   linha em 2×gutter. Com auto ele passa a preencher o que sobra. */
.content > .table-wrap { width: auto; }

.content > .kpis + .dist { margin-top: var(--sp-4); }

.kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.kpi {
  padding: var(--sp-4) 18px;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.kpi:last-child { border-right: 0; }

.kpi__label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--fg-3);
  line-height: 1.35;
}

.kpi__value {
  margin-top: 6px;
  font-family: var(--font-num);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi__value--sm { font-size: 19px; font-weight: 600; }

.kpi__foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.35;
  min-width: 0;
  flex-wrap: wrap;
}

/* ==========================================================================
   Distribuição por status
   ========================================================================== */

.dist {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}

.dist__bar {
  display: flex;
  gap: 2px;
  height: 6px;
  flex: 0 1 380px;
  min-width: 160px;
  overflow: hidden;
}

.dist__seg { height: 100%; border-radius: var(--r-pill); transition: opacity var(--t) var(--ease); }
.dist__seg:hover { opacity: 0.7; }

.dist__legend { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; flex: 0 0 auto; }

.dist__item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-3);
  white-space: nowrap;
}

.dist__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  align-self: center;
}

.dist__count {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Status — pílula com ponto. Fundo suave, tinta legível.
   ========================================================================== */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--st-draft-bg);
  color: var(--st-draft-ink);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: middle;
}

.status__dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.status--draft      { background: var(--st-draft-bg);      color: var(--st-draft-ink); }
.status--testing    { background: var(--st-testing-bg);    color: var(--st-testing-ink); }
.status--running    { background: var(--st-running-bg);    color: var(--st-running-ink); }
.status--winner     { background: var(--st-winner-bg);     color: var(--st-winner-ink); }
.status--scaling    { background: var(--st-scaling-bg);    color: var(--st-scaling-ink); }
.status--saturating { background: var(--st-saturating-bg); color: var(--st-saturating-ink); }
.status--dead       { background: var(--st-dead-bg);       color: var(--st-dead-ink); }
.status--archived   { background: var(--st-archived-bg);   color: var(--st-archived-ink); }

/* Dentro de um menu a pílula perde o fundo: quem dá o destaque é o item. */
.dropdown__item .status { height: auto; padding: 0; background: none; font-weight: 500; }
.dropdown__item .status__dot { background: var(--st-draft); opacity: 1; }
.dropdown__item .status--draft      .status__dot { background: var(--st-draft); }
.dropdown__item .status--testing    .status__dot { background: var(--st-testing); }
.dropdown__item .status--running    .status__dot { background: var(--st-running); }
.dropdown__item .status--winner     .status__dot { background: var(--st-winner); }
.dropdown__item .status--scaling    .status__dot { background: var(--st-scaling); }
.dropdown__item .status--saturating .status__dot { background: var(--st-saturating); }
.dropdown__item .status--dead       .status__dot { background: var(--st-dead); }
.dropdown__item .status--archived   .status__dot { background: var(--st-archived); }

/* Botão que abre o seletor de status: a pílula inteira é o gatilho. */
.status-trigger { display: inline-flex; border-radius: var(--r-pill); transition: var(--t-ui); }
.status-trigger:hover { box-shadow: 0 0 0 3px rgba(16, 24, 40, 0.05); }

/* Fileira de status no cabeçalho de um painel: a composição da carteira em
   badges, cada uma levando à biblioteca já filtrada. */
.statusbadges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.statusbadges .status { transition: var(--t-ui); }
.statusbadges a.status:hover { box-shadow: 0 0 0 3px rgba(16, 24, 40, 0.05); }
.statusbadges .num { font-weight: 700; }

/* Barra de proporção sob o cabeçalho do painel: a carteira inteira em um
   objeto só. Com margem lateral e cantos arredondados ela lê como um
   elemento deliberado — sangrando de ponta a ponta viraria um sublinhado
   multicolorido do cabeçalho. Fios de 1px entre os segmentos para ler como
   partes contadas, não como um degradê decorativo. */
/* Badges + barra, como um bloco só no canto do cabeçalho. */
.dist-head { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 0; }

.distbar {
  display: flex;
  gap: 1px;
  height: 4px;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--line-soft);
}

.distbar__seg { height: 100%; transition: opacity var(--t) var(--ease); }
.distbar__seg:hover { opacity: 0.7; }

/* Marca de alerta na linha: ponto + texto curto. Sem badge grande. */
.flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  min-width: 0;
}

.flag::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.flag--critical { color: var(--down-ink); }
.flag--warning { color: var(--warn-ink); }

/* Indicador de performance: traço vertical na borda da linha/card. */
.perf-edge {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: transparent;
}

.perf-edge--strong { background: var(--perf-strong); }
.perf-edge--watch { background: var(--perf-watch); }
.perf-edge--drop { background: var(--perf-drop); }

/* ==========================================================================
   Chip / tag
   ========================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--s2);
  font-size: 13px;
  color: var(--fg-2);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}

.chip--interactive { cursor: pointer; transition: var(--t-ui); }
.chip--interactive:hover { border-color: var(--line-2); color: var(--fg); background: var(--s2-hover); }

.chip.is-selected {
  background: var(--accent-soft);
  border-color: rgba(7, 154, 120, 0.35);
  color: var(--accent-strong);
  font-weight: 500;
}

/* Contador dentro de um botão: quantos filtros avançados estão ligados. */
.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Em zero ele continua na tela — some só o alarde. */
.count-badge--zero { background: var(--s2-sunk); color: var(--fg-4); }

.chip__key { color: var(--fg-3); }
.chip__remove {
  display: grid;
  place-items: center;
  width: 16px; height: 16px;
  margin-right: -3px;
  border-radius: 50%;
  color: inherit;
  opacity: 0.6;
  transition: var(--t-ui);
}
.chip__remove:hover { opacity: 1; background: rgba(16, 24, 40, 0.07); }

/* Alias mantido: várias telas ainda usam .tag. */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--s2);
  font-size: 12px;
  color: var(--fg-2);
  white-space: nowrap;
}

.tag--interactive { cursor: pointer; transition: var(--t-ui); }
.tag--interactive:hover { border-color: var(--line-2); color: var(--fg); }
.tag.is-selected { background: var(--accent-soft); border-color: rgba(7, 154, 120, 0.35); color: var(--accent-strong); }
.tag__remove { display: grid; place-items: center; margin-right: -3px; color: inherit; opacity: 0.6; }
.tag__remove:hover { opacity: 1; }

/* ==========================================================================
   Grupo segmentado e abas
   ========================================================================== */

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--s2-sunk);
  box-shadow: var(--shadow-xs);
}

.segmented__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  transition: var(--t-ui);
}

.segmented__item:hover { color: var(--fg); }

/* O item ativo precisa se destacar DENTRO do trilho afundado; aqui a sombra
   mínima é estrutural, não decoração — é o que o levanta do fundo. */
.segmented__item.is-active {
  background: var(--s2);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.07);
}

.segmented--icons .segmented__item { width: 32px; padding: 0; justify-content: center; }

/* Abas de status: texto + contagem, sublinhado verde no ativo. ------------- */

.tabs {
  display: flex;
  align-items: stretch;
  gap: var(--sp-5);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: var(--sp-5);
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-3);
  white-space: nowrap;
  flex: 0 0 auto;
  transition: color var(--t) var(--ease);
}

.tab:hover { color: var(--fg); }

.tab.is-active { color: var(--accent); font-weight: 600; }

.tab.is-active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.tab__count {
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.tab.is-active .tab__count { color: var(--accent); }

/* Abas dentro de um painel: sem o fio embaixo e sem margem — o cabeçalho do
   painel já separa. O sublinhado do ativo continua. */
.tabs--inline {
  border-bottom: 0;
  margin-bottom: 0;
  gap: var(--sp-4);
}

.tabs--inline .tab { height: 34px; font-size: 13.5px; }
.tabs--inline .tab.is-active::after { bottom: 0; }

/* ==========================================================================
   Tabela

   Container com contorno e raio; cabeçalho em superfície afundada; fios
   horizontais entre as linhas; números tabulares à direita.
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
}

/* A tabela principal da tela não pode ficar dentro de um container com
   overflow: `overflow-x: auto` cria um scrollport próprio, e aí o `top` do
   cabeçalho fixo passa a contar a partir dele — o cabeçalho desce para o
   meio da tabela em vez de encostar na toolbar. Em tela larga ela cabe
   inteira; abaixo disso devolvemos o scroll e o cabeçalho volta a top: 0. */
.table-wrap--docked { overflow-x: visible; }

/* Sem fundo próprio: a superfície é a do wrapper.
   Com `background` aqui a tabela pinta um retângulo branco por cima das
   quinas arredondadas do cartão, e o canto passa a parecer reto. */
.table { width: 100%; font-size: 14px; }

.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 44px;
  padding: 0 var(--sp-3);
  background: var(--s2-sunk);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-2);
  text-align: left;
  white-space: nowrap;
}

/* O cabeçalho tem fundo próprio e encosta na quina do cartão. O raio dele é
   o raio INTERNO do wrapper — o do wrapper menos a borda de 1px. Com o
   mesmo valor dos dois lados sobra uma fresta branca triangular na quina, e
   o canto lê como se fosse reto. */
.table thead tr:first-child th:first-child { border-top-left-radius: calc(var(--r) - 1px); }
.table thead tr:first-child th:last-child { border-top-right-radius: calc(var(--r) - 1px); }

/* O cabeçalho encaixa logo abaixo das faixas fixas da tela. A altura real é
   medida em JS (--dock): a toolbar cresce quando quebra linha e a faixa de
   filtros ativos aparece e some. Valor fixo aqui desalinha em telas médias. */
.table--docked thead th { top: var(--dock, 0px); }

.table thead th.is-numeric,
.table tbody td.is-numeric { text-align: right; white-space: nowrap; }

.table tbody td {
  height: var(--row-h);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  color: var(--fg);
}

/* A primeira e a última célula respiram contra a borda do painel. */
.table thead th:first-child,
.table tbody td:first-child { padding-left: var(--sp-4); }

.table thead th:last-child,
.table tbody td:last-child { padding-right: var(--sp-4); }

.table tbody tr:last-child td { border-bottom: 0; }

/* A última linha encosta na quina de baixo do cartão: o hover e a seleção
   precisam do mesmo raio interno do cabeçalho, senão pintam por cima da
   curva quando o mouse passa. Não vale para tabela dentro de painel, que
   não tem quina própria. */
.table-wrap:not(.table-wrap--flush) .table tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--r) - 1px); }
.table-wrap:not(.table-wrap--flush) .table tbody tr:last-child td:last-child { border-bottom-right-radius: calc(var(--r) - 1px); }
.table tbody tr { transition: background var(--t) var(--ease); }
.table tbody tr:hover { background: var(--row-hover); }
.table tbody tr.is-selected { background: var(--accent-wash); }
.table tbody tr.is-clickable { cursor: pointer; }

/* Tabela compacta: painéis do dashboard e listas laterais. */
.table--compact { font-size: 13px; }

.table--compact thead th {
  height: 36px;
  padding: 0 var(--sp-3);
  font-size: 12px;
  color: var(--fg-3);
  font-weight: 500;
}

.table--compact tbody td { height: 52px; padding: var(--sp-2) var(--sp-3); }
.table--compact .creative-cell__name { font-size: 13px; }

/* Tabela em coluna estreita (trilho do dashboard).

   Com distribuição automática o nome do criativo pede a largura do texto
   inteiro e empurra status e ações para fora do painel. Com largura fixa a
   tabela cabe sempre, e o que sobra do nome vira reticências. */
/* O corte fica no conteúdo, não na célula: `overflow: hidden` no <td>
   também recortaria a dica que sobe a partir de dentro dele. */
.table--fixed { table-layout: fixed; }
.table--fixed .creative-cell { min-width: 0; }
.table--fixed .creative-cell__name { max-width: 100%; }
.table--fixed tbody td > * { max-width: 100%; }

.table__sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  font: inherit;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: color var(--t) var(--ease);
}

.table__sort:hover { color: var(--fg); }
.table__sort.is-active { color: var(--fg); font-weight: 600; }
.table__sort svg { opacity: 0.45; flex: 0 0 auto; transition: opacity var(--t) var(--ease); }
.table__sort:hover svg { opacity: 0.8; }
.table__sort.is-active svg { opacity: 1; color: var(--accent); }

/* O menu "…" fica sempre visível: uma linha que só revela ação no hover
   parece uma linha sem ação. */
.table__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

/* Coluna de seleção. */
.table th.col-check,
.table td.col-check { width: 44px; padding-right: 0; }

/* Posição no ranking: número discreto, alinhado à direita da própria coluna. */
.table td.rank {
  font-family: var(--font-num);
  font-size: 13px;
  color: var(--fg-4);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table tbody tr:first-child td.rank { color: var(--accent); font-weight: 700; }

/* Célula de tendência. */
.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-num);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--fg-3);
  white-space: nowrap;
}

.trend--up { color: var(--up-ink); }
.trend--down { color: var(--down-ink); }

/* ==========================================================================
   Miniaturas
   ========================================================================== */

.thumb {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--s2-hover);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  flex: 0 0 auto;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }

.thumb__fallback {
  display: grid;
  place-items: center;
  width: 100%; height: 100%;
  color: var(--fg-4);
}

.thumb--xs { width: 28px; height: 28px; }
.thumb--sm { width: 36px; height: 36px; }
.thumb--md { width: 48px; height: 48px; }
.thumb--lg { width: 64px; height: 64px; }
.thumb--portrait { width: 48px; height: 48px; }

/* ==========================================================================
   Pessoa
   ========================================================================== */

.person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.person__name { font-size: 14px; color: var(--fg-2); white-space: nowrap; }

.person__initials {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-3);
  flex: 0 0 auto;
}

.person__avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: var(--r-pill);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--fg-2);
}

.person__avatar--1 { background: #0f7a5c; }
.person__avatar--2 { background: #2c5fa8; }
.person__avatar--3 { background: #a06510; }
.person__avatar--4 { background: #0f6c74; }
.person__avatar--5 { background: #7a3f6d; }

/* ==========================================================================
   Menu suspenso e popover
   ========================================================================== */

.dropdown { position: relative; }

.dropdown__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 208px;
  padding: 6px;
  background: var(--s3);
  border-radius: var(--r);
  box-shadow: var(--pop);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}

.dropdown.is-open > .dropdown__menu { opacity: 1; transform: translateY(0); pointer-events: auto; }
.dropdown__menu--left { right: auto; left: 0; }
.dropdown__menu--up { top: auto; bottom: calc(100% + 6px); }

.dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-xs);
  font-size: 14px;
  color: var(--fg-2);
  text-align: left;
  transition: var(--t-ui);
}

.dropdown__item svg { color: var(--fg-3); flex: 0 0 auto; }
.dropdown__item:hover { background: var(--s2-hover); color: var(--fg); }
.dropdown__item:hover svg { color: var(--fg-2); }
.dropdown__item.is-current { background: var(--accent-soft); color: var(--accent-strong); font-weight: 500; }
.dropdown__item--danger { color: var(--down-ink); }
.dropdown__item--danger svg { color: var(--down-ink); }
.dropdown__item--danger:hover { background: var(--st-dead-bg); color: var(--down-ink); }

.dropdown__sep { height: 1px; margin: 6px -6px; background: var(--line); }

.dropdown__label {
  padding: 6px 10px 4px;
  font-size: 12px;
  color: var(--fg-3);
}

/* Popover: painel mais largo, para filtros avançados. */
.popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  width: 360px;
  background: var(--s3);
  border-radius: var(--r);
  box-shadow: var(--pop);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}

.dropdown.is-open > .popover { opacity: 1; transform: translateY(0); pointer-events: auto; }
.popover--left { right: auto; left: 0; }
.popover--wide { width: 440px; }

.popover__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}

.popover__title { font-size: 14px; font-weight: 600; }
.popover__body { padding: var(--sp-4); max-height: 56vh; overflow-y: auto; }

.popover__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line);
}

/* ==========================================================================
   Dica (tooltip)
   ========================================================================== */

.tip { position: relative; }

/* `display: none` em vez de `opacity: 0`: uma dica escondida continua
   ocupando espaço no cálculo de rolagem do container, e as dos cabeçalhos
   das últimas colunas empurravam a página inteira para a direita. Por isso
   a entrada é uma animação, não uma transição — de none para block a
   transição não roda. */
.tip::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 9px;
  border-radius: var(--r-xs);
  background: var(--fg);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  max-width: 280px;
  pointer-events: none;
  z-index: 70;
  box-shadow: var(--pop);
}

.tip:hover::after,
.tip:focus-visible::after {
  display: block;
  animation: tip-in var(--t) var(--ease);
}

@keyframes tip-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tip--below::after { bottom: auto; top: calc(100% + 8px); }

/* Ancorada à direita: para o que fica perto da borda da tela. */
.tip--end::after { left: auto; right: 0; transform: none; }

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: rgba(16, 24, 40, 0.5);
  opacity: 0;
  transition: opacity var(--t) var(--ease);
  overflow-y: auto;
}

.modal-backdrop.is-open { opacity: 1; }

.modal {
  width: 100%;
  max-width: 480px;
  margin: auto;
  background: var(--s3);
  border-radius: var(--r-lg);
  box-shadow: var(--pop-lg);
  transform: translateY(8px);
  opacity: 0;
  transition: transform var(--t-slow) var(--ease), opacity var(--t-slow) var(--ease);
}

.modal-backdrop.is-open .modal { transform: translateY(0); opacity: 1; }
.modal--wide { max-width: 680px; }
.modal--narrow { max-width: 420px; }

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--line);
}

.modal__title { font-size: 16px; font-weight: 600; letter-spacing: -0.011em; }
.modal__subtitle { margin-top: 4px; font-size: 13px; color: var(--fg-3); }
.modal__body { padding: var(--sp-5); }

.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line);
}

.modal__close {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  margin: -4px -6px 0 0;
  border-radius: var(--r-xs);
  color: var(--fg-3);
  flex: 0 0 auto;
  transition: var(--t-ui);
}

.modal__close:hover { background: var(--s2-hover); color: var(--fg); }

/* Ícone de confirmação: ladrilho de cor suave. */
.modal__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--sp-4);
  border-radius: var(--r-sm);
}

.modal__icon--danger { background: var(--st-dead-bg); color: var(--down-ink); }
.modal__icon--warning { background: var(--st-testing-bg); color: var(--warn-ink); }

/* ==========================================================================
   Gaveta lateral
   ========================================================================== */

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  background: var(--s3);
  box-shadow: var(--pop-lg);
  transform: translateX(24px);
  opacity: 0;
  transition: transform var(--t-slow) var(--ease), opacity var(--t-slow) var(--ease);
}

.drawer--wide { max-width: 720px; }

.modal-backdrop--drawer { align-items: stretch; justify-content: flex-end; padding: 0; overflow: hidden; }
.modal-backdrop--drawer.is-open .drawer { transform: translateX(0); opacity: 1; }

.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.drawer__body { flex: 1 1 auto; overflow-y: auto; }
.drawer__body--pad { padding: var(--sp-5); }

.drawer__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}

.drawer__section { padding: var(--sp-5); border-bottom: 1px solid var(--line); }
.drawer__section:last-child { border-bottom: 0; }

.drawer__section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

/* ==========================================================================
   Avisos
   ========================================================================== */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: var(--sp-6);
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  padding: 12px 14px;
  background: var(--fg);
  border-radius: var(--r);
  color: #fff;
  font-size: 14px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  box-shadow: var(--pop-lg);
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}

.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast__icon { display: grid; place-items: center; flex: 0 0 auto; }
.toast--success .toast__icon { color: #6ee7b7; }
.toast--error .toast__icon { color: #fca5a5; }
.toast--info .toast__icon { color: #93c5fd; }
.toast__message { flex: 1 1 auto; line-height: 1.4; }

.toast__close {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  flex: 0 0 auto;
  margin-right: -4px;
  border-radius: var(--r-xs);
  color: rgba(255, 255, 255, 0.55);
  transition: color var(--t) var(--ease);
}

.toast__close:hover { color: #fff; }

/* Aviso em linha. */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid currentColor;
  border-radius: var(--r-sm);
  background: var(--s2-sunk);
  font-size: 14px;
  line-height: 1.45;
}

.notice--critical { color: var(--down-ink); background: var(--st-dead-bg); border-color: rgba(220, 38, 38, 0.2); border-left-color: var(--down); }
.notice--warning { color: var(--warn-ink); background: var(--st-testing-bg); border-color: rgba(245, 158, 11, 0.24); border-left-color: var(--warn); }
.notice svg { flex: 0 0 auto; margin-top: 1px; }
.notice strong { font-weight: 600; }

/* ==========================================================================
   Estado vazio e estado de erro
   ========================================================================== */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-12) var(--sp-5);
  max-width: 420px;
  margin: 0 auto;
}

.empty__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--s2-sunk);
  color: var(--fg-3);
}

.empty__title { font-size: 16px; font-weight: 600; }
.empty__text { margin-top: 6px; font-size: 14px; color: var(--fg-3); line-height: 1.5; }
.empty__actions { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-5); flex-wrap: wrap; justify-content: center; }
.empty__action { margin-top: var(--sp-5); }
.empty--sm { padding: var(--sp-8) var(--sp-4); }
.empty--error .empty__icon { background: var(--st-dead-bg); color: var(--down-ink); }
.empty__icon--ok { background: var(--st-winner-bg); color: var(--st-winner-ink); }

/* Estado BOM — não é a mesma coisa que estado vazio.
   "Nada fora do esperado" é uma boa notícia: cabe em uma linha com um check
   verde, não em um bloco centralizado do tamanho de meia tela. */
.allgood {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: var(--sp-4);
}

.allgood__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: var(--st-winner-bg);
  color: var(--st-winner-ink);
}

.allgood__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.allgood__title { font-size: 14px; font-weight: 600; }
.allgood__text { font-size: 13px; color: var(--fg-3); line-height: 1.45; }

/* ==========================================================================
   Paginação
   ========================================================================== */

/* Faixa própria, fora do cartão da lista: navegação não é conteúdo da
   tabela. Sem fundo e sem contorno — o que separa é o espaço. */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) 2px 0;
  flex-wrap: wrap;
}

.pagination__info {
  font-family: var(--font-num);
  font-size: 13px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.pagination__end { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.pagination__pages { display: flex; align-items: center; gap: 4px; }

.pagination__page {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--s2);
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-xs);
  transition: var(--t-ui);
}

.pagination__page:hover { background: var(--s2-hover); border-color: var(--line-2); color: var(--fg); }

.pagination__page.is-active {
  background: var(--accent-soft);
  border-color: rgba(7, 154, 120, 0.35);
  color: var(--accent-strong);
  font-weight: 600;
}

.pagination__page.is-disabled { opacity: 0.4; pointer-events: none; box-shadow: none; }
.pagination__gap { padding: 0 2px; color: var(--fg-3); font-size: 13px; }

.pagination__size {
  height: 36px;
  padding: 0 32px 0 12px;
  font-size: 13px;
  width: auto;
  min-width: 140px;
  background-position: right 10px center;
}

/* ==========================================================================
   Carregando
   ========================================================================== */

.is-loading { position: relative; }

.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  pointer-events: none;
  z-index: 5;
  border-radius: var(--r);
}

.spinner {
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.75;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Esqueleto: um pulso discreto no tom do fio. */
.skeleton {
  background: var(--line-soft);
  border-radius: var(--r-xs);
  animation: skeleton 1.4s ease-in-out infinite;
}

@keyframes skeleton {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.skeleton--text { height: 12px; }
.skeleton--row { height: 14px; margin: 14px 0; }
.skeleton--circle { border-radius: 50%; }

/* O esqueleto ocupa exatamente a altura da linha real: a tabela não pula
   quando os dados chegam. */
.skeleton-table td { height: var(--row-h); }
.skeleton-table .skeleton { height: 12px; }

/* ==========================================================================
   Área de arquivo e bandeja de upload
   ========================================================================== */

.dropzone {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--sp-4);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-sm);
  background: var(--s2-sunk);
  cursor: pointer;
  transition: var(--t-ui);
}

.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone__icon { color: var(--fg-3); flex: 0 0 auto; }
.dropzone__title { font-size: 14px; font-weight: 500; }
.dropzone__hint { font-size: 12px; color: var(--fg-3); line-height: 1.4; }

.upload-tray {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 180;
  width: 340px;
  background: var(--s3);
  border-radius: var(--r);
  box-shadow: var(--pop-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}

.upload-tray.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.upload-tray__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 44px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
}

.upload-tray__title { font-size: 13px; font-weight: 600; }
.upload-tray__list { max-height: 260px; overflow-y: auto; }

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.upload-item:last-child { border-bottom: 0; }
.upload-item__icon { display: grid; place-items: center; flex: 0 0 auto; color: var(--fg-3); }
.upload-item.is-done .upload-item__icon { color: var(--up-ink); }
.upload-item.is-error .upload-item__icon { color: var(--down-ink); }
.upload-item__main { display: block; flex: 1 1 auto; min-width: 0; }

.upload-item__name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item__meta {
  display: block;
  margin-top: 2px;
  font-family: var(--font-num);
  font-size: 12px;
  color: var(--fg-3);
}

.upload-item.is-error .upload-item__meta { color: var(--down-ink); }

.upload-item__bar {
  display: block;
  height: 4px;
  margin-top: 6px;
  background: var(--line-soft);
  overflow: hidden;
  border-radius: var(--r-pill);
}

/* `display: block` é o que faz a barra andar: o fill é um <span>, e em
   elemento inline o navegador ignora width e height. O JS escrevia
   `width: 40%` corretamente e nada acontecia na tela. */
.upload-item__fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width var(--t) linear;
}
.upload-item.is-done .upload-item__bar { display: none; }

.upload-item__cancel {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  flex: 0 0 auto;
  border-radius: var(--r-xs);
  color: var(--fg-3);
}

.upload-item__cancel:hover { background: var(--s2-hover); color: var(--fg); }
.upload-item.is-done .upload-item__cancel { display: none; }

body.has-upload-tray .content { padding-bottom: 140px; }

/* ==========================================================================
   Busca global do header
   ========================================================================== */

.globalsearch {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 320px;
  height: 40px;
  padding: 0 10px 0 12px;
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs);
  color: var(--fg-4);
  font-size: 14px;
  text-align: left;
  transition: var(--t-ui);
}

.globalsearch:hover { border-color: var(--line-2); }
.globalsearch svg { flex: 0 0 auto; color: var(--fg-3); }
.globalsearch__text { flex: 1 1 auto; min-width: 0; }

.kbd {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--s2-sunk);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-3);
  white-space: nowrap;
  flex: 0 0 auto;
}

/* Paleta de comandos ------------------------------------------------------- */

.palette-backdrop { align-items: flex-start; padding-top: 12vh; }

.palette {
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--s3);
  border-radius: var(--r-lg);
  box-shadow: var(--pop-lg);
  overflow: hidden;
  transform: translateY(8px);
  opacity: 0;
  transition: transform var(--t-slow) var(--ease), opacity var(--t-slow) var(--ease);
}

.modal-backdrop.is-open .palette { transform: translateY(0); opacity: 1; }

.palette__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--sp-4);
  height: 56px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.palette__head > svg { color: var(--fg-3); flex: 0 0 auto; }

.palette__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  font-size: 16px;
  color: var(--fg);
  outline: none;
}

.palette__input::placeholder { color: var(--fg-4); }

/* O campo já é o foco da paleta: um anel em volta dele só faria barulho.
   O foco visível continua existindo em tudo o mais. */
.palette__input:focus-visible { box-shadow: none; }

.palette__body { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-2); }

.palette__group + .palette__group { margin-top: 2px; }

.palette__group-label {
  padding: 10px 10px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-3);
}

.palette__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--fg);
  transition: background var(--t-fast) var(--ease);
}

.palette__item.is-active { background: var(--s2-hover); }
.palette__item.is-active .palette__item-code { color: var(--accent); }

.palette__item-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: var(--r-xs);
  background: var(--s2-sunk);
  color: var(--fg-3);
  overflow: hidden;
}

.palette__item-icon img { width: 100%; height: 100%; object-fit: cover; }
.palette__item-main { flex: 1 1 auto; min-width: 0; }

/* Título e subtítulo são <span> (o item é um <button>, que não aceita <div>
   dentro): sem display:block eles colariam na mesma linha. */
.palette__item-title,
.palette__item-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette__item-title { font-size: 14px; font-weight: 500; line-height: 1.35; }
.palette__item-sub { font-size: 12px; color: var(--fg-3); margin-top: 2px; line-height: 1.3; }

.palette__item-code {
  font-family: var(--font-num);
  font-size: 12px;
  color: var(--fg-3);
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.palette__state { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--fg-3); font-size: 14px; }

.palette__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 10px var(--sp-4);
  border-top: 1px solid var(--line);
  background: var(--s2-sunk);
  font-size: 12px;
  color: var(--fg-3);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.palette__hint { display: inline-flex; align-items: center; gap: 6px; }

/* ==========================================================================
   Notificações
   ========================================================================== */

.bell { position: relative; }

.bell__dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--down);
  border: 2px solid var(--s0);
}

.topbar.is-stuck .bell__dot { border-color: var(--s1); }

.notif-drawer { max-width: 400px; }

.notif-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.notif-drawer__tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.notif-list { flex: 1 1 auto; overflow-y: auto; }

.notif {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  transition: background var(--t) var(--ease);
}

.notif:hover { background: var(--row-hover); }
.notif.is-unread { background: rgba(7, 154, 120, 0.035); }

.notif__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: var(--s2-sunk);
  color: var(--fg-2);
}

.notif__icon--success { background: var(--st-winner-bg); color: var(--st-winner-ink); }
.notif__icon--warning { background: var(--st-testing-bg); color: var(--st-testing-ink); }
.notif__icon--critical { background: var(--st-dead-bg); color: var(--st-dead-ink); }
.notif__icon--info { background: var(--st-running-bg); color: var(--st-running-ink); }

.notif__main { flex: 1 1 auto; min-width: 0; }

/* São <span> dentro de um <a>: sem display:block título, descrição e hora
   viriam coladas na mesma linha. */
.notif__title,
.notif__text,
.notif__time { display: block; }

.notif__title { font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--fg); }
.notif__text { margin-top: 3px; font-size: 13px; color: var(--fg-2); line-height: 1.4; }
.notif__time { margin-top: 5px; font-size: 12px; color: var(--fg-3); }

.notif__unread {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.notif-drawer__foot {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}

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

@media (max-width: 1500px) {
  .globalsearch { width: 260px; }
}

@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis--6 .kpi:nth-child(3n) { border-right: 0; }
  .kpis--6 .kpi:nth-child(-n + 3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 1240px) {
  .globalsearch { width: 44px; padding: 0; justify-content: center; }
  .globalsearch__text,
  .globalsearch .kbd { display: none; }
}

@media (max-width: 1100px) {
  .kpis--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis--5 .kpi:nth-child(3n) { border-right: 0; }
  .kpis--5 .kpi:nth-child(-n + 3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 1023px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .kpis--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis--4 .kpi:nth-child(2n) { border-right: 0; }
  .kpis--4 .kpi:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .drawer--wide { max-width: 100%; }
}

/* Abaixo desta largura as onze colunas da biblioteca não cabem mais na
   coluna de trabalho: volta o scroll horizontal e, com ele, o cabeçalho
   ancorado no topo do próprio scrollport.

   O número sai do `min-width` de .table--creatives (1286px) mais a sidebar
   e as margens laterais. Mexer nas larguras de .table--creatives pede revisar
   este valor junto. */
@media (max-width: 1570px) {
  .table-wrap--docked { overflow-x: auto; }
  .table--docked thead th { top: 0; }
}

/* Com a barra recolhida sobram 148px, e a tabela volta a caber inteira —
   é exatamente para isso que o botão de recolher existe. Nessa faixa o
   cabeçalho volta a encaixar embaixo das faixas fixas. */
@media (min-width: 1420px) and (max-width: 1570px) {
  :root.is-collapsed .table-wrap--docked { overflow-x: visible; }
  :root.is-collapsed .table--docked thead th { top: var(--dock, 0px); }
}

@media (max-width: 720px) {
  /* Dois por linha e mais baixos: cinco cartões altos empurrariam a tabela
     para fora da primeira tela do celular. A linha de referência sai — o
     rótulo e o valor já dizem o essencial. */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .kpi-card { gap: 10px; padding: var(--sp-3); min-height: 0; }
  .kpi-card__icon { width: 32px; height: 32px; }
  .kpi-card__value { font-size: 20px; }
  .kpi-card__foot { display: none; }
  .kpis--3, .kpis--4, .kpis--5, .kpis--6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: var(--sp-3); border-right: 1px solid var(--line); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi__value { font-size: 20px; }
  .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: span 1; }
  .toast-stack { left: var(--sp-3); right: var(--sp-3); transform: none; }
  .toast { max-width: none; }
  .modal__foot { flex-direction: column-reverse; align-items: stretch; }
  .modal__foot .btn { width: 100%; }
  .upload-tray { left: var(--sp-3); right: var(--sp-3); width: auto; }

  /* No celular o popover de filtros vira folha inferior: ancorado ao botão
     ele ficaria metade fora da tela, e é onde se digita mais. */
  .popover,
  .popover--wide,
  .popover--left {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 86vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--pop-lg);
    transform: translateY(100%);
    z-index: 120;
  }

  .dropdown.is-open > .popover { transform: translateY(0); }
  .popover__body { max-height: 62vh; }
  .popover__head { padding: var(--sp-4) var(--sp-5); }
  .popover__foot { padding: var(--sp-4) var(--sp-5); padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom)); }
  .popover__body { padding: var(--sp-4) var(--sp-5); }
  .palette-backdrop { padding: var(--sp-3); padding-top: 6vh; }
  .notif-drawer { max-width: 100%; }
  .empty { padding: var(--sp-8) var(--sp-4); }
}

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-card__icon { display: none; }
}
