/* =========================================================================
   HD Ferragens — Área do Representante
   Sistema de design (preto/branco, identidade HD)
   ========================================================================= */

:root {
  /* Cores de marca (Manual da Marca HD Ferragens) */
  --hd-blue: #10318F;       /* cor primária — Hex oficial */
  --hd-blue-dark: #0B2468;
  --hd-blue-2: #1D44B8;     /* hover */
  --hd-blue-soft: rgba(16, 49, 143, 0.10);
  --hd-black: #222222;      /* neutra escura oficial */
  --hd-white: #ffffff;
  --accent: #E57818;        /* cor secundária — Hex oficial */
  --accent-dark: #C4630C;
  --accent-soft: rgba(229, 120, 24, 0.12);

  /* Neutros */
  --bg: #f2f2f2;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8eb;
  --border-strong: #d4d7dc;
  --text: #222222;
  --text-muted: #6b7280;
  --text-faint: #9aa0a8;

  /* Status */
  --green: #1f9d55;
  --green-soft: rgba(31, 157, 85, 0.12);
  --amber: #d98a00;
  --amber-soft: rgba(217, 138, 0, 0.12);
  --red: #d23b3b;
  --red-soft: rgba(210, 59, 59, 0.12);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.12);

  /* Gráficos — mudam junto com o tema (grade e rótulos) */
  --chart-grid: #eef0f2;
  --chart-ink: #222222;

  /* Layout */
  --sidebar-w: 248px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16, 17, 20, 0.06), 0 1px 2px rgba(16, 17, 20, 0.04);
  --shadow-lg: 0 8px 30px rgba(16, 17, 20, 0.12);
  --font: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  color-scheme: light;
}

/* =========================================================================
   TEMA ESCURO — só troca as variáveis; o resto do CSS continua igual.
   Ativado por data-theme="dark" no <html> (hd-tema.js, antes do 1º paint).
   A sidebar segue no azul da marca (bom nos dois temas). O azul/laranja/verde/
   vermelho de MARCA e STATUS não mudam — funcionam sobre fundo escuro.
   ========================================================================= */
:root[data-theme="dark"] {
  --bg: #0e1420;
  --surface: #161d2b;
  --surface-2: #1e2736;
  --border: #2a3446;
  --border-strong: #3b4658;
  --text: #e7eaef;
  --text-muted: #a6b0bd;
  --text-faint: #808b9a;
  --hd-blue-soft: rgba(60, 110, 224, 0.22);
  --accent-soft: rgba(229, 120, 24, 0.20);
  --green-soft: rgba(31, 157, 85, 0.20);
  --amber-soft: rgba(217, 138, 0, 0.22);
  --red-soft: rgba(210, 59, 59, 0.20);
  --blue-soft: rgba(37, 99, 235, 0.24);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.6);
  --chart-grid: #273044;
  --chart-ink: #e7eaef;
  color-scheme: dark;
}

/* Reset ------------------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
/* Gavetas (drawer) ficam fora da tela à direita com translateX(100%).
   overflow-x:clip na raiz impede que isso gere rolagem horizontal, sem
   criar contêiner de rolagem (o cabeçalho/menu "sticky" segue funcionando). */
html { overflow-x: clip; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Impede que gavetas (drawer) fora da tela criem rolagem horizontal.
     overflow-x:clip recorta sem criar contêiner de rolagem, então o
     cabeçalho/menu "sticky" continua funcionando normalmente. */
  overflow-x: clip;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: 14px; }
ul { list-style: none; }

/* =========================================================================
   LOGO / MARCA
   ========================================================================= */
.brand-logo img { display: block; height: 38px; width: auto; }
/* Cartão branco que segura a logo colorida sobre fundos azuis */
.logo-card {
  background: #fff; border-radius: 12px; padding: 9px 14px;
  display: inline-flex; align-items: center; box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.logo-card .brand-logo img { height: 34px; }

/* Fallback (enquanto a logo.png não está na pasta) — wordmark no estilo HD */
.logo-fallback { display: none; align-items: center; gap: 10px; }
.logo-mark { width: 40px; height: 40px; flex: none; }
.logo-word { line-height: 1; }
.logo-word b {
  font-style: italic; font-weight: 800; font-size: 26px;
  letter-spacing: -0.5px; color: var(--hd-blue);
}
.logo-word span {
  display: block; font-style: italic; font-weight: 700;
  font-size: 10.5px; letter-spacing: .5px; color: var(--hd-black);
  text-transform: none; margin-top: 1px;
}

/* =========================================================================
   LOGIN
   ========================================================================= */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.login-brand {
  background: linear-gradient(160deg, var(--hd-blue) 0%, var(--hd-blue-dark) 100%);
  color: var(--hd-white);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}
/* Logo grande e centralizada no topo */
.brand-logo-top { width: 100%; display: flex; justify-content: center; }
.logo-card-lg { padding: 22px 34px; border-radius: 16px; }
.logo-card-lg .brand-logo img { height: 74px; }
.logo-card-lg .logo-fallback .logo-mark { width: 64px; height: 64px; }
.logo-card-lg .logo-word b { font-size: 42px; }
.logo-card-lg .logo-word span { font-size: 15px; }
.brand-title { max-width: 460px; }
.brand-slogan {
  font-size: 21px; font-weight: 600; font-style: italic; line-height: 1.4;
  color: rgba(255,255,255,0.92); max-width: 480px;
}
.login-brand::after {
  content: "";
  position: absolute;
  right: -120px; bottom: -120px;
  width: 360px; height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
}
.login-brand .logo { font-size: 28px; }
.login-brand h1 {
  font-size: 38px;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.5px;
  max-width: 460px;
}
.login-brand .tagline { color: rgba(255,255,255,0.6); max-width: 420px; margin-top: 16px; }
.login-brand .features { display: flex; flex-direction: column; gap: 14px; }
.login-brand .features li { display: flex; gap: 12px; align-items: center; color: rgba(255,255,255,0.85); }
.login-brand .features .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.login-card .sub { color: var(--text-muted); margin: 8px 0 28px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 7px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--hd-blue); box-shadow: 0 0 0 3px var(--hd-blue-soft); }

/* ---- Usuários e perfis (painel admin) ---- */
.usr-form { margin-bottom: 18px; border-left: 4px solid var(--hd-blue); }
.usr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.usr-grid .field select { width: 100%; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.usr-grid .field select:focus { outline: none; border-color: var(--hd-blue); box-shadow: 0 0 0 3px var(--hd-blue-soft); }
.usr-perfil-desc { display: block; font-size: 12px; margin-top: 6px; }
.usr-email-hint { display: block; font-size: 12px; margin-top: 6px; }
.usr-grid .field input.locked { background: #eef1f6; color: var(--text-muted); cursor: not-allowed; border-style: dashed; }
.usr-form-foot { display: flex; align-items: center; gap: 12px; margin-top: 4px; flex-wrap: wrap; }
.usr-msg { font-size: 13px; font-weight: 600; }
.usr-acoes { white-space: nowrap; text-align: right; }
.usr-acoes .btn { margin-left: 4px; }
.usr-acoes .btn svg { width: 15px; height: 15px; vertical-align: -2px; }
.usr-acoes .usr-del:hover { color: var(--red); background: var(--red-soft, #fdecec); }
table.data tr.usr-off td { opacity: .55; }
.usr-toast { display: inline-block; margin-left: 12px; font-size: 12.5px; font-weight: 600; color: var(--green); background: var(--green-soft); padding: 4px 10px; border-radius: 999px; }
@media (max-width: 680px) { .usr-grid { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background .15s, transform .05s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }

/* Bloco "Instalar como app" nos guias Como usar (PWA) */
.install-box { margin-top: 16px; background: var(--accent-soft); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.install-box.ok { background: var(--green-soft); border-color: rgba(31,157,85,.35); }
.install-h { font-weight: 800; font-size: 13.5px; }
.install-steps { display: none; margin-top: 10px; padding: 11px 13px; border-radius: 10px; background: rgba(16,49,143,.06); border: 1px solid rgba(16,49,143,.20); font-size: 12.5px; color: var(--text); line-height: 1.6; }
.install-steps.destaque { animation: instFlash 1.2s ease; }
@keyframes instFlash { 0%, 100% { box-shadow: 0 0 0 0 rgba(229,120,24,0); } 30% { box-shadow: 0 0 0 4px rgba(229,120,24,.38); border-color: rgba(229,120,24,.6); } }
.btn-primary { background: var(--hd-blue); color: #fff; }
.btn-primary:hover { background: var(--hd-blue-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 8px 12px; font-size: 13px; }

.login-error {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(210,59,59,.3);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-hint { margin-top: 20px; font-size: 12.5px; color: var(--text-faint); text-align: center; }
.link-esqueci {
  display: block; width: 100%; margin: 14px 0 0;
  background: none; border: none; cursor: pointer;
  color: var(--hd-blue); font-size: 13px; font-weight: 600; text-align: center;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-esqueci:hover { color: var(--accent); }
.login-aviso {
  margin-top: 12px; padding: 11px 13px;
  background: var(--accent-soft); border: 1px solid rgba(229,120,24,.35);
  border-radius: var(--radius-sm); font-size: 13px; color: var(--text); text-align: center; line-height: 1.45;
}

/* ---- Recuperação de senha (login) ---- */
.recuperar-box { margin-top: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2, #f6f8fc); }
.recuperar-box .rec-intro { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.5; }
.recuperar-box .field { margin-bottom: 12px; }

/* ---- Criar/definir senha: força + requisitos ---- */
.ds-sub { font-size: 13.5px; color: var(--text-muted); margin: 6px 0 22px; line-height: 1.5; }
.pw-strength { display: flex; align-items: center; gap: 10px; margin: -6px 0 10px; }
.pw-bar { display: flex; gap: 5px; flex: 1; }
.pw-bar span { height: 6px; flex: 1; border-radius: 3px; background: #e5e7eb; transition: background .2s; }
.pw-bar.fraca span:nth-child(-n+1) { background: #d23b3b; }
.pw-bar.media span:nth-child(-n+2) { background: #E57818; }
.pw-bar.forte span:nth-child(-n+3) { background: #1f9d55; }
.pw-bar.muito-forte span:nth-child(-n+4) { background: #1f9d55; }
.pw-rot { font-size: 12px; font-weight: 700; min-width: 76px; text-align: right; }
.pw-rot.fraca { color: #d23b3b; } .pw-rot.media { color: #E57818; } .pw-rot.forte, .pw-rot.muito-forte { color: #1f9d55; }
.pw-reqs { list-style: none; padding: 0; margin: 8px 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.pw-reqs li { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.pw-reqs li.ok { color: var(--green, #1f9d55); }
.pw-reqs li .mk { display: inline-flex; width: 16px; justify-content: center; font-weight: 700; }
.pw-match { display: block; font-size: 12.5px; font-weight: 600; margin-top: 7px; min-height: 16px; }
.pw-match.ok { color: var(--green, #1f9d55); }
.pw-match.no { color: #d23b3b; }
.ds-sucesso { text-align: center; }
.ds-ok-ic { width: 64px; height: 64px; border-radius: 50%; background: var(--green-soft, #e6f6ee); color: var(--green, #1f9d55); font-size: 34px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin: 6px auto 16px; }
@media (max-width: 480px) { .pw-reqs { grid-template-columns: 1fr; } }

/* =========================================================================
   APP SHELL
   ========================================================================= */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--hd-blue) 0%, var(--hd-blue-dark) 100%);
  color: rgba(255,255,255,0.75);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  padding: 20px 18px 18px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar .brand small { color: rgba(255,255,255,0.6); font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; }
.sidebar .brand .logo { color: #fff; font-size: 20px; }
.sidebar .brand small { display: block; color: rgba(255,255,255,0.45); font-size: 11px; font-weight: 500; letter-spacing: .3px; }

.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-section { color: rgba(255,255,255,0.35); font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; padding: 14px 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ico { width: 18px; height: 18px; flex: none; }
.nav-item .badge {
  margin-left: auto; background: rgba(255,255,255,0.15); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
}
.nav-item.active .badge { background: rgba(0,0,0,0.25); }

.sidebar .user {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar .user .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.sidebar .user .meta { overflow: hidden; }
.sidebar .user .meta strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user .meta span { font-size: 11.5px; color: rgba(255,255,255,0.5); }
.sidebar .user .logout { margin-left: auto; color: rgba(255,255,255,0.6); padding: 6px; border-radius: 6px; }
.sidebar .user .logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* Botão "Sair de todos os aparelhos" — logo abaixo do cartão do usuário.
   Serve para quem perdeu o celular ou esqueceu o painel aberto no computador
   de um cliente: derruba TODAS as sessões e faz o código por e-mail ser
   pedido de novo em cada aparelho, sem depender do administrador. */
.sidebar .user-extra { padding: 0 14px 14px; }
.sidebar .user-extra .sair-tudo {
  display: block; width: 100%; text-align: center;
  padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.78);
  border: 1px solid rgba(255,255,255,0.14);
  font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.25;
  cursor: pointer; transition: background .15s, color .15s;
}
.sidebar .user-extra .sair-tudo:hover { background: rgba(255,255,255,0.14); color: #fff; }
.sidebar .user-extra .sair-tudo:focus-visible { outline: 2px solid rgba(255,255,255,0.6); outline-offset: 2px; }
.sidebar .user-extra .sair-tudo[disabled] { opacity: .6; cursor: default; }


/* Conteúdo ---------------------------------------------------------------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.backdrop { display: none; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; }
.topbar .crumb { color: var(--text-faint); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .period {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface);
  font-weight: 600; font-size: 13px;
}
.topbar .period select { border: none; background: none; font-weight: 600; cursor: pointer; }
.hamburger { display: none; }

.content { padding: 28px; max-width: 1320px; width: 100%; }
.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* =========================================================================
   COMPONENTES
   ========================================================================= */
.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .spacer { flex: 1; }
.card-head .link { color: var(--accent); font-weight: 600; font-size: 13px; }

/* KPI */
.kpi { padding: 18px 20px; }
.kpi .label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .ico-box {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.kpi .value { font-size: 27px; font-weight: 800; letter-spacing: -0.6px; margin-top: 12px; }
.kpi .delta { font-size: 12.5px; font-weight: 600; margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--text-faint); }
/* KPI clicável com mini-gráfico */
.kpi-clic, .kpi-acao { cursor: pointer; transition: box-shadow .15s, transform .05s; }
.kpi-clic:hover, .kpi-acao:hover { box-shadow: 0 6px 18px rgba(28, 63, 156, .12); transform: translateY(-1px); }
.kpi.kpi-on { outline: 2px solid var(--hd-blue); outline-offset: -1px; }
.kpi-clic:active { transform: translateY(0); }
.city-chip[data-pinuf] { cursor: pointer; }
.city-chip[data-pinuf]:hover { outline: 2px solid var(--hd-blue); outline-offset: 1px; }
.uf-clic:hover { background: var(--surface-2); }
tr[data-selmes] { cursor: pointer; }
tr[data-selmes]:hover td { background: var(--surface-2); }
.kpi-spark { position: relative; margin-top: 12px; }
.kpi-spark .spark { width: 100%; height: 34px; }
.kpi-spark .spark-zoom { position: absolute; right: 0; top: 0; opacity: 0; transition: opacity .15s; }
.kpi-clic:hover .spark-zoom { opacity: 1; }

/* Progresso de meta */
.goal { display: flex; flex-direction: column; gap: 14px; }
.goal .bar { height: 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.goal .bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); transition: width .6s ease; }
.goal .scale { display: flex; justify-content: space-between; color: var(--text-faint); font-size: 12px; }

/* Tabela */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px;
  padding: 12px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2);
}
table.data td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .strong { font-weight: 700; }

.client-cell { display: flex; align-items: center; gap: 10px; }
/* Avatar/código (rep ou cliente) — GLOBAL: fora da .client-cell (listas
   "Precisam de atenção", cobrança, dropdowns de busca) o código aparecia como
   número solto, desalinhado do nome, porque a regra era escopada. */
.av {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--hd-blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
/* Variações INLINE do quadradinho (padrão p/ código de representante no meio
   de títulos e linhas de texto — ver avRep() no admin.js) */
.av.av-badge { display: inline-flex; vertical-align: middle; width: 22px; height: 22px; font-size: 10px; border-radius: 6px; margin-right: 7px; position: relative; top: -1px; }
.av.av-mini  { display: inline-flex; vertical-align: middle; width: 19px; height: 19px; font-size: 9.5px; border-radius: 5px; margin: 0 5px 0 1px; position: relative; top: -1px; }

/* Badges/pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.gray { background: var(--chart-grid); color: var(--text-muted); }

/* Toolbar de filtros */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; background: var(--surface); min-width: 240px; flex: 1; max-width: 360px;
}
.search input { border: none; outline: none; width: 100%; background: none; }
.select {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; background: var(--surface); font-weight: 500; cursor: pointer;
}

/* Faturamento por região (barras horizontais no Mapa do admin) */
.reg-chart { display: flex; flex-direction: column; gap: 12px; }
.reg-row { display: flex; align-items: center; gap: 12px; }
.reg-nome { flex: none; width: 104px; font-size: 13px; font-weight: 600; color: var(--text); }
.reg-bar { flex: 1; min-width: 0; height: 16px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.reg-bar > span { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--hd-blue), var(--accent)); }
.reg-val { flex: none; min-width: 176px; text-align: right; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .reg-nome { width: 78px; font-size: 12px; } .reg-val { min-width: 132px; font-size: 11.5px; } }

/* Chart */
.chart { width: 100%; height: 240px; position: relative; }
.chart svg { cursor: ew-resize; touch-action: none; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 6;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); font-size: 12px; line-height: 1.5;
  padding: 8px 11px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.14);
  white-space: nowrap; transform: translate(-50%, -115%); display: none;
}
.chart-tip strong { font-weight: 700; }

/* Lista de pedidos recentes */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-item .ic { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none; }
.feed-item .ic.green { background: var(--green-soft); color: var(--green); }
.feed-item .ic.amber { background: var(--amber-soft); color: var(--amber); }
.feed-item .ic.blue { background: var(--blue-soft); color: var(--blue); }
.feed-item .ic.red { background: var(--red-soft); color: var(--red); }
.feed-item .txt { flex: 1; min-width: 0; }
.feed-item .txt strong { font-size: 13.5px; }
.feed-item .txt span { display: block; color: var(--text-muted); font-size: 12.5px; }
.feed-item .amt { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Ranking */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-row .pos { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; background: var(--chart-grid); color: var(--text-muted); flex: none; }
.rank-row.me { background: var(--accent-soft); margin: 0 -12px; padding: 11px 12px; border-radius: var(--radius-sm); border-bottom: none; }
.rank-row.me .pos { background: var(--accent); color: #fff; }
.rank-row .nm { flex: 1; font-weight: 600; }
.rank-row .vl { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Sugestões de recompra */
.suggest { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.suggest:last-child { border-bottom: none; }
.suggest .txt { flex: 1; }
.suggest .txt strong { font-size: 13.5px; }
.suggest .txt span { display: block; color: var(--text-muted); font-size: 12px; }

/* Alertas */
.alert-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--amber-soft); border: 1px solid rgba(217,138,0,.3);
  color: #8a5a00; padding: 13px 16px; border-radius: var(--radius); margin-bottom: 18px;
}
.alert-banner .ic { flex: none; }
.alert-banner strong { color: #7a4f00; }
.alert-banner .btn { margin-left: auto; }

.section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin: 26px 0 14px; }

.muted { color: var(--text-muted); }
.empty { padding: 40px; text-align: center; color: var(--text-faint); }

.stock-bar { height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; width: 90px; display: inline-block; }
.stock-bar > span { display: block; height: 100%; border-radius: 999px; }

/* Mini-tendência (sparkline) */
.spark { width: 84px; height: 28px; vertical-align: middle; }

/* Variante de alerta com cor de destaque */
.alert-banner.accent { background: var(--accent-soft); border-color: rgba(229,120,24,.35); color: var(--accent-dark); }
.alert-banner.accent strong { color: var(--accent-dark); }
.alert-banner.accent .ic { color: var(--accent); }

/* Variante de alerta crítico (vermelho) — ex.: meta não batida 2 meses seguidos */
.alert-banner.red { background: var(--red-soft); border-color: rgba(210,59,59,.4); color: #9a1b1b; }
.alert-banner.red strong { color: #7e1414; }
.alert-banner.red .ic { color: var(--red); }
.alert-banner.col { display: block; align-items: stretch; }
.alert-banner.col .ab-head { display: flex; align-items: center; gap: 12px; }
.alert-banner .ab-list { margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 7px 18px; }
.alert-banner .ab-list li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.alert-banner .ab-list .ab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); flex: none; }

/* Oportunidades de venda cruzada (Visão Geral) */
.card-oport { border-left: 4px solid var(--accent); }
.oport-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.oport-row:hover { background: var(--surface-2); }
.oport-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.oport-chip { font-size: 10.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent-dark); padding: 2px 8px; border-radius: 999px; }
.oport-chip-mais { background: none; color: var(--text-faint); }

/* Listas de ranking (Top 10 clientes / itens) — usadas no rep e no admin */
.rk-list { display: flex; flex-direction: column; }
.rk-item { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rk-item:last-child { border-bottom: none; }
.rk-item[data-cliente-open], .rk-item[data-rep-open] { cursor: pointer; transition: background .12s; }
.rk-item[data-cliente-open]:hover, .rk-item[data-rep-open]:hover { background: var(--surface-2); }
.rk-pos { flex: none; width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }

/* Seleção múltipla (filtros do Mapa do admin): botão + painel de checkboxes */
.msel { position: relative; }
.msel-btn { display: inline-flex; align-items: center; gap: 8px; font-family: inherit; font-size: 13.5px; }
.msel-btn::after { content: "▾"; font-size: 10px; color: var(--text-muted); }
.msel-pop {
  /* z-index acima dos controles do Leaflet (1000) — senão o mapa cobre a lista */
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 1200;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .16); width: 86vw; max-width: 330px; /* = min(330px, 86vw), sem depender de min() */
}
.msel.open .msel-pop { display: block; }
.msel-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.msel-list { max-height: 280px; overflow: auto; padding: 6px; }
.msel-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.msel-item:hover { background: var(--surface-2); }
.msel-item input { width: 15px; height: 15px; flex: none; cursor: pointer; accent-color: var(--hd-blue); }
.msel-item .muted { margin-left: auto; font-size: 11.5px; flex: none; }

/* Busca rápida de representante (topo do Painel do Administrador) */
.rep-search { position: relative; }
.rep-search > input { width: 240px; max-width: 42vw; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13.5px; background: var(--surface); color: var(--text); font-family: inherit; }
.rep-search > input:focus { outline: none; border-color: var(--hd-blue); box-shadow: 0 0 0 3px var(--hd-blue-soft); }
.rep-search-res { position: absolute; top: calc(100% + 6px); right: 0; width: 340px; max-width: 86vw; max-height: 340px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 70; display: none; }
.rep-search-res.open { display: block; }
.rep-search-res .rs-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.rep-search-res .rs-item:last-child { border-bottom: none; }
.rep-search-res .rs-item:hover { background: var(--surface-2); }
.rep-search-res .rs-empty { padding: 12px; color: var(--text-muted); font-size: 13px; }

/* Tabela de Clientes: em telas estreitas, esconde colunas secundárias para caber
   sem rolagem (a info continua disponível ao abrir o cliente). */
@media (max-width: 1500px) {
  #view-clientes .col-abc, #view-clientes .col-trend { display: none; }
}
@media (max-width: 1300px) {
  #view-clientes .col-ticket { display: none; }
}

/* Botão WhatsApp */
.btn-wa {
  display: inline-flex; align-items: center; gap: 6px;
  background: #25d366; color: #fff; font-weight: 600; font-size: 13px;
  padding: 7px 11px; border-radius: var(--radius-sm); white-space: nowrap;
  transition: background .15s;
}
.btn-wa:hover { background: #1ebe5b; }
.btn-wa svg { width: 16px; height: 16px; }

/* Botão de ícone (sino) */
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface);
}
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; right: 0; top: 48px; width: 320px; max-width: 86vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 40; overflow: hidden; display: none;
}
.notif-panel.open { display: block; }
.notif-head { display: flex; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.notif-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item .txt { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-foot { padding: 12px 16px; text-align: center; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer; }
.notif-foot:hover { background: var(--accent-soft); }

/* Celular: o painel ancorado no sino estoura a tela. Vira uma FOLHA fixa no
   rodapé (estilo app), largura total, rolável, e os nomes quebram linha em
   vez de sair cortados. Tocar fora dela fecha (mesmo handler de sempre). */
@media (max-width: 820px) {
  .notif-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: auto; max-width: none;
    border-radius: 16px 16px 0 0; border-left: none; border-right: none; border-bottom: none;
    max-height: 70vh; overflow-y: auto; z-index: 80;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, .28);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .notif-item .txt { white-space: normal; line-height: 1.35; }
  .notif-item { padding: 13px 16px; }
}

/* ---- Barras rotuladas (aging da inadimplência / Pareto de concentração) ---- */
.aging-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.aging-rot { flex: none; width: 108px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.aging-track { flex: 1; height: 14px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.aging-fill { display: block; height: 100%; border-radius: 5px; }
.aging-val { flex: none; font-size: 12.5px; min-width: 120px; text-align: right; }
@media (max-width: 600px) {
  .aging-row { flex-wrap: wrap; gap: 4px 10px; }
  .aging-rot { width: auto; flex: 1; }
  .aging-val { min-width: 0; }
  .aging-track { flex: 1 1 100%; order: 3; }
}

/* ---- Sazonalidade por família (mapa de calor, admin) ---- */
.hm-grid { display: grid; grid-template-columns: minmax(84px, 150px) repeat(var(--hm-cols, 12), 1fr); gap: 3px; align-items: center; }
.hm-rot { font-size: 11.5px; font-weight: 600; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 6px; }
.hm-mes { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--text-faint); overflow: hidden; }
/* Tela estreita: nome do mês POR EXTENSO fica na vertical (não corta nem vira sigla) */
@media (max-width: 980px) {
  .hm-mes { writing-mode: vertical-rl; transform: rotate(180deg); justify-self: center; align-self: end; white-space: nowrap; line-height: 1.1; padding: 2px 0; font-size: 10px; }
}
.hm-cel { height: 22px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 9px; }
/* ★ pico do ano da família: dourada e maior — o antigo ● branco sumia no azul */
.hm-pico { color: #ffd23e; font-size: 13px; line-height: 1; text-shadow: 0 1px 2px rgba(0, 0, 0, .45); }
/* Matriz rep × família: % escrito dentro da célula + nome COMPLETO na vertical */
.hm-fam {
  writing-mode: vertical-rl; transform: rotate(180deg);
  justify-self: center; align-self: end;
  font-size: 10.5px; font-weight: 700; color: var(--text-muted);
  white-space: nowrap; line-height: 1; padding: 2px 0;
}
.hm-grid .hm-cel { font-size: 10px; font-weight: 700; letter-spacing: -.2px; }
@media (max-width: 480px) {
  .hm-grid { grid-template-columns: minmax(64px, 84px) repeat(var(--hm-cols, 12), 1fr); gap: 2px; }
  .hm-cel { height: 18px; } .hm-rot { font-size: 10.5px; }
  .hm-grid .hm-cel { font-size: 7.5px; letter-spacing: -.3px; }
  .hm-fam { font-size: 9px; }
}
/* Lacuna de mix (rep não vende a família) — VERMELHO forte para saltar aos olhos */
.hm-zero { background: #d64545 !important; color: #fff !important; }

/* Elementos clicáveis dos gráficos (matriz, aging, pareto) */
.hm-clic { cursor: pointer; }
.hm-rot.hm-clic:hover { color: var(--hd-blue); text-decoration: underline; }
.hm-zero.hm-clic:hover { filter: brightness(1.15); }
.aging-clic { cursor: pointer; border-radius: 8px; }
.aging-clic:hover { background: var(--surface-2); }
/* Destaque temporário ao pular para um card (ex.: Pareto → Top 10 clientes) */
.flash-card { animation: flashCard 1.6s ease; }
@keyframes flashCard { 0%, 100% { box-shadow: none; } 25% { box-shadow: 0 0 0 4px rgba(229, 120, 24, .55); } }

/* Aviso de sessão expirando (idle-timeout.js) */
.sessao-aviso {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%);
  z-index: 250; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  background: #1c2430; color: #fff; font-size: 13.5px; line-height: 1.4;
  padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  max-width: 92vw; transition: transform .25s ease; /* fallback p/ navegadores sem min() */
  max-width: min(92vw, 520px);
}
.sessao-aviso.show { transform: translate(-50%, 0); }

/* ===== 📺 Modo TV (admin): Visão Geral em tela cheia para o telão da equipe =====
   Some menu lateral e barra do topo; o conteúdo ganha ~12% de escala para leitura
   à distância. A .tv-bar flutua no canto com o relógio e o botão de sair. */
body.modo-tv .app { grid-template-columns: 1fr; }
body.modo-tv .sidebar, body.modo-tv .topbar, body.modo-tv .backdrop { display: none; }
body.modo-tv .content { max-width: none; padding: 26px 32px 60px; zoom: 1.12; }
.tv-bar {
  position: fixed; right: 14px; bottom: 14px; z-index: 400;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface, #fff); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 8px 6px 16px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(16, 49, 143, .2);
}
.tv-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); animation: tvPulse 2s infinite; }
@keyframes tvPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
#btn-tv { font-size: 16px; }
/* Modo TV é para telão/computador — no celular o botão não aparece */
@media (max-width: 820px) { #btn-tv { display: none; } }

/* ===== Tour guiado (hd-tour.js): holofote + cartão do passo ===== */
.tour-hole {
  position: fixed; z-index: 500; pointer-events: none; border-radius: 12px;
  box-shadow: 0 0 0 200vmax rgba(12, 18, 34, .62);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
}
.tour-card {
  position: fixed; z-index: 501; background: var(--surface, #fff); color: var(--text, #1f2430);
  border-radius: 14px; padding: 14px 16px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  font-size: 13.5px; line-height: 1.5;
}
.tour-passo { font-size: 11px; font-weight: 700; color: var(--accent, #e57818); text-transform: uppercase; letter-spacing: .4px; }
.tour-tit { font-weight: 800; font-size: 15px; margin: 4px 0 6px; }
.tour-txt { color: var(--text-muted, #6b7280); }
.tour-acoes { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

/* 🛣️ Modo estrada: aviso de sem conexão (app.js) */
.offline-aviso {
  position: fixed; left: 50%; top: 10px; transform: translateX(-50%);
  z-index: 260; max-width: 92vw; max-width: min(92vw, 560px); /* 1º valor = fallback sem min() */
  background: #7a4d00; color: #fff; font-size: 13px; line-height: 1.4;
  padding: 9px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

/* 🎉 Confete (zerou a agenda do dia — burstConfetti no app.js) */
.confetti-box { position: fixed; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; z-index: 600; overflow: hidden; }
.confetti-box i {
  position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px;
  animation: confettiFall 2s ease-in forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(560deg); opacity: .85; }
}

/* Tooltip rico dos gráficos (hd-tips.js — elementos com data-tip) */
.hd-tip {
  position: fixed; z-index: 300; display: none; pointer-events: none;
  max-width: 280px; padding: 8px 11px; border-radius: 9px;
  background: #1c2430; color: #fff; font-size: 12px; line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}

/* Matriz rep × família: SEM rolagem interna (rola com a página) e com
   escrita LEGÍVEL — células mais altas e fontes maiores (pedido 15/jul);
   o cabeçalho das famílias fica FIXO sob a barra do topo durante a rolagem,
   então nunca se perde a referência de qual coluna é qual. */
.hm-compact { gap: 3px; }
.hm-compact .hm-cel { height: 20px; border-radius: 4px; font-size: 11px; letter-spacing: -.2px; }
.hm-compact .hm-rot { font-size: 12px; }
.hm-compact .hm-fam { font-size: 11.5px; }
/* Cabeçalho das famílias numa FAIXA própria (.hm-head): gruda INTEIRA sob a
   barra do topo, com fundo opaco — nada de nomes soltos sobrepondo as células
   ao rolar (correção 15/jul). */
.hm-head { margin-bottom: 3px; }
@media (min-width: 821px) {
  .hm-head {
    position: sticky; top: 72px; z-index: 6; /* topbar sticky termina em ~73px */
    background: var(--surface);
    box-shadow: 0 6px 8px -8px rgba(0, 0, 0, .35);
    padding: 4px 0;
  }
}

/* ---- Comparador de representantes (lado a lado) ---- */
.cmp-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.cmp-row:last-of-type { border-bottom: none; }
.cmp-row.cmp-head { border-bottom: 2px solid var(--border-strong); padding-bottom: 10px; }
.cmp-met { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.cmp-val { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.cmp-val.win { color: var(--green); font-weight: 800; }
@media (max-width: 480px) { .cmp-row { grid-template-columns: 1fr 1fr 1fr; gap: 6px; } .cmp-met { font-size: 11.5px; } .cmp-val { font-size: 12px; } }

/* ---- Agenda da semana (Carteira do dia do representante) ---- */
.agd-grupo { margin: 12px 0 4px; font-weight: 800; font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.agd-grupo:first-child { margin-top: 4px; }

/* ---- Assuntos de cobrança: etiqueta + explicação cinza ----
   Desktop: lado a lado (como sempre foi). Celular: a explicação desce para a
   linha de baixo com a LARGURA TOTAL do cartão — legível, sem quebrar palavra
   por palavra numa coluna espremida. */
.cob-motivo { display: flex; gap: 7px; align-items: baseline; margin-top: 3px; }
.cob-motivo .cob-det { font-size: 12px; }
.cob-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
@media (max-width: 820px) {
  .cob-motivo { flex-wrap: wrap; row-gap: 3px; }
  .cob-motivo .cob-det { flex: 1 1 100%; padding-left: 2px; line-height: 1.45; }
  /* Cartão da Cobrança: botão "Ver / Cobrar" e o valor descem para uma
     linha própria no rodapé do cartão, liberando a largura para os textos. */
  #view-cobranca .rank-row { flex-wrap: wrap; }
  #view-cobranca .cob-right { flex-direction: row-reverse; width: 100%; justify-content: space-between; align-items: center; margin-top: 9px; }
}

/* Carteira do dia — lista de ações */
.action-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.action-row:last-child { border-bottom: none; }
.action-row .txt { flex: 1; min-width: 0; }
.action-row .txt strong { font-size: 14px; }
.action-row .txt span { display: block; color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.action-btns { display: flex; gap: 8px; align-items: center; flex: none; }

/* Campanha */
.campaign {
  display: flex; gap: 16px; align-items: flex-start;
  background: linear-gradient(135deg, var(--hd-blue), var(--hd-blue-dark));
  color: #fff; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.campaign-ic { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; flex: none; color: var(--accent); }
.campaign-ic svg { width: 24px; height: 24px; }
.campaign-body { flex: 1; }
.campaign-top { display: flex; align-items: center; gap: 10px; }
.campaign-top strong { font-size: 16px; }
.campaign .muted { color: rgba(255,255,255,.75) !important; }
.campaign .goal .bar { background: rgba(255,255,255,.25); }
.campaign .goal .scale { color: rgba(255,255,255,.8); }
.campaign .goal .bar > span { background: var(--accent); }

/* Drawer (detalhe do cliente) */
.drawer-backdrop { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.4); z-index: 70; }
.drawer-backdrop.show { display: block; }
.drawer {
  /* top+bottom (sem height:100vh): no iOS Safari o 100vh inclui a área sob a
     barra do navegador e escondia o rodapé do drawer; ancorar nas duas pontas
     acompanha o viewport visível em qualquer navegador. */
  position: fixed; top: 0; right: 0; bottom: 0; width: 820px; max-width: 95vw;
  background: var(--surface); z-index: 80; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-head .spacer { flex: 1; }
.drawer-close { margin-left: auto; width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.drawer-close:hover { background: var(--surface-2); }
.drawer-body { padding: 18px 20px; overflow-y: auto; }
.drawer-actions { display: flex; gap: 10px; margin-bottom: 18px; }
.drawer-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.drawer-stats > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.drawer-stats span { display: block; color: var(--text-muted); font-size: 12px; }
.drawer-stats strong { font-size: 16px; }
.drawer-sec { font-size: 13px; font-weight: 700; margin: 20px 0 8px; display: flex; align-items: center; gap: 8px; }

/* Dados cadastrais do cliente (ficha) */
.cad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cad-dado { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px; min-width: 0; }
.cad-dado.full { grid-column: 1 / -1; }
.cad-rot { display: block; color: var(--text-muted); font-size: 11.5px; margin-bottom: 2px; }
.cad-v { display: block; font-size: 13.5px; font-weight: 600; word-break: break-word; }
@media (max-width: 520px) { .cad-grid { grid-template-columns: 1fr; } }
/* Limite de crédito (ficha do cliente) */
.cred-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.cred-box.warn { background: var(--red-soft); border-color: rgba(210,59,59,.4); }
.cred-box .btn-wa { margin-top: 10px; }

/* Formulário de solicitação de alteração cadastral */
.cad-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cad-fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cad-fld.full { grid-column: 1 / -1; }
.cad-fld > span { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.cad-fld input, .cad-fld select { padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--text); width: 100%; }
.cad-fld input:focus, .cad-fld select:focus { outline: none; border-color: var(--hd-blue); }
.cad-ok { display: flex; gap: 12px; align-items: flex-start; background: var(--green-soft); border: 1px solid rgba(31,157,85,.35); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.cad-ok-ic { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; }
@media (max-width: 520px) { .cad-form { grid-template-columns: 1fr; } }

/* Mini-gráfico clicável (abre o gráfico grande) */
.spark-click { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; padding: 2px 4px; }
.spark-click:hover { background: var(--surface-2); outline: 1px solid var(--border); }
.spark-zoom { color: var(--text-faint); }
.spark-zoom svg { width: 13px; height: 13px; }

/* Modal (gráfico do cliente) */
.modal-backdrop { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.5); z-index: 90; }
.modal-backdrop.show { display: block; }
.modal {
  position: fixed; z-index: 100; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 94vw; max-width: 640px; max-height: 90vh; overflow: auto; /* = min(640px, 94vw), sem min() */
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none;
}
.modal.open { display: block; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }

/* Guia "Como usar": abre INTEIRO na tela (sem rolagem) em monitores comuns —
   modal mais largo e alto, menus em 2 colunas, blocos de instalação e de
   notificações lado a lado e botões numa linha só. Em telas baixas/celular,
   a rolagem interna continua como reserva. */
.modal.modal-guia { width: 96vw; max-width: 1100px; max-height: 94vh; }
.guia-body { padding: 14px 20px 16px; font-size: 12.5px; line-height: 1.42; }
.guia-body > p { margin-bottom: 9px; }
.guia-menus { list-style: disc; padding-left: 20px; margin: 0; display: grid; grid-template-columns: 1fr; gap: 6px 24px; }
.guia-menus li { break-inside: avoid; }
@media (min-width: 680px) { .guia-menus { grid-template-columns: 1fr 1fr; } }
.guia-body .install-box { margin-top: 12px; }
/* Instalação (PWA) + notificações lado a lado quando há largura (texto compacto) */
.guia-extras { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.guia-extras .install-box { font-size: 12px; }
.guia-extras .install-box p { margin: 4px 0 8px; }
@media (min-width: 760px) and (max-width: 1099px) {
  .guia-extras { grid-template-columns: 1fr 1fr; align-items: stretch; }
  .guia-extras .install-box { margin-top: 0; height: 100%; }
}
/* Telas largas (notebook/desktop): guia em DUAS REGIÕES — menus à esquerda,
   instalação + notificações + dica + botões à direita. Corta a altura quase
   pela metade: o guia abre INTEIRO, sem rolagem. */
@media (min-width: 1100px) {
  .modal.modal-guia { max-width: 1260px; }
  .modal-guia .modal-head { padding: 12px 20px; }
  .guia-extras .install-box { padding: 10px 12px; }
  .guia-menus { gap: 5px 24px; }
  .guia-body { padding: 12px 20px 14px; display: grid; grid-template-columns: 1.35fr 1fr; column-gap: 26px; align-items: start; grid-auto-rows: min-content; }
  .guia-body > p:first-of-type { grid-column: 1 / -1; }
  .guia-menus { grid-column: 1; grid-row: 2 / span 5; grid-template-columns: 1fr; align-content: start; }
  .guia-body > p.muted { grid-column: 2; margin-top: 0; font-size: 12px; }
  .guia-extras { grid-column: 2; grid-template-columns: 1fr; margin-top: 0; }
  .guia-extras .install-box { margin-top: 0; }
  .guia-body > label { grid-column: 2; margin-top: 0 !important; }
  .guia-acoes { grid-column: 2; margin-top: 0; }
}
/* Botões do rodapé do guia numa linha só (economiza um "andar" inteiro) */
.guia-acoes { display: flex; gap: 10px; margin-top: 12px; }
.guia-acoes .btn { flex: 1; margin-top: 0 !important; }
@media (max-width: 560px) { .guia-acoes { flex-direction: column; } }

/* Evolução de Vendas (Visão Geral) */
.evol-chart { width: 100%; position: relative; }
.evol-i { background: none; border: none; cursor: pointer; color: var(--text-faint); display: inline-flex; padding: 2px; margin-left: 4px; }
.evol-i svg { width: 16px; height: 16px; }
.evol-i:hover { color: var(--hd-blue); }
.evol-pop { position: absolute; z-index: 20; top: 6px; left: 6px; max-width: 320px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 14px 16px; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.evol-pop strong { display: block; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 8px; }
.evol-pop p { margin: 0; }
.evol-tip { position: absolute; z-index: 15; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.14); padding: 9px 11px; font-size: 12px; min-width: 170px; }
.evol-tip-h { font-weight: 700; margin-bottom: 5px; }
.evol-tip > div { display: flex; justify-content: space-between; gap: 14px; line-height: 1.7; }
.evol-tip > div span { color: var(--text-muted); }
.evol-tip > div.g b { color: var(--green); }
.evol-tip > div.o b { color: var(--accent); }

/* Legenda padrão dos gráficos (rodapé) — identidade visual única para todos os gráficos.
   Marcadores: mk-line (linha), mk-line.dash (linha tracejada), mk-dot (ponto), mk-sw (quadradinho).
   A cor de cada marcador vem por style inline (border-color p/ linha; background p/ ponto/quadrado). */
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; align-items: center; margin-top: 12px; font-size: 12.5px; color: var(--text-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend .mk { flex: none; display: inline-block; }
.chart-legend .mk-line { width: 16px; height: 0; border-top: 3px solid; border-radius: 2px; }
.chart-legend .mk-line.dash { border-top-style: dashed; }
.chart-legend .mk-dot { width: 9px; height: 9px; border-radius: 50%; }
.chart-legend .mk-sw { width: 11px; height: 11px; border-radius: 3px; }

/* CRM leve — registro de contato (drawer do cliente) */
.crm-form { display: grid; gap: 8px; margin: 4px 0 12px; }
.crm-form .select, .crm-form input { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 9px; font-size: 13.5px; font-family: inherit; background: var(--surface); }
.crm-form .crm-ret { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.crm-form .crm-ret input { width: auto; flex: 1; }
.crm-hist { display: flex; flex-direction: column; gap: 8px; }
.crm-item { border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; background: var(--surface-2); }
.crm-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.crm-nota { font-size: 12.5px; color: var(--text); margin-top: 4px; line-height: 1.4; }
.crm-item-top { align-items: center; }
.crm-del { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border-radius: 6px; background: none; border: none; color: var(--text-faint); cursor: pointer; flex: none; transition: background .12s, color .12s; }
.crm-del svg { width: 14px; height: 14px; }
.crm-del:hover { background: var(--red-soft); color: var(--red); }

/* Plano de ação (Central de Cobrança) */
.plano-bloco { border: 1px solid var(--border); border-left: 3px solid var(--hd-blue); border-radius: 10px; padding: 11px 12px; margin-bottom: 10px; background: var(--surface); }
.plano-acao { font-size: 12.5px; color: var(--text); background: var(--accent-soft); border-radius: 8px; padding: 7px 10px; margin: 6px 0; line-height: 1.4; }
.plano-lista { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.plano-cli { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: var(--surface-2); }

/* Estatísticas do mapa */
.mapa-stats { font-size: 12.5px; margin-top: 8px; }

/* Relatório de Comissões — cards de mês */
.com-meses { display: flex; gap: 12px; flex-wrap: wrap; }
.com-mes { flex: 1 1 150px; min-width: 150px; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer; transition: box-shadow .15s, border-color .15s; font-family: inherit; }
.com-mes:hover { box-shadow: 0 4px 14px rgba(28, 63, 156, .1); }
.com-mes.on { border-color: var(--hd-blue); box-shadow: 0 0 0 2px rgba(28, 63, 156, .15); background: var(--surface); }
.com-mes-top { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.com-mes-val { font-size: 19px; font-weight: 800; margin: 8px 0 2px; letter-spacing: -.3px; }
.data tfoot td { border-top: 2px solid var(--border-strong); padding-top: 10px; }
.com-th { cursor: pointer; user-select: none; white-space: nowrap; }
.com-th:hover { color: var(--hd-blue); }

/* Ficha Cadastral */
.ff-form { display: grid; gap: 16px; max-width: 760px; }
.ff-row { display: grid; gap: 6px; }
.ff-row > label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.ff-row .req { color: var(--red); font-weight: 700; }
.ff-form input, .ff-form textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 10px; font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); }
.ff-form input:focus, .ff-form textarea:focus { outline: none; border-color: var(--hd-blue); box-shadow: 0 0 0 3px rgba(28, 63, 156, .12); }
.ff-form textarea { resize: vertical; }
.ff-radios { display: flex; flex-wrap: wrap; gap: 18px; padding: 4px 0; }
.ff-radio { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 500; cursor: pointer; }
.ff-radio input { width: auto; }
.ff-row.err input, .ff-row.err textarea { border-color: var(--red); background: #fef2f2; }
.ff-row.err > label { color: var(--red); }
.ff-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.ff-ok { text-align: center; padding: 30px 16px; }
.ff-ok-ic { width: 56px; height: 56px; margin: 0 auto 14px; color: var(--green); }
.ff-ok-ic svg { width: 56px; height: 56px; }
.ff-ok h3 { margin: 0 0 6px; }
.ff-ok .btn { margin-top: 16px; }
.ff-anexos { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* Projeção de fechamento (run-rate, admin) */
.proj-bar { height: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.proj-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.proj-fill.green { background: linear-gradient(90deg, #1f9d55, #16a34a); }
.proj-fill.amber { background: linear-gradient(90deg, #d97706, #f59e0b); }
.proj-fill.red { background: linear-gradient(90deg, #b91c1c, #ef4444); }
.proj-risco { border-top: 1px solid var(--border); margin-top: 4px; }
.risco-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.risco-item:last-child { border-bottom: none; }

/* Qualidade de cadastro — campo de correção inline */
.cad-table td { vertical-align: top; }
.cad-table td:first-child { min-width: 170px; }
.cad-fields { display: flex; flex-direction: column; gap: 10px; min-width: 145px; }
.cad-fl { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.cad-falta { color: var(--red); font-weight: 700; }
.cad-ok { color: var(--green); font-weight: 600; }
.cad-inp { width: 100%; min-width: 140px; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text); font-weight: 400; }
.cad-inp:focus { outline: none; border-color: var(--hd-blue); box-shadow: 0 0 0 3px rgba(28, 63, 156, .12); }

/* Meta × Realizado por representante (admin → Metas) */
.mvr-list { display: flex; flex-direction: column; gap: 22px; }
.mvr-row { display: flex; align-items: center; gap: 12px; border-radius: 8px; }
.mvr-clic { cursor: pointer; transition: background .12s; }
.mvr-clic:hover { background: var(--surface-2); }
.mvr-total { padding-bottom: 20px; border-bottom: 2px solid var(--border-strong); }
.mvr-total .mvr-nome { font-weight: 800; }
.mvr-nome { width: 150px; flex: none; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mvr-bars { flex: 0 1 340px; min-width: 170px; display: flex; flex-direction: column; gap: 5px; }
.mvr-bar { display: flex; align-items: center; gap: 8px; }
.mvr-track { flex: 1; height: 13px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.mvr-fill { display: block; height: 100%; border-radius: 4px; min-width: 2px; }
.mvr-fill.meta { background: #c2cad6; }
.mvr-fill.real { background: #1f9d55; }
.mvr-fill.abaixo { background: #e0653f; }
.mvr-val { width: 74px; flex: none; text-align: right; font-size: 11.5px; font-weight: 700; color: var(--text); }
.mvr-pct { width: 52px; flex: none; text-align: right; font-weight: 700; font-size: 13px; }
.mvr-pct.ok { color: var(--green); }
.mvr-pct.low { color: var(--red); }
/* ---- Padrão "tabela → fichas" (classe tab-cards) ----
   Em telas estreitas, cada LINHA da tabela vira uma FICHA empilhada:
   células com data-l viram "rótulo → valor" (rótulo cinza à esquerda,
   valor à direita) e a célula sem data-l é o título da ficha. Vale para
   celular E tablet deitado (até 1140px, onde a barra lateral come a
   largura) — nenhuma tabela com esta classe exige rolagem lateral. */
@media (max-width: 1140px) {
  .table-wrap table.tab-cards thead { display: none; }
  .table-wrap table.tab-cards, .table-wrap table.tab-cards tbody, .table-wrap table.tab-cards tfoot,
  .table-wrap table.tab-cards tr, .table-wrap table.tab-cards td { display: block; width: 100%; }
  .table-wrap table.tab-cards tr { padding: 11px 0 12px; border-bottom: 1px solid var(--border); }
  .table-wrap table.tab-cards tr:last-child { border-bottom: none; }
  .table-wrap table.tab-cards td { border-bottom: none; padding: 3px 14px; text-align: left; white-space: normal !important; }
  .table-wrap table.tab-cards td[data-l] { position: relative; padding: 3px 14px 3px 142px; text-align: right; min-height: 21px; }
  .table-wrap table.tab-cards td[data-l]::before {
    content: attr(data-l); position: absolute; left: 14px; top: 4px;
    font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-align: left;
  }
  .table-wrap table.tab-cards td[data-l]:empty { display: none; } /* célula vazia some */
  .table-wrap table.tab-cards tfoot tr { border-top: 2px solid var(--border-strong); border-bottom: none; }
}

/* ---- Notebooks menores / tablets grandes (1141–1520px) ----
   Acima de 1140px as tabelas voltam ao formato normal, mas as mais LARGAS
   (Uso 8 col, Rankings 10 col, Usuários) ainda não cabem em notebooks de
   1280/1366px. Esconde colunas secundárias nessa faixa (mesma técnica da
   tabela de Clientes). O min-width garante que, no modo fichas (<=1140px),
   TODAS as informações continuem aparecendo. */
@media (min-width: 1141px) and (max-width: 1520px) {
  .col-uso-sec, .col-rk-sec { display: none; }   /* Uso: Região/Sessões/Tempo médio · Rankings: Pedidos/Estados */
}
@media (min-width: 1141px) and (max-width: 1300px) {
  .col-uso-ter, .col-rk-ter, .col-usr-sec { display: none; } /* Uso: Telas mais usadas · Rankings: vs. mês ant. · Usuários: Vínculo */
}

/* Detalhamento mensal (Visão Geral do rep): valores em 2 formatos — completo
   no desktop (R$ 506.640,00) e curto no celular (R$ 507k) — para a tabela
   caber SEM rolagem lateral. O JS imprime os dois; o CSS mostra um só. */
.v-short { display: none; }
@media (max-width: 820px) {
  .v-full { display: none; }
  .v-short { display: inline; }
  /* Especificidade maior que a regra genérica "table.data td" do bloco mobile
     (que vem depois no arquivo) — senão o padding de 12px volta a valer. */
  .table-wrap table.tab-mensal th, .table-wrap table.tab-mensal td { padding: 11px 6px; font-size: 12.5px; }
  .table-wrap table.tab-mensal th { font-size: 11px; }
  .table-wrap table.tab-mensal .pill { font-size: 11px; padding: 3px 7px; }
}

/* Qualidade de Cadastros no celular: a tabela de 3 colunas exigia rolagem
   lateral para alcançar o botão "Enviar à HD". Vira FICHAS empilhadas —
   cliente, campos e o botão (largura total) aparecem sem puxar para o lado. */
@media (max-width: 820px) {
  table.cad-table thead { display: none; }
  table.cad-table, table.cad-table tbody, table.cad-table tr, table.cad-table td { display: block; width: 100%; }
  table.cad-table tr { padding: 12px 0 14px; border-bottom: 1px solid var(--border); }
  table.cad-table tr:last-child { border-bottom: none; }
  table.cad-table td { padding: 5px 14px; border-bottom: none; }
  table.cad-table td.num { text-align: left; white-space: normal !important; }
  table.cad-table .cad-enviar { width: 100%; margin-top: 4px; }
}

/* Celular: a linha (nome 150px + barras 170px+ + % 52px) não cabe e o
   percentual estourava o card. Reorganiza em 2 linhas: nome + % em cima,
   barras embaixo com a largura total. */
@media (max-width: 820px) {
  .mvr-list { gap: 18px; }
  .mvr-row { flex-wrap: wrap; gap: 4px 10px; }
  .mvr-nome { width: auto; flex: 1; min-width: 0; order: 1; }
  .mvr-pct { order: 2; width: auto; }
  .mvr-bars { order: 3; flex: 1 1 100%; min-width: 0; }
}
.mvr-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.mvr-key.meta { background: #c2cad6; }
.mvr-key.real { background: #1f9d55; }

/* Lista "Metas batidas por representante" (admin → Rankings) */
.m12-wrap { overflow-x: auto; }
.m12-list { min-width: 480px; }
.m12-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.m12-row:last-child { border-bottom: none; }
.m12-head { border-bottom: 1px solid var(--border-strong); padding-bottom: 6px; }
.m12-rank { width: 22px; flex: none; text-align: center; font-weight: 700; font-size: 13px; color: var(--text-muted); }
.m12-nome { flex: 1; min-width: 130px; }
.m12-score { flex: none; width: 52px; text-align: center; }
.m12-cells { flex: none; display: flex; gap: 3px; }
.m12-c { width: 14px; height: 14px; border-radius: 3px; display: inline-block; background: #e5e7eb; flex: none; }
.m12-c.hit { background: #1f9d55; }
.m12-c.miss { background: #d23b3b; }
.m12-c.none { background: #e5e7eb; }
.m12-ml { width: 14px; flex: none; font-size: 9.5px; color: var(--text-faint); text-align: center; }

/* Barra "vendo como representante" (admin) */
.imp-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--hd-black); color: #fff; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 18px; font-size: 13px; font-weight: 600; }
.imp-bar .imp-lbl { display: inline-flex; align-items: center; gap: 8px; }
.imp-bar svg { width: 16px; height: 16px; }
.imp-bar select { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.28); border-radius: 8px; padding: 6px 10px; font-weight: 600; max-width: 320px; }
.imp-bar select option { color: #222222; }
.imp-bar .btn { background: var(--accent); color: #fff; }
.imp-bar .btn:hover { background: var(--accent-dark); }

/* Mapeamento de vendas */
.modo-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.modo-toggle button { padding: 7px 12px; font-size: 13px; font-weight: 600; background: var(--surface); color: var(--text-muted); }
.modo-toggle button.on { background: var(--hd-blue); color: #fff; }
/* position+z-index criam um CONTEXTO DE EMPILHAMENTO: os z-index internos do
   Leaflet (controles chegam a 1000) ficam CONTIDOS aqui dentro e não passam
   mais por cima do cabeçalho sticky (z-index 20) ao rolar a página. */
.mapa-pins { height: 560px; border-radius: 10px; overflow: hidden; position: relative; z-index: 0; }
.mapa-pins .leaflet-container { height: 100%; font: inherit; }
.leaflet-popup-content { font-size: 13px; }
.mapa-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; max-width: 380px; margin: 4px auto; }
/* height fixo = fallback p/ navegadores sem aspect-ratio (Chrome<88, iOS<15) */
.mapa-tile { height: 42px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; transition: transform .1s; }
@supports (aspect-ratio: 1) { .mapa-tile { height: auto; aspect-ratio: 1 / 1; } }
.mapa-tile[title]:hover { transform: scale(1.08); cursor: default; }
.mapa-legend { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin-top: 14px; font-size: 12.5px; color: var(--text-muted); }
.mapa-legend span { display: flex; align-items: center; gap: 7px; }
.mapa-legend i { width: 13px; height: 13px; border-radius: 4px; display: inline-block; }
.uf-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.uf-row:last-child { border-bottom: none; }
.uf-badge { width: 42px; height: 42px; border-radius: 10px; background: var(--hd-blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex: none; }
.city-chips { display: flex; flex-wrap: wrap; margin-top: 6px; }
.city-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; margin: 0 6px 6px 0; }
.city-chip.on { background: var(--hd-blue-soft); color: var(--hd-blue); }
.city-chip.on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--hd-blue); }
.city-chip.off { background: var(--chart-grid); color: var(--text-faint); }

/* Loading / erro */
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 80px 20px; color: var(--text-muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--hd-blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { text-align: center; padding: 70px 20px; }
.error-state .ic { width: 56px; height: 56px; border-radius: 50%; background: var(--red-soft); color: var(--red); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.error-state .ic svg { width: 28px; height: 28px; }
.error-state h3 { font-size: 18px; margin-bottom: 6px; }
.error-state .btn { margin-top: 16px; }

/* =========================================================================
   RESPONSIVO
   ========================================================================= */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3, .cols-2, .cols-2-1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  /* Login no celular: faixa da marca (logo + título + slogan) COMPACTA no topo,
     e o formulário logo abaixo — antes o bloco da marca ficava escondido. */
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand {
    padding: 30px 24px 26px; gap: 14px;
    justify-content: center; min-height: 0;
  }
  .login-brand::after { width: 220px; height: 220px; right: -90px; bottom: -90px; }
  .logo-card-lg { padding: 14px 22px; }
  .logo-card-lg .brand-logo img { height: 50px; }
  .logo-card-lg .logo-fallback .logo-mark { width: 46px; height: 46px; }
  .logo-card-lg .logo-word b { font-size: 30px; }
  .brand-title, .login-brand h1 { font-size: 23px; }
  .brand-slogan { font-size: 14.5px; }
  .login-form-side { padding: 30px 24px 40px; align-items: flex-start; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; width: 270px;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .sidebar.open { transform: none; }
  .hamburger { display: inline-flex; }
  .backdrop { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.4); z-index: 50; }
  .backdrop.show { display: block; }
  .content { padding: 18px; }
  .topbar { padding: 14px 18px; flex-wrap: wrap; }
  /* Busca de representante ocupa uma linha própria no celular (não espreme o topo) */
  .rep-search { order: 9; width: 100%; }
  .rep-search > input { width: 100%; max-width: 100%; }
  .rep-search-res { width: 100%; max-width: 100%; }
  .drawer { width: 100%; max-width: 100%; }
  .action-row { flex-wrap: wrap; }
  /* width 100% + margin-left estourava o card em 48px — o calc compensa o recuo */
  .action-row .action-btns { width: calc(100% - 48px); margin-left: 48px; }
  table.data th, table.data td { padding: 11px 12px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { max-width: none; min-width: 0; flex: 1 1 100%; }
  .toolbar .select { flex: 1 1 100%; min-width: 0; max-width: 100%; }
  .alert-banner { flex-wrap: wrap; }
  .alert-banner .btn { margin-left: 0; width: 100%; }
  .campaign { flex-direction: column; gap: 10px; }
  .action-row .action-btns { margin-left: 0; width: 100%; }
  .action-row .btn-wa { flex: 1; justify-content: center; }
  /* Cross-sell (Visão Geral): empilha o WhatsApp abaixo dos chips no celular estreito */
  .oport-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .oport-row .btn-wa { width: 100%; justify-content: center; }
}

/* =========================================================================
   Fallback de espaçamento — navegadores SEM gap em FLEXBOX
   (Chrome < 84, Safari/iOS < 14.5). A classe .no-flexgap é posta no <html>
   pelo ui-boot.js via detecção por medição (o @supports mente nesses
   navegadores, pois o gap de grid existe desde antes). Cobre os contêineres
   mais visíveis; o restante degrada só esteticamente.
   ========================================================================= */
.no-flexgap .topbar > * + * { margin-left: 10px; }
.no-flexgap .toolbar > * + * { margin-left: 10px; }
.no-flexgap .btn > * + *,
.no-flexgap .icon-btn > * + * { margin-left: 8px; }
.no-flexgap .nav-item .ico { margin-right: 10px; }
.no-flexgap .user > * + * { margin-left: 10px; }
.no-flexgap .sidebar .brand > * + * { margin-top: 10px; }
.no-flexgap .logo-fallback > * + * { margin-left: 10px; }
.no-flexgap .login-brand .features > li + li { margin-top: 14px; }
.no-flexgap .login-brand .features li > * + * { margin-left: 12px; }
.no-flexgap .pw-strength > * + * { margin-left: 10px; }
.no-flexgap .pw-bar > * + * { margin-left: 5px; }
.no-flexgap .usr-form-foot > * + * { margin-left: 12px; }
.no-flexgap .reg-row > * + *,
.no-flexgap .feed-item > * + *,
.no-flexgap .rank-row > * + *,
.no-flexgap .oport-row > * + *,
.no-flexgap .aging-row > * + *,
.no-flexgap .uf-row > * + * { margin-left: 12px; }
.no-flexgap .drawer-head > * + *,
.no-flexgap .modal-head > * + * { margin-left: 12px; }
.no-flexgap .mapa-legend > * + * { margin-left: 18px; }
.no-flexgap .mapa-legend span > * + * { margin-left: 7px; }
.no-flexgap .tour-acoes > * + * { margin-left: 8px; }
.no-flexgap .tv-bar > * + * { margin-left: 10px; }
.no-flexgap .sessao-aviso > * + * { margin-left: 12px; }
.no-flexgap .period > * + * { margin-left: 8px; }
/* Componentes de conteúdo mais novos (mix rico, anexos da ficha, balão de novidades) */
.no-flexgap .mixl-row > * + *,
.no-flexgap .ff-file > * + *,
.no-flexgap .novidade-toast > * + * { margin-left: 8px; }

/* 🆕 Balão "Novidades da versão" (hd-versao.js) — discreto, some sozinho */
.novidade-toast {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%);
  z-index: 240; display: flex; align-items: center; gap: 10px; max-width: 92vw;
  background: #10318F; color: #fff; font-size: 13px; line-height: 1.4;
  padding: 10px 12px 10px 14px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(16, 49, 143, .35); transition: transform .3s ease;
}
.novidade-toast.show { transform: translate(-50%, 0); }
.novidade-toast .nv-tag { flex: none; font-weight: 800; background: #E57818; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; }
.novidade-toast .nv-x { flex: none; background: none; border: none; color: #fff; opacity: .75; font-size: 14px; cursor: pointer; padding: 4px 6px; }
.novidade-toast .nv-x:hover { opacity: 1; }

/* Lista rica do "Mix por categoria" (Visão Geral do rep): preenche a coluna
   sob a rosca com R$ por família, barra de participação e variação vs. mês
   anterior — o espaço vazio vira leitura de tendência. */
.mixl { width: 100%; margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.mixl-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; font-size: 12.5px; cursor: pointer; border-radius: 6px; }
.mixl-row:hover { background: var(--surface-2, #f4f6fa); }
.mixl-nome { flex: none; width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.mixl-bar { flex: 1; height: 7px; background: var(--surface-2, #eef1f6); border-radius: 99px; overflow: hidden; min-width: 40px; }
.mixl-bar span { display: block; height: 100%; border-radius: 99px; }
.mixl-val { flex: none; width: 88px; text-align: right; font-weight: 700; }
.mixl-delta { flex: none; width: 82px; text-align: right; font-size: 11.5px; font-weight: 700; }

/* 📎 Anexos da Ficha Cadastral (upload no lugar do WhatsApp) */
.ff-upload { display: block; border: 2px dashed var(--border-strong, #cbd2dc); border-radius: 10px; padding: 16px 14px; cursor: pointer; text-align: center; background: var(--surface-2, #f7f8fa); transition: border-color .15s, background .15s; }
.ff-upload:hover { border-color: var(--hd-blue); background: #f0f4ff; }
.ff-upload input[type="file"] { width: 100%; font: inherit; font-size: 13px; }
.ff-upload-dica { display: block; margin-top: 6px; color: var(--text-muted); font-size: 12px; }
.ff-files { margin-top: 8px; }
.ff-file { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; margin-top: 6px; font-size: 12.5px; background: var(--surface, #fff); }
.ff-file-ic { flex: none; }
.ff-file-nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ff-file-rm { flex: none; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.ff-file-rm:hover { color: var(--red); background: var(--red-soft, #fdecec); }

/* Botão flutuante de tema (telas de login e criar-senha, que não têm topbar) */
.tema-fab {
  position: fixed; top: 16px; right: 16px; z-index: 60;
  width: 42px; height: 42px; font-size: 18px; line-height: 1;
  box-shadow: var(--shadow); cursor: pointer;
}
.tema-fab:hover { border-color: var(--hd-blue); }

/* =========================================================================
   ACESSIBILIDADE (24/08/2026, auditoria)
   ========================================================================= */

/* Atalho de teclado: primeiro Tab da pagina pula a barra lateral inteira e
   vai direto ao conteudo. Fica invisivel ate receber foco. */
.pular-para-conteudo {
  position: absolute; left: -9999px; top: 0; z-index: 9999;
  background: var(--hd-blue, #10318F); color: #fff;
  padding: 10px 16px; border-radius: 0 0 8px 0; font-weight: 700;
  text-decoration: none;
}
.pular-para-conteudo:focus { left: 0; }

/* Alvo de toque no celular. Medido em 375x812: 11 de 34 controles ficavam
   abaixo de 40px, e o seletor de mes tinha 20px de altura - dificil de acertar
   com o polegar em campo. So no celular, para nao mexer no layout do desktop. */
@media (max-width: 520px) {
  /* Medido em 375x812. Cuidado com os seletores: o #sel-mes NAO tem class="select"
     e o #cli-topbusca e um <input> SEM atributo type - a primeira versao desta
     regra usava .select e input[type="text"] e nao alcancava nenhum dos dois,
     justamente os dois piores (20px e 36px de altura). */
  .select,
  select,
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  textarea {
    min-height: 40px;
  }
  .btn-sm { min-height: 40px; padding-top: 10px; padding-bottom: 10px; }
  .btn-wa { min-height: 44px; }                 /* acao principal do rep no celular */
  .drawer-close, .logout { min-width: 40px; min-height: 40px; }
  /* Deixados de proposito: o "i" do grafico (20px, meramente informativo) e as
     caixas de selecao, cujo <label> ja da a area de toque de verdade. */
}
