: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;
  --navy: #000131;
  --navy-lt: #e8eaf6;
  --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;
}

#resultado {
  position: relative;
  min-height: 320px;
}

/* ── Card ── */
.pss-filter-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-top: 3px solid var(--blue);
  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);
}

/* ── Hero ── */
.pss-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 1.25rem;
  box-shadow: 0 4px 20px rgba(37, 99, 235, .25);
}
.pss-hero-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.pss-hero-icon {
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.pss-hero-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 .15rem;
}
.pss-hero-sub {
  font-size: .78rem;
  color: rgba(255,255,255,.72);
  margin: 0;
}

/* ── Labels ── */
.form-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
  display: block;
}
.req {
  color: var(--blue);
}

/* ── Buttons ── */
.btn-primary-custom {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  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-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);
}

/* ── Select2 theme ── */
.select2-container--default .select2-selection--single {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  height: 38px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  padding-left: .75rem;
  color: var(--gray-900);
  font-size: .85rem;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px;
  right: 6px;
}
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
  outline: none;
}
.select2-dropdown {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, .1);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  padding: .35rem .6rem;
  font-size: .83rem;
}
.select2-container--default .select2-results__option {
  font-size: .83rem;
  padding: .4rem .75rem;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--blue);
}
.select2-container--default .select2-results__option[aria-selected=true] {
  background: var(--gray-100);
  color: var(--gray-900);
}

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

/* ── Legenda ── */
.rf-legenda {
  font-size: .77rem;
  color: var(--gray-600);
  border-left: 3px solid var(--blue);
  padding: .4rem .75rem;
  background: var(--gray-50);
  border-radius: 0 6px 6px 0;
  margin-bottom: .85rem;
  line-height: 1.8;
}

/* ── 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: 600px;
}
table.t-pss thead tr:first-child {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
}
table.t-pss thead tr:first-child th {
  font-size: .82rem;
  font-weight: 500;
  color: var(--gray-900);
  padding: .65rem .85rem;
  text-align: left;
}
table.t-pss thead tr:last-child {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
}
table.t-pss thead tr:last-child th {
  color: rgba(255,255,255,.9);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
  text-align: center;
  border: none;
}
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:nth-child(even) { background: #f7f9ff; }
table.t-pss tbody tr:hover { background: var(--blue-lt); }
table.t-pss tbody tr:last-child { border-bottom: none; }
table.t-pss tbody td {
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  color: var(--gray-600);
  white-space: nowrap;
  text-align: center;
}
.td-name {
  text-align: left !important;
  white-space: normal !important;
  font-weight: 500;
  color: var(--gray-900) !important;
  min-width: 200px;
  cursor: pointer;
}
.td-name:hover { text-decoration: underline; color: var(--blue) !important; }
.td-cpf {
  font-family: monospace;
  font-size: .78rem;
  color: var(--gray-400) !important;
}
.td-total {
  font-family: monospace;
  font-weight: 600;
  color: var(--gray-900) !important;
}
.td-nasc {
  font-size: .75rem;
  font-weight: 600;
  color: var(--blue-dark) !important;
}

/* ── Btn detalhe ── */
.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;
}
.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: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
}
.chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chip-green { background: var(--green-lt); color: var(--green); }
.chip-green .chip-dot { background: var(--green); }
.chip-red { background: var(--red-lt); color: var(--red); }
.chip-red .chip-dot { background: var(--red); }
.chip-navy { background: var(--navy-lt); color: var(--navy); }
.chip-navy .chip-dot { background: var(--navy); }
.chip-blue { background: var(--blue-lt); color: var(--blue); }
.chip-blue .chip-dot { background: var(--blue); }
.chip-yellow { background: var(--yellow-lt); color: var(--yellow); }
.chip-yellow .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;
}

/* ── Ver mais ── */
.ver-mais-wrap {
  padding: .85rem 1rem;
  text-align: center;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── State boxes ── */
.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;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile ── */
@media (max-width: 576px) {
  .pss-filter-card { padding: 1rem; }
  .btn-primary-custom,
  .btn-ghost { width: 100%; justify-content: center; }
}
