/* ==========================================================================
   LeadFlow — base do sistema visual
   Tokens, reset, tipografia, botões, campos, cards, tabelas, alertas, modais.

   Regras da casa (ver docs/DESIGN.md):
   - Toda cor passa pelos tokens abaixo. Componente não inventa cor.
   - Uma família de letra em tudo (Figtree), no painel e no site.
   - Sombra só no que flutua (menu, modal, aviso). Card é borda, não sombra.
   - Três raios: 4px (etiquetas), 6px (controles), 8px (blocos).
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;

  /* Superfícies */
  --bg: #F7F6F3;          /* fundo das telas */
  --sidebar: #F1EFEB;
  --surface: #FFFFFF;     /* cards, tabelas, campos */
  --surface-2: #FAF9F7;   /* cabeçalho de tabela, rodapé de modal */
  --surface-3: #F0EEEA;   /* hover, etiqueta neutra */
  --border: #E5E2DC;
  --border-strong: #D3CFC7;

  /* Texto */
  --text: #1F1D1A;
  --text-muted: #5F5B53;
  --text-dim: #6F6B63;

  /* Marca: o verde do logo */
  --brand: #1A7A4C;
  --brand-dark: #135E3A;
  --brand-light: rgba(26, 122, 76, 0.09);
  --on-brand: #FFFFFF;

  /* Estados */
  --success: #1A7A4C;
  --success-light: #E8F3ED;
  --warning: #8A5A00;
  --warning-light: #FDF3D8;
  --danger: #B42318;
  --danger-light: #FCEDEB;
  --info: #2B4DB3;
  --info-light: #ECF0FA;
  --roxo: #5B3F99;        /* só para dar cor a etiquetas */
  --roxo-light: #F1EDF8;

  /* Gráficos e etapas desenhados por JavaScript (ui.js lê estes tokens;
     o par escuro vem mais abaixo). Duas séries nunca dependem só da cor. */
  --grafico-serie-1: #2B4DB3;        /* azul — leads / investimento */
  --grafico-serie-1-hover: #223E91;
  --grafico-serie-2: #1A7A4C;        /* verde — vendas / resultados */
  --grafico-serie-2-hover: #135E3A;
  --grafico-serie-3: #7A5AB8;        /* lilás */
  --grafico-serie-4: #C2621A;        /* laranja */
  --grafico-grade: #ECE9E4;
  --grafico-texto: #5F5B53;
  --grafico-dica-fundo: #26241F;
  --grafico-dica-borda: #26241F;
  --grafico-dica-texto: #FFFFFF;
  /* Pontos e barras das etapas do funil: um tom só, do cinza-azulado ao azul */
  --etapa-novo: #A9B4CF;
  --etapa-primeiro_contato: #8696BF;
  --etapa-em_atendimento: #6478AE;
  --etapa-proposta: #435A9C;
  --etapa-negociacao: #2B4389;
  --etapa-ganho: #1A7A4C;
  --etapa-perdido: #B42318;

  /* Formas */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  --shadow-sm: none;
  --shadow: 0 1px 2px rgba(20, 18, 15, 0.06), 0 4px 12px rgba(20, 18, 15, 0.08);
  --shadow-lg: 0 2px 6px rgba(20, 18, 15, 0.06), 0 16px 40px rgba(20, 18, 15, 0.16);
  --anel-foco: 0 0 0 3px rgba(26, 122, 76, 0.2);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --sidebar-w: 232px;
  --header-h: 56px;

  --font: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; /* só para códigos */

  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* ---------- Tema escuro ----------
   Vale só quando <html> tem data-theme="dark" (alternador em js/tema.js).
   Como toda cor passa pelos tokens, o site inteiro acompanha sem mexer nos
   componentes. A escolha fica salva e o primeiro acesso respeita o sistema. */
html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #16150F;
  --sidebar: #1C1A13;
  --surface: #211F17;
  --surface-2: #27241A;
  --surface-3: #322E22;
  --border: #353124;
  --border-strong: #47422F;

  --text: #F3F0E7;
  --text-muted: #B7B1A1;
  --text-dim: #938D7D;

  --brand: #2FA76C;
  --brand-dark: #5FCB95;            /* links e destaques precisam clarear no escuro */
  --brand-light: rgba(63, 190, 128, 0.16);
  --on-brand: #08140D;

  --success: #2FA76C;
  --success-light: rgba(63, 190, 128, 0.16);
  --warning: #E3AC45;
  --warning-light: rgba(227, 172, 69, 0.15);
  --danger: #F07167;
  --danger-light: rgba(240, 113, 103, 0.15);
  --info: #86A2F2;
  --info-light: rgba(134, 162, 242, 0.15);
  --roxo: #B096E4;
  --roxo-light: rgba(176, 150, 228, 0.16);

  --shadow-sm: none;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 14px rgba(0, 0, 0, .55);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .5), 0 18px 48px rgba(0, 0, 0, .65);
  --anel-foco: 0 0 0 3px rgba(63, 190, 128, 0.35);

  /* Gráficos: séries e grade clareiam para ler sobre o fundo escuro */
  --grafico-serie-1: #86A2F2;
  --grafico-serie-1-hover: #A5BAF6;
  --grafico-serie-2: #4FC98C;
  --grafico-serie-2-hover: #74D7A6;
  --grafico-serie-3: #B096E4;
  --grafico-serie-4: #E39B5A;
  --grafico-grade: #353124;
  --grafico-texto: #B7B1A1;
  --grafico-dica-fundo: #322E22;
  --grafico-dica-borda: #47422F;
  --grafico-dica-texto: #F3F0E7;
  /* Etapas: o tom clareia conforme o lead avança, destacando sobre o escuro */
  --etapa-novo: #6E7CA6;
  --etapa-primeiro_contato: #8291BC;
  --etapa-em_atendimento: #97A6CF;
  --etapa-proposta: #ADBBE2;
  --etapa-negociacao: #C4CFF0;
  --etapa-ganho: #4FC98C;
  --etapa-perdido: #F07167;
}

/* Trechos que trazem cor fixa no claro e precisam de par no escuro */
html[data-theme="dark"] ::selection { background: rgba(63, 190, 128, 0.28); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #8B8676; }
html[data-theme="dark"] input:hover,
html[data-theme="dark"] select:hover,
html[data-theme="dark"] textarea:hover,
html[data-theme="dark"] .btn-secondary:hover { border-color: #5B5540; }
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="time"],
html[data-theme="dark"] input[type="datetime-local"] { color-scheme: dark; }
html[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23B7B1A1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .btn-whatsapp:hover { background: rgba(47, 167, 108, 0.16); border-color: #3B6B52; }
html[data-theme="dark"] .alert-error { color: #FFB4AC; border-color: rgba(240, 113, 103, .4); }
html[data-theme="dark"] .alert-success { color: #9FE3BE; border-color: rgba(63, 190, 128, .4); }
html[data-theme="dark"] .alert-warning { color: #F2D08C; border-color: rgba(227, 172, 69, .4); }
html[data-theme="dark"] .alert-info { color: #B9C8F7; border-color: rgba(134, 162, 242, .4); }
html[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.6); }

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(26, 122, 76, 0.22); }

img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
  margin: 0 0 var(--space-3);
  line-height: 1.25;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.0625rem; }
h4 { font-size: 0.9375rem; }

p { margin: 0 0 var(--space-3); }

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

small, .text-sm { font-size: 0.8125rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.strong { font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.hidden { display: none !important; }
.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;
}

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

/* Barras de rolagem discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* Ícones de traço (UI.icone): herdam a cor e o tamanho do texto em volta */
svg.i {
  width: 1.15em; height: 1.15em; flex: 0 0 auto; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.state-icon svg.i { width: 24px; height: 24px; }

/* ---------- Layout utilitário ---------- */
.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.row { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.col { flex: 1 1 0; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.inline { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 7px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn[disabled], .btn.is-loading { opacity: .55; cursor: not-allowed; }
.btn svg.i { width: 16px; height: 16px; }

.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-dark); color: var(--on-brand); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: #B9B4AA; color: var(--text); }

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

.btn-success { background: var(--success); color: var(--on-brand); }
.btn-success:hover { background: var(--brand-dark); color: var(--on-brand); }

.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-danger:hover { background: #8F1C13; color: #FFFFFF; }

.btn-outline-danger { background: var(--surface); color: var(--danger); border-color: var(--border-strong); }
.btn-outline-danger:hover { background: var(--danger-light); border-color: rgba(180, 35, 24, 0.45); }

/* WhatsApp: botão claro com o ícone na cor do app. Repetido numa lista, não grita. */
.btn-whatsapp { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-whatsapp svg.i { color: #128C4B; }
.btn-whatsapp:hover { background: #EEF8F1; border-color: #9CCDB0; color: var(--text); }

.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 0.8125rem; }
.btn-sm svg.i { width: 15px; height: 15px; }
.btn-lg { min-height: 44px; padding: 11px 22px; font-size: 0.9375rem; }
.btn-block { width: 100%; }

/* Botão só com ícone (editar, excluir, mover): quadrado, com nome em aria-label/title */
.btn-icone { width: 30px; min-height: 30px; padding: 0; }
.btn-icone svg.i { width: 16px; height: 16px; }
.btn-ghost.btn-icone { color: var(--text-dim); }
.btn-ghost.btn-icone:hover { color: var(--text); }
.btn-ghost.acao-perigo:hover { color: var(--danger); background: var(--danger-light); }

.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: var(--on-brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-secondary .spinner, .btn-ghost .spinner, .btn-outline-danger .spinner, .btn-whatsapp .spinner {
  border-color: rgba(31, 29, 26, .2); border-top-color: var(--text);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulários ---------- */
.field { margin-bottom: var(--space-4); }
.field label,
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}
.field .hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="number"], input[type="date"], input[type="time"], input[type="search"],
input[type="datetime-local"], input[type="url"], select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background-color: var(--surface);
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: #B9B4AA; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--anel-foco);
}
input[disabled], select[disabled], textarea[disabled], input[readonly] { background-color: var(--surface-2); color: var(--text-muted); }
input::placeholder, textarea::placeholder { color: #8C877E; }
input[type="date"], input[type="time"], input[type="datetime-local"] { color-scheme: light; }
textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%235F5B53' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }
select option { background: var(--surface); color: var(--text); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }

.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field.has-error input:focus, .field.has-error select:focus, .field.has-error textarea:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); }
.field-error { color: var(--danger); font-size: 0.75rem; margin-top: 4px; display: block; }

/* Campo de senha com botão de mostrar/ocultar (ver UI.ligarVerSenha) */
.senha-wrap { position: relative; }
.senha-wrap input { padding-right: 44px; }
.senha-toggle {
  position: absolute; top: 50%; right: 3px; transform: translateY(-50%);
  width: 32px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-muted); cursor: pointer;
}
.senha-toggle:hover { color: var(--text); background: var(--surface-3); }
.senha-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.senha-toggle svg { width: 18px; height: 18px; }

/* ---------- Assinatura e pagamento por PIX (assinatura.js, layout.js) ---------- */
.aviso-assinatura { margin: var(--space-4) var(--space-5) 0; }

.plano-opcoes { display: grid; gap: var(--space-2); margin: var(--space-3) 0; }
.plano-opcao {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px 12px; cursor: pointer; font-size: 0.875rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.plano-opcao input { width: auto; margin: 0; }
.plano-opcao .nome { font-weight: 600; }
.plano-opcao .detalhe { color: var(--text-muted); font-size: 0.8125rem; }
.plano-opcao .preco { margin-left: auto; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plano-opcao.selecionado { border-color: var(--brand); background: var(--brand-light); }
.plano-recursos { margin: var(--space-3) 0; padding-left: 18px; color: var(--text-muted); font-size: 0.875rem; }

.pix-resumo { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 1rem; }
.pix-qr { display: flex; justify-content: center; margin: var(--space-4) 0; }
.pix-qr img {
  /* O QR Code precisa de fundo claro para ser lido pela câmera. */
  width: 200px; height: 200px; padding: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.pix-copia { display: flex; gap: var(--space-2); }
.pix-copia input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 0.75rem; }
.pix-passos { margin: var(--space-3) 0; padding-left: 20px; color: var(--text-muted); font-size: 0.875rem; }
.pix #pixStatus { margin: var(--space-3) 0; }
.loader-mini {
  display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid var(--border-strong); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@media (max-width: 640px) {
  .aviso-assinatura { margin: var(--space-3) var(--space-3) 0; }
}

.checkbox { display: flex; align-items: flex-start; gap: 10px; font-size: 0.875rem; color: var(--text-muted); }
.checkbox input { width: auto; margin-top: 3px; flex: 0 0 auto; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }
.form-grid .full { grid-column: 1 / -1; }
/* Título de um bloco dentro de um formulário longo (Contato, Negociação...) */
.grupo-form {
  margin: var(--space-2) 0 var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--border);
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
}
.grupo-form:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4);
}
.card-header h3, .card-header h2 { margin: 0; }
.card-header h3 { font-size: 0.9375rem; }
.card-header .text-sm.text-muted { display: block; margin-top: 1px; }
.card-flush { padding: 0; overflow: hidden; }

/* ---------- Etiquetas de estado (badges) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: var(--radius-sm);
  font-size: 0.75rem; font-weight: 500; line-height: 1.35; white-space: nowrap;
  background: var(--surface-3); color: var(--text-muted);
}
.badge-brand { background: var(--brand-light); color: var(--brand-dark); }
.badge-success { background: var(--success-light); color: var(--brand-dark); }
.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-neutral { background: var(--surface-3); color: var(--text-muted); }
.badge-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--cor-etapa, currentColor); display: inline-block; flex: 0 0 auto;
}

/* ---------- Tabelas ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 860px;
}
/* A primeira coluna costuma ser o nome: precisa de largura para não quebrar letra a letra */
table.data th:first-child,
table.data td:first-child { min-width: 180px; }
table.data th {
  text-align: left;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .sort-arrow { opacity: .35; font-size: .7rem; }
table.data th.sorted { color: var(--text); }
table.data th.sorted .sort-arrow { opacity: 1; }
table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------- Alertas ---------- */
.alert {
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-light); color: #7A1A12; border-color: #F1CBC6; }
.alert-success { background: var(--success-light); color: #0F4A2E; border-color: #C3DFCF; }
.alert-warning { background: var(--warning-light); color: #5E3E00; border-color: #EEDAA3; }
.alert-info { background: var(--info-light); color: #1F3780; border-color: #CFD9F2; }
.alert a { color: inherit; text-decoration: underline; }
.alert .btn { margin-left: 6px; }

/* ---------- Estados: carregando / vazio ---------- */
.state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
  font-size: 0.875rem;
}
.state h3 { color: var(--text); font-size: 0.9375rem; margin-bottom: 4px; }
.state p { max-width: 420px; margin-left: auto; margin-right: auto; }
.state .state-icon {
  margin: 0 auto var(--space-3);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
}
.state .state-icon.erro { color: var(--danger); }
.loader {
  width: 22px; height: 22px; margin: 0 auto var(--space-3);
  border: 2px solid var(--border-strong); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite;
}
.skeleton {
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  height: 14px;
  animation: pulsar 1.4s ease-in-out infinite;
}
@keyframes pulsar { 50% { opacity: .55; } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 18, 15, 0.4);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--space-6) var(--space-4);
  z-index: 80;
  overflow-y: auto;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  margin: auto;
  animation: modal-in .16s ease-out;
}
.modal-sm { max-width: 440px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-close {
  background: transparent; border: none; font-size: 20px; line-height: 1;
  color: var(--text-muted); cursor: pointer; width: 30px; height: 30px; border-radius: var(--radius);
  flex: 0 0 auto;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: var(--space-5); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-wrap: wrap;
}

/* ---------- Avisos rápidos (toasts) ---------- */
#toasts {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 120; max-width: min(420px, calc(100vw - 40px));
}
.toast {
  background: #26241F; color: #FFFFFF;
  padding: 10px 14px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 0.875rem;
  animation: toast-in .18s ease-out;
  display: flex; align-items: center; gap: 10px;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #A8A399; flex: 0 0 auto; }
.toast-success::before { background: #5FD49A; }
.toast-error::before { background: #FF8A7A; }
.toast-info::before { background: #9DB4F2; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Logo ---------- */
.logo {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font); font-weight: 700; font-size: 1.125rem; letter-spacing: -.02em;
  color: var(--text);
}
.logo:hover { text-decoration: none; }
/* Balão de conversa com um "visto" (o SVG está no HTML e no layout.js) */
.logo-mark { width: 26px; height: 26px; flex: 0 0 auto; display: block; }
.logo-balao { fill: var(--brand); }
.logo-check { fill: none; stroke: var(--on-brand); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.logo-light { color: var(--text); }

/* ---------- Barra de progresso ---------- */
.progress { height: 6px; background: var(--surface-3); border-radius: var(--radius-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: var(--radius-pill); transition: width .3s var(--ease); }

/* ---------- Alternador de tema (claro/escuro) ----------
   O botão é inserido por js/tema.js — no cabeçalho do site e na barra superior
   do painel (.topbar-actions). Mostra o sol no escuro (para voltar ao claro) e
   a lua no claro. Vale no site e no painel (os dois carregam este arquivo). */
.tema-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; flex: 0 0 auto;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease, transform .15s var(--ease);
}
.tema-toggle:hover { color: var(--text); border-color: #B9B4AA; }
html[data-theme="dark"] .tema-toggle:hover { border-color: #5B5540; }
.tema-toggle:active { transform: scale(.94); }
.tema-toggle svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.tema-toggle .tema-sol { display: none; }
.tema-toggle .tema-lua { display: block; }
html[data-theme="dark"] .tema-toggle .tema-sol { display: block; }
html[data-theme="dark"] .tema-toggle .tema-lua { display: none; }
/* Nas telas sem cabeçalho (login, senha), fica flutuando no canto */
.tema-toggle.flutua { position: fixed; top: 16px; right: 16px; z-index: 70; box-shadow: var(--shadow); }
@media (prefers-reduced-motion: reduce) { .tema-toggle { transition: none; } .tema-toggle:active { transform: none; } }

/* Nome de variável de ambiente / trecho técnico (tela de integrações). */
code {
  font-family: var(--font-mono);
  font-size: .8125em;
  color: var(--text);
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  white-space: nowrap;
}

/* Aceite do termo na tela interna (layout.js) */
.termos-aceite p { color: var(--text-muted); }
.termos-aceite .links { display: flex; gap: 10px; flex-wrap: wrap; margin: var(--space-3) 0 var(--space-4); }
