/* -------------------------------------------------------------------------- */
/* Design tokens — escuro (padrão)                                              */
/* -------------------------------------------------------------------------- */
:root {
  --bg: #060a12;
  --bg-elevated: #0c1222;
  --card: #0f172a;
  --card-soft: rgba(15, 23, 42, 0.72);
  --line: #1e293b;
  --line-strong: #334155;
  --primary: #60a5fa;
  --primary-strong: #2563eb;
  --primary-glow: rgba(37, 99, 235, 0.35);
  --text: #e2e8f0;
  --text-soft: #94a3b8;
  --text-muted: #64748b;
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;
  --sidebar: #0a0f1c;
  --sidebar-hover: rgba(96, 165, 250, 0.12);
  --topbar: rgba(10, 15, 28, 0.85);
  --chip-bg: rgba(37, 99, 235, 0.15);
  --chip-border: rgba(96, 165, 250, 0.35);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* -------------------------------------------------------------------------- */
/* Tema claro                                                                   */
/* -------------------------------------------------------------------------- */
[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-soft: rgba(255, 255, 255, 0.92);
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.2);
  --text: #0f172a;
  --text-soft: #475569;
  --text-muted: #64748b;
  --success: #059669;
  --error: #dc2626;
  --warning: #d97706;
  --sidebar: #ffffff;
  --sidebar-hover: rgba(37, 99, 235, 0.08);
  --topbar: rgba(255, 255, 255, 0.92);
  --chip-bg: rgba(37, 99, 235, 0.08);
  --chip-border: rgba(37, 99, 235, 0.22);
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .bg-glow {
  background: radial-gradient(circle at 18% 12%, rgba(37, 99, 235, 0.12), transparent 38%);
}

[data-theme="light"] body {
  background: linear-gradient(165deg, #f8fafc 0%, #e2e8f0 48%, #f1f5f9 100%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(ellipse 120% 80% at 100% 0%, #0f1a33 0%, var(--bg) 52%);
  transition: background 0.25s ease, color 0.2s ease;
}

body.nav-open {
  overflow: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 18% 12%, rgba(96, 165, 250, 0.14), transparent 36%);
}

/* -------------------------------------------------------------------------- */
/* App shell + sidebar                                                          */
/* -------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 10px 10px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.28s ease, box-shadow 0.2s ease;
}

[data-theme="light"] .sidebar {
  box-shadow: 4px 0 20px rgba(15, 23, 42, 0.06);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 12px;
}

.sidebar-close {
  display: none;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.sidebar-logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.92rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
  box-shadow: 0 6px 18px var(--primary-glow);
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sidebar-logo-title {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.sidebar-logo-sub {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.78rem;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  border-color: var(--line);
}

.sidebar-link.is-active {
  background: var(--sidebar-hover);
  border-color: rgba(96, 165, 250, 0.45);
  color: var(--primary);
}

[data-theme="light"] .sidebar-link.is-active {
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary-strong);
}

.sidebar-ico {
  width: 1rem;
  text-align: center;
  opacity: 0.85;
  font-size: 0.72rem;
}

.sidebar-spacer {
  flex: 1;
  min-height: 12px;
}

.sidebar-userbox {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-user-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 0.78rem;
  word-break: break-all;
}

.sidebar-logout-form {
  margin: 0;
}

.sidebar-scrim {
  display: none;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-titles {
  flex: 1;
  min-width: 0;
}

.topbar-kicker {
  margin: 0;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.topbar-heading {
  margin: 1px 0 0;
  font-size: clamp(0.92rem, 1.6vw, 1.12rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-content {
  flex: 1;
  padding: 12px 14px 22px;
  max-width: 1840px;
  margin: 0 auto;
  width: 100%;
}

.app-content.app-content--narrow {
  max-width: 760px;
}

/* Mobile sidebar */
@media (max-width: 959px) {
  .sidebar {
    position: fixed;
    z-index: 30;
    left: 0;
    top: 0;
    transform: translateX(-104%);
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(2, 6, 23, 0.55);
    border: none;
    padding: 0;
    cursor: pointer;
  }

  .sidebar-scrim[hidden] {
    display: none !important;
  }

  .menu-btn {
    display: inline-flex !important;
  }
}

@media (min-width: 960px) {
  .menu-btn {
    display: none !important;
  }
}

/* -------------------------------------------------------------------------- */
/* Primitivos: botões, inputs, ícones                                           */
/* -------------------------------------------------------------------------- */
.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-soft);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--sidebar-hover);
}

.menu-ico {
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
  display: block;
}

.menu-ico::before,
.menu-ico::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.menu-ico::before {
  top: -6px;
}
.menu-ico::after {
  top: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  color: #fff;
  background: linear-gradient(120deg, var(--primary-strong), var(--primary));
  box-shadow: 0 6px 18px var(--primary-glow);
}

.btn--primary:hover {
  filter: brightness(1.05);
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn--ghost:hover {
  background: var(--sidebar-hover);
  border-color: var(--line-strong);
}

.btn--danger {
  color: #fff;
  background: linear-gradient(120deg, #b91c1c, #ef4444);
}

.btn--sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.76rem;
}

.btn--block {
  width: 100%;
}

.theme-toggle .theme-ico {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.35);
  background: #fbbf24;
}

[data-theme="light"] .theme-toggle .theme-ico {
  background: #1e293b;
  box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.15);
}

.theme-label {
  font-size: 0.74rem;
  font-weight: 600;
}

.container {
  width: 100%;
  max-width: 1840px;
  margin: 0 auto;
}

.container.narrow {
  max-width: 720px;
}

.tag {
  display: inline-block;
  margin: 0;
  font-size: 0.78rem;
  color: var(--primary);
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
}

.hero {
  margin-top: 8px;
  margin-bottom: 6px;
}

.hero h1 {
  margin: 8px 0 6px;
  font-size: clamp(1.55rem, 2.6vw, 2.35rem);
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 0;
  color: var(--text-soft);
  max-width: 62ch;
  line-height: 1.45;
}

.search-card,
.table-card,
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-card {
  margin-top: 12px;
  padding: 14px 16px;
}

.search-card > h2,
.form-section-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
}

.search-card label,
.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 600;
}

.search-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.filters-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.source-filter-wrap {
  min-width: 150px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

button:not(.icon-btn):not(.btn):not(.nav-button) {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  height: 36px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(120deg, var(--primary-strong), var(--primary));
}

button:not(.icon-btn):not(.btn):not(.nav-button):disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-btn {
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.status {
  margin: 12px 2px 0;
  font-size: 0.9rem;
}

.status.idle {
  color: var(--text-soft);
}
.status.loading {
  color: var(--primary);
}
.status.success {
  color: var(--success);
}
.status.warning {
  color: var(--warning);
}

.status.error {
  color: var(--error);
}

.stats-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 14px 16px;
}

.stat-card span {
  color: var(--text-soft);
  font-size: 0.8rem;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.12rem;
}

.table-card {
  margin-top: 16px;
  padding: 16px 18px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.table-header h2 {
  margin: 0;
  font-size: 1.08rem;
}

.table-title-wrap h2 {
  margin: 0;
}

.table-subtitle {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
  line-height: 1.4;
}

.results-toolbar {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.results-toolbar-title {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.results-filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px 10px;
  align-items: end;
}

.results-toolbar-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.results-toolbar-hint {
  font-size: 0.78rem;
  color: var(--text-soft);
  line-height: 1.35;
  flex: 1 1 220px;
}

.results-toolbar select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: 70vh;
  margin-top: 12px;
  background: var(--bg-elevated);
}

.table-wrapper--history-list {
  max-height: 52vh;
}

.table-wrapper--history-items {
  max-height: 55vh;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-results {
  min-width: 1450px;
}

.table-admin {
  min-width: 720px;
}

.table-history {
  min-width: 880px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 11px;
  font-size: 0.86rem;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--card);
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  z-index: 1;
}

tbody tr:nth-child(odd) {
  background: rgba(148, 163, 184, 0.04);
}

tbody tr:hover {
  background: var(--sidebar-hover);
}

/* Colunas resultados (painel + histórico detalhe) */
.table-results td:nth-child(1) {
  white-space: nowrap;
  min-width: 118px;
  font-weight: 600;
}
.table-results td:nth-child(3) {
  min-width: 260px;
}
.table-results td:nth-child(6) {
  min-width: 300px;
}
.table-results td:nth-child(7),
.table-results td:nth-child(8),
.table-results td:nth-child(11) {
  white-space: nowrap;
  min-width: 82px;
}
.table-results td:nth-child(9) {
  min-width: 160px;
}
.table-results td:nth-child(10) {
  min-width: 132px;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

/* -------------------------------------------------------------------------- */
/* Busca em andamento (painel)                                                */
/* -------------------------------------------------------------------------- */
.search-card.is-searching {
  animation: searchCardPulse 1.6s ease-in-out infinite;
  border-color: rgba(37, 99, 235, 0.45);
}

[data-theme="light"] .search-card.is-searching {
  border-color: rgba(37, 99, 235, 0.35);
}

@keyframes searchCardPulse {
  0%,
  100% {
    box-shadow: var(--shadow), 0 0 0 0 rgba(37, 99, 235, 0);
  }
  50% {
    box-shadow: var(--shadow), 0 0 0 4px rgba(37, 99, 235, 0.12);
  }
}

.search-progress {
  margin-top: 14px;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}

.search-progress--hidden {
  display: none !important;
}

.search-progress-track {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.search-progress-bar {
  height: 100%;
  width: 42%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-strong), var(--primary), var(--primary-strong));
  animation: searchProgressSlide 1.25s ease-in-out infinite;
}

@keyframes searchProgressSlide {
  0% {
    transform: translateX(-120%);
    opacity: 0.85;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(320%);
    opacity: 0.85;
  }
}

.status-with-spinner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 10px;
}

.status-spinner {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--primary);
  border-right-color: var(--primary);
  animation: spin 0.7s linear infinite;
}

.status-spinner[hidden] {
  display: none !important;
}

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

.status-with-spinner .status {
  margin-top: 0;
  flex: 1;
}

#searchButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 148px;
}

#searchButton.is-running {
  cursor: wait;
  opacity: 0.95;
  filter: saturate(1.05);
}

#searchButton .btn-busy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#searchButton .btn-busy::before {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.65s linear infinite;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Chips, badges, alertas */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--muted {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-soft);
}

.badge--ok {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.badge--err {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
}

.badge--urgent {
  background: rgba(251, 191, 36, 0.2);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.45);
}

.badge--overdue {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.badge--run {
  background: rgba(96, 165, 250, 0.15);
  color: var(--primary);
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  margin: 12px 0;
}

.alert--error {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.08);
  color: var(--error);
}

.detail-panel {
  margin-top: 16px;
  animation: fadeIn 0.28s ease;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-term {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.raw-json {
  margin-top: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0 12px 10px;
  background: var(--bg-elevated);
}

.raw-json summary {
  cursor: pointer;
  font-weight: 600;
  padding: 10px 0;
  color: var(--text-soft);
}

.raw-json pre {
  margin: 0;
  padding: 10px 0 4px;
  font-size: 0.75rem;
  color: var(--text-soft);
  overflow: auto;
  max-height: 240px;
  white-space: pre-wrap;
  word-break: break-word;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 4px;
}

.toolbar-spacer {
  flex: 1;
}

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

/* Admin: abas */
.admin-tabs-wrap {
  margin-top: 8px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.admin-tab-btn {
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

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

.admin-tab-btn.is-active {
  color: #fff;
  background: linear-gradient(120deg, var(--primary-strong), var(--primary));
  border-color: transparent;
}

.admin-tab-panel {
  display: block;
}

.admin-tab-panel[hidden] {
  display: none !important;
}

.admin-tab-intro code {
  font-size: 0.82em;
}

.admin-transp-status {
  font-size: 0.84rem;
  line-height: 1.45;
  margin: 0;
}

.admin-transp-status.muted {
  color: var(--text-soft);
}

.admin-transp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

.admin-file-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Admin: formulário em grade + ações em details */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 16px;
  align-items: end;
}

.user-actions {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  margin-top: 4px;
}

.user-actions summary {
  cursor: pointer;
  font-weight: 700;
  padding: 8px 12px;
  list-style: none;
  color: var(--primary);
  font-size: 0.85rem;
}

.user-actions summary::-webkit-details-marker {
  display: none;
}

.user-actions[open] summary {
  border-bottom: 1px solid var(--line);
}

.user-actions-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pwd-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pwd-row input {
  flex: 1;
  min-width: 160px;
}

/* Login */
.page-login {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.login-topbar {
  display: flex;
  justify-content: flex-end;
  padding: 14px 18px;
  position: relative;
  z-index: 2;
}

.login-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
  position: relative;
  z-index: 1;
}

.login-card-wrap {
  width: 100%;
  max-width: 420px;
}

.login-brand {
  text-align: center;
  margin-bottom: 18px;
}

.login-brand-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.25rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
  box-shadow: 0 10px 28px var(--primary-glow);
}

.login-brand h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
}

.login-brand p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}

/* Compat: links antigos top-nav (se ainda existirem) */
.top-nav {
  display: none;
}

@media (max-width: 920px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }
}

/* Licitações — utilidades */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.source-checkboxes-field {
  margin: 0 0 1rem;
  border: none;
  padding: 0;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: 1.15rem;
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
  color: var(--text-soft);
}

.warnings-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--warning);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* Licitações — layout compacto */
.hero.hero--slim {
  padding: 0.85rem 0 0.35rem;
  margin-bottom: 0.35rem;
}

.hero.hero--slim h1 {
  font-size: 1.35rem;
  font-weight: 650;
  margin: 0.2rem 0 0.25rem;
  letter-spacing: -0.02em;
}

.hero.hero--slim .tag {
  margin: 0 0 0.1rem;
  font-size: 0.72rem;
}

.hero.hero--slim .subtitle {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  max-width: 52rem;
  color: var(--text-soft);
}

.hero.hero--slim .subtitle a {
  color: var(--primary);
}

.hero.hero--slim.hero--tight {
  padding: 0.25rem 0 0.15rem;
  margin-bottom: 0.15rem;
}

.hero.hero--slim.hero--tight h1 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.search-card.lic-search-card {
  margin-top: 12px;
  padding: 14px 16px;
}

/* Filtros da 1.ª linha — mesmo tamanho legível que Preços (label + inputs) */
.search-card.lic-search-card .lic-row-filters input,
.search-card.lic-search-card .lic-row-filters select {
  padding: 8px 10px;
  font-size: 0.88rem;
  min-height: 38px;
}

/* Licitações: linha 1 (datas, UF, portais) + linha 2 (termo largo + buscar) */
.lic-form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 100%;
}

.lic-row-filters {
  display: grid;
  grid-template-columns:
    minmax(148px, 1fr)
    minmax(148px, 1fr)
    minmax(72px, 0.45fr)
    minmax(220px, 1.35fr);
  gap: 10px 12px;
  align-items: end;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

/* Termo: mesma estrutura que Preços — input é filho direto de .search-row (tipografia global) */
.lic-term-section .lic-search-main-row {
  margin-top: 12px;
}

.field.lic-inline-field {
  margin: 0;
  min-width: 0;
}

.field.lic-inline-field label {
  display: block;
  margin-bottom: 1px;
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.search-card.lic-search-card .lic-row-filters .field.lic-inline-field label {
  font-size: 0.88rem;
  margin-bottom: 7px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-soft);
  white-space: nowrap;
}

.search-card.lic-search-card .lic-row-filters input,
.search-card.lic-search-card .lic-row-filters select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.field.lic-field-uf select {
  padding-left: 6px;
  padding-right: 4px;
}

button.primary-btn.lic-row-submit {
  justify-self: start;
  white-space: nowrap;
}

@media (max-width: 620px) {
  .search-card.lic-search-card .lic-search-main-row .primary-btn.lic-row-submit {
    justify-self: stretch;
    width: 100%;
  }
}

.lic-status-line {
  margin-top: 2px;
}

.lic-status-line .status {
  margin-top: 4px;
  font-size: 0.72rem;
}

.search-card.lic-search-card .search-progress {
  margin-top: 6px;
}

.stats-grid.stats-grid--compact {
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 0.45rem;
  margin: 0.5rem 0 0.65rem;
}

.stats-grid.stats-grid--compact .stat-card {
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
}

.stats-grid.stats-grid--compact .stat-card span {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.stats-grid.stats-grid--compact .stat-card strong {
  font-size: 0.98rem;
}

.table-card--compact {
  padding: 0.65rem 0.85rem;
}

.table-card--compact .table-header--compact {
  margin-bottom: 0.35rem;
}

.table-card--compact .table-header--compact h2 {
  font-size: 0.95rem;
  margin: 0;
}

/* Para avaliar */
.para-resumo-card {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.para-summary-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
}

.para-summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip.chip--stat {
  font-size: 0.82rem;
  padding: 0.28rem 0.55rem;
}

.chip.chip--stat strong {
  font-weight: 700;
  margin-right: 0.2rem;
}

.chip.chip--warn {
  border-color: rgba(251, 191, 36, 0.55);
  color: var(--warning);
}

.chip.chip--err {
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--error);
}

.para-cell-title {
  max-width: min(28vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.para-input-date {
  min-height: 36px;
  font-size: 0.86rem;
}

.para-input-num {
  width: 3.25rem;
  min-height: 36px;
  font-size: 0.86rem;
}

.para-input-notes {
  min-width: 120px;
  max-width: min(22vw, 240px);
  width: 100%;
  min-height: 36px;
  font-size: 0.82rem;
}

.para-cell-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.table-wrapper.table-wrapper--scroll {
  overflow-x: auto;
}

@media (max-width: 620px) {
  .lic-sources-inline {
    margin-left: 0;
    width: 100%;
  }

  .search-head {
    flex-direction: column;
    align-items: stretch;
  }
  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }
  .source-filter-wrap {
    min-width: 0;
  }
  .search-row {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1200px) {
  .results-filters-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .results-filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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