/* Portaria — layout do app.
 *
 * O alvo visual é o app original do Mitra (tenant_40951): fundo branco,
 * superfícies planas sem bordas/sombras, tipografia Inter, barra lateral
 * de 256px com grupos em Caixa Alta suave removida, tabelas com
 * cabeçalho cinza claro e linhas de 33px, e as duas barras do topo
 * (barra da plataforma + cabeçalho do tenant).
 *
 * As cores e o vocabulário vêm da própria definição capturada:
 * cards com ICONCOLOR/ICONBGCOLOR/CARDBGCOLOR, menu com headerLogo/
 * headerTitle/headerSubtitle e colunas com headerName em Caixa Baixa.
 */

/* ── fonte ─────────────────────────────────────────────────────────────── */

/* Inter variável (100–900) auto-hospedada: é a fonte que o app original
   aplica nos componentes do tenant (`font-family:Inter,system-ui,…` no
   CSS capturado). Os arquivos vêm do Google Fonts (v51) e são servidos
   daqui, sem depender de terceiros e sem bloquear a renderização —
   `font-display: swap` deixa o fallback desenhar enquanto o woff2 chega.
   Latin + latin-ext cobrem o pt-BR. O trunk copia `public/` para a raiz
   do build como `/public/…` (mesmo destino do definition.json).
   
   preload opcional: o browser pode pré-carregar a fonte com um link no
   HTML, mas como a fonte é pequena (~130KB) e o app não bloqueia a
   renderização por ela, o preload não é obrigatório. O critical rendering
   path (CSS → HTML → WASM) já é rápido. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(public/fonts/inter-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(public/fonts/inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #ececf0;
  --line-strong: #e2e5ea;
  --text: #111827;
  --text-soft: #4b5563;
  --text-muted: #6b7280;
  --text-faint: #9aa2b1;
  --accent: #111827;
  --accent-soft: #eef2ff;
  --brand: #1d4ed8;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  --row-h: 33px;
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* iOS/Android não podem ampliar o texto por conta própria. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* Rede de segurança universal: nenhuma imagem vaza do container. */
img { max-width: 100%; }

/* Navegação por teclado visível sem alterar o visual do mouse. */
:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

/* ── estrutura ─────────────────────────────────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  /* dvh acompanha a barra de endereço/mobile; vh é o fallback antigo. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Faixa de baixo: barra lateral + conteúdo, como no app original
   (`<div class="flex flex-1">`). */
.app-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
}

.content {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  /* safe-area: a base do iPhone fica sob a barra de gestos. */
  padding: 5px 0 calc(28px + env(safe-area-inset-bottom, 0px));
  min-height: 0;
  flex: 1;
  /* Container de consulta: `1cqw` = 1% da largura do conteúdo. O app
     original desenha os componentes num canvas de 1500 unidades escalado
     para a largura disponível — a mesma conta, em CSS. */
  container-type: inline-size;
  contain-intrinsic-size: 100% 100%;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* Cada faixa do canvas ocupa a altura do componente (em unidades de
   canvas) e começa onde a anterior termina.

   `min-height` em vez de `height`: em resolução baixa a altura
   proporcional fica menor que o conteúdo (cards, rótulos) e uma altura
   fixa recortava os contadores ao meio. Com min-height a faixa cresce
   para caber o que tem dentro — nada fica cortado. */
.screen-row {
  display: flex;
  content-visibility: auto;
  contain-intrinsic-size: 0 1px;
  min-width: 0;
  max-width: 100%;
  padding-left: calc(var(--x, 0) * 100% / var(--canvas, 1500));
  margin-top: calc(var(--mt, 0) * 100cqw / var(--canvas, 1500));
  height: auto;
  min-height: calc(var(--h, 0) * 100cqw / var(--canvas, 1500));
  overflow: visible;
}

/* A última faixa ocupa a altura restante (tabela/lista rolam por dentro). */
.screen-row.fill {
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  /* A faixa que rola ocupa o viewport e o lazy frame não ajuda. */
  content-visibility: visible;
}

.screen-cell {
  display: flex;
  min-width: 0;
  min-height: 0;
  width: calc(var(--w, 0) * 100% / var(--canvas, 1500));
  flex: none;
}

.screen-cell > .panel {
  flex: 1 1 auto;
  min-width: 0;
}

/* Recolhe a barra lateral no desktop (botão do cabeçalho). */
@media (min-width: 769px) {
  .app.sidebar-collapsed .sidebar { display: none; }
}

/* Foto da conta logada quando o tenant devolve `FOTO`. */
.avatar .avatar-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-initials { font-size: 11px; font-weight: 500; }

/* ── barra lateral ─────────────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 10px 11px;
  overflow: hidden;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: cover;
  background: #1f2937;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 500;
  font-size: 12px;
  overflow: hidden;
  flex: none;
}

.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-name {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
}
.brand-sub { color: var(--text-faint); font-size: 11px; margin-top: 1px; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-group {
  margin: 10px 8px 3px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-faint);
}

.nav-group:first-child { margin-top: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.nav-item.is-active {
  background: #f1f2f5;
  color: var(--text);
}

.nav-item .icon { color: currentColor; opacity: 0.8; }

.sidebar-footer {
  position: relative;
  border-top: 1px solid var(--line);
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 500;
  color: #334155;
  flex: none;
}

.user-meta { min-width: 0; flex: 1; }
.user-name, .user-mail {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-name { font-size: 11.5px; font-weight: 500; color: var(--text-soft); }
.user-mail { font-size: 10.5px; color: var(--text-faint); }

.user-menu-btn {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  padding: 3px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
}
.user-menu {
  position: absolute;
  bottom: 100%;
  right: 8px;
  margin-bottom: 4px;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 60;
}

.user-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 12.5px;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
}
/* ── cabeçalho da plataforma (1ª faixa do app original) ──────────────── */

/* O app original empilha duas faixas antes do conteúdo: a barra da
   plataforma (botão de menu + selo do condomínio + nome do app + botão
   "Remover cabeçalho" + avatar) e o cabeçalho do tenant (toggle, trilha e
   busca). As duas ocupam a largura toda. Medidas tiradas do DOM do app
   original em 1920px. */
.platform-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid #e7e8f0;
  flex: none;
}

/* "Remover cabeçalho" some com a barra da plataforma inteira. */
.app.no-platform-header .platform-header { display: none; }

/* Botão de menu da plataforma: 46×46 com o ícone de 20px encostado à
   esquerda (o `menu-divider` do original). */
.platform-menu {
  width: 46px;
  height: 46px;
  margin-left: -8px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #5d6585;
  cursor: pointer;
}

.platform-menu .icon { width: 20px; height: 20px; }

/* Selo do condomínio: quadrado roxo-claro com as iniciais em roxo. */
.platform-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 2px;
  border-radius: 7px;
  background: #ddbeff;
  color: #7839ee;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  flex: none;
}

.platform-title {
  font-size: 16px;
  font-weight: 500;
  color: #0e1428;
  white-space: nowrap;
}

.platform-remove {
  height: 28px;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: #313854;
  border-color: #c7cbdd;
  gap: 8px;
  border-radius: 8px;
}

.platform-remove .icon { width: 16px; height: 16px; color: #313854; }

.platform-avatar {
  width: 24px;
  height: 24px;
}

/* ── barra superior (cabeçalho do original: toggle, trilha e busca) ─── */

.topbar {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 16px;
  height: 50px;
  background: var(--surface);
  border-bottom: 1px solid #e2e8f0;
  flex: none;
}

/* Toggle da barra lateral: no original o ícone mede 14px desenhados. */
.sidebar-toggle { padding: 0; }
.sidebar-toggle .icon { width: 19px; height: 19px; }

.topbar-sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  flex: none;
  margin-right: 4px;
}

.crumb-group { color: #64748b; }
.crumb-sep { color: #64748b; display: inline-flex; }
.crumb-sep .icon { width: 14px; height: 14px; }

/* Pill "Search..." do cabeçalho: abre a busca global do menu (Ctrl+K). */
.search-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  height: 32px;
  width: 256px;
  max-width: 42vw;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
}

.search-pill .icon { width: 15px; height: 15px; }

.search-pill:hover { background: #f6f7f9; }

/* Diálogo de busca do menu (cmd-k). */
.cmdk {
  width: min(560px, 92vw);
  padding: 0;
  overflow: hidden;
}

.cmdk-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
}

.cmdk-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
}

.cmdk-list {
  max-height: min(52vh, 440px);
  overflow: auto;
  padding: 8px;
}

.cmdk-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 6px 8px;
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.cmdk-item:hover { background: #f6f7f9; }

.cmdk-empty {
  padding: 14px 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 13px;
  color: #64748b;
  font-size: 13px;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
}

.crumbs .current {
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* No topbar do original só vai o avatar (sem nome/e-mail): o espaço é da
   busca. */
.topbar .user-meta { display: none; }
.topbar .sidebar-footer { border: 0; padding: 0; gap: 8px; }

.topbar-spacer { flex: 1; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  min-width: 220px;
  color: var(--text-muted);
}

.search input {
  border: 0;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 12.5px;
  color: var(--text);
}

.search input::placeholder { color: var(--text-faint); }

/* ── cards ─────────────────────────────────────────────────────────────── */

/* No original os cards são uma linha horizontal (`cg-horizontal`):
   dividem a largura igualmente (gap 16px) e o conteúdo trunca em vez de
   quebrar linha. Medidas tiradas do DOM do app original: card 525×121,
   padding 24px, raio 12px, ícone 40px com raio 8px, rótulo 14px/20px
   #667085 e valor 24px/700 #111827. */
.cards {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  align-items: flex-start;
  /* Ocupa a largura do componente do canvas (a faixa define a altura). */
  flex: 1 1 auto;
  min-width: 0;
}

.card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex: 1 1 0;
  min-width: 0;
  /* Recuo interno do card no original (`cg-header`): 24px em volta. */
  padding: 24px;
  background: #fff;
  border: 0;
  border-radius: 12px;
  box-shadow: none;
  overflow: hidden;
}

/* Em resolução baixa a faixa do canvas (altura proporcional à largura,
   `--h * 100cqw / canvas`) fica menor que o conteúdo do card e o contador
   era cortado. A partir de 640px de largura de conteúdo o card quebra o
   número para a linha de baixo do rótulo e a faixa cresce para caber —
   nada fica fora da vista (corte por overflow escondido). */
@container (max-width: 640px) {
  .card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }
  .card-label,
  .card-value {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .card-value {
    font-size: 20px;
  }
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
}

.card-icon .icon { width: 24px; height: 24px; }

.card-body { min-width: 0; }

.card-label {
  color: #667085;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── painéis / tabelas ─────────────────────────────────────────────────── */

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0;
}

/* A tabela do original abre com o título ~30px abaixo do topo do
   componente (a folga interna do componente de tabela do tenant). */
.table-panel { padding-top: 30px; }

.panel-title { font-size: 16px; font-weight: 600; margin: 0; color: var(--text); }
.panel-subtitle { color: var(--text-muted); font-size: 13px; margin: 6px 0 0; }
.panel-head .spacer { flex: 1; }

.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 16px;
}

.panel-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 36px;
  width: 450px;
  max-width: 100%;
  color: var(--text-muted);
  background: var(--surface);
}

.panel-search input {
  border: 0;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 12.5px;
}

.panel-search input::placeholder { color: var(--text-faint); }

.table-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  flex: 1;
}

table.grid-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  /* Colunas de largura igual, como no componente de tabela do tenant. */
  table-layout: fixed;
}

.grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fcfcfc;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
  text-align: left;
  padding: 8px 9px;
  white-space: nowrap;
}

.grid-table tbody td {
  height: var(--row-h);
  padding: 0 9px;
  border-bottom: 1px solid #f0f1f4;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
}

.grid-table tbody tr:last-child td { border-bottom: 0; }

.grid-table th.actions,
.grid-table td.actions {
  text-align: center;
  white-space: nowrap;
}

/* ── filtro por coluna (estilo Excel) ────────────────────────────────── */

/* Cabeçalho com o funil no canto direito: o mesmo lugar do botão de filtro
   do Excel, que fica visível quando a coluna está em uso. */
.grid-th { padding: 0; }

.grid-th-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 8px 9px;
  height: 100%;
}

.grid-th-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-filter-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0.65;
  transition: background 120ms ease, color 120ms ease, opacity 120ms ease;
}

.grid-filter-btn:hover {
  background: #eef0f4;
  color: var(--text-soft);
  opacity: 1;
}

.grid-filter-btn:focus-visible { outline-offset: 0; }

.grid-filter-icon { display: grid; place-items: center; }
.grid-filter-icon .icon { width: 15px; height: 15px; }
.grid-filter-icon.active { color: var(--brand); }

/* O menu do filtro vive no `body` (portal) para não ser cortado pelo
   scroll da tabela — por isso é `fixed`. */
.filter-menu {
  position: fixed;
  z-index: 60;
  width: 268px;
  max-width: calc(100vw - 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
  font-size: 12.5px;
  color: var(--text);
}

.filter-menu-sorts {
  display: flex;
  gap: 6px;
}

.filter-sort {
  flex: 1 1 0;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
}

.filter-sort:hover { background: var(--surface-2); color: var(--text); }

.filter-menu-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.filter-menu-search input {
  border: 0;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 12.5px;
  color: var(--text);
}

.filter-menu-list {
  max-height: 232px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.filter-item:hover { background: var(--surface-2); }
.filter-item span { overflow: hidden; text-overflow: ellipsis; }
.filter-item input { accent-color: var(--brand); margin: 0; }
.filter-item-all { border-bottom: 1px solid var(--line); margin-bottom: 2px; }

.filter-menu-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-clear {
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
}

.filter-clear:hover { background: var(--surface-2); color: var(--text); }
.filter-count { color: var(--text-faint); font-size: 11.5px; }

.cell-empty { color: var(--text-faint); }

/* Filtro que removeu todas as linhas: a tabela continua na tela (com os
   funis e a ordenação) e a mensagem ocupa a largura toda. */
.grid-filter-empty td {
  height: auto;
  padding: 0;
  border-bottom: 0;
  white-space: normal;
  text-align: center;
}

.grid-filter-empty .empty { padding: 28px 16px; }
.grid-filter-empty .btn { margin-top: 4px; }

/* ── paginação ────────────────────────────────────────────────────────── */

/* Barra no rodapé da tabela: quantas linhas estão na tela, o tamanho da
   página e a navegação (primeira / anterior / números / próxima / última). */
.grid-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
  padding: 10px 0 2px;
  border-top: 1px solid var(--line);
}

.grid-pager-info {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.grid-pager-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}

.grid-pager-size {
  height: 28px;
  margin-right: 6px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
}

.grid-page-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.grid-page-btn .icon { width: 15px; height: 15px; }

.grid-page-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

.grid-page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.grid-page-gap {
  min-width: 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  user-select: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

/* ── listas (Pretty List) ──────────────────────────────────────────────── */

/* Busca + botão "Adicionar" na mesma linha, como no componente original. */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 4px;
}

.list-toolbar .list-search {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
  overflow: auto;
  min-height: 0;
  flex: 1;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.list-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}

.list-body { min-width: 0; flex: 1; }
.list-title { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── botões ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 400;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.ghost { border-color: transparent; background: transparent; color: var(--text-soft); }

.btn.icon-only { padding: 5px; border-color: transparent; background: transparent; color: var(--text-muted); }

.btn.sm { padding: 6px 10px; font-size: 12px; }

/* ── estados ───────────────────────────────────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 36px 16px;
  color: var(--text-muted);
  text-align: center;
}

.empty strong { color: var(--text-soft); font-weight: 500; }

.skeleton {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 50%, #eef1f5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #7f1d1d;
}

/* ── modal / formulário ────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  width: min(680px, 100%);
  max-height: min(86vh, 780px);
  max-height: min(86dvh, 780px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-title { font-size: 14px; font-weight: 500; margin: 0; }
.modal-sub { font-size: 11.5px; color: var(--text-muted); margin: 2px 0 0; }

.modal-body {
  padding: 16px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 400; color: var(--text-soft); }
.field .req { color: var(--danger); }

.field input, .field select, .field textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
  outline: none;
  font-size: 12.5px;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

.field textarea { min-height: 76px; resize: vertical; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 12.5px;
  z-index: 60;
}

.toast.error { background: #7f1d1d; }

/* ── responsivo (sidebar recolhida + barra superior, como no original) ── */

.sidebar-toggle { display: inline-flex; }

@media (max-width: 768px) {
  .app-body { flex-direction: column; }
  .crumb-group, .crumb-sep { display: none; }
  .search-pill { width: auto; min-width: 0; flex: 1; max-width: none; }
  .platform-remove { display: none; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    max-width: 85vw;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 160ms ease;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .topbar {
    display: flex;
    /* o notch em retrato não pode cobrir a barra (viewport-fit=cover). */
    height: calc(48px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }
  .content {
    padding: 14px 14px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .search { min-width: 0; flex: 1; }
  .panel-search { width: 100%; }
  /* iOS dá zoom automático em inputs < 16px: aqui o zoom fica 1.0. */
  .panel-search input,
  .search input,
  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
  }
  /* Tabela estreita vira rolagem horizontal, como no original em celular. */
  .grid-table { min-width: 560px; }
  /* Paginação empilha: informação em cima, botões embaixo. */
  .grid-pager { flex-direction: column; align-items: stretch; }
  .grid-pager-controls { justify-content: center; flex-wrap: wrap; }
  .cards { gap: 10px 12px; }
  .screen { gap: 12px; }
  /* Modal vira folha presa à base (alcance de polegar + safe-area). */
  .overlay {
    padding: 0;
    place-items: end stretch;
  }
  .modal {
    width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: 14px 14px 0 0;
  }
  .modal-body {
    grid-template-columns: 1fr;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .modal-foot {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* Rodapé do app: presente em toda a aplicação; fica abaixo do conteúdo
   no arquivo baixe (content) e no final do corpo no mobile quando o conteúdo
   é curto. O nome e o telefone são em destaque (negrito). */
.app-footer {
  margin: 0 4px 4px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12.5px;
}
.app-footer .footer-strong { font-weight: 700; color: var(--text); }

@media (max-width: 560px) {
  .app-footer { text-align: center; }
}

/* Alvos de toque generosos apenas quando o ponteiro é de fato tátil — o
   visual de desktop permanece intacto. */
@media (pointer: coarse) {
  .nav-item { padding: 9px 8px; min-height: 40px; }
  .btn { min-height: 38px; }
  .btn.sm { min-height: 34px; }
  .btn.icon-only { padding: 9px; }
  .user-menu-btn { padding: 8px; }
  .user-menu button { padding: 10px 8px; }
  .list-row { padding: 11px 10px; }
}

/* Hover só onde existe hover de verdade: no toque o estado "grudado" do
   :hover é um artefato feio. */
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover { background: #f6f7f9; color: var(--text); }
  .user-menu-btn:hover { background: #f3f4f6; color: var(--text-soft); }
  .user-menu button:hover { background: #f6f7f9; color: var(--text); }
  .grid-table tbody tr:hover td { background: #fafbfc; }
  .list-row:hover { background: #fafbfc; }
  .btn:hover { background: #f6f7f9; border-color: #d3d8e0; }
  .btn.primary:hover { background: #1f2937; }
  .btn.ghost:hover { background: #f3f4f6; }
  .btn.icon-only:hover { background: #f3f4f6; color: var(--text); }
  .btn.icon-only.danger:hover { background: #fef2f2; color: var(--danger); }
  .grid-page-btn:hover:not(:disabled) { background: #f6f7f9; color: var(--text); }
}

/* Celulares em deitado e telas curtas: barra e respiros menores. */
@media (max-height: 500px) and (max-width: 940px) {
  .topbar { height: calc(42px + env(safe-area-inset-top, 0px)); }
  .content { padding-top: 10px; }
  .panel-toolbar { padding: 6px 0; }
}

/* Telas grandes (2K/4K/ultrawide): o canvas do tenant escala junto com a
   largura, então só o respiro inferior muda. */
@media (min-width: 1600px) {
  .content { padding-bottom: 36px; }
}

/* Respeita a preferência do sistema por menos movimento. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .skeleton { animation: none; background: #eef1f5; }
}

/* ── Portão de PIN (primeiro acesso) ──────────────────────────────────── */
.pin-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(37, 99, 235, 0.08), transparent 60%),
    #f6f7f9;
}
.pin-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.10);
  padding: 28px 28px 20px;
  text-align: center;
}
.pin-title {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
.pin-dots {
  display: flex;
  gap: 7px;
  justify-content: center;
  margin-bottom: 22px;
}
.pin-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent, #2563eb);
  animation: pin-pulse 1s ease-in-out infinite;
}
.pin-dots span:nth-child(2) { animation-delay: 0.18s; }
.pin-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes pin-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1); }
}
.pin-callout {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.pin-label {
  display: block;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft, #6b7280);
  margin-bottom: 6px;
}
.pin-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #d9dee6;
  border-radius: 10px;
  font-size: 16px;
  letter-spacing: 0.28em;
  text-align: left;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pin-input::placeholder { letter-spacing: normal; color: #9aa3b2; }
.pin-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}
.pin-submit {
  width: 100%;
  height: 42px;
  margin-top: 14px;
  border: none;
  border-radius: 10px;
  background: var(--text, #111827);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.pin-submit:hover { background: #1f2937; }
.pin-submit:active { transform: scale(0.985); }
.pin-error {
  display: block;
  min-height: 18px;
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--danger, #dc2626);
}
.pin-error.is-idle { visibility: hidden; }
.pin-hint {
  margin: 2px 0 0;
  font-size: 12px;
  color: #6b7280;
}

/* Celular: o cartão ocupa a largura disponível. */
@media (max-width: 480px) {
  .pin-gate { padding: 16px; align-items: flex-start; padding-top: 15vh; }
  .pin-card { border-radius: 14px; padding: 22px 20px 16px; }
}
