/* ============================================================
   Sistema-Cobranca Uelicon — app.css
   Tokens em :root (design-tokens.md) + componentes customizados.
   Tailwind CDN cobre o utilitario; aqui ficam as pecas semanticas.
   ============================================================ */

:root {
  /* --- Superficie --- */
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D4D4D4;

  /* --- Tinta --- */
  --ink-900: #0A0A0A;
  --ink-900-hover: #1A1A1A;   /* +6% L pra hover sobre ink-900 */
  --ink-900-active: #000000;  /* pressed */
  --ink-700: #404040;
  --ink-500: #737373;
  --ink-300: #D4D4D4;
  --ink-on-dark: #FFFFFF;

  /* --- Semanticas --- */
  --green-700: #15803D;
  --green-600: #16A34A;
  --green-50:  #F0FDF4;
  --red-600:   #DC2626;
  --red-700:   #B91C1C;
  --red-100:   #FEE7E7;  /* hover sobre row-late (linha de pgto atrasado) */
  --red-50:    #FEF2F2;
  --amber-700: #B45309;  /* texto sobre amber-50 (callouts warning) */
  --amber-600: #D97706;
  --amber-100: #FEF3C7;  /* borda sutil pra pill warning */
  --amber-50:  #FFFBEB;
  --blue-600:  #2563EB;
  --blue-700:  #1D4ED8;
  --blue-100:  #DBEAFE;  /* borda sutil pra .pill-self */
  --blue-50:   #EFF6FF;

  /* --- Marca Uelicon (padrao Jean) ---
     Verde Uelicon = cor de ACAO PRIMARIA (botao, nav ativo, page ativa, logo).
     NAO confundir com --green-700 abaixo, que e SEMANTICO de status "Pago"
     (regra do design-tokens.md S2.2). Dois verdes coexistem com papeis distintos. */
  --primary:        #22A05D;   /* oklch(0.64 0.18 145) - hex equivalente do verde TMB */
  --primary-hover:  #1C8A4F;   /* -7% L */
  --primary-active: #15703F;   /* -14% L */
  --primary-fg:     #FFFFFF;   /* texto sobre verde */
  --primary-ring:   rgba(34, 160, 93, 0.25); /* 4F transparente do primary pro focus ring */
  --primary-soft:   #E8F5EE;   /* fundo bem-claro pro hover de btn-group/ghost (reservado) */

  /* --- Focus + overlay --- */
  /* Anel sutil verde 3px (era 0 0 0 2px var(--bg), 0 0 0 4px var(--ink-700) -
     anel duplo de 6px solido preto agredia em autofocus de page-load) */
  --focus-ring: 0 0 0 3px var(--primary-ring);
  /* Fallback neutro pra btn-secondary/btn-danger onde verde brigaria
     com a propria identidade do botao */
  --focus-ring-neutral: 0 0 0 3px rgba(64, 64, 64, 0.18);
  --overlay: rgba(0, 0, 0, 0.4);
  --row-hover: #F5F5F5;

  /* --- Tipografia --- */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   18px;
  --text-xl:   22px;
  --text-2xl:  28px;

  /* --- Spacing --- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-8:  48px;

  /* --- Radius --- */
  --radius-sm:  4px;
  --radius:     6px;
  --radius-lg:  8px;
  --radius-pill: 9999px;

  /* --- Shadow --- */
  --shadow-overlay: 0 4px 12px rgba(0, 0, 0, 0.08);

  /* --- Z-index --- */
  --z-sticky:  10;
  --z-dropdown: 20;
  --z-overlay: 50;
  --z-modal:   51;
  --z-toast:   60;
  --z-tooltip: 70;

  /* --- Transicoes --- */
  --t-fast: 100ms ease-out;
  --t-base: 150ms ease-out;

  /* --- Larguras --- */
  --w-content-max: 1280px;
  --w-modal-sm:    480px;
  --w-modal:       560px;

  /* --- Heights de controles (padrao Jean Uelicon) ---
     jean-tokens.json mediu TMB e Central com 44px em input e btn submit.
     Manter sm 36px pra row de tabela (densidade preservada). */
  --control-h:    44px;   /* default - input, select, btn padrao */
  --control-h-sm: 36px;   /* compacto - btn em row de tabela */
  --control-h-lg: 48px;   /* CTA destacado - raro, so em CTA solo */
}

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--ink-700);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea, button { font-family: inherit; }

.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ============================================================
   Layout shells
   ============================================================ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-content {
  flex: 1;
  width: 100%;
  max-width: var(--w-content-max);
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-8);
}
.app-footer {
  font-size: var(--text-xs);
  color: var(--ink-500);
  text-align: center;
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ============================================================
   Header global
   ============================================================ */
.app-header {
  height: 73px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.app-header-inner {
  height: 100%;
  max-width: var(--w-content-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}
.brand {
  display: inline-flex;
  align-items: center;        /* era baseline - centraliza badge + label */
  gap: var(--space-3);        /* texto afastado do U (12px) — pedido do Gustavo */
  text-decoration: none;
  color: inherit;
}
/* Badge quadrado verde com U branco - padrao Jean (TMB, Suporte, Novos Alunos).
   Substitui o antigo .brand-u (texto inline preto). */
.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: var(--primary);
  color: var(--primary-fg);
  font-size: var(--text-lg);       /* header +30% — escala junto com a barra */
  font-weight: 700;
  letter-spacing: 0;
  border-radius: var(--radius);    /* 6px - quadrado com cantos suaves */
  flex: 0 0 42px;
}
.brand-module {
  font-size: var(--text-lg);       /* header +30% */
  font-weight: 600;                /* era 500 - sobe 1 pra pareiar com o badge */
  color: var(--ink-900);           /* era ink-700 - mais legivel */
  word-spacing: -0.5px;            /* leve aproximação (—2px ficou apertado demais) */
}
.nav-main { display: flex; align-items: center; gap: var(--space-1); }
.nav-link {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-md);       /* header +30% */
  font-weight: 500;
  color: var(--ink-700);
  border-radius: var(--radius);
  transition: color var(--t-fast);
  position: relative;
}
.nav-link:hover { color: var(--ink-900); }
.nav-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.nav-link.is-active {
  color: var(--primary);              /* verde - era ink-900 */
  font-weight: 600;
}
.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: -2px;
  height: 2px;
  background: var(--primary);         /* verde - era ink-900 */
  border-radius: 1px;
}
/* Configuração no header = só ícone de engrenagem (fase25). Mantém .nav-link
   (padding/focus-ring/is-active) e só ajusta o alinhamento do SVG.
   fase25 FIX 2 (a11y): alvo de toque mínimo 44x44 (WCAG 2.5.5). O ícone tem
   só 18px, então a área clicável precisa crescer. Para NÃO aumentar a altura
   visual da navbar (os .nav-link de texto têm ~34px), zera-se o padding herdado
   e compensa-se a sobra vertical com margin negativa — o hit area fica 44px mas
   a barra mantém a mesma linha de base dos outros itens. SVG centralizado via
   inline-flex (já existente). is-active/focus-ring herdam de .nav-link intactos. */
.nav-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 0;                 /* sobrescreve o var(--space-2) var(--space-3) do .nav-link */
  /* Absorve a diferença de altura (44px vs ~34px do nav-link de texto) pra não
     esticar a navbar. (44 - ~34) / 2 ≈ 5px de cada lado. */
  margin-top: -5px;
  margin-bottom: -5px;
}
.nav-link-icon svg { display: block; }

.header-spacer { flex: 1; }

/* Botão refresh do header (ícone único, sem texto) */
.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-700);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 200ms ease, background 200ms ease, border-color 200ms ease, transform 120ms ease;
}
.header-icon-btn:hover { color: var(--ink-900); background: var(--row-hover); }
.header-icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.header-icon-btn:active:not(:disabled) { transform: scale(0.94); }
.header-icon-btn:disabled { cursor: progress; }
/* Engrenagem de Configuração como link de ícone (fase27): sem sublinhado +
   estado ativo (página atual) em verde sutil, igual à linguagem da marca. */
a.header-icon-btn { text-decoration: none; }
.header-icon-btn.is-active {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

/* Loading: spin infinito enquanto requests rolam (para na hora que finaliza). */
.header-icon-btn.is-loading {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}
.header-icon-btn.is-loading svg {
  animation: header-refresh-spin 700ms cubic-bezier(0.55, 0.1, 0.45, 0.9) infinite;
  transform-origin: 50% 50%;
}

/* Success: pop + verde por 700ms quando termina ok. */
.header-icon-btn.is-success {
  color: var(--green-700);
  border-color: color-mix(in srgb, var(--green-600) 40%, var(--border));
  background: var(--green-50);
}
.header-icon-btn.is-success svg {
  animation: header-refresh-pop 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes header-refresh-spin {
  from { transform: rotate(0); }
  to   { transform: rotate(360deg); }
}
@keyframes header-refresh-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.28); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .header-icon-btn.is-loading svg,
  .header-icon-btn.is-success svg { animation: none; }
}

/* Badge contador no nav (ex: "Melhorias 3") */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-on-dark);
  background: var(--primary);
  border-radius: 999px;
  line-height: 1;
  vertical-align: middle;
}
.nav-badge[hidden] { display: none; }
.user-menu { position: relative; }
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  color: var(--ink-700);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius);
}
.user-menu-trigger:hover { color: var(--ink-900); background: var(--row-hover); }
.user-menu-trigger:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.user-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-1) 0;
  z-index: var(--z-dropdown);
}
.user-menu-info {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--ink-500);
}
.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-700);
  background: transparent;
  border: none;
}
.user-menu-item:hover { background: var(--row-hover); color: var(--ink-900); }
.user-menu-item:focus-visible { outline: none; background: var(--row-hover); }

/* Sprint 3 frente C — chip de tecla pro modal de atalhos (shell.js) */
.kbd-key {
  display: inline-block;
  min-width: 24px;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-900);
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  text-align: center;
  line-height: 1.2;
}

/* ============================================================
   Kebab menu generico (acoes contextuais em cards/linhas)
   ============================================================ */
.kebab-wrap { position: relative; display: inline-block; }
/* Touch target 44x44 (WCAG 2.5.5 AAA). Visual permanece denso porque o icone
   continua 16px e o background do hover/focus tambem usa os 44x44 (consistencia
   com a area clicavel). Antes era 36x36 (apenas AA). Decisao Sprint 3 frente F. */
.kebab-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--ink-500);
  border-radius: var(--radius);
  cursor: pointer;
}
.kebab-trigger:hover { background: var(--row-hover); color: var(--ink-900); }
.kebab-trigger:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.kebab-trigger[aria-expanded="true"] { background: var(--row-hover); color: var(--ink-900); }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-1) 0;
  z-index: var(--z-dropdown);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-700);
  background: transparent;
  border: none;
  text-decoration: none;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--row-hover); color: var(--ink-900); }
.dropdown-item:focus-visible { outline: none; background: var(--row-hover); }
.dropdown-item--danger { color: var(--red-600); }
.dropdown-item--danger:hover { background: var(--red-50); color: var(--red-700); }
/* width+height explicitos defendem contra SVG sem atributos (gatcha bug visual 2026-05-26 noite). */
.dropdown-item-icon { flex: 0 0 14px; width: 14px; height: 14px; opacity: 0.7; }
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

/* ============================================================
   Linkback
   ============================================================ */
.linkback {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin-bottom: var(--space-3);
}
.linkback:hover { color: var(--ink-900); text-decoration: underline; }
.linkback:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

/* ============================================================
   Botoes
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);   /* 44px - era 36px (padrao Jean) */
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-900);
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn[disabled], .btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
/* Primario disabled: mantem verde com opacity (nao vira cinza pra nao
   confundir com botao secundario). Mesma estrategia do Paiva Lima sessao
   chip-counter-white: nunca forcar cor interna quando ha multiplos estados. */
.btn-primary[disabled], .btn-primary.is-disabled {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
  opacity: 0.5;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); border-color: var(--primary-active); }
.btn-primary:focus-visible { box-shadow: var(--focus-ring); } /* verde-on-verde da glow leve, identico TMB */

.btn-secondary {
  background: var(--surface);
  color: var(--ink-900);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--row-hover); }
.btn-secondary:focus-visible { box-shadow: var(--focus-ring-neutral); }

.btn-danger {
  background: var(--surface);
  color: var(--red-600);
  border-color: var(--red-600);
}
.btn-danger:hover { background: var(--red-50); }
.btn-danger:focus-visible { box-shadow: var(--focus-ring-neutral); }

.btn-link {
  background: transparent;
  color: var(--primary);
  border-color: transparent;
  padding: 0 var(--space-1);
  height: auto;
}
.btn-link:hover { color: var(--primary-hover); text-decoration: underline; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  color: var(--ink-500);
  border-color: transparent;
}
.btn-icon:hover { background: var(--row-hover); color: var(--ink-700); }

.btn-sm { height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-xs); }   /* 36px - row de tabela */
.btn-lg { height: var(--control-h-lg); padding: 0 var(--space-5); }                              /* 48px - CTA solo */
.btn-block { width: 100%; }

.btn .spinner { width: 14px; height: 14px; }

/* ============================================================
   Inputs / selects / textarea
   ============================================================ */
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field-label {
  font-size: var(--text-sm);          /* 13px - era 11px (text-xs) */
  font-weight: 500;
  letter-spacing: 0;                  /* zerado - era 0.04em */
  text-transform: none;               /* removido - era uppercase (padrao Jean Capitalize) */
  color: var(--ink-700);              /* sobe 1 nivel - era ink-500 */
  margin-bottom: var(--space-1);
}
.field-hint {
  font-size: var(--text-sm);
  color: var(--ink-500);
}
.field-error {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--red-600);
}

.input, .select, .textarea {
  width: 100%;
  height: var(--control-h);   /* 44px - era 36px (padrao Jean) */
  padding: 0 var(--space-3);
  font-size: var(--text-md);
  color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ink-700);
  box-shadow: var(--focus-ring);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--bg);
  color: var(--ink-500);
  cursor: not-allowed;
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--red-600);
}

.textarea {
  height: auto;
  min-height: 96px;             /* era 80px - sobe pra ~3 linhas a 44px de control-h */
  padding: var(--space-2) var(--space-3);
  line-height: 1.5;
  resize: vertical;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: 32px;
}

.input-money {
  position: relative;
}
.input-money input {
  padding-left: 36px;
}
.input-money::before {
  content: "R$";
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-500);
  font-size: var(--text-sm);
  pointer-events: none;
}
/* Variante compacta usada na tabela de parcelas (cell ~140px) */
.input-money.input-money-compact::before {
  left: 6px;
  font-size: var(--text-xs);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
}
.card-title {
  margin: 0 0 var(--space-4);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.01em;
}
.card-subtitle {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-500);
}

/* Card-como-filtro (aging buckets) */
.bucket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  cursor: pointer;
  transition: border-color var(--t-fast);
  position: relative;
  text-align: left;
  min-width: 0;
}
.bucket-card:hover { border-color: var(--ink-700); }
.bucket-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.bucket-card.is-active {
  border: 2px solid var(--ink-900);
  padding: calc(var(--space-4) - 1px);
}
.bucket-card.is-active .bucket-card-check {
  display: inline-flex;
}
.bucket-card-check {
  display: none;
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 14px;
  height: 14px;
  color: var(--ink-900);
}
.bucket-card-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-500);
}
.bucket-card-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.bucket-card-meta {
  font-size: var(--text-sm);
  color: var(--ink-500);
}

/* ============================================================
   Cards categoria + métrica (padrão TMB)
   ============================================================ */

/* Linha 1: 4 cards principais (3 categorias + 1 métrica de vendas) */
.cards-row-1 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
/* Linha 2: 3 cards secundários (2 categorias + 1 métrica de caixa) */
.cards-row-2 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-3);
}
@media (max-width: 900px) {
  .cards-row-1 { grid-template-columns: repeat(2, 1fr); }
  .cards-row-2 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .cards-row-1 { grid-template-columns: 1fr; }
  .cards-row-2 { grid-template-columns: 1fr; }
}

/* ----- Card categoria (clicável, colorido) ----- */
.card-categoria {
  --tone-bg: var(--surface);
  --tone-border: var(--border);
  --tone-text: var(--ink-900);
  --tone-icon: var(--ink-500);
  --tone-num: var(--ink-900);
  background: var(--tone-bg);
  border: 1px solid var(--tone-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform 80ms;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  position: relative;
}
.card-categoria:hover { transform: translateY(-1px); }
.card-categoria:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.card-categoria.is-active {
  border-color: var(--tone-icon);
  border-width: 2px;
  padding: 13px 15px;
}
.card-categoria.is-active::after {
  content: "";
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone-icon);
}

.card-categoria-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--tone-text);
}
.card-categoria-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--tone-icon) 18%, transparent);
  color: var(--tone-icon);
  flex-shrink: 0;
}
.card-categoria-label {
  color: var(--tone-text);
  font-size: var(--text-sm);
  font-weight: 500;
}
.card-categoria-num {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.card-categoria-qtd {
  font-size: 28px;
  font-weight: 700;
  color: var(--tone-num);
  letter-spacing: -0.02em;
  line-height: 1;
}
.card-categoria-unit {
  font-size: var(--text-xs);
  color: var(--ink-500);
}
.card-categoria-valor {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}
.card-categoria-sub {
  font-size: 11px;
  min-height: 14px;
  color: var(--ink-500);
}
/* Badge "X >30d" dentro de cards de Inadimplentes / Aguardando entrada — alerta de envelhecimento (TMB). */
.badge-30d {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--red-700);
  background: var(--red-50);
  border: 1px solid color-mix(in srgb, var(--red-600) 30%, var(--border));
  border-radius: 999px;
  line-height: 1.4;
  vertical-align: middle;
}

/* Tons (mapa de cores extraído da TMB) */
.card-tone-good {
  --tone-bg: #f0fdf4;
  --tone-border: #bbf7d0;
  --tone-icon: #16a34a;
  --tone-num: #15803d;
}
.card-tone-bad {
  --tone-bg: #fef2f2;
  --tone-border: #fecaca;
  --tone-icon: #dc2626;
  --tone-num: #b91c1c;
}
.card-tone-info {
  --tone-bg: #eff6ff;
  --tone-border: #bfdbfe;
  --tone-icon: #2563eb;
  --tone-num: #1d4ed8;
}
.card-tone-warn {
  --tone-bg: #fffbeb;
  --tone-border: #fde68a;
  --tone-icon: #d97706;
  --tone-num: #b45309;
}
/* Promessas — roxo, distinto do amber de "Aguardando entrada" (mesma família antes) */
.card-tone-promessa {
  --tone-bg: #f5f3ff;
  --tone-border: #ddd6fe;
  --tone-icon: #7c3aed;
  --tone-num: #6d28d9;
}
.card-tone-muted {
  --tone-bg: #f9fafb;
  --tone-border: #e5e7eb;
  --tone-icon: #6b7280;
  --tone-num: #4b5563;
}

/* ----- Cards de métrica (linha secundária, neutros) ----- */
.card-metrica {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  transition: border-color var(--t-fast);
}
.card-metrica:hover { border-color: var(--ink-700); }
.card-metrica-warn {
  border-color: color-mix(in srgb, #dc2626 30%, var(--border));
  background: #fef2f2;
}
.card-metrica-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-metrica-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink-700);
  flex-shrink: 0;
}
.card-metrica-warn .card-metrica-icon {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}
.card-metrica-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-700);
}
.card-metrica-num {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.card-metrica-qtd {
  font-size: 28px;
  font-weight: 700;
  color: #15803d;
  letter-spacing: -0.02em;
  line-height: 1;
}
.card-metrica-warn .card-metrica-qtd { color: #b91c1c; }
.card-metrica-unit {
  font-size: var(--text-sm);
  color: var(--ink-500);
}
.card-metrica-valor {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}
.card-metrica-sub {
  font-size: var(--text-xs);
  min-height: 16px;
}

/* Ícones SVG via background-image (preto, herdam currentColor via mask) */
.card-categoria-icon::before,
.card-metrica-icon::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  background-color: currentColor;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-size: contain;
          mask-size: contain;
}
.icon-check::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
}
.icon-warn::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m10.29 3.86-8.16 14a2 2 0 0 0 1.71 3h16.32a2 2 0 0 0 1.71-3l-8.16-14a2 2 0 0 0-3.42 0z'/><line x1='12' y1='9' x2='12' y2='13'/><line x1='12' y1='17' x2='12.01' y2='17'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m10.29 3.86-8.16 14a2 2 0 0 0 1.71 3h16.32a2 2 0 0 0 1.71-3l-8.16-14a2 2 0 0 0-3.42 0z'/><line x1='12' y1='9' x2='12' y2='13'/><line x1='12' y1='17' x2='12.01' y2='17'/></svg>");
}
.icon-clock::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><polyline points='12 6 12 12 16 14'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><polyline points='12 6 12 12 16 14'/></svg>");
}
.icon-x::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>");
}
.icon-bolt::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><polygon points='13 2 3 14 12 14 11 22 21 10 12 10 13 2'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><polygon points='13 2 3 14 12 14 11 22 21 10 12 10 13 2'/></svg>");
}
.icon-money::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='12' y1='1' x2='12' y2='23'/><path d='M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><line x1='12' y1='1' x2='12' y2='23'/><path d='M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/></svg>");
}

/* ============================================================
   "Para fazer hoje" — bloco priorizado no topo do dashboard
   ============================================================ */
.para-hoje-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: color-mix(in srgb, #fbbf24 8%, var(--surface));
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: var(--text-sm);
  text-align: left;
  color: var(--ink-900);
}
.para-hoje-header:hover { background: color-mix(in srgb, #fbbf24 14%, var(--surface)); }
.para-hoje-bolt {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: #fef3c7;
  color: #d97706;
}
.para-hoje-bolt::before {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><polygon points='13 2 3 14 12 14 11 22 21 10 12 10 13 2'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><polygon points='13 2 3 14 12 14 11 22 21 10 12 10 13 2'/></svg>") center/contain no-repeat;
}
.para-hoje-body {
  padding: 8px 0;
}
.para-hoje-grupo {
  padding: 8px 16px;
}
.para-hoje-grupo + .para-hoje-grupo {
  border-top: 1px dashed var(--border);
}
.para-hoje-grupo-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.para-hoje-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 8px 8px;
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-size: var(--text-sm);
  color: var(--ink-900);
  min-width: 0;
}
.para-hoje-item:hover { background: var(--row-hover); }

/* ============================================================
   Projeção de caixa — barras stacked simples
   ============================================================ */
.projecao-legenda {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--ink-500);
  flex-wrap: wrap;
}
.projecao-legenda-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.projecao-legenda-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.projecao-legenda-dot.is-pago     { background: #16a34a; }
.projecao-legenda-dot.is-receber  { background: #94a3b8; }
.projecao-legenda-dot.is-atrasado { background: #dc2626; }

.projecao-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--space-3);
  align-items: end;
  min-height: 180px;
  padding-top: var(--space-2);
}
.projecao-mes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.projecao-bar-wrap {
  width: 100%;
  max-width: 56px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 140px;
  border-radius: 4px;
  overflow: hidden;
}
.projecao-bar {
  width: 100%;
  transition: opacity 120ms;
}
.projecao-bar:hover { opacity: 0.8; }
.projecao-bar-pago     { background: #16a34a; }
.projecao-bar-receber  { background: #94a3b8; }
.projecao-bar-atrasado { background: #dc2626; }
.projecao-mes-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-700);
}
.projecao-mes-valor {
  font-size: 11px;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}

/* Stat cards (TMB-style: label pequeno cinza + valor grande + sparkline + trend) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--t-fast);
  min-width: 0;
}
.stat-card:hover { border-color: var(--ink-700); }
.stat-card.is-warn {
  border-color: color-mix(in srgb, var(--red-600) 30%, var(--border));
  background: color-mix(in srgb, var(--red-600) 3%, var(--surface));
}
.stat-card-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-500);
}
.stat-card-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-card.is-warn .stat-card-value { color: var(--red-600); }
.stat-card-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}
.stat-card-spark {
  flex: 0 0 120px;
  height: 32px;
  display: block;
  max-width: 50%;
}
.stat-card-sub {
  font-size: var(--text-xs);
  min-height: 16px;
}
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stat-trend.is-good { color: var(--primary); }
.stat-trend.is-bad  { color: var(--red-600); }
.stat-trend.is-neutral { color: var(--ink-500); }
.stat-trend::before {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  margin-right: 2px;
}
.stat-trend.is-good::before { border-bottom: 5px solid var(--primary); }
.stat-trend.is-bad::before  { border-top: 5px solid var(--red-600); }
.stat-trend.is-neutral::before { display: none; }

/* Chip de categoria (TMB-style) */
.chip-cat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 8px 14px 8px 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-700);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  min-height: 36px;
}
.chip-cat:hover { border-color: var(--ink-700); }
.chip-cat:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.chip-cat.is-active {
  /* Verde marca sólido + texto branco (padrão Tarefas / blueprint Melhorias). */
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-fg);
}
.chip-cat.is-active .chip-cat-count {
  background: rgba(255,255,255,0.16);
  color: var(--surface);
}
.chip-cat-count {
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--bg);
  color: var(--ink-500);
  padding: 2px 8px;
  border-radius: 9999px;
  font-variant-numeric: tabular-nums;
}

/* Drawer lateral do cliente (TMB-style) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.40);
  z-index: 60;
  backdrop-filter: blur(2px);
}
.drawer-right {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  /* Sprint 4 Frente D — drawer adaptativo.
     Mobile (<=640px): ocupa 90vw (deixa 10% pro backdrop ser tocável).
     Tablet (641-1366px): 480px fixo (comportamento histórico).
     Desktop wide (>=1367px): 35vw clampado entre 480-640px — preenche tela ampla
     sem espremer, mantém largura razoável em telas gigantes.
     Transition de width preserva animação suave em resize. */
  width: 480px;
  max-width: 96vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.10);
  z-index: 61;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 200ms ease-out;
}
@media (max-width: 640px) {
  .drawer-right { width: 90vw; max-width: 90vw; }
}
@media (min-width: 1367px) {
  .drawer-right { width: clamp(480px, 35vw, 640px); }
}
.drawer-enter { transition: transform 200ms ease-out; }
.drawer-enter-start { transform: translateX(100%); }
.drawer-enter-end { transform: translateX(0); }
.drawer-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
/* Removido 2026-05-27 — `.drawer-actions-bar` + `.bulk-parcela-item*` saíram
   junto com a UI "Contato em várias parcelas". Re-introduzir se a barra de
   ações em massa voltar (não previsto). */
.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.drawer-tabs button {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.drawer-tabs button:hover { color: var(--ink-700); }
.drawer-tabs button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Botão WhatsApp na ficha do cliente — ícone circular verde (WhatsApp brand),
   alinhado à direita da célula pra manter o grid 2-col simétrico. */
.wa-icon-btn {
  margin-left: auto;
  flex: 0 0 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  transition: background var(--t-fast), transform var(--t-fast);
}
.wa-icon-btn:hover { background: #1ebe5b; }
.wa-icon-btn:active { transform: scale(0.94); }

/* Número de celular clicável → abre o WhatsApp (ficha do cliente).
   display:block força o botão Whatsapp pra LINHA DE BAIXO (era inline → ficava ao lado). */
.wa-num-link { color: var(--ink-900); text-decoration: none; display: block; }
.wa-num-link:hover { color: var(--primary); text-decoration: underline; }
/* Botão "Whatsapp" com texto, ABAIXO do número — verde WhatsApp, tamanho de botão
   confortável (não o pill minúsculo de status). */
.wa-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  height: 28px;
  padding: 0 12px;
  margin-top: 6px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
  background: #25d366;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast);
}
.wa-pill-btn:hover { background: #1ebe5b; }
.wa-pill-btn:active { transform: scale(0.97); }
.wa-icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wa-pill-btn:focus-visible, .wa-num-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.drawer-tabs button.is-active {
  color: var(--ink-900);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}
/* Rodapé fixo do drawer de NOVA VENDA — soma + botões. O drawer é flex-column
   e o body tem flex:1, então o footer naturalmente fica colado embaixo. */
.drawer-footer-soma {
  flex: 0 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.drawer-footer-soma .soma-status { font-size: var(--text-sm); flex-wrap: wrap; }
.drawer-footer-soma .flex-row { justify-content: flex-end; }

/* ===== Stepper de NOVA VENDA — 3 passos gateados (1 expandido por vez) =====
   Cada passo é um card com header clicável (chevron + nº + título + resumo/cadeado)
   e corpo controlado por x-show. Passo bloqueado fica esmaecido e não clicável;
   passo concluído colapsa pra 1 linha de resumo. Reusa --primary / --focus-ring. */
.step-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.step-dot {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--bg);
  color: var(--ink-500);
  border: 1px solid var(--border);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.step-dot.is-active { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.step-dot.is-done { background: var(--green-50); color: var(--green-700); border-color: var(--green-600); }
.step-dot.is-locked { opacity: 0.5; }
.step-dot-line { flex: 1 1 auto; height: 1px; background: var(--border); }

.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-3);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--t-fast), opacity var(--t-fast);
}
.step-card.is-open { border-color: var(--border-strong); }
.step-card.is-done { border-color: var(--green-600); }
/* Bloqueado: esmaecido + não interativo (o botão também leva :disabled no markup) */
.step-card.is-locked { opacity: 0.55; }

.step-card-head { margin: 0; }
.step-card-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}
.step-card-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius);
}
.step-card-toggle:disabled { cursor: not-allowed; }
.step-card-toggle .mel-chevron {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  color: var(--ink-500);
  transition: transform var(--t-base);
}
.step-card.is-open .step-card-toggle .mel-chevron { transform: rotate(90deg); }
.step-card-title {
  flex: 0 0 auto;
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-900);
}
.step-card.is-locked .step-card-title { color: var(--ink-500); }
.step-lock {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin-left: auto;
  color: var(--ink-500);
}
.step-summary {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step-summary-sep { color: var(--ink-300); }
.step-summary-action {
  margin-left: var(--space-2);
  color: var(--primary);
  font-weight: 600;
}
.step-card-body {
  padding: 0 var(--space-3) var(--space-4) var(--space-3);
}

/* ===== Pagamento: gating + expansividade DENTRO do passo (simplificar Seixas).
   Formas de recebimento colapsam atrás de 1 linha; a tabela vira um resumo
   "✓ N pagamentos · ..." e só expande sob demanda. ===== */
.pgto-collapse {
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}
.pgto-collapse-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: transparent;
  border: none;
  padding: var(--space-1) 0;
  cursor: pointer;
  text-align: left;
}
.pgto-collapse-head:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius);
}
.pgto-collapse-head .mel-chevron {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  color: var(--ink-500);
  transition: transform var(--t-base);
}
.pgto-collapse-head .mel-chevron.is-open { transform: rotate(90deg); }
.pgto-collapse-title {
  flex: 0 0 auto;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-700);
}
.pgto-collapse-resumo {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-xs);
  color: var(--ink-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Cartão-resumo dos pagamentos gerados (colapsado) — clicável pra editar. */
.pgto-resumo-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.pgto-resumo-card:hover { border-color: var(--ink-700); background: var(--bg); }
.pgto-resumo-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.pgto-resumo-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pgto-resumo-action {
  flex: 0 0 auto;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
}
.pgto-empty-hint {
  padding: var(--space-3);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--ink-500);
  text-align: center;
}

/* Lista vertical de pagamentos (substitui a tabela de 8 colunas apertada).
   1 cartão legível por pagamento; clicar abre editor empilhado full-width. */
.pgto-lista { display: flex; flex-direction: column; gap: var(--space-2); }
.pgto-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.pgto-item.is-editing { border-color: var(--ink-700); }
.pgto-item-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  background: transparent;
  border: none;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  text-align: left;
}
.pgto-item-row:hover { background: var(--row-hover); }
.pgto-item-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.pgto-item-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.pgto-item-label { font-weight: 600; color: var(--ink-900); font-size: var(--text-sm); }
.pgto-item-sub {
  font-size: var(--text-xs); color: var(--ink-500);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pgto-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.pgto-item-valor { font-weight: 600; color: var(--ink-900); font-size: var(--text-sm); }
.pgto-item-chev {
  width: 14px; height: 14px; flex: 0 0 14px;
  color: var(--ink-500); transition: transform var(--t-base);
}
.pgto-item-chev.is-open { transform: rotate(90deg); }
.pgto-row-editor {
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
/* Formas de recebimento: dois grupos rotulados (Entrada / Parcelas) pra
   acabar com a confusão de "o que é entrada e o que é parcela". */
.pgto-formas-grupo { margin-bottom: var(--space-3); }
.pgto-formas-grupo:last-child { margin-bottom: 0; }
.pgto-formas-grupo-titulo {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-500);
  margin-bottom: var(--space-1);
}
/* Indicador dos 2 sub-passos do wizard entrada+parcelas (Estrutura → Forma). */
.pgto-sub-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.pgto-sub-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--surface);
  color: var(--ink-500);
  border: 1px solid var(--border);
}
.pgto-sub-dot.is-on {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pgto-sub-line { flex: 1; height: 1px; background: var(--border); }
.drawer-venda-link {
  display: block;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink-900);
  transition: border-color var(--t-fast), background var(--t-fast);
}
/* ===== Drawer da VENDA (reutilizável) — empilha ACIMA do drawer do cliente.
   Cliente usa z 60/61; a venda fica em 80/81 pra cobrir o cliente + seus
   modais internos (contato z 50/51, deleteTent z 70). Modais próprios da venda
   sobem pra z 90 (inline no markup). ===== */
.venda-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  z-index: 80;
  backdrop-filter: blur(1px);
}
.venda-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 96vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.14);
  z-index: 81;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 200ms ease-out;
}
@media (max-width: 640px) {
  .venda-drawer { width: 90vw; max-width: 90vw; }
}
@media (min-width: 1367px) {
  .venda-drawer { width: clamp(480px, 35vw, 640px); }
}
.drawer-venda-link:hover { border-color: var(--ink-700); background: var(--bg); }
.drawer-venda-link.is-focus {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}
.drawer-venda-focus {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
  padding-left: var(--space-3);
  border-left: 3px solid var(--primary);
}
/* Header accordion da venda na aba Cobranças — chevron + título + resumo.
   Botão sem estilo nativo; ocupa a largura disponível pra área de clique ampla. */
.drawer-venda-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: inherit;
}
.drawer-venda-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius);
}
.drawer-venda-toggle .mel-chevron {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  color: var(--ink-500);
  transition: transform var(--t-base);
}
.drawer-venda-toggle h3 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Chevron aponta pra direita colapsado; rotaciona 90° quando a section abre */
.is-open .drawer-venda-toggle .mel-chevron { transform: rotate(90deg); }
.drawer-venda-resumo {
  flex: 0 0 auto;
  margin-left: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-500);
}
/* Cada pagamento dentro da aba Cobranças é um card clicável que expande inline */
.drawer-pagamento {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--t-fast);
}
.drawer-pagamento:hover { border-color: var(--ink-700); }
.drawer-pagamento.is-active { border-color: var(--primary); }
.drawer-pagamento-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--ink-900);
  text-align: left;
}
.drawer-pagamento-row:hover { background: var(--bg); }
.drawer-pagamento-actions {
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ============================================================
   Tabela densa
   ============================================================ */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table thead {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.table th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-500);
}
.table th.tx-right { text-align: right; }
.table td {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-700);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table td.tx-right { text-align: right; }
.table td.tx-nowrap { white-space: nowrap; }
.table .row-clickable { cursor: pointer; }
/* Variante compacta (tabelas de pagamento na ficha do cliente) — menos espaço
   vertical por linha, pra não esticar a ficha com muitas parcelas. */
.table-compact th, .table-compact td { padding-top: 4px; padding-bottom: 4px; }
.table .row-clickable:hover { background: var(--row-hover); }
.table .row-late { background: var(--red-50); }
.table .row-late:hover { background: var(--red-100); }
.table.is-updating tbody { opacity: 0.6; }

/* ============================================================
   Status pills + papel/gateway pills
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 6px;
  background: currentColor;
}
.pill-pago { color: var(--green-700); background: var(--green-50); }
.pill-atrasado { color: var(--red-600); background: var(--red-50); }
.pill-aberto { color: var(--ink-700); background: var(--bg); }
.pill-vencendo { color: var(--amber-600); background: var(--amber-50); }
.pill-cancelado { color: var(--ink-500); background: var(--bg); }
.pill-estornado { color: var(--ink-500); background: var(--bg); }
/* Bucket 2 PR3 — pagamento parcial (R$ recebido < valor contratado).
   Mesma família amber dos status "atenção suave" (vencendo, promessa). */
.pill-parcial { color: var(--amber-600); background: var(--amber-50); }

/* Indicador sutil dentro do pill primário pra sinalizar sobreposição
   (ex: Aguardando entrada com parcela atrasada → ponto vermelho ao lado do texto).
   Decisão 2026-05-25 tarde: pill secundário com texto ficou poluído,
   trocamos por um dot vermelho discreto. Detalhe vai no counter ("· 1 atrasada"). */
.pill-warn-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red-600);
  margin-left: 4px;
  flex: 0 0 6px;
}

.pill-papel {
  color: var(--ink-700);
  background: transparent;
  border: 1px solid var(--border);
}
.pill-prio-alta  { color: #b91c1c; background: #fee2e2; }
.pill-prio-media { color: #b45309; background: #fef3c7; }
.pill-prio-baixa { color: var(--ink-500); background: var(--bg); }
.pill-gateway {
  color: var(--blue-600);
  background: var(--blue-50);
}

/* Pílulas da régua de cobrança (Contato 1 azul → 2 laranja → 3 vermelho → Promessa amarelo) */
.pill-contato-1 { color: #1d4ed8; background: #dbeafe; }
.pill-contato-2 { color: #c2410c; background: #ffedd5; }
.pill-contato-3 { color: #b91c1c; background: #fee2e2; }
.pill-promessa  { color: #a16207; background: #fef3c7; }
/* Bucket 2 PR4 — status novo `renegociado`. Cor distinta de `cancelado` (cinza)
   e de `pago` (verde). Roxo bordô-suave: comunica "ação válida feita" sem
   competir com verde Jean nem alarmar como vermelho do cancelado. */
.pill-renegociado { color: #6d28d9; background: #ede9fe; }

/* Stepper visual do modal Contato — 4 botões coloridos lado a lado */
.contato-tipo-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}
.contato-tipo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all 120ms;
}
.contato-tipo-btn:hover { transform: translateY(-1px); }
.contato-tone-azul     { color: #1d4ed8; }
.contato-tone-laranja  { color: #c2410c; }
.contato-tone-vermelho { color: #b91c1c; }
.contato-tone-amarelo  { color: #a16207; }
.contato-tipo-btn.is-active.contato-tone-azul     { background: #dbeafe; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.18); }
.contato-tipo-btn.is-active.contato-tone-laranja  { background: #ffedd5; border-color: #ea580c; box-shadow: 0 0 0 3px rgba(234,88,12,0.20); }
.contato-tipo-btn.is-active.contato-tone-vermelho { background: #fee2e2; border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,0.20); }
.contato-tipo-btn.is-active.contato-tone-amarelo  { background: #fef3c7; border-color: #d97706; box-shadow: 0 0 0 3px rgba(217,119,6,0.22); }
@media (max-width: 540px) {
  .contato-tipo-stepper { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  /* Responsivo: nunca estoura a viewport (causava scroll horizontal no editar).
     min() prende a largura entre o ideal e (100vw - margem). */
  width: min(var(--w-modal), calc(100vw - 2rem));
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  z-index: var(--z-modal);
}
.modal-sm { width: min(var(--w-modal-sm), calc(100vw - 2rem)); }
.modal-header, .modal-body, .modal-footer {
  padding: var(--space-5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink-900);
}
.modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden; /* trava scroll horizontal — só vertical interno */
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  border-top: 1px solid var(--border);
}

/* Cards de ação dentro do modal Contato (Entrei em contato / Promessa / Pagar) */
.contato-cards-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.contato-action-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 140px;
  transition: border-color 120ms;
}
.contato-action-card:hover { border-color: var(--primary); }
.contato-card-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-3);
}
.contato-card-head strong {
  font-size: var(--text-md);
  color: var(--ink-700);
}
.contato-card-head span {
  font-size: var(--text-sm);
}
.contato-card-body { flex: 1; }
.contato-card-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-2);
}

/* Lista de cobranças anteriores no topo do modal Contato */
.contato-historico-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 180px;
  overflow-y: auto;
}
.contato-historico-item {
  font-size: var(--text-sm);
  line-height: 1.4;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.contato-historico-item:last-child {
  border-bottom: none;
}

/* ============================================================
   Toast
   ============================================================ */
.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border-left: 4px solid var(--ink-700);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  padding: var(--space-3) var(--space-4);
  min-width: 320px;
  max-width: 400px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  pointer-events: auto;
  animation: toast-in 200ms ease-out;
}
.toast-ok { border-left-color: var(--green-700); }
.toast-info { border-left-color: var(--blue-600); }
.toast-warning { border-left-color: var(--amber-600); }
.toast-error { border-left-color: var(--red-600); }
.toast-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-900);
}
.toast-message {
  font-size: var(--text-sm);
  color: var(--ink-700);
  margin-top: 2px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Banner de erro persistente
   ============================================================ */
.banner-error {
  background: var(--red-50);
  border-left: 4px solid var(--red-600);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.banner-error-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--red-700);
}
.banner-error-message {
  font-size: var(--text-sm);
  color: var(--ink-700);
  margin-top: 2px;
}
.banner-error-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--text-xs);
  color: var(--ink-500);
}
.banner-warning {
  background: var(--amber-50);
  border-left: 4px solid var(--amber-600);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--ink-700);
}
.banner-info {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--blue-50);
  border-left: 4px solid var(--blue-600);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--ink-700);
}
.banner-info-icon {
  flex: 0 0 16px;
  margin-top: 2px;
  opacity: 0.8;
  color: var(--blue-700);
}

/* ============================================================
   Callouts compactos (warning/danger) usados em modais.
   Reaproveitam tokens semanticos sem inline-style.
   ============================================================ */
.callout {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}
.callout-icon {
  flex: 0 0 18px;
  margin-top: 1px;
}
.callout-title {
  font-weight: 500;
  margin-bottom: 2px;
}
.callout-list {
  margin: 0;
  padding-left: var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.callout-danger {
  background: var(--red-50);
  color: var(--red-700);
  border-left: 3px solid var(--red-600);
}
.callout-warning {
  background: var(--amber-50);
  color: var(--amber-700);
  border-left: 3px solid var(--amber-600);
}

/* ============================================================
   User identity card (linha avatar+email+meta usada em modais
   pra contextualizar AÇÃO destrutiva/sensivel sobre um user)
   ============================================================ */
.user-identity-card {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
.user-identity-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex: 0 0 40px;
}
.user-identity-body { flex: 1; min-width: 0; }
.user-identity-name {
  font-weight: 500;
  color: var(--ink-900);
}
.user-identity-meta {
  font-size: var(--text-sm);
  color: var(--ink-500);
}
.user-identity-sub {
  font-size: var(--text-xs);
  color: var(--ink-500);
  margin-top: 2px;
}

/* ============================================================
   Pill discreto: "Voce" na propria linha (identidade)
   ============================================================ */
.pill-self {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-pill);
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-100);
  margin-left: 6px;
}

/* ============================================================
   Password strength meter (segmentos de 4)
   ============================================================ */
.password-strength {
  margin-top: var(--space-2);
}
.password-strength-bar {
  display: flex;
  gap: 2px;
  height: 4px;
  margin-bottom: 4px;
}
.password-strength-seg {
  flex: 1;
  border-radius: 2px;
  background: var(--ink-300);
  transition: background-color var(--t-fast);
}
.password-strength-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--ink-500);
}

/* ============================================================
   Field group (fieldset semantico — Permissoes etc.)
   ============================================================ */
.field-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin: 0;
}
.field-group-legend {
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-700);
}

/* ============================================================
   Input com icone interno trailing (ex: cadeado em campo bloqueado)
   ============================================================ */
.input-with-icon {
  position: relative;
}
.input-with-icon .input {
  padding-right: 36px;
}
.input-icon-trailing {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-500);
  pointer-events: none;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-6);
  text-align: center;
}
.empty-state-icon {
  color: var(--ink-300);
  width: 32px;
  height: 32px;
}
.empty-state-text {
  font-size: var(--text-sm);
  color: var(--ink-500);
  max-width: 320px;
  margin: 0;
}

/* ============================================================
   Spinner + skeleton
   ============================================================ */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: var(--bg);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--ink-500);
}
.pagination-controls { display: flex; align-items: center; gap: var(--space-1); }
.page-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-700);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.page-btn:hover { background: var(--row-hover); color: var(--ink-900); }
.page-btn.is-active {
  background: var(--primary);         /* verde - era ink-900 (consistencia com nav-link ativo) */
  color: var(--primary-fg);
  pointer-events: none;
}
.page-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   Dropdown autocomplete (busca de aluno em venda-nova, etc).
   NÃO confundir com .dropdown-menu (kebab) — sao componentes distintos.
   Renomeado de .dropdown-item -> .dropdown-panel-item em 2026-05-26 noite
   pra acabar com conflito de declaracao duplicada (.dropdown-item ja existia
   no .kebab-wrap com display: flex, era sobrescrito aqui com display: block).
   ============================================================ */
.dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
  z-index: var(--z-dropdown);
  max-height: 360px;
  overflow-y: auto;
}
/* Variante INLINE (drawer Nova Venda): resultados no fluxo, não overlay absoluto.
   O .step-card tem overflow:hidden e recortava o dropdown absoluto — inline o card
   cresce e o .drawer-body (overflow-y:auto) rola naturalmente. Some o corte; o
   Seixas rola pra ver todos os clientes. NÃO afeta a página venda-nova.html. */
.dropdown-panel--inline {
  position: static;
  margin-top: var(--space-1);
  box-shadow: none;
  max-height: 320px;
}
.dropdown-panel-item {
  display: block;
  width: 100%;
  text-align: left;
  /* Linha mais alta + nome em destaque: o Seixas precisa BATER O OLHO no nome
     do cliente que está buscando (feedback 2026-05-29). */
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-700);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.dropdown-panel-item:last-child { border-bottom: none; }
.dropdown-panel-item .text-strong {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-900);
}
.dropdown-panel-item:hover, .dropdown-panel-item.is-active {
  background: var(--row-hover);
  color: var(--ink-900);
}
.dropdown-panel-item-meta {
  font-size: var(--text-xs);
  color: var(--ink-500);
  margin-top: 2px;
}
.dropdown-empty {
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-500);
}

/* ============================================================
   Botao-grupo (segmented control)
   ============================================================ */
.btn-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.btn-group button {
  background: transparent;
  border: none;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-700);
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background-color var(--t-fast);
}
.btn-group button:last-child { border-right: none; }
.btn-group button:hover { background: var(--row-hover); color: var(--ink-900); }
.btn-group button.is-active {
  background: var(--primary);         /* verde - era ink-900 */
  color: var(--primary-fg);
}
.btn-group button.is-active:hover {
  background: var(--primary-hover);   /* hover sobre ativo */
}

/* ============================================================
   Chips ativos (filtros aplicados)
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 24px;
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-700);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.chip button {
  background: none;
  border: none;
  color: var(--ink-500);
  padding: 0;
  cursor: pointer;
  display: inline-flex;
}
.chip button:hover { color: var(--ink-900); }

/* ============================================================
   Login screen
   ============================================================ */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--space-5);
}
.login-card {
  width: 100%;
  max-width: 400px;             /* 380 -> 400 - respira 20px a mais */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);      /* 24 -> 32 - mais arejado, padrao Jean */
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.login-brand {
  display: flex;
  flex-direction: column;        /* era row - empilha badge em cima do modulo */
  align-items: center;           /* era baseline */
  gap: var(--space-3);
  margin-bottom: var(--space-4); /* era space-2 */
}
.login-brand .brand-badge {
  width: 48px;                   /* maior na tela de login - hero */
  height: 48px;
  font-size: var(--text-xl);     /* 22px */
  border-radius: var(--radius-lg); /* 8px - leve crescimento de elegancia */
  flex: 0 0 48px;
}
.login-brand .brand-module {
  font-size: var(--text-lg);     /* 18px - hierarquia hero */
  font-weight: 600;
}

/* ============================================================
   Form helpers
   ============================================================ */
.form-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.form-row { display: flex; gap: var(--space-3); align-items: flex-start; }
.form-row > .field { flex: 1; min-width: 0; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); }

@media (max-width: 768px) {
  .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   Sticky-bottom rodape (venda-nova)
   ============================================================ */
.sticky-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-5);
  z-index: var(--z-sticky);
}
.soma-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink-700);
}
.soma-ok { color: var(--green-700); }
.soma-bad { color: var(--red-600); }
/* soma-warn: soma das parcelas passou do total (multa/juros/atraso). Avisa, NÃO bloqueia. */
.soma-warn { color: var(--amber-600); }

/* ============================================================
   Bucket 2 PR4 — Form Renegociar (inline dentro do modal pagamento)
   ============================================================ */
/* Modal-pagamento expande de 640 → 760 quando activeForm='renegociar'
   (repeater de parcelas precisa de mais coluna). Aplicada via :class na div .modal. */
/* Largura do modal-renegociando vem via :style no template (760px desktop,
   selecionado pelo activeForm). Override apenas no breakpoint mobile. */
@media (max-width: 820px) {
  .modal[style*="760px"] { width: 96vw !important; }
}

/* Resumo do pagamento origem (topo do form de renegociar) */
.reneg-resumo {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-3);
}
.reneg-resumo .resumo-item { display: flex; flex-direction: column; gap: 2px; }
.reneg-resumo .resumo-label { font-size: var(--text-xs); color: var(--ink-500); }
.reneg-resumo .resumo-valor { font-size: var(--text-sm); color: var(--ink-700); }
.reneg-resumo .resumo-saldo .resumo-valor { font-size: var(--text-md); color: var(--ink-900); font-weight: 600; }
@media (max-width: 540px) {
  .reneg-resumo { grid-template-columns: 1fr; }
}

/* Radio motivo: layout vertical */
.reneg-motivo-group { display: flex; flex-direction: column; gap: var(--space-1); border: 0; padding: 0; margin: 0; }
.reneg-motivo-group legend { font-size: var(--text-sm); font-weight: 500; color: var(--ink-700); margin-bottom: var(--space-2); padding: 0; }
.reneg-motivo-group label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--ink-700);
}
.reneg-motivo-group label:hover { background: var(--bg); }
.reneg-motivo-group input[type="radio"]:focus-visible + span { text-decoration: underline; }

/* Tabela de parcelas novas — grid CSS pra alinhar colunas.
   Layout: head (uma vez) + body (lista de rows que repetem o mesmo grid).
   Cada `.reneg-parcela-row` é um único elemento root (Alpine x-for friendly). */
.reneg-parcelas-head,
.reneg-parcela-row {
  display: grid;
  grid-template-columns: 32px 140px 150px 130px 130px 32px;
  gap: var(--space-2);
  align-items: start;
}
.reneg-parcelas-head {
  font-size: var(--text-xs);
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0 4px var(--space-1);
}
.reneg-parcelas-body { display: flex; flex-direction: column; gap: var(--space-2); }
.reneg-parcela-row { padding: 4px 0; }
.reneg-parcela-row .reneg-cell { min-width: 0; }
.reneg-parcela-row .reneg-num {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-500);
  font-size: var(--text-sm);
}
.reneg-parcela-row .btn-icon-remove {
  width: 32px;
  height: 36px;
}
.reneg-parcela-helper {
  font-size: var(--text-xs);
  color: var(--amber-600);
  padding: 2px 0 0;
}
@media (max-width: 700px) {
  /* Empilha cada parcela em mobile */
  .reneg-parcelas-head { display: none; }
  .reneg-parcela-row {
    grid-template-columns: 32px 1fr 32px;
    grid-template-areas:
      "num valor remove"
      ".   venc  venc"
      ".   metodo metodo"
      ".   gateway gateway";
    border-bottom: 1px dashed var(--border);
    padding-bottom: var(--space-2);
  }
  .reneg-parcela-row > .reneg-num { grid-area: num; }
  .reneg-parcela-row > .reneg-cell:nth-of-type(1) { grid-area: valor; }
  .reneg-parcela-row > .reneg-cell:nth-of-type(2) { grid-area: venc; }
  .reneg-parcela-row > .reneg-cell:nth-of-type(3) { grid-area: metodo; }
  .reneg-parcela-row > .reneg-cell:nth-of-type(4) { grid-area: gateway; }
  .reneg-parcela-row > .reneg-cell:last-child { grid-area: remove; }
}

/* Total a renegociar (linha de destaque acima do helper de soma) */
.reneg-total-linha {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  color: var(--ink-700);
}
.reneg-total-linha .reneg-total-valor {
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--ink-900);
}

/* Footer sticky DENTRO do form de renegociar (não confunde com sticky-footer global do venda-nova) */
.reneg-form-footer {
  position: sticky;
  bottom: 0;
  margin: var(--space-3) calc(var(--space-4) * -1) calc(var(--space-4) * -1);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.reneg-form-footer .soma-status { font-size: var(--text-sm); }
/* Estado "vazio" (sem parcelas preenchidas ainda): neutro cinza */
.soma-empty { color: var(--ink-500); }

/* Detalhes de renegociação no histórico do drawer (audit log) */
.historico-reneg {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border-left: 2px solid #ede9fe;  /* casa com pill-renegociado */
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--text-xs);
}
.historico-reneg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  color: var(--ink-700);
  margin-bottom: var(--space-2);
}
.historico-reneg-meta strong { color: var(--ink-900); font-weight: 600; }
.historico-reneg-parcelas { display: flex; flex-direction: column; gap: 2px; }
.historico-reneg-parcela {
  display: flex;
  gap: var(--space-1);
  align-items: baseline;
  color: var(--ink-700);
}

/* ============================================================
   Highlight pos-acao
   ============================================================ */
@keyframes row-highlight {
  0%   { background: var(--bg); border-left-color: var(--ink-300); }
  80%  { background: var(--bg); border-left-color: var(--ink-300); }
  100% { background: transparent; border-left-color: transparent; }
}
.is-highlighted {
  border-left: 2px solid var(--ink-300);
  animation: row-highlight 2s ease-out;
}

/* ============================================================
   Typography helpers
   ============================================================ */
.h1-page {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-900);
}
.h2-section {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-900);
}
.page-subtitle {
  margin: 0 0 var(--space-5);
  font-size: var(--text-sm);
  color: var(--ink-500);
}

.text-muted { color: var(--ink-500); }
.text-strong { color: var(--ink-900); font-weight: 500; }
.text-late { color: var(--red-600); }

/* ============================================================
   Timeline (tentativas)
   ============================================================ */
.timeline { display: flex; flex-direction: column; gap: var(--space-3); }
.timeline-item {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.timeline-meta {
  font-size: var(--text-xs);
  color: var(--ink-500);
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}
.timeline-body {
  font-size: var(--text-sm);
  color: var(--ink-700);
}
/* Tentativa "zerada": foi feita ANTES do pagamento da parcela —
   fica no histórico mas visualmente desbotada */
.timeline-item.is-zerada {
  opacity: 0.55;
  border-style: dashed;
  background: var(--bg);
}
.timeline-item.is-zerada::after {
  content: "zerada pelo pagamento";
  display: block;
  font-size: var(--text-xs);
  color: var(--ink-500);
  font-style: italic;
  margin-top: 6px;
}

/* ============================================================
   Historico (drawer aba) — filtros + agrupamento por dia + diffs
   ============================================================ */
.historico-filtros {
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-3);
}
.historico-filtros-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.historico-filtro-label {
  font-size: var(--text-xs);
  color: var(--ink-500);
}
.historico-grupo { margin-bottom: var(--space-4); }
.historico-grupo-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--space-1) 0 var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}
.historico-grupo-dia {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-900);
}
.historico-grupo-itens { display: flex; flex-direction: column; gap: var(--space-2); }
.historico-item {
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.historico-item-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.historico-item-time { font-size: var(--text-xs); }
.historico-item-actor { font-size: var(--text-xs); margin-left: auto; }
.historico-item-obs {
  margin: var(--space-2) 0 0 0;
  font-size: var(--text-sm);
  color: var(--ink-700);
  white-space: pre-wrap;
}
.historico-diffs {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.historico-diff {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  padding: 4px var(--space-2);
  background: var(--bg);
  border-radius: var(--radius);
}
.historico-diff-label {
  color: var(--ink-500);
  min-width: 80px;
}
.historico-diff-before {
  color: var(--ink-500);
  text-decoration: line-through;
}
.historico-diff-arrow { color: var(--ink-500); }
.historico-diff-after { color: var(--ink-900); }

.input-sm, .select-sm {
  height: 32px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Fase 1 — Quick wins TMB-style
   ============================================================ */

/* QW1: "Atualizado há Xmin" — chip leve à direita do título da página.
   Dot verde pulsa sutil se loading; estático se sincronizado. */
.dashboard-updated {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  font-size: var(--text-xs);
  color: var(--ink-500);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  cursor: help;
  user-select: none;
}
.dashboard-updated-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}
.dashboard-updated-label {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* QW3: sumário top-of-fold (Sem vencimento / Total em aberto / Pagos acumulado).
   3 colunas iguais, valor grande tabular, label pequeno acima. */
.sumario-topo {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
}
.sumario-topo-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 0 var(--space-2);
  border-right: 1px solid var(--border);
}
.sumario-topo-item:last-child {
  border-right: none;
}
.sumario-topo-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-500);
  text-transform: none;
  letter-spacing: 0;
  /* "Capitalize sem letter-spacing" — padrão Jean */
}
.sumario-topo-valor {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  .sumario-topo { grid-template-columns: 1fr; padding: var(--space-3); }
  .sumario-topo-item { border-right: none; border-bottom: 1px solid var(--border); padding: var(--space-2) 0; }
  .sumario-topo-item:last-child { border-bottom: none; }
}

/* QW2: linha de cards de aging (0-30 / 31-60 / 61-90 / 90+).
   Reusa .bucket-card que já existe; aging-tone-* dá nuance de cor sem
   sobrescrever os tokens já validados pelos cards de categoria. */
.aging-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
@media (max-width: 900px) { .aging-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .aging-row { grid-template-columns: 1fr; } }

/* Nuance por tom (borda esquerda colorida + acento no value).
   Padrão Jean: discreto, verde primário é só pra "OK"; vermelho intensifica com idade. */
.aging-bucket.aging-tone-warn-soft { border-left: 3px solid #fde68a; }
.aging-bucket.aging-tone-warn      { border-left: 3px solid #d97706; }
.aging-bucket.aging-tone-bad-soft  { border-left: 3px solid #fecaca; }
.aging-bucket.aging-tone-bad       { border-left: 3px solid #b91c1c; }
.aging-bucket.aging-tone-bad .bucket-card-value      { color: #b91c1c; }
.aging-bucket.aging-tone-bad-soft .bucket-card-value { color: #b91c1c; }

/* QW4: sub-label "Excluídos pelo time" no card Inadimplentes — 2ª linha sutil. */
.card-categoria-sub-extra {
  font-size: 11px;
  color: var(--ink-500);
  margin-top: 2px;
  line-height: 1.3;
}

/* ============================================================
   Bucket 2 PR2 — "Para fazer hoje" + cards promessa
   ============================================================
   2 cards priorizados acima dos 3 originais (atrasadas/vencem hoje/aguardando
   entrada). Padrão Jean: borda esquerda colorida + header denso + lista
   compacta clicável. Itens abrem drawer do aluno (mesmo padrão da tabela).
*/
.para-fazer-section {
  margin-bottom: var(--space-5);
}
.para-fazer-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.para-fazer-grid {
  display: grid;
  /* Auto-fit garante 1/2/3 colunas conforme largura, sem deixar última linha
     visualmente "torta" quando há 5 cards (2+2+1 vira 3+2 em telas largas). */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3);
}
@media (max-width: 900px) { .para-fazer-grid { grid-template-columns: 1fr; } }

.card-promessa {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 120px;
}
/* Promessas pra hoje — tom verde-amarelo (atenção positiva, "lembrete do
   compromisso firmado"). Borda esquerda âmbar 4px sinaliza a ação devida hoje. */
.card-promessa-hoje {
  border-left: 4px solid var(--amber-600);
  background: linear-gradient(180deg, var(--amber-50) 0%, var(--surface) 60%);
}
/* Promessas quebradas — tom vermelho-escuro (urgência máxima). Borda 4px
   bordô. Já passou da data prometida, prioridade absoluta do operador. */
.card-promessa-quebrada {
  border-left: 4px solid var(--red-700);
  background: linear-gradient(180deg, var(--red-50) 0%, var(--surface) 60%);
}

.card-promessa-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-900);
}
.card-promessa-head-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex: 0 0 18px;
}
.card-promessa-hoje .card-promessa-head-icon {
  background: var(--amber-50);
  color: var(--amber-600);
}
.card-promessa-quebrada .card-promessa-head-icon {
  background: var(--red-50);
  color: var(--red-700);
}
.card-promessa-count {
  font-variant-numeric: tabular-nums;
  color: var(--ink-500);
  font-weight: 500;
  font-size: var(--text-xs);
}
.card-promessa-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
}
.card-promessa-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--t-fast), border-color var(--t-fast);
  font: inherit;
  color: inherit;
}
.card-promessa-item:hover {
  background: var(--row-hover);
  border-color: var(--border);
}
.card-promessa-item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.card-promessa-item-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.card-promessa-item-nome {
  font-weight: 600;
  color: var(--ink-900);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-promessa-item-sub {
  font-size: var(--text-xs);
  color: var(--ink-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-promessa-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex: 0 0 auto;
}
.card-promessa-item-valor {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-900);
  font-size: var(--text-sm);
}
.card-promessa-item-meta {
  font-size: 10px;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}
.card-promessa-quebrada .card-promessa-item-meta {
  color: var(--red-700);
  font-weight: 600;
}

/* ============================================================
   Bucket 2 PR2 (complemento 2026-05-25) — 3 cards "Para fazer hoje"
   ============================================================
   Endpoint /api/dashboard/para-fazer-hoje sempre devolveu esses 3 blocos
   (atrasadas sem tentativa, vencem hoje, aguardando entrada), mas o template
   nunca os renderizou. Gap pré-existente fechado aqui. Cada modifier reusa
   a base .card-promessa e só troca borda + tom do header-icon, mantendo
   coerência visual do padrão Jean.
*/

/* Atrasadas sem tentativa — vermelho médio (urgente, mas menos crítico que
   `card-promessa-quebrada` que usa red-700 — operador AINDA tem chance de
   evitar o "quebrou"). Reusa --red-600/--red-50 já no design system. */
.card-atrasadas-sem-tentativa {
  border-left: 4px solid var(--red-600);
  background: linear-gradient(180deg, var(--red-50) 0%, var(--surface) 60%);
}
.card-atrasadas-sem-tentativa .card-promessa-head-icon {
  background: var(--red-50);
  color: var(--red-600);
}
.card-atrasadas-sem-tentativa .card-promessa-item-meta {
  color: var(--red-600);
  font-weight: 600;
}

/* Vencem hoje — azul (próxima ação, neutro-positivo). Reusa --blue-600 e
   --blue-50, tokens já em uso em pills/toasts info. Distingue claramente
   dos cards vermelhos (urgência passada) e do amarelo (promessa firmada). */
.card-vencem-hoje {
  border-left: 4px solid var(--blue-600);
  background: linear-gradient(180deg, var(--blue-50) 0%, var(--surface) 60%);
}
.card-vencem-hoje .card-promessa-head-icon {
  background: var(--blue-50);
  color: var(--blue-600);
}
.card-vencem-hoje .card-promessa-item-meta {
  color: var(--blue-700);
  font-weight: 500;
}

/* Aguardando entrada atrasada — cinza-escuro neutro. Não há urgência
   cromática, é um lembrete de "destravar venda parada". Sem token color
   próprio (evita inflar a paleta), usa --ink-500 (cinza médio) com fundo
   levemente cinza pra diferenciar do card branco padrão. */
.card-aguardando-entrada {
  border-left: 4px solid var(--ink-500);
  background: linear-gradient(180deg, color-mix(in srgb, var(--ink-500) 8%, var(--surface)) 0%, var(--surface) 60%);
}
.card-aguardando-entrada .card-promessa-head-icon {
  background: color-mix(in srgb, var(--ink-500) 12%, var(--surface));
  color: var(--ink-700);
}
.card-aguardando-entrada .card-promessa-item-meta {
  color: var(--ink-700);
  font-weight: 500;
}

/* ============================================================
   Bucket 2 PR2 — dot bordô "Promessa quebrada"
   ============================================================
   Decisão 2026-05-25 noite: pill secundário com texto ficaria lado a
   lado com o primário (mesma poluição visual que Gustavo já vetou hoje
   cedo pro `tambem_inadimplente`). Trocado por dot dentro do pill
   primário — mesmo padrão do `pill-warn-dot`, mas em `--red-700`
   (mais bordô) pra distinguir de `tambem_inadimplente` (red-600).
*/
.pill-warn-dot-promessa {
  background: var(--red-700);
}

/* ============================================================
   Bucket 2 PR3 — Pagamento parcial: barra de progresso + saldo + helper
   ============================================================
   Linguagem visual amber (mesma família de vencendo/promessa/parcial).
   - .progress-bar: container fino + cinza claro
   - .progress-bar-fill: preenchido proporcional, amber-500ish
   - .saldo-restante-card: card discreto "Saldo a receber"
   - .pagar-helper / .pagar-helper-ok / .pagar-helper-warn: inline abaixo do input
*/
.progress-bar {
  position: relative;
  width: 100%;
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar-fill {
  display: block;
  height: 100%;
  background: var(--amber-600);
  border-radius: var(--radius-pill);
  transition: width var(--t-fast);
}
.progress-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--ink-500);
}
.progress-bar-label .tabular { color: var(--ink-700); }

.saldo-restante-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--amber-50);
  border-left: 3px solid var(--amber-600);
  border-radius: var(--radius);
  font-size: var(--text-sm);
}
.saldo-restante-card .saldo-label {
  color: var(--amber-600);
  font-weight: 600;
}
.saldo-restante-card .saldo-valor {
  color: var(--ink-900);
  font-weight: 700;
  margin-left: auto;
}

.pagar-helper {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--ink-500);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.pagar-helper-ok   { color: var(--green-700); }
.pagar-helper-warn { color: var(--amber-600); }
.pagar-helper-error { color: var(--red-600); }

/* ============================================================
   Utility classes finais
   ============================================================ */
.hidden { display: none !important; }
[x-cloak] { display: none !important; }
.flex-row { display: flex; flex-direction: row; align-items: center; gap: var(--space-3); }
.flex-col { display: flex; flex-direction: column; gap: var(--space-3); }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.between { display: flex; align-items: center; justify-content: space-between; }

/* ============================================================
   UX Copy 2026-05-25 — classes novas (cache-bust ?v=20260525-uxcopy)
   ============================================================ */

/* sr-only: texto acessível apenas pra leitores de tela. Usado nos tooltips
   `aria-describedby` dos cards de sumário/Resultado de caixa. Hover via
   `title` continua funcionando pra usuários sighted. */
.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;
}

/* Contador grande nos cards "Para fazer hoje". Acentua o número dentro
   do header de cada card — operador de callcenter olha número primeiro.
   Parte 3.3 do spec UX. Token --text-lg (18px). Mantém os parênteses no
   .card-promessa-count (11px ink-500) sutis. */
.card-promessa-count-big {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 0 1px;
}

/* Resultado de caixa (mês) — cor condicional do valor.
   Parte 5 do spec UX: pode ficar negativo quando estornos > pagamentos.
   Verde quando entra caixa (> 0), vermelho quando sai (< 0), default cinza
   ink-900 quando zero ou null. */
.card-metrica-valor.caixa-mes-pos { color: var(--green-700); }
.card-metrica-valor.caixa-mes-neg { color: var(--red-600); }

/* ============================================================
   Fase 2 — /usuarios
   ============================================================ */

/* Pill "Admin" — verde Jean discreto (mesma família do primary, sem brigar
   com pill-pago que ja usa verde pra pagamentos). Tom mais claro pro fundo. */
.pill-role-admin {
  color: var(--green-700);
  background: var(--green-50);
  border: 1px solid transparent;
}

/* Pill "Deve trocar" — atencao suave, mesma familia do amber (vencendo, promessa).
   Sinaliza "esse user ainda nao trocou a senha temp" sem alarmar.
   border 1px transparent: simetria de altura com .pill-role-admin (vizinha
   na mesma linha da tabela quando user tem must_change_password). */
.pill-must-change {
  color: var(--amber-600);
  background: var(--amber-50);
  border: 1px solid transparent;
}

/* Pill "Super Admin" — papel privilegiado, so visivel pra super_admin.
   Tom roxo da mesma familia do .pill-renegociado, distinto do verde Admin. */
.pill-role-super {
  color: #6d28d9;
  background: #ede9fe;
  border: 1px solid transparent;
}

/* Pill "Operador" — neutro, mesma família do .pill-papel (borda fina). */
.pill-role-operador {
  color: var(--ink-700);
  background: transparent;
  border: 1px solid var(--border);
}

/* ============================================================
   Avatar determinístico (cor via style inline do helper avatar.js)
   Usado em /usuarios (lista) e /melhorias (autor + comentários).
   ------------------------------------------------------------
   .avatar      base — círculo, iniciais brancas, cor via style.
   .avatar-xs   20px (comentários, linha densa)
   .avatar-sm   28px
   .avatar-md   32px (linha de usuário, padrão)
   ============================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary); /* fallback se style inline ausente */
  color: #fff;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
  overflow: hidden;
}
.avatar-xs { width: 20px; height: 20px; flex-basis: 20px; font-size: 9px; }
.avatar-sm { width: 28px; height: 28px; flex-basis: 28px; font-size: 11px; }
.avatar-md { width: 32px; height: 32px; flex-basis: 32px; font-size: 12px; }

/* ============================================================
   Lista de usuários (estilo Tarefas — substitui a tabela densa)
   Container .card + <ul> com linhas .user-row separadas por divisória.
   SEM overflow-x: menu ⋯ abre alinhado à direita, pra dentro.
   ============================================================ */
.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.user-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-height: 56px;
}
.user-row + .user-row { border-top: 1px solid var(--border); }
.user-row:hover { background: var(--row-hover); }

.user-row-main { flex: 1; min-width: 0; }
.user-row-line1 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.user-row-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.user-row-email {
  font-size: var(--text-xs);
  color: var(--ink-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

/* Mini-badge de papel (uppercase, com ícone) na linha 1 */
.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  height: 18px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
}
.user-role-badge svg { width: 11px; height: 11px; }
.user-role-badge.is-super    { color: #6d28d9; background: #ede9fe; }
.user-role-badge.is-admin    { color: var(--green-700); background: var(--green-50); }
.user-role-badge.is-operador { color: var(--ink-700); background: #f3f4f6; }

/* Marcadores inline (inativo / deve trocar senha) — só ícone com title */
.user-row-flag {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.user-row-flag svg { width: 14px; height: 14px; }
.user-row-flag.is-inactive { color: var(--ink-500); }
.user-row-flag.is-mustchange { color: var(--amber-600); }

/* Ações à direita: botões ghost inline + kebab destrutivo */
.user-row-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 0 0 auto;
}
.btn-ghost {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: var(--control-h-sm);
  padding: 0 var(--space-3);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-700);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.btn-ghost svg { width: 14px; height: 14px; opacity: 0.75; }
.btn-ghost:hover { background: var(--row-hover); color: var(--ink-900); }
.btn-ghost:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Esconde o e-mail e os botões-texto no mobile? Mantemos e-mail; os botões
   ghost viram só ícone via .btn-ghost-label oculto pra não estourar a linha. */
@media (max-width: 560px) {
  .btn-ghost { padding: 0 var(--space-2); }
  .btn-ghost .btn-ghost-label { display: none; }
}

/* ============================================================
   Fase 1 — /configuracao (Auditoria + Backups)
   Tabs estilo "segmented" (botoes lado a lado, ativo = fundo verde marca).
   ============================================================ */
.config-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
.config-tab {
  appearance: none;
  background: none;
  border: none;
  padding: 0 var(--space-4);
  height: var(--control-h-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-500);
  cursor: pointer;
  border-radius: calc(var(--radius) - 2px);
  transition: background var(--t-fast), color var(--t-fast);
}
.config-tab:hover { color: var(--ink-900); }
.config-tab:focus-visible { box-shadow: var(--focus-ring-neutral); outline: none; }
.config-tab.is-active {
  background: var(--primary);
  color: var(--surface);
  font-weight: 600;
}

/* Payload de auditoria expandido inline — bloco monospace pre-formatado. */
.audit-payload {
  margin: var(--space-2) 0 0;
  padding: var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--ink-700);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}
.audit-payload-toggle {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}
.audit-payload-toggle:hover { color: var(--green-700); }
.audit-payload-toggle:focus-visible { box-shadow: var(--focus-ring-neutral); outline: none; border-radius: 2px; }

