/* ============================================================ BOTÕES ==== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 var(--s-4);
  min-height: 42px;
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
              transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn .icon { flex: none; }

.btn-primary {
  background: var(--brand-500);
  color: #fff;
  box-shadow: var(--sh-1);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-900);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-200); background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover:not(:disabled) { background: var(--brand-50); color: var(--brand-700); }

.btn-danger { background: var(--danger-50); color: var(--danger-500); border-color: #f6d5cf; }
.btn-danger:hover:not(:disabled) { background: #fbe0da; }

.btn-sm { min-height: 34px; padding: 0 var(--s-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { min-height: 50px; padding: 0 var(--s-5); font-size: var(--fs-body); }
.btn-block { width: 100%; }

.btn-icon {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-700);
}
.btn-icon:hover { background: var(--brand-50); color: var(--brand-700); }

/* Ação em texto — para links secundários dentro de cards. */
.text-action {
  background: none;
  border: 0;
  padding: 0;
  color: var(--brand-700);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-action:hover { color: var(--brand-500); }

/* ============================================================= CARDS ==== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  min-width: 0;
}
.card-flush { padding: 0; overflow: hidden; }
.card-quiet { background: var(--surface-2); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.card-head h2 { font-size: var(--fs-h3); }
.card-head p { margin-top: var(--s-1); color: var(--ink-500); font-size: var(--fs-xs); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.section-head h2 { font-size: var(--fs-h2); }
.section-head p { margin-top: var(--s-1); color: var(--ink-500); font-size: var(--fs-sm); }

/* ============================================================ BADGES ==== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--r-full);
  padding: 3px 9px;
  font-size: var(--fs-2xs);
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-neutral { background: var(--line-soft); color: var(--ink-500); }
.badge-brand   { background: var(--brand-50); color: var(--brand-700); }
.badge-gold    { background: var(--gold-50); color: var(--gold-600); }
.badge-ok      { background: var(--ok-50); color: var(--ok-500); }
.badge-warn    { background: var(--warn-50); color: var(--warn-500); }
.badge-danger  { background: var(--danger-50); color: var(--danger-500); }
.badge-info    { background: var(--info-50); color: var(--info-500); }

.badge-dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ========================================================= FORMULÁRIO === */
.field { display: grid; gap: 6px; min-width: 0; }
.field > .label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-700);
}
.field > .hint { font-size: var(--fs-2xs); color: var(--ink-500); line-height: 1.45; }
.field > .error { font-size: var(--fs-2xs); color: var(--danger-500); font-weight: 700; }

.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px var(--s-3);
  min-height: 42px;
  font-size: var(--fs-sm);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: var(--focus);
}
.input[aria-invalid="true"] { border-color: var(--danger-500); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }

.select {
  appearance: none;
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237a655c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
}

.search-field { position: relative; }
.search-field .icon {
  position: absolute;
  left: var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  pointer-events: none;
}
.search-field .input { padding-left: 38px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.check input { accent-color: var(--brand-500); width: 17px; height: 17px; margin-top: 1px; flex: none; }

/* Cartões selecionáveis (onboarding, canais, estilos). */
.choice {
  display: grid;
  gap: 3px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  min-height: 54px;
  align-content: center;
  font-size: var(--fs-sm);
  font-weight: 700;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.choice small { font-weight: 500; font-size: var(--fs-2xs); color: var(--ink-500); line-height: 1.4; }
.choice:hover { border-color: var(--brand-200); }
.choice[aria-pressed="true"], .choice.selected {
  border-color: var(--brand-500);
  background: var(--brand-50);
  color: var(--brand-700);
}
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-2); }

/* ============================================================== TABS ==== */
.tabs {
  display: flex;
  gap: var(--s-1);
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-4);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  padding: 10px var(--s-3);
  color: var(--ink-500);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink-900); }
.tabs button[aria-selected="true"] { color: var(--brand-700); border-color: var(--brand-500); }

.chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  padding: 6px var(--s-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-700);
}
.chip:hover { border-color: var(--brand-200); }
.chip[aria-pressed="true"] { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }

/* ============================================================ MODAL ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(30, 18, 14, 0.42);
  display: flex;
  padding: var(--s-4);
  animation: fade 0.14s var(--ease);
}
.overlay-center { align-items: center; justify-content: center; }
.overlay-right { align-items: stretch; justify-content: flex-end; padding: 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }

.modal {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - var(--s-8));
  overflow: auto;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  animation: riseIn 0.18s var(--ease);
}
.modal-lg { width: min(880px, 100%); }

.drawer {
  position: relative;
  width: min(520px, 100%);
  max-height: 100vh;
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--sh-3);
  animation: slideIn 0.2s var(--ease);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: var(--s-5) var(--s-5) var(--s-4);
}
.modal-head p { margin-top: var(--s-1); color: var(--ink-500); font-size: var(--fs-xs); }
.modal-body { padding: var(--s-5); }
.modal-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: var(--s-4) var(--s-5);
}

.modal-close {
  flex: none;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-500);
}
.modal-close:hover { background: var(--brand-50); color: var(--brand-700); }

body.locked { overflow: hidden; }

/* ============================================================ TOAST ===== */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: var(--s-6);
  transform: translateX(-50%);
  z-index: 90;
  display: grid;
  gap: var(--s-2);
  width: min(420px, calc(100vw - var(--s-8)));
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--ink-900);
  color: #fff;
  border-radius: var(--r-md);
  padding: 11px var(--s-4);
  font-size: var(--fs-xs);
  font-weight: 600;
  box-shadow: var(--sh-3);
  animation: riseIn 0.18s var(--ease);
}
.toast-ok .icon { color: #6ee7a8; }
.toast-warn .icon { color: var(--gold-400); }

/* ========================================================= SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, var(--line-soft) 25%, #fff 50%, var(--line-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card { height: 296px; border-radius: var(--r-lg); }
.skeleton-line { height: 12px; }

/* ====================================================== EMPTY STATE ===== */
.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: var(--s-2);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-10) var(--s-6);
}
.empty .empty-icon {
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  background: var(--brand-50);
  color: var(--brand-500);
  margin-bottom: var(--s-1);
}
.empty h3 { font-size: var(--fs-h3); }
.empty p { color: var(--ink-500); font-size: var(--fs-sm); max-width: 42ch; }
.empty .btn { margin-top: var(--s-2); }

/* =========================================================== AVATAR ===== */
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--brand-500);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.02em;
  overflow: hidden;
}
.avatar-lg { width: 72px; height: 72px; font-size: var(--fs-h2); }

/* ========================================================== TOOLTIP ===== */
.tip { position: relative; display: inline-flex; }
.tip > .tip-text {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  max-width: 230px;
  background: var(--ink-900);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: var(--fs-2xs);
  font-weight: 500;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s var(--ease);
}
.tip:hover > .tip-text,
.tip:focus-within > .tip-text { opacity: 1; }

/* ====================================================== BANNER/NOTA ===== */
.note {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--ink-700);
}
.note .icon { flex: none; color: var(--ink-400); margin-top: 1px; }
.note strong { display: block; color: var(--ink-900); }
.note-info { background: var(--info-50); border-color: #dbe4ff; }
.note-info .icon { color: var(--info-500); }
.note-warn { background: var(--warn-50); border-color: var(--gold-200); }
.note-warn .icon { color: var(--warn-500); }

/* ===================================================== CARD PRODUTO ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(226px, 1fr));
  gap: var(--s-4);
}

.product-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  min-width: 0;
  transition: border-color 0.15s var(--ease), box-shadow 0.18s var(--ease),
              transform 0.18s var(--ease);
}
.product-card:hover {
  border-color: var(--brand-200);
  box-shadow: var(--sh-2);
  transform: translateY(-2px);
}

.product-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--brand-50);
  overflow: hidden;
}
.product-media img { width: 100%; height: 100%; object-fit: cover; }

.product-flags {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.product-fav {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink-500);
  box-shadow: var(--sh-1);
}
.product-fav:hover { color: var(--brand-500); }
.product-fav[aria-pressed="true"] { color: var(--brand-500); }

.product-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  flex: 1;
}
.product-cat {
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--ink-400);
  letter-spacing: 0.02em;
}
.product-name {
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-price { display: flex; align-items: baseline; gap: var(--s-2); flex-wrap: wrap; }
.product-price strong {
  font-size: var(--fs-h3);
  letter-spacing: var(--track-tight);
  font-variant-numeric: tabular-nums;
}
.product-price del { color: var(--ink-400); font-size: var(--fs-xs); }

.product-meta {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  font-size: var(--fs-2xs);
  color: var(--ink-500);
}
.product-actions { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-1); }
.product-actions .btn { width: 100%; }

/* Score de oportunidade — cálculo local, sempre rotulado como tal. */
.score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  padding: 3px 10px 3px 4px;
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--ink-500);
}
.score b {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: var(--r-full);
  font-size: var(--fs-2xs);
  font-variant-numeric: tabular-nums;
}
.score-high b { background: var(--ok-50); color: var(--ok-500); }
.score-mid b  { background: var(--gold-50); color: var(--gold-600); }
.score-low b  { background: var(--line-soft); color: var(--ink-500); }
.score-none { color: var(--ink-400); font-weight: 600; }

/* ========================================================== MÉTRICAS ==== */
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); }
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.metric .label { display: flex; align-items: center; gap: 6px; color: var(--ink-500); font-size: var(--fs-2xs); font-weight: 700; }
.metric .value {
  display: block;
  margin-top: var(--s-2);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: var(--track-display);
  font-variant-numeric: tabular-nums;
}
.metric .value.pending { font-size: var(--fs-h3); color: var(--ink-400); letter-spacing: 0; }

@media (max-width: 720px) {
  .metric-row { grid-template-columns: repeat(2, 1fr); }
}
