/* ==========================================================================
   Maily — tokens e componentes
   Fonte única de verdade do visual. Nenhuma cor, tamanho ou raio fora daqui.
   Tema claro em :root; tema escuro em [data-theme="dark"] no <html>.
   ========================================================================== */

/* ---------- Fonte (local, por causa da CSP) ---------- */
@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens: tema claro (padrão) ---------- */
:root {
  color-scheme: light;

  /* Superfícies */
  --bg-app: #F9FAFB;          /* fundo geral, menu de visões, área da conversa */
  --bg-surface: #FFFFFF;      /* cards, lista, painel lateral, cabeçalhos */
  --bg-subtle: #F3F4F6;       /* blocos de apoio, miniaturas, linhas Total/Média */
  --bg-rail: #FFFFFF;         /* trilho de ícones */
  --bg-reply: #F3F4F6;        /* card de resposta da equipe */
  --bg-hover: rgba(17, 24, 39, 0.04);
  --bg-selected: rgba(17, 24, 39, 0.06);  /* item ativo e conversa selecionada */
  --bg-row-hover: #F9FAFB;    /* hover de linha de tabela (precisa ser opaco por causa da coluna fixa) */
  --overlay: rgba(17, 24, 39, 0.40);

  /* Bordas */
  --border: #E5E7EB;
  --border-strong: #D1D5DB;

  /* Texto */
  --text-1: #111827;          /* principal */
  --text-2: #6B7280;          /* secundário e meta (passa AA) */
  --text-3: #9CA3AF;          /* SÓ ícones decorativos, separadores e desabilitado — nunca texto que precisa ser lido */
  --text-btn: #374151;        /* texto de botão secundário e itens de menu */
  --text-on-accent: #FFFFFF;

  /* Destaque (azul) — só botão principal, links, foco e ponto de não lida */
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-text: #2563EB;     /* links e texto azul */
  --focus-ring: rgba(37, 99, 235, 0.25);

  /* Pontos de status */
  --danger: #EF4444;          /* ponto de notificação, desconectado */
  --danger-strong: #DC2626;   /* fundo de contador com número branco, borda de erro */
  --ok: #34D399;              /* online, conectado, status Aberta */
  --warn: #F59E0B;            /* atenção */

  /* Selos semânticos (fundo / texto) */
  --badge-green-bg: #DCFCE7;  --badge-green-tx: #166534;
  --badge-amber-bg: #FEF3C7;  --badge-amber-tx: #92400E;
  --badge-red-bg: #FEE2E2;    --badge-red-tx: #B91C1C;
  --badge-blue-bg: #DBEAFE;   --badge-blue-tx: #1E40AF;
  --badge-gray-bg: #F3F4F6;   --badge-gray-tx: #374151;
  --badge-purple-bg: #F3E8FF; --badge-purple-tx: #6B21A8;

  /* Nota interna */
  --note-bg: #FFFBEB;
  --note-border: #FDE68A;
  --note-tx: #92400E;

  /* Controle segmentado */
  --seg-track: #F3F4F6;
  --seg-on: #FFFFFF;

  /* Gráficos (paleta validada para daltonismo) */
  --chart-1: #3B82F6;         /* série única */
  --chart-grid: #F3F4F6;
  --sent-calmo: #3B82F6;
  --sent-irritado: #F59E0B;
  --sent-muito: #B91C1C;

  /* Lojas — paleta de 8 cores; cada loja guarda o número (1–8). Nenhuma cor fixa por loja.
     Ordem validada para daltonismo; a mesma ordem vale nos gráficos "por loja". */
  --store-1: #EB6834;
  --store-2: #1BAF7A;
  --store-3: #EDA100;
  --store-4: #E87BA4;
  --store-5: #008300;
  --store-6: #6250D6;
  --store-7: #E34948;
  --store-8: #2A78D6;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-seg: 0 1px 2px rgba(16, 24, 40, 0.08), 0 0 0 1px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, 0.12);

  /* Tipografia */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Espaçamento (múltiplos de 4) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Raios */
  --r-badge: 6px;   /* selos, kbd */
  --r-ctrl: 8px;    /* botões, campos, itens de menu, chips de canal, miniaturas */
  --r-card: 12px;   /* cards, modais, menus flutuantes, nota interna */
  --r-full: 999px;  /* chips de filtro, avatares, pontos */

  /* Layout */
  --rail-w: 64px;
  --menu-w: 216px;
  --list-w: 336px;
  --panel-w: 312px;
  --header-h: 56px;
  --read-max: 720px;
  --page-max: 1280px;

  /* Movimento */
  --t-fast: 150ms;
}

/* ---------- Tokens: tema escuro ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-app: #1A1A1A;
  --bg-surface: #222222;
  --bg-subtle: #2A2A2A;
  --bg-rail: #2E2E2E;
  --bg-reply: #2A2A2A;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-selected: rgba(255, 255, 255, 0.08);
  --bg-row-hover: #272727;
  --overlay: rgba(0, 0, 0, 0.60);

  --border: #3A3A3A;
  --border-strong: #4A4A4A;

  --text-1: #F5F5F5;
  --text-2: #B0B0B0;
  --text-3: #808080;
  --text-btn: #E5E5E5;

  /* --accent e --accent-hover não mudam (texto branco continua AA) */
  --accent-text: #60A5FA;
  --focus-ring: rgba(96, 165, 250, 0.35);

  --badge-green-bg: rgba(52, 211, 153, 0.14);  --badge-green-tx: #6EE7B7;
  --badge-amber-bg: rgba(251, 191, 36, 0.14);  --badge-amber-tx: #FCD34D;
  --badge-red-bg: rgba(248, 113, 113, 0.14);   --badge-red-tx: #FCA5A5;
  --badge-blue-bg: rgba(96, 165, 250, 0.14);   --badge-blue-tx: #93C5FD;
  --badge-gray-bg: #2E2E2E;                    --badge-gray-tx: #D4D4D4;
  --badge-purple-bg: rgba(192, 132, 252, 0.14); --badge-purple-tx: #D8B4FE;

  --note-bg: rgba(251, 191, 36, 0.08);
  --note-border: rgba(251, 191, 36, 0.28);
  --note-tx: #FCD34D;

  --seg-track: #1A1A1A;
  --seg-on: #3A3A3A;

  --chart-1: #3B82F6;
  --chart-grid: #2E2E2E;
  --sent-calmo: #3B82F6;
  --sent-irritado: #C2870A;
  --sent-muito: #DC2626;

  --store-1: #D95926;
  --store-2: #199E70;
  --store-3: #C98500;
  --store-4: #D55181;
  --store-5: #008300;
  --store-6: #9085E9;
  --store-7: #E66767;
  --store-8: #3987E5;

  --shadow-sm: none;
  --shadow-seg: none;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.50);
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { margin: 0; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--badge-blue-bg); }

/* Tipografia — os únicos estilos de texto permitidos */
.t-greeting { font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -0.01em; }
.t-kpi      { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.t-highlight{ font-size: 24px; line-height: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.t-page     { font-size: 20px; line-height: 28px; font-weight: 600; }
.t-col      { font-size: 16px; line-height: 24px; font-weight: 600; }
.t-card     { font-size: 14px; line-height: 20px; font-weight: 600; }
.t-body     { font-size: 14px; line-height: 20px; font-weight: 400; }
.t-label    { font-size: 14px; line-height: 20px; font-weight: 500; }
.t-list     { font-size: 13px; line-height: 18px; font-weight: 400; }
.t-meta     { font-size: 12px; line-height: 16px; font-weight: 400; color: var(--text-2); }
.t-section  { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); } /* títulos de grupo no menu; sem maiúsculas */
.muted      { color: var(--text-2); }
.num        { font-variant-numeric: tabular-nums; }
.truncate   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.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; }

/* Ícones (Lucide via sprite local) */
.icon     { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon--20 { width: 20px; height: 20px; }
.icon--14 { width: 14px; height: 14px; }
.icon--12 { width: 12px; height: 12px; }
.icon--filled { fill: currentColor; }   /* só a estrela de preferencial */

/* ==========================================================================
   Estrutura
   ========================================================================== */
.app { display: flex; min-height: 100vh; }
.app__main { flex: 1; min-width: 0; }

/* Caixa de entrada: colunas fixas, cada uma rola sozinha, a página não rola */
@media (min-width: 1024px) {
  .app--inbox { height: 100vh; min-height: 640px; overflow: hidden; }
  .app--inbox > .col { height: 100%; overflow-y: auto; }
  .app--inbox > .col--conversation { overflow: hidden; }
}
.col { min-width: 0; }

/* Trilho */
.rail {
  flex: 0 0 var(--rail-w);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-1);
  padding: var(--sp-3) 0;
  background: var(--bg-rail);
  border-right: 1px solid var(--border);
}
.rail__logo {
  width: 36px; height: 36px; margin-bottom: var(--sp-3);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-ctrl);
  background: var(--text-1); color: var(--bg-surface);
  font-size: 16px; font-weight: 700; text-decoration: none;
}
.rail__logo:hover { text-decoration: none; }
.rail__item {
  position: relative; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--r-ctrl);
  background: transparent; color: var(--text-2);
  cursor: pointer; transition: background-color var(--t-fast), color var(--t-fast);
}
.rail__item:hover { background: var(--bg-hover); color: var(--text-1); text-decoration: none; }
.rail__item.is-active { background: var(--bg-selected); color: var(--text-1); }
.rail__badge {
  position: absolute; top: 3px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-full); background: var(--danger-strong); color: #FFFFFF;
  font-size: 11px; line-height: 16px; font-weight: 600; text-align: center;
}
.rail__spacer { flex: 1; }
.rail__avatar { position: relative; margin-top: var(--sp-1); }
.rail__presence {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
  border-radius: var(--r-full); background: var(--ok); border: 2px solid var(--bg-rail);
}

/* Menu de visões / seções (2ª coluna) */
.secnav {
  flex: 0 0 var(--menu-w);
  display: flex; flex-direction: column;
  background: var(--bg-app);
  border-right: 1px solid var(--border);
}
.secnav__body { padding: 0 var(--sp-2) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.secnav__group { display: flex; flex-direction: column; gap: 2px; }
.secnav__title { display: flex; align-items: center; height: 28px; padding: 0 var(--sp-2); font-size: 12px; font-weight: 500; color: var(--text-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-2);
  height: 32px; padding: 0 var(--sp-2);
  border-radius: var(--r-ctrl);
  color: var(--text-btn); font-size: 14px; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background-color var(--t-fast);
}
.nav-item:hover { background: var(--bg-hover); text-decoration: none; }
.nav-item.is-active { background: var(--bg-selected); color: var(--text-1); }
.nav-item .icon { color: var(--text-2); }
.nav-item__count { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Cabeçalho de coluna (56px) */
.col-header {
  flex: none; height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-2) 0 var(--sp-4);
}
.col-header--bordered { border-bottom: 1px solid var(--border); }

/* Página comum (Painel, Relatórios, Configurações, Base de conhecimento…) */
.page { flex: 1; min-width: 0; padding: 28px var(--sp-10) 48px; }
.page__inner { max-width: var(--page-max); margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp-6); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.page-header__actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.filters { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--sp-4); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: var(--sp-4); }
.form-narrow { max-width: 640px; }

/* ==========================================================================
   Componentes
   ========================================================================== */

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: var(--r-ctrl); border: 1px solid transparent;
  font-size: 14px; line-height: 20px; font-weight: 500;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { text-decoration: none; }
.btn--primary   { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--secondary { background: var(--bg-surface); border-color: var(--border); color: var(--text-btn); box-shadow: var(--shadow-sm); }
.btn--secondary:hover { background: var(--bg-subtle); }
.btn--ghost     { background: transparent; color: var(--text-btn); }
.btn--ghost:hover { background: var(--bg-hover); }
.btn--danger    { background: var(--bg-surface); border-color: var(--border); color: var(--badge-red-tx); }
.btn--danger:hover { background: var(--badge-red-bg); }
.btn--sm   { height: 32px; padding: 0 10px; font-size: 13px; }
.btn--xs   { height: 28px; padding: 0 8px; font-size: 13px; gap: 4px; }
.btn--icon { width: 32px; height: 32px; padding: 0; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent-text); font-size: 12px; font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* Atalho de teclado */
.kbd {
  display: inline-flex; align-items: center; height: 18px; padding: 0 5px;
  border-radius: 4px; border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-2);
  font-size: 11px; line-height: 16px; font-weight: 500;
}
.btn--primary .kbd { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.28); color: #FFFFFF; }

/* Campos */
.label { display: block; margin-bottom: 6px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--text-1); }
.help  { margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--text-2); }
.error-text { margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--badge-red-tx); }
.field {
  display: flex; align-items: center; gap: var(--sp-2);
  height: 36px; padding: 0 10px 0 12px;
  border-radius: var(--r-ctrl); border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-3);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.field.is-invalid { border-color: var(--danger-strong); }
.field input, .field select {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font-size: 14px; color: var(--text-1);
}
.field input::placeholder, .textarea::placeholder { color: var(--text-2); }
.textarea {
  width: 100%; min-height: 96px; padding: 10px 12px;
  border-radius: var(--r-ctrl); border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-1);
  font-size: 14px; line-height: 20px; resize: vertical;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* Interruptor */
.switch { position: relative; display: inline-block; width: 32px; height: 18px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track { position: absolute; inset: 0; border-radius: var(--r-full); background: var(--border-strong); transition: background-color var(--t-fast); }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: var(--r-full); background: #FFFFFF; transition: transform var(--t-fast); }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Controle segmentado */
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-ctrl); background: var(--seg-track); }
.seg__btn {
  height: 28px; padding: 0 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.seg__btn:hover { color: var(--text-1); }
.seg__btn.is-active, .seg__btn[aria-selected="true"] { background: var(--seg-on); color: var(--text-1); box-shadow: var(--shadow-seg); }
.seg--sm .seg__btn { height: 24px; padding: 0 10px; font-size: 12px; }

/* Chips de filtro */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: var(--r-full); border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text-btn);
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-fast);
}
.chip:hover { background: var(--bg-subtle); }
.chip.is-active { background: var(--bg-selected); border-color: transparent; color: var(--text-1); }
.chip__count { color: var(--text-2); font-variant-numeric: tabular-nums; }
.chip--sm { height: 24px; padding: 0 8px; font-size: 12px; }

/* Abas de página */
.tabs { display: flex; gap: var(--sp-6); border-bottom: 1px solid var(--border); }
.tab {
  display: inline-flex; align-items: center; height: 40px; padding: 0 2px; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-2); font-size: 14px; font-weight: 500; text-decoration: none;
}
.tab:hover { color: var(--text-1); text-decoration: none; }
.tab.is-active { color: var(--text-1); border-bottom-color: var(--text-1); }

/* Selos */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 6px; border-radius: var(--r-badge);
  font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap;
}
.badge--green  { background: var(--badge-green-bg);  color: var(--badge-green-tx); }
.badge--amber  { background: var(--badge-amber-bg);  color: var(--badge-amber-tx); }
.badge--red    { background: var(--badge-red-bg);    color: var(--badge-red-tx); }
.badge--blue   { background: var(--badge-blue-bg);   color: var(--badge-blue-tx); }
.badge--gray   { background: var(--badge-gray-bg);   color: var(--badge-gray-tx); }
.badge--purple { background: var(--badge-purple-bg); color: var(--badge-purple-tx); }

/* Ponto (loja, status, não lida) */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--r-full); flex: none; }
.dot--unread { background: var(--accent); }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); animation: pulse-warn 2s infinite; }
.dot--danger { background: var(--danger); animation: pulse-danger 2s infinite; }
@keyframes pulse-warn   { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .5); } 70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); } 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); } }
@keyframes pulse-danger { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); }  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

/* Avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none; border-radius: var(--r-full);
  background: var(--bg-subtle); color: var(--text-btn);
  font-size: 12px; font-weight: 600;
}
.avatar--team { background: var(--text-1); color: var(--bg-surface); }
.avatar--40 { width: 40px; height: 40px; font-size: 14px; }
.avatar--28 { width: 28px; height: 28px; font-size: 11px; }
.avatar--20 { width: 20px; height: 20px; font-size: 10px; }

/* Cards */
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-sm); }
.card__header { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-height: 60px; padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border); }
.card__body { padding: var(--sp-5); }

/* Card de KPI (sempre clicável) */
.kpi { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-5); color: inherit; text-decoration: none; transition: border-color var(--t-fast); }
.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi__label { display: flex; align-items: center; justify-content: space-between; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--text-2); }
.kpi__arrow { opacity: 0; color: var(--text-2); transition: opacity var(--t-fast); }
.kpi:hover .kpi__arrow, .kpi:focus-visible .kpi__arrow { opacity: 1; }
.kpi__delta { font-size: 12px; line-height: 16px; font-weight: 500; }
.kpi__delta--up { color: var(--badge-green-tx); }
.kpi__delta--down { color: var(--badge-red-tx); }

/* Item de lista dentro de card */
.list-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; transition: background-color var(--t-fast); }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--bg-hover); text-decoration: none; }

/* Tabela */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  position: sticky; top: 0; z-index: 2;
  height: 44px; padding: 0 var(--sp-4);
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  color: var(--text-2); font-size: 12px; line-height: 16px; font-weight: 500;
  text-align: right; white-space: nowrap;
}
.table td {
  height: 52px; padding: 0 var(--sp-4);
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.table th:first-child, .table td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; border-right: 1px solid var(--border); }
.table th:first-child { z-index: 3; }
.table .is-text { text-align: left; }
.table tr.is-aggregate td { height: 44px; background: var(--bg-subtle); font-weight: 600; }
.table tbody tr:not(.is-aggregate):hover td { background: var(--bg-row-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.is-empty { color: var(--text-2); } /* conteúdo "—" com title="Sem dados no período" */
.th-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.th-sort:hover, .th-sort.is-active { color: var(--text-1); }

/* Menu flutuante (dropdown, seletor de período, seletor de colunas) */
.popover { position: absolute; z-index: 30; min-width: 220px; padding: var(--sp-1); background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.popover__item { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: var(--r-ctrl); background: transparent; color: var(--text-1); font-size: 14px; text-align: left; cursor: pointer; }
.popover__item:hover, .popover__item.is-focused { background: var(--bg-hover); }
.popover__sep { height: 1px; margin: var(--sp-1) 0; background: var(--border); }

/* Tooltip (posicionado por JS) */
.tooltip { position: fixed; z-index: 50; max-width: 260px; padding: 6px 8px; border-radius: 6px; background: var(--text-1); color: var(--bg-surface); font-size: 12px; line-height: 16px; box-shadow: var(--shadow-pop); pointer-events: none; }
.tooltip .kbd { margin-left: 6px; background: transparent; border-color: rgba(255, 255, 255, .3); color: inherit; }

/* Toast */
.toast-region { position: fixed; left: var(--sp-6); bottom: var(--sp-6); z-index: 60; display: flex; flex-direction: column; gap: var(--sp-2); }
.toast { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 40px; padding: 0 14px; border-radius: var(--r-ctrl); background: var(--text-1); color: var(--bg-surface); box-shadow: var(--shadow-pop); font-size: 14px; font-weight: 500; }

/* Modal e gaveta */
.overlay { position: fixed; inset: 0; z-index: 40; background: var(--overlay); }
.modal { position: fixed; z-index: 41; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(480px, calc(100vw - 32px)); padding: var(--sp-6); background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.modal__title { font-size: 16px; line-height: 24px; font-weight: 600; }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-6); }
.drawer { position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(360px, 100vw); overflow-y: auto; background: var(--bg-surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-pop); }

/* Estado vazio */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: var(--sp-8) var(--sp-4); text-align: center; }
.empty__icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-full); background: var(--bg-subtle); color: var(--text-2); }
.empty__text { font-weight: 500; }

/* Skeleton */
.skeleton { display: block; border-radius: 6px; background: var(--bg-subtle); animation: skeleton 1.4s ease-in-out infinite; }
@keyframes skeleton { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ==========================================================================
   Caixa de entrada
   ========================================================================== */
.col--list { flex: 0 0 var(--list-w); display: flex; flex-direction: column; background: var(--bg-surface); border-right: 1px solid var(--border); }
.col--conversation { flex: 1 1 420px; display: flex; flex-direction: column; min-width: 0; background: var(--bg-app); }
.col--panel { flex: 0 0 var(--panel-w); background: var(--bg-surface); border-left: 1px solid var(--border); }

.list-search { flex: none; padding: 0 var(--sp-4) var(--sp-3); }
.list-chips { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--sp-4) var(--sp-3); border-bottom: 1px solid var(--border); }

/* Linha de conversa */
.conv-row { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; cursor: pointer; transition: background-color var(--t-fast); }
.conv-row:hover { background: var(--bg-hover); text-decoration: none; }
.conv-row.is-selected { background: var(--bg-selected); }
.conv-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-row__top { display: flex; align-items: center; gap: 6px; }
.conv-row__name { font-size: 14px; font-weight: 500; color: var(--text-1); }
.conv-row__aside { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.conv-row__subject { font-size: 13px; line-height: 18px; color: var(--text-1); }
.conv-row__preview { font-size: 13px; line-height: 18px; color: var(--text-2); }
.conv-row__meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.conv-row.is-unread .conv-row__name { font-weight: 600; }
.conv-row.is-unread .conv-row__subject { font-weight: 500; }

/* Cabeçalho da conversa */
.conv-header { flex: none; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); background: var(--bg-surface); border-bottom: 1px solid var(--border); }

/* Linha do tempo */
.timeline { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-5); }
.timeline__inner { max-width: var(--read-max); margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp-3); }
.msg { padding: 14px var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-card); }
.msg--customer { background: var(--bg-surface); box-shadow: var(--shadow-sm); }
.msg--team { background: var(--bg-reply); }
.msg__header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.msg__author { font-weight: 600; }
.msg__body { margin-top: 10px; }
.msg__body p + p { margin-top: var(--sp-2); }
.msg__footer { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; line-height: 16px; color: var(--text-2); }
.note { padding: 10px 14px 12px; border: 1px solid var(--note-border); border-radius: var(--r-card); background: var(--note-bg); }
.note__header { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--note-tx); }
.note__body { margin-top: var(--sp-1); font-size: 13px; line-height: 20px; color: var(--text-1); }
.event { display: flex; align-items: center; gap: 10px; font-size: 12px; line-height: 16px; color: var(--text-2); }
.event::before, .event::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.attachment { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r-ctrl); background: var(--bg-surface); font-size: 13px; color: var(--text-btn); }

/* Editor */
.composer { flex: none; padding: var(--sp-3) var(--sp-5) var(--sp-4); background: var(--bg-surface); border-top: 1px solid var(--border); }
.composer__inner { max-width: var(--read-max); margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.ai-banner { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); padding: 6px 6px 6px 10px; border-radius: var(--r-ctrl); background: var(--bg-subtle); }
.editor { border: 1px solid var(--border); border-radius: var(--r-ctrl); background: var(--bg-surface); }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.editor__bar { display: flex; align-items: center; gap: var(--sp-2); padding: 6px var(--sp-2); border-bottom: 1px solid var(--border); }
.editor__text { width: 100%; min-height: 120px; max-height: 240px; padding: var(--sp-3); border: 0; outline: 0; resize: none; background: transparent; color: var(--text-1); font-size: 14px; line-height: 20px; }
.editor--note { border-color: var(--note-border); background: var(--note-bg); }
.composer__toolbar { display: flex; align-items: center; gap: var(--sp-1); }
.composer__toolbar .btn--primary { margin-left: auto; }

/* Painel do cliente e pedido */
.side-section { padding: var(--sp-4); border-bottom: 1px solid var(--border); }
.side-section__header { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.stat-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); padding: 10px var(--sp-3); border-radius: var(--r-ctrl); background: var(--bg-subtle); }
.thumb { width: 40px; height: 40px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: var(--r-ctrl); background: var(--bg-subtle); color: var(--text-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.track { list-style: none; margin: 0; padding: 0 0 0 4px; }
.track__step { position: relative; margin-left: 3px; padding: 0 0 var(--sp-3) 14px; border-left: 1px solid var(--border); }
.track__step:last-child { border-left-color: transparent; padding-bottom: 0; }
.track__dot { position: absolute; left: -5px; top: 4px; width: 9px; height: 9px; border-radius: var(--r-full); background: var(--border-strong); }
.track__step.is-current .track__dot { background: var(--warn); box-shadow: 0 0 0 3px var(--badge-amber-bg); }
.track__step.is-current .track__title { font-weight: 600; color: var(--text-1); }
.track__title { font-size: 13px; line-height: 18px; color: var(--text-2); }

/* Barra de progresso (orçamento de API, metas) */
.progress { height: 8px; border-radius: var(--r-full); background: var(--bg-subtle); overflow: hidden; }
.progress__fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--chart-1); }
.progress__fill--warn { background: var(--warn); }
.progress__fill--danger { background: var(--danger-strong); }

/* Segredo mascarado (Chaves de API) */
.secret { font-family: var(--font-mono); font-size: 13px; color: var(--text-1); letter-spacing: 0.02em; }

/* Botão dividido (Enviar ▾) */
.btn-split { position: relative; display: inline-flex; }
.btn-split > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-split > .btn + .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 8px; border-left-color: rgba(255, 255, 255, 0.35); }
.btn-split .popover { bottom: calc(100% + 8px); right: 0; width: 290px; }

/* Seleção múltipla na lista */
.conv-row__check { display: none; width: 32px; height: 32px; flex: none; align-items: center; justify-content: center; }
.conv-row:hover .conv-row__check, .is-selecting .conv-row__check { display: flex; }
.conv-row:hover > .avatar, .is-selecting .conv-row > .avatar { display: none; }
.bulk-bar { flex: none; height: var(--header-h); display: flex; align-items: center; gap: var(--sp-1); padding: 0 var(--sp-2) 0 var(--sp-4); background: var(--bg-selected); }

/* Aviso de outra pessoa na conversa */
.presence-note { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--text-2); }

/* Aviso em linha (conflito de envio, oferta detectada, pedido não encontrado) */
.inline-alert { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); padding: 8px 10px; border-radius: var(--r-ctrl); background: var(--badge-amber-bg); color: var(--badge-amber-tx); font-size: 13px; line-height: 18px; }
.inline-alert .btn { height: 28px; padding: 0 8px; font-size: 13px; }
.ok-line { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 16px; color: var(--badge-green-tx); }

/* Marca da loja: logo quadrado ou iniciais (substitui a bolinha colorida).
   Fundo: style="background: var(--store-{{ loja.cor }})". Iniciais em branco ou #111827, o que tiver mais contraste. */
.store-mark { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: none; overflow: hidden; border-radius: 4px; font-size: 8px; line-height: 1; font-weight: 700; letter-spacing: 0.02em; color: #FFFFFF; }
.store-mark img { width: 100%; height: 100%; object-fit: cover; }
.store-mark--dark-text { color: #111827; }
.store-mark--20 { width: 20px; height: 20px; border-radius: 5px; font-size: 9px; }
.store-mark--32 { width: 32px; height: 32px; border-radius: 8px; font-size: 12px; }
.store-label { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; line-height: 16px; color: var(--text-2); }

/* Variável dentro de resposta pronta e no editor */
.var-chip { display: inline; padding: 1px 4px; border-radius: 4px; background: var(--badge-blue-bg); color: var(--badge-blue-tx); font-size: 13px; }
.var-chip--empty { background: var(--badge-amber-bg); color: var(--badge-amber-tx); }

/* Gaveta larga (Nova solicitação) */
.drawer--wide { width: min(400px, 100vw); display: flex; flex-direction: column; }
.drawer__header { flex: none; height: var(--header-h); display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-2) 0 var(--sp-5); border-bottom: 1px solid var(--border); }
.drawer__body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: 18px; }
.drawer__footer { flex: none; display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); }

/* Item de solicitação no painel */
.request-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-ctrl); color: inherit; text-decoration: none; transition: background-color var(--t-fast); }
.request-item:hover { background: var(--bg-hover); text-decoration: none; }

/* Prazo com contagem regressiva (frente Chargebacks) */
.countdown { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Barras de rolagem finas */
.app * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ==========================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 1279px) {
  .col--panel { display: none; }                 /* vira .drawer aberto pelo botão "Cliente e pedido" */
}
@media (max-width: 1023px) {
  .secnav--inbox { display: none; }              /* visões viram um seletor no cabeçalho da lista */
  .app--inbox { flex-wrap: wrap; }
  .col--list { flex: 1 1 320px; }
}
@media (max-width: 767px) {
  .app { flex-direction: column; }
  .rail { flex: none; flex-direction: row; justify-content: space-between; padding: var(--sp-2) var(--sp-3); border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .rail__spacer { display: none; }
  .rail__logo { margin: 0; }
  .page { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
}

/* Movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
