/* ============================================================
   COMPRE COMIGO — Design System (Onyx & Ouro)
   ------------------------------------------------------------
   Paleta tirada da marca: fundo preto absoluto + lettering em
   degradê metálico (bronze → ouro → champanhe). O ouro é o ÚNICO
   destaque de marca; as cores semânticas (verde/vermelho/laranja)
   existem só pra status e vêm dessaturadas pra não brigar com ele.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@700;800&display=swap');

:root {
  /* ── Onyx (o preto da marca) ── */
  --bg: #1b130b;
  --surface: #261b11;
  --surface2: #32251a;
  --border: rgba(207, 168, 114, .16);
  --text: #f5efe6;
  --text-muted: #b9a98f;
  --muted: #b9a98f;
  --subtle: #8d7d68;

  /* ── Rampa de ouro (do lettering da logo) ── */
  --gold-deep: #6c471e;
  --gold: #cfa872;
  --gold-soft: #dfc79e;
  --gold-bright: #ead8b8;
  --gold-pale: #f6eedf;
  --gold-bg: rgba(207, 168, 114, .12);
  --gold-border: rgba(207, 168, 114, .34);
  /* Varredura metálica: reproduz o brilho que corre no "Compre Comigo" */
  --gold-grad: linear-gradient(120deg, #6c471e 0%, #cfa872 26%, #f2e0ba 50%, #cfa872 74%, #6c471e 100%);

  /* Semânticas — quentes o suficiente pra conviver com o ouro */
  --blue: #7fa8c9;
  --blue-bg: rgba(127, 168, 201, .12);
  --blue-border: rgba(127, 168, 201, .3);
  --green: #57b98a;
  --green-bg: rgba(87, 185, 138, .12);
  --green-border: rgba(87, 185, 138, .3);
  --orange: #e0913f;
  --orange-bg: rgba(224, 145, 63, .12);
  --orange-border: rgba(224, 145, 63, .3);
  --red: #e0655f;
  --red-bg: rgba(224, 101, 95, .13);
  --red-border: rgba(224, 101, 95, .35);
  /* --purple é o "acento primário" herdado do template: na Compre Comigo ele É o ouro.
     Mantido com o nome antigo porque dezenas de telas já o consomem. */
  --purple: #cfa872;
  --purple-bg: rgba(207, 168, 114, .12);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --topbar-h: 60px;
}

/* ── Tema claro (Champanhe) ─────────────────────────────── */
[data-theme="light"] {
  --bg: #ede5d7;
  --surface: #fbf8f2;
  --surface2: #f3ebdf;
  --border: rgba(108, 71, 30, 0.16);
  --text: #392202;
  --text-muted: #5f452a;
  --muted: #7a5a3a;
  --subtle: #a49075;
  --shadow-card: 0 12px 32px rgba(60, 44, 20, 0.10);
  --radius-lg: 20px;

  /* No claro o ouro precisa escurecer pra ter contraste sobre champanhe —
     inclusive o degradê: o miolo claro (#f2e0ba) sumiria no fundo creme. */
  --gold: #6c471e;
  --gold-soft: #8a5a2b;
  --gold-bright: #cfa872;
  --gold-bg: rgba(108, 71, 30, .10);
  --gold-border: rgba(108, 71, 30, .3);
  --gold-grad: linear-gradient(120deg, #432f16 0%, #6c471e 26%, #cfa872 50%, #6c471e 74%, #432f16 100%);

  --blue: #3a6f96;
  --blue-bg: rgba(58, 111, 150, .10);
  --blue-border: rgba(58, 111, 150, .25);
  --green: #2e7d55;
  --green-bg: rgba(46, 125, 85, .10);
  --green-border: rgba(46, 125, 85, .25);
  --orange: #b9701f;
  --orange-bg: rgba(185, 112, 31, .10);
  --orange-border: rgba(185, 112, 31, .25);
  --red: #b3403a;
  --red-bg: rgba(179, 64, 58, .10);
  --red-border: rgba(179, 64, 58, .28);
  --purple: #6c471e;
  --purple-bg: rgba(108, 71, 30, .12);
}

/* Mesma onda, véu champanhe: no claro ela aparece bem mais que no escuro. */
[data-theme="light"] body {
  background:
    linear-gradient(rgba(239, 231, 218, .88), rgba(239, 231, 218, .88)),
    url('/img/brand/fundo-futuro.webp') center center / cover no-repeat fixed;
  background-color: var(--bg);
}

[data-theme="light"] .topbar {
  background: #14110d; /* a topbar continua ONYX nos dois temas — é a assinatura da marca */
  border-bottom-color: rgba(207, 168, 114, .28);
}
[data-theme="light"] .topbar__title {
  color: var(--gold-bright);
}
[data-theme="light"] .logo-badge {
  background: rgba(207, 168, 114, .14);
  border-color: rgba(207, 168, 114, .5);
  color: #ead8b8;
}

/* ── Theme toggle switch ────────────────────────────────── */
.theme-toggle {
  width: 54px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: #1c1a16;
  box-shadow: inset 3px 3px 6px #0b0a08, inset -3px -3px 6px #322c22;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
  margin-right: 8px;
  transition: background 0.3s, box-shadow 0.3s;
}
.theme-toggle__knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1c1a16;
  box-shadow: 2px 2px 4px #0b0a08, -2px -2px 4px #322c22;
  display: grid;
  place-items: center;
  position: absolute;
  left: 3px;
  transform: translateX(26px);
  transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), background 0.3s, box-shadow 0.3s;
  color: var(--gold);
}

[data-theme="light"] .theme-toggle {
  background: #ede5d7;
  box-shadow: inset 4px 4px 6px #cfc3ae, inset -4px -4px 6px #fffdf8;
}
[data-theme="light"] .theme-toggle__knob {
  background: #ede5d7;
  box-shadow: 3px 3px 6px #cfc3ae, -3px -3px 6px #fffdf8;
  color: #6c471e;
  transform: translateX(0);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

/* Fundo escuro: a onda dourada da marca sob um véu quase opaco de onyx —
   sobra só o reflexo do ouro no rodapé da tela, sem roubar leitura.
   (O tema claro troca o véu por champanhe lá em cima.) */
body {
  background:
    linear-gradient(rgba(10, 10, 11, .93), rgba(10, 10, 11, .93)),
    url('/img/brand/fundo-futuro.webp') center center / cover no-repeat fixed;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
}

a {
  color: inherit;
}

ul {
  list-style: none;
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--purple);
}

input::placeholder {
  color: var(--subtle);
}

select option {
  background: var(--surface);
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  /* Onyx nos dois temas + fio de ouro embaixo: é a "moldura" da marca,
     igual à faixa dourada que corta o lettering da logo. */
  background: #14110d;
  border-bottom: 1px solid rgba(207, 168, 114, .28);
  box-shadow: 0 1px 0 rgba(207, 168, 114, .10), var(--shadow-card, 0 0 0 rgba(0,0,0,0));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Monograma "RL": onyx com contorno de ouro — o selo da marca em miniatura.
   Tipografia = a mesma sans das lojas irmãs (Plus Jakarta Sans); o que
   identifica a Compre Comigo é a cor (ouro sobre onyx), não a serifa. */
.logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(207, 168, 114, .12);
  border: 1.5px solid rgba(207, 168, 114, .5);
  display: grid;
  place-items: center;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -.02em;
  color: var(--gold-bright);
  flex-shrink: 0;
}

/* Wordmark: degradê metálico recortado no texto (fallback = ouro chapado). */
.topbar__title {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--gold-bright);
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  line-height: 1.1;
}

/* No celular o nome completo quebrava em 3 linhas e estourava o topbar.
   Encurta para "Compre Comigo" via CSS (font-size:0 + ::before) e NÃO mexendo no
   HTML de propósito: financeiro.html lê .topbar__title.textContent para
   estampar o nome da loja em recibos — dividir o texto em spans faria os
   documentos saírem com o nome duplicado. Assim o DOM continua intacto.
   O !important vence os .topbar__title inline de financeiro/configuracoes. */
@media (max-width: 640px) {
  /* A saudação ("Boa tarde, Fulano!") espremia o wordmark e empurrava o botão
     de sair pra fora da tela no celular. Fora em telas estreitas — o nome de
     quem está logado não é informação de trabalho. */
  #dashGreeting, .topbar__right > span:not(.logo-badge) { display: none; }
  .topbar { padding: 0 12px; }
  .topbar .topbar__title { font-size: 0 !important; }
  .topbar .topbar__title::before {
    content: 'Compre Comigo';
    font-size: 18px !important;
    font-weight: 800;
    letter-spacing: -.02em;
    /* o degradê é repetido aqui porque o background-clip do pai não alcança
       de forma confiável o conteúdo gerado em todos os motores */
    background: var(--gold-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}

.btn-back:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(.97);
}

.btn:disabled {
  opacity: .45;
  pointer-events: none;
}

/* Botão primário = placa de ouro com texto onyx (texto branco sobre ouro
   não passa em contraste e "suja" o metal). */
.btn--primary {
  background: var(--gold-grad);
  background-size: 180% 100%;
  background-position: 30% 0;
  color: #14110d;
  font-weight: 700;
  border: 1px solid rgba(108, 71, 30, .5);
  transition: background-position .35s ease, opacity .15s, transform .1s;
}

.btn--primary:hover {
  background-position: 70% 0;
  opacity: 1;
}

.btn--success {
  background: var(--green);
  color: #fff;
}

.btn--success:hover {
  opacity: .88;
}

.btn--danger {
  background: var(--red);
  color: #fff;
}

.btn--danger:hover {
  opacity: .88;
}

.btn--ghost {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--border);
}

.btn--sm {
  padding: 7px 13px;
  font-size: 13px;
}

.btn--icon-only {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius);
}

/* ── Layout Content ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 20px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 800;
}

/* ── Search Bar ──────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-bar input {
  flex: 1;
  min-width: min(200px, 100%);
}

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

th {
  background: var(--surface2);
  color: var(--subtle);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 11px 14px;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(207, 168, 114, .07);
}

.customer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0;
}

.customer-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-empty td {
  text-align: center;
  color: var(--subtle);
  padding: 40px;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card, none);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card, none);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.stat-card__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--subtle);
  margin-bottom: 6px;
}

.stat-card__value {
  font-size: 28px;
  font-weight: 800;
}

.stat-card__sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Badge / Chip ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--blue {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue-border);
}

.badge--green {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.badge--orange {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid var(--orange-border);
}

.badge--red {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}

.badge--purple {
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid var(--gold-border);
}

/* alias semântico — mesma pílula, nome que faz sentido na marca */
.badge--gold {
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid var(--gold-border);
}

.badge--gray {
  background: rgba(168, 158, 138, .12);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .7);
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal__title {
  font-size: 17px;
  font-weight: 700;
}

.modal__body {
  overflow-y: auto;
  padding: 20px;
  flex: 1;
  scrollbar-width: thin;
}

.modal__footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: flex-end;
}

/* ── Form ────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  font-size: 12px;
  color: var(--subtle);
  margin-top: 4px;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  width: min(calc(100vw - 32px), 400px);
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
  animation: toast-in .2s ease;
}

.toast--success {
  border-color: var(--green-border);
  background: var(--green-bg);
}

.toast--error {
  border-color: var(--red-border);
  background: var(--red-bg);
}

.toast--info {
  border-color: var(--blue-border);
  background: var(--blue-bg);
}

.toast.leaving {
  animation: toast-out .2s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ── Stock pill ──────────────────────────────────────────────── */
.stock-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 0 7px;
}

.stock-pill--ok {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.stock-pill--low {
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid var(--orange-border);
}

.stock-pill--zero {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 30px 20px;
  font-size: 10px;
  font-weight: 500;
  color: var(--subtle);
  margin-top: auto;
  letter-spacing: 0.5px;
  width: 100%;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .page-content {
    padding: 12px;
  }

  .page-header h1 {
    font-size: 18px;
  }

  .modal__footer {
    flex-direction: column;
  }

  .modal__footer .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .topbar {
    padding: 0 12px;
  }

  .page-content {
    padding: 10px;
  }
}

/* ── Marca Compre Comigo — utilitários compartilhados ─────────────── */

/* Texto em ouro escovado. Aplique em títulos/valores de destaque. */
.gold-text {
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--gold-bright); /* fallback */
}

/* Fio dourado — o mesmo traço fino que emoldura o lettering da logo. */
.gold-rule {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .55;
}

/* Selo circular da marca (login/portal): a logo real sobre o disco onyx. */
.brand-mark {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #ede5d7 url('/img/brand/comprecomigo-logo.jpg') center / 108% auto no-repeat;
  border: 1px solid rgba(207, 168, 114, .45);
  box-shadow: 0 0 0 6px rgba(207, 168, 114, .06), 0 14px 40px rgba(0, 0, 0, .55);
  flex-shrink: 0;
}

::selection {
  background: rgba(207, 168, 114, .3);
  color: var(--text);
}

/* Barras de rolagem discretas em ouro (só onde o motor suporta) */
* {
  scrollbar-color: rgba(207, 168, 114, .35) transparent;
}