/* ============================================================================
   components.css — botões, inputs, cards, badges, tabelas, modais, toasts,
   skeletons, avatar, abas, autocomplete. Tudo via tokens semânticos.
   ============================================================================ */

.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; }

/* ------------------------------------------------------------- botões ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--fs-base); font-weight: var(--fw-400);
  cursor: pointer; white-space: nowrap;
  text-decoration: none;
  transition: opacity var(--transition), background var(--transition), border-color var(--transition);
}
.btn:hover, .btn:focus { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary   { background: var(--btn-primary-bg);   color: var(--btn-primary-text); }
.btn--primary:hover:not(:disabled)   { opacity: 0.88; }
.btn--secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn--secondary:hover:not(:disabled) { opacity: 0.85; }
.btn--ghost     { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover:not(:disabled)     { background: var(--surface-2); }
/* outline: igual ghost mas com borda mais forte (stroke fino porém visível) —
   usado nos botões "Selecionar". */
.btn--outline   { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn--outline:hover:not(:disabled)   { background: var(--surface-2); }
.btn--danger    { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--danger:hover:not(:disabled)    { background: var(--danger-soft); }
.btn--sm { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }
.btn--icon { padding: var(--sp-2); width: 40px; height: 40px; }
.btn--block { width: 100%; }
/* CTA em destaque (banner/hero): pill. Botões do dia-a-dia continuam retângulo. */
.btn--pill { border-radius: var(--radius-pill); padding: var(--sp-3) var(--sp-5); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
/* rótulo de botão que colapsa para só-ícone no mobile (ver bloco mobile ≤900px) */
.btn--icon svg { width: 20px; height: 20px; }
/* lápis/lixeira das linhas de tabela (Clientes/Serviços/Estoque) — únicos .btn--icon.btn--sm do projeto */
.btn--icon.btn--sm { width: 32px; height: 32px; padding: var(--sp-1); }
.btn--icon.btn--sm svg { width: 16px; height: 16px; }

.btn-google {
  width: 100%; gap: var(--sp-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
  padding: var(--sp-4);
}
.btn-google:hover:not(:disabled) { background: var(--surface-2); }
.btn-google svg { width: 18px; height: 18px; }

/* --------------------------------------------------------- formulários ---- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.field label { font-size: var(--fs-sm); color: var(--text-muted); }
.field .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit; font-size: var(--fs-base); font-weight: var(--fw-300);
  transition: border-color var(--transition);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-strong);
}
.textarea { resize: vertical; min-height: 80px; }
.field-row { display: flex; gap: var(--sp-3); }
/* min-width:0 evita que o min-content do <input> (que os browsers calculam
   com uma largura mínima própria) force o item flex a estourar o field-row —
   mesma causa-raiz do overflow visto no formulário de Clientes no mobile. */
.field-row > .field { flex: 1; min-width: 0; }
.hint { font-size: var(--fs-xs); color: var(--text-faint); }

/* toggle / switch ----------------------------------------------------------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border-strong); border-radius: var(--radius-pill);
  transition: background var(--transition);
}
.switch .track::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: var(--switch-thumb); border-radius: 50%; transition: transform var(--transition);
}
.switch input:checked + .track { background: var(--color-black); }
.switch input:checked + .track::before { transform: translateX(20px); }
/* o input é invisível (opacity:0) — o anel de foco vai no trilho */
.switch input:focus-visible + .track { outline: var(--focus-ring); outline-offset: 2px; }

/* segmented — padrão único de abas/toggle do app (estilo iOS): trilho neutro,
   indicador em pill deslocado pela classe .active. Rola na horizontal quando não
   cabe (ex.: 5 abas do Fluxo de Caixa no mobile) sem estourar a largura da tela.
   ponytail: pill via troca de .active (não transform literal); mesmo resultado
   visual, sem precisar medir posição/contagem em JS. */
.segmented {
  display: inline-flex; align-self: flex-start; max-width: 100%; gap: 2px; padding: 3px;
  /* trilho um tom mais escuro que o fundo da página (--bg = gray-100): assim o
     container do toggle é sempre visível — na página e no modal branco — e dois
     toggles lado a lado não se fundem num único bloco. */
  background: var(--segment-track); border-radius: var(--radius-pill);
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  border: none; background: transparent; color: var(--text-muted);
  padding: var(--sp-2) var(--sp-4); cursor: pointer; font-size: var(--fs-sm);
  border-radius: var(--radius-pill); white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* color picker -------------------------------------------------------------- */
.swatches { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.swatch.selected { border-color: var(--text); }

/* --------------------------------------------------------------- cards ---- */
.card {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  padding: var(--sp-5);
}
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat { background: var(--surface); box-shadow: var(--shadow-sm); border-radius: var(--radius); padding: var(--sp-4) var(--sp-5); }
.stat .label { font-size: var(--fs-sm); color: var(--text-muted); }
.stat .value { font-size: var(--fs-xl); font-weight: var(--fw-400); margin-top: var(--sp-1); }
.stat .value.pos { color: var(--success); }
.stat .value.neg { color: var(--danger); }

/* -------------------------------------------------------------- badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--sp-2); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-400);
  background: var(--surface-2); color: var(--text-muted);
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger); }
/* text-faint aqui reprovava contraste AA (4.12:1) sobre --surface-2; text-muted passa (5.7:1) */
.badge--muted   { background: var(--surface-2);    color: var(--text-muted); }

/* -------------------------------------------------------------- tabelas --- */
/* overflow-x: tabela larga rola pro lado em vez de esmagar as colunas */
.table-wrap { background: var(--surface); box-shadow: var(--shadow-sm); border-radius: var(--radius); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data th {
  text-align: left; font-weight: var(--fw-400); color: var(--text-muted);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: default;
}
.data th.sortable { cursor: pointer; }
.data td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.data tr:last-child td { border-bottom: none; }
.data tbody tr.clickable { cursor: pointer; }
.data tbody tr.clickable:hover { background: var(--surface-2); }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-detail td { background: var(--surface-2); }

/* seleção em massa (Histórico/Caixa): coluna de checkbox + barra de ação */
.data .chk { width: 36px; }
/* accent-color nativo é inconsistente entre navegadores/webviews — checkbox
   custom garante a cor de destaque em qualquer ambiente. */
.data .chk input {
  appearance: none; -webkit-appearance: none;
  display: grid; place-content: center;
  width: 18px; height: 18px; margin: 0;
  border: 1.5px solid var(--border-strong); border-radius: 4px;
  background: var(--surface); cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.data .chk input:checked {
  background: var(--color-mauve-700); border-color: var(--color-mauve-700);
}
.data .chk input:checked::after {
  content: ''; width: 4px; height: 8px;
  border: solid var(--color-white); border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.bulkbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm); color: var(--text-muted);
}

/* -------------------------------------------------------------- avatar ---- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: var(--fs-sm); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-lg); }

/* abas: unificadas em .segmented (não há mais componente .tabs). */

/* ------------------------------------------------------- autocomplete ----- */
.autocomplete { position: relative; }
.autocomplete__list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); overflow: hidden;
  max-height: 280px; overflow-y: auto;
}
.autocomplete__item { padding: var(--sp-3); cursor: pointer; }
.autocomplete__item:hover, .autocomplete__item.active { background: var(--surface-2); }
.autocomplete__item .sub { font-size: var(--fs-xs); color: var(--text-faint); }

/* -------------------------------------------------------------- modais ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay-bg); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: var(--sp-5);
  animation: fade var(--dur-fast) var(--ease-out);
}
/* card em flex-coluna com overflow:hidden: cabeçalho/rodapé ficam fixos e só o
   .modal__body rola — a barra de rolagem fica no miolo, longe dos cantos
   arredondados (antes o card inteiro rolava e a barra tocava o raio). */
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 520px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideUp var(--dur-base) var(--ease-out);
}
.modal--wide { max-width: 720px; }
.modal--detail { max-width: 560px; } /* +40px sobre o modal padrão (openDetail) */
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5); border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: var(--surface);
}
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-400); }
.modal__close {
  background: none; border: none; font-size: var(--fs-xl); cursor: pointer;
  color: var(--text-muted); line-height: 1;
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: var(--radius-sm); margin: calc(-1 * var(--sp-2));
}
.modal__body { padding: var(--sp-5); overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal__foot {
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-5); border-top: 1px solid var(--border);
  flex-shrink: 0; background: var(--surface);
}

/* detalhe do agendamento (openDetail em agenda.js) --------------------------- */
.detail-chip {
  display: inline-flex; align-items: center;
  padding: 3px var(--sp-3); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-500);
  margin-bottom: var(--sp-3);
}
.detail-name { font-size: 18px; font-weight: var(--fw-500); margin: 0; }
.detail-note {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: var(--sp-3); font-size: var(--fs-sm); color: var(--text-muted);
  white-space: pre-wrap; margin-top: var(--sp-3);
}
.detail-fin { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); }
.detail-row { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs-sm); }
.detail-row .label { color: var(--text-muted); }
.detail-row--total {
  border-top: 1px solid var(--border); margin-top: var(--sp-2);
  padding-top: var(--sp-3); font-size: var(--fs-base);
}
.detail-row--total .value { font-weight: var(--fw-600); }
/* selo de estado fechado — não é botão, não reage a hover/click */
.detail-done {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  width: 100%; padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2); color: var(--text-faint);
  border-radius: var(--radius-sm); font-size: var(--fs-base);
}
.detail-foot { display: flex; flex-direction: column; gap: var(--sp-3); width: 100%; }
.detail-foot .row2 { display: flex; gap: var(--sp-3); }
.detail-foot .row2 > * { flex: 1; }
.detail-foot .btn--danger.btn--sm { align-self: center; border-color: transparent; }
/* drawer lateral (perfil da cliente) — mesma receita do modal: o container não
   rola; quem rola é a região .drawer__body montada pelo módulo. */
.drawer { position: fixed; top: 0; right: 0; height: 100dvh; width: 460px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--border); z-index: 100;
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideLeft var(--dur-base) var(--ease-out); }
/* variante central (perfil de cliente, item de estoque): mesmo componente,
   mas centralizado pelo grid do .modal-overlay em vez de fixo à direita */
.drawer--center {
  position: static; top: auto; right: auto; height: auto; max-height: 88vh;
  width: 640px; max-width: 92vw; border-left: none; border-radius: var(--radius-lg);
  animation: slideUp var(--dur-base) var(--ease-out);
}
/* conteúdo do drawer: bloco fixo no topo (dados/botões/abas) + corpo rolável.
   .drawer__wrap é o elemento que o módulo passa pro openDrawer(). */
.drawer__wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.drawer__head { flex-shrink: 0; padding: var(--sp-5) var(--sp-5) 0; }
.drawer__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.closing .drawer.drawer--center { animation: slideDownOut var(--dur-exit) var(--ease-out) forwards; }
/* variante sheet (menu "Mais" da tabbar): gruda no rodapé, largura total,
   cantos superiores arredondados; safe-area p/ iPhone. */
.drawer--sheet {
  top: auto; bottom: 0; left: 0; right: 0;
  width: 100%; max-width: 100%; height: auto; max-height: 80dvh;
  border-left: none; border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: slideUp var(--dur-base) var(--ease-out);
}
.closing .drawer.drawer--sheet { animation: slideDownOut var(--dur-exit) var(--ease-out) forwards; }
.sheet-nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.sheet-divider { height: 1px; background: var(--border); margin: var(--sp-2) 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } }
@keyframes slideLeft { from { transform: translateX(40px); opacity: 0; } }

/* saída: keyframes próprios só com `to` — partem do estado computado atual
   (interruptível se a entrada ainda estiver rodando) e mantêm o ease-out
   (reverse inverteria a curva → ease-in). JS remove o nó no animationend. */
@keyframes fadeOut { to { opacity: 0; } }
@keyframes slideDownOut { to { opacity: 0; transform: translateY(12px); } }
@keyframes slideRightOut { to { opacity: 0; transform: translateX(40px); } }
.modal-overlay.closing { animation: fadeOut var(--dur-exit) var(--ease-out) forwards; }
.closing .modal { animation: slideDownOut var(--dur-exit) var(--ease-out) forwards; }
.closing .drawer { animation: slideRightOut var(--dur-exit) var(--ease-out) forwards; }
.toast.closing { animation: slideDownOut var(--dur-exit) var(--ease-out) forwards; }

/* -------------------------------------------------------------- toasts ---- */
.toasts { position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 200; display: flex; flex-direction: column; gap: var(--sp-2); }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow); min-width: 240px; max-width: 340px;
  animation: slideUp var(--dur-base) var(--ease-out); font-size: var(--fs-sm);
}
.toast--success { border-left-color: var(--success); }
.toast--warning { border-left-color: var(--warning); }
.toast--error   { border-left-color: var(--danger); }

/* ----------------------------------------------------------- skeletons ---- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite linear;
  border-radius: var(--radius-sm); height: 14px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* --------------------------------------------------------- estados vazios - */
.empty { text-align: center; padding: var(--sp-8) var(--sp-5); color: var(--text-faint); }
.empty .icon { font-size: 2rem; opacity: 0.6; }
.empty .icon svg { width: 40px; height: 40px; }
.empty p { margin: var(--sp-3) 0 var(--sp-4); }

/* utilitários --------------------------------------------------------------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.flex { display: flex; gap: var(--sp-3); align-items: center; }
/* linha de filtros (Fluxo de Caixa, Histórico…): grid responsivo — quando não
   cabe numa linha, quebra em colunas alinhadas (nada de campo "solto" à
   esquerda, que era o defeito do flex-wrap cru). flex-basis alta faz o bloco
   descer inteiro pra própria linha quando divide o toolbar com o segmented. */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-2);
  align-items: center;
  flex: 1 1 460px;
  min-width: 0;
  margin-left: auto;
}
.filters > .input, .filters > .select { max-width: none; width: 100%; }
/* toggle de período (view Retornos) é o único filho da grid: sem isto a célula
   1fr estica o .segmented na largura toda ("sem hug"). justify-self encolhe ao conteúdo. */
.filters > .segmented { justify-self: start; }
@media (max-width: 640px) { .filters { grid-template-columns: 1fr; } }
.mt-4 { margin-top: var(--sp-4); }
.search-input {
  max-width: 280px;
  border-radius: var(--radius-pill);          /* cantos 100% arredondados */
  padding-left: 38px;                          /* espaço p/ a lupa */
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27%23767676%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Ccircle%20cx%3D%2711%27%20cy%3D%2711%27%20r%3D%277%27%2F%3E%3Cpath%20d%3D%27M21%2021l-4.35-4.35%27%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: left var(--sp-3) center;
  background-size: 16px 16px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* --------------------------------------------------------------- home ----- */
/* 3ª coluna vira grid interno da Home; some abaixo de 1200px (spec 1) */
.home-grid { display: grid; grid-template-columns: 1fr 400px; gap: var(--sp-5); align-items: start; }
.home-main { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-5); }
.home-aside { display: flex; flex-direction: column; gap: var(--sp-5); }
@media (max-width: 1200px) { .home-grid { grid-template-columns: 1fr; } }

.hero {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  border-radius: var(--radius-xl); padding: var(--sp-6);
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-5);
}
.hero__label { text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; color: var(--text-faint); }
.hero__title { font-size: var(--fs-2xl); font-weight: var(--fw-700); margin-top: var(--sp-2); color: var(--text); }
.hero__title svg { width: 24px; height: 24px; vertical-align: -3px; }
.hero__sub { color: var(--text-muted); margin-top: var(--sp-2); }
/* três ações do hero numa linha; quebram para a próxima linha em telas
   estreitas (wrap) em vez de estourar o card. */
.hero__actions {
  display: flex; gap: var(--sp-2); flex-wrap: wrap;
}
.hero__actions .btn { flex: 0 0 auto; }

/* mini stat-cards da Home (ícone em círculo pastel) */
.mini-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
@media (max-width: 700px) { .mini-cards { grid-template-columns: 1fr; } }
.mini { background: var(--surface); border-radius: 16px; padding: var(--sp-4); box-shadow: var(--shadow-sm); }
/* cor do ícone fixa (não herda --text) — o fundo (tint) continua claro nos
   dois temas, então o ícone precisa de um tom escuro fixo pra sempre contrastar */
.mini__icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; margin-bottom: var(--sp-3); color: var(--color-mauve-700); }
.mini__icon svg { width: 20px; height: 20px; }
.mini__label { font-size: var(--fs-xs); color: var(--text-muted); }
.mini__value { font-size: var(--fs-lg); font-weight: var(--fw-600); margin-top: 2px; }

/* card genérico grande da Home / painel direito */
.panel { background: var(--surface); border-radius: var(--radius-xl); padding: var(--sp-5); box-shadow: var(--shadow-sm); }
.panel__title { display: flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-600); margin-bottom: var(--sp-4); }
.panel__title svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-muted); }
.panel__row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); }
.panel__row:first-of-type { border-top: none; }
.panel__row .grow { flex: 1; min-width: 0; }
.panel__row .grow .sub { font-size: var(--fs-xs); color: var(--text-faint); }

/* pills de categoria (pastéis) */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: var(--fw-500); }
.pill svg { width: 14px; height: 14px; }
.pill--blue  { background: var(--pill-blue-bg);  color: var(--pill-blue-text); }
.pill--tan   { background: var(--pill-tan-bg);   color: var(--pill-tan-text); }
.pill--peach { background: var(--pill-peach-bg); color: var(--pill-peach-text); }

/* barras do comparativo (financeiro) */
.bar { position: relative; display: flex; align-items: center; gap: var(--sp-2); height: 22px; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; }
.bar__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: var(--radius-sm); opacity: 0.35; }
.bar__fill.pos { background: var(--color-mauve-500); }
.bar__fill.neg { background: var(--danger); }
.bar__val { position: relative; margin-left: auto; padding: 0 var(--sp-2); font-size: var(--fs-xs); }

/* Comparativo: duas tabelas lado a lado (metade da tela cada) */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); align-items: start; }
.compare-col { min-width: 0; }
.compare-col .panel__title { margin-bottom: var(--sp-3); }
@media (max-width: 900px) { .compare-grid { grid-template-columns: 1fr; } }

/* seletor menor dentro de Gráficos (não estica a largura toda) */
.segmented--sm { display: inline-flex; width: auto; }

/* pizza (donut) Entradas × Saídas */
.pie-wrap { display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; }
.pie { width: 180px; height: 180px; flex: 0 0 auto; }
.pie-legend { display: flex; flex-direction: column; gap: var(--sp-3); }
.pie-legend .dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: var(--sp-2); vertical-align: -1px; }
.pie-legend .dot.pos { background: var(--color-mauve-500); opacity: 0.6; }
.pie-legend .dot.neg { background: var(--danger); opacity: 0.5; }

/* link de WhatsApp (listagem de clientes / agenda) */
.wa-link { display: inline-flex; align-items: center; gap: 4px; color: var(--whatsapp); text-decoration: none; }
.wa-link:hover { text-decoration: underline; }
.wa-link svg { width: 15px; height: 15px; }

/* thumbnail de item (estoque) */
.thumb { width: 80px; height: 80px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-2); flex-shrink: 0; }

/* -------------------------------------------------------------- agenda ----- */
.mb-3 { margin-bottom: var(--sp-3); }
.ag-nav { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

.ag-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0 var(--sp-2) var(--sp-2); border-top: 1px solid var(--border); border-left: 3px solid transparent; }
.ag-row:first-of-type { border-top: 0; }
.ag-time { font-variant-numeric: tabular-nums; color: var(--text-muted); min-width: 64px; }
.ag-summary { flex: 1; }

.ag-scroll { overflow-x: auto; }
.ag-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
/* 7 colunas não cabem em telas estreitas → scroll horizontal contido no .ag-scroll */
@media (max-width: 600px) { .ag-grid { min-width: 640px; } }
.ag-head { background: var(--surface-2); text-align: center; padding: var(--sp-2); font-size: 12px; color: var(--text-muted); }
.ag-cell { background: var(--surface); min-height: 96px; padding: var(--sp-2); cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.ag-cell.is-muted { background: var(--surface-2); color: var(--text-muted); }
.ag-cell.is-today .ag-cell__n { background: var(--accent); color: var(--accent-text); border-radius: var(--radius-pill); padding: 0 6px; }
.ag-cell__n { font-size: 12px; align-self: flex-start; }
.ag-chip { font-size: 11px; background: var(--accent); color: var(--accent-text); border-radius: var(--radius-sm); padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ag-more { font-size: 11px; color: var(--text-muted); }

/* ============================================== mobile (Rodada 7) ========== */
/* ≤900px — modo app: FAB, rótulos de botão colapsam, toasts sobem da tabbar */
@media (max-width: 900px) {
  .btn-label { display: none; }
  /* a ação primária do módulo (sempre "+ Alguma coisa") vira botão flutuante
     acima da tabbar; o texto some (font-size:0) e o ::before desenha o "+" */
  .header__actions .btn--primary {
    position: fixed; right: var(--sp-4);
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-4));
    width: 56px; height: 56px; border-radius: 50%; padding: 0;
    box-shadow: var(--shadow); z-index: 80;
    font-size: 0;
  }
  .header__actions .btn--primary::before { content: '+'; font-size: 28px; line-height: 1; }
  /* o svg do ícone (já visível no botão) duplicava o "+" ao lado do ::before,
     descentralizando o par no círculo — só o ::before deve renderizar aqui */
  .header__actions .btn--primary svg { display: none; }
  .toasts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-4)); }
}

/* ≤640px — telefone: tabelas em cards, overlays em bottom sheet, forms 1 col */
@media (max-width: 640px) {
  /* tabelas → cards empilhados: thead some; td[data-th] vira "rótulo  valor";
     td sem data-th é o título do card; .chk vai pro canto; .actions alinha
     os botões à direita. Módulos marcam as células com data-th/actions. */
  .data thead { display: none; }
  .data, .data tbody, .data td { display: block; width: 100%; }
  /* tr em flex-coluna: a célula-título (sem data-th) sobe pro topo do card
     via order:-1, mesmo quando não é a 1ª coluna da tabela desktop */
  .data tr { display: flex; flex-direction: column; position: relative; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
  .data tr:last-child { border-bottom: none; }
  .data td { border: none; padding: 2px 0; }
  .data td.num { text-align: left; }
  .data td[data-th] { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); }
  .data td[data-th]::before { content: attr(data-th); color: var(--text-muted); font-size: var(--fs-xs); flex-shrink: 0; }
  .data td:not([data-th]):not(.chk):not(.actions) { order: -1; font-weight: var(--fw-500); padding-right: 40px; }
  .data td.chk { position: absolute; top: var(--sp-3); right: var(--sp-4); width: auto; }
  .data td.actions { display: flex; justify-content: flex-end; gap: var(--sp-2); padding-top: var(--sp-2); }

  /* modais e drawers viram bottom sheets */
  .modal-overlay { padding: 0; align-items: end; }
  .modal, .drawer--center {
    width: 100%; max-width: 100%; max-height: 94dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .drawer {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; max-width: 100%; height: auto; max-height: 94dvh;
    border-left: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slideUp var(--dur-base) var(--ease-out);
  }
  .closing .drawer { animation: slideDownOut var(--dur-exit) var(--ease-out) forwards; }

  /* formulários: campos empilham em coluna única. !important necessário
     porque vários forms (Clientes/Agenda/Histórico/Estoque) setam flex:N
     inline pra proporção desktop (ex.: Rua flex:3 / Número flex:1) — sem
     isso, o basis:0% do inline sobrevivia ao wrap e espremia os campos
     lado a lado em vez de empilhar, causando o overflow visto no mobile. */
  .field-row { flex-wrap: wrap; }
  .field-row > .field { flex: 1 1 140px !important; }

  /* toolbars: busca em linha própria; navegação da agenda idem */
  .module__toolbar .search-input { max-width: none; flex: 1 1 100%; }
  .ag-nav { margin-left: 0; width: 100%; justify-content: space-between; }

  /* toasts na largura da tela */
  .toasts { left: var(--sp-4); right: var(--sp-4); }
  .toast { max-width: none; min-width: 0; }
}

/* ------------------------------------------------- reduced motion ---------- */
/* respeita a preferência do SO: mata transições/animações (o shimmer do
   skeleton vira estático — continua sinalizando "carregando" pela cor) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ajustes: linha rótulo-à-esquerda / controle-à-direita + divisor sutil entre
   grupos dentro de um mesmo card (usado na seção Google de Configurações). */
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); margin: 0; }
.setting-divider { border-top: 1px solid var(--border); margin: var(--sp-5) 0; }

/* linha do número de WhatsApp: campo travado (legível) + lápis/✓ ao final. */
.wa-row { display: flex; align-items: center; gap: var(--sp-2); }
.wa-row .input { flex: 1; min-width: 0; }
.wa-row .input:disabled { opacity: 1; -webkit-text-fill-color: var(--text); color: var(--text); cursor: default; background: var(--surface-2); }

/* botão-ícone em processamento: gira o ícone e bloqueia clique */
@keyframes spin-icon { to { transform: rotate(360deg); } }
.btn--icon.is-busy { pointer-events: none; opacity: .65; }
.btn--icon.is-busy svg { animation: spin-icon .8s linear infinite; }
/* logo de app do Google ao lado do rótulo (não encolhe) */
.g-logo { display: inline-flex; flex: 0 0 auto; line-height: 0; }
