@import url('./tokens/typography.css');
@import url('./tokens/colors.css');
@import url('./tokens/spacing.css');
@import url('./tokens/radii.css');
@import url('./tokens/shadows.css');

/* ==========================================================================
   Agenda Interna — Nodum · Design v4
   Ordem: 1 base · 2 botões/campos · 3 login · 4 shell (menu, topo) ·
          5 página/toolbar/abas · 6 cards e números · 7 tabela · 8 selos/avatares ·
          9 quadro (kanban/funil) · 10 modal/detalhe · 11 CRM/anexos/WhatsApp ·
          12 movimento · 13 responsivo
   ========================================================================== */

/* ---------- 1. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body-md);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--surface-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-snug);
  margin: 0;
}
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--brand-primary) 26%, transparent); }
::placeholder { color: var(--text-tertiary); opacity: 1; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: var(--fw-medium);
}
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-secondary); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

* { scrollbar-width: thin; scrollbar-color: var(--border-default) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* ---------- 2. Botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 9px var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent; background: transparent;
  font-family: var(--font-body); font-size: var(--fs-body-sm); font-weight: var(--fw-semibold);
  line-height: 1.2; cursor: pointer; white-space: nowrap; user-select: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease,
              box-shadow 200ms ease, transform 160ms ease, filter 160ms ease;
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn-primary { background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-brand), inset 0 1px 0 rgba(255,255,255,.18); }
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(.985); }
.btn-secondary { background: var(--surface-card); color: var(--text-primary); border-color: var(--border-default); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--neutral-50); border-color: var(--border-strong); transform: translateY(-1px); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--neutral-100); color: var(--text-primary); }
.btn-danger { background: var(--error-500); color: #fff; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--error-500) 60%, transparent); }
.btn-danger:hover { filter: brightness(.93); transform: translateY(-1px); }
.btn-sm { min-height: 32px; padding: 5px var(--space-3); font-size: 13px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; filter: none; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 13px; font-weight: var(--fw-semibold); color: var(--text-primary); }

.input, .select, .textarea {
  width: 100%; min-height: 42px;
  padding: 10px var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  font-size: var(--fs-body-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, box-shadow 200ms ease, background-color 160ms ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}
.textarea { min-height: 100px; resize: vertical; font-family: var(--font-body); line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px;
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236C7C75' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
}
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { min-height: 42px; }

.input-wrap { position: relative; }
.input.has-toggle { padding-right: 46px; }
.input-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: var(--radius-sm);
  color: var(--text-tertiary); cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.input-toggle:hover { background: var(--neutral-100); color: var(--text-primary); }
.input-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.input-toggle .ico-olho-off { display: none; }
.input-toggle.is-on .ico-olho { display: none; }
.input-toggle.is-on .ico-olho-off { display: block; }
.input-toggle.is-on { color: var(--brand-primary); }

input[type="file"] { font-size: var(--fs-body-sm); color: var(--text-secondary); max-width: 100%; }
input[type="file"].input { padding: 6px var(--space-2); }
input[type="file"]::file-selector-button {
  margin-right: var(--space-3); padding: 7px var(--space-3);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-card); color: var(--text-primary);
  font: inherit; font-weight: var(--fw-semibold); cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}
input[type="file"]::file-selector-button:hover { background: var(--neutral-100); border-color: var(--border-strong); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-primary); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-grid .span-2 { grid-column: 1 / -1; }

/* ---------- 3. Login ---------- */
.theme-toggle {
  position: fixed; top: var(--space-5); right: var(--space-5); z-index: 10;
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border: 1px solid var(--border-subtle); border-radius: 999px;
  background: color-mix(in srgb, var(--surface-card) 80%, transparent);
  backdrop-filter: blur(8px);
  color: var(--text-secondary); cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background-color 160ms ease, color 160ms ease, transform 200ms ease;
}
.theme-toggle:hover { background: var(--surface-card); color: var(--text-primary); transform: rotate(18deg); }
.theme-toggle svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle span { display: none; }

.login-page { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; background: var(--surface-page); }
.login-aside {
  position: relative; overflow: hidden; isolation: isolate;
  color: var(--text-on-dark);
  padding: var(--space-16) var(--space-12);
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(900px 520px at 105% -10%, rgba(34,181,140,.42), transparent 60%),
    radial-gradient(640px 420px at -10% 108%, rgba(95,208,166,.20), transparent 62%),
    linear-gradient(160deg, #0F1D17 0%, #0A120F 100%);
}
.login-aside::before {
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 40%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 40%, transparent);
}
.login-aside h1 { font-size: clamp(32px, 3.4vw, 46px); color: #fff; margin-top: var(--space-12); max-width: 13ch; line-height: 1.1; }
.login-aside p { color: var(--text-on-dark-secondary); max-width: 46ch; }
.login-aside .eyebrow { color: var(--coral-400); }
.login-points { list-style: none; padding: 0; margin: var(--space-10) 0 0; display: grid; gap: var(--space-4); }
.login-points li {
  display: flex; gap: var(--space-4); align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius-md);
  background: rgba(255,255,255,.04); backdrop-filter: blur(6px);
}
.login-points .num {
  font-family: var(--font-mono); font-size: 11px; font-weight: var(--fw-bold);
  color: #0A120F; background: var(--coral-400);
  border-radius: 999px; width: 28px; height: 28px; display: grid; place-items: center; flex: none;
}
.login-points strong { display: block; color: #fff; font-weight: var(--fw-semibold); }
.login-points span { color: var(--text-on-dark-secondary); font-size: var(--fs-body-sm); }

.login-main { display: grid; place-items: center; padding: var(--space-12) var(--space-8); background: var(--surface-page); }
.login-card { width: 100%; max-width: 420px; }
.login-card h2 { font-size: var(--fs-heading-lg); margin: 6px 0 var(--space-2); }
.login-form { display: grid; gap: var(--space-5); margin-top: var(--space-8); }
.login-form .btn-primary { min-height: 46px; font-size: var(--fs-body-md); }
.login-error {
  background: var(--error-100); color: var(--error-500);
  border: 1px solid color-mix(in srgb, var(--error-500) 30%, transparent);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4);
  font-size: var(--fs-body-sm); font-weight: var(--fw-semibold);
}
.login-hint {
  margin-top: var(--space-8); padding: var(--space-4);
  border: 1px dashed var(--border-default); border-radius: var(--radius-lg);
  background: var(--surface-card-alt); font-size: 13px; color: var(--text-secondary);
}
.login-logo-mobile { display: none; height: 30px; width: auto; margin-bottom: var(--space-8); }
.login-logo-mobile.is-dark { display: none; }
@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-main { align-items: start; padding: 72px var(--space-5) var(--space-10); }
  .login-logo-mobile.is-light { display: block; }
  :root[data-theme="dark"] .login-logo-mobile.is-light { display: none; }
  :root[data-theme="dark"] .login-logo-mobile.is-dark { display: block; }
}
@media (max-width: 900px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-logo-mobile.is-light { display: none; }
  :root:not([data-theme="light"]) .login-logo-mobile.is-dark { display: block; }
}

/* ---------- 4. Shell: menu lateral e barra superior ---------- */
.app-shell { display: grid; grid-template-columns: 276px 1fr; min-height: 100vh; }

/* O menu é escuro nos dois temas: é a "assinatura" visual do app. Os tokens
   são redefinidos só aqui dentro, então o JS (que usa var(--text-*) inline)
   continua funcionando sem saber disso. */
.sidebar {
  --text-primary: #EAF3EF; --text-secondary: #A5B8AF; --text-tertiary: #6F847A;
  --neutral-50: rgba(255,255,255,.04); --neutral-100: rgba(255,255,255,.07); --neutral-200: rgba(255,255,255,.11);
  --border-subtle: rgba(255,255,255,.08); --border-default: rgba(255,255,255,.14);
  --surface-card: rgba(255,255,255,.05);
  color: var(--text-primary);
  background:
    radial-gradient(420px 300px at 0% 0%, rgba(34,181,140,.16), transparent 70%),
    linear-gradient(180deg, #0F1A15 0%, #0A110E 100%);
  border-right: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: var(--space-5);
  padding: var(--space-4) var(--space-3);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-top { display: flex; align-items: center; gap: var(--space-1); }
.sidebar-top .sidebar-brand { flex: 1; min-width: 0; }
.sidebar-brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); border-radius: var(--radius-md); color: inherit; text-decoration: none; transition: background-color 160ms ease; }
.sidebar-brand:hover { background: var(--neutral-100); text-decoration: none; }
.sidebar-brand img { width: 30px; height: 30px; }
.sidebar-brand strong { display: block; font-family: var(--font-display); font-size: 17px; color: #fff; letter-spacing: -.01em; }
.sidebar-brand span span { display: block; font-size: 10px; color: var(--text-tertiary); font-family: var(--font-mono); letter-spacing: .12em; }
.sidebar-collapse-btn {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: none; background: transparent; border-radius: var(--radius-sm);
  color: var(--text-tertiary); cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.sidebar-collapse-btn:hover { background: var(--neutral-100); color: #fff; }
.sidebar-collapse-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.sidebar-section { display: grid; gap: 2px; }
.sidebar-section > .eyebrow { padding: var(--space-2) var(--space-3) var(--space-1); font-size: 10px; letter-spacing: .14em; }

.nav-item {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  width: 100%; padding: 9px var(--space-3);
  border: none; background: transparent; border-radius: var(--radius-md);
  font-size: var(--fs-body-sm); font-weight: var(--fw-medium); color: var(--text-secondary);
  cursor: pointer; text-align: left;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.nav-item:hover { background: var(--neutral-100); color: #fff; }
.nav-item svg { flex: none; width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 160ms ease; }
.nav-item:hover svg { transform: scale(1.08); }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(34,181,140,.24), rgba(34,181,140,.08));
  color: #fff; font-weight: var(--fw-semibold);
  box-shadow: inset 0 0 0 1px rgba(95,208,166,.16);
}
.nav-item.is-active svg { color: var(--coral-400); }
.nav-item.is-active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--coral-400);
  box-shadow: 0 0 12px rgba(95,208,166,.7);
}
.nav-item .nav-count {
  margin-left: auto; min-width: 22px; text-align: center; padding: 1px 7px;
  border-radius: 999px; background: var(--neutral-100); color: var(--text-secondary);
  font-family: var(--font-mono); font-size: 11px; font-weight: var(--fw-semibold);
}
.nav-item .nav-count:empty { display: none; }
.nav-item.is-active .nav-count { background: rgba(95,208,166,.22); color: #fff; }

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border-subtle); padding-top: var(--space-4); display: grid; gap: 2px; }
.sidebar-footer .btn-primary { margin-bottom: var(--space-2); }
.sidebar-user { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-3); }
.sidebar-user .meta { min-width: 0; }
.sidebar-user .meta strong { display: block; font-size: var(--fs-body-sm); font-weight: var(--fw-semibold); color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .meta span { display: block; font-size: 12px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Menu recolhido (≥ 901px): trilha só com ícones. A escolha fica em
   <html class="sidebar-collapsed">, aplicada antes do CSS pintar. */
@media (min-width: 901px) {
  html.sidebar-collapsed .app-shell { grid-template-columns: 78px 1fr; transition: grid-template-columns 200ms ease; }
  html.sidebar-collapsed .sidebar { padding-left: var(--space-2); padding-right: var(--space-2); }
  html.sidebar-collapsed .sidebar-top { flex-direction: column; gap: var(--space-2); }
  html.sidebar-collapsed .sidebar-brand span,
  html.sidebar-collapsed .sidebar-section > .eyebrow,
  html.sidebar-collapsed .sidebar-user .meta { display: none; }
  html.sidebar-collapsed .sidebar-brand { justify-content: center; padding: var(--space-2) 0; }
  html.sidebar-collapsed .nav-item { justify-content: center; padding: 10px; font-size: 0 !important; }
  html.sidebar-collapsed .nav-item .nav-count { display: none; }
  html.sidebar-collapsed .nav-item.is-active::before { left: -8px; }
  html.sidebar-collapsed .sidebar-user { justify-content: center; padding: var(--space-2) 0; }
  html.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
  html.sidebar-collapsed #btnNovaTarefa { width: 38px; height: 38px; min-height: 0; padding: 0; margin: 0 auto var(--space-2); font-size: 0; overflow: hidden; border-radius: 50%; }
  html.sidebar-collapsed #btnNovaTarefa::before { content: '+'; font-size: 22px; line-height: 1; }
  html.sidebar-collapsed .page { max-width: 1680px; }
}
@media (max-width: 900px) { .sidebar-collapse-btn { display: none; } }

.main { display: flex; flex-direction: column; min-width: 0; background: var(--surface-canvas); }

.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-8);
  min-height: 64px;
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-page) 82%, transparent);
  backdrop-filter: saturate(170%) blur(12px);
  -webkit-backdrop-filter: saturate(170%) blur(12px);
  position: sticky; top: 0; z-index: 35;
}
.topbar .breadcrumb { font-size: var(--fs-body-sm); color: var(--text-tertiary); }
.topbar .breadcrumb strong { color: var(--text-primary); font-weight: var(--fw-semibold); }
.topbar .spacer { flex: 1; }

.search-box { position: relative; }
.search-box .input { width: 280px; padding-left: 38px; border-radius: 999px; background: var(--surface-card-alt); box-shadow: none; min-height: 40px; }
.search-box .input:focus { background: var(--surface-card); width: 320px; }
.search-box .input { transition: width 220ms ease, border-color 160ms ease, box-shadow 200ms ease, background-color 160ms ease; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; stroke: var(--text-tertiary); fill: none; stroke-width: 1.9; pointer-events: none; }

.menu-toggle {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  background: var(--surface-card); color: var(--text-secondary); cursor: pointer; box-shadow: var(--shadow-sm);
}
.menu-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; }
.menu-toggle:hover { background: var(--neutral-100); color: var(--text-primary); }
.sidebar-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(4,10,7,.55); backdrop-filter: blur(3px); animation: fadeIn 160ms ease; }
.sidebar-overlay[hidden] { display: none; }

/* Sino de notificações */
.alert-bell-wrap { position: relative; }
.alert-bell {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--border-subtle);
  background: var(--surface-card); border-radius: 999px; color: var(--text-secondary);
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.alert-bell:hover { background: var(--neutral-100); color: var(--text-primary); transform: translateY(-1px); }
.alert-bell svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.alert-bell.tem-alerta svg { animation: sinoBalanca 2.6s ease-in-out infinite; transform-origin: top center; }
@keyframes sinoBalanca {
  0%, 60%, 100% { transform: rotate(0); } 63% { transform: rotate(12deg); } 66% { transform: rotate(-10deg); }
  69% { transform: rotate(7deg); } 72% { transform: rotate(-5deg); } 75% { transform: rotate(0); }
}
.alert-bell-badge[hidden] { display: none; }
.alert-bell-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  background: var(--error-500); color: #fff; font-size: 10px; font-weight: var(--fw-bold);
  border-radius: 999px; border: 2px solid var(--surface-page);
}
.alert-bell-pop {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 45;
  width: 360px; max-height: 440px; overflow-y: auto;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: popIn 180ms cubic-bezier(.2,.8,.2,1) both; transform-origin: top right;
}
.alert-bell-pop .eyebrow { padding: var(--space-4) var(--space-4) var(--space-2); margin: 0; }
.alert-bell-pop .alert-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-subtle);
  cursor: pointer; transition: background-color 120ms ease;
}
.alert-bell-pop .alert-item:hover { background: var(--neutral-50); }
.alert-bell-pop .alert-item .k { flex: 1; min-width: 0; }
.alert-bell-pop .alert-item .k strong { display: block; font-size: var(--fs-body-sm); font-weight: var(--fw-semibold); }
.alert-bell-pop .alert-item .k span { display: block; font-size: 12px; color: var(--error-500); font-family: var(--font-mono); margin-top: 2px; }
.alert-bell-pop .alert-empty { padding: var(--space-8) var(--space-4); text-align: center; color: var(--text-tertiary); font-size: var(--fs-body-sm); }

#alertasRoot { position: fixed; top: var(--space-5); right: var(--space-5); z-index: 300; display: grid; gap: var(--space-2); max-width: 340px; }
.alerta-flutuante {
  display: flex; align-items: flex-start; gap: var(--space-3);
  background: var(--surface-card); border: 1px solid color-mix(in srgb, var(--error-500) 50%, var(--border-subtle));
  border-left: 4px solid var(--error-500); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: var(--space-3) var(--space-4); cursor: pointer;
  animation: alertaEntra 240ms cubic-bezier(.2,.8,.2,1) both, alertaBrilho 1.8s ease-in-out infinite;
}
@keyframes alertaEntra { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes alertaBrilho {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--error-500) 40%, transparent), var(--shadow-lg); }
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--error-500) 0%, transparent), var(--shadow-lg); }
}
.alerta-flutuante-pulso { animation: alertaEntra 240ms cubic-bezier(.2,.8,.2,1) both, alertaBrilho 1.8s ease-in-out infinite, alertaTremelique 500ms ease-in-out; }
@keyframes alertaTremelique {
  0%, 100% { transform: translateX(0); } 15% { transform: translateX(-4px); } 30% { transform: translateX(4px); }
  45% { transform: translateX(-3px); } 60% { transform: translateX(3px); } 75% { transform: translateX(-1px); }
}
.alerta-flutuante .alerta-icone { flex: none; font-size: 18px; line-height: 1; }
.alerta-flutuante .alerta-corpo { flex: 1; min-width: 0; }
.alerta-flutuante .alerta-corpo strong { display: block; font-size: var(--fs-body-sm); font-weight: var(--fw-semibold); }
.alerta-flutuante .alerta-corpo span { display: block; font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* ---------- 5. Página, filtros e abas ---------- */
.page { padding: var(--space-8); max-width: 1440px; width: 100%; margin: 0 auto; }
.page-header { margin-bottom: var(--space-6); }
.page-header .eyebrow { display: block; margin-bottom: 6px; color: var(--brand-primary); }
.page-header h1 { font-size: clamp(26px, 3vw, 34px); letter-spacing: -.025em; }
.page-header p { color: var(--text-secondary); margin: var(--space-2) 0 0; max-width: 72ch; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); row-gap: var(--space-2); margin-bottom: var(--space-5); position: relative; z-index: 30; }
.toolbar .spacer { flex: 1; }
.toolbar .select, .toolbar .input { width: auto; min-width: 150px; }

.msel { position: relative; }
.msel-btn { display: flex; align-items: center; gap: var(--space-2); min-width: 150px; max-width: 220px; text-align: left; background-image: none; padding-right: var(--space-3); }
.msel-btn span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel-btn::after {
  content: ''; flex: none; width: 16px; height: 16px; background-repeat: no-repeat; background-position: center; background-size: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236C7C75' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
}
.msel-btn.has-value { border-color: var(--brand-primary); color: var(--brand-primary); font-weight: var(--fw-semibold); background: var(--brand-soft); }
.msel-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  min-width: 230px; max-height: 280px; overflow-y: auto;
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: var(--space-1);
  animation: slideDown 160ms ease both; transform-origin: top;
}
.msel-opt { display: flex; align-items: center; gap: var(--space-2); padding: 8px var(--space-2); border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs-body-sm); white-space: nowrap; transition: background-color 120ms ease; }
.msel-opt:hover { background: var(--neutral-100); }
.msel-opt input { width: 16px; height: 16px; flex: none; cursor: pointer; }
.msel-empty { padding: var(--space-3); font-size: var(--fs-body-sm); color: var(--text-tertiary); }

.viewtabs {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: var(--space-5);
  background: var(--neutral-100); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  max-width: 100%;
}
.viewtab {
  border: none; background: transparent; cursor: pointer;
  padding: 8px var(--space-4); border-radius: var(--radius-sm);
  font-size: var(--fs-body-sm); font-weight: var(--fw-semibold); color: var(--text-secondary);
  transition: color 160ms ease, background-color 160ms ease, box-shadow 200ms ease;
}
.viewtab:hover { color: var(--text-primary); }
.viewtab.is-active { color: var(--text-primary); background: var(--surface-card); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-subtle); }

/* ---------- 6. Cards, números e gráficos ---------- */
.card {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-5);
  transition: box-shadow 220ms ease, border-color 160ms ease, transform 200ms ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title { font-size: var(--fs-heading-sm); margin-bottom: var(--space-4); }
.card-hint { margin: -8px 0 var(--space-4); font-size: 13px; color: var(--text-tertiary); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.stat-card { position: relative; display: flex; flex-direction: column; text-align: left; overflow: hidden; padding: var(--space-5); }
.stat-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 100%; pointer-events: none; opacity: .9;
  background: radial-gradient(220px 120px at 100% 0%, color-mix(in srgb, var(--brand-primary) 13%, transparent), transparent 70%);
}
.stat-card:has(.value.is-alert)::before { background: radial-gradient(220px 120px at 100% 0%, color-mix(in srgb, var(--error-500) 14%, transparent), transparent 70%); }
.stat-card::after { content: ''; position: absolute; left: var(--space-5); top: 0; width: 34px; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand-primary); transition: width 240ms ease; }
.stat-card:has(.value.is-alert)::after { background: var(--error-500); }
.stat-card .eyebrow { display: block; margin-bottom: var(--space-3); position: relative; }
.stat-card .value { position: relative; margin-top: auto; font-family: var(--font-display); font-size: var(--fs-stat-md); font-weight: var(--fw-extrabold); line-height: var(--lh-tight); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-card .value.is-alert { color: var(--error-500); }
.stat-card .value.is-good { color: var(--brand-primary); }
.stat-card .foot { position: relative; font-size: 12px; color: var(--text-tertiary); margin-top: var(--space-2); min-height: 18px; }
.stat-card:not(:has(.foot)) .value { margin-bottom: calc(var(--space-2) + 18px); }
.stat-card.is-clickable { cursor: pointer; font: inherit; color: inherit; width: 100%; border: 1px solid var(--border-subtle); background: var(--surface-card); }
.stat-card.is-clickable:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-default); }
.stat-card.is-clickable:hover::after { width: 64px; }
.stat-card.is-clickable:active { transform: translateY(-1px); }
.stat-go { position: absolute; right: var(--space-4); top: var(--space-4); display: inline-flex; color: var(--text-tertiary); opacity: 0; transform: translateX(-4px); transition: opacity 180ms ease, transform 180ms ease, color 180ms ease; }
.stat-card.is-clickable:hover .stat-go { opacity: 1; transform: none; color: var(--brand-primary); }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--space-4); align-items: stretch; }
.chart-grid .span-2 { grid-column: span 2; }
.chart-grid .span-3 { grid-column: 1 / -1; }
.chart-card { display: flex; flex-direction: column; }
.chart-card > div:last-of-type { margin-top: auto; }

/* ---- gráficos (assets/js/charts.js) ---- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 11px; fill: var(--text-tertiary); }
.chart .axis-line { stroke: var(--border-default); stroke-width: 1; }
.chart .grid-line { stroke: var(--border-subtle); stroke-width: 1; stroke-dasharray: 3 5; }
.chart .eixo-x { fill: var(--text-secondary); font-size: 11.5px; font-weight: 500; }
.chart .eixo-x-sub { fill: var(--text-tertiary); font-size: 10.5px; font-weight: 400; }
.chart .eixo-y { fill: var(--text-secondary); font-size: 12px; font-weight: 500; }
.chart .bar-label { fill: var(--text-primary); font-family: var(--font-display); font-size: 12px; font-weight: 700; }
.chart .bar-trilha { fill: var(--neutral-100); opacity: .7; pointer-events: none; }
.chart .barra-trilha { fill: var(--neutral-100); }
.chart .donut-trilha { stroke: var(--neutral-100); }
.chart .donut-valor { font-family: var(--font-display); font-weight: 800; fill: var(--text-primary); letter-spacing: -.03em; }
.chart .donut-legenda { fill: var(--text-tertiary); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.chart .grupo-hover { fill: transparent; }
.chart .grupo-hover:hover { fill: color-mix(in srgb, var(--brand-primary) 6%, transparent); }
.chart .cursor-linha { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .bar, .chart .donut-seg { transition: filter 160ms ease, opacity 160ms ease; }
.chart .bar:hover { filter: brightness(1.12) saturate(1.05); }
.chart .bar-grow { transform-box: fill-box; transform-origin: 50% 100%; animation: chartGrow 640ms cubic-bezier(.2,.8,.2,1) both; }
.chart .bar-fade { animation: fadeIn 420ms ease both; }
.chart .donut-in { animation: donutIn 700ms cubic-bezier(.2,.8,.2,1) both; }
.chart .stack-reveal { transform-box: fill-box; transform-origin: 0 50%; animation: chartSweep 700ms cubic-bezier(.2,.8,.2,1) both; }
.chart .area-in { animation: fadeIn 800ms ease both; }
.chart .linha-in { stroke-dasharray: 1; stroke-dashoffset: 1; animation: linhaDesenha 1100ms cubic-bezier(.4,0,.2,1) forwards; }
@keyframes chartGrow { from { transform: scaleY(0); opacity: .4; } to { transform: scaleY(1); opacity: 1; } }
@keyframes chartSweep { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes donutIn { from { opacity: 0; transform: scale(.9); transform-origin: center; } to { opacity: 1; transform: none; } }
@keyframes linhaDesenha { to { stroke-dashoffset: 0; } }

.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-5) var(--space-6); padding: var(--space-2) 0; }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; flex: 1 1 180px; min-width: 170px; max-width: 320px; }
.legend-item { display: grid; grid-template-columns: 10px 1fr auto 42px; align-items: center; gap: var(--space-3); padding: 7px var(--space-2); border-radius: var(--radius-sm); font-size: var(--fs-body-sm); transition: background-color 120ms ease; }
.legend-item.is-clickable { cursor: pointer; }
.legend-item.is-clickable:hover { background: var(--neutral-100); }
.legend-item i { width: 10px; height: 10px; border-radius: 4px; }
.legend-nome { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-valor { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }
.legend-pct { font-style: normal; font-size: 12px; color: var(--text-tertiary); text-align: right; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-4); }
.legend span { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 12px; color: var(--text-secondary); }
.legend i { width: 10px; height: 10px; border-radius: 4px; flex: none; display: inline-block; }

.chart-tip {
  position: fixed; left: 0; top: 0; z-index: 400; pointer-events: none;
  min-width: 120px; max-width: 280px; padding: 10px 12px;
  background: var(--ink-900); color: #fff; border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: 12.5px; line-height: 1.4; opacity: 0; transition: opacity 120ms ease;
}
.chart-tip.is-on { opacity: 1; }
:root[data-theme="dark"] .chart-tip { background: var(--neutral-800); color: var(--ink-900); border-color: transparent; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chart-tip { background: var(--neutral-800); color: var(--ink-900); border-color: transparent; } }
.chart-tip-titulo { font-weight: 700; margin-bottom: 6px; }
.chart-tip-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; padding: 2px 0; }
.chart-tip-row i { width: 8px; height: 8px; border-radius: 3px; }
.chart-tip-row b { font-variant-numeric: tabular-nums; }

.funil-viz { display: grid; gap: var(--space-3); }
.funil-linha { display: grid; grid-template-columns: minmax(80px, 28%) 1fr auto; align-items: center; gap: var(--space-3); padding: 4px 0; border-radius: var(--radius-sm); }
.funil-linha:hover .funil-barra { filter: brightness(1.1); }
.funil-rotulo { font-size: var(--fs-body-sm); font-weight: var(--fw-medium); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funil-trilha { height: 22px; border-radius: 999px; background: var(--neutral-100); overflow: hidden; }
.funil-barra { height: 100%; border-radius: 999px; transform-origin: 0 50%; animation: chartSweep 700ms cubic-bezier(.2,.8,.2,1) both; transition: filter 160ms ease; }
.funil-valor { display: flex; flex-direction: column; align-items: flex-end; min-width: 72px; line-height: 1.15; }
.funil-valor b { font-family: var(--font-display); font-size: var(--fs-body-md); font-variant-numeric: tabular-nums; }
.funil-valor small { font-size: 11px; color: var(--text-tertiary); }
.spark { display: block; }

.progress { height: 8px; background: var(--neutral-100); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand-gradient); border-radius: 999px; transition: width 500ms cubic-bezier(.4,0,.2,1); }

.empty, .empty-state {
  padding: var(--space-10) var(--space-6); text-align: center; color: var(--text-secondary); font-size: var(--fs-body-sm);
  border: 1px dashed var(--border-default); border-radius: var(--radius-lg); background: var(--surface-card-alt);
}
.empty-state h2 { font-size: var(--fs-heading-md); color: var(--text-primary); }
.empty { color: var(--text-tertiary); }

/* ---------- 7. Tabelas ---------- */
.table-wrap {
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  background: var(--surface-card); overflow-x: auto; box-shadow: var(--shadow-sm);
  position: relative; z-index: 0;
}
table.tasks { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 900px; }
table.tasks th {
  position: sticky; top: 0; z-index: 1; text-align: left;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-tertiary); font-weight: var(--fw-medium);
  padding: 14px var(--space-4); border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-card-alt); white-space: nowrap;
}
table.tasks th.sortable { cursor: pointer; user-select: none; }
table.tasks th.sortable:hover { color: var(--text-primary); }
table.tasks td { padding: 14px var(--space-4); border-bottom: 1px solid var(--border-subtle); font-size: var(--fs-body-sm); vertical-align: middle; }
table.tasks tbody tr:last-child td { border-bottom: none; }
table.tasks tbody tr { cursor: pointer; transition: background-color 150ms ease; }
table.tasks tbody tr:hover { background: color-mix(in srgb, var(--brand-primary) 5%, var(--surface-card)); }
table.tasks tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--brand-primary); }
table.tasks .task-name { font-weight: var(--fw-semibold); }
table.tasks .task-project { display: block; font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.tabela-contas .valor-conta { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

table.tabela-clientes { min-width: 0; table-layout: auto; }
table.tabela-clientes th, table.tabela-clientes td { padding-left: var(--space-3); padding-right: var(--space-3); }
table.tabela-clientes td { white-space: normal; }
table.tabela-clientes td.mono { white-space: nowrap; }
table.tabela-clientes th:nth-child(2), table.tabela-clientes td:nth-child(2) { min-width: 160px; }
table.tabela-clientes th:nth-child(7), table.tabela-clientes td:nth-child(7) { min-width: 110px; }
table.tabela-clientes td:nth-child(8) { white-space: normal; min-width: 130px; }
table.tabela-clientes th:nth-child(10), table.tabela-clientes td:nth-child(10) { white-space: normal; }
table.tabela-clientes td:nth-child(10) .badge { white-space: normal; max-width: 130px; }

/* ---------- 8. Selos, avatares, switches ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: var(--fw-semibold); white-space: nowrap;
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
}
.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge-neutral { background: var(--neutral-100); color: var(--neutral-600); }
.badge-green   { background: var(--b-green-bg); color: var(--b-green-fg); }
.badge-mint    { background: var(--b-mint-bg);  color: var(--b-mint-fg); }
.badge-amber   { background: var(--b-amber-bg); color: var(--b-amber-fg); }
.badge-red     { background: var(--b-red-bg);   color: var(--b-red-fg); }
.badge-ink     { background: var(--neutral-200); color: var(--text-primary); }
.badge-blue    { background: var(--b-blue-bg);  color: var(--b-blue-fg); }
.badge-crm     { background: var(--b-crm-bg);   color: var(--b-crm-fg); }

.avatar {
  width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 11px; font-weight: var(--fw-bold); color: #fff; flex: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); transition: transform 160ms ease;
}
.avatar:hover { transform: translateY(-1px) scale(1.06); z-index: 2; }
.avatar-lg { width: 46px; height: 46px; font-size: 14px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.person { display: flex; align-items: center; gap: var(--space-2); }
.person .name { font-weight: var(--fw-medium); }
.avatar-group { display: inline-flex; flex: none; }
.avatar-group .avatar { margin-left: -8px; border: 2px solid var(--surface-card); box-sizing: content-box; }
.avatar-group .avatar:first-child { margin-left: 0; }
.avatar-group .avatar-more { background: var(--neutral-300); color: var(--text-primary); }

.person-picker { border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-card); max-height: 200px; overflow-y: auto; padding: var(--space-1); box-shadow: var(--shadow-sm); }
.person-picker-item { display: flex; align-items: center; gap: var(--space-2); padding: 8px var(--space-2); border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs-body-sm); transition: background-color 120ms ease; }
.person-picker-item:hover { background: var(--neutral-100); }
.person-picker-item.is-checked { background: var(--brand-soft); color: var(--text-primary); }
.person-picker-item input[type="checkbox"] { width: 16px; height: 16px; flex: none; cursor: pointer; }
.person-picker-item span.p-nome { font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-picker-empty { padding: var(--space-3); font-size: var(--fs-body-sm); color: var(--text-tertiary); }

.switch-row { display: flex; align-items: center; gap: var(--space-3); padding: 2px 0; }
.switch-row .switch-label { font-size: var(--fs-body-sm); font-weight: var(--fw-medium); cursor: pointer; }
.switch { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; background: var(--neutral-300); border-radius: 999px; transition: background-color 180ms ease; }
.switch-track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform 180ms cubic-bezier(.3,1.4,.5,1); }
.switch input:checked + .switch-track { background: var(--brand-gradient); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.due { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.due.is-late { color: var(--error-500); font-weight: var(--fw-bold); }
.due.is-soon { color: var(--warning-500); font-weight: var(--fw-bold); }

/* Contas a pagar / receber */
.conta-alerta { border-left: 4px solid var(--warning-500); }
.conta-alerta-grave { border-left: 4px solid var(--error-500); background: color-mix(in srgb, var(--error-500) 6%, var(--surface-card)); animation: contaAlertaPulso 2.4s ease-in-out infinite; }
@keyframes contaAlertaPulso { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--error-500) 32%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--error-500) 0%, transparent); } }
.conta-alerta-item { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--neutral-50); cursor: pointer; font-size: var(--fs-body-sm); transition: background-color 120ms ease; }
.conta-alerta-item:hover { background: var(--neutral-100); }
.conta-popup-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); margin-bottom: var(--space-2); }
.conta-popup-item.is-atrasada { border-color: color-mix(in srgb, var(--error-500) 60%, transparent); background: color-mix(in srgb, var(--error-500) 7%, var(--surface-card)); }
.conta-popup-item .k { flex: 1; min-width: 0; }
.conta-popup-item .k strong { display: block; }
.conta-popup-item label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-tertiary); white-space: nowrap; font-weight: var(--fw-regular); margin-top: 4px; }

/* ---------- 9. Quadros (kanban / funil), equipe ---------- */
.kanban, .funil-board { display: flex; gap: var(--space-4); align-items: start; overflow-x: auto; padding-bottom: var(--space-4); scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; position: relative; z-index: 0; }
.kanban .kcol, .funil-board .kcol { flex: 0 0 320px; width: 320px; scroll-snap-align: start; }
.kcol {
  background: var(--neutral-100); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: var(--space-3); display: flex; flex-direction: column;
  height: calc(100dvh - 300px); min-height: 160px;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 200ms ease;
}
.kcol.is-over { border-color: var(--brand-primary); background: color-mix(in srgb, var(--brand-primary) 12%, var(--neutral-100)); box-shadow: inset 0 0 0 2px var(--brand-primary); }
.kcol-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2) var(--space-3); flex: none; }
.kcol-head .title { font-family: var(--font-display); font-size: var(--fs-body-sm); font-weight: var(--fw-bold); }
.kcol-head .count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); background: var(--surface-card); border: 1px solid var(--border-subtle); padding: 1px 8px; border-radius: 999px; }
.kcol-sub { font-size: 12px; color: var(--text-tertiary); padding: 0 var(--space-2) var(--space-2); margin-top: -4px; font-family: var(--font-mono); }
.kcol-body { display: grid; gap: var(--space-3); align-content: start; flex: 1; min-height: 0; overflow-y: auto; padding: 2px 2px 2px 0; }
.kcol-body .empty, .kcol-body .empty-state { padding: var(--space-5) var(--space-3); background: transparent; }

.tcard {
  background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); padding: var(--space-4); cursor: grab; display: grid; gap: var(--space-3); min-width: 0;
  transition: box-shadow 200ms ease, transform 180ms ease, border-color 160ms ease;
}
.tcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-default); }
.tcard:active { cursor: grabbing; }
.tcard.is-dragging { opacity: .85; transform: rotate(1.5deg) scale(1.02); box-shadow: var(--shadow-lg); }
.tcard .tcard-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.tcard h4 { font-size: var(--fs-body-sm); font-weight: var(--fw-semibold); font-family: var(--font-body); line-height: var(--lh-snug); letter-spacing: 0; }
.tcard .tcard-foot { display: flex; align-items: center; gap: var(--space-2); }
.tcard .tcard-foot .spacer { flex: 1; }

.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--space-4); }
.person-card { display: grid; gap: var(--space-4); }
.person-card:hover { transform: translateY(-2px); border-color: var(--border-default); }
.person-card .head { display: flex; align-items: center; gap: var(--space-3); }
.person-card .head strong { display: block; font-family: var(--font-display); font-size: var(--fs-body-md); }
.person-card .head span { font-size: 12px; color: var(--text-tertiary); }
.person-card .metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); align-items: stretch; }
.person-card .metrics:has(> :nth-child(2):last-child) { grid-template-columns: 1.3fr 1fr; }
.person-card .metrics div { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; text-align: center; background: var(--neutral-50); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-3) var(--space-2); }
.person-card .metrics b { display: block; overflow-wrap: anywhere; font-family: var(--font-display); font-size: var(--fs-heading-md); font-variant-numeric: tabular-nums; }
.person-card .metrics small { font-size: 11px; color: var(--text-tertiary); }

/* ---------- 10. Modal e detalhe ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5,12,9,.58); backdrop-filter: blur(4px); display: grid; place-items: center; padding: var(--space-6); z-index: 100; animation: fadeIn 180ms ease; }
.modal {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 660px; max-height: 90vh; overflow-y: auto; overflow-x: hidden;
  animation: popIn 240ms cubic-bezier(.2,.8,.2,1) both;
}
.modal-head, .modal-header {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 2; background: color-mix(in srgb, var(--surface-card) 92%, transparent);
  backdrop-filter: blur(8px); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.modal-head h3, .modal-header h3 { font-size: var(--fs-heading-md); }
.modal-head .spacer { flex: 1; }
.modal-body { padding: var(--space-6); display: grid; gap: var(--space-5); }
.modal-foot, .modal-actions {
  display: flex; gap: var(--space-3); justify-content: flex-end;
  padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-subtle);
  position: sticky; bottom: 0; z-index: 2; background: color-mix(in srgb, var(--surface-card) 94%, transparent);
  backdrop-filter: blur(8px);
}
.icon-btn { border: none; background: transparent; cursor: pointer; width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--text-secondary); transition: background-color 160ms ease, color 160ms ease, transform 160ms ease; }
.icon-btn:hover { background: var(--neutral-100); color: var(--text-primary); transform: scale(1.05); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.icon-btn-sm {
  flex: none; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-card); color: var(--text-secondary); font-size: 14px; line-height: 1; cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.icon-btn-sm:hover { background: var(--neutral-100); color: var(--text-primary); }
.icon-btn-sm[disabled] { opacity: .4; cursor: not-allowed; }

.detail-list { display: grid; gap: var(--space-3); }
.detail-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: var(--space-4); }
.detail-row > .k { font-size: 13px; color: var(--text-tertiary); }
.detail-row > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.descricao-tarefa { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }

.checklist { display: grid; gap: var(--space-2); }
.checklist-subtitulo { font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--ls-eyebrow); text-transform: uppercase; color: var(--text-tertiary); font-weight: var(--fw-medium); margin: var(--space-3) 0 0; }
.checklist-subtitulo:first-child { margin-top: 0; }
.check-item { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-body-sm); }
.check-item input[type="checkbox"] { width: 17px; height: 17px; flex: none; cursor: pointer; }
.check-item input[type="text"] { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; font-size: var(--fs-body-sm); color: var(--text-primary); transition: border-color 150ms ease, background-color 150ms ease; }
.check-item input[type="text"]:hover { background: var(--neutral-50); }
.check-item input[type="text"]:focus { outline: none; border-color: var(--brand-primary); background: var(--surface-card); box-shadow: var(--shadow-focus); }
.check-item.done input[type="text"] { text-decoration: line-through; color: var(--text-tertiary); }
.check-item .icon-btn-sm { border: none; background: transparent; width: 28px; height: 28px; color: var(--text-tertiary); flex: none; display: grid; place-items: center; }
.check-item .icon-btn-sm:hover { background: var(--error-100); color: var(--error-500); }
.check-item .icon-btn-sm svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }
.checklist-add-row { display: flex; gap: var(--space-2); margin-top: var(--space-3); }

.toast {
  position: fixed; bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  background: var(--ink-900); color: #fff; padding: 12px var(--space-5); border-radius: 999px;
  font-size: var(--fs-body-sm); font-weight: var(--fw-semibold); box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.1); z-index: 200; max-width: calc(100vw - 32px); text-align: center;
  animation: toastIn 280ms cubic-bezier(.2,.8,.2,1) both;
}
:root[data-theme="dark"] .toast { background: var(--neutral-800); color: var(--ink-900); border-color: transparent; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: var(--neutral-800); color: var(--ink-900); border-color: transparent; } }

/* ---------- 11. CRM, anexos, vínculos, WhatsApp ---------- */
.form-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: flex-start; }
.form-row > * { flex: 1; min-width: 0; }
.form-row .btn { flex: none; }
.etapa-row { display: flex; align-items: center; gap: var(--space-2); }
.etapa-row .input, .etapa-row .select { width: auto; }

.crm-timeline { margin-top: var(--space-6); border-top: 1px solid var(--border-subtle); padding-top: var(--space-5); }
.timeline-add { display: flex; flex-direction: column; gap: var(--space-2); background: var(--surface-card-alt); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-3); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-4); position: relative; }
.timeline-item { display: flex; gap: var(--space-3); animation: sweepIn 300ms ease both; }
.timeline-ic { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: 50%; font-size: 14px; box-shadow: var(--shadow-sm); }
.timeline-item.is-pendente .timeline-ic { border-color: var(--warning-500); background: var(--warning-100); }
.timeline-body { flex: 1; min-width: 0; }
.timeline-head { display: flex; align-items: center; gap: var(--space-2); }
.timeline-head strong { font-size: var(--fs-body-sm); }
.timeline-head .spacer { flex: 1; }
.ic { display: inline-block; vertical-align: -2px; flex: none; }
.ic-wrap { display: inline-flex; align-items: center; color: var(--text-secondary); }
.timeline-ic .ic { width: 16px; height: 16px; }

.anexos-bloco { display: grid; gap: var(--space-3); }
.anexos-lista { display: grid; gap: var(--space-2); }
.anexo-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-card); transition: border-color 160ms ease, background-color 160ms ease, box-shadow 200ms ease; }
.anexo-item:hover { border-color: var(--border-default); background: var(--neutral-50); box-shadow: var(--shadow-sm); }
.anexo-ic { display: inline-flex; flex: none; color: var(--text-tertiary); }
.anexo-item:hover .anexo-ic { color: var(--brand-primary); }
.anexo-nome { flex: 1; min-width: 0; font-size: var(--fs-body-sm); color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.anexo-nome:hover { color: var(--brand-primary); text-decoration: underline; }
.anexo-meta { flex: none; font-size: 12px; color: var(--text-tertiary); }
.anexos-acoes { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.anexo-btn-arquivo { cursor: pointer; }
.anexo-form-link { display: grid; grid-template-columns: 2fr 1fr auto; gap: var(--space-2); }
.anexo-form-link[hidden], .anexo-progresso[hidden] { display: none; }
.anexo-progresso { display: grid; gap: var(--space-1); }
.anexo-progresso .mono { font-size: 11px; color: var(--text-tertiary); }
.anexo-limite { font-size: 12px; margin: 0; color: var(--text-tertiary); }
.anexo-item.is-pendente { border-style: dashed; background: var(--neutral-50); }
.anexo-item.is-pendente .anexo-nome { color: var(--text-secondary); cursor: default; }
.anexo-item.is-pendente .anexo-meta::after { content: ' · a enviar'; color: var(--warning-500); }

.vinculos-bloco { display: grid; gap: var(--space-3); position: relative; }
.vinculos-lista { display: grid; gap: var(--space-2); }
.vinculo-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-card); cursor: pointer; transition: border-color 160ms ease, background-color 160ms ease; }
.vinculo-item:hover { border-color: var(--border-default); background: var(--neutral-50); }
.vinculo-item.is-pendente { cursor: default; border-style: dashed; background: var(--neutral-50); }
.vinculo-status { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.vinculo-titulo { flex: 1; min-width: 0; font-size: var(--fs-body-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vinculo-busca { position: relative; }
.vinculo-resultados { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; max-height: 250px; overflow-y: auto; background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); animation: slideDown 160ms ease both; }
.vinculo-resultados[hidden] { display: none; }
.vinculo-resultado { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: var(--space-3); border: 0; background: transparent; text-align: left; font: inherit; font-size: var(--fs-body-sm); color: var(--text-primary); cursor: pointer; }
.vinculo-resultado:hover { background: var(--neutral-100); }
.vinculo-resultado.vinculo-criar { color: var(--brand-primary); border-top: 1px solid var(--border-subtle); font-weight: var(--fw-semibold); }

.wa-status-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--neutral-300); box-shadow: 0 0 0 4px color-mix(in srgb, var(--neutral-300) 25%, transparent); }
.wa-status-dot.is-on { background: var(--brand-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-primary) 25%, transparent); animation: pulso 2.2s ease-in-out infinite; }
@keyframes pulso { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--brand-primary) 0%, transparent); } }
.wa-conversas { display: grid; grid-template-columns: 300px 1fr; gap: var(--space-4); height: calc(100dvh - 260px); min-height: 440px; }
.wa-lista { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); box-shadow: var(--shadow-sm); overflow-y: auto; padding: var(--space-2); display: flex; flex-direction: column; gap: 2px; }
.wa-lista > p, .wa-lista > .muted { padding: var(--space-6) var(--space-4); color: var(--text-tertiary); font-size: var(--fs-body-sm); text-align: center; }
.wa-item { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-3); border: 0; border-radius: var(--radius-md); background: transparent; text-align: left; cursor: pointer; transition: background-color 160ms ease; }
.wa-item:hover { background: var(--neutral-100); }
.wa-item.is-ativo { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand-primary); }
.wa-item-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wa-item-info strong { font-size: var(--fs-body-sm); }
.wa-item-previa { font-size: 12px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-item-tag { display: inline-block; font-size: 10px; font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--ls-wide); color: var(--b-amber-fg); background: var(--b-amber-bg); padding: 1px 7px; border-radius: 999px; margin-left: 4px; vertical-align: middle; }
.wa-painel { display: flex; flex-direction: column; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.wa-painel-vazio { flex: 1; display: grid; place-items: center; color: var(--text-tertiary); font-size: var(--fs-body-sm); }
.wa-painel-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.wa-thread {
  flex: 1; overflow-y: auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface-canvas);
  background-image: radial-gradient(color-mix(in srgb, var(--text-tertiary) 14%, transparent) 1px, transparent 1px);
  background-size: 18px 18px;
}
.wa-bolha-linha { display: flex; }
.wa-bolha-linha.is-saida { justify-content: flex-end; }
.wa-bolha { max-width: 72%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px; background: var(--surface-card); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-sm); font-size: var(--fs-body-sm); overflow-wrap: anywhere; position: relative; animation: fadeInUp 200ms ease both; }
.wa-bolha-linha.is-saida .wa-bolha { border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg); background: color-mix(in srgb, var(--brand-primary) 16%, var(--surface-card)); border-color: color-mix(in srgb, var(--brand-primary) 32%, transparent); }
.wa-bolha-hora { display: block; margin-top: 4px; font-size: 10px; color: var(--text-tertiary); text-align: right; }
.wa-compose { display: flex; gap: var(--space-2); align-items: flex-end; padding: var(--space-3); border-top: 1px solid var(--border-subtle); background: var(--surface-card); }
.wa-compose .textarea { flex: 1; min-height: 42px; max-height: 120px; resize: vertical; }

/* ---------- 12. Movimento ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(14px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes drawIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sweepIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.page-header { animation: fadeInUp 260ms ease both; }
.stat-grid { animation: fadeInUp 300ms ease both; }
.chart-grid, .people-grid { animation: fadeInUp 340ms ease both; }
.viewtabs, .toolbar, .table-wrap, .kanban, .funil-board { animation: fadeIn 260ms ease both; }
/* Durante a atualização silenciosa em segundo plano (app.js), nada reanima. */
.sem-animacao, .sem-animacao * { animation: none !important; transition: none !important; }

/* ---------- 13. Responsivo ---------- */
@media (max-width: 1100px) {
  .page { padding: var(--space-6); }
  .chart-grid .span-2 { grid-column: auto; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; width: 288px; max-width: 86vw; height: 100dvh;
    transform: translateX(-104%); transition: transform 280ms cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow-lg);
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open { overflow: hidden; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .page { padding: var(--space-5) var(--space-4); }
  .search-box { flex: 1; min-width: 0; }
  .search-box .input, .search-box .input:focus { width: 100%; }
  .topbar .breadcrumb { display: none; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
  .chart-grid, .form-grid { grid-template-columns: 1fr; }
  .detail-row { grid-template-columns: 1fr; align-items: start; gap: var(--space-1); }
  .wa-conversas { grid-template-columns: 1fr; height: auto; }
  .wa-lista { max-height: 260px; }
  .wa-painel { min-height: 440px; }
}
@media (max-width: 640px) {
  .page { padding: var(--space-4) var(--space-3); }
  .page-header { margin-bottom: var(--space-5); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: var(--space-4); }
  .stat-card .value { font-size: 26px; }
  .stat-go { display: none; }
  .alert-bell-pop { width: calc(100vw - 24px); right: -8px; }
  #alertasRoot { left: var(--space-3); right: var(--space-3); max-width: none; }
  .toolbar { gap: var(--space-2); }
  .toolbar .msel, .toolbar .select, .toolbar .input { flex: 1 1 calc(50% - var(--space-2)); min-width: 0; }
  .toolbar .msel-btn { width: 100%; max-width: none; }
  .toolbar .spacer { display: none; }
  .toolbar .btn { flex: 1 1 100%; }
  .viewtabs { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .viewtab { white-space: nowrap; flex: 1; }
  .kanban, .funil-board { gap: var(--space-3); scroll-snap-type: x mandatory; margin: 0 calc(var(--space-3) * -1); padding-left: var(--space-3); padding-right: var(--space-3); }
  .kanban .kcol, .funil-board .kcol { flex: 0 0 86vw; }
  .kcol { height: calc(100dvh - 330px); }
  .people-grid { grid-template-columns: 1fr; }
  .etapa-row { flex-wrap: wrap; }
  .etapa-row .input { flex: 1 1 100%; order: -1; }
  .anexo-form-link { grid-template-columns: 1fr; }
  .anexos-acoes .btn { flex: 1 1 100%; }
  .vinculo-titulo { white-space: normal; }

  /* Tabela vira lista de cards: nada de rolagem horizontal. */
  .table-wrap { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  table.tasks { min-width: 0; display: block; width: 100%; }
  table.tasks thead { display: none; }
  table.tasks tbody { display: grid; gap: var(--space-3); }
  table.tasks tbody tr { display: block; padding: var(--space-4); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); box-shadow: var(--shadow-sm); }
  table.tasks tbody tr:hover td:first-child { box-shadow: none; }
  table.tasks td { display: flex; align-items: center; gap: var(--space-3); border: 0; padding: var(--space-1) 0; min-width: 0; }
  table.tasks td::before { content: attr(data-rotulo); flex: none; width: 88px; font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--ls-wide); text-transform: uppercase; color: var(--text-tertiary); }
  table.tasks td:first-child { flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 0 var(--space-3); margin-bottom: var(--space-2); border-bottom: 1px solid var(--border-subtle); font-weight: var(--fw-semibold); }
  table.tasks td:first-child::before { display: none; }
  table.tasks td .task-name, table.tasks td .task-project { white-space: normal; }
  table.tasks td > * { min-width: 0; }
  table.tasks td .due { white-space: normal; }

  .modal-backdrop { align-items: end; padding: 0; }
  .modal { max-width: none; max-height: 92dvh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .modal-head, .modal-header, .modal-foot, .modal-actions { padding-left: var(--space-4); padding-right: var(--space-4); }
  .modal-head, .modal-header { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-body { padding: var(--space-4); }
  .modal-foot, .modal-actions { flex-wrap: wrap; }
  .modal-foot .btn, .modal-actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .stat-card.is-clickable:hover, .tcard:hover, .person-card:hover, .btn-primary:hover, .btn-secondary:hover, .icon-btn:hover, .avatar:hover { transform: none; }
}

/* ---------- Ajustes finos (pós-auditoria) ---------- */
/* Botões de ação da barra de filtros ficam à direita mesmo quando quebram de linha. */
.toolbar .spacer { flex: 1 1 0; min-width: 0; }
.toolbar .spacer + .btn { margin-left: auto; }
/* O avatar é um <span> — não herda cor/tamanho do texto de apoio do cabeçalho do card. */
.person-card .head span.avatar { color: #fff; font-size: 14px; }
/* Rodapé do menu: fundo sólido, o conteúdo rola por baixo sem vazar. */
.sidebar-footer {
  position: sticky; bottom: calc(var(--space-4) * -1);
  margin: auto calc(var(--space-3) * -1) calc(var(--space-4) * -1); padding: var(--space-3) var(--space-3) var(--space-4);
  background: #0A110E; border-top: 1px solid rgba(255,255,255,.08); z-index: 2;
}
.sidebar { gap: var(--space-4); }

/* ==========================================================================
   Design v5 — identidade ERP: indicadores, hero, cabeçalhos com ícone
   ========================================================================== */

/* ---------- Indicadores (KPI) ---------- */
.stat-card { --tom: var(--brand-primary); }
.stat-card.tom-azul { --tom: #4F8CD1; }
.stat-card.tom-verde { --tom: var(--brand-primary); }
.stat-card.tom-vermelho { --tom: var(--error-500); }
.stat-card.tom-ambar { --tom: var(--warning-500); }
.stat-card.tom-roxo { --tom: #8B6FD6; }
.stat-card.tom-neutro { --tom: var(--neutral-500); }
.stat-card::before { background: radial-gradient(240px 130px at 100% 0%, color-mix(in srgb, var(--tom) 14%, transparent), transparent 70%); }
.stat-card:has(.value.is-alert)::before { background: radial-gradient(240px 130px at 100% 0%, color-mix(in srgb, var(--error-500) 16%, transparent), transparent 70%); }
.stat-card::after { background: var(--tom); width: 38px; }
.stat-card:has(.value.is-alert)::after { background: var(--error-500); }
.kpi-top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.stat-card .eyebrow { margin: 0; padding-top: 2px; line-height: 1.35; }
.kpi-ic {
  flex: none; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  color: var(--tom); background: color-mix(in srgb, var(--tom) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--tom) 24%, transparent);
  transition: transform 220ms cubic-bezier(.3,1.4,.5,1), background-color 160ms ease;
}
.kpi-ic .ic { width: 19px; height: 19px; }
.stat-card.is-clickable:hover .kpi-ic { transform: rotate(-6deg) scale(1.1); background: color-mix(in srgb, var(--tom) 22%, transparent); }
.stat-card .value { margin-top: auto; font-size: clamp(26px, 2.6vw, 34px); }
.stat-card .value.is-good { color: var(--brand-primary); }
.kpi-base { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-2); min-height: 22px; }
.kpi-base .foot { margin: 0; min-height: 0; }
.kpi-spark { flex: none; opacity: .95; }
.stat-card:not(:has(.foot)) .value { margin-bottom: 0; }

/* ---------- Seções ---------- */
.section-head { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-8) 0 var(--space-4); }
.section-head h3 { display: flex; align-items: center; gap: 10px; font-size: var(--fs-body-md); letter-spacing: 0; }
.section-head h3::before { content: ''; width: 4px; height: 18px; border-radius: 4px; background: var(--brand-gradient); }
.section-head .spacer { flex: 1; }

.lista-compacta { display: grid; gap: var(--space-2); }
.item-compacto { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-card-alt); transition: border-color 160ms ease, background-color 160ms ease; }
.item-compacto:hover { border-color: var(--border-default); background: var(--neutral-50); }
.item-ic { flex: none; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-primary); }
.item-txt { min-width: 0; }
.item-txt strong { display: block; font-size: var(--fs-body-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-txt small { color: var(--text-tertiary); font-size: 12px; }
.conta-alerta-item { border: 1px solid var(--border-subtle); background: var(--surface-card-alt); }
.conta-alerta-item:hover { border-color: color-mix(in srgb, var(--brand-primary) 40%, var(--border-default)); background: var(--neutral-50); }

/* ---------- Hero do Painel ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-6);
  padding: var(--space-8); margin-bottom: var(--space-6);
  border-radius: var(--radius-xl); color: #fff;
  border: 1px solid rgba(255,255,255,.08); box-shadow: var(--shadow-md);
  background:
    radial-gradient(520px 280px at 92% -10%, rgba(95,208,166,.42), transparent 70%),
    radial-gradient(420px 260px at -5% 125%, rgba(34,181,140,.30), transparent 70%),
    linear-gradient(135deg, #0F2219 0%, #0A1612 55%, #0C1E17 100%);
  animation: fadeInUp 280ms ease both;
}
.hero::after {
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .5; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px); background-size: 22px 22px;
  mask-image: linear-gradient(100deg, transparent 20%, #000 70%); -webkit-mask-image: linear-gradient(100deg, transparent 20%, #000 70%);
}
.hero-main { min-width: 0; }
.hero-data { margin: 0 0 8px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--coral-400); }
.hero h1 { color: #fff; font-size: clamp(28px, 3.6vw, 42px); letter-spacing: -.03em; }
.hero-sub { margin: 10px 0 0; color: rgba(255,255,255,.74); max-width: 62ch; }
.hero-sub strong { color: #fff; }
.hero-sub .hero-alerta { color: #FFB4B4; }
.hero-acoes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--space-5); }
.hero-btn { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(6px); box-shadow: none; }
.hero-btn:hover { background: rgba(255,255,255,.18); transform: translateY(-1px); }
.hero-btn-principal { background: #fff; color: #0A1612; border-color: #fff; box-shadow: 0 10px 28px -10px rgba(0,0,0,.6); }
.hero-btn-principal:hover { background: #E7FFF5; }
.hero-ring { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.hero-ring span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.hero .chart .donut-valor { fill: #fff; }
.hero .chart .donut-trilha { stroke: rgba(255,255,255,.12); }
.hero .chart .donut-legenda { fill: rgba(255,255,255,.6); }

/* ---------- Cabeçalho de página com ícone por tela ---------- */
.page-header {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--space-4); align-items: center;
  padding-bottom: var(--space-5); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-6);
}
.page-header > * { grid-column: 2; }
.page-header::before {
  content: ''; grid-column: 1; grid-row: 1 / span 3; align-self: center;
  width: 54px; height: 54px; border-radius: 17px;
  background: var(--ic, none) center / 26px no-repeat, var(--brand-gradient);
  box-shadow: var(--shadow-brand), inset 0 1px 0 rgba(255,255,255,.25);
}
.page-header .eyebrow { justify-self: start; display: inline-flex; padding: 3px 10px; margin-bottom: 4px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-primary); font-weight: var(--fw-semibold); }
.page-header h1 { font-size: clamp(24px, 2.8vw, 32px); }
.page-header p { margin: 4px 0 0; }

/* ícone de cada tela (usado pelo ::before do cabeçalho) */
.page[data-view="painel"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='9' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='5' rx='1.5'/%3E%3Crect x='14' y='12' width='7' height='9' rx='1.5'/%3E%3Crect x='3' y='16' width='7' height='5' rx='1.5'/%3E%3C/svg%3E"); }
.page[data-view="minhas"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }
.page[data-view="tarefas"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Cpath d='M3 9h18M9 9v11'/%3E%3C/svg%3E"); }
.page[data-view="prazos"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M8 3v4M16 3v4M3 11h18'/%3E%3C/svg%3E"); }
.page[data-view="crm-funil"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5h18l-7 8v6l-4 2v-8z'/%3E%3C/svg%3E"); }
.page[data-view="crm-contatos"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20a6 6 0 0 1 12 0'/%3E%3Ccircle cx='10' cy='8' r='3.4'/%3E%3Cpath d='M17 11h4M19 9v4'/%3E%3C/svg%3E"); }
.page[data-view="crm-conversas"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E"); }
.page[data-view="crm-whatsapp"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.5 8.5 0 0 1-12.4 7.55L3 20l1.05-5.4A8.5 8.5 0 1 1 21 11.5z'/%3E%3Cpath d='M8.5 10.5c0 3 2.5 5.5 5.5 5.5'/%3E%3C/svg%3E"); }
.page[data-view="equipe"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3.2'/%3E%3Cpath d='M3 20a6 6 0 0 1 12 0'/%3E%3Cpath d='M16 5.2a3.2 3.2 0 0 1 0 5.6M17.5 14.4A6 6 0 0 1 21 20'/%3E%3C/svg%3E"); }
.page[data-view="projetos"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E"); }
.page[data-view="clientes-empresas"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21V7l9-4 9 4v14M9 21v-6h6v6M3 21h18'/%3E%3C/svg%3E"); }
.page[data-view="empresas"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21V7l9-4 9 4v14M9 21v-6h6v6M3 21h18'/%3E%3C/svg%3E"); }
.page[data-view="financeiro-painel"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3v18h18'/%3E%3Cpath d='M7 15l4-5 3 3 5-7'/%3E%3C/svg%3E"); }
.page[data-view="contas-pagar"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 2h12v20l-3-2-3 2-3-2-3 2z'/%3E%3Cpath d='M9 7h6M9 11h6M9 15h3'/%3E%3C/svg%3E"); }
.page[data-view="contas-receber"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2v20M17 7a5 5 0 0 0-5-2 4 4 0 0 0 0 8 4 4 0 0 1 0 8 5 5 0 0 1-5-2'/%3E%3C/svg%3E"); }
.page[data-view="configuracoes"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M4.2 4.2l2.1 2.1M17.7 17.7l2.1 2.1M2 12h3M19 12h3M4.2 19.8l2.1-2.1M17.7 6.3l2.1-2.1'/%3E%3C/svg%3E"); }

/* ---------- Menu: rodapé mais compacto ---------- */
.sidebar-footer .nav-item { padding: 7px var(--space-3); }
.sidebar-footer .sidebar-user { padding-bottom: var(--space-2); }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .hero { padding: var(--space-6); }
  .hero-ring { display: none; }
}
@media (max-width: 640px) {
  .hero { padding: var(--space-5); border-radius: var(--radius-lg); }
  .hero-acoes .btn { flex: 1 1 calc(50% - 10px); }
  .page-header { grid-template-columns: 1fr; }
  .page-header::before { display: none; }
  .page-header > * { grid-column: 1; }
  .section-head { margin-top: var(--space-6); }
  .kpi-ic { width: 34px; height: 34px; border-radius: 11px; }
  .legend-list { max-width: none; }
  .funil-linha { grid-template-columns: minmax(70px, 30%) 1fr auto; }
}

.stat-card .value.is-money { font-size: clamp(19px, 1.7vw, 26px); white-space: nowrap; letter-spacing: -.02em; }
.sidebar-footer .nav-item { padding: 6px var(--space-3); }

.chart-card > .lista-compacta, .chart-card > .empty, .chart-card > .lista-compacta + * { margin-top: 0; }

/* Subtítulos soltos dentro de barras de ferramentas (ex.: "Cartões", "Contas") seguem o padrão das seções. */
.toolbar > h3.card-title { display: flex; align-items: center; gap: 10px; font-size: var(--fs-body-md); letter-spacing: 0; }
.toolbar > h3.card-title::before { content: ''; width: 4px; height: 18px; border-radius: 4px; background: var(--brand-gradient); }

/* ==========================================================================
   Menu recolhido — trilha de ícones refeita
   Cada item vira um "tile" do mesmo tamanho, centralizado; seções separadas
   por uma linha fina; contadores viram uma bolinha no canto do ícone; "Nova
   tarefa" vira um tile com "+" desenhado em CSS. O nome de cada item aparece
   no balão nativo (atributo title) ao passar o mouse.
   ========================================================================== */
.nav-count[data-n="0"] { display: none; }

@media (min-width: 901px) {
  html.sidebar-collapsed .app-shell { grid-template-columns: 88px 1fr; }
  html.sidebar-collapsed .sidebar { padding: var(--space-4) 0; gap: 10px; align-items: center; }

  html.sidebar-collapsed .sidebar-top { width: 100%; flex-direction: column; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.07); }
  html.sidebar-collapsed .sidebar-top .sidebar-brand { flex: none; width: 46px; height: 46px; padding: 0; justify-content: center; border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09); }
  html.sidebar-collapsed .sidebar-brand img { width: 26px; height: 26px; }
  html.sidebar-collapsed .sidebar-collapse-btn { width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; background: rgba(255,255,255,.04); }
  html.sidebar-collapsed .sidebar-collapse-btn:hover { background: rgba(255,255,255,.12); }

  html.sidebar-collapsed .sidebar-section { width: 100%; justify-items: center; gap: 4px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.07); }
  html.sidebar-collapsed .sidebar-top + .sidebar-section { border-top: 0; padding-top: 0; }

  html.sidebar-collapsed .nav-item {
    width: 48px; height: 44px; padding: 0; margin: 0 auto; justify-content: center;
    border-radius: 14px; font-size: 0 !important;
  }
  html.sidebar-collapsed .nav-item svg { width: 20px; height: 20px; }
  html.sidebar-collapsed .nav-item:hover { transform: none; background: rgba(255,255,255,.09); }
  html.sidebar-collapsed .nav-item.is-active {
    background: linear-gradient(135deg, rgba(34,181,140,.36), rgba(34,181,140,.12));
    box-shadow: inset 0 0 0 1px rgba(95,208,166,.30), 0 8px 18px -8px rgba(34,181,140,.6);
  }
  html.sidebar-collapsed .nav-item.is-active::before { left: -20px; top: 11px; bottom: 11px; }

  html.sidebar-collapsed .nav-item .nav-count {
    display: flex !important; position: absolute; top: 2px; right: 2px; margin: 0;
    min-width: 18px; height: 18px; padding: 0 5px; align-items: center; justify-content: center;
    font-size: 10px !important; font-weight: 700; line-height: 1;
    background: var(--coral-400); color: #05140E; box-shadow: 0 0 0 2px #0B1612;
  }
  html.sidebar-collapsed .nav-item .nav-count:empty,
  html.sidebar-collapsed .nav-item .nav-count[data-n="0"] { display: none !important; }

  html.sidebar-collapsed .sidebar-footer {
    width: 100%; margin: auto 0 calc(var(--space-4) * -1); padding: 12px 0 var(--space-4);
    display: grid; justify-items: center; gap: 4px;
  }
  html.sidebar-collapsed #btnNovaTarefa {
    width: 46px; height: 46px; min-height: 0; padding: 0; margin: 0 0 8px; border-radius: 15px;
    font-size: 0; overflow: hidden;
    background:
      linear-gradient(#fff, #fff) center / 18px 2.5px no-repeat,
      linear-gradient(#fff, #fff) center / 2.5px 18px no-repeat,
      var(--brand-gradient);
  }
  html.sidebar-collapsed #btnNovaTarefa::before { content: none; }
  html.sidebar-collapsed .sidebar-user { padding: 6px 0 8px; margin-top: 0 !important; }
  html.sidebar-collapsed .sidebar-user .avatar { width: 40px; height: 40px; font-size: 13px; box-shadow: 0 0 0 2px rgba(255,255,255,.16); }
  html.sidebar-collapsed .sidebar-footer .nav-item { width: 44px; height: 38px; }
}
