/* ============================================================
   TCIA — Estilos do Painel do Pesquisador
   ============================================================ */

.panel-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.btn-sm {
  padding: 10px 18px;
  font-size: 14px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  background: #fff;
  margin-bottom: 20px;
}

.panel-card h3 {
  margin: 0 0 14px;
  font-size: 22px;
  color: var(--ink);
}

.panel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-card-header h3 {
  margin: 0;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
}

.filter-check {
  grid-column: span 2;
}
@media (max-width: 600px) {
  .filter-check { grid-column: span 1; }
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  text-transform: none !important;
  font-weight: 500 !important;
  cursor: pointer;
  padding: 10px 0;
}

.export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: #faf7f2;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 820px) {
  .charts-grid { grid-template-columns: 1fr; }
}

.chart-wrap {
  position: relative;
  height: 280px;
}
.chart-wrap.tall {
  height: 340px;
}
.chart-wrap.xtall {
  height: 460px;
}

.chart-sub {
  margin: -8px 0 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.chart-card {
  animation: cardReveal 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}
.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px -14px rgba(0, 0, 0, 0.22);
  border-color: #d6d2c7;
}
.charts-grid .chart-card:nth-child(2) { animation-delay: 60ms; }
.charts-grid .chart-card:nth-child(3) { animation-delay: 120ms; }
.charts-grid .chart-card:nth-child(4) { animation-delay: 180ms; }
.charts-grid .chart-card:nth-child(5) { animation-delay: 240ms; }
.charts-grid .chart-card:nth-child(6) { animation-delay: 300ms; }

@keyframes cardReveal {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.scatter-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.scatter-controls label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.scatter-controls select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
}

/* ====== Botão e Modal de Zoom dos Gráficos ====== */
.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.chart-card-head h3 {
  margin: 0;
}
.zoom-btn {
  border: 1px solid var(--line);
  background: #faf7f2;
  color: var(--ink);
  padding: 5px 10px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms, border-color 150ms, color 150ms;
}
.zoom-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chart-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 18, 0.65);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}
.chart-modal.open {
  display: flex;
}
.chart-modal-box {
  background: #fff;
  border-radius: 16px;
  width: 96vw;
  max-width: 1600px;
  height: 92vh;
  padding: 24px 30px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: modalPop 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.chart-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.chart-modal-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.modal-scroll-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}

.inspect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.inspect-box {
  background: #faf7f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.inspect-box small {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.palat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.palat-pill {
  background: #faf7f2;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
}
.palat-pill strong {
  color: var(--accent);
}

/* ====== Modal de Importação & Toast TCIA ====== */
.import-modal-box {
  max-width: 620px;
  height: auto;
  max-height: 85vh;
}

.import-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 12px;
  gap: 14px;
}

.import-progress-wrap {
  width: 100%;
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.import-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 220ms ease;
}

.import-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 520px) {
  .import-summary-grid { grid-template-columns: 1fr; }
}

.import-stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  background: #faf7f2;
}
.import-stat.ok {
  background: #f0f9f4;
  border-color: #b5d4b8;
  color: var(--green);
}
.import-stat.warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.import-stat.err {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--red);
}
.import-stat-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 38px;
  line-height: 1;
}
.import-stat-lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 4px;
}

.import-detail-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafaf7;
  margin-top: 10px;
  font-size: 13px;
}

.confirm-modal-box {
  width: 100%;
  max-width: 440px;
  height: auto;
  max-height: 90vh;
  padding: 24px 26px;
}
.confirm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.confirm-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--red);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.confirm-message {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn.danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn.danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

.tcia-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  border-left: 4px solid var(--accent);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 10000;
  max-width: 380px;
}
.tcia-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.tcia-toast.success { border-left-color: var(--green); }
.tcia-toast.error { border-left-color: var(--red); }

.table-scroll {
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: grab;
}
.table-scroll.dragging {
  cursor: grabbing;
  user-select: none;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: #faf7f2;
}

.data-table th[data-sort] {
  cursor: pointer;
  user-select: none;
  transition: color .15s, background .15s;
}
.data-table th[data-sort]:hover {
  color: var(--ink);
  background: #f2ece2;
}
.data-table th[data-sort].sort-active {
  color: var(--accent);
}
.data-table th .sort-ind {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.4;
}
.data-table th[data-sort]:hover .sort-ind,
.data-table th[data-sort].sort-active .sort-ind {
  opacity: 1;
}

.data-table th:last-child,
.data-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #fff;
  box-shadow: -6px 0 12px -6px rgba(0, 0, 0, 0.14);
}
.data-table th:last-child {
  z-index: 4;
  background: #faf7f2;
}
.data-table tbody tr:hover td:last-child {
  background: #fafaf7;
}

.data-table tbody tr:hover {
  background: #fafaf7;
}

.action-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  margin-right: 4px;
}
.action-btn:hover {
  border-color: var(--ink);
}
.action-btn.danger {
  color: var(--red);
  border-color: #fecaca;
}
.action-btn.danger:hover {
  background: #fef2f2;
  border-color: var(--red);
}

/* ====== Tela de verificação inicial e spinners de carregamento ====== */
.auth-loader-wrap {
  min-height: 75vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}
.auth-loader-text {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}
.spinner.sm {
  width: 18px;
  height: 18px;
  border-width: 2.5px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.panel-loading-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border-radius: 10px;
  background: #faf7f2;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  animation: cardReveal 300ms ease both;
}

/* ====== Impressão / PDF em Lote ====== */
.print-only {
  display: none;
}

@media print {
  body {
    background: #fff !important;
  }
  #view-auth-loading,
  #view-login,
  #view-dashboard {
    display: none !important;
  }
  .print-only {
    display: block !important;
    padding: 16px;
    font-family: 'Lora', Georgia, serif;
    color: #1a1a1a;
  }
  .print-header {
    border-bottom: 2px solid #c2410c;
    padding-bottom: 10px;
    margin-bottom: 18px;
  }
  .print-header h1 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 32px;
    margin: 0;
  }
  .print-kpis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0 24px;
  }
  .print-kpi {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
  }
  .print-kpi small {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    color: #666;
  }
  .print-kpi strong {
    font-size: 20px;
  }
  .print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 24px;
  }
  .print-table th,
  .print-table td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    text-align: left;
  }
  .print-table th {
    background: #f5f5f5;
  }
  .print-page-break {
    page-break-before: always;
  }
  .print-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
    page-break-inside: avoid;
  }
}
