/* ============================================================================
 * No Alvo Promoções — sistema de design
 * ============================================================================
 *
 * Sem build step e sem CDN: a CSP da aplicação (SecurityHeaders) permite
 * apenas `style-src 'self'`, então todo estilo vive aqui e nenhum atributo
 * `style=` aparece nas views. Ícones são um sprite SVG inline.
 *
 * Paleta: instância de referência do design system, validada para superfície
 * clara e escura. Os slots categóricos (--series-N) são usados em ordem fixa
 * pelo gráfico de preços.
 * ========================================================================= */

/* ---------------------------------------------------------------- tokens -- */

:root {
  color-scheme: light;

  /* superfícies e tinta */
  --page: #f6f6f4;
  --surface-1: #ffffff;
  --surface-2: #fbfbfa;
  --surface-3: #f1f1ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --border: #e6e5e0;
  --border-strong: #d4d3cc;
  --chart-grid: #e1e0d9;

  /* acento — vermelho do alvo da logo, escurecido para texto branco passar
     de 4.5:1 de contraste */
  --accent: #c93a1a;
  --accent-hover: #ad3115;
  --accent-soft: #fdefea;
  --accent-border: #f7d0c4;
  --on-accent: #ffffff;

  /* estados */
  --good: #0ca30c;
  --good-soft: #eaf7ea;
  --warning: #fab219;
  --warning-soft: #fdf4e3;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-soft: #fbecec;

  /* séries do gráfico (ordem fixa, nunca ciclada) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  /* forma e movimento */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(11, 11, 11, 0.05);
  --shadow: 0 1px 3px rgba(11, 11, 11, 0.07), 0 8px 24px -12px rgba(11, 11, 11, 0.12);
  --shadow-lg: 0 2px 6px rgba(11, 11, 11, 0.07), 0 16px 48px -16px rgba(11, 11, 11, 0.18);
  --ring: 0 0 0 3px rgba(201, 58, 26, 0.25);
  --ease: cubic-bezier(0.2, 0, 0, 1);

  --sidebar-w: 248px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #151514;
    --surface-3: #232322;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --border: #2c2c2a;
    --border-strong: #3d3d3a;
    --chart-grid: #2c2c2a;

    --accent: #ef6a45;
    --accent-hover: #f3866a;
    --accent-soft: #2e1710;
    --accent-border: #5c2617;
    --on-accent: #1a0904;

    --good-soft: #12240f;
    --warning-soft: #2a2008;
    --critical-soft: #2d1414;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 16px 48px -16px rgba(0, 0, 0, 0.7);
    --ring: 0 0 0 3px rgba(239, 106, 69, 0.35);
  }
}

/* ----------------------------------------------------------------- reset -- */

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

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.12s var(--ease);
}
a:hover { color: var(--accent-hover); }

code, kbd, samp {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface-3);
  padding: 0.1em 0.38em;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

svg.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
svg.icon-sm { width: 15px; height: 15px; }
svg.icon-lg { width: 22px; height: 22px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------- estrutura */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  color: var(--text-primary);
}
.sidebar-brand:hover { color: var(--text-primary); }

.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  display: block;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 640; letter-spacing: -0.01em; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }

.nav-group + .nav-group { margin-top: 18px; }

.nav-label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.nav-item + .nav-item { margin-top: 1px; }
.nav-item:hover { background: var(--surface-3); color: var(--text-primary); }
.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 560;
}
.nav-item[aria-current="page"] svg { stroke-width: 2; }

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--surface-3);
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-footer { border-top: 1px solid var(--border); padding: 12px; }

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--text-secondary);
  min-width: 0;
}
.account:hover { background: var(--surface-3); color: var(--text-primary); }
.account[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.account-info { min-width: 0; line-height: 1.3; }
.account-name {
  font-size: 13px;
  font-weight: 560;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-role { font-size: 11px; color: var(--text-muted); }

.sidebar-toggle {
  display: inline-flex;
  padding: 6px;
  margin-left: -6px;
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.sidebar-toggle:hover { background: var(--surface-3); color: var(--text-primary); }

/* menu recolhido (só no desktop): vira uma faixa com os ícones */
@media (min-width: 901px) {
  .sidebar { transition: width 0.18s var(--ease); }

  body.nav-collapsed .sidebar { width: 68px; }
  body.nav-collapsed .sidebar-brand { padding: 18px 18px 14px; justify-content: center; }
  body.nav-collapsed .brand-text,
  body.nav-collapsed .nav-text,
  body.nav-collapsed .account-info { display: none; }
  body.nav-collapsed .sidebar-nav { padding: 6px 10px 16px; overflow-x: hidden; }
  body.nav-collapsed .nav-label {
    font-size: 0;
    padding: 0;
    margin: 0 8px 8px;
    border-top: 1px solid var(--border);
  }
  body.nav-collapsed .nav-group:first-child .nav-label { border-top: 0; }
  body.nav-collapsed .nav-item { justify-content: center; padding: 9px 0; position: relative; }
  body.nav-collapsed .nav-count {
    position: absolute;
    top: 2px;
    right: 4px;
    margin: 0;
    padding: 0 5px;
    font-size: 10px;
    background: var(--accent);
    color: var(--on-accent);
  }
  body.nav-collapsed .sidebar-footer { padding: 12px 10px; }
  body.nav-collapsed .account { justify-content: center; padding: 7px 0; }
}

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  height: 60px;
  background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 620;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Ocupa toda a largura: as grades (auto-fill) ganham colunas em telas largas
   em vez de deixar uma faixa vazia à direita. */
main { padding: 24px 28px 64px; width: 100%; }

.page-intro {
  color: var(--text-secondary);
  max-width: 68ch;
  margin-bottom: 22px;
}

.section { margin-top: 30px; }
.section:first-child { margin-top: 0; }

/* barra de salvar presa ao rodapé da tela em formulários longos */
.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding: 12px 0;
  background: var(--page);
  border-top: 1px solid var(--border);
}
.save-bar .hint { font-size: 13px; color: var(--text-muted); margin-right: auto; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 14.5px; font-weight: 620; letter-spacing: -0.01em; }
.section-head p { font-size: 13px; color: var(--text-muted); }
.section-head .spacer { margin-left: auto; }

/* ----------------------------------------------------------------- grades */

.grid { display: grid; gap: 14px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ---------------------------------------------------------------- cartões */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 620; letter-spacing: -0.01em; }
.card-head p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.card-head .spacer { margin-left: auto; }
.card-head-icon {
  width: 32px; height: 32px; flex: none;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-secondary);
  display: grid; place-items: center;
}

.card + .card,
form + .card,
.card + form,
form + form { margin-top: 14px; }

/* Dentro de uma grade o espaçamento vem do `gap`; a margem acima
   desalinharia todo cartão que não é o primeiro da linha. */
.grid > .card,
.grid > form { margin-top: 0; }

.card-body { padding: 18px; }
.card-body + .card-body { border-top: 1px solid var(--border); }
.card-body > p { color: var(--text-secondary); max-width: 74ch; }
.card-body > p + p { margin-top: 10px; }
.card-body > .notice:last-child { margin-bottom: 0; }
.card-body[hidden] { display: none; }

.card-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.card-foot .hint {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 60ch;
  margin-right: auto; /* empurra os botões para a direita */
}
.card-foot .spacer { margin-left: auto; }
.card-foot form { display: inline-flex; }

/* Rótulo com insígnia ao lado (campos de credencial). */
label .badge { margin-left: 6px; font-weight: 500; }

/* --------------------------------------------------------- stat / métrica */

.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 17px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-label svg { width: 14px; height: 14px; }
.stat-value {
  font-size: 26px;
  font-weight: 640;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-top: 8px;
}
.stat-note { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

/* --------------------------------------------------------- card de oferta */

.offer { display: flex; flex-direction: column; padding: 17px 18px; }
.offer-source {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.offer-source .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.offer h3 {
  font-size: 14px;
  font-weight: 580;
  line-height: 1.4;
  letter-spacing: -0.005em;
  margin-bottom: 10px;
}
.offer h3 a { color: var(--text-primary); }
.offer h3 a:hover { color: var(--accent); }
.offer-price {
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.offer-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.offer-foot {
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-variant-numeric: tabular-nums;
  font-weight: 560;
}
.delta svg { width: 13px; height: 13px; }
.delta-down { color: var(--good); }
.delta-up { color: var(--critical); }

/* --------------------------------------------------------------- insígnias */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 560;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
}
.badge svg { width: 12px; height: 12px; }

/* O ponto colorido acompanha SEMPRE um rótulo em texto: a classificação
   nunca é comunicada só por cor. */
.badge-dot::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}

.badge-OFERTA_EXCELENTE { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge-OFERTA_EXCELENTE::before { background: var(--good); }
.badge-BOM_PRECO { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-BOM_PRECO::before { background: var(--accent); }
.badge-PRECO_NORMAL::before { background: var(--text-muted); }
.badge-PROMOCAO_DUVIDOSA { background: var(--warning-soft); color: #8a5e00; border-color: transparent; }
.badge-PROMOCAO_DUVIDOSA::before { background: var(--warning); }
.badge-POSSIVEL_FALSA_PROMOCAO { background: var(--critical-soft); color: var(--critical); border-color: transparent; }
.badge-POSSIVEL_FALSA_PROMOCAO::before { background: var(--critical); }

.badge-ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge-ok::before { background: var(--good); }
.badge-off { background: var(--critical-soft); color: var(--critical); border-color: transparent; }
.badge-off::before { background: var(--critical); }
.badge-pending { background: var(--warning-soft); color: #8a5e00; border-color: transparent; }
.badge-pending::before { background: var(--warning); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-PROMOCAO_DUVIDOSA,
  :root:not([data-theme="light"]) .badge-pending { color: var(--warning); }
}

.score {
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------- tabelas */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}
.card > .table-wrap { border: 0; border-radius: 0; box-shadow: none; }

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

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 640;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s var(--ease); }
tbody tr:hover { background: var(--surface-2); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * + * { margin-left: 6px; }

.row-muted td { color: var(--text-muted); }
.cell-strong { font-weight: 560; color: var(--text-primary); }
.cell-sub { font-size: 12px; color: var(--text-muted); }

/* ------------------------------------------------------------ formulários */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

label, .label {
  display: block;
  font-size: 12.5px;
  font-weight: 560;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.field-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }
.field-error { font-size: 12.5px; color: var(--critical); margin-top: 5px; font-weight: 500; }

input[type="text"], input[type="search"], input[type="email"],
input[type="password"], input[type="number"], input[type="url"],
input[type="tel"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
  appearance: none;
}

select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23898781' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-3);
  color: var(--text-muted);
  cursor: not-allowed;
}

input[aria-invalid="true"] { border-color: var(--critical); }

.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group input, .input-group select { flex: 1; min-width: 0; }

.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .field { margin-bottom: 0; }
.form-grid .field-wide { grid-column: 1 / -1; }
.form-grid + .field, .form-grid + .check { margin-top: 16px; }
.field + .check { margin-top: 16px; }

.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 170px; margin-bottom: 0; }

.inline-form { display: inline-flex; gap: 6px; align-items: center; vertical-align: middle; }

/* Selects dentro de tabela/cabeçalho dimensionam pelo conteúdo: com largura
   fixa, rótulos como "A cada 30 minutos" ficavam cortados. */
.inline-form select {
  width: auto;
  min-width: 11.5rem;
  font-size: 13px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}
.check input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.check-text { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.check-text span { display: block; font-weight: 400; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* --------------------------------------------------------------- botões */

.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease), opacity 0.12s var(--ease);
}
.btn:hover, button:hover { background: var(--accent-hover); color: var(--on-accent); }

.btn-secondary {
  background: var(--surface-1);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-3); color: var(--text-primary); }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text-primary); }

.btn-danger { background: var(--critical); }
.btn-danger:hover { background: #b93333; }

.btn-danger-quiet {
  background: transparent;
  color: var(--critical);
  border-color: var(--border-strong);
}
.btn-danger-quiet:hover { background: var(--critical-soft); color: var(--critical); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; gap: 5px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }

.btn:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------------- avisos */

.notice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--text-primary);
  margin-bottom: 18px;
  font-size: 13.5px;
  line-height: 1.55;
}
.notice svg { color: var(--accent); margin-top: 1px; }
.notice-body { min-width: 0; flex: 1; }
.notice-body strong { font-weight: 620; }
.notice-body a { text-decoration: underline; }

.notice-warn { border-color: #f0dca8; background: var(--warning-soft); }
.notice-warn svg { color: #b07d00; }

.notice-error { border-color: #f0c4c4; background: var(--critical-soft); }
.notice-error svg { color: var(--critical); }

.notice-success { border-color: #bfe6bf; background: var(--good-soft); }
.notice-success svg { color: var(--good); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .notice-warn { border-color: #4a3a10; }
  :root:not([data-theme="light"]) .notice-warn svg { color: var(--warning); }
  :root:not([data-theme="light"]) .notice-error { border-color: #4a1f1f; }
  :root:not([data-theme="light"]) .notice-success { border-color: #1d3a19; }
}

.errors { font-size: 13.5px; }
.errors li { padding-left: 14px; position: relative; }
.errors li::before { content: "·"; position: absolute; left: 4px; }
.errors li + li { margin-top: 2px; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 42px 28px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.empty svg { width: 26px; height: 26px; color: var(--border-strong); stroke-width: 1.4; }
.empty strong { color: var(--text-secondary); font-weight: 560; font-size: 14px; }
.empty p { font-size: 13px; max-width: 46ch; }

/* ------------------------------------------------- tendência (sparkline) */

.trend { display: flex; align-items: center; gap: 10px; }

.spark {
  width: 104px;
  height: 30px;
  flex: none;
  display: block;
}

.trend-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}
.trend-value svg { width: 14px; height: 14px; }

@media (max-width: 860px) {
  .spark { width: 72px; }
}

/* --------------------------------------------------------------- gráfico */

.chart { width: 100%; height: auto; display: block; }
.chart-tick { font: 11px var(--font); fill: var(--text-muted); }
.chart-label { font: 12px var(--font); font-weight: 560; fill: var(--text-secondary); }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend-1 { background: var(--series-1); }
.legend-2 { background: var(--series-2); }
.legend-3 { background: var(--series-3); }
.legend-4 { background: var(--series-4); }
.legend-5 { background: var(--series-5); }
.legend-6 { background: var(--series-6); }
.legend-7 { background: var(--series-7); }
.legend-8 { background: var(--series-8); }

/* ----------------------------------------------------- telas de acesso */

.auth-wrap {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -14%, var(--accent-soft), transparent 70%),
    var(--page);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px;
}

.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .brand-mark { width: 64px; height: 64px; margin: 0 auto 14px; }
.auth-head h1 { font-size: 19px; font-weight: 640; letter-spacing: -0.02em; }
.auth-head p { font-size: 13.5px; color: var(--text-secondary); margin-top: 6px; }

.auth-foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* código de 6 dígitos */
.code-input {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 640;
  text-align: center;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  padding: 13px 11px;
}

.resend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.resend-row form { display: inline-flex; }

/* ----------------------------------------------------- abas (configurações) */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  overflow-x: auto;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  font-size: 13.5px;
  font-weight: 540;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 580; }

/* ------------------------------------------------------- lista descritiva */

.kv { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 8px 18px; font-size: 13.5px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text-primary); }

/* ------------------------------------------------------------- paginação */

.pagination {
  display: flex;
  gap: 5px;
  margin: 18px 0 0;
  flex-wrap: wrap;
  font-size: 13px;
}
.pagination li span,
.pagination li a {
  display: block;
  min-width: 32px;
  text-align: center;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
}
.pagination li a:hover { background: var(--surface-3); color: var(--text-primary); }
.pagination .active span { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.pagination .disabled span { opacity: 0.4; }

/* ---------------------------------------------------------------- responsivo */

@media (max-width: 900px) {
  .shell { flex-direction: column; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 0.2s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }

  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(11, 11, 11, 0.45);
    z-index: 35;
  }

  .topbar { padding: 0 16px; }
  main { padding: 18px 16px 48px; }
}

@media (max-width: 560px) {
  .topbar-actions .btn-label { display: none; }
  .offer-price { font-size: 21px; }
  .stat-value { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* -------------------------------------------------- curadoria e publicação */

a.stat { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.stat:hover { border-color: var(--accent-border); }

.badge-danger { background: var(--critical-soft); color: var(--critical); border-color: transparent; }
.badge-danger::before { background: var(--critical); }
.badge-muted { background: var(--surface-3); color: var(--text-secondary); border-color: transparent; }
.badge-muted::before { background: var(--text-muted); }

/* Situação dos envios no topo de toda página: pausado precisa saltar aos olhos. */
.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 560;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
  text-decoration: none;
}
.topbar-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.topbar-status.is-on::before { background: var(--good); }
.topbar-status.is-off { background: var(--warning-soft); border-color: transparent; color: #8a5e00; }
.topbar-status.is-off::before { background: var(--warning); }

.thumb {
  width: 48px; height: 48px;
  flex: none;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
}
.thumb-lg { width: 112px; height: 112px; border-radius: 12px; }
.thumb-empty { display: inline-grid; place-items: center; color: var(--text-muted); background: var(--surface-2); }
.thumb-empty svg { width: 18px; height: 18px; }

.product-cell { display: flex; gap: 11px; align-items: center; min-width: 240px; }
.product-cell .cell-strong { display: block; }
.product-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.product-head h2 { font-size: 16px; font-weight: 620; letter-spacing: -0.01em; line-height: 1.35; }

.reasons { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--text-muted); }
.reasons li { margin-top: 2px; }
.reasons .is-flag { color: #8a5e00; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chips a { text-decoration: none; }
.chips .badge { padding: 4px 10px; font-size: 12.5px; }
.chips a[aria-current="true"] .badge { outline: 2px solid var(--accent); outline-offset: 1px; }

.message-preview {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  line-height: 1.55;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 15px;
  margin: 0;
}

.search-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.search-last { font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; }
.source-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.source-picks .check { padding: 8px 11px; }

.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.rank li:last-child { border-bottom: 0; }
.rank .rank-value { font-weight: 620; font-variant-numeric: tabular-nums; }
.rank .rank-value.is-bad { color: var(--critical); }

.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.vars code { font-size: 12px; background: var(--surface-3); padding: 2px 7px; border-radius: 6px; }

textarea.template-body { min-height: 200px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.big-switch { display: flex; align-items: center; gap: 14px; justify-content: space-between; flex-wrap: wrap; }
.big-switch strong { font-size: 14.5px; }
.big-switch p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.card-danger { border-color: #f0c4c4; background: var(--critical-soft); }

/* ------------------------------------------------------- manuais (ajuda) */

.doc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 36px;
  align-items: start;
  max-width: 1180px;
}

.doc-toc {
  position: sticky;
  top: 84px;
  order: 2;
  font-size: 13px;
  border-left: 1px solid var(--border);
  padding-left: 16px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.doc-toc p {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.doc-toc li + li { margin-top: 2px; }
.doc-toc a { display: block; padding: 3px 0; color: var(--text-secondary); }
.doc-toc a:hover { color: var(--accent); }

.doc-body { min-width: 0; max-width: 80ch; font-size: 14.5px; line-height: 1.65; }

.doc-hero {
  padding: 26px 26px 22px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.doc-eyebrow {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.doc-hero h2 { font-size: 26px; font-weight: 680; letter-spacing: -0.025em; line-height: 1.2; margin-top: 6px; }
.doc-hero > p:not(.doc-eyebrow) { color: var(--text-secondary); margin-top: 10px; max-width: 64ch; }
.doc-hero .doc-switch { font-size: 13.5px; padding-top: 14px; margin-top: 16px; border-top: 1px solid var(--border); }

.doc-body section { scroll-margin-top: 76px; }
.doc-body h2.doc-h {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 20px;
  font-weight: 660;
  letter-spacing: -0.02em;
  margin-top: 48px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
}
.doc-num {
  width: 30px; height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 680;
}
.doc-h .doc-tagline { margin-left: auto; font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--text-muted); }

.doc-body h3 { font-size: 15.5px; font-weight: 640; letter-spacing: -0.01em; margin-top: 28px; color: var(--accent); }
.doc-body h4 { font-size: 14px; font-weight: 640; margin-top: 18px; }
.doc-body p { margin-top: 10px; }
.doc-body .notice { margin: 16px 0 0; font-size: 14px; }
.doc-body .table-wrap { margin-top: 14px; }
.doc-body table { font-size: 13.5px; }
.doc-body tbody td { vertical-align: top; }
.doc-body pre.message-preview { margin-top: 12px; }

.doc-list { list-style: disc; padding-left: 22px; margin-top: 8px; }
.doc-list li + li { margin-top: 4px; }
.doc-list li::marker { color: var(--text-muted); }

/* Passo a passo numerado: o número é desenho, não texto do item. */
.steps { counter-reset: step; margin-top: 12px; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 40px;
  min-height: 26px;
}
.steps > li + li { margin-top: 10px; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--warning);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 680;
}
.steps .doc-list { margin-top: 6px; }

/* Nome de botão, menu ou campo exatamente como aparece na tela. */
.ui {
  font-weight: 620;
  color: var(--text-primary);
  white-space: nowrap;
}

.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  margin-top: 16px;
}
.flow-step {
  flex: 1 1 130px;
  padding: 11px 13px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
}
.flow-step strong { display: block; font-size: 13.5px; color: var(--accent); }
.flow-step span { color: var(--text-muted); }
.flow-arrow { align-self: center; color: var(--text-muted); font-size: 18px; }

.doc-cta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

@media (max-width: 1100px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .doc-toc {
    position: static;
    order: 0;
    max-height: none;
    border-left: 0;
    padding: 14px 16px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
  }
  .doc-toc ul { columns: 2; column-gap: 20px; }
}

@media (max-width: 560px) {
  .doc-toc ul { columns: 1; }
  .doc-hero { padding: 20px 18px 18px; }
  .doc-hero h2 { font-size: 22px; }
  .flow-arrow { display: none; }
}

@media print {
  .sidebar, .topbar-actions, .card-foot, .pagination { display: none; }
  body { background: #fff; }
  .doc { display: block; }
  .doc-toc, .doc-cta { display: none; }
  .doc-body { max-width: none; }
  .doc-body section { break-inside: avoid-page; }
}
