/* Licita v2 — design tokens
   Estilo "Swiss/minimal" para ferramenta de dados: azul institucional como ação,
   âmbar só para destaque (favorita, lance), Fira Sans no texto e Fira Code nos números. */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-subtle: #eef2f6;
  --fg: #0f172a;
  --fg-2: #334155;
  --muted: #5b6b82;
  --faint: #8494a9;
  --accent: #1e40af;
  --accent-hover: #1e3a8a;
  --accent-soft: #eef3ff;
  --accent-border: #d3defa;
  --destaque: #b45309;
  --destaque-soft: #fff7ed;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --ia: #6d28d9;
  --ia-soft: #f5f3ff;
  --ia-border: #ddd6fe;
  --radius: 10px;
  --radius-sm: 7px;
  --sombra: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.04);
  --sombra-alta: 0 12px 32px rgba(15, 23, 42, 0.12);
  --anel: 0 0 0 3px rgba(30, 64, 175, 0.22);
  --sans: "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "Fira Code", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --sidebar: 236px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { font-size: 14px; }

body {
  font-family: var(--sans);
  font-size: 14.5px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--anel); border-radius: var(--radius-sm); }

.ico { flex-shrink: 0; vertical-align: -3px; }

.pular {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm);
}
.pular:focus { top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.marca {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.marca:hover { text-decoration: none; }
.marca .logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.marca .versao {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-border); border-radius: 999px; padding: 0 6px;
}

.nav { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.nav-grupo { display: flex; flex-direction: column; gap: 1px; }
.nav-titulo {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--faint); padding: 0 10px 4px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-2);
  font-weight: 500;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.nav a .ico { color: var(--faint); transition: color 150ms var(--ease); }
.nav a:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; }
.nav a:hover .ico { color: var(--fg-2); }
.nav a.ativo { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.ativo .ico { color: var(--accent); }
.nav a.nav-destaque:not(.ativo) .ico { color: var(--ia); }
.nav-novo {
  margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ia); background: var(--ia-soft); border: 1px solid var(--ia-border);
  border-radius: 999px; padding: 0 6px;
}

.sessao {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sessao .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; color: var(--fg-2);
}
.sessao .usuario { flex: 1; font-size: 13px; font-weight: 500; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; }

.btn-icone {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.btn-icone:hover { background: var(--surface-2); color: var(--fg); border-color: var(--border); }

.topo-mobile { display: none; }
.veu { display: none; }

.conteudo { flex: 1; min-width: 0; padding: 28px 36px 56px; max-width: 1320px; }

@media (max-width: 960px) {
  .topo-mobile {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 40;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 8px 12px;
  }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    box-shadow: var(--sombra-alta);
  }
  .menu-aberto .sidebar { transform: none; }
  .veu { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, 0.4); }
  .veu[hidden] { display: none; }
  .conteudo { padding: 20px 16px 48px; }
}

.cabecalho { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cabecalho > div:first-child, .cabecalho > h1:first-child { min-width: 0; }
.cabecalho h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.25; }
.cabecalho .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 760px; }
.cabecalho .sub .badge { margin-top: 2px; }
.cabecalho-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.migalha { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.migalha:hover { color: var(--accent); text-decoration: none; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--sombra);
}
.card + .card, .card + .tabela-wrap, .tabela-wrap + .card { margin-top: 16px; }
.card h2 { font-size: 14.5px; font-weight: 600; color: var(--fg); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.stat .rotulo { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .valor {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.stat .detalhe { font-size: 12px; color: var(--faint); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- Tabelas ---- */
.tabela-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--sombra);
}
.card .tabela-wrap { box-shadow: none; }
table.tabela { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabela th {
  text-align: left;
  padding: 11px 14px;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tabela th a { color: inherit; }
.tabela th a:hover { color: var(--accent); text-decoration: none; }
.tabela td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr { transition: background 120ms var(--ease); }
.tabela tbody tr:hover { background: #f8fafd; }
/* Licitação com lance já registrado: linha pintada + barra à esquerda. */
.tabela tbody tr.tem-lance { background: #f6f3ff; }
.tabela tbody tr.tem-lance:hover { background: #efe9ff; }
.tabela tbody tr.tem-lance td:first-child { box-shadow: inset 3px 0 0 #6d28d9; }
.tabela .num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabela .objeto a { color: var(--fg); font-weight: 500; }
.tabela .objeto a:hover { color: var(--accent); }
.tabela .secundario { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Coluna com a ficha cadastral do órgão (CNPJ, endereço) + botão de copiar. */
.cel-orgao { min-width: 210px; max-width: 260px; }
.btn-copiar {
  margin-top: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--muted);
  background: var(--card, #fff);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-copiar:hover { color: var(--accent); border-color: var(--accent); }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-aberta { background: var(--ok-soft); color: var(--ok); border-color: #bbe5c8; }
.badge-encerrada { background: #f1f5f9; color: var(--muted); border-color: var(--border); }
.badge-fonte { background: var(--accent-soft); color: var(--accent); border-color: #d5e3fb; }
.badge-erro { background: var(--err-soft); color: var(--err); border-color: #f5c6c6; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #f2dfb3; }
.badge-tag { background: #f1f5f9; color: var(--fg-2); border-color: var(--border); font-weight: 500; }
.badge-lance { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.tag-link { display: inline-block; margin: 0 4px 4px 0; }
.tag-link:hover { text-decoration: none; }
.tag-link:hover .badge-tag { background: var(--accent-soft); color: var(--accent); border-color: #d5e3fb; }

.score {
  font-family: var(--mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
}
.score-alto { background: var(--ok-soft); color: var(--ok); }
.score-medio { background: var(--warn-soft); color: var(--warn); }
.score-baixo { background: #f1f5f9; color: var(--muted); }

/* ---- Formulários / filtros ---- */

.filtros .campo { display: flex; flex-direction: column; gap: 4px; }
.campo label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

input[type="text"], input[type="date"], input[type="number"], input[type="password"], select, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-height: 38px;
  width: 100%;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' 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;
  padding-right: 30px;
  white-space: nowrap;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: var(--anel);
  border-color: var(--accent);
}
input[type="file"] { font: inherit; font-size: 13px; }
textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms cubic-bezier(0.25, 1, 0.5, 1);
}
.btn:hover { background: #f1f5f9; text-decoration: none; border-color: #d5dde8; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(30, 64, 175, 0.25); }
.btn-primario:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ia { background: var(--ia); border-color: var(--ia); color: #fff; box-shadow: 0 1px 2px rgba(109, 40, 217, 0.25); }
.btn-ia:hover { background: #5b21b6; border-color: #5b21b6; }
.btn-fantasma { background: none; border-color: transparent; color: var(--muted); }
.btn-fantasma:hover { background: var(--surface-2); color: var(--fg); }
.btn-mini { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }

/* ---- Paginação ---- */
.paginacao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}
.paginacao .paginas { display: flex; gap: 4px; }
.paginacao a, .paginacao span.atual {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.paginacao span.atual { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.paginacao a:hover { background: #f1f5f9; text-decoration: none; }

/* ---- Mensagens ---- */
.mensagens { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.mensagem {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
}
.mensagem.success { background: var(--ok-soft); border-color: #bbe5c8; color: var(--ok); }
.mensagem.warning { background: var(--warn-soft); border-color: #f2dfb3; color: var(--warn); }
.mensagem.error { background: var(--err-soft); border-color: #f5c6c6; color: var(--err); }

/* ---- Login ---- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.login-card .marca { justify-content: center; margin-bottom: 24px; font-size: 17px; }
.login-card .campo { margin-bottom: 16px; display: flex; flex-direction: column; gap: 4px; }
.login-card .btn { width: 100%; justify-content: center; }
.login-erro { color: var(--err); font-size: 13px; margin-bottom: 12px; }

/* ---- Detalhe ---- */
.def-lista { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.def-lista .def dt { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.def-lista .def dd { margin-top: 2px; font-size: 13px; }
.def-lista .def dd.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.objeto-completo { font-size: 14px; line-height: 1.6; color: var(--fg-2); }

.acoes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.ia-box { border-left: 3px solid var(--accent); padding: 12px 16px; background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.ia-box .ia-cabecalho { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-weight: 600; font-size: 12px; color: var(--accent); }

/* ---- Barras (dashboard) ---- */
.barras { display: flex; flex-direction: column; gap: 8px; }
.barra-linha { display: grid; grid-template-columns: 44px 1fr 56px; align-items: center; gap: 8px; font-size: 12px; }
.barra-linha .rotulo { font-weight: 600; color: var(--fg-2); }
.barra-trilha { background: var(--border-subtle); border-radius: 999px; height: 8px; overflow: hidden; }
.barra-preenchida { background: var(--accent); opacity: 0.75; height: 100%; border-radius: 999px; }
.barra-linha .qtd { font-family: var(--mono); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Checkbox chips (perfil) ----
   Django 5 renderiza CheckboxSelectMultiple como <div><div><label>...;
   os seletores cobrem também ul/li para listas escritas à mão. */
.chips > div, .chips ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.chips > div > div, .chips li { display: inline-flex; }
.chips label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-2);
  cursor: pointer;
  background: var(--surface);
}
.chips label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chips input { accent-color: var(--accent); }

.form-linhas { display: flex; flex-direction: column; gap: 20px; max-width: 720px; }
.form-linhas .campo-bloco > label, .form-linhas .campo-bloco > .rotulo {
  display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px;
}
.ajuda { font-size: 12px; color: var(--faint); margin-top: 4px; }
.erro-campo { color: var(--err); font-size: 12px; margin-top: 4px; }

/* ---- Favoritas ---- */
.btn-fav {
  font: inherit;
  font-size: 16px;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--faint);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: color 150ms cubic-bezier(0.25, 1, 0.5, 1);
}
.btn-fav:hover { color: #d97706; }
.btn-fav.ativa { color: #d97706; }
.btn.fav-ativa { color: #b45309; border-color: #f2dfb3; background: var(--warn-soft); }

/* ---- Oportunidade no Google (flag + modal do ID) ---- */
.btn-op {
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--faint);
  cursor: pointer;
  padding: 3px 8px;
  transition: color 150ms cubic-bezier(0.25, 1, 0.5, 1);
}
.btn-op:hover { color: var(--accent); border-color: var(--accent); }
.btn-op.ativa {
  font-family: var(--mono);
  border-style: solid;
  background: var(--ok-soft);
  border-color: #bbe5c8;
  color: var(--ok);
}
.badge-oportunidade { background: var(--ok-soft); color: var(--ok); border-color: #bbe5c8; }

/* ---- Observações da licitação ---- */
.acoes-celula { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.btn-nota {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  filter: grayscale(1);
  opacity: 0.45;
  transition: opacity 150ms cubic-bezier(0.25, 1, 0.5, 1);
}
.btn-nota:hover { opacity: 1; }
.btn-nota.ativa { filter: none; opacity: 1; }
.nota-lista {
  margin-top: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  white-space: pre-line;
}
.btn-perigo { color: var(--err); border-color: #f5c6c6; background: var(--err-soft); }
.btn-perigo:hover { background: #fde8e8; }

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}
.modal::backdrop { background: rgba(15, 23, 42, 0.45); }
.modal-corpo { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-corpo h2 { font-size: 14px; font-weight: 600; color: var(--fg); }
.modal-objeto { font-size: 12px; line-height: 1.45; }
.modal-acoes { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.modal-espaco { flex: 1; }
.modal-largo { width: min(620px, calc(100vw - 32px)); }
.modal textarea { font-size: 13px; line-height: 1.5; }

/* ---- Descrição expandível de itens (sem JS) ---- */
.desc-item summary {
  cursor: pointer;
  list-style: none;
}
.desc-item summary::-webkit-details-marker { display: none; }
.desc-item .desc-completa { display: none; }
.desc-item[open] .desc-curta { display: none; }
.desc-item[open] .desc-completa { display: inline; white-space: pre-line; }
.desc-item summary::after {
  content: " expandir";
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}
.desc-item[open] summary::after { content: " recolher"; }

.vazio { padding: 32px; text-align: center; color: var(--faint); font-size: 13px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.texto-muted { color: var(--muted); }

/* ---- Mercado: sub-abas de família de produto ---- */
.subnav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.subnav a {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav a:hover { color: var(--fg-2); text-decoration: none; }
.subnav a.ativo { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Mercado: barra proporcional dentro da célula da tabela (BI sem JS) ---- */
.barra { display: flex; align-items: center; gap: 8px; }
.barra .trilho {
  flex: 1;
  min-width: 60px;
  height: 6px;
  background: var(--border-subtle);
  border-radius: 3px;
  overflow: hidden;
}
.barra .preenchida { height: 100%; background: var(--accent); border-radius: 3px; }
.barra .preenchida.ok { background: var(--ok); }
.barra .preenchida.warn { background: #d97706; }
.barra .rotulo {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---- Mercado: caixa de leitura ("o que estes números dizem") ---- */
.leitura {
  background: var(--accent-soft);
  border: 1px solid #d5e3fb;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg-2);
}
.leitura strong { color: var(--fg); }
.leitura + .leitura { margin-top: 12px; }
.leitura.alerta { background: var(--warn-soft); border-color: #f2dfb3; }

/* ---- Mercado: página em largura cheia (sem o teto de 1280px) ---- */
.conteudo.largo { max-width: none; }

/* ---- Mercado: tabelas com dado centralizado na coluna ----
   O texto corrido (descrição expandida e as caixas de leitura) continua à
   esquerda: parágrafo centralizado não se lê. */
.tabela.centrada th,
.tabela.centrada td { text-align: center; vertical-align: middle; }
.tabela.centrada .barra { justify-content: center; }
.tabela.centrada .desc-item summary { text-align: center; }
.tabela.centrada .desc-item[open] .desc-completa { display: block; text-align: left; }
.grid-stats.centrada .card { text-align: center; }

/* =====================================================================
   v2 — componentes novos
   ===================================================================== */

/* ---- Cabeçalho da licitação (detalhe) ---- */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--sombra);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.hero-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.hero h1 { font-size: 19px; font-weight: 600; line-height: 1.4; letter-spacing: -0.015em; color: var(--fg); }
.hero .hero-orgao { margin-top: 6px; color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fatos {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px; background: var(--border-subtle);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  overflow: hidden; margin-top: 16px;
}
.fato { background: var(--surface); padding: 10px 14px; }
.fato .rotulo { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.fato .valor { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.fato .valor.urgente { color: var(--err); }
.hero-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.hero-acoes form { display: contents; }
.hero-acoes .separador { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }

.layout-detalhe { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.layout-detalhe > * + * { margin-top: 0; }
.coluna { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.coluna > .card + .card, .coluna > .card + .tabela-wrap, .coluna > .tabela-wrap + .card { margin-top: 0; }
@media (max-width: 1100px) { .layout-detalhe { grid-template-columns: 1fr; } }

/* Cartão que chama para o assistente de IA */
.card-ia {
  border-color: var(--ia-border);
  background: linear-gradient(180deg, var(--ia-soft), var(--surface) 70%);
}
.card-ia h2 { color: var(--ia); }
.card-ia p { font-size: 13.5px; color: var(--fg-2); }
.card-ia .btn { width: 100%; margin-top: 12px; }
.card-ia ul.conversas { list-style: none; margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.card-ia ul.conversas a { font-size: 13px; }

.secao-titulo { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 8px 0 -4px; }

/* ---- Painel: próximos passos ---- */
.passos { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.passo {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; color: var(--fg); box-shadow: var(--sombra);
  transition: border-color 150ms var(--ease), transform 150ms var(--ease);
}
.passo:hover { border-color: var(--accent-border); text-decoration: none; transform: translateY(-1px); }
.passo .passo-ico {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.passo.ia .passo-ico { background: var(--ia-soft); color: var(--ia); }
.passo strong { display: block; font-size: 14px; }
.passo span.desc { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }

/* ---- Filtros recolhíveis ---- */
.mais-filtros { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.mais-filtros > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent);
  list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
}
.mais-filtros > summary::-webkit-details-marker { display: none; }
.mais-filtros > summary::before { content: "+"; font-family: var(--mono); }
.mais-filtros[open] > summary::before { content: "−"; }
.mais-filtros[open] > .filtros { margin-top: 10px; }

/* ---- Assistente: lista ---- */
.assistente-topo { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 960px) { .assistente-topo { grid-template-columns: 1fr; } }
.zona-upload {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed var(--ia-border); border-radius: var(--radius); background: var(--ia-soft);
  padding: 22px; text-align: center; cursor: pointer; color: var(--fg-2);
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
}
.zona-upload:hover, .zona-upload.arrastando { border-color: var(--ia); background: #efe9ff; }
.zona-upload .ico { color: var(--ia); }
.zona-upload strong { font-size: 14px; }
.zona-upload small { color: var(--muted); font-size: 12.5px; }
.zona-upload input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.zona-upload .arquivos-escolhidos { font-size: 12.5px; color: var(--ia); font-weight: 600; }
.lista-passos { list-style: none; counter-reset: passo; display: flex; flex-direction: column; gap: 10px; }
.lista-passos li { counter-increment: passo; display: flex; gap: 10px; font-size: 13.5px; color: var(--fg-2); }
.lista-passos li::before {
  content: counter(passo); flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ia-soft); color: var(--ia); font-weight: 700; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---- Assistente: conversa ---- */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .chat-layout { grid-template-columns: 1fr; } }
.chat {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--sombra);
  height: calc(100vh - 150px); min-height: 520px;
}
@media (max-width: 960px) { .chat { height: calc(100vh - 120px); } }
.chat-cabecalho {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle); font-size: 13px; color: var(--muted);
}
.chat-cabecalho .rotulo-ia {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ia);
  background: var(--ia-soft); border: 1px solid var(--ia-border); border-radius: 999px; padding: 2px 10px; font-size: 12px;
}
.chat-cabecalho .custo { margin-left: auto; font-family: var(--mono); font-size: 12px; }
.chat-mensagens { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; scroll-behavior: smooth; }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg .quem {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.msg.ia .quem { background: var(--ia-soft); color: var(--ia); border: 1px solid var(--ia-border); }
.msg.voce { flex-direction: row-reverse; }
.msg.voce .quem { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); }
.msg .balao { min-width: 0; font-size: 14px; line-height: 1.6; color: var(--fg); }
.msg.voce .balao {
  background: var(--accent); color: #fff; padding: 9px 14px; border-radius: 14px 14px 4px 14px;
  max-width: 78%; white-space: pre-wrap;
}
.msg.ia .balao { flex: 1; padding-top: 4px; }
.msg-acoes { display: flex; gap: 4px; margin-top: 6px; }
.msg-acoes button {
  font: inherit; font-size: 12px; color: var(--muted); background: none; border: 1px solid transparent;
  border-radius: 6px; padding: 3px 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 28px;
}
.msg-acoes button:hover { background: var(--surface-2); border-color: var(--border); color: var(--fg); }
.digitando { display: inline-flex; gap: 4px; padding: 8px 0; }
.digitando i { width: 7px; height: 7px; border-radius: 50%; background: var(--ia); opacity: 0.35; animation: pulso 1.2s infinite var(--ease); }
.digitando i:nth-child(2) { animation-delay: 0.15s; }
.digitando i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulso { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.chat-vazio { margin: auto; max-width: 560px; text-align: center; padding: 12px; }
.chat-vazio .ico-grande {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center; background: var(--ia-soft); color: var(--ia);
}
.chat-vazio h2 { font-size: 17px; font-weight: 600; }
.chat-vazio p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.sugestoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: 16px; text-align: left; }
.sugestao {
  font: inherit; font-size: 13px; text-align: left; line-height: 1.4; color: var(--fg-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: pointer; min-height: 44px;
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
}
.sugestao:hover { border-color: var(--ia); background: var(--ia-soft); color: var(--fg); }
.sugestao strong { display: block; color: var(--fg); font-size: 13px; margin-bottom: 1px; }
.chips-sugestao { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 8px; }
.chips-sugestao button {
  font: inherit; font-size: 12px; color: var(--fg-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; cursor: pointer; min-height: 30px;
}
.chips-sugestao button:hover { border-color: var(--ia); color: var(--ia); background: var(--ia-soft); }

.chat-composer { border-top: 1px solid var(--border-subtle); padding: 12px 16px 14px; }
.chat-composer form { display: flex; gap: 8px; align-items: flex-end; }
.chat-composer textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 200px; line-height: 1.5; font-size: 14px;
  border-radius: 12px; padding: 11px 14px;
}
.chat-composer .btn { min-height: 44px; border-radius: 12px; }
.chat-composer .dica { font-size: 11.5px; color: var(--faint); margin-top: 6px; }

.chat-lateral { display: flex; flex-direction: column; gap: 16px; }
.chat-lateral .card { padding: 16px; }
.chat-lateral h2 { font-size: 13.5px; }
.lista-fontes { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.lista-fontes li { display: flex; gap: 8px; align-items: flex-start; color: var(--fg-2); word-break: break-word; }
.lista-fontes .ico { color: var(--muted); margin-top: 2px; }
.mini-itens { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--fg-2); max-height: 280px; overflow-y: auto; }
.mini-itens li { border-left: 2px solid var(--border); padding-left: 8px; }
.mini-itens .mono { color: var(--muted); }

/* ---- Markdown das respostas da IA ---- */
.md > * + * { margin-top: 10px; }
.md h1, .md h2, .md h3, .md h4 { font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; margin-top: 16px; }
.md h1 { font-size: 17px; } .md h2 { font-size: 16px; } .md h3 { font-size: 15px; } .md h4 { font-size: 14px; }
.md > :first-child { margin-top: 0; }
.md ul, .md ol { padding-left: 22px; }
.md li + li { margin-top: 3px; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border-subtle); border-radius: 4px; padding: 0 4px; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; }
.md pre code { border: none; padding: 0; background: none; }
.md blockquote { border-left: 3px solid var(--ia-border); padding: 2px 12px; color: var(--fg-2); background: var(--ia-soft); border-radius: 0 6px 6px 0; }
.md hr { border: none; border-top: 1px solid var(--border); }
.md .md-tabela { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; }
.md th { background: var(--surface-2); text-align: left; font-weight: 600; }
.md th, .md td { padding: 7px 10px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.md tr:last-child td { border-bottom: none; }

.base-editor { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; min-height: 520px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 900px) {
  .filtros > .campo { grid-column: 1 / -1 !important; }
  .hero-acoes .separador { display: none; }
}

/* Cartões dentro de grades não herdam o espaçamento vertical de .card + .card */
.grid-stats > .card, .grid-2 > .card, .assistente-topo > .card { margin-top: 0 !important; }

/* =====================================================================
   Grid de 12 colunas (mesma API do Vuetify): <div class="v-row">
     <div class="v-col-12 v-col-md-6 v-col-lg-3">…
   Sem classe de coluna = linha inteira. Breakpoints: sm 600, md 960, lg 1280, xl 1920.
   ===================================================================== */
.v-row, .filtros {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.v-row.denso, .filtros { gap: 14px 16px; }
.v-row.esticar { align-items: stretch; }
.v-row.centro { align-items: center; }
.v-row > * { grid-column: span 12; min-width: 0; }
.v-row + .v-row, .v-row + .card, .card + .v-row, .v-row + .tabela-wrap, .tabela-wrap + .v-row { margin-top: 20px; }
.v-row > .card + .card, .v-row > .card + .tabela-wrap { margin-top: 0; }

.v-row > .v-col-1 { grid-column: span 1; }
.v-row > .v-col-2 { grid-column: span 2; }
.v-row > .v-col-3 { grid-column: span 3; }
.v-row > .v-col-4 { grid-column: span 4; }
.v-row > .v-col-5 { grid-column: span 5; }
.v-row > .v-col-6 { grid-column: span 6; }
.v-row > .v-col-7 { grid-column: span 7; }
.v-row > .v-col-8 { grid-column: span 8; }
.v-row > .v-col-9 { grid-column: span 9; }
.v-row > .v-col-10 { grid-column: span 10; }
.v-row > .v-col-11 { grid-column: span 11; }
.v-row > .v-col-12 { grid-column: span 12; }
@media (min-width: 600px) {
  .v-row > .v-col-sm-1 { grid-column: span 1; }
  .v-row > .v-col-sm-2 { grid-column: span 2; }
  .v-row > .v-col-sm-3 { grid-column: span 3; }
  .v-row > .v-col-sm-4 { grid-column: span 4; }
  .v-row > .v-col-sm-5 { grid-column: span 5; }
  .v-row > .v-col-sm-6 { grid-column: span 6; }
  .v-row > .v-col-sm-7 { grid-column: span 7; }
  .v-row > .v-col-sm-8 { grid-column: span 8; }
  .v-row > .v-col-sm-9 { grid-column: span 9; }
  .v-row > .v-col-sm-10 { grid-column: span 10; }
  .v-row > .v-col-sm-11 { grid-column: span 11; }
  .v-row > .v-col-sm-12 { grid-column: span 12; }
}
@media (min-width: 960px) {
  .v-row > .v-col-md-1 { grid-column: span 1; }
  .v-row > .v-col-md-2 { grid-column: span 2; }
  .v-row > .v-col-md-3 { grid-column: span 3; }
  .v-row > .v-col-md-4 { grid-column: span 4; }
  .v-row > .v-col-md-5 { grid-column: span 5; }
  .v-row > .v-col-md-6 { grid-column: span 6; }
  .v-row > .v-col-md-7 { grid-column: span 7; }
  .v-row > .v-col-md-8 { grid-column: span 8; }
  .v-row > .v-col-md-9 { grid-column: span 9; }
  .v-row > .v-col-md-10 { grid-column: span 10; }
  .v-row > .v-col-md-11 { grid-column: span 11; }
  .v-row > .v-col-md-12 { grid-column: span 12; }
}
@media (min-width: 1280px) {
  .v-row > .v-col-lg-1 { grid-column: span 1; }
  .v-row > .v-col-lg-2 { grid-column: span 2; }
  .v-row > .v-col-lg-3 { grid-column: span 3; }
  .v-row > .v-col-lg-4 { grid-column: span 4; }
  .v-row > .v-col-lg-5 { grid-column: span 5; }
  .v-row > .v-col-lg-6 { grid-column: span 6; }
  .v-row > .v-col-lg-7 { grid-column: span 7; }
  .v-row > .v-col-lg-8 { grid-column: span 8; }
  .v-row > .v-col-lg-9 { grid-column: span 9; }
  .v-row > .v-col-lg-10 { grid-column: span 10; }
  .v-row > .v-col-lg-11 { grid-column: span 11; }
  .v-row > .v-col-lg-12 { grid-column: span 12; }
}
@media (min-width: 1920px) {
  .v-row > .v-col-xl-1 { grid-column: span 1; }
  .v-row > .v-col-xl-2 { grid-column: span 2; }
  .v-row > .v-col-xl-3 { grid-column: span 3; }
  .v-row > .v-col-xl-4 { grid-column: span 4; }
  .v-row > .v-col-xl-5 { grid-column: span 5; }
  .v-row > .v-col-xl-6 { grid-column: span 6; }
  .v-row > .v-col-xl-7 { grid-column: span 7; }
  .v-row > .v-col-xl-8 { grid-column: span 8; }
  .v-row > .v-col-xl-9 { grid-column: span 9; }
  .v-row > .v-col-xl-10 { grid-column: span 10; }
  .v-row > .v-col-xl-11 { grid-column: span 11; }
  .v-row > .v-col-xl-12 { grid-column: span 12; }
}

/* Formulários antigos: .filtros usa style="grid-column: span N" — no celular vira linha inteira */
@media (max-width: 959px) { .filtros > .campo, .filtros > * { grid-column: 1 / -1 !important; } }


/* =====================================================================
   Centralização (v2.1)
   ===================================================================== */
.conteudo { margin-inline: auto; width: 100%; max-width: 1600px; }
.conteudo.largo { max-width: 1840px; }

/* Cabeçalho da página centralizado: título, subtítulo e ações empilhados */
.cabecalho {
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 12px; margin-bottom: 28px;
}
.cabecalho > div:first-child { display: flex; flex-direction: column; align-items: center; }
.cabecalho h1 { font-size: 26px; }
.cabecalho .sub { margin-inline: auto; }
.cabecalho-acoes, .cabecalho > .acoes, .cabecalho > div:not(:first-child) { justify-content: center; }
.migalha { display: flex; width: fit-content; }

/* Números e atalhos */
.grid-stats { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.grid-stats > * { grid-column: span 12; }
@media (min-width: 600px) { .grid-stats > * { grid-column: span 6; } }
@media (min-width: 1280px) { .grid-stats > * { grid-column: span 3; } }
.stat { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 118px; }
.stat .valor { font-size: 30px; }
.grid-2 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.grid-2 > * { grid-column: span 12; }
@media (min-width: 960px) { .grid-2 > * { grid-column: span 6; } }

.passos { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.passos > * { grid-column: span 12; }
@media (min-width: 600px) { .passos > * { grid-column: span 6; } }
@media (min-width: 1280px) { .passos > * { grid-column: span 3; } }
.passo { flex-direction: column; align-items: center; text-align: center; padding: 22px 18px; gap: 10px; }
.passo .passo-ico { width: 46px; height: 46px; border-radius: 12px; }

.vazio { text-align: center; }
.card > h2 { justify-content: flex-start; }
.card.centro, .card.centro h2 { text-align: center; justify-content: center; }
.acoes.centro { justify-content: center; }

/* Tabelas: dados centralizados na coluna; colunas de texto corrido à esquerda.
   Coluna de texto = célula .objeto/.texto, com max-width inline, com linha
   secundária ou <details>; o cabeçalho da mesma coluna acompanha via :has(). */
.tabela th, .tabela td { text-align: center; vertical-align: middle; }
.tabela td.objeto, .tabela td.texto, .tabela td[style*="max-width"],
.tabela td:has(> .secundario), .tabela td:has(> details), .tabela td:has(> .nota-lista) { text-align: left; }
.tabela td .acoes-celula { margin: 0 auto; }
.tabela td > .acoes, .tabela td > form { justify-content: center; }
.tabela:has(tbody tr > td:nth-child(1):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(1) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(2):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(2) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(3):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(3) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(4):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(4) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(5):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(5) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(6):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(6) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(7):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(7) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(8):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(8) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(9):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(9) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(10):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(10) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(11):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(11) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(12):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(12) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(13):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(13) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(14):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(14) { text-align: left; }
.tabela:has(tbody tr > td:nth-child(15):is(.objeto, .texto, [style*="max-width"], :has(> .secundario), :has(> details), :has(> .nota-lista))) th:nth-child(15) { text-align: left; }

/* Campos de formulário que ficaram sem estilo */
input[type="email"], input[type="url"], input[type="tel"], input[type="search"], input[type="datetime-local"], input[type="time"], input[type="month"] {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 11px; min-height: 38px; width: 100%;
}
.form-linhas { max-width: none; }

/* =====================================================================
   Responsivo (celular / tablet)
   ===================================================================== */
@media (max-width: 759px) {
  .tabela-wrap { overflow: visible; background: none; border: none; box-shadow: none; }
  .card .tabela-wrap { margin: 0 -4px; }
  table.tabela.responsiva, .tabela.responsiva tbody, .tabela.responsiva tr, .tabela.responsiva td { display: block; width: 100%; }
  .tabela.responsiva thead { display: none; }
  .tabela.responsiva tbody tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--sombra); padding: 6px 14px; margin-bottom: 12px;
  }
  .tabela.responsiva tbody tr:hover { background: var(--surface); }
  .tabela.responsiva td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    text-align: right !important; padding: 9px 0 !important;
    border-bottom: 1px solid var(--border-subtle);
    min-width: 0 !important; max-width: none !important;
  }
  .tabela.responsiva td:last-child { border-bottom: none; }
  .tabela.responsiva td::before {
    content: attr(data-label); flex-shrink: 0; max-width: 45%;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--muted); text-align: left; padding-top: 2px;
  }
  .tabela.responsiva td[data-label=""]::before { display: none; }
  .tabela.responsiva td[data-label=""] { justify-content: center; }
  /* texto corrido (objeto, descrição): rótulo em cima, texto embaixo, à esquerda */
  .tabela.responsiva td.objeto, .tabela.responsiva td.texto, .tabela.responsiva td[style*="max-width"],
  .tabela.responsiva td:has(> .secundario), .tabela.responsiva td:has(> details) {
    flex-direction: column; align-items: stretch; text-align: left !important;
  }
  .tabela.responsiva td.objeto::before, .tabela.responsiva td.texto::before { max-width: none; }
  .tabela.responsiva td.objeto a { font-size: 14.5px; }
  .tabela.responsiva td .acoes-celula { flex-direction: row; margin: 0; gap: 10px; }
  .tabela.responsiva tr.tem-lance td:first-child { box-shadow: none; }
  .tabela.responsiva tr.tem-lance { border-left: 3px solid #6d28d9; }

  .cabecalho h1 { font-size: 21px; }
  .card { padding: 16px; }
  .hero { padding: 16px; }
  .hero h1 { font-size: 16.5px; }
  .hero-acoes .btn { flex: 1 1 calc(50% - 8px); }
  .hero-acoes form { display: flex; flex: 1 1 calc(50% - 8px); }
  .hero-acoes form .btn { flex: 1; }
  .fato .valor { font-size: 14px; }
  .stat { min-height: 96px; }
  .stat .valor { font-size: 24px; }
  .cabecalho-acoes { width: 100%; }
  .cabecalho-acoes .btn { flex: 1; }
  .paginacao { flex-direction: column; }
  .paginacao .paginas { flex-wrap: wrap; justify-content: center; }
  .subnav { overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .chat { height: calc(100dvh - 110px); min-height: 440px; border-radius: 0; margin: 0 -16px; border-left: none; border-right: none; }
  .chat-mensagens { padding: 14px; }
  .msg.voce .balao { max-width: 88%; }
  .chips-sugestao { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips-sugestao button { flex-shrink: 0; }
  .sugestoes { grid-template-columns: 1fr; }
  .chat-composer .btn span { display: none; }
  .modal { width: calc(100vw - 24px); }
  .mensagens .mensagem { font-size: 13.5px; }
}
@media (max-width: 959px) {
  .passo { flex-direction: row; text-align: left; align-items: center; padding: 14px 16px; }
}
/* inputs com 16px no celular: evita o zoom automático do iOS ao focar */
@media (max-width: 759px) {
  input, select, textarea { font-size: 16px !important; }
}

/* Tabelas repetidas por grupo (Documentos): mesma largura de coluna em todos os grupos */
@media (min-width: 760px) {
  .tabela-fixa { table-layout: fixed; }
  .tabela-fixa th.col-nome { width: 44%; }
}
@media (max-width: 759px) {
  #ia-card { flex-direction: column; align-items: stretch !important; text-align: center; }
  #ia-card .btn { width: 100%; white-space: normal; }
}

/* Botões de remover (lixeira) e ações por linha */
.btn-remover {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer;
  background: none; border: 1px solid transparent; color: var(--faint);
  transition: color 150ms var(--ease), background 150ms var(--ease), border-color 150ms var(--ease);
}
.btn-remover:hover { color: var(--err); background: var(--err-soft); border-color: #f5c6c6; }
.btn-remover:disabled { opacity: 0.4; cursor: wait; }
.acoes-linha { display: inline-flex; align-items: center; gap: 4px; }
.acoes-linha form { display: inline-flex; }
.tabela tbody tr.saindo { opacity: 0; transform: translateX(12px); transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
@media (max-width: 759px) {
  html, body { overflow-x: clip; }
  .tabela.responsiva td .acoes-linha { gap: 10px; }
  .btn-remover, .acoes-linha .btn-icone { width: 40px; height: 40px; border-color: var(--border); }
}

/* ---- Fila de tarefas (canto inferior direito) ---- */
.fila {
  position: fixed; right: 20px; top: 20px; z-index: 80;
  width: min(380px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 8px;
}
.fila[hidden] { display: none; }
.fila-ativas:empty, .fila-avisos:empty { display: none; }
.fila-ativas {
  background: var(--fg); color: #fff; border-radius: var(--radius);
  box-shadow: var(--sombra-alta); padding: 10px 14px; display: flex; flex-direction: column; gap: 6px;
}
.fila-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.fila-spin {
  width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #fff;
  animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
.fila-avisos { display: flex; flex-direction: column; gap: 8px; }
.fila-aviso {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--ok);
  border-radius: var(--radius); box-shadow: var(--sombra-alta); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 3px; font-size: 13px;
}
.fila-aviso.erro { border-left-color: var(--err); }
.fila-aviso strong { color: var(--fg); }
.fila-aviso span { color: var(--fg-2); }
.fila-aviso-acoes { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.tarefa-banner {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent-border); color: var(--accent);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px; font-weight: 500;
}
.tarefa-banner .fila-spin { border-color: rgba(30, 64, 175, 0.2); border-top-color: var(--accent); }
@media (max-width: 759px) { .fila { right: 12px; left: 12px; top: 64px; width: auto; } }

/* ---- Habilidades da IA ---- */
.habilidade-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  height: 100%; color: var(--fg); padding: 24px 20px;
  transition: border-color 150ms var(--ease), transform 150ms var(--ease);
}
.habilidade-card:hover { border-color: var(--ia-border); text-decoration: none; transform: translateY(-1px); }
.habilidade-card.inativa { opacity: 0.6; }
.habilidade-ico {
  width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ia-soft); color: var(--ia);
}
.habilidade-card strong { font-size: 15px; }
.habilidade-card .desc { font-size: 13px; color: var(--muted); }
.habilidade-selos { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 4px; }

.seletor-habilidade {
  display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto; scrollbar-width: none; align-items: center;
}
.seletor-habilidade .rotulo-sel { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); flex-shrink: 0; margin-right: 2px; }
.seletor-habilidade button {
  font: inherit; font-size: 12.5px; font-weight: 500; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--fg-2); border: 1px solid var(--border);
  transition: all 150ms var(--ease);
}
.seletor-habilidade button:hover { border-color: var(--ia); color: var(--ia); }
.seletor-habilidade button[aria-pressed="true"] { background: var(--ia); border-color: var(--ia); color: #fff; }
.seletor-habilidade a { margin-left: auto; font-size: 12px; flex-shrink: 0; }
.msg .rotulo-hab {
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px;
  font-size: 11px; font-weight: 600; color: var(--ia); background: var(--ia-soft);
  border: 1px solid var(--ia-border); border-radius: 999px; padding: 0 8px;
}
/* itens de grade não podem crescer pelo conteúdo (seletor/atalhos rolam por dentro) */
.chat-layout > *, .chat, .chat-mensagens, .msg .balao { min-width: 0; }
