:root {
  --primary: #1e3a8a;
  --primary-light: #f0fdf4;
  --text: #0f172a;
  --border: #cbd5e1;
  --danger: #dc2626;
  --success: #16a34a;
  --complete-blue: #1d4ed8;
  --gray-muted: #64748b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  background: #f8fafc;
  color: var(--text);
  padding-top: 125px;
}

/* AppBar */
.appbar-extended {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  padding: 8px 20px;
  z-index: 1000;
  gap: 8px;
}
.appbar-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.appbar-brand h1 {
  font-size: 1.2rem;
  color: var(--primary);
  font-weight: 700;
}
.appbar-upload {
  display: flex;
  gap: 8px;
  align-items: center;
}

.compact-dropzone {
  border: 1px dashed #94a3b8;
  padding: 5px 10px;
  border-radius: 6px;
  background: #f8fafc;
  position: relative;
  cursor: pointer;
  font-size: 0.8rem;
}
.compact-dropzone input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.btn-primary-compact {
  background: var(--primary);
  color: white;
  border: none;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.btn-export {
  background: #059669;
  color: white;
  border: none;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

/* Filtros */
.appbar-filters-row {
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 6px;
  width: 100%;
}
.f-item {
  flex: 1;
  min-width: 120px;
}
.f-item.search-w {
  flex: 2.5;
  min-width: 250px;
}
.appbar-filters-row select {
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text);
  width: 100%;
  background: #f8fafc;
  outline: none;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.search-input-wrapper input {
  width: 100%;
  padding: 5px 30px 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.8rem;
  outline: none;
}
.clear-search-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: #94a3b8;
  cursor: pointer;
}

/* Toggle */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
.switch {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 16px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.2s;
  border-radius: 16px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(14px);
}
.toggle-label {
  font-size: 0.75rem;
  color: #64748b;
}
.toggle-label.active {
  color: var(--primary);
  font-weight: bold;
}

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

/* Painel de Boas-Vindas */
.welcome-section {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  animation: fadeIn 0.4s ease-in-out;
}
.welcome-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  width: 100%;
  max-width: 950px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.welcome-card h2 {
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 8px;
  text-align: center;
}
.welcome-card .subtitle {
  color: var(--gray-muted);
  font-size: 0.95rem;
  text-align: center;
  margin-bottom: 30px;
}
.instructions-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.ins-column {
  flex: 1;
  min-width: 260px;
  background: #f8fafc;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.ins-column h3 {
  font-size: 0.95rem;
  color: #1e293b;
  margin-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 6px;
}
.ins-column ul li {
  margin-bottom: 8px;
  list-style: none;
  position: relative;
  padding-left: 12px;
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.6;
}
.ins-column ul li::before {
  content: "•";
  color: var(--primary);
  font-weight: bold;
  position: absolute;
  left: 0;
}
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.tag {
  background: #e2e8f0;
  color: #334155;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Animação do Carregamento */
.loading-section {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 20px;
}
.loader-container {
  text-align: center;
  background: white;
  border: 1px solid var(--border);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
  max-width: 450px;
  width: 100%;
}
.loader-container h3 {
  font-size: 1.1rem;
  color: var(--primary);
  margin-top: 15px;
  margin-bottom: 5px;
}
.loader-container p {
  font-size: 0.8rem;
  color: var(--gray-muted);
  line-height: 1.4;
}
.modern-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f1f5f9;
  border-top: 4px solid var(--primary);
  border-right: 4px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}
.pulse-bar {
  width: 100%;
  height: 4px;
  background: #e2e8f0;
  margin-top: 20px;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.pulse-bar::after {
  content: "";
  position: absolute;
  left: -50%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: loadingBar 1.5s infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes loadingBar {
  from {
    left: -50%;
  }
  to {
    left: 150%;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Expander Gerencial */
.robust-expander {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.expander-summary {
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  background: #f1f5f9;
  font-size: 0.85rem;
}
.robust-expander[open] .summary-chevron {
  transform: rotate(180deg);
}
.expander-content {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.dashboard-grid {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}
.metrics-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}
.mini-card {
  padding: 10px;
  border-radius: 6px;
  border-left: 4px solid #94a3b8;
  background: #f8fafc;
}
.mini-card.info {
  border-left-color: var(--primary);
}
.mini-card.danger {
  border-left-color: var(--danger);
}
.mini-card.success {
  border-left-color: var(--success);
}
.mini-card h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #64748b;
}
.mini-card p {
  font-size: 1.3rem;
  font-weight: 700;
}
.chart-container {
  flex: 2;
  max-height: 140px;
  min-width: 260px;
}

/* Tabela Wide Mínima */
.table-wrapper {
  background: white;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  text-align: left;
}
th,
td {
  padding: 3px 5px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  text-align: center;
}
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  background-color: #e2e8f0;
}
.sort-icon {
  font-size: 0.65rem;
  color: #94a3b8;
}

.bg-gray {
  background-color: #f1f5f9;
}
.bg-p1 {
  background-color: #f0fdf4;
}
.bg-p2 {
  background-color: #eff6ff;
}
.bg-p3 {
  background-color: #fffbeb;
}
.bg-danger-light {
  background-color: #fef2f2;
  font-weight: bold;
}
.badge-alert {
  color: var(--danger);
  font-weight: bold;
}

.date-subtext {
  display: block;
  font-size: 0.65rem;
  color: var(--gray-muted);
  font-weight: normal;
  margin-top: 1px;
}
.database-badge {
  display: block;
  font-size: 0.63rem;
  color: #78716c;
  font-weight: normal;
  margin-top: 1px;
}

.completou-tr {
  color: var(--complete-blue);
  font-weight: 600;
}
.check-icon {
  color: var(--success);
  margin-left: 3px;
  font-size: 0.75rem;
}

.percent-badge {
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.7rem;
}
.percent-low {
  background: #fee2e2;
  color: #b91c1c;
}
.percent-mid {
  background: #fef3c7;
  color: #d97706;
}
.percent-high {
  background: #dcfce7;
  color: #15803d;
}

.hidden {
  display: none !important;
}
