:root {
  --bg: #0f0f0f;
  --surface: #171717;
  --border: #262626;
  --text: #fafafa;
  --muted: #8a8a8a;
  --red: #ef4444;
  --orange: #f97316;
  --purple: #a855f7;
  --yellow: #eab308;
  --blue: #3b82f6;
  --green: #22c55e;
}

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

/* Respeita usuários que pedem menos movimento (WCAG 2.3.3 / prefers-reduced-motion).
   Neutraliza animações e transições sem quebrar a leitura. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Pular para o conteúdo — visível só ao receber foco pelo teclado (WCAG 2.4.1). */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
  text-decoration: none;
  transition: top 0.15s;
}

.skip-link:focus {
  top: 0.5rem;
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ─── Header ─── */
header {
  padding: 1.5rem max(2rem, calc((100% - 1200px) / 2 + 2rem));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.municipio-selector {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  min-width: 220px;
}

/* ─── Auth area (header) ─── */
.auth-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 1rem;
  white-space: nowrap;
}
.auth-area .auth-user { color: var(--text); }
.auth-area .auth-cota {
  background: #18181b;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  color: var(--blue);
}
.auth-area .auth-cota.auth-admin { color: var(--green); }
.auth-area .auth-cota.auth-warn { color: var(--orange); border-color: var(--orange); }
.auth-area .auth-link {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: none;
}
.auth-area .auth-link:hover { border-color: var(--blue); color: var(--blue); }

.municipio-selector label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.municipio-selector select {
  width: 100%;
  max-width: 280px;
  background: #18181b;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}

.municipio-selector select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.municipio-coleta-hint {
  font-size: 0.7rem;
  color: #52525b;
  text-align: right;
  max-width: 280px;
}

/* ─── Nav tabs ─── */
#main-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 max(2rem, calc((100% - 1200px) / 2 + 2rem));
  overflow-x: auto;
  scrollbar-width: none;
}

#main-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s;
  margin-bottom: -1px;
}

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

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--red);
}

a.tab-btn {
  text-decoration: none;
  display: inline-block;
}

/* ─── Main content ─── */
main {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-section {
  display: none;
}

.tab-section.active {
  display: block;
}

/* ─── KPI cards ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* O painel principal tem 6 KPIs: grade 3×2 no desktop fecha certo, sem o 6º
   card órfão que o auto-fit (5+1) deixava. Tablet/mobile herdam os overrides
   de .kpi-grid. Não afeta #orgaos-cards / #empenhos-resumo-cards (contagem
   variável, seguem no auto-fit). */
@media (min-width: 769px) {
  #kpi-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

/* Realce por borda completa tênue, não por faixa lateral (side-stripe). */
.kpi-card.highlight {
  border-color: rgba(239, 68, 68, 0.45);
}

.kpi-card.kpi-clickable {
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}

.kpi-card.kpi-clickable:hover {
  background: #1a2235;
  border-color: var(--blue);
  transform: translateY(-1px);
}

.kpi-card.kpi-clickable:active {
  transform: translateY(0);
}

.kpi-value {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.kpi-hint {
  font-size: 0.75rem;
  color: #525252;
  margin-top: 0.2rem;
}

/* ─── Charts ─── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.chart-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

/* ─── Filter bar ─── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="number"] {
  background: #171717;
  border: 1px solid #262626;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #fafafa;
  font-family: Inter, sans-serif;
  font-size: 0.875rem;
  min-width: 160px;
  outline: none;
  transition: border-color 0.2s;
}

.filter-bar select:focus,
.filter-bar input[type="text"]:focus,
.filter-bar input[type="number"]:focus {
  border-color: #ef4444;
}

#filter-fornecedor-ranking {
  background: #171717;
  border: 1px solid #262626;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #fafafa;
  font-family: Inter, sans-serif;
  font-size: 0.875rem;
  width: 100%;
  max-width: 360px;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s;
  display: block;
}

#filter-fornecedor-ranking:focus { border-color: #ef4444; }

/* ─── Tables ─── */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.alertas-wrap,
#alertas-table-wrap {
  overflow: visible;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.875rem;
  overflow: visible;
}

#orgaos-table {
  table-layout: fixed;
}
#orgaos-table th:first-child,
#orgaos-table td:first-child {
  min-width: 200px;
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

#alertas-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

#alertas-table tbody tr:hover td {
  background: #1c1c1c;
}

/* ─── Badges ─── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-red    { background: #ef444420; color: #ef4444; border: 1px solid #ef444440; }
.badge-orange { background: #f9731620; color: #f97316; border: 1px solid #f9731640; }
.badge-purple { background: #a855f720; color: #a855f7; border: 1px solid #a855f740; }
.badge-yellow { background: #eab30820; color: #eab308; border: 1px solid #eab30840; }
.badge-blue   { background: #3b82f620; color: #3b82f6; border: 1px solid #3b82f640; }
.badge-green  { background: #22c55e20; color: #22c55e; border: 1px solid #22c55e40; }
.badge-gray   { background: #6b728020; color: #9ca3af; border: 1px solid #6b728040; }

/* ─── Pagination ─── */
#pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.btn-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.875rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-page:hover:not(:disabled) {
  background: #222;
}

.btn-page:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ver-analise,
.btn-ver-detalhes {
  background: transparent;
  border: 1px solid #333;
  color: #a3a3a3;
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}
.btn-ver-analise:hover,
.btn-ver-detalhes:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* ─── Toggle groups ─── */
.toggle-group {
  display: flex;
  width: fit-content;
  border: 1px solid #262626;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.toggle-btn {
  background: #171717;
  border: none;
  color: #8a8a8a;
  padding: 0.4rem 1rem;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn.active {
  background: #262626;
  color: #fafafa;
}

/* ─── Timeline controls ─── */
.timeline-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.year-checkboxes {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.year-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.year-checkboxes input[type="checkbox"] {
  accent-color: var(--red);
  width: 14px;
  height: 14px;
}

/* ─── Detail panel ─── */
#detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  display: none;
}

#detail-backdrop.backdrop-open {
  display: block;
}

#detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  max-height: 100vh;
  width: 480px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 200;
  overflow-y: auto;
  padding: 1.5rem;
}

#detail-panel.panel-open {
  transform: translateX(0);
}

#detail-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: #262626;
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#detail-close:hover {
  background: #333;
}

#detail-content {
  margin-top: 1rem;
  overflow-x: auto;
}

#detail-content .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#detail-content table {
  min-width: 500px;
  width: 100%;
}

#detail-content td,
#detail-content th {
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
}

#detail-content td:first-child,
#detail-content th:first-child {
  white-space: normal;
  min-width: 160px;
  max-width: 220px;
}

.detail-fornecedor {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.75rem;
}

.detail-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.detail-valor {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.detail-field label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: block;
  margin-bottom: 0.2rem;
}

.detail-field p {
  font-size: 0.875rem;
  line-height: 1.4;
}

.detail-block {
  margin-bottom: 1rem;
}

.detail-block label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: block;
  margin-bottom: 0.35rem;
}

.detail-block p {
  font-size: 0.875rem;
  line-height: 1.6;
  color: #d4d4d4;
}

.narrativa-block {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.narrativa-block label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--red);
  display: block;
  margin-bottom: 0.5rem;
}

.narrativa-block p {
  font-size: 0.8rem;
  line-height: 1.7;
  color: #d4d4d4;
}

.veredito-ia-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.veredito-ia-block label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--blue);
  display: block;
  margin-bottom: 0.5rem;
}

.veredito-status-sugerido {
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.veredito-justificativa {
  font-size: 0.8rem;
  line-height: 1.6;
  color: #a3a3a3;
  margin-bottom: 0.75rem;
}

.btn-aplicar-veredito {
  padding: 0.45rem 0.875rem;
  background: #1e3a5f;
  border: 1px solid #2563eb;
  border-radius: 6px;
  color: #93c5fd;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-aplicar-veredito:hover:not(:disabled) {
  background: #1d4ed8;
  color: #fff;
}

.btn-aplicar-veredito:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Parecer único da IA (reformulação jul/2026) ── */
.parecer-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.parecer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.plaus-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
}
.plaus-pill.plaus-alerta {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
}
.plaus-pill.plaus-ok {
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
}
.plaus-pill.plaus-neutro {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.35);
}

.parecer-prov {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.parecer-analise {
  font-size: 0.83rem;
  line-height: 1.65;
  color: #d4d4d4;
  margin: 0;
}

.parecer-sug {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--border);
}

.parecer-sug-txt {
  font-size: 0.82rem;
  color: #e5e5e5;
}

.detail-link {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.4rem 0.875rem;
  background: #262626;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--blue);
  font-size: 0.8rem;
  text-decoration: none;
  transition: background 0.15s;
}

.detail-link:hover {
  background: #333;
}

/* ─── Fornecedores ─── */
.fornecedor-link {
  background: none;
  border: none;
  color: var(--blue);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.fornecedor-link:hover {
  color: #60a5fa;
}

/* ─── Sobre ─── */
.sobre-section {
  max-width: 720px;
}

.sobre-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.sobre-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: #d4d4d4;
}

.sobre-section p {
  color: #a3a3a3;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.sobre-section ul {
  list-style: none;
  padding: 0;
}

.sobre-section ul li {
  color: #a3a3a3;
  padding: 0.4rem 0 0.4rem 1rem;
  border-left: 2px solid var(--border);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.sobre-section a {
  color: var(--blue);
}

/* Pipeline visual */
.sobre-pipeline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1.25rem 0 1.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.sobre-pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 80px;
}

.sobre-pipeline-icon {
  font-size: 1.5rem;
}

.sobre-pipeline-label {
  font-size: 0.72rem;
  color: #9ca3af;
  text-align: center;
  font-weight: 500;
}

.sobre-pipeline-arrow {
  color: #4b5563;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* Detector cards */
.sobre-detectores {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}

.sobre-detector {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  padding: 1rem 1.1rem;
}

.sobre-detector-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.sobre-detector-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sobre-detector-code {
  font-size: 0.72rem;
  color: #60a5fa;
  background: rgba(37,99,235,.15);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  margin-left: auto;
  font-family: 'Courier New', monospace;
}

.sobre-detector p {
  margin-bottom: 0.5rem;
}

/* Formula block */
.sobre-formula {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sobre-formula-line {
  display: flex;
  gap: 0.75rem;
  font-size: 0.82rem;
  font-family: 'Courier New', monospace;
}

.sobre-formula-name {
  color: #60a5fa;
  min-width: 60px;
  font-weight: 700;
}

.sobre-formula-eq {
  color: #d4d4d4;
}

/* Severity table */
.sobre-severity-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.sobre-severity-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: #a3a3a3;
}

/* ─── Feedback states ─── */
.error-msg {
  color: var(--red);
  font-size: 0.875rem;
  padding: 1rem;
  background: #ef444410;
  border: 1px solid #ef444430;
  border-radius: 6px;
  margin: 0.5rem 0;
}

.loading-msg {
  color: var(--muted);
  font-size: 0.875rem;
  padding: 1.5rem;
  text-align: center;
}

/* ─── Grouped alertas table ─── */
.row-group {
  cursor: pointer;
  transition: background 0.1s;
}

.row-group:hover td {
  background: #1c1c1c;
}

.row-group.expanded td {
  background: #191919;
}

.row-detail {
  display: none;
}

.row-detail.visible {
  display: table-row;
}

.row-detail > td {
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.detail-inner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: start;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--border);
  margin-left: 2rem;
  background: #111;
}

.detail-objeto {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-meta {
  display: flex;
  gap: 1.5rem;
  align-items: start;
  flex-shrink: 0;
}

.detail-item {
  display: flex;
  flex-direction: column;
  min-width: 80px;
}

.detail-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.detail-value {
  font-size: 0.85rem;
  color: var(--text);
}

.detail-inner .detail-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
  padding-top: 1.2rem;
}

@media (max-width: 768px) {
  .detail-inner { grid-template-columns: 1fr; }
  .detail-inner .detail-actions { padding-top: 0; }
}

/* ─── Compact expanded rows ─── */
.detail-compact {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 1rem 0.45rem 1.25rem;
  border-left: 3px solid var(--border);
  background: #111;
  font-size: 0.83rem;
}

.detail-compact-status {
  flex-shrink: 0;
  min-width: 92px;
}

.detail-compact-valor {
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
  min-width: 90px;
}

/* Progresso de triagem no cabeçalho do grupo (N/M triados) */
.grupo-progresso {
  margin-top: 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.grupo-progresso.completo {
  color: var(--green);
}

.detail-compact-data {
  white-space: nowrap;
  color: var(--muted);
  min-width: 74px;
}

.detail-compact-objeto {
  flex: 1;
  color: #c4c4c4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-compact-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .detail-compact {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .detail-compact-objeto { min-width: 0; width: 100%; order: -1; }
}

.btn-pncp {
  display: inline-block;
  background: transparent;
  border: 1px solid #333;
  color: #a3a3a3;
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 0.8rem;
  transition: border-color 0.2s, color 0.2s;
}

.btn-pncp:hover { border-color: #3b82f6; color: #3b82f6; }

.btn-expand-obj {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
}
.btn-expand-obj:hover { text-decoration: underline; }

.expand-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 0.5rem;
  line-height: 1;
}

.expand-btn:hover {
  color: var(--text);
}

/* ─── Tooltips ─── */
.tooltip-wrap {
  position: relative;
  display: inline-block;
}

.tooltip-wrap .tooltip-text {
  visibility: hidden;
  background: #1a1a1a;
  color: #fafafa;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.75rem;
  line-height: 1.4;
  width: 260px;
  position: absolute;
  z-index: 9999;
  top: auto;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  font-weight: 400;
  white-space: normal;
}

.tooltip-wrap:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

.tooltip-wrap:first-child .tooltip-text,
.tooltip-wrap.tooltip-bottom .tooltip-text {
  bottom: auto;
  top: calc(100% + 8px);
}

/* ─── Download bar ─── */
.download-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 1rem;
  background: #171717;
  border: 1px solid #262626;
  border-radius: 8px;
  flex-wrap: wrap;
  font-size: 0.875rem;
}

.btn-download {
  background: #262626;
  color: #fafafa;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s;
}

.btn-download:hover {
  background: #333;
}

.btn-pdf {
  background: #1e3fa0;
}

.btn-pdf:hover {
  background: #1e40af;
}

.download-hint {
  color: #8a8a8a;
  font-size: 0.75rem;
}

/* ─── Investigação IA (painel de detalhe) ─── */
.investigation-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0 0.75rem;
  padding: 0.75rem;
  background: #18181b;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn-investigar {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-investigar:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-investigar:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-acao-principal {
  background: #27272a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn-acao-principal:hover {
  background: #3f3f46;
  border-color: #52525b;
}

.btn-dossie {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-dossie:hover:not(:disabled) {
  background: #27272a;
}

.investigacao-status {
  font-size: 0.78rem;
  color: var(--muted);
  flex: 1 1 100%;
}

.investigacao-status.investigacao-loading {
  color: #c4b5fd;
}

.investigation-toolbar.is-loading {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.25);
}

.ia-progress {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 0;
}

.ia-spinner {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid #3f3f46;
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: ia-spin 0.75s linear infinite;
}

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

.ia-progress-text strong {
  display: block;
  font-size: 0.88rem;
  color: #e4e4e7;
  margin-bottom: 0.2rem;
}

.ia-progress-text p {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}

.ia-progress-steps {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.ia-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.76rem;
  color: #52525b;
  transition: color 0.2s;
}

.ia-step.is-active {
  color: #c4b5fd;
}

.ia-step.is-done {
  color: #22c55e;
}

.ia-step-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #3f3f46;
  flex-shrink: 0;
}

.ia-step.is-active .ia-step-dot {
  background: #818cf8;
  box-shadow: 0 0 6px rgba(129, 140, 248, 0.6);
  animation: ia-pulse 1.2s ease-in-out infinite;
}

.ia-step.is-done .ia-step-dot {
  background: #22c55e;
}

@keyframes ia-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.narrativa-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.narrativa-skeleton-line {
  height: 0.65rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #1f1f23 25%, #2a2a30 50%, #1f1f23 75%);
  background-size: 200% 100%;
  animation: ia-shimmer 1.4s ease-in-out infinite;
}

.narrativa-skeleton-line:nth-child(1) { width: 100%; }
.narrativa-skeleton-line:nth-child(2) { width: 92%; animation-delay: 0.1s; }
.narrativa-skeleton-line:nth-child(3) { width: 78%; animation-delay: 0.2s; }
.narrativa-skeleton-line:nth-child(4) { width: 85%; animation-delay: 0.3s; }

@keyframes ia-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.narrativa-block.is-loading {
  border-color: #4f46e5;
  position: relative;
}

.btn-investigar .btn-spinner {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-right: 0.35rem;
  vertical-align: -0.15rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ia-spin 0.75s linear infinite;
}

.investigacao-status.investigacao-ok {
  color: #22c55e;
}

.investigacao-status.investigacao-erro {
  color: #ef4444;
}

.narrativa-empty {
  color: var(--muted);
  font-style: italic;
}

/* ─── Detail actions row ─── */
.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* ─── Sortable headers ─── */
th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]:hover {
  color: var(--text);
}

th.sort-active {
  color: var(--red);
}

/* ─── Results counter ─── */
.resultados-counter {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  text-align: right;
}

.badge-risk {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-count {
  background: #f97316;
  color: white;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-count-single {
  background: #374151;
  color: #9ca3af;
}

/* ─── Mobile (tablet e celular) ─── */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  header h1 {
    font-size: 1.25rem;
  }

  .subtitle {
    font-size: 0.72rem;
    line-height: 1.4;
  }

  .municipio-selector {
    align-items: stretch;
    min-width: unset;
    width: 100%;
  }

  .municipio-selector select {
    max-width: none;
  }

  .municipio-coleta-hint {
    text-align: left;
    max-width: none;
  }

  #main-nav {
    padding: 0 0.5rem;
    padding-left: max(0.5rem, env(safe-area-inset-left));
  }

  .tab-btn {
    padding: 0.7rem 0.75rem;
    font-size: 0.78rem;
  }

  main {
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .kpi-card {
    padding: 0.85rem;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .download-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.85rem;
  }

  .download-bar .btn-download {
    text-align: center;
  }

  .download-hint {
    font-size: 0.7rem;
  }

  .triagem-header {
    flex-direction: column;
  }

  .triagem-resumo {
    width: 100%;
  }

  .triagem-chip {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: unset;
  }

  .filter-bar {
    flex-direction: column;
  }

  .filter-bar select,
  .filter-bar input[type="text"],
  .filter-bar input[type="number"] {
    width: 100%;
    min-width: unset;
  }

  #alertas-table-wrap,
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #alertas-table {
    min-width: 640px;
  }

  #pagination {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .timeline-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .year-checkboxes {
    flex-wrap: wrap;
  }

  #detail-panel {
    width: 100%;
    max-width: 100vw;
    padding: 1rem;
    padding-top: max(2.5rem, calc(env(safe-area-inset-top) + 1.5rem));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  #detail-close {
    top: max(0.75rem, env(safe-area-inset-top));
    right: max(0.75rem, env(safe-area-inset-right));
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-valor {
    font-size: 1.45rem;
  }

  .detail-fornecedor {
    font-size: 1rem;
    padding-right: 2rem;
  }

  .detail-actions {
    flex-direction: column;
  }

  .detail-actions .detail-link,
  .detail-actions .btn-page {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .investigation-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .investigation-toolbar .btn-investigar,
  .investigation-toolbar .btn-investigar-profundo,
  .investigation-toolbar .btn-dossie {
    width: 100%;
    text-align: center;
  }

  .investigacao-status {
    flex: unset;
  }

  #detail-content table {
    min-width: unset;
    width: 100%;
  }

  #detail-content td,
  #detail-content th {
    white-space: normal;
  }

  .comparacao-grid {
    grid-template-columns: 1fr;
  }

  .narrativa-col:first-child {
    border-right: none;
    border-bottom: 1px solid rgba(6, 182, 212, 0.1);
  }

  .comparador-picker-actions {
    flex-direction: column;
  }

  .comparador-picker-actions button {
    width: 100%;
  }

  .pipeline-status-grid {
    grid-template-columns: 1fr 1fr;
  }

  .config-modal-inner {
    width: calc(100vw - 2rem);
    max-height: 90vh;
    overflow-y: auto;
  }

  #tour-btn {
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: max(1rem, env(safe-area-inset-right));
  }

  .detail-inner {
    grid-template-columns: 1fr;
  }

  .detail-inner .detail-actions {
    padding-top: 0;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .triagem-chip {
    flex: 1 1 100%;
  }

  /* Triagem: esconde colunas secundárias — mantém tipo, status, fornecedor, ações */
  #alertas-table th:nth-child(2),
  #alertas-table td:nth-child(2),
  #alertas-table th:nth-child(6),
  #alertas-table td:nth-child(6),
  #alertas-table th:nth-child(8),
  #alertas-table td:nth-child(8) {
    display: none;
  }

  #alertas-table {
    min-width: unset;
  }

  #alertas-table td:nth-child(7),
  #alertas-table th:nth-child(7) {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pipeline-status-grid {
    grid-template-columns: 1fr;
  }

  .tab-btn {
    padding: 0.65rem 0.6rem;
    font-size: 0.72rem;
  }

  .inv-profunda-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ─── Tour help button ─── */
#tour-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 500;
  transition: transform 0.2s, border-color 0.2s;
}
#tour-btn:hover {
  transform: scale(1.1);
  border-color: var(--blue);
}

/* ─── Custom tour ─── */
#tour-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8999;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  transition: opacity 0.3s ease;
}

#tour-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9000;
  pointer-events: none;
  display: none;
  transition: opacity 0.3s ease;
}

#tour-overlay rect {
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#tour-card {
  position: fixed;
  z-index: 9001;
  width: 300px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  display: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.tour-step-count {
  font-size: 0.7rem;
  color: #8a8a8a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.tour-title {
  color: #fafafa;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.tour-text {
  color: #a3a3a3;
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0 0 1rem;
}

.tour-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tour-nav {
  display: flex;
  gap: 0.5rem;
}

.tour-btn-nav {
  flex: 1;
  background: #262626;
  color: #fafafa;
  border: 1px solid #333;
  border-radius: 5px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.tour-btn-nav:hover:not(:disabled) { background: #333; }

.tour-btn-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tour-btn-primary {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

.tour-btn-primary:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }

.tour-skip {
  background: none;
  border: none;
  color: #8a8a8a;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  padding: 2px 0;
  transition: color 0.15s;
}

.tour-skip:hover { color: #a3a3a3; }

/* ─── Órgãos count cells ─── */
.count-red    { color: #ef4444; font-weight: 600; }
.count-orange { color: #f97316; font-weight: 600; }
.count-green  { color: #22c55e; font-weight: 600; }
.count-gray   { color: #8a8a8a; }

/* ─── Triagem ─── */
.section-heading {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.section-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.triagem-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.triagem-resumo {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.triagem-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  min-width: 6.5rem;
  transition: border-color 0.15s, background 0.15s;
}

.triagem-chip:hover,
.triagem-chip.active {
  border-color: #525252;
  background: #1a1a1a;
}

.triagem-chip-primary {
  border-color: #3b82f6;
}

.triagem-chip-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.triagem-chip-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.badge.status-aberto {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.badge.status-investigando {
  background: rgba(234, 179, 8, 0.12);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.badge.status-confirmado {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge.status-descartado {
  background: rgba(115, 115, 115, 0.15);
  color: #a3a3a3;
  border: 1px solid rgba(115, 115, 115, 0.35);
}

.triage-block {
  margin: 1.25rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121212;
}

/* Modo leitor: CTA de login no lugar do formulário/botão de escrita.
   Os CTAs são <a> reusando classes de botão; removemos o sublinhado de link
   e garantimos o layout de botão. */
.btn-entrar-triar,
.btn-investigar-login {
  display: inline-block;
  text-decoration: none;
}

.btn-entrar-triar {
  margin-top: 0.75rem;
}

.triage-block-readonly .section-note {
  margin: 0 0 0.75rem;
}

.triage-form label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.75rem 0 0.35rem;
}

.triage-form label:first-child {
  margin-top: 0;
}

.triage-form select,
.triage-form textarea {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem 0.65rem;
  font-family: inherit;
  font-size: 0.875rem;
}

.triage-form textarea {
  resize: vertical;
}

.triage-form .btn-page {
  margin-top: 0.75rem;
}

.triage-motivo-wrap {
  margin-top: 0.5rem;
}

.prio-score {
  display: inline-block;
  min-width: 2rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: #1e1e2e;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  color: #a5b4fc;
}

.triage-historico {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.triage-historico label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.triage-historico ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.triage-historico li {
  font-size: 0.82rem;
  color: #d4d4d4;
}

.triage-hist-meta {
  color: var(--muted);
  margin-right: 0.35rem;
}

.triage-hist-nota {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.triage-hist-empty {
  color: var(--muted);
}

/* Pipeline status */
.pipeline-status-card {
  margin-bottom: 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f0f0f;
}

.pipeline-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pipeline-status-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.pipeline-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.pipeline-badge.ok { color: #4ade80; border-color: #166534; background: #052e16; }
.pipeline-badge.warn { color: #fbbf24; border-color: #854d0e; background: #422006; }
.pipeline-badge.fail { color: #f87171; border-color: #991b1b; background: #450a0a; }

.pipeline-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.pipeline-stat label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.pipeline-stat span {
  font-size: 0.88rem;
  color: var(--text);
}

.pipeline-log-snippet {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: #a3a3a3;
  white-space: pre-wrap;
  max-height: 6rem;
  overflow-y: auto;
}

/* Monitoramento — watchlists / regras */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .config-grid { grid-template-columns: 1fr; }
}

.config-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f0f0f;
  padding: 1rem;
}

.config-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.config-panel-header h3 {
  margin: 0;
  font-size: 0.92rem;
}

.btn-primary-sm,
.btn-secondary-sm {
  font-size: 0.78rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  font-family: inherit;
}

.btn-primary-sm {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.btn-primary-sm:hover { background: #b91c1c; }

.btn-secondary-sm {
  background: transparent;
  color: var(--text);
}

.btn-secondary-sm:hover { background: #1a1a1a; }

.config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.config-table th,
.config-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.config-table th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.config-actions button {
  background: none;
  border: none;
  color: #93c5fd;
  cursor: pointer;
  font-size: 0.78rem;
  margin-right: 0.5rem;
  padding: 0;
}

.config-actions button.danger { color: #f87171; }

.config-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
}

.config-modal.hidden { display: none; }

.config-modal-inner {
  width: min(420px, 92vw);
  background: #141414;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.config-modal-inner h3 { margin: 0 0 1rem; font-size: 1rem; }

.config-modal-inner label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0.65rem 0 0.3rem;
}

.config-modal-inner input,
.config-modal-inner select,
.config-modal-inner textarea {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  font-family: inherit;
  font-size: 0.875rem;
}

.config-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.section-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin: -0.5rem 0 1rem;
}

/* Transparência RJ no painel de detalhes */
.transparencia-rj-block .section-note {
  margin: 0.25rem 0 0.65rem;
}

.transp-rj-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.transp-rj-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.transp-rj-table th,
.transp-rj-table td {
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--border);
}

.transp-rj-table th {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: #0f0f0f;
}

.transp-rj-table tbody tr:last-child td {
  border-bottom: none;
}

/* Comparador multi-fornecedor */
.comparador-panel {
  margin-bottom: 1.5rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f0f0f;
}

.comparador-picker {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.comparador-picker input[type="search"] {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem 0.65rem;
  font-family: inherit;
  font-size: 0.85rem;
}

.comparador-picker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.comparador-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 1.5rem;
}

.comparador-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #7c3aed;
  background: #1e1033;
  color: #e9d5ff;
}

.comparador-chip button {
  border: none;
  background: none;
  color: #c4b5fd;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
}

.comparador-lista {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a0a0a;
}

.comparador-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.8rem;
}

.comparador-item:last-child {
  border-bottom: none;
}

.comparador-item:hover {
  background: #141414;
}

.comparador-item.selected {
  background: #1a1028;
}

.comparador-item input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.comparador-item-main {
  flex: 1;
  min-width: 0;
}

.comparador-item-nome {
  font-weight: 500;
  line-height: 1.3;
}

.comparador-item-ni {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.comparador-item-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.comparador-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.comparador-vinculos {
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #422006;
  border-radius: 8px;
  background: #1c1208;
  font-size: 0.82rem;
}

.comparador-vinculos strong {
  color: #fbbf24;
}

.comparador-grid {
  display: grid;
  gap: 0.75rem;
  overflow-x: auto;
}

.comparador-col {
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a0a0a;
  padding: 0.75rem;
}

.comparador-col h3 {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.3;
}

.comparador-col .comparador-ni {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.comparador-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
}

.comparador-kpis span {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.comparador-section label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0.65rem 0 0.35rem;
}

.comparador-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.78rem;
}

.comparador-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.comparador-list li:last-child {
  border-bottom: none;
}

.comparador-badge-sancao {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #450a0a;
  color: #f87171;
  border: 1px solid #991b1b;
  margin-bottom: 0.5rem;
}

/* ─── Comparação de modelos IA ─── */
.narrativa-comparacao {
  margin-top: 24px;
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 8px;
  overflow: hidden;
}

.comparacao-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(6, 182, 212, 0.06);
  border-bottom: 1px solid rgba(6, 182, 212, 0.15);
}

.comparacao-title {
  font-size: 11px;
  font-weight: 600;
  color: #06b6d4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.comparacao-badge {
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #f59e0b;
  letter-spacing: 0.08em;
}

.comparacao-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.narrativa-col {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.narrativa-col:first-child {
  border-right: 1px solid rgba(6, 182, 212, 0.1);
}

.narrativa-col-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.model-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.model-dot.gemini { background: #06b6d4; }
.model-dot.gemma  { background: #8b5cf6; }

.veredito-status {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  text-transform: capitalize;
}

.veredito-justificativa {
  font-size: 12px;
  line-height: 1.6;
  color: #94a3b8;
  flex: 1;
}

.narrativa-col-text.muted {
  font-size: 12px;
  color: #475569;
  font-style: italic;
}

.btn-aplicar-veredito {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.06em;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: #06b6d4;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  align-self: flex-start;
}

.btn-aplicar-veredito:hover {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.5);
}

.btn-aplicar-veredito:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Investigação Profunda */
.btn-investigar-profundo {
  padding: 7px 14px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.06em;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #8b5cf6;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-investigar-profundo:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.5);
}

.btn-investigar-profundo:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.inv-profunda-status {
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: #64748b;
  margin-top: 6px;
  min-height: 16px;
}

.inv-profunda-result {
  margin-top: 20px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 8px;
  overflow: hidden;
}

.inv-profunda-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(139, 92, 246, 0.06);
  border-bottom: 1px solid rgba(139, 92, 246, 0.12);
}

.inv-profunda-title {
  font-size: 11px;
  font-weight: 600;
  color: #8b5cf6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.inv-profunda-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.06em;
  text-transform: capitalize;
}

.inv-profunda-resumos {
  list-style: none;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inv-profunda-resumos li {
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
}

.inv-profunda-resumos strong {
  color: #94a3b8;
}

.inv-profunda-sintese {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.08);
}

.inv-profunda-sintese-label {
  font-size: 10px;
  font-weight: 600;
  color: #8b5cf6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.inv-profunda-sintese-text {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.65;
  white-space: pre-wrap;
}

.inv-profunda-rec {
  padding: 12px 16px;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.55;
}

.inv-profunda-rec strong {
  color: #e2e8f0;
}

/* ─── Ícones SVG monocromáticos (substituem emojis) ─── */
.ico {
  display: inline-block;
  vertical-align: -0.14em;
  flex: none;
}

/* ─── Indicador de ordenação (consistente em todas as colunas) ─── */
.sort-ind {
  display: inline-block;
  margin-left: 0.3em;
  font-size: 0.72em;
  color: var(--muted);
  vertical-align: middle;
}
th.sort-active .sort-ind {
  color: var(--red);
}

/* ─── Coluna e checkboxes de seleção para triagem em lote ─── */
.col-select,
.cell-select {
  width: 3rem;
  white-space: nowrap;
  text-align: left;
}
.cell-select .lote-cb-grupo {
  vertical-align: middle;
  margin-right: 0.35rem;
}
.cell-select .expand-btn {
  vertical-align: middle;
}
.lote-cb-grupo,
.lote-cb-item,
#lote-select-all {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--blue);
  flex: none;
}
.lote-cb-item {
  margin-right: 0.6rem;
  vertical-align: middle;
}
/* Anônimo não tria: o checkbox "selecionar todos" some (as linhas já não têm
   checkbox no DOM). A coluna permanece para não desalinhar o botão de expandir. */
.is-anon #lote-select-all {
  display: none;
}

/* ─── Barra de ações em lote ─── */
.lote-bar {
  display: none;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0.5rem;
  z-index: 5;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
}
.lote-bar.visible {
  display: flex;
}
.lote-bar-count {
  font-size: 0.9rem;
}
.lote-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.lote-bar-motivo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.lote-bar-motivo select {
  padding: 0.3rem 0.5rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.lote-bar-motivo select.campo-invalido {
  border-color: var(--red);
}
.lote-btn-descartar {
  border-color: var(--red) !important;
  color: var(--red) !important;
}
.lote-progresso {
  flex-basis: 100%;
  font-size: 0.82rem;
  color: var(--muted);
}
.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.82rem;
  padding: 0.2rem;
}
.btn-link:hover {
  color: var(--text);
}

/* ─── Legenda de atalhos de teclado da triagem ─── */
.triage-atalhos {
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.7;
}
.triage-atalhos kbd {
  display: inline-block;
  min-width: 1.1em;
  padding: 0.05em 0.4em;
  font-family: inherit;
  font-size: 0.9em;
  text-align: center;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* ─── Selo de conflito de interesse (sócio-servidor) na fila ─── */
/* Cor reservada (roxo) para "beneficiário identificado" — não colide com
   severidade (vermelho/amarelo) nem com a seleção em lote (azul). */
.badge-conflito {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  vertical-align: middle;
}
.badge-conflito.forte {
  color: var(--purple);
  border-color: color-mix(in srgb, var(--purple) 45%, transparent);
  background: color-mix(in srgb, var(--purple) 12%, transparent);
}

/* Bloco de conflito no painel de detalhe */
.detail-conflito {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0.75rem 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  font-size: 0.85rem;
}
.detail-conflito.forte {
  border-left-color: var(--purple);
}
.detail-conflito .ico {
  margin-top: 0.15rem;
  color: var(--purple);
  flex: none;
}
.detail-conflito strong { display: block; margin-bottom: 0.2rem; }
.detail-conflito p { color: var(--muted); margin: 0; line-height: 1.5; }
.detail-conflito .detail-link { margin-left: 0.3rem; }

/* ─── Anotação no histórico (nota sem mudança de status) ─── */
.triage-hist-anotacao {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-right: 0.3rem;
}
