/* ============================================================
   NBSA Lead Manager — Design System v2
   Estética: Fintech Dashboard · Clean · Minimal · NBSA Palette
   Fonte: DM Sans
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

:root {
  /* Paleta NBSA */
  --primary:        #8E00FF;
  --primary-dark:   #6B00C2;
  --primary-10:     rgba(142,0,255,0.08);
  --primary-06:     rgba(142,0,255,0.05);
  --primary-light:  #F3E8FF;

  --success:        #0A7C4A;
  --success-10:     rgba(10,124,74,0.08);
  --success-light:  #DCFCE7;

  --attention:      #E07800;
  --attention-10:   rgba(224,120,0,0.08);
  --attention-light:#FEF3C7;

  --critical:       #C41A1A;
  --critical-10:    rgba(196,26,26,0.08);
  --critical-light: #FEE2E2;

  --neutral:        #6B6880;
  --neutral-10:     rgba(107,104,128,0.08);

  --info:           #1D4ED8;
  --info-10:        rgba(29,78,216,0.08);
  --info-light:     #DBEAFE;

  /* Superfícies — off-white, não roxo */
  --bg:             #F5F5F7;
  --bg-2:           #EBEBEF;
  --card:           #FFFFFF;
  --card-hover:     #FAFAFA;
  --border:         #E8E8EC;
  --border-strong:  #D0D0D8;

  /* Texto */
  --text:           #0F0F14;
  --text-secondary: #3A3A4A;
  --text-muted:     #6E6E82;
  --text-disabled:  #ABABBC;

  /* Sidebar — com texto, largura normal */
  --sidebar-bg:       #0F0F14;
  --sidebar-w:        240px;
  --sidebar-item:     rgba(255,255,255,0.06);
  --sidebar-hover:    rgba(142,0,255,0.18);
  --sidebar-active:   rgba(142,0,255,0.25);

  /* Topbar */
  --topbar-h:       56px;
  --companybar-h:   45px;

  /* Radius — mais arredondado */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-full: 999px;

  /* Sombras — mais suaves */
  --shadow-xs: 0 1px 3px rgba(15,15,20,0.03);
  --shadow-sm: 0 6px 28px rgba(15,15,20,0.05), 0 2px 6px rgba(15,15,20,0.02);
  --shadow-md: 0 4px 20px rgba(15,15,20,0.05), 0 1px 4px rgba(15,15,20,0.03);
  --shadow-lg: 0 8px 40px rgba(15,15,20,0.07), 0 2px 8px rgba(15,15,20,0.04);
  --shadow-primary: 0 4px 20px rgba(142,0,255,0.18);

  /* Transições */
  --t-fast: 0.12s ease;
  --t-base: 0.18s ease;
  --t-slow: 0.28s cubic-bezier(0.16,1,0.3,1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; touch-action: manipulation; }

/* Mobile: evita zoom automático do iOS ao focar campos (fonte < 16px dispara o zoom) */
@media (hover: none) and (pointer: coarse) {
  .form-control, input, select, textarea { font-size: 16px !important; }
}
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  /* Fundo da página branco (--bg segue cinza para superfícies internas: pills, thead etc.) */
  background: #FFFFFF;
  color: var(--text);
  line-height: 1.5;
}

/* Chrome mobile: conteúdo mais largo que a tela expande o "layout viewport" e
   desancora elementos position:fixed quando a barra do navegador recolhe
   (menu inferior aparece no meio da tela). Bloqueia o transbordo horizontal. */
html, body { overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; transition: opacity var(--t-fast); }
a:hover { opacity: 0.75; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Layout ─────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ── Sidebar com texto ──────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-right: 1px solid rgba(255,255,255,0.04);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-logo-mark {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(142,0,255,0.4);
}
.sidebar-logo-mark svg { color: #fff; }
.sidebar-logo-text { display: flex; flex-direction: column; gap: 1px; }
.sidebar-logo-name { font-size: 0.9rem; font-weight: 700; color: #fff; letter-spacing: -0.3px; line-height: 1; }
.sidebar-logo-sub  { font-size: 0.68rem; color: rgba(255,255,255,0.28); letter-spacing: 0.5px; text-transform: uppercase; }

/* Nav */
.sidebar-nav { flex: 1; padding: 10px 8px; }
.sidebar-section-label {
  padding: 12px 8px 4px;
  font-size: 0.65rem; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: rgba(255,255,255,0.28);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: rgba(255,255,255,0.6);
  font-size: 0.84rem; font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none !important;
}
.sidebar-item:hover  { background: var(--sidebar-hover); color: #fff; opacity: 1; }
.sidebar-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar-item.active::before {
  content: '';
  position: absolute; left: 0; top: 25%; bottom: 25%;
  width: 3px; background: var(--primary);
  border-radius: 0 var(--r-full) var(--r-full) 0;
}
.sidebar-item svg { flex-shrink: 0; opacity: 0.75; }
.sidebar-item.active svg, .sidebar-item:hover svg { opacity: 1; }

/* Badge com número */
.sidebar-badge {
  margin-left: auto;
  background: var(--critical);
  color: #fff;
  font-size: 0.68rem; font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-full);
  min-width: 18px; text-align: center; line-height: 16px;
}

.sidebar-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 8px 0; }

/* Footer */
.sidebar-footer { padding: 12px 12px 16px; border-top: 1px solid rgba(255,255,255,0.06); flex-shrink: 0; }
.sidebar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 8px; border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.sidebar-user:hover { background: var(--sidebar-item); }
.sidebar-avatar {
  width: 28px; height: 28px; border-radius: var(--r-full);
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #fff; flex-shrink: 0;
  cursor: default;
  border: none;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: rgba(255,255,255,0.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.68rem; color: rgba(255,255,255,0.28); }

/* Tooltip via title — não mostrar no desktop com sidebar com texto */
.sidebar-item::after { display: none; }
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.topbar-breadcrumb { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.topbar-breadcrumb-item { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }
.topbar-breadcrumb-item.current { font-weight: 600; color: var(--text); }
.topbar-breadcrumb-sep { color: var(--border-strong); font-size: 0.8rem; }

/* Avatares empilhados na topbar */
.topbar-avatars {
  display: flex;
  align-items: center;
}
.topbar-avatars .avatar-stack {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  background: var(--primary-10);
  border: 2px solid var(--card);
  margin-left: -8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700;
  color: var(--primary);
  overflow: hidden;
}
.topbar-avatars .avatar-stack:first-child { margin-left: 0; }
.topbar-avatars .avatar-more {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.65rem;
}

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

/* Sino de notificações */
.topbar-bell {
  width: 34px; height: 34px;
  border-radius: var(--r-full);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
  transition: background var(--t-fast);
}
.topbar-bell:hover { background: var(--border); color: var(--text); }
.topbar-bell .bell-dot {
  position: absolute;
  top: 6px; right: 7px;
  width: 7px; height: 7px;
  background: var(--critical);
  border-radius: 50%;
  border: 1.5px solid var(--card);
}

/* ── Barra de contas (topo) ─────────────────────────────────── */
.company-bar {
  height: var(--companybar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 101;
}
/* Com a barra de contas acima, a topbar cola logo abaixo dela */
.company-bar + .topbar { top: var(--companybar-h); }
.company-bar-label {
  display: flex; align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.company-bar-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 1;
  min-width: 0;
}
.company-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.company-chip:hover { background: var(--border); color: var(--text); }
.company-chip.active {
  background: var(--primary-10);
  border-color: var(--primary);
  color: var(--primary);
}
.company-chip-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--critical);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 18px; /* = altura → número centralizado na vertical */
  text-align: center;
  font-variant-numeric: tabular-nums;
  animation: badgeBlink 1.5s ease-in-out infinite;
}
.company-chip-badge[hidden],
.sidebar-badge[hidden] { display: none !important; }
.company-chip-badge.bump { animation: chipBump 0.4s ease, badgeBlink 1.5s ease-in-out 0.4s infinite; }
@keyframes chipBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
/* Pulso contínuo: pisca suave + anel que se expande, para chamar o olho */
@keyframes badgeBlink {
  0%, 100% { opacity: 1;   transform: scale(1);    box-shadow: 0 0 0 0 rgba(196,26,26,0.45); }
  50%      { opacity: 0.75; transform: scale(1.08); box-shadow: 0 0 0 5px rgba(196,26,26,0); }
}

/* ── Page ───────────────────────────────────────────────────── */
.page { flex: 1; padding: 24px; }
.page-header { margin-bottom: 20px; }
.page-title { font-size: 1.3rem; font-weight: 800; color: var(--text); letter-spacing: -0.5px; line-height: 1.2; }
.page-subtitle { font-size: 0.83rem; color: var(--text-muted); margin-top: 3px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-title { font-size: 0.9rem; font-weight: 700; color: var(--text); flex: 1; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* ── KPI Cards ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.kpi-icon-primary  { background: var(--primary-10); color: var(--primary); }
.kpi-icon-success  { background: var(--success-10); color: var(--success); }
.kpi-icon-attention{ background: var(--attention-10); color: var(--attention); }
.kpi-icon-critical { background: var(--critical-10); color: var(--critical); }
.kpi-icon-neutral  { background: var(--neutral-10); color: var(--neutral); }
.kpi-value {
  font-size: 1.9rem; font-weight: 800; color: var(--text);
  letter-spacing: -1.5px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; font-weight: 500; }

/* ── Tabela ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-xl); }
.table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.table thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.71rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table thead th:first-child { border-radius: var(--r-xl) 0 0 0; }
.table thead th:last-child  { border-radius: 0 var(--r-xl) 0 0; }
.table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-secondary); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover td { background: var(--primary-06); }
.table tbody tr.row-alert td { background: #FFF8F8; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 0.72rem; font-weight: 600;
  white-space: nowrap; letter-spacing: 0.1px;
}
.badge-primary   { background: var(--primary-10);   color: var(--primary); }
.badge-success   { background: var(--success-10);   color: var(--success); }
/* Pulso de destaque (ex.: contagem de leads novos no monitoramento) */
.badge-pulse { animation: badgePulse 1.6s ease-out infinite; }
@keyframes badgePulse {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(10,124,74,0.4); }
  70%  { transform: scale(1.1); box-shadow: 0 0 0 7px rgba(10,124,74,0); }
  100% { transform: scale(1.1); box-shadow: 0 0 0 7px rgba(10,124,74,0); }
}
.badge-attention { background: var(--attention-10); color: var(--attention); }
.badge-critical  { background: var(--critical-10);  color: var(--critical); }
.badge-neutral   { background: var(--neutral-10);   color: var(--neutral); }
.badge-info      { background: var(--info-10);      color: var(--info); }
.badge-yellow    { background: #FEF9C3; color: #854D0E; }
.badge svg { width: 10px; height: 10px; }

/* ── Tabs — pill style ──────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 4px;
  margin-bottom: 20px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  font-size: 0.82rem; font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none !important;
  background: none;
  border: none;
  font-family: inherit;
  white-space: nowrap;
  /* Remove o underline do v1 */
  border-bottom: none !important;
  margin-bottom: 0 !important;
}
.tab:hover { color: var(--text); background: rgba(0,0,0,0.04); opacity: 1; }
.tab.active {
  color: var(--text);
  background: var(--card);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.tab svg { width: 13px; height: 13px; }

/* Relatório: no celular os controles (funil/etapa, período, PDF) e o
   seletor Loja/vendedor ficam escondidos atrás do botão "Filtros";
   no desktop o botão some e nada muda. */
.report-filters-toggle { display: none; }
.gerente-topbar-static { position: static !important; }
.rc-period, .rc-export { display: contents; }
/* Até 1024px: cobre celular deitado (iPhone 16 = 852px) e tablets em pé */
@media (max-width: 1024px) {
  .report-filters-toggle { display: inline-flex; }
  .report-collapsible { display: none !important; }
  body.report-controls-open .report-header { margin-bottom: 0 !important; }
  /* Painel: parte de cima (filtros, período, exportar) */
  body.report-controls-open #report-controls {
    display: flex !important; flex-direction: column; align-items: stretch; gap: 18px; width: 100%;
    background: var(--card); border: 1px solid var(--border); border-bottom: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 16px; margin-top: 4px;
  }
  body.report-controls-open .rc-section { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
  body.report-controls-open .rc-section::before, body.report-controls-open .rc-view::before {
    content: attr(data-label); display: block; width: 100%;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  }
  body.report-controls-open #report-controls form { flex-direction: column; align-items: stretch; }
  body.report-controls-open #report-controls form .form-control { width: 100% !important; }
  body.report-controls-open .rc-period .btn { flex: 1 1 28%; justify-content: center; }
  body.report-controls-open .rc-export { flex-direction: column; }
  body.report-controls-open .rc-export > div { width: 100%; }
  body.report-controls-open .rc-export > div > .btn { width: 100%; justify-content: center; }
  /* Painel: parte de baixo (Loja / vendedores), emendada na de cima */
  body.report-controls-open .rc-view {
    display: flex !important; flex-wrap: wrap; gap: 8px;
    background: var(--card); border: 1px solid var(--border); border-top: 1px dashed var(--border);
    border-radius: 0 0 var(--r-lg) var(--r-lg); padding: 16px; margin: 0 0 16px;
  }
  body.report-controls-open .rc-view .tab {
    border: 1px solid var(--border) !important; border-radius: var(--r-full); padding: 6px 14px; margin: 0 !important; background: var(--bg);
  }
  body.report-controls-open .rc-view .tab.active { background: var(--primary); color: #fff; border-color: var(--primary) !important; }
  /* Abas do relatório quebram em duas linhas: raio de card em vez de pílula */
  #report-tabs { border-radius: var(--r-xl); padding: 6px; }
  #report-tabs .tab { flex: 1 1 auto; justify-content: center; }
}
/* Só em telas pequenas: coluna única e sem rolagem lateral */
@media (max-width: 768px) {
  /* Nada passa da largura da tela: cards, gráficos e blocos flex */
  #report-root { overflow-x: hidden; }
  #report-root .card { min-width: 0; max-width: 100%; }
  #report-root .card-body { min-width: 0; }
  #report-root canvas { max-width: 100% !important; }
  #report-root .card-body[style*="space-around"] { flex-wrap: wrap; }
  #report-root .card-body[style*="space-around"] > div { flex: 1 1 100%; }
  /* Cards em coluna única: minmax(340px) estourava a largura de telas pequenas */
  .grid-2 { grid-template-columns: 1fr !important; }
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; } /* KPIs em duas colunas */
}
/* Relatório: abas de conteúdo. No PDF, .pdf-mode mostra o título da
   seção e .pdf-all mostra todas as abas, uma por página. */
.rtab { display: none; }
.rtab.active { display: block; }
.rtab-title { display: none; font-size: 1.05rem; font-weight: 800; margin: 0 0 14px; padding-bottom: 6px; border-bottom: 2px solid var(--primary); color: var(--text); }
#report-root.pdf-mode .rtab-title { display: block; }
#report-root.pdf-all .rtab { display: block; }
#report-root.pdf-all .rtab + .rtab { page-break-before: always; margin-top: 8px; }

/* Tabs dentro de card (sem o pill externo) */
.tabs-inline {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  background: none;
  border-radius: 0;
  padding: 0;
  width: auto;
  max-width: none;
}
.tabs-inline .tab {
  border-radius: 0;
  box-shadow: none;
  padding: 10px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
}
.tabs-inline .tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: none;
  box-shadow: none;
}

/* ── Botões ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 16px; height: 36px;
  border-radius: var(--r-full); /* Botões pill */
  font-size: 0.84rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--t-fast);
  white-space: nowrap; text-decoration: none !important;
  font-family: inherit; letter-spacing: -0.1px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 3px rgba(142,0,255,0.25);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow-primary); opacity: 1; }
.btn-secondary { background: var(--primary-10); color: var(--primary); border: 1px solid rgba(142,0,255,0.15); }
.btn-secondary:hover:not(:disabled) { background: rgba(142,0,255,0.14); opacity: 1; }
.btn-outline {
  background: var(--card); color: var(--text-secondary);
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.btn-outline:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); opacity: 1; }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--neutral-10); color: var(--text); opacity: 1; }
.btn-danger { background: var(--critical-10); color: var(--critical); border: 1px solid rgba(196,26,26,0.15); }
.btn-danger:hover:not(:disabled) { background: var(--critical); color: #fff; opacity: 1; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { height: 30px; padding: 0 14px; font-size: 0.78rem; }
.btn-xs { height: 26px; padding: 0 10px; font-size: 0.72rem; border-radius: var(--r-full); }
.btn-lg { height: 44px; padding: 0 28px; font-size: 0.92rem; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* ── Formulários ────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-label .req { color: var(--critical); margin-left: 2px; }
.form-label .opt { color: var(--text-muted); font-weight: 400; margin-left: 4px; font-size: 0.72rem; }
.form-control {
  width: 100%; height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 0.84rem; font-family: inherit;
  color: var(--text); background: var(--card);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(142,0,255,0.10);
}
.form-control::placeholder { color: var(--text-disabled); }
textarea.form-control { height: auto; padding: 10px 14px; resize: vertical; min-height: 80px; line-height: 1.5; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E6E82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}
.form-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.72rem; color: var(--critical); margin-top: 4px; }

/* Toggle */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-base);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform var(--t-base);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle.toggle-sm { width: 28px; height: 16px; }
.toggle.toggle-sm .toggle-slider::before { width: 10px; height: 10px; }
.toggle.toggle-sm input:checked + .toggle-slider::before { transform: translateX(12px); }

/* ── Drawer ─────────────────────────────────────────────────── */
.drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,15,20,0.4); backdrop-filter: blur(4px);
  z-index: 300;
}
.drawer-overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 480px; max-width: 96vw;
  background: var(--card);
  border-left: 1px solid var(--border);
  z-index: 301;
  transform: translateX(100%);
  transition: transform var(--t-slow);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 40px rgba(15,15,20,0.12);
  border-radius: var(--r-xl) 0 0 var(--r-xl);
}
.drawer.open { transform: translateX(0); }
.drawer-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.drawer-title { flex: 1; font-size: 0.95rem; font-weight: 700; color: var(--text); }
.drawer-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  background: var(--bg);
  border-radius: 0 0 0 var(--r-xl);
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,15,20,0.45); backdrop-filter: blur(4px);
  z-index: 400; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: var(--r-2xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  animation: scaleIn 0.2s ease;
}
.modal-header { padding: 22px 24px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.modal-title { flex: 1; font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ''; position: absolute;
  left: 9px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot {
  position: absolute; left: -23px; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--border);
}
.dot-appointment { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-10); }
.dot-status      { background: var(--neutral); }
.dot-lost        { background: var(--critical); }
.dot-preventive  { background: var(--attention); }
.timeline-time { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.timeline-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 14px;
}
.timeline-card.card-status { background: var(--neutral-10); }
.timeline-card.card-note {
  background: rgba(107,104,128,0.22);
  border-color: rgba(107,104,128,0.35);
  border-left: 3px solid var(--neutral);
}

/* ── Nota privada ───────────────────────────────────────────── */
.private-note {
  background: linear-gradient(135deg, #FAF5FF, #F3E8FF);
  border: 1.5px dashed rgba(142,0,255,0.25);
  border-radius: var(--r-xl); padding: 14px 16px;
}
.private-note-header {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 10px; font-size: 0.78rem;
  font-weight: 700; color: var(--primary);
}

/* ── Alertas ────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-lg);
  font-size: 0.84rem; margin-bottom: 14px;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-warning { background: var(--attention-light); color: #92400E; }
.alert-error   { background: var(--critical-light);  color: #991B1B; }
.alert-success { background: var(--success-light);   color: #065F46; }
.alert-info    { background: var(--primary-light);   color: #5B21B6; }

/* ── Filtros ────────────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.filter-bar .form-control { width: auto; min-width: 120px; height: 30px; font-size: 0.8rem; border-radius: var(--r-full); }
.filter-bar .btn { height: 30px; }
/* Campo com filtro ativo (diferente do padrão) */
.form-control.filter-active {
  border-color: var(--primary);
  background: var(--primary-06);
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--primary-06);
}
.filter-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

/* ── Progress ───────────────────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: var(--r-full); overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--r-full); background: var(--primary); transition: width 0.5s ease; }
.progress-bar.bar-success  { background: var(--success); }
.progress-bar.bar-attention{ background: var(--attention); }
.progress-bar.bar-critical { background: var(--critical); }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 24px; text-align: center; gap: 10px;
}
.empty-state-icon {
  width: 52px; height: 52px; border-radius: var(--r-xl);
  background: var(--neutral-10);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); margin-bottom: 4px;
}
.empty-state-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.empty-state-desc  { font-size: 0.82rem; color: var(--text-muted); max-width: 280px; }

/* ── Login ──────────────────────────────────────────────────── */
.login-root { min-height: 100vh; display: grid; grid-template-columns: 1fr 460px; }
.login-left {
  background: var(--sidebar-bg); position: relative;
  overflow: hidden; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 40px;
}
.login-left-glow {
  position: absolute; width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle, rgba(142,0,255,0.25), transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  pointer-events: none;
}
.login-left-content { position: relative; text-align: center; color: #fff; }
.login-logo-big {
  width: 56px; height: 56px; background: var(--primary);
  border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 0 40px rgba(142,0,255,0.5);
}
.login-product-name { font-size: 2rem; font-weight: 800; letter-spacing: -1px; margin-bottom: 6px; }
.login-product-desc { font-size: 0.88rem; color: rgba(255,255,255,0.4); }
.login-right {
  background: var(--card); display: flex;
  align-items: center; justify-content: center; padding: 48px 40px;
}
.login-form-wrap { width: 100%; max-width: 360px; }
.login-form-title { font-size: 1.5rem; font-weight: 800; color: var(--text); letter-spacing: -0.5px; margin-bottom: 4px; }
.login-form-sub { font-size: 0.84rem; color: var(--text-muted); margin-bottom: 28px; }

/* ── Mobile layout ──────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Base 16px no mobile: padrão de leitura (iOS 17px / Material 16px).
     Tudo usa rem, então o site inteiro escala proporcionalmente. */
  html { font-size: 16px; }
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .page { padding: 16px 8px; padding-bottom: 72px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .drawer { width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; top: auto; height: 90vh; }
  .login-root { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .login-right { padding: 32px 24px; }
  .topbar { padding: 0 16px; }
  .tabs { max-width: 100%; }
}

/* ── Gerente/Vendedor: sempre visíveis ──────────────────────── */
.mobile-header { display: none; }
.bottom-nav    { display: none; }

body.layout-gerente .mobile-header,
body.layout-vendedor .mobile-header { display: flex !important; }
body.layout-gerente .bottom-nav,
body.layout-vendedor .bottom-nav    { display: flex !important; }

.mobile-header-logo {
  font-size: 1rem; font-weight: 800; color: #fff !important; letter-spacing: -0.4px;
}

body.layout-gerente .page-wrap,
body.layout-vendedor .page-wrap {
  max-width: 680px; margin: 0 auto; padding: 16px 16px 24px;
}

/* ── Shell mobile: rolagem no contêiner interno ───────────────
   A barra do Chrome só recolhe quando o documento rola; com a
   rolagem num contêiner interno, o menu inferior nunca se move. */
body.layout-gerente,
body.layout-vendedor {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.layout-gerente .app-scroll,
body.layout-vendedor .app-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.layout-gerente .bottom-nav,
body.layout-vendedor .bottom-nav {
  display: flex !important;
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(15,15,20,0.04);
  z-index: 100; padding-bottom: env(safe-area-inset-bottom);
  justify-content: center;
}
body.layout-gerente .bottom-nav-inner,
body.layout-vendedor .bottom-nav-inner {
  display: flex; width: 100%; max-width: 680px;
}
body.layout-gerente .bottom-nav-item,
body.layout-vendedor .bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 10px 4px 8px;
  font-size: 0.72rem; font-weight: 500; color: var(--text-muted);
  text-decoration: none !important; gap: 4px;
  transition: color var(--t-fast);
}
body.layout-gerente .bottom-nav-item.active,
body.layout-vendedor .bottom-nav-item.active { color: var(--primary); }
body.layout-gerente .bottom-nav-item svg,
body.layout-vendedor .bottom-nav-item svg { width: 20px; height: 20px; }

/* ── Toast ──────────────────────────────────────────────────── */
#toast-root {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; max-width: 340px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-xl);
  font-size: 0.84rem; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: slideUp 0.2s ease;
  pointer-events: all; border: 1px solid transparent;
}
.toast-success { background: var(--success-light); color: #065F46; border-color: #A7F3D0; }
.toast-error   { background: var(--critical-light); color: #991B1B; border-color: #FCA5A5; }
.toast-info    { background: var(--primary-light);  color: #5B21B6; border-color: #C4B5FD; }
.toast-warning { background: var(--attention-light);color: #92400E; border-color: #FCD34D; }

/* ── Utilitários ────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex-1 { flex: 1; } .min-w-0 { min-width: 0; } .w-full { width: 100%; }
.text-sm { font-size: 0.875rem; } .text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-critical { color: var(--critical) !important; }
.text-success { color: var(--success) !important; }
.font-bold { font-weight: 700; } .font-mono { font-family: 'DM Mono', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-1{margin-top:4px} .mt-2{margin-top:8px} .mt-3{margin-top:12px}
.mt-4{margin-top:16px} .mt-5{margin-top:20px} .mt-6{margin-top:24px}
.mb-1{margin-bottom:4px} .mb-2{margin-bottom:8px} .mb-3{margin-bottom:12px}
.mb-4{margin-bottom:16px} .mb-5{margin-bottom:20px} .mb-6{margin-bottom:24px}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.rounded { border-radius: var(--r-md); } .rounded-lg { border-radius: var(--r-lg); }

/* ── Animações ──────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--neutral); }

/* ── Tooltip via data-tip ───────────────────────────────────── */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 0.72rem;
  padding: 4px 8px; border-radius: var(--r-sm); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast); z-index: 999;
}
[data-tip]:hover::after { opacity: 1; }

/* ── Sidebar item title como tooltip ───────────────────────── */
/* No v2 usamos title= para o tooltip nativo via CSS acima */

/* ── Desktop: ações do card sempre visíveis à direita ─────────
   No celular as ações aparecem deslizando o card (touch); no
   computador não há gesto de arrastar, então a faixa de botões
   fica fixa ao lado do conteúdo e o site alarga o equivalente
   (680px + faixa de botões) para nada ficar espremido. */
@media (min-width: 769px) {
  body.layout-gerente .page-wrap,
  body.layout-vendedor .page-wrap,
  body.layout-gerente .bottom-nav-inner,
  body.layout-vendedor .bottom-nav-inner { max-width: 920px; }
  /* Páginas largas (relatório): o conteúdo ocupa a página inteira */
  body.layout-gerente.page-full .page-wrap { max-width: none; padding-left: 24px; padding-right: 24px; }

  .swipe-card { display: flex; align-items: stretch; }
  .swipe-card .swipe-content {
    flex: 1 1 auto;
    min-width: 0;
    transform: none !important; /* neutraliza swipe iniciado em tela touch */
  }
  .swipe-card .swipe-actions {
    position: static;
    flex: 0 0 auto;
    order: 2; /* no DOM a faixa vem antes do conteúdo; aqui vai para a direita */
  }
  .swipe-act:hover { filter: brightness(0.92); }
}
