/* ============================================================================
   APAP · UI — Sistema de design consolidado (fonte única da verdade)
   ----------------------------------------------------------------------------
   Use estas classes em todas as telas do sistema. Tudo aqui é "estilização":
   tokens + componentes + padrões de página. Nada de lógica.
   Fonte: Manrope (400–800). Ícones: lucide (stroke 1.75).
   ========================================================================== */

/* ───────────────────────────── 1. TOKENS ────────────────────────────────── */
:root {
  /* superfícies */
  --bg:            #F4F2EC;   /* fundo da aplicação (bege quente) */
  --surface:       #FFFFFF;   /* cards, inputs, barras */
  --surface-2:     #FAF8F2;   /* zebra, hover sutil, cabeçalho de tabela */
  --surface-sunken:#EFECE3;   /* trilhos, áreas rebaixadas */

  /* bordas */
  --border:        #E6E2D6;   /* borda padrão de card/input */
  --border-strong: #D6D1C0;   /* borda em hover/realce */
  --hairline:      #EEEBE0;   /* divisórias finas */

  /* tinta / texto */
  --ink:           #1A1B1F;   /* texto primário e botão primário */
  --ink-soft:      #34353A;   /* texto secundário forte */
  --muted:         #6B6B70;   /* texto auxiliar */
  --muted-soft:    #9B9A9D;   /* placeholder, metadados fracos */

  /* acento da marca (teal) */
  --accent:        #3F8B98;
  --accent-ink:    #1F5A65;
  --accent-soft:   #E5EEF0;
  --accent-bg:     #EEF5F6;

  /* status — sempre par (bg tonal + tinta) */
  --ok:            #2F7D4F;   --ok-bg:    #E5F0E6;   /* sucesso/positivo */
  --warn:          #B66E2A;   --warn-bg:  #F6E8D4;   /* atenção/pendente  */
  --danger:        #B23A2E;   --danger-bg:#F6E1DD;   /* erro/negativo     */
  --neutral:       #5C5B57;   --neutral-bg:#ECE9E0;  /* neutro/etiqueta   */

  /* tokens de componente (flipam no tema escuro) */
  --on-solid:          #FFFFFF;   /* texto/ícone sobre preenchimento sólido (ink/ok) */
  --btn-primary-hover: #000000;
  --btn-success-hover: #2A6E46;

  /* dots de especialidade (agenda) */
  --dot-fono:  #3F8B98;
  --dot-fisio: #D0689A;
  --dot-psico: #C9A227;
  --dot-to:    #7FA66B;
  --dot-musico:#8A6FC0;

  /* raio */
  --radius-lg: 18px;
  --radius:    14px;   /* card padrão */
  --radius-sm: 10px;   /* controles (botão, input) */
  --radius-xs: 8px;
  --radius-pill: 999px;

  /* sombra */
  --shadow-card: 0 1px 2px rgba(20,20,30,.04);
  --shadow-pop:  0 8px 28px rgba(20,20,30,.12);

  /* espaçamento (escala de 4) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;

  color-scheme: light;
}

/* ──────────────────────── 1b. TEMA ESCURO ──────────────────────────────────
   Tema claro é o padrão; o escuro é opt-in e só aplica quando o usuário o
   escolhe no toggle (grava [data-theme="dark"]). Sobrescreve apenas tokens de
   cor/sombra; raio, espaçamento, fonte e os dots de especialidade permanecem. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #16171B;
  --surface:       #1E1F24;
  --surface-2:     #26272D;
  --surface-sunken:#121317;

  --border:        #33343B;
  --border-strong: #45464F;
  --hairline:      #2A2B31;

  --ink:           #F2F0EA;
  --ink-soft:      #D4D3CE;
  --muted:         #A0A0A6;
  --muted-soft:    #77777D;

  --accent:        #4FA3B1;
  --accent-ink:    #8FCBD5;
  --accent-soft:   #1E3A40;
  --accent-bg:     #17282C;

  --ok:            #5FB07E;   --ok-bg:    #18301F;
  --warn:          #D3944C;   --warn-bg:  #362713;
  --danger:        #D96A5E;   --danger-bg:#3A1F1B;
  --neutral:       #A3A29C;   --neutral-bg:#2A2A26;

  --on-solid:          var(--bg);
  --btn-primary-hover: #FFFFFF;
  --btn-success-hover: #4E9A6B;

  --shadow-card: 0 1px 2px rgba(0,0,0,.40);
  --shadow-pop:  0 8px 28px rgba(0,0,0,.55);
}

/* ─────────────────────────── 2. BASE / RESET ────────────────────────────── */
.apap-ui, .apap-ui * { box-sizing: border-box; }
.apap-ui {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.apap-ui button { font-family: inherit; cursor: pointer; }
.apap-ui [data-lucide] { width: 18px; height: 18px; stroke-width: 1.75; }
.apap-ui h1, .apap-ui h2, .apap-ui h3, .apap-ui h4, .apap-ui p { margin: 0; }

/* ───────────────────────────── 3. TIPOGRAFIA ────────────────────────────── */
/* Escala de uso — aplique como classe utilitária quando não houver componente. */
.t-display  { font-size: 26px;   font-weight: 700; letter-spacing: -0.018em; line-height: 1.15; }
.t-title    { font-size: 18px;   font-weight: 700; letter-spacing: -0.012em; line-height: 1.25; }
.t-card     { font-size: 15px;   font-weight: 600; letter-spacing: -0.01em;  line-height: 1.3; }
.t-body     { font-size: 13.5px; font-weight: 400; line-height: 1.55; }
.t-meta     { font-size: 12.5px; font-weight: 400; color: var(--muted); line-height: 1.5; }
.t-eyebrow  { font-size: 11px;   font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.text-muted { color: var(--muted); }
.text-strong{ color: var(--ink); font-weight: 600; }

/* ───────────────────────────── 4. BOTÕES ────────────────────────────────── */
.btn {
  font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}
.btn [data-lucide] { width: 16px; height: 16px; stroke-width: 2; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

/* primário — ação principal da tela e submit de formulário */
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-solid); }
.btn-primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); }

/* sucesso — ação de criar/positiva (opcional; ex.: "+ Novo …") */
.btn-success { background: var(--ok); border-color: var(--ok); color: var(--on-solid); }
.btn-success:hover { background: var(--btn-success-hover); border-color: var(--btn-success-hover); }

/* perigo — exclusão/ação destrutiva (contorno) */
.btn-danger { color: var(--danger); border-color: var(--danger-bg); background: var(--surface); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }

/* atenção — advertência/estado intermediário (contorno) */
.btn-warn { color: var(--warn); border-color: var(--warn-bg); background: var(--surface); }
.btn-warn:hover { background: var(--warn-bg); border-color: var(--warn); }

/* fantasma — ação terciária */
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

/* tamanhos */
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn-lg { height: 44px; padding: 0 22px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* botão-ícone — ações compactas em cards e linhas */
.icon-btn {
  appearance: none; border: 0; background: transparent;
  width: 32px; height: 32px; border-radius: var(--radius-xs);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn [data-lucide] { width: 16px; height: 16px; stroke-width: 1.75; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.is-danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ───────────────────────────── 5. BADGES / STATUS ───────────────────────── */
/* Pílula tonal. Combine .badge com um modificador de cor.                     */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; letter-spacing: 0.01em;
  line-height: 1.5; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral);
}
button.badge { appearance: none; border: 0; font-family: inherit; cursor: pointer; }
.badge [data-lucide] { width: 12px; height: 12px; stroke-width: 2.25; }
.badge--ok      { background: var(--ok-bg);      color: var(--ok); }
.badge--warn    { background: var(--warn-bg);    color: var(--warn); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger); }
.badge--accent  { background: var(--accent-bg);  color: var(--accent-ink); }
.badge--neutral { background: var(--neutral-bg); color: var(--neutral); }

/* variante "dot" — bolinha de cor à esquerda (status discreto) */
.badge--dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}

/* etiqueta de categoria/CID — contorno suave em maiúsculas */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: var(--radius-xs);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.tag--accent { background: var(--accent-bg); color: var(--accent-ink); border-color: transparent; }

/* chip de especialidade — dot colorido + nome (agenda) */
.spec {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 8px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--hairline);
  font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
}
.spec::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral); }
.spec.is-fono::before  { background: var(--dot-fono); }
.spec.is-fisio::before { background: var(--dot-fisio); }
.spec.is-psico::before { background: var(--dot-psico); }
.spec.is-to::before    { background: var(--dot-to); }
.spec.is-musico::before{ background: var(--dot-musico); }

/* ───────────────────────────── 6. AVATAR ────────────────────────────────── */
.avatar {
  --size: 40px;
  width: var(--size); height: var(--size);
  border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 700; font-size: calc(var(--size) * 0.36); letter-spacing: 0.02em;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { --size: 32px; }
.avatar.lg { --size: 48px; }

/* ───────────────────────────── 7. FORMULÁRIOS ───────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field + .field { margin-top: var(--sp-5); }
/* Campos lado a lado em grade: o espaçamento vertical vem do `gap` do grid.
   Sem isto, `.field + .field` aplicaria margin-top à coluna seguinte da mesma
   linha, desalinhando-a para baixo em relação à coluna da esquerda. */
.form-grid-2 > .field,
[class*="grid-cols-"] > .field { margin-top: 0; }
.label {
  font-size: 13px; font-weight: 600; color: var(--ink-soft); letter-spacing: -0.005em;
  display: inline-flex; align-items: center; gap: 4px;
}
.label .req { color: var(--danger); font-weight: 700; }
.help { font-size: 12px; color: var(--muted); line-height: 1.45; }

.input, .textarea, .select {
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit; font-size: 14px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted-soft); }
.textarea { min-height: 112px; resize: vertical; line-height: 1.55; }
/* Altura fixa nos campos de linha única: <input type="date"> renderiza mais alto que
   selects/texto com apenas min-height, desalinhando grids como "Data + Tipo". */
.input, .select { height: 44px; }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
/* select com chevron próprio */
.select {
  appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6B70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  color: var(--ink);
}
.select.is-placeholder { color: var(--muted-soft); }

/* estados */
.field.is-error .input, .field.is-error .textarea, .field.is-error .select { border-color: var(--danger); }
.field.is-error .input:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
.field-error { font-size: 12px; color: var(--danger); display: inline-flex; align-items: center; gap: 5px; }
.field-error [data-lucide] { width: 13px; height: 13px; }
.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--surface-2); color: var(--muted); cursor: not-allowed;
}

/* checkbox — bloco com rótulo e ajuda (ex.: "Agendamento recorrente") */
.check {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
}
.check input[type="checkbox"] {
  appearance: none; width: 18px; height: 18px; margin: 1px 0 0; flex: 0 0 auto;
  border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--surface);
  cursor: pointer; position: relative; transition: background .12s, border-color .12s;
}
.check input[type="checkbox"]:checked { background: var(--ink); border-color: var(--ink); }
.check input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 9px;
  border: solid var(--on-solid); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.check .check-text { line-height: 1.35; }
.check .check-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.check .check-help { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ───────────────────────────── 8. ALERTAS ───────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.5;
  border: 1px solid transparent;
}
.alert [data-lucide] { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.alert--ok     { background: var(--ok-bg);     color: var(--ok);     border-color: #cfe6d3; }
.alert--warn   { background: var(--warn-bg);   color: var(--warn);   border-color: #ecd9bd; }
.alert--danger { background: var(--danger-bg); color: var(--danger); border-color: #edcdc7; }
.alert--info   { background: var(--accent-bg); color: var(--accent-ink); border-color: #cfe1e4; }
.alert--info-strong { background: var(--accent); color: #fff; border-color: var(--accent-ink); }

/* ═══════════════════════════ PADRÕES DE PÁGINA ═══════════════════════════ */

/* ───────────────────────── 9. CABEÇALHO DE PÁGINA ───────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--muted); margin-bottom: 4px;
}
.breadcrumb .crumb-strong { color: var(--ink); font-weight: 600; }
.breadcrumb .sep { color: var(--muted-soft); }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  padding-bottom: 20px; border-bottom: 1px solid var(--hairline); margin-bottom: 20px;
}
.page-header .ph-title { font-size: 26px; font-weight: 700; letter-spacing: -0.018em; color: var(--ink); }
.page-header .ph-count { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.page-header .ph-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* ───────────────────────── 10. TOOLBAR (busca + filtros) ────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.search { position: relative; flex: 1 1 280px; max-width: 420px; }
.search [data-lucide] {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%; height: 40px; padding: 0 12px 0 38px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-family: inherit; font-size: 13.5px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted-soft); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* select de filtro compacto (toolbar) */
.filter-select {
  appearance: none; height: 40px; padding: 0 34px 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--ink-soft); cursor: pointer; min-width: 150px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B6B70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.filter-select:hover { border-color: var(--border-strong); }
.filter-select:focus { outline: none; border-color: var(--accent); }
.toolbar-spacer { flex: 1 1 auto; }

/* toggle de visualização cards/lista */
.view-toggle {
  display: inline-flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px; height: 40px; gap: 2px;
}
.vt-btn {
  appearance: none; border: 0; background: transparent; width: 34px; height: 32px;
  border-radius: var(--radius-xs); display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer; transition: background .12s, color .12s;
}
.vt-btn:hover { color: var(--ink-soft); }
.vt-btn.active { background: var(--ink); color: #fff; }
.vt-btn [data-lucide] { width: 16px; height: 16px; }

/* ───────────────────────── 11. CARDS DE ESTATÍSTICA (KPI) ───────────────── */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.kpi .kpi-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.kpi .kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.kpi .kpi-desc  { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ───────────────────── 12. LISTAGEM EM CARDS (PADRÃO) ───────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card-grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }

.record-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-card);
  transition: border-color .15s, transform .15s, box-shadow .15s;
  cursor: pointer;
}
.record-card:hover { border-color: var(--ink); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(20,20,30,.06); }

.record-card .rec-head { display: flex; align-items: flex-start; gap: 12px; }
.record-card .rec-id { min-width: 0; flex: 1; }
.record-card .rec-name {
  font-size: 14.5px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.record-card .rec-sub { font-size: 12px; color: var(--muted-soft); margin-top: 2px; }
.record-card .rec-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* coluna de ações no topo direito (abrir, baixar, excluir) */
.record-card .rec-actions {
  position: absolute; top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 2px;
  opacity: 0; transition: opacity .15s;
  /* o link do corpo do card ganha will-change de app-animations.js e passaria por cima das ações */
  z-index: 1;
}
.record-card:hover .rec-actions, .record-card:focus-within .rec-actions { opacity: 1; }
.record-card .rec-actions .icon-btn { width: 28px; height: 28px; }
.record-card .rec-actions .icon-btn [data-lucide] { width: 15px; height: 15px; }

/* corpo de metadados (linhas rótulo: valor) */
.record-card .rec-meta { margin-top: 14px; display: flex; flex-direction: column; gap: 5px; }
.rec-meta .meta-line { font-size: 12.5px; color: var(--muted); line-height: 1.45; display: flex; gap: 6px; }
.rec-meta .meta-line .ml-key { color: var(--muted); }
.rec-meta .meta-line .ml-val { color: var(--ink-soft); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* bloco "RELATO" — eyebrow + texto truncado (evolução social) */
.record-card .rec-note { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hairline); }
.rec-note .note-label { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-soft); }
.rec-note .note-text {
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ───────────────── 13. LISTAGEM EM TABELA DENSA (FINANCEIRO) ─────────────── */
.data-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  text-align: left; height: 42px; padding: 0 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--hairline);
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--hairline); font-size: 13.5px; color: var(--ink-soft); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .td-strong { font-weight: 600; color: var(--ink); }
.data-table .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .td-actions { text-align: right; white-space: nowrap; }
.data-table .col-pos { color: var(--ok); font-weight: 600; }
.data-table .col-neg { color: var(--danger); font-weight: 600; }

/* ───────────────────────── 14. FORMULÁRIO (PÁGINA) ──────────────────────── */
.form-wrap { max-width: 760px; margin: 0 auto; }
.form-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 28px 24px;
  box-shadow: var(--shadow-card);
}
.form-section + .form-section { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--hairline); }
.form-section-title { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--hairline);
}
.form-footer .spacer { flex: 1; }
.form-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }
.form-note .req { color: var(--danger); }

/* ───────────────────────── 15. ESTADO VAZIO ─────────────────────────────── */
.empty {
  text-align: center; padding: 56px 24px;
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty .empty-icon {
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 14px; background: var(--accent-bg); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
}
.empty .empty-icon [data-lucide] { width: 24px; height: 24px; }
.empty .empty-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.empty .empty-desc { font-size: 13px; color: var(--muted); margin: 6px auto 18px; max-width: 360px; line-height: 1.5; }

/* ───────────────────────── 16. PAGINAÇÃO ────────────────────────────────── */
.pagination { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.pagination .pager { display: flex; gap: 4px; }
.pg-btn {
  appearance: none; min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface);
  font-family: inherit; font-size: 12.5px; color: var(--ink-soft); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.pg-btn:hover:not(:disabled):not(.active) { background: var(--surface-2); }
.pg-btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pg-btn:disabled { opacity: .45; cursor: not-allowed; }
.pg-btn [data-lucide] { width: 14px; height: 14px; }

/* ─────────────────── 17. COMPATIBILIDADE COM UTILITIES ───────────────────── */
/* No Tailwind v4 as utilities ficam em @layer (prioridade baixa) e perdem para as
   classes unlayered deste arquivo. Sem isto, componentes com `display` próprio
   (.btn, .field, .alert, .badge…) ignoram `.hidden` quando alternado via JS,
   ficando sempre visíveis. O seletor composto evita afetar utilities responsivas
   como "hidden md:flex" (a sidebar), pois exige as duas classes no mesmo elemento. */
.btn.hidden, .icon-btn.hidden, .field.hidden, .field-error.hidden,
.alert.hidden, .badge.hidden, .tag.hidden, .spec.hidden, .check.hidden,
.kpi.hidden, .empty.hidden, .record-card.hidden, .data-table.hidden,
.page-header.hidden, .toolbar.hidden, .breadcrumb.hidden { display: none !important; }

/* Campo "bloqueado" alternado por JS sem usar o atributo :disabled
   (mesmo visual que .input:disabled). */
.is-locked { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

.page-wrap { max-width: 96rem; margin-left: auto; margin-right: auto; }

/* ─────────────────────────────── TOOLTIP ─────────────────────────────────── */
/* Uso: <elemento data-tooltip="texto">. Posição: acima do elemento.           */
[data-tooltip] { position: relative; cursor: default; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  line-height: 1.4;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  white-space: normal;
  width: max-content;
  max-width: 280px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 200;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ───────────────────────────── Select2 (tema) ───────────────────────────── */
.select2-dropdown {
  background-color: var(--surface);
  color: var(--ink);
}
.select2-search--dropdown .select2-search__field {
  background-color: var(--surface);
  color: var(--ink);
}
.select2-results__option {
  color: var(--ink);
  background-color: var(--surface);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--accent);
  color: var(--on-solid);
}
.select2-container--default .select2-results__option[aria-selected="true"] {
  background-color: var(--surface-2);
  color: var(--ink);
}
