/* Licita — design tokens (utilitário/dados: slate frio, acento azul, bordas) */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-subtle: #eef2f6;
  --fg: #0f172a;
  --fg-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --radius: 8px;
  --radius-sm: 6px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

.marca {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.marca .logo {
  width: 24px; height: 24px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: block;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  color: var(--fg-2);
  font-weight: 500;
}
.nav a:hover { background: #e9edf2; text-decoration: none; }
.nav a.ativo { background: #e4e9f0; color: var(--fg); }

.sessao {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sessao .usuario { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.conteudo { flex: 1; min-width: 0; padding: 24px 32px 48px; max-width: 1280px; }

.cabecalho { margin-bottom: 24px; }
.cabecalho h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.cabecalho .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card, .card + .tabela-wrap, .tabela-wrap + .card { margin-top: 16px; }
.card h2 { font-size: 13px; font-weight: 600; color: var(--fg-2); margin-bottom: 12px; }

.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: 24px;
  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;
}
table.tabela { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabela th {
  text-align: left;
  padding: 10px 12px;
  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: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr:hover { background: #fafbfc; }
.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; }

/* ---- 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; }

.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 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.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: 7px 10px;
  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: 2px solid rgba(29, 78, 216, 0.25);
  outline-offset: 0;
  border-color: var(--accent);
}
textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 500;
  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; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primario:hover { background: var(--accent-hover); }
.btn-mini { padding: 4px 10px; font-size: 12px; }

/* ---- 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); }

/* ---- 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); }
