/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: 600;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn--primary   { background: var(--brand); color: #fff; }
.btn--primary:hover:not(:disabled)   { background: var(--brand-hover); }
.btn--secondary { background: var(--surface); color: var(--text-1); border-color: var(--border); }
.btn--secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-2); }
.btn--ghost     { background: transparent; color: var(--text-2); }
.btn--ghost:hover:not(:disabled)     { background: var(--surface-2); color: var(--text-1); }
.btn--danger    { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled)    { background: #D53129; }
.btn--sm  { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); }
.btn--lg  { padding: var(--sp-3) var(--sp-6); font-size: var(--fs-md); }
.btn--full{ width: 100%; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-sm);
}
.card__title    { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--sp-2); }
.card__subtitle { color: var(--text-2); font-size: var(--fs-sm); margin-bottom: var(--sp-4); }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-4);
}

/* KPI */
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-2);
  text-decoration: none; color: inherit; transition: transform var(--t-fast);
}
a.kpi:hover { transform: translateY(-2px); border-color: var(--brand-light); }
.kpi__label { font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; font-weight: 600; letter-spacing: .05em; }
.kpi__value { font-size: var(--fs-2xl); font-weight: 700; min-height: 32px; }
.kpi__value--empty { color: var(--text-3); font-size: var(--fs-md); font-style: italic; font-weight: 400; }

/* Forms */
.form-field { margin-bottom: var(--sp-4); }
.form-label {
  display: block; font-size: var(--fs-sm); font-weight: 600;
  margin-bottom: var(--sp-1);
}
.form-label--required::after { content: ' *'; color: var(--danger); }
.form-hint  { font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--sp-1); }
.form-error { font-size: var(--fs-xs); color: var(--danger); margin-top: var(--sp-1); }

.input, .textarea, .select {
  width: 100%; padding: var(--sp-2) var(--sp-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: var(--fs-base);
  transition: border var(--t-fast), box-shadow var(--t-fast);
  outline: none; min-height: 40px;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
.input:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
.input.has-error { border-color: var(--danger); }
.textarea { min-height: 96px; resize: vertical; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-2); font-size: var(--fs-xs); font-weight: 600;
  border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2);
}
.badge--success { background: var(--success-light); color: var(--success); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--danger  { background: var(--danger-light);  color: var(--danger); }
.badge--info    { background: var(--info-light);    color: var(--info); }
.badge--brand   { background: var(--brand-light);   color: var(--brand); }

/* Empty state */
.empty {
  padding: var(--sp-10) var(--sp-6); text-align: center;
  border: 1px dashed var(--border-2); border-radius: var(--r-lg);
  background: var(--surface);
}
.empty__icon { font-size: 40px; margin-bottom: var(--sp-3); opacity: .6; }
.empty__title { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--sp-1); }
.empty__msg { color: var(--text-2); font-size: var(--fs-sm); max-width: 360px; margin: 0 auto var(--sp-4); }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, #E9EBEE 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.4s infinite;
  border-radius: var(--r-sm);
  height: 16px;
}
@keyframes skeleton-shine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast */
.toast-container {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 9999;
  display: flex; flex-direction: column; gap: var(--sp-2); pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--info); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: var(--sp-3) var(--sp-4);
  min-width: 280px; max-width: 360px;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  pointer-events: auto; animation: toast-in .25s ease;
}
.toast--success { border-left-color: var(--success); }
.toast--warning { border-left-color: var(--warning); }
.toast--danger  { border-left-color: var(--danger); }
.toast__title { font-size: var(--fs-sm); font-weight: 600; }
.toast__msg   { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }
.toast__close { color: var(--text-3); font-size: var(--fs-lg); line-height: 1; padding: 0; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,.55);
  z-index: 9990; display: none;
  align-items: center; justify-content: center; padding: var(--sp-4);
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 480px; max-height: 90vh;
  display: flex; flex-direction: column; z-index: 9991;
  animation: modal-in .2s ease;
}
.modal--lg { max-width: 720px; }
.modal--xl { max-width: 960px; }
.modal__header {
  padding: var(--sp-5); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal__title { font-size: var(--fs-lg); font-weight: 600; }
.modal__close { color: var(--text-3); font-size: 24px; padding: var(--sp-1); border-radius: var(--r-sm); }
.modal__close:hover { background: var(--surface-2); color: var(--text-1); }
.modal__body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.modal__footer {
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--sp-2);
}
@keyframes modal-in {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Alerts */
.alert {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  font-size: var(--fs-sm);
  display: flex; align-items: flex-start; gap: var(--sp-2);
  border: 1px solid transparent;
}
.alert--success { background: var(--success-light); color: var(--success); border-color: var(--success); }
.alert--warning { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.alert--danger  { background: var(--danger-light);  color: var(--danger);  border-color: var(--danger); }
.alert--info    { background: var(--info-light);    color: var(--info);    border-color: var(--info); }

/* Table */
.table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border-radius: var(--r-lg); overflow: hidden;
}
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: var(--fs-base); }
.table th {
  background: var(--surface-2); font-weight: 600; font-size: var(--fs-xs);
  color: var(--text-2); text-transform: uppercase; letter-spacing: .03em;
}
.table tr:hover td { background: var(--brand-lighter); }
@media (max-width: 600px) {
  .table thead { display: none; }
  .table tr {
    display: block; background: var(--surface); margin-bottom: 12px;
    border-radius: var(--r-lg); padding: 12px; border: 1px solid var(--border);
  }
  .table td { display: flex; justify-content: space-between; border: 0; padding: 6px 0; }
  .table td::before { content: attr(data-label); color: var(--text-3); font-weight: 600; }
}

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.spinner--lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
