:root {
  --blue: #2563eb;
  --blue-lt: #eff4ff;
  --blue-dark: #1d4ed8;
  --blue-ring: rgba(37, 99, 235, 0.1);
  --gray-50: #f8f9fb;
  --gray-100: #f1f3f6;
  --gray-200: #e4e8ef;
  --gray-400: #9aa3b2;
  --gray-600: #4b5668;
  --gray-900: #111827;
  --green: #16a34a;
  --green-lt: #dcfce7;
  --red: #dc2626;
  --red-lt: #fee2e2;
  --yellow: #d97706;
  --yellow-lt: #fef3c7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  background: var(--gray-50);
  color: var(--gray-900);
  font-family: "DM Sans", sans-serif;
  font-size: 0.9rem;
  min-height: 100vh;
}

#resultado {
  position: relative;
  min-height: 320px;
}

/* ── Header ── */
header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 1rem;
  flex-wrap: wrap;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-text {
  line-height: 1.2;
}
.logo-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-900);
}
.logo-text span {
  font-size: 0.72rem;
  color: var(--gray-400);
}
.header-badge {
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--green-lt);
  color: var(--green);
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
}

/* ── Page heading ── */
.page-heading {
  padding: 1.75rem 0 0;
}
.page-heading h1 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0 0 0.15rem;
}
.page-heading p {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin: 0;
}

/* ── Card ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-top: 1.25rem;
  overflow: visible;
}
.card-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gray-100);
}

/* ── Labels ── */
.form-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
}
.req {
  color: var(--blue);
}

/* ── Selects ── */
.form-select {
  font-family: "DM Sans", sans-serif;
  font-size: 0.85rem;
  color: var(--gray-900);
  background-color: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.55rem 2.2rem 0.55rem 0.75rem;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
  outline: none;
}
.form-select.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}
.invalid-feedback {
  font-size: 0.72rem;
  color: var(--red);
  margin-top: 0.25rem;
}

/* ── Buttons ── */
.btn-primary-custom {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: "DM Sans", sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.58rem 1.5rem;
  cursor: pointer;
  transition:
    background 0.15s,
    box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-primary-custom:hover {
  background: var(--blue-dark);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-family: "DM Sans", sans-serif;
  font-size: 0.85rem;
  padding: 0.58rem 1.2rem;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.btn-ghost:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

/* ── Loading ── */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 10;
}
.loading-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  min-width: 220px;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-card span {
  font-size: 0.78rem;
  color: var(--gray-400);
}

/* ── Result meta ── */
.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 0.75rem;
}
.result-meta h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}
.count-chip {
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--blue-lt);
  color: var(--blue);
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
}

/* ── Table ── */
.table-wrap {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow-x: auto;
}
table.t-pss {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}
table.t-pss thead tr {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
table.t-pss thead th {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}
table.t-pss tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
  animation: fadeIn 0.2s ease forwards;
  opacity: 0;
}
table.t-pss tbody tr:last-child {
  border-bottom: none;
}
table.t-pss tbody tr:hover {
  background: var(--gray-50);
}
table.t-pss tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.83rem;
  color: var(--gray-600);
  white-space: nowrap;
}
.td-cpf {
  font-family: "DM Mono", monospace;
  font-size: 0.78rem;
  color: var(--gray-400);
}
.td-name {
  font-weight: 500;
  color: var(--gray-900);
}
.td-total {
  font-family: "DM Mono", monospace;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-900);
}
.td-rank {
  width: 3.5rem;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-weight: 600;
  color: var(--gray-900);
}

/* Ícone “ver detalhes” na tabela (carrega com a página; antes ficava só no CSS injetado ao abrir o modal). */
.btn-detalhe {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-400);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}
.btn-detalhe:hover {
  background: var(--blue-lt);
  border-color: #c7d9f9;
  color: var(--blue);
}

/* ── Chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}
.chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.chip.aprovado {
  background: var(--green-lt);
  color: var(--green);
}
.chip.aprovado .chip-dot {
  background: var(--green);
}
.chip.reprovado {
  background: var(--red-lt);
  color: var(--red);
}
.chip.reprovado .chip-dot {
  background: var(--red);
}
.chip.classificado {
  background: var(--yellow-lt);
  color: var(--yellow);
}
.chip.classificado .chip-dot {
  background: var(--yellow);
}

/* ── Table footer ── */
.table-footer {
  padding: 0.6rem 1rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
  font-size: 0.7rem;
  color: var(--gray-400);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Paginação ── */
.paginacao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.25rem 0 1.5rem;
}
.pag-info {
  font-size: 0.75rem;
  color: var(--gray-400);
}
.pag-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.pag-btn,
.pag-nav {
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: #fff;
  color: var(--gray-600);
  font-family: "DM Sans", sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.12s,
    border-color 0.12s,
    color 0.12s;
}
.pag-btn:hover,
.pag-nav:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
  color: var(--gray-900);
}
.pag-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
  pointer-events: none;
}
.pag-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pag-ellipsis {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--gray-400);
  user-select: none;
}

/* ── Error state ── */
.state-box {
  text-align: center;
  padding: 3.5rem 1rem;
}
.state-box strong {
  display: block;
  font-size: 0.9rem;
  color: var(--gray-600);
  margin-bottom: 0.25rem;
}
.state-box p {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin: 0;
}

/* ── Footer ── */
footer {
  padding: 2rem 1rem 1.5rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--gray-400);
  line-height: 1.55;
}
footer > div + div {
  margin-top: 2px;
}

/* ── Chamadas Especiais — custom dropdown ── */
.cex-wrap {
  position: relative;
}

.cex-trigger {
  width: 100%;
  min-height: 38px;
  height: auto;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 6px 34px 6px 36px;
  background: #fff !important;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.cex-trigger:hover:not(.disabled) {
  border-color: var(--gray-400);
}
.cex-trigger.open {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
}
.cex-trigger.disabled {
  background: var(--gray-100) !important;
  cursor: not-allowed;
  border-color: var(--gray-200);
  color: var(--gray-400);
}
.cex-trigger.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.cex-trigger-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--blue);
  pointer-events: none;
}
.cex-trigger.disabled .cex-trigger-icon {
  color: var(--gray-400);
}

.cex-trigger-text {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  color: var(--gray-900);
  font-family: "DM Sans", sans-serif;
}
.cex-trigger-text.cex-placeholder {
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cex-trigger-selected {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
}
.cex-trigger-selected-title {
  font-weight: 500;
  font-size: 0.85rem;
  line-height: 1.25;
  color: var(--gray-900);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cex-trigger-selected-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  max-width: 100%;
}
.cex-trigger-selected-meta .cex-meta-chip {
  font-size: 0.68rem;
}
.cex-trigger-selected-meta .cex-meta-chip svg {
  flex-shrink: 0;
}

.cex-badge {
  background: var(--blue-lt);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.cex-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--gray-400);
  pointer-events: none;
  transition: transform 0.2s;
}
.cex-trigger.open .cex-chevron {
  transform: translateY(-50%) rotate(180deg);
}

.cex-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  z-index: 999;
  overflow: hidden;
  display: none;
}
.cex-dropdown.open {
  display: block;
}

.cex-search-wrap {
  position: relative;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--gray-100);
}
.cex-search {
  width: 100%;
  height: 34px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 0 10px 0 30px;
  font-size: 0.8rem;
  font-family: "DM Sans", sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.cex-search:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
  background: #fff;
}
.cex-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--gray-400);
  pointer-events: none;
}

.cex-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}

.cex-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.cex-item:hover {
  background: var(--gray-50);
}
.cex-item.selected {
  background: var(--blue-lt);
}

.cex-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--blue-lt);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.cex-item-body {
  flex: 1;
  min-width: 0;
}
.cex-item-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-900);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cex-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.cex-meta-chip {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  color: var(--gray-400);
}

.cex-empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray-400);
}

.cex-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--gray-400);
  margin-top: 5px;
}
.cex-hint.active {
  color: var(--blue);
}

/* Tooltip "vários cargos" — só o ícone abre o tooltip */
.cex-varios-cargos-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
}
.cex-varios-cargos-tip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  padding: 2px;
  margin: -2px;
  border-radius: 4px;
  color: var(--blue);
  border-bottom: 1px dashed var(--blue);
  line-height: 0;
  transition: background 0.12s ease;
}
.cex-varios-cargos-tip:hover,
.cex-varios-cargos-tip:focus-visible {
  background: var(--blue-lt);
  outline: none;
}
.cex-varios-cargos-tip .cex-tooltip-hint-icon {
  display: block;
  opacity: 0.9;
}

.cesp-tooltip {
  position: fixed;
  z-index: 10000;
  background: #1e2532;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.76rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  border: 1px solid #2a2f3a;
  min-width: min(820px, calc(100vw - 24px));
  max-width: min(960px, calc(100vw - 16px));
}
.cesp-tooltip.visible {
  opacity: 1;
}
.cesp-tooltip-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #60a5fa;
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #2a2f3a;
}
.cesp-tooltip-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px 16px;
}
@media (max-width: 1200px) {
  .cesp-tooltip-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 768px) {
  .cesp-tooltip-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.cesp-tooltip-item {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  padding: 3px 0;
  line-height: 1.4;
  font-size: 0.7rem;
  color: #cbd5e1;
}
.cesp-tooltip-item::before {
  content: "›";
  color: #60a5fa;
  flex-shrink: 0;
  font-weight: 700;
}

/* ── Mobile ── */
@media (max-width: 576px) {
  .card {
    padding: 1rem;
  }
  .btn-primary-custom,
  .btn-ghost {
    width: 100%;
    justify-content: center;
  }
  .header-badge {
    display: none;
  }
  .paginacao {
    justify-content: center;
  }
  .pag-info {
    width: 100%;
    text-align: center;
  }
}
