/* ---------- Section cards ---------- */
.secao {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--sombra-sm);
  margin-bottom: 18px;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.secao-head {
  padding: 13px 16px;
  border-left: 5px solid var(--azul-medio);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sec-icon {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: rgba(58, 68, 120, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sec-icon svg {
  width: 17px;
  height: 17px;
  stroke: var(--text-primary);
}
.secao-head h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}
.secao-nota {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0 0 12px;
}
.secao-inner {
  padding: 6px 16px 18px;
}

/* ---------- KPI grid ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}
.kpi-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.35rem;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.kpi-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}
.kpi-value {
  font-family: var(--fonte-mono);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1.1;
}
.kpi-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.kpi-grid .kpi-card:nth-child(1)::before {
  background: linear-gradient(90deg, #e8601c, #f6ce5c);
}
.kpi-grid .kpi-card:nth-child(1) .kpi-value {
  color: #e8601c;
}
.kpi-grid .kpi-card:nth-child(2)::before {
  background: linear-gradient(90deg, #10b981, #34d399);
}
.kpi-grid .kpi-card:nth-child(2) .kpi-value {
  color: #10b981;
}
.kpi-grid .kpi-card:nth-child(3)::before {
  background: linear-gradient(90deg, #ef4444, #f87171);
}
.kpi-grid .kpi-card:nth-child(3) .kpi-value {
  color: #ef4444;
}
.kpi-grid .kpi-card:nth-child(4)::before {
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}
.kpi-grid .kpi-card:nth-child(4) .kpi-value {
  color: #8b5cf6;
}
.kpi-grid .kpi-card:nth-child(5)::before {
  background: linear-gradient(90deg, #06b6d4, #22d3ee);
}
.kpi-grid .kpi-card:nth-child(5) .kpi-value {
  color: #06b6d4;
}
.kpi-grid .kpi-card:nth-child(6)::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.kpi-grid .kpi-card:nth-child(6) .kpi-value {
  color: #f59e0b;
}
.kpi-grid .kpi-card:nth-child(7)::before {
  background: linear-gradient(90deg, #2d3561, #3a4478);
}
.kpi-grid .kpi-card:nth-child(7) .kpi-value {
  color: var(--text-primary);
}
.kpi-grid .kpi-card:nth-child(8)::before {
  background: linear-gradient(90deg, #84cc16, #a3e635);
}
.kpi-grid .kpi-card:nth-child(8) .kpi-value {
  color: #84cc16;
}

.kpi-clicavel {
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.kpi-clicavel:hover {
  transform: translateY(-2px);
  box-shadow: var(--sombra);
}
.kpi-clicavel:focus-visible {
  outline: 2px solid var(--laranja);
  outline-offset: 2px;
}

/* ---------- Charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.chart-card .secao-inner {
  position: relative;
  height: 300px;
}
.chart-card canvas {
  max-height: 100%;
}
.chart-card.card-clicavel {
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.chart-card.card-clicavel:hover {
  transform: translateY(-2px);
  box-shadow: var(--sombra);
}
.chart-hint {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: var(--fonte-mono);
  margin-left: auto;
  white-space: nowrap;
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 0 20px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
thead th {
  background: var(--bg-elevated);
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-align: left;
  padding: 10px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
  vertical-align: top;
}
tbody tr:hover {
  background: var(--bg-elevated);
}
td.mono,
th.mono {
  font-family: var(--fonte-mono);
}
td.num {
  font-family: var(--fonte-mono);
  text-align: right;
}

/* ---------- Cabeçalhos ordenáveis / filtráveis ---------- */
.th-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.th-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  color: inherit;
  transition: color var(--trans);
}
.th-label:hover {
  color: var(--text-primary);
}
.th-label.ativo {
  color: var(--text-primary);
}
.th-sort-arrow {
  font-size: 0.62rem;
  opacity: 0.35;
}
.th-sort-arrow.ativo {
  opacity: 1;
  color: var(--laranja);
}
.th-filtro-btn {
  background: transparent;
  border: none;
  padding: 4px;
  border-radius: 4px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition:
    background var(--trans),
    color var(--trans);
}
.th-filtro-btn:hover {
  background: var(--border-soft);
}
.th-filtro-btn.filtro-ativo {
  background: var(--azul-medio);
  color: var(--branco);
}
.th-filtro-btn.aberto {
  background: var(--azul-claro);
  color: var(--branco);
}

.filtro-dropdown {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--sombra);
  width: 230px;
  max-height: 320px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 250;
  font-family: var(--fonte-corpo);
  text-transform: none;
  letter-spacing: normal;
}
.filtro-dropdown-busca {
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}
.filtro-dropdown-busca input {
  width: 100%;
  min-height: 32px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 400;
}
.filtro-dropdown-busca input:focus {
  outline: none;
  border-color: var(--laranja);
  box-shadow: 0 0 0 3px rgba(232, 96, 28, 0.15);
}
.filtro-dropdown-acoes {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}
.filtro-acao {
  flex: 1;
  background: var(--bg-elevated);
  border: none;
  border-radius: 4px;
  padding: 5px 6px;
  font-size: 0.7rem;
  font-family: var(--fonte-display);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: none;
}
.filtro-acao:hover {
  background: var(--border-soft);
}
.filtro-dropdown-lista {
  overflow-y: auto;
  padding: 4px 0;
}
.filtro-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 400;
  cursor: pointer;
  color: var(--text-primary);
}
.filtro-item:hover {
  background: var(--bg-elevated);
}
.filtro-item input {
  flex: none;
  accent-color: var(--azul-medio);
}
.filtro-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tfoot td {
  padding: 10px 12px;
  font-weight: 600;
  border-top: 2px solid var(--border);
  font-family: var(--fonte-mono);
}
.pct-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pct-bar-track {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: var(--border-soft);
  overflow: hidden;
  min-width: 50px;
}
.pct-bar-fill {
  height: 100%;
  background: var(--laranja);
  border-radius: 99px;
}
.pct-bar-fill.over {
  background: var(--erro);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-feita {
  background: rgba(22, 163, 74, 0.13);
  color: var(--sucesso);
}
.badge-andamento {
  background: var(--amarelo-suave);
  color: #92620a;
}
.badge-afazer {
  background: var(--border-soft);
  color: var(--text-muted);
}
.badge-iseo {
  background: var(--border-soft);
  color: var(--text-secondary);
}
.badge-equipe {
  background: var(--amarelo-suave);
  color: #7a5a06;
}

.urg-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-family: var(--fonte-mono);
  font-weight: 500;
  font-size: 0.74rem;
  white-space: nowrap;
}
.urg-atrasada {
  background: rgba(220, 38, 38, 0.12);
  color: var(--erro);
  font-weight: 700;
}
.urg-urgente {
  background: var(--amarelo);
  color: var(--azul);
  font-weight: 700;
}
.urg-proxima {
  background: var(--amarelo-suave);
  color: #7a5a06;
}
.urg-distante {
  background: var(--border-soft);
  color: var(--text-muted);
}

/* ---------- Table controls ---------- */
.table-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.table-controls input[type="text"] {
  flex: 1;
  min-width: 220px;
  min-height: 40px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0 12px;
  font-size: 0.88rem;
}
.table-controls select {
  min-height: 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0 30px 0 12px;
  font-size: 0.88rem;
  background: var(--bg-elevated);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b98c4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}
.table-controls input:focus,
.table-controls select:focus {
  outline: none;
  border-color: var(--laranja);
  box-shadow: 0 0 0 3px rgba(232, 96, 28, 0.15);
}
.table-controls .campo-tamanho {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.table-controls .campo-tamanho select {
  min-height: 36px;
}
.empty-row td {
  text-align: center;
  color: var(--text-secondary);
  padding: 26px 12px;
  font-style: italic;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}
.btn-mini {
  background: var(--border-soft);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius);
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 8px 14px;
  min-height: 34px;
  transition: background var(--trans);
}
.btn-mini:hover:not(:disabled) {
  background: var(--border);
}
.btn-mini:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagina-info {
  font-family: var(--fonte-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ---------- Buttons ---------- */
.btn-primario {
  background: var(--laranja);
  color: var(--branco);
  border: none;
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: var(--radius);
  padding: 11px 16px;
  min-height: 44px;
  transition: background 0.18s;
}
.btn-primario:hover {
  background: var(--laranja-hover);
}
.btn-primario:active {
  transform: scale(0.97);
}
.btn-secundario {
  background: var(--azul-medio);
  color: var(--branco);
  border: none;
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius);
  padding: 9px 16px;
  min-height: 38px;
  transition: background 0.18s;
}
.btn-secundario:hover {
  background: var(--azul-claro);
}
.btn-secundario:active {
  transform: scale(0.97);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 26, 0.78);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--sombra);
  width: min(1560px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  background: var(--azul);
  color: var(--branco);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
}
.modal-head h3 {
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 1rem;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--branco);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 6px;
  transition: background var(--trans);
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.15);
}
.modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-family: var(--fonte-mono);
}

/* ---------- Modal: linhas clicáveis (drill-down) ---------- */
tr.row-clicavel {
  cursor: pointer;
  transition: background var(--trans);
}
tr.row-clicavel:hover {
  background: var(--bg-elevated);
}

/* ---------- Modal: detalhe de operação ---------- */
.btn-voltar {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 2px;
  margin-bottom: 14px;
  transition: color var(--trans);
}
.btn-voltar:hover {
  color: var(--laranja);
}
.detalhe-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.detalhe-head h4 {
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
}
.detalhe-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-box.modal-box-detalhe {
  width: min(760px, 94vw);
}
.detalhe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 20px;
}
.detalhe-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.detalhe-item.full {
  grid-column: 1/-1;
}
.detalhe-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  font-family: var(--fonte-display);
  font-weight: 600;
}
.detalhe-valor {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: var(--fonte-corpo);
}
.detalhe-valor.mono {
  font-family: var(--fonte-mono);
}
.detalhe-valor.vazio {
  color: var(--text-muted);
  font-style: italic;
}
.detalhe-secao {
  border-top: 1px solid var(--border-soft);
  margin-top: 18px;
  padding-top: 16px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  transition: transform 0.35s ease;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-family: var(--fonte-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--branco);
  max-width: 90vw;
  z-index: 200;
  box-shadow: var(--sombra);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.erro {
  background: var(--erro);
}
.toast.sucesso {
  background: var(--sucesso);
}
