/* =====================================================================
   TEMA PREMIUM — Fluir ERP
   ---------------------------------------------------------------------
   Camada de acabamento visual sobre o SB Admin 2 (Bootstrap 4).
   Objetivo: dar a TODA tela nova o mesmo padrão dos vídeos de treinamento
   (cards suaves, micro-labels, chips/badges arredondados, tiles de ícone,
   tabelas e kanban premium) SEM quebrar o que já existe.

   COMO USAR (ver docs/DESIGN.md):
   - Prefira os componentes `fx-*` deste arquivo em telas novas.
   - NUNCA cravar cor/sombra/raio inline — use as variáveis `--fx-*`.
   - A paleta segue a do tenant (`--fluir-primary`); os tokens abaixo só
     preenchem o que o sb-admin2 não tem.

   Carregar DEPOIS de sb-admin-2.min.css e responsivo.css.
   ===================================================================== */

:root {
  /* --- Cor (herda a paleta do tenant; fallback = azul/roxo dos mockups) --- */
  --fx-primary:   var(--fluir-primary, #4e73df);
  --fx-primary-2: #825ee4;                 /* 2º tom p/ gradientes premium   */
  --fx-success:   var(--fluir-secondary, #2dce89);
  --fx-info:      #11cdef;
  --fx-warning:   var(--fluir-accent, #fb6340);
  --fx-danger:    #e74a3b;

  /* --- Neutros (tinta, apoio, linhas, superfícies) --- */
  --fx-ink:      #3a3b45;   /* texto forte / títulos            */
  --fx-ink-2:    #5a5c69;   /* texto padrão                     */
  --fx-muted:    #8a94ad;   /* legendas / labels                */
  --fx-faint:    #b7b9cc;   /* placeholders / ícones apagados   */
  --fx-line:     #e3e6f0;   /* bordas                           */
  --fx-line-2:   #eef1f5;   /* divisórias internas              */
  --fx-surface:  #ffffff;   /* fundo de card                    */
  --fx-surface-2:#f7f8fc;   /* cabeçalho de tabela / trilhos    */
  --fx-tint:     #eef2ff;   /* fundo de tile/realce da primária */

  /* --- Forma & profundidade --- */
  --fx-radius:    12px;     /* cards                            */
  --fx-radius-sm: 8px;      /* botões, campos, chips            */
  --fx-radius-lg: 16px;     /* modais, heros                    */
  --fx-shadow:    0 2px 10px rgba(20,22,40,.05);
  --fx-shadow-md: 0 8px 24px rgba(20,22,40,.10);
  --fx-shadow-lg: 0 24px 70px rgba(10,12,30,.28);
  --fx-ring:      0 0 0 3px rgba(94,114,228,.30);   /* foco/realce */

  /* --- Tipografia --- */
  --fx-font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* =====================================================================
   1) UPLIFT GLOBAL — cosmético e conservador
   Só toca raio, sombra, peso e cor de detalhe (nada de layout/tamanho),
   para elevar as telas atuais sem risco de quebrar grid/posicionamento.
   ===================================================================== */

.card {
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius);
  box-shadow: var(--fx-shadow);
}
.card .card-header {
  background: var(--fx-surface);
  border-bottom: 1px solid var(--fx-line-2);
  font-weight: 800;
}

.btn { border-radius: var(--fx-radius-sm); font-weight: 700; }

.badge { border-radius: 20px; font-weight: 800; letter-spacing: .2px; }

.modal-content { border: 0; border-radius: var(--fx-radius-lg); box-shadow: var(--fx-shadow-lg); }
.modal-header, .modal-footer { border-color: var(--fx-line-2); }

/* Tabelas do Bootstrap ganham cabeçalho no padrão premium */
.table thead th {
  background: var(--fx-surface-2);
  color: var(--fx-muted);
  text-transform: uppercase;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .4px;
  border-top: 0;
  border-bottom: 1px solid var(--fx-line-2);
}
.table td { vertical-align: middle; }

/* Foco consistente em campos (cor da primária, sem o azul cru do BS) */
.form-control:focus, .custom-select:focus {
  border-color: var(--fx-primary);
  box-shadow: var(--fx-ring);
}

/* =====================================================================
   2) KIT DE COMPONENTES `fx-*` — use em telas novas
   ===================================================================== */

/* ---- Cabeçalho de página --------------------------------------------- */
.fx-page-title {
  font-family: var(--fx-font);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--fx-ink);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.fx-page-title i { color: var(--fx-primary); }
.fx-page-sub { font-size: .8rem; color: var(--fx-muted); margin-top: .15rem; }

/* ---- Mini-hero de módulo (cabeçalho de lista premium, reutilizável) --- */
.fx-modhero {
  position: relative; overflow: hidden;
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius-lg);
  background:
    radial-gradient(120% 160% at 92% -30%, color-mix(in srgb, var(--fx-primary) 15%, transparent), transparent 60%),
    linear-gradient(120deg, color-mix(in srgb, var(--fx-primary) 8%, var(--fx-surface)), var(--fx-surface) 60%);
  box-shadow: var(--fx-shadow);
  padding: 18px 20px; margin-bottom: 1.1rem;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.fx-modhero__ic {
  width: 50px; height: 50px; flex: 0 0 auto;
  border-radius: 14px; display: grid; place-items: center;
  color: #fff; font-size: 1.25rem;
  background: linear-gradient(135deg, var(--fx-primary), var(--fx-primary-2));
  box-shadow: var(--fx-shadow-md);
}
.fx-modhero__t { font-size: 1.3rem; font-weight: 800; color: var(--fx-ink); line-height: 1.15; margin: 0; }
.fx-modhero__s { font-size: .84rem; color: var(--fx-ink-2); margin-top: .12rem; }
.fx-modhero__tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 640px) { .fx-modhero__tools { margin-left: 0; width: 100%; } }

/* ---- Wrapper de tabela larga: rolagem horizontal no mobile ----------- */
.fx-tablewrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Card premium ---------------------------------------------------- */
.fx-card {
  background: var(--fx-surface);
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius);
  box-shadow: var(--fx-shadow);
}
.fx-card__head {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--fx-line-2);
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--fx-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.fx-card__body { padding: 1.15rem; }

/* Cabeçalho de card com FAIXA (o "acabamento" premium): gradiente do tema +
   ícone + título/subtítulo. Dá o mesmo ar finalizado dos importadores de
   Cadastros, porém na paleta fx-*. Opt-in (adicionar --accent ao __head). */
.fx-card__head--accent {
  background: linear-gradient(135deg, var(--fx-primary), var(--fx-primary-2));
  color: #fff;
  border-bottom: 0;
  border-radius: var(--fx-radius) var(--fx-radius) 0 0;
  text-transform: none;
  letter-spacing: normal;
  padding: .85rem 1.1rem;
  gap: .7rem;
}
.fx-card__head--accent .fx-card__head-ic {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,.22);
  color: #fff; font-size: 1rem;
}
.fx-card__head--accent .fx-card__head-tt { min-width: 0; }
.fx-card__head--accent .fx-card__head-t { font-size: .95rem; font-weight: 800; line-height: 1.15; }
.fx-card__head--accent .fx-card__head-s { font-size: .72rem; font-weight: 600; opacity: .88; }
.fx-card__head--accent .fx-card__head-act { margin-left: auto; }
.fx-card__head--accent .fx-card__head-act .fx-btn { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }
.fx-card__head--accent .fx-card__head-act .fx-btn:hover { background: rgba(255,255,255,.3); }

/* ---- Stat card (KPI) ------------------------------------------------- */
.fx-stat {
  background: var(--fx-surface);
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius);
  box-shadow: var(--fx-shadow);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
}
.fx-stat__ic {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; color: #fff;
  background: linear-gradient(135deg, var(--fx-primary), var(--fx-primary-2));
  flex-shrink: 0;
}
.fx-stat__label { font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--fx-muted); }
.fx-stat__value { font-size: 1.5rem; font-weight: 800; color: var(--fx-ink); line-height: 1.1; }
.fx-stat__delta { font-size: .7rem; font-weight: 800; }
.fx-stat__delta.up   { color: var(--fx-success); }
.fx-stat__delta.down { color: var(--fx-danger); }

/* ---- Micro-label (rótulo de campo/seção) ----------------------------- */
.fx-label {
  display: block;
  font-size: .6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--fx-muted);
  margin-bottom: .3rem;
}

/* ---- Chip ------------------------------------------------------------ */
.fx-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--fx-tint);
  color: var(--fx-primary);
  border-radius: var(--fx-radius-sm);
  padding: .2rem .55rem;
  font-size: .72rem;
  font-weight: 800;
}
.fx-chip--muted { background: #f0f3fb; color: var(--fx-ink-2); }

/* ---- Badge de status (pílula) ---------------------------------------- */
.fx-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border-radius: 20px;
  padding: .18rem .6rem;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .2px;
}
.fx-badge--success { background: #e6f7ee; color: #1aae6f; }
.fx-badge--info    { background: #e6f6fd; color: #0c9dc0; }
.fx-badge--primary { background: var(--fx-tint); color: var(--fx-primary); }
.fx-badge--warning { background: #fff5e0; color: #c98a00; }   /* aviso = amarelo/âmbar */
.fx-badge--danger  { background: #fdecec; color: var(--fx-danger); } /* SÓ erro/falha real */
.fx-badge--muted   { background: var(--fx-line-2); color: var(--fx-muted); }

/* ---- Tile de ícone (ex.: início de linha/lista) ---------------------- */
.fx-tile-ic {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--fx-tint);
  color: var(--fx-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  flex-shrink: 0;
}

/* ---- Miniatura de produto (lista/pedido) ----------------------------- */
.fx-thumb {
  width: 48px; height: 48px;
  border-radius: var(--fx-radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}
/* quando não há foto: usa o tile de ícone no mesmo tamanho da miniatura */
.fx-tile-ic.fx-thumb { font-size: 1rem; }

/* ---- Botões premium -------------------------------------------------- */
.fx-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  border: 0;
  border-radius: var(--fx-radius-sm);
  padding: .55rem 1rem;
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
  transition: filter .15s, box-shadow .15s, background .15s;
}
.fx-btn--primary { background: var(--fx-primary); color: #fff; }
.fx-btn--primary:hover { filter: brightness(.95); }
.fx-btn--ghost {
  background: var(--fx-surface);
  border: 1.5px solid var(--fx-primary);
  color: var(--fx-primary);
}
.fx-btn--ghost:hover { background: var(--fx-tint); }
.fx-btn--soft { background: var(--fx-line-2); color: var(--fx-ink-2); }

/* ---- Hero (faixa de destaque com gradiente) -------------------------- */
.fx-hero {
  background: linear-gradient(135deg, var(--fx-primary), var(--fx-primary-2));
  border-radius: var(--fx-radius-lg);
  padding: 1.4rem 1.6rem;
  color: #fff;
  box-shadow: 0 12px 30px rgba(94,114,228,.30);
}
.fx-hero h2 { font-size: 1.35rem; font-weight: 800; margin: 0; }
.fx-hero p  { font-size: .8rem; opacity: .9; margin: .35rem 0 0; }

/* ---- Tabela premium (quando não usa .table do BS) -------------------- */
.fx-table {
  width: 100%;
  background: var(--fx-surface);
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius);
  overflow: hidden;
  box-shadow: var(--fx-shadow);
}
.fx-table thead th,
.fx-table .fx-thead > div {
  background: var(--fx-surface-2);
  color: var(--fx-muted);
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: .7rem 1rem;
}
.fx-table tbody td { padding: .75rem 1rem; border-top: 1px solid var(--fx-line-2); font-size: .8rem; color: var(--fx-ink); }
.fx-table tbody tr:hover { background: #f9fafe; }

/* ---- Kanban ---------------------------------------------------------- */
.fx-kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.fx-col {
  width: 220px; flex-shrink: 0;
  background: #eef1f7;
  border-radius: var(--fx-radius);
  display: flex; flex-direction: column;
}
.fx-col__head {
  padding: .7rem .8rem;
  border-radius: var(--fx-radius) var(--fx-radius) 0 0;
  color: #fff;
  font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .4px;
}
.fx-col__body { padding: .6rem; display: flex; flex-direction: column; gap: .6rem; }
.fx-kcard {
  background: var(--fx-surface);
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(50,50,93,.11), 0 1px 3px rgba(0,0,0,.08);
  padding: .7rem;
  cursor: grab;
}
.fx-kcard:hover { box-shadow: var(--fx-shadow-md); }

/* ---- Switch (liga/desliga) ------------------------------------------- */
.fx-switch {
  width: 46px; height: 26px;
  border-radius: 20px;
  background: #d6d9e6;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  display: inline-block;
}
.fx-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: left .2s;
}
.fx-switch.on { background: var(--fx-success); }
.fx-switch.on::after { left: 23px; }

/* ---- Campos de formulário: checkbox & switch nativos ------------------ */
/* Envolvem um <input type=checkbox> REAL (Django/crispy) num rótulo, com o
   respiro correto entre a caixa e o texto. O input nativo fica oculto e a
   caixa/trilho abaixo reagem via seletor de irmão (:checked). Reutilizável
   em qualquer formulário — não cravar spacing/cor no template. */
.fx-check, .fx-toggle {
  display: inline-flex;
  align-items: center;
  gap: .6rem;                 /* <- respiro caixa ↔ rótulo */
  cursor: pointer;
  margin: 0;
  user-select: none;
  color: var(--fx-ink);
  font-weight: 700;
  line-height: 1.25;
}
.fx-check > input[type="checkbox"],
.fx-toggle > input[type="checkbox"] {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
}
.fx-check--block { display: flex; }        /* ocupa a linha inteira */
.fx-check__text, .fx-toggle__text { display: flex; flex-direction: column; }
.fx-check__hint, .fx-toggle__hint {
  font-weight: 600; font-size: .72rem; color: var(--fx-muted); margin-top: .1rem;
}

/* Caixa (checkbox) */
.fx-check__box {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border: 1.5px solid var(--fx-line);
  border-radius: 6px;
  background: var(--fx-surface);
  display: grid; place-items: center;
  color: #fff; font-size: .68rem;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.fx-check__box i { opacity: 0; transform: scale(.5); transition: opacity .15s, transform .15s; }
.fx-check:hover .fx-check__box { border-color: var(--fx-primary); }
.fx-check > input:checked + .fx-check__box {
  background: var(--fx-primary); border-color: var(--fx-primary);
}
.fx-check > input:checked + .fx-check__box i { opacity: 1; transform: scale(1); }
.fx-check > input:focus-visible + .fx-check__box { box-shadow: var(--fx-ring); }
.fx-check > input:disabled ~ * { opacity: .55; }

/* Trilho (switch) — mesmo visual do .fx-switch, porém dirigido pelo input */
.fx-toggle__track {
  flex: 0 0 auto;
  width: 44px; height: 24px; border-radius: 20px;
  background: #d6d9e6; position: relative;
  transition: background .2s;
}
.fx-toggle__track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .2s;
}
.fx-toggle > input:checked + .fx-toggle__track { background: var(--fx-success); }
.fx-toggle > input:checked + .fx-toggle__track::after { left: 23px; }
.fx-toggle > input:focus-visible + .fx-toggle__track { box-shadow: var(--fx-ring); }
.fx-toggle > input:disabled ~ * { opacity: .55; }

/* Checkbox de seleção nas planilhas (seletor de linha) — só cor de marca */
.table-spreadsheet input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: var(--fx-primary);
  cursor: pointer; vertical-align: middle;
}

/* ---- Abas ------------------------------------------------------------ */
.fx-tabs { display: flex; gap: .1rem; border-bottom: 1px solid var(--fx-line); }
.fx-tab {
  padding: .65rem .9rem;
  font-size: .78rem; font-weight: 800;
  color: var(--fx-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem;
}
.fx-tab.active { color: var(--fx-primary); border-bottom-color: var(--fx-primary); }

/* Botão "information" das execuções (fundo azul, exclamação branca) — usado nas telas de backup */
.bkp-info { display:inline-flex; align-items:center; justify-content:center; width:28px; height:28px;
  border:0; border-radius:50%; background:var(--fx-info,#3b82f6); color:#fff; cursor:pointer;
  font-size:.8rem; line-height:1; padding:0; transition:filter .15s, transform .05s; }
.bkp-info:hover { filter:brightness(1.08); }
.bkp-info:active { transform:scale(.94); }
.bkp-info:focus-visible { outline:none; box-shadow:var(--fx-ring); }
.bkp-info i { color:#fff; }

/* ---- Nota / dica (destaque suave) ------------------------------------ */
.fx-note {
  background: var(--fx-tint);
  border-left: 3px solid var(--fx-primary);
  border-radius: var(--fx-radius-sm);
  padding: .55rem .8rem;
  font-size: .72rem;
  color: #4a5578;
  display: flex; gap: .5rem; align-items: flex-start;
}
.fx-note i { color: var(--fx-primary); margin-top: .1rem; }

/* ---- Nota / dica — variantes semânticas ------------------------------ */
.fx-note--danger  { background: #fdecec; border-left-color: var(--fx-danger);  color: #8a2f27; }
.fx-note--danger i { color: var(--fx-danger); }
.fx-note--warning { background: #fff5e0; border-left-color: var(--fx-warning); color: #7a5b12; }
.fx-note--warning i { color: var(--fx-warning); }
.fx-note--info { background: #e9f1ff; border-left-color: var(--fx-info, #3b82f6); color: #2b4a7a; }
.fx-note--info i { color: var(--fx-info, #3b82f6); }

/* ---- Modais premium (cabeçalho gradiente + corpo/rodapé + seções) ----- */
/* Reutilizável por qualquer modal do ERP; a cor segue a marca do tenant.  */
.fx-modalhead {
  background: linear-gradient(135deg, var(--fx-primary), var(--fx-primary-2));
  color: #fff;
  border: 0;
  padding: 1rem 1.25rem;
}
.fx-modalhead .modal-title {
  margin: 0;
  font-weight: 800;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.fx-modalhead__ic {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: rgba(255,255,255,.18);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .9rem;
}
.fx-modalhead .close { color: #fff; opacity: .9; text-shadow: none; }
.fx-modalbody { padding: 1.35rem 1.25rem .5rem; max-height: 74vh; overflow-y: auto; }
.fx-modalfoot {
  background: var(--fx-surface-2);
  border-top: 1px solid var(--fx-line-2);
  display: flex; justify-content: space-between; align-items: center;
  padding: .8rem 1.25rem;
}
/* Cantos arredondados consistentes com os modais .fmodal (ex.: Novo Solicitante):
   clipa o cabeçalho gradiente e o rodapé às bordas do modal, senão vazam com
   cantos retos por cima do border-radius do .modal-content. */
.modal-content:has(.fx-modalhead) { border-radius: 22px !important; overflow: hidden; }

/* Ícone de ajuda (i) ao lado de um rótulo — abre popover */
.fx-help {
  color: var(--fx-faint);
  font-size: .78rem;
  cursor: help;
  margin-left: .3rem;
  vertical-align: baseline;
  transition: color .15s;
}
.fx-help:hover, .fx-help:focus { color: var(--fx-primary); outline: none; }

/* Cabeçalho de coluna ordenável (listagens) */
.fx-sorth {
  color: inherit; text-decoration: none;
  display: inline-flex; align-items: center; gap: .3rem; cursor: pointer;
}
.fx-sorth:hover { color: var(--fx-primary); text-decoration: none; }
.fx-sorth .dim { opacity: .3; }

/* Divisória de seção dentro de formulários */
.fx-formsec {
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--fx-primary);
  margin: 1.35rem 0 .9rem;
  padding-left: .6rem;
  border-left: 3px solid var(--fx-primary);
  display: flex; align-items: center; gap: .5rem;
}
.fx-formsec:first-child { margin-top: .2rem; }
.fx-formsec::after { content: ""; flex: 1; height: 1px; background: var(--fx-line); }

/* Formulários no padrão premium: rótulos do crispy com o micro-label */
.fx-form label { font-weight: 700; font-size: .78rem; color: var(--fx-ink-2); }
.fx-form .form-control,
.fx-form .form-select,
.fx-form .custom-select,
.fx-form textarea,
.fx-form select {
  min-height: 42px;
  padding: .5rem .75rem;
  font-size: .85rem;
  color: var(--fx-ink);
  background-color: var(--fx-surface);
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius-sm);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.fx-form textarea.form-control { min-height: 88px; line-height: 1.4; }
.fx-form .form-control::placeholder,
.fx-form textarea::placeholder { color: var(--fx-faint); }
/* Foco premium: substitui o glow azul cru do Bootstrap/SB-Admin por anel do tema.
   (Aposenta o "designer antigo" nos formulários — o foco era o resíduo mais visível.) */
.fx-form .form-control:focus,
.fx-form .form-select:focus,
.fx-form textarea:focus,
.fx-form select:focus,
.fx-form input:focus {
  outline: 0;
  border-color: var(--fx-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-primary) 20%, transparent);
  background-color: var(--fx-surface);
}
/* Checkbox/radio comum (fora do modo switch) no tom da marca, com foco do tema. */
.fx-form .form-check-input { accent-color: var(--fx-primary); }
.fx-form .form-check-input:focus {
  border-color: var(--fx-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fx-primary) 20%, transparent);
}
/* Asterisco de campo obrigatório: âmbar = atenção (regra de cor: vermelho só erro). */
.fx-form .asteriskField { color: var(--fx-warning); font-weight: 800; margin-left: .12rem; }
/* <select> de 1 opção: tira o visual "cru" do navegador e põe um chevron do tema.
   (Selects que viram Select2 ficam ocultos, então isto não os afeta.) */
.fx-form select:not([multiple]) {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238a94ad' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  background-size: .95rem;
}
/* Campos de data/hora nativos alinhados ao tema (ícone do calendário discreto). */
.fx-form input[type="date"]::-webkit-calendar-picker-indicator,
.fx-form input[type="time"]::-webkit-calendar-picker-indicator,
.fx-form input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  opacity: .5; cursor: pointer;
}
.fx-form input[type="date"]:hover::-webkit-calendar-picker-indicator,
.fx-form input[type="time"]:hover::-webkit-calendar-picker-indicator { opacity: .9; }
/* Input file (Escolher arquivo) no padrão do tema em vez do botão cinza do SO. */
.fx-form input[type="file"].form-control { padding: .38rem .5rem; }
.fx-form input[type="file"]::file-selector-button {
  margin-right: .7rem; padding: .35rem .8rem;
  border: 0; border-radius: var(--fx-radius-sm);
  background: var(--fx-tint); color: var(--fx-primary);
  font-weight: 800; font-size: .78rem; cursor: pointer;
  transition: background .15s;
}
.fx-form input[type="file"]::file-selector-button:hover { background: color-mix(in srgb, var(--fx-primary) 18%, #fff); }
/* texto de ajuda do crispy (help_text): discreto, não desproporcional */
.fx-form .form-text, .fx-form small.text-muted {
  font-size: .68rem;
  line-height: 1.25;
  margin-top: .2rem;
  color: var(--fx-faint);
}
/* Autofill do Chrome pinta o campo de amarelo/creme e quebra o visual premium.
   Mantém o fundo branco (superfície do tema) e a cor de tinta corretos. GLOBAL. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill,
input:autofill,
textarea:autofill,
select:autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--fx-surface) inset !important;
  box-shadow: 0 0 0 1000px var(--fx-surface) inset !important;
  -webkit-text-fill-color: var(--fx-ink) !important;
  caret-color: var(--fx-ink);
  transition: background-color 9999s ease-out 0s;
}

/* ---- Área de upload (arrastar arquivo) — importadores premium -------- */
.fx-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: .35rem; cursor: pointer;
  padding: 1.9rem 1rem;
  border: 2px dashed var(--fx-line-2);
  border-radius: var(--fx-radius);
  background: var(--fx-tint-soft, #f6f8ff);
  transition: border-color .15s, background .15s;
}
.fx-dropzone:hover,
.fx-dropzone.is-drag { border-color: var(--fx-primary); background: color-mix(in srgb, var(--fx-primary) 7%, #fff); }
.fx-dropzone__ic { font-size: 2.1rem; color: var(--fx-primary); margin-bottom: .2rem; }
.fx-dropzone__t { font-weight: 800; color: var(--fx-ink); font-size: .92rem; }
.fx-dropzone__s { font-size: .74rem; color: var(--fx-muted); }
.fx-dropzone__file {
  margin-top: .5rem; font-size: .8rem; font-weight: 700; color: var(--fx-primary);
  display: inline-flex; align-items: center; gap: .4rem;
}

/* ---- Estado vazio ---------------------------------------------------- */
.fx-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--fx-muted);
}
.fx-empty i { font-size: 2rem; color: var(--fx-faint); margin-bottom: .6rem; }

/* ---- Utilitários de realce (foco de atenção) ------------------------- */
.fx-ring { box-shadow: var(--fx-ring) !important; }
.fx-elevated { box-shadow: var(--fx-shadow-md); }

/* ---- Aviso "Nova versão disponível" ---------------------------------- */
/* Âmbar = aviso não-bloqueante (regra de cor do projeto). Canto inferior      */
/* direito; não intercepta cliques quando oculto (hidden). Reusa fx-btn.       */
.fx-update {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1080;               /* acima do conteúdo, abaixo de modais (bs=1050+backdrop) */
  max-width: 24rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem .9rem;
  background: var(--fx-surface);
  border: 1px solid var(--fx-line);
  border-left: 4px solid var(--fx-warning);   /* âmbar/accent = aviso */
  border-radius: var(--fx-radius);
  box-shadow: var(--fx-shadow-lg);
  transform: translateY(140%);
  opacity: 0;
  transition: transform .28s ease, opacity .28s ease;
}
.fx-update.is-in { transform: translateY(0); opacity: 1; }
.fx-update__ic {
  flex: 0 0 auto;
  width: 2.1rem; height: 2.1rem;
  display: grid; place-items: center;
  border-radius: var(--fx-radius-sm);
  background: color-mix(in srgb, var(--fx-warning) 16%, #fff);
  color: var(--fx-warning);
  font-size: .95rem;
}
.fx-update__body { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.fx-update__body strong { color: var(--fx-ink); font-size: .86rem; }
.fx-update__body span { color: var(--fx-muted); font-size: .74rem; }
.fx-update__go { flex: 0 0 auto; padding: .4rem .8rem; font-size: .8rem; }
.fx-update__x {
  flex: 0 0 auto;
  border: 0; background: transparent;
  color: var(--fx-faint);
  font-size: 1.25rem; line-height: 1;
  padding: 0 .1rem; cursor: pointer;
}
.fx-update__x:hover { color: var(--fx-ink-2); }

/* ---- Formulário premium: booleanos crispy viram switch (opt-in) -------- */
/* Aplicar adicionando `fx-form--switch` ao lado de `fx-form`. Converte o
   checkbox nativo (crispy/bootstrap5 sobre o BS4 do sb-admin2) num trilho
   deslizante idêntico ao .fx-toggle — sem tocar em forms.py nem no template
   de cada campo. Só afeta formulários que optam pela classe (zero risco no
   resto do ERP). Cor "ligado" = --fx-success (regra de cor do projeto). */
.fx-form--switch .form-check {
  display: flex; flex-wrap: wrap; align-items: center;
  column-gap: .6rem; row-gap: .15rem;
  padding-left: 0; min-height: auto; margin: 0;
}
.fx-form--switch .form-check-input {
  -webkit-appearance: none; appearance: none;
  position: relative; float: none; margin: 0;
  flex: 0 0 auto; order: 0;
  width: 44px; height: 24px; border-radius: 20px;
  background: #d6d9e6; border: 0; cursor: pointer;
  transition: background .2s;
}
.fx-form--switch .form-check-input::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .2s;
}
.fx-form--switch .form-check-input:checked { background: var(--fx-success); }
.fx-form--switch .form-check-input:checked::after { left: 23px; }
.fx-form--switch .form-check-input:focus-visible { box-shadow: var(--fx-ring); outline: none; }
.fx-form--switch .form-check-input:disabled { opacity: .55; cursor: default; }
.fx-form--switch .form-check-label {
  order: 1; margin: 0; cursor: pointer;
  font-weight: 700; font-size: .82rem; color: var(--fx-ink);
}
/* help_text do campo booleano quebra para a linha de baixo, alinhado ao rótulo */
.fx-form--switch .form-check .form-text,
.fx-form--switch .form-check small.text-muted {
  order: 2; flex-basis: 100%; margin: 0 0 0 calc(44px + .6rem);
  font-size: .68rem; color: var(--fx-faint);
}

/* ---- Formulário premium: seletor de cor e multi-seleção --------------- */
/* Acabamento geral p/ campos <input type=color> e <select multiple> dentro
   de qualquer .fx-form (raros e sempre querem esse visual). */
.fx-form input[type="color"].form-control {
  width: 100%; max-width: 96px; height: 42px;
  padding: 4px; cursor: pointer;
  border-radius: var(--fx-radius-sm); border: 1px solid var(--fx-line);
  background: var(--fx-surface);
}
.fx-form select[multiple].form-control {
  min-height: auto; padding: .25rem;
  border-radius: var(--fx-radius-sm); border-color: var(--fx-line);
}
.fx-form select[multiple].form-control option {
  padding: .3rem .45rem; border-radius: var(--fx-radius-sm); margin-bottom: 1px;
}

/* ---- Botão de ação compacto p/ linhas de tabela (tokenizado) ---------- */
/* Substitui os `btn btn-sm btn-outline-*` do BS4 em listagens. */
.fx-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  height: 32px; min-width: 32px; padding: 0 .55rem;
  border-radius: var(--fx-radius-sm);
  border: 1.5px solid var(--fx-line);
  background: var(--fx-surface); color: var(--fx-ink-2);
  font-size: .78rem; font-weight: 700; line-height: 1;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.fx-iconbtn:hover {
  border-color: var(--fx-primary); color: var(--fx-primary);
  background: var(--fx-tint); text-decoration: none;
}
.fx-iconbtn--danger:hover {
  border-color: var(--fx-danger); color: var(--fx-danger); background: #fdecec;
}
.fx-iconbtn:disabled { opacity: .5; cursor: default; }
/* Estado ATIVO de um toggle em ícone (ex.: publicado/destaque/novidade na vitrine).
   Preenche com a cor semântica via token — substitui os btn-success/warning/primary do BS4. */
.fx-iconbtn--on-success { background: var(--fx-success); border-color: var(--fx-success); color: #fff; }
.fx-iconbtn--on-warning { background: var(--fx-warning); border-color: var(--fx-warning); color: #fff; }
.fx-iconbtn--on-primary { background: var(--fx-primary); border-color: var(--fx-primary); color: #fff; }
.fx-iconbtn--on-success:hover, .fx-iconbtn--on-warning:hover, .fx-iconbtn--on-primary:hover {
  color: #fff; filter: brightness(.96);
}

/* ---------------------------------------------------------------------
   Barra de filtros (.fx-filtros) — campos lado a lado, quebram em telas
   estreitas. Cada campo: <label class="fx-filtros__campo"><span>Rótulo</span>
   <select|input></label>. Ações em .fx-filtros__acoes (ficam à direita).
   Os <select> >5 itens viram Select2 sozinhos (initSelect2 do base.html).
   --------------------------------------------------------------------- */
.fx-filtros {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px;
  padding: 14px 16px; margin-bottom: 16px;
  background: var(--fx-surface); border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius); box-shadow: var(--fx-shadow);
}
.fx-filtros__campo { display: flex; flex-direction: column; gap: 4px; margin: 0; flex: 1 1 170px; min-width: 150px; max-width: 280px; }
.fx-filtros__campo--busca { flex: 2 1 260px; max-width: 420px; }
.fx-filtros__campo > span {
  font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--fx-muted);
}
.fx-filtros__campo input,
.fx-filtros__campo select {
  width: 100%; height: 38px; padding: 0 .7rem; font: inherit; font-size: .84rem; font-weight: 600;
  color: var(--fx-ink); background-color: var(--fx-surface);
  border: 1px solid var(--fx-line); border-radius: var(--fx-radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.fx-filtros__campo select:not([multiple]) {
  -webkit-appearance: none; appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a94ad' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
}
.fx-filtros__campo input:focus,
.fx-filtros__campo select:focus { outline: 0; border-color: var(--fx-primary); box-shadow: var(--fx-ring); }
.fx-filtros__campo .select2-container { width: 100% !important; }
.fx-filtros__campo .select2-container .select2-selection--single { height: 38px !important; border-radius: var(--fx-radius-sm) !important; }
.fx-filtros__acoes { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.fx-filtros__acoes .fx-btn { height: 38px; }
@media (max-width: 576px) {
  .fx-filtros__campo, .fx-filtros__campo--busca { max-width: none; flex-basis: 100%; }
  .fx-filtros__acoes { width: 100%; }
  .fx-filtros__acoes .fx-btn { flex: 1; justify-content: center; }
}

/* Campo avulso no padrão (fora de crispy/fx-form): <input|select|textarea class="fx-input"> */
.fx-input {
  width: 100%; min-height: 38px; padding: .4rem .7rem; font: inherit; font-size: .84rem;
  color: var(--fx-ink); background-color: var(--fx-surface);
  border: 1px solid var(--fx-line); border-radius: var(--fx-radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
textarea.fx-input { min-height: 80px; line-height: 1.45; }
select.fx-input:not([multiple]) {
  -webkit-appearance: none; appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a94ad' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
}
.fx-input:focus { outline: 0; border-color: var(--fx-primary); box-shadow: var(--fx-ring); }
.fx-input::placeholder { color: var(--fx-faint); }

/* Select2 com a mesma cara do .fx-input (filtros, ferramentas do cabeçalho e campos avulsos) */
select.fx-input + .select2-container .select2-selection--single,
.fx-filtros__campo .select2-container .select2-selection--single,
.fx-modhero__tools .select2-container .select2-selection--single {
  height: 38px !important; border: 1px solid var(--fx-line) !important; border-radius: var(--fx-radius-sm) !important;
  background: var(--fx-surface) !important; display: flex; align-items: center;
}
select.fx-input + .select2-container .select2-selection__rendered,
.fx-filtros__campo .select2-container .select2-selection__rendered,
.fx-modhero__tools .select2-container .select2-selection__rendered {
  line-height: 36px !important; padding-left: .7rem !important; font-size: .84rem; font-weight: 600; color: var(--fx-ink) !important;
}
select.fx-input + .select2-container .select2-selection__arrow,
.fx-filtros__campo .select2-container .select2-selection__arrow,
.fx-modhero__tools .select2-container .select2-selection__arrow { height: 36px !important; }
select.fx-input + .select2-container--focus .select2-selection--single,
.fx-filtros__campo .select2-container--focus .select2-selection--single,
.fx-modhero__tools .select2-container--focus .select2-selection--single { border-color: var(--fx-primary) !important; box-shadow: var(--fx-ring); }
.fx-modhero__tools .select2-container { min-width: 180px; }
.fx-modhero__tools select:not([multiple]) {
  height: 38px; padding: 0 2rem 0 .7rem; font: inherit; font-size: .84rem; font-weight: 600; color: var(--fx-ink);
  background: var(--fx-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a94ad' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right .7rem center;
  border: 1px solid var(--fx-line); border-radius: var(--fx-radius-sm); -webkit-appearance: none; appearance: none; cursor: pointer;
}

/* =====================================================================
   TIPS — ícone (i) azul que abre a dica ao passar o mouse, focar ou clicar
   <i class="fas fa-circle-info fx-tip" tabindex="0" data-tip="Texto"></i>  |  {% tip "Texto" %}
   NUNCA usar ::before no .fx-tip: é o slot do glifo do FontAwesome (apaga o ícone).
   O balão (.fx-tip-pop) é criado pelo static/js/fx-feedback.js no <body>.
   ===================================================================== */
.fx-tip {                 /* sempre um ícone FontAwesome: <i class="fas fa-circle-info fx-tip" data-tip> */
  color: var(--fx-primary); font-size: .85em; margin-left: .35rem; vertical-align: baseline;
  cursor: help; border-radius: 50%; transition: color .15s, box-shadow .15s, transform .15s;
}
.fx-tip:hover, .fx-tip:focus-visible, .fx-tip[aria-describedby] {
  color: var(--fx-primary-2); outline: none; box-shadow: var(--fx-ring); transform: scale(1.08);
}
.fx-tip-pop {
  position: fixed; z-index: 2000; max-width: min(320px, calc(100vw - 16px));
  padding: .55rem .75rem; border-radius: var(--fx-radius-sm);
  background: var(--fx-ink); color: #fff; box-shadow: var(--fx-shadow-md);
  font: 500 .78rem/1.45 var(--fx-font); letter-spacing: 0; text-transform: none; white-space: normal;
  opacity: 0; transform: translateY(-3px); pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
}
.fx-tip-pop--on { opacity: 1; transform: none; pointer-events: auto; }
.fx-tip-pop::after {
  content: ''; position: absolute; top: -5px; left: var(--fx-tip-seta, 50%);
  margin-left: -5px; border: 5px solid transparent; border-top: 0; border-bottom-color: var(--fx-ink);
}
.fx-tip-pop--acima::after { top: auto; bottom: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--fx-ink); }
/* help_text convertido em tip: some da tela, continua para leitor de tela */
.fx-tip-origem, [data-fx-tip="oculto"] { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html[data-theme="dark"] .fx-tip { color: #8ab4ff; }
html[data-theme="dark"] .fx-tip-pop { background: #f2f3f7; color: #1d1d1f; }
html[data-theme="dark"] .fx-tip-pop::after { border-bottom-color: #f2f3f7; }
html[data-theme="dark"] .fx-tip-pop--acima::after { border-bottom-color: transparent; border-top-color: #f2f3f7; }

/* lista de motivos nos avisos "Não foi salvo" (SweetAlert) */
.fx-swal-lista { text-align: left; margin: .5rem 0 0; padding-left: 1.1rem; font-size: .85rem; }
.fx-swal-lista li { margin: .15rem 0; }

/* ---- Tabela ordenável (static/js/fx-tabela-ordenavel.js): <table class="fx-table fx-sortable"> ---- */
table.fx-sortable thead th:not(.no-sort){cursor:pointer;user-select:none;white-space:nowrap}
table.fx-sortable thead th:not(.no-sort):hover{color:var(--fx-primary)}
table.fx-sortable thead th:not(.no-sort)::after{content:"\2195";margin-left:5px;font-size:.8em;opacity:.35}
table.fx-sortable thead th[aria-sort="ascending"]::after{content:"\2191";opacity:1;color:var(--fx-primary)}
table.fx-sortable thead th[aria-sort="descending"]::after{content:"\2193";opacity:1;color:var(--fx-primary)}
table.fx-sortable thead th:focus-visible{outline:2px solid var(--fx-ring);outline-offset:-2px}
