/* Componentes reutilizáveis + pequena camada de utilitários de layout,
   substituindo o Tailwind por classes escritas à mão (sem build step). */

/* -------------------- Utilitários de layout -------------------- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 1rem; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.8125rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.375rem; }
.text-2xl { font-size: 1.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-muted { color: var(--text-secondary); }
.text-faint { color: var(--text-muted); }
.text-brand { color: rgb(var(--brand-600)); }
.text-danger { color: rgb(var(--red-600)); }
.text-success { color: rgb(var(--green-700)); }
.text-warning { color: rgb(var(--amber-700)); }
.line-through { text-decoration: line-through; }

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

/* -------------------- Cartão -------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}
.card-tint-brand { background: rgb(var(--brand-50)); }
[data-theme='dark'] .card-tint-brand { background: rgba(var(--brand-950), 0.4); }

/* -------------------- Botões -------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: rgb(var(--brand-600)); color: #fff; }
.btn-primary:hover:not(:disabled) { background: rgb(var(--brand-700)); }

.btn-secondary { background: var(--surface-muted); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-muted); }

.btn-danger { background: rgb(var(--red-600)); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; }
.btn-icon { padding: 0.5rem; }

/* -------------------- Formulários -------------------- */
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-size: 0.75rem; font-weight: 500; color: var(--text-secondary); }

.input, select.input, textarea.input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.8125rem;
  background: var(--surface);
  color: var(--text-primary);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: 2px solid rgb(var(--brand-400));
  outline-offset: 1px;
  border-color: rgb(var(--brand-500));
}
textarea.input { resize: vertical; min-height: 4.5rem; }

.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; }

.form-error { font-size: 0.75rem; color: rgb(var(--red-600)); }

/* -------------------- Tabela -------------------- */
.table-wrap { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
thead { background: var(--surface-muted); text-align: left; }
th, td { padding: 0.6rem 1rem; }
tbody tr { border-top: 1px solid var(--border); }

/* -------------------- Badge de status -------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 500;
}
.badge-gray { background: var(--surface-muted); color: var(--text-secondary); }
.badge-blue { background: rgb(var(--brand-50)); color: rgb(var(--brand-700)); }
.badge-green { background: rgb(var(--green-50)); color: rgb(var(--green-700)); }
.badge-amber { background: rgb(var(--amber-50)); color: rgb(var(--amber-700)); }
.badge-red { background: #fef2f2; color: rgb(var(--red-600)); }
[data-theme='dark'] .badge-blue { background: rgba(var(--brand-950), 0.5); }
[data-theme='dark'] .badge-green { background: rgba(var(--green-950), 0.5); }
[data-theme='dark'] .badge-amber { background: rgba(var(--amber-950), 0.5); }

/* -------------------- Modal -------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-lg { max-width: 48rem; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  padding: 1rem 1.25rem; border-top: 1px solid var(--border);
}

/* -------------------- Toast -------------------- */
#toast-root {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 100;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  border-left: 3px solid rgb(var(--brand-600));
  max-width: 20rem;
}
.toast-error { border-left-color: rgb(var(--red-600)); }
.toast-success { border-left-color: rgb(var(--green-600)); }

/* -------------------- Spinner -------------------- */
.spinner {
  width: 1.25rem; height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: rgb(var(--brand-600));
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------- Paginação -------------------- */
.pagination { display: flex; align-items: center; gap: 0.35rem; justify-content: center; }
.pagination button {
  min-width: 2rem; height: 2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.8125rem;
}
.pagination button.active { background: rgb(var(--brand-600)); border-color: rgb(var(--brand-600)); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* -------------------- Ícones (Tabler, via CDN) -------------------- */
.icon { font-size: 1rem; line-height: 1; vertical-align: -2px; }
