:root, [data-theme="light"] {
  --bg: oklch(98% 0.005 250);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(96.5% 0.006 250);
  --fg: oklch(22% 0.02 240);
  --muted: oklch(50% 0.018 240);
  --border: oklch(90% 0.008 240);
  --border-strong: oklch(82% 0.01 240);
  --accent: oklch(52% 0.14 145);
  --accent-fg: oklch(99% 0.01 145);
  --accent-soft: oklch(94% 0.04 145);
  --success: oklch(48% 0.12 150);
  --success-soft: oklch(95% 0.03 150);
  --warn: oklch(62% 0.13 75);
  --warn-soft: oklch(96% 0.04 85);
  --danger: oklch(52% 0.17 25);
  --danger-soft: oklch(96% 0.03 25);
  --info: oklch(50% 0.11 240);
  --info-soft: oklch(95% 0.03 240);
  --shadow-sm: 0 1px 2px oklch(20% 0.02 240 / 0.06);
  --shadow-md: 0 4px 16px oklch(20% 0.02 240 / 0.08);
  --shadow-lg: 0 12px 40px oklch(20% 0.02 240 / 0.14);
  --sidebar-w: 240px;
  --sidebar-collapsed: 56px;
  --header-h: 52px;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: oklch(16% 0.012 250);
  --surface: oklch(20% 0.012 250);
  --surface-2: oklch(24% 0.014 250);
  --fg: oklch(94% 0.01 240);
  --muted: oklch(68% 0.016 240);
  --border: oklch(28% 0.014 250);
  --border-strong: oklch(36% 0.016 250);
  --accent: oklch(68% 0.14 145);
  --accent-fg: oklch(16% 0.02 145);
  --accent-soft: oklch(28% 0.05 145);
  --success: oklch(70% 0.13 150);
  --success-soft: oklch(28% 0.05 150);
  --warn: oklch(78% 0.12 85);
  --warn-soft: oklch(30% 0.05 85);
  --danger: oklch(68% 0.15 25);
  --danger-soft: oklch(28% 0.06 25);
  --info: oklch(72% 0.1 240);
  --info-soft: oklch(28% 0.05 240);
  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.3);
  --shadow-md: 0 4px 16px oklch(0% 0 0 / 0.35);
  --shadow-lg: 0 12px 40px oklch(0% 0 0 / 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  /* 3 linhas: header (altura fixa) · barra de abas do módulo (auto — colapsa a
     0 quando .module-subnav está oculta) · conteúdo (1fr). Ver shell.js
     (moduleSubnavHtml) — a barra é um irmão entre <header> e <main>. */
  grid-template-rows: var(--header-h) auto 1fr;
  height: 100vh;
  overflow: hidden;
}
.app.collapsed { grid-template-columns: var(--sidebar-collapsed) 1fr; }

.sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  z-index: 30;
}
.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.sidebar-brand .logo {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: var(--accent-fg);
  display: grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: 12px;
}
.sidebar-brand .brand-text { white-space: nowrap; overflow: hidden; }
.app.collapsed .brand-text,
.app.collapsed .nav-label,
.app.collapsed .nav-section-title,
.app.collapsed .sidebar-footer-text { display: none; }

.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
/* Escondido até CRM.mountShell (shell.js) terminar de filtrar os itens por
   permissão — evita o menu inteiro "piscar" sem filtro nenhum por uma fração
   de segundo antes do que a pessoa não pode ver ser removido. */
.nav.nav-loading { visibility: hidden; }
.nav-section-title {
  font-size: 11px; font-weight: 550; color: var(--muted);
  letter-spacing: 0.07em; text-transform: uppercase;
  padding: 10px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--muted); font-weight: 510; font-size: 13px;
  letter-spacing: 0.01em; width: 100%; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--fg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 590; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.7; }
.nav-item .badge-count {
  margin-left: auto; font-size: 11px; font-weight: 550;
  background: var(--surface-2); color: var(--muted);
  padding: 1px 6px; border-radius: 99px; font-variant-numeric: tabular-nums;
}
.nav-item.active .badge-count { background: var(--accent); color: var(--accent-fg); }
.badge-count.badge-count-danger { background: var(--danger); color: #fff; }

/* Tela de "acesso restrito" — usada quando o grupo do usuário não tem acesso
   a um módulo (Configurações > Grupos). */
.access-denied { padding: 60px 20px; text-align: center; color: var(--muted); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--info-soft); color: var(--info);
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.img { background-size: cover; background-position: center; color: transparent; }

.header {
  grid-column: 2; grid-row: 1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; min-width: 0;
}

/* Barra de abas do módulo (Financeiro/RH/Compras/…): reúne as seções que
   antes eram itens soltos na sidebar. Renderizada por shell.js
   (moduleSubnavHtml) como irmão entre <header> e <main>. Quando a página
   ativa não pertence a nenhum módulo com abas, fica [hidden] e a linha de
   grid `auto` colapsa a 0. */
.module-subnav {
  grid-column: 2; grid-row: 2;
  display: flex; gap: 2px; align-items: stretch;
  padding: 0 16px; min-width: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.module-subnav[hidden] { display: none; }
.msub-item {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 9px 12px; font-size: 13px; font-weight: 510; color: var(--muted);
  text-decoration: none; border-bottom: 2px solid transparent;
}
.msub-item:hover { color: var(--fg); }
.msub-item.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.msub-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-sm); }
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius);
  display: grid; place-items: center; color: var(--muted);
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s, transform 0.08s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-btn:active { background: var(--border); transform: scale(0.9); }
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.7; }

.tenant-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border: 1px solid var(--border);
  border-radius: 99px; background: var(--bg); font-size: 12px; font-weight: 510;
}
.tenant-chip .dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, oklch(60% 0.12 250), oklch(55% 0.14 200));
  display: grid; place-items: center; color: white; font-size: 9px; font-weight: 700;
}
/* Seletor de Linha de Negócio (Controle de Acesso > Linhas de Negócio) —
   mesmo componente visual do tenant-chip ao lado, só que clicável (abre o
   dropdown de troca, mesmo padrão dos quick-icon-dropdown da topbar). Só
   aparece quando o tenant tem mais de 1 linha ativa (ver shell.js). */
.tenant-chip-btn { cursor: pointer; border: none; }
.tenant-chip-btn:hover, .tenant-chip-btn[aria-expanded="true"] { background: var(--surface-2); }
.tenant-chip-btn svg { width: 12px; height: 12px; color: var(--muted); flex-shrink: 0; }
.business-line-dot { width: 8px !important; height: 8px !important; background: var(--accent); flex-shrink: 0; }
#business-line-dropdown { left: 0; width: 240px; }
.business-line-dropdown-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius);
  font-size: 12.5px; cursor: pointer; width: 100%; text-align: left; background: none; border: none; color: inherit;
}
.business-line-dropdown-item:hover { background: var(--surface-2); }
.business-line-dropdown-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.business-line-dropdown-item .business-line-current { margin-left: auto; font-size: 10px; color: var(--muted); }
.business-line-dropdown-new {
  display: flex; gap: 6px; padding: 8px; margin-top: 4px; border-top: 1px solid var(--border);
}
.business-line-dropdown-new input {
  flex: 1; height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--fg); font-size: 12px;
}

.search-box {
  flex: 1; position: relative;
}
.search-box input {
  width: 100%; height: 34px; padding: 0 12px 0 34px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--fg);
}
.search-box input::placeholder { color: var(--muted); }
.search-box svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted); pointer-events: none;
}
.search-box kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px;
  background: var(--surface);
}
/* A busca global acompanha a largura do próprio campo (que é flexível,
   .search-box já é flex:1) em vez da largura fixa de 280px do dropdown
   padrão dos ícones rápidos — mesma classe base (.quick-icon-dropdown),
   só a largura e a posição mudam. */
.global-search-dropdown { left: 0; right: 0; width: auto; max-height: 360px; }
.quick-icon-dropdown-group {
  padding: 8px 10px 4px; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
.quick-icon-dropdown-item[href] { text-decoration: none; color: inherit; }
.header-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.quick-icon-wrap { position: relative; }
.quick-icon {
  position: relative; display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 8px 0 4px; border-radius: var(--radius);
  font-size: 12px; font-weight: 590; color: var(--fg);
  transition: background 0.12s, transform 0.08s;
}
.quick-icon:hover { background: var(--surface-2); }
.quick-icon:active { background: var(--border); transform: scale(0.94); }
.quick-icon.quick-icon-iconly { padding: 0; width: 32px; justify-content: center; }
.quick-icon-badge {
  position: relative; display: grid; place-items: center; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid transparent;
}
.quick-icon-badge svg { width: 15px; height: 15px; stroke-width: 1.9; }
.quick-icon-badge-agenda { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
:root[data-theme="dark"] .quick-icon-badge-agenda { background: #451a03; border-color: #92400e; color: #fde68a; }
.quick-icon-badge-ponto { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
:root[data-theme="dark"] .quick-icon-badge-ponto { background: #1e293b; border-color: #3b82f6; color: #bfdbfe; }
.quick-icon-badge-whatsapp { background: #dcfce7; border-color: #86efac; color: #15803d; }
:root[data-theme="dark"] .quick-icon-badge-whatsapp { background: #052e16; border-color: #16a34a; color: #bbf7d0; }
.quick-icon-dot {
  position: absolute; bottom: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); border: 2px solid var(--surface); flex-shrink: 0;
}
.quick-icon-dot-on { background: #22c55e; }

.quick-icon-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; width: 280px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); z-index: 50; padding: 6px;
}
.quick-icon-dropdown-empty { padding: 14px 10px; text-align: center; color: var(--muted); font-size: 12px; }
.quick-icon-dropdown-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); font-size: 12.5px;
}
.quick-icon-dropdown-item:hover { background: var(--surface-2); }
.quick-icon-dropdown-item .mono { font-family: var(--font-mono); color: var(--muted); flex-shrink: 0; }
.quick-icon-dropdown-who { margin-left: auto; color: var(--muted); font-size: 11px; }
.notif-dropdown { left: auto; right: 0; width: 320px; }
.notif-count {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.notif-wrap .icon-btn { position: relative; }
.notif-item { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.notif-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-text span { color: var(--muted); font-size: 12px; }
.notif-text small { color: var(--muted); font-size: 11px; }
.notif-unread { background: var(--accent-soft); }
.quick-icon-dropdown-footer {
  display: block; text-align: center; padding: 8px; margin-top: 4px; border-top: 1px solid var(--border);
  font-size: 12px; font-weight: 550; color: var(--info);
}

.qi-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 60;
  align-items: center; justify-content: center;
}
.qi-modal-backdrop:not([hidden]) { display: flex; }
.qi-modal {
  width: calc(100% - 32px); max-width: 340px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 20px;
}
.qi-modal h3 { font-size: 15px; margin: 0 0 6px; }
.qi-modal p { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.qi-modal-input {
  width: 100%; height: 34px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--fg); font: inherit;
}
.qi-modal-error { color: var(--danger, #dc2626); font-size: 12px; margin-top: 8px; }
.qi-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.main {
  grid-column: 2; grid-row: 3;
  overflow: hidden; display: flex; flex-direction: column; min-width: 0; background: var(--bg);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius);
  font-size: 13px; font-weight: 550; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn svg { width: 15px; height: 15px; stroke-width: 1.7; }
.btn-primary {
  background: var(--accent); color: var(--accent-fg);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--surface); color: var(--fg); border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }

/* Badges / pills */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 99px;
  font-size: 11px; font-weight: 550; letter-spacing: 0.02em;
  white-space: nowrap; max-width: 100%;
}
.badge-neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-origin {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--fg); font-weight: 510;
}
.badge-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}

/* Page toolbar */
.page-toolbar {
  display: flex; align-items: center; gap: 10px 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-wrap: wrap;
}
.page-title {
  font-size: 16px; font-weight: 600; letter-spacing: -0.015em;
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.page-title h1 {
  margin: 0; font-size: inherit; font-weight: inherit; letter-spacing: inherit;
  line-height: 1.2;
}
.page-title .count {
  font-size: 12px; font-weight: 510; color: var(--muted);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
  white-space: nowrap;
}
.toolbar-filters {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  flex: 1 1 220px; min-width: 0;
}
.filter-chip {
  height: 32px; padding: 0 11px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 12px; font-weight: 510; color: var(--muted);
  letter-spacing: 0.02em;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.filter-chip:hover, .filter-chip.active {
  border-color: var(--border-strong); color: var(--fg); background: var(--surface);
}
.filter-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.filter-chip:active:not(.active) { transform: translateY(1px); }
.toolbar-actions {
  margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

/* Kanban */
.kanban-wrap {
  flex: 1; overflow-x: auto; overflow-y: hidden;
  padding: 12px 16px 16px;
}
.kanban {
  display: flex; gap: 10px; height: 100%; min-width: min-content;
}
.kanban-col {
  width: 280px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-height: 100%;
}
.kanban-col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kanban-col-head h2,
.kanban-col-head h3 {
  margin: 0; font-size: 12px; font-weight: 600;
  letter-spacing: 0.02em; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.col-count {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 99px;
}
.col-sum {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}
.kanban-col-body {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 80px;
  transition: background 0.12s, box-shadow 0.12s;
}
.kanban-col-body.is-drop-target {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px color-mix(in oklch, var(--accent) 45%, transparent);
}
.kanban-col-head[draggable="true"] { cursor: grab; }
.kanban-col.col-dragging { opacity: .6; }
.kanban-hint {
  font-size: 11px; color: var(--muted); font-weight: 510;
  letter-spacing: 0.01em; white-space: nowrap;
}

/* Lead card */
.lead-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 11px;
  box-shadow: var(--shadow-sm); cursor: grab;
  transition: border-color 0.12s, box-shadow 0.12s, opacity 0.12s, transform 0.12s;
  text-align: left; width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.lead-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.lead-card:focus-visible { outline-offset: 0; }
.lead-card:active { cursor: grabbing; }
.lead-card.is-dragging {
  opacity: 0.45;
  box-shadow: var(--shadow-md);
  transform: scale(0.98);
}
.lead-card.is-urgent {
  border-color: color-mix(in oklch, var(--danger) 45%, var(--border));
  box-shadow: inset 3px 0 0 var(--danger);
}
.lead-card.is-warn {
  border-color: color-mix(in oklch, var(--warn) 40%, var(--border));
  box-shadow: inset 3px 0 0 var(--warn);
}
.lead-card.is-blocked {
  opacity: 0.72;
  background: var(--surface-2);
}
.progress-track {
  height: 4px; background: var(--border); border-radius: 99px;
  overflow: hidden; margin-top: 8px;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: var(--accent);
  transition: width 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.progress-fill.is-done { background: var(--success); }
.progress-fill.is-danger { background: var(--danger); }
.empty-col {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; padding: 28px 14px;
  text-align: center; color: var(--muted); min-height: 120px;
}
.empty-col svg { width: 22px; height: 22px; opacity: 0.55; stroke-width: 1.6; }
.empty-col strong { font-size: 12px; font-weight: 550; color: var(--fg); }
.empty-col span { font-size: 11px; line-height: 1.45; max-width: 18ch; }
.col-risk {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--border-strong);
}
.col-risk.warn { background: var(--warn); }
.col-risk.danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: min(420px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13px; line-height: 1.4;
  animation: toast-in 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.toast.ok { border-color: color-mix(in oklch, var(--success) 35%, var(--border)); }
.toast.warn { border-color: color-mix(in oklch, var(--warn) 40%, var(--border)); }
.toast .toast-ico {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.toast.ok .toast-ico { background: var(--success-soft); color: var(--success); }
.toast.warn .toast-ico { background: var(--warn-soft); color: var(--warn); }
.toast-body { flex: 1; min-width: 0; }
.toast-body strong { display: block; font-weight: 590; margin-bottom: 2px; }
.toast-body span { color: var(--muted); font-size: 12px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.drawer[aria-hidden="true"] { visibility: hidden; }
.drawer.open[aria-hidden="false"] { visibility: visible; }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45; cursor: not-allowed; pointer-events: none;
  transform: none; filter: none;
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.sr-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.block-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--danger-soft); border: 1px solid color-mix(in oklch, var(--danger) 30%, var(--border));
  margin-bottom: 14px; font-size: 12px; line-height: 1.45;
}
.block-banner strong { display: block; color: var(--danger); font-weight: 590; margin-bottom: 2px; }
.block-banner span { color: var(--muted); }
.checklist-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: 13px; min-height: 44px;
}
.checklist-item input {
  width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0;
  accent-color: var(--accent);
}
.checklist-item.is-done span { color: var(--muted); text-decoration: line-through; }
.skeleton-card {
  height: 108px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border: 1px solid var(--border);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .drawer { transition: none; }
  .drawer-backdrop { transition: none; }
  .lead-card:active { transform: none; }
}
.lead-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
}
.lead-card-title {
  font-size: 13px; font-weight: 590; letter-spacing: -0.01em;
  line-height: 1.3; margin: 0;
}
.lead-card-company {
  font-size: 12px; color: var(--muted); margin: 2px 0 0;
}
.lead-card-meta {
  display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0;
}
.lead-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}
.lead-value {
  font-family: var(--font-mono); font-size: 12px; font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.sla {
  font-family: var(--font-mono); font-size: 11px; font-weight: 510;
  display: inline-flex; align-items: center; gap: 4px;
}
.sla.ok { color: var(--success); }
.sla.warn { color: var(--warn); }
.sla.danger { color: var(--danger); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -6px; border: 1.5px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: oklch(10% 0.02 240 / 0.35);
  z-index: 40; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: var(--shadow-lg);
}
.drawer.open { transform: translateX(0); }
.drawer.wide { width: min(720px, 100vw); }
.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.drawer-head-body { flex: 1; min-width: 0; }
.drawer-head h2 {
  margin: 0; font-size: 18px; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.2;
}
.drawer-sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.drawer-actions { display: flex; gap: 6px; flex-shrink: 0; }
.drawer-tabs {
  display: flex; gap: 0; padding: 0 12px;
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.drawer-tab {
  padding: 10px 12px; font-size: 13px; font-weight: 510;
  color: var(--muted); border-bottom: 2px solid transparent;
  letter-spacing: 0.01em; white-space: nowrap;
}
.drawer-tab:hover { color: var(--fg); }
.drawer-tab.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 590; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.drawer-footer {
  border-top: 1px solid var(--border); padding: 12px 18px;
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  background: var(--surface);
}
.drawer-footer .btn { min-height: 36px; }

/* Timeline */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px;
  width: 1px; background: var(--border);
}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -20px; top: 4px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.tl-dot.accent { border-color: var(--accent); background: var(--accent-soft); }
.tl-dot.success { border-color: var(--success); background: var(--success-soft); }
.tl-dot.warn { border-color: var(--warn); background: var(--warn-soft); }
.tl-dot.info { border-color: var(--info); background: var(--info-soft); }
.tl-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted); margin-bottom: 3px;
}
.tl-meta time { font-family: var(--font-mono); letter-spacing: 0.01em; }
.tl-title { font-size: 13px; font-weight: 550; margin: 0 0 2px; }
.tl-body { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; max-width: 58ch; }

/* Stats strip */
.stats-strip {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  background: var(--surface); overflow-x: auto;
}
.stat-cell {
  flex: 1; min-width: 120px; padding: 10px 16px;
  border-right: 1px solid var(--border);
}
.stat-cell:last-child { border-right: none; }
.stat-label {
  font-size: 11px; color: var(--muted); font-weight: 510;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.stat-value {
  font-family: var(--font-mono); font-size: 18px; font-weight: 600;
  letter-spacing: -0.02em; margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.stat-delta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* Detail grid */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
  margin-bottom: 18px;
}
.field-label {
  font-size: 11px; color: var(--muted); font-weight: 510;
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 3px;
}
.field-value { font-size: 13px; font-weight: 510; }
.section-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.board-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 48px 24px; text-align: center;
  color: var(--muted);
}
.board-empty svg { width: 28px; height: 28px; opacity: 0.5; stroke-width: 1.6; }
.board-empty strong { font-size: 14px; font-weight: 590; color: var(--fg); }
.board-empty p { margin: 0; font-size: 13px; max-width: 36ch; line-height: 1.5; }
.sla svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Study document */
.study-doc {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg); overflow: hidden;
}
.study-doc-head {
  padding: 14px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.study-doc-body { padding: 16px; }
.study-block {
  margin-bottom: 16px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.study-block:last-child { margin-bottom: 0; padding-bottom: 0; border: none; }
.study-block h4 {
  margin: 0 0 6px; font-size: 13px; font-weight: 600;
  letter-spacing: -0.01em;
}
.study-block p {
  margin: 0; font-size: 13px; color: var(--muted);
  line-height: 1.55; max-width: 65ch;
}
.metric-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
}
.metric-card .m-label { font-size: 11px; color: var(--muted); }
.metric-card .m-value {
  font-family: var(--font-mono); font-size: 16px; font-weight: 600;
  margin-top: 2px; font-variant-numeric: tabular-nums;
}

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 550;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }

/* Chat / WhatsApp panel */
.chat-panel {
  display: flex; flex-direction: column; height: 100%; min-height: 320px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; background: var(--bg); display: flex; flex-direction: column; gap: 8px; }
.bubble {
  max-width: 80%; padding: 8px 11px; border-radius: 10px;
  font-size: 13px; line-height: 1.45;
}
.bubble.in {
  align-self: flex-start; background: var(--surface);
  border: 1px solid var(--border); border-bottom-left-radius: 3px;
}
.bubble.out {
  align-self: flex-end; background: var(--accent-soft); color: var(--fg);
  border-bottom-right-radius: 3px;
}
.bubble time {
  display: block; font-size: 10px; color: var(--muted);
  font-family: var(--font-mono); margin-top: 4px; text-align: right;
}
.chat-compose {
  display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-compose input {
  flex: 1; height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg);
}

/* Empty / misc */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.stack-h { display: flex; align-items: center; gap: 8px; }
.stack-v { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Launcher cards */
.launcher {
  min-height: 100vh; background: var(--bg); padding: 48px 32px;
}
.launcher-inner { max-width: 1080px; margin: 0 auto; }
.launcher h1 {
  font-size: 28px; font-weight: 600; letter-spacing: -0.025em;
  margin: 0 0 8px; line-height: 1.15;
}
.launcher .lede {
  font-size: 15px; color: var(--muted); max-width: 58ch;
  line-height: 1.55; margin: 0 0 32px;
}
.screen-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.screen-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.screen-card:hover {
  border-color: var(--border-strong); box-shadow: var(--shadow-md);
}
.screen-card .sc-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin-bottom: 14px;
}
.screen-card .sc-icon svg { width: 18px; height: 18px; stroke-width: 1.7; }
.screen-card h2 {
  margin: 0 0 6px; font-size: 15px; font-weight: 600; letter-spacing: -0.015em;
}
.screen-card p {
  margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5;
}
.screen-card .sc-meta {
  margin-top: 14px; font-size: 11px; color: var(--muted);
  font-weight: 510; letter-spacing: 0.04em; text-transform: uppercase;
}

.token-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px; margin-top: 24px;
}
.token-swatch {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.token-swatch .sw { height: 40px; }
.token-swatch .ti { padding: 8px 10px; }
.token-swatch .tn { font-size: 11px; font-weight: 550; font-family: var(--font-mono); }
.token-swatch .tv { font-size: 10px; color: var(--muted); margin-top: 2px; }

@media (max-width: 900px) {
  .app { grid-template-columns: var(--sidebar-collapsed) 1fr; }
  .brand-text, .nav-label, .nav-section-title, .sidebar-footer-text { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: 1fr 1fr; }
  .kanban-hint { display: none; }
  .page-toolbar { padding: 10px 12px; }
  .toolbar-actions { width: 100%; margin-left: 0; justify-content: flex-start; }
  .stats-strip { -webkit-overflow-scrolling: touch; }
  .stat-cell { min-width: 140px; }
  .drawer { width: min(100vw, 560px); }
  .drawer-footer { justify-content: stretch; }
  .drawer-footer .btn { flex: 1 1 auto; }
}
@media (max-width: 640px) {
  .kanban-col { width: min(260px, 78vw); }
  .search-box { display: none; }
  .tenant-chip span:last-child { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Modal genérico de confirmação com senha do supervisor (exclusão segura) */
.sv-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
  display: grid; place-items: center; z-index: 60; padding: 20px;
}
.sv-modal {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 20px;
}
.sv-modal h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.sv-modal p { margin: 0 0 16px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.sv-field { margin-bottom: 12px; }
.sv-field label { display: block; font-size: 12px; font-weight: 550; color: var(--muted); margin-bottom: 5px; }
.sv-field input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); font-size: 13px;
}
.sv-error { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius); padding: 8px 10px; font-size: 12px; margin-bottom: 12px; }

/* Gráficos de barra/funil zero-dependência (CRM.renderBarChart/renderFunnelChart) */
.crm-bar-chart, .crm-funnel-chart { display: flex; flex-direction: column; gap: 10px; }
.crm-bar-row, .crm-funnel-row {
  display: grid; grid-template-columns: 140px 1fr 56px; align-items: center; gap: 10px;
}
.crm-bar-label { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-bar-track { height: 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; }
.crm-bar-fill { height: 100%; border-radius: 999px; transition: width 0.2s ease; }
.crm-bar-value { font-family: var(--font-mono); font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .crm-bar-row, .crm-funnel-row { grid-template-columns: 96px 1fr 44px; }
}
.sv-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Botão flutuante de WhatsApp (canto inferior direito) — acima do drawer
   (z-index 50) pra continuar visível com um registro aberto, abaixo do modal
   de exclusão (60) e dos toasts (80, que ficam centralizados embaixo). */
.whatsapp-float-btn {
  position: fixed; right: 24px; bottom: 24px; z-index: 55;
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: var(--shadow-md); transition: transform 0.15s ease;
}
/* [hidden] tem a mesma especificidade que a classe acima — sem isso, o CSS de
   autor vence a regra padrão do atributo e o botão apareceria mesmo "escondido". */
.whatsapp-float-btn[hidden] { display: none; }
.whatsapp-float-btn svg { width: 56px; height: 56px; }
.whatsapp-float-btn:hover { transform: scale(1.06); }
@media (max-width: 640px) {
  .whatsapp-float-btn { right: 16px; bottom: 16px; width: 48px; height: 48px; }
  .whatsapp-float-btn svg { width: 48px; height: 48px; }
}

/* ---------------------------------------------------------------------------
   Visão geral de módulo (Compras/Contratos/Patrimônio): KPIs + atalhos +
   lista de recentes, só leitura, reaproveitando os endpoints summary/overview
   que já existem. Classes compartilhadas pelas 3 páginas *-visao.html.
   --------------------------------------------------------------------------- */
.ov-wrap { flex: 1; overflow: auto; padding: 16px 20px 28px; display: flex; flex-direction: column; gap: 18px; }
.ov-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.ov-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 14px 16px; }
.ov-k { font-size: 11px; color: var(--muted); font-weight: 510; letter-spacing: 0.06em; text-transform: uppercase; }
.ov-v { font-family: var(--font-mono); font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ov-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.ov-section { display: flex; flex-direction: column; gap: 10px; }
.ov-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ov-section-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.ov-more { font-size: 12px; text-decoration: none; color: var(--accent); }
.ov-more:hover { text-decoration: underline; }
.ov-links { display: flex; gap: 10px; flex-wrap: wrap; }
.ov-link { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px 14px; font-size: 13px; font-weight: 550; color: var(--fg); text-decoration: none; }
.ov-link:hover { background: var(--surface-2); border-color: var(--border-strong); }
.ov-alert { display: inline-flex; align-items: center; padding: 9px 12px; border-radius: var(--radius); font-size: 12px; font-weight: 510; text-decoration: none; border: 1px solid transparent; }
.ov-alert.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in oklch, var(--warn) 30%, transparent); }
.ov-alert.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklch, var(--danger) 35%, transparent); }
.ov-tablewrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; background: var(--surface); }
.ov-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ov-table th { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.ov-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.ov-table tbody tr:last-child td { border-bottom: 0; }
.ov-table .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ov-empty { text-align: center; color: var(--muted); padding: 28px; }
