/* ==========================================================================
   AutoAgenda — Folha de estilo única. CSS puro, sem framework.

   Mesma paleta e os mesmos componentes do FitMulti (a marca #ff5722, a
   sidebar recolhível, cards, tabelas, badges e modais) — de propósito: os
   dois sistemas são do mesmo fornecedor e precisam parecer a mesma família.
   As cores podem ser sobrescritas em Configurações > Cores, que injeta as
   variáveis de :root no <head> (ver App\Support\Branding::themeTag).
   ========================================================================== */

:root {
  --bg:          #0f1115;
  --surface:     #171a21;
  --surface-2:   #1f232c;
  --border:      #2a2f3a;
  --text:        #e6e8ee;
  --text-muted:  #9aa3b2;
  --brand:       #ff5722;
  --brand-soft:  rgba(255, 87, 34, .14);
  --ok:          #22c55e;
  --ok-soft:     rgba(34, 197, 94, .14);
  --warn:        #f59e0b;
  --warn-soft:   rgba(245, 158, 11, .14);
  --danger:      #ef4444;
  --danger-soft: rgba(239, 68, 68, .14);
  --radius:      10px;
  --shadow:      0 6px 24px rgba(0, 0, 0, .35);
  --font:        system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==========================================================================
   Layout administrativo + sidebar recolhível
   ========================================================================== */
:root { --sidebar-w: 248px; --sidebar-w-collapsed: 68px; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
/* Recolhido: só os ícones. A classe vive no <html>, aplicada antes da pintura. */
html.is-collapsed .layout { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ---------- Marca ---------- */
.sidebar-head { padding: 4px 6px 16px; }
.logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 9px;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 17px;
}
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: -.4px; white-space: nowrap; }
.logo-text span { color: var(--brand); }
.logo-img { height: 32px; width: auto; max-width: 180px; object-fit: contain; flex-shrink: 0; }
/* Logotipo do cliente na sidebar (ver layouts/app.php) — troca pro "A"
   quadrado só quando a sidebar está recolhida (ícone-only), porque o
   logotipo enviado pode ser bem mais largo que os 32px do trilho de ícones. */
.logo-mark-recolhido { display: none; }
html.is-collapsed .logo-mark-recolhido { display: grid; }
html.is-collapsed .logo-img-expandido { display: none; }
/* Recolhido, encolhe para caber na trilha de ícones em vez de sumir. */
html.is-collapsed .logo-img { height: 28px; max-width: 36px; }

/* ---------- Itens ---------- */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 11px; border-radius: 9px;
  color: var(--text-muted); font-size: 14px; font-family: inherit;
  background: none; border: 0; cursor: pointer; text-align: left;
  text-decoration: none; position: relative;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

/* Ícones herdam a cor do item — nenhum tem cor própria. */
.nav-link .icon { flex-shrink: 0; opacity: .85; }
.nav-link:hover .icon,
.nav-link.active .icon { opacity: 1; }

.nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
/* Barra de destaque do item ativo */
.nav-link.active::before {
  content: ''; position: absolute; left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0;
  background: var(--brand);
}

.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Submenus (accordion) ---------- */
.nav-caret {
  flex-shrink: 0; opacity: .6;
  transition: transform .18s ease;
}
.nav-section.open > .nav-toggle .nav-caret { transform: rotate(90deg); }
.nav-section.open > .nav-toggle { color: var(--text); }

.nav-sub {
  display: grid;
  grid-template-rows: 0fr;            /* animação de altura sem JS medir nada */
  transition: grid-template-rows .2s ease;
  margin-left: 21px;
  border-left: 1px solid var(--border);
  padding-left: 7px;
}
.nav-section.open > .nav-sub { grid-template-rows: 1fr; }

/**
 * Filho ÚNICO, obrigatoriamente. `grid-template-rows: 0fr` dimensiona só a
 * primeira linha; qualquer irmão vira linha implícita `auto` e o submenu não
 * fecha nunca. O min-height:0 permite o colapso e o overflow:hidden esconde o
 * conteúdo durante a transição.
 */
.nav-sub-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-sub-title { display: none; }     /* só aparece no flyout do modo recolhido */

/* Navegadores que não animam 0fr: alterna display, sem transição. */
@supports not (grid-template-rows: 0fr) {
  .nav-sub { display: none; }
  .nav-section.open > .nav-sub { display: block; }
}

.nav-child { font-size: 13.5px; padding: 8px 10px; }
.nav-child.active::before { left: -8px; height: 16px; }

/* ---------- Botão de recolher ---------- */
.sidebar-collapse { margin-top: 8px; flex-shrink: 0; }
html.is-collapsed .sidebar-collapse .icon { transform: scaleX(-1); }

.topbar-burger {
  display: none;
  background: none; border: 0; cursor: pointer;
  color: var(--text-muted); padding: 6px; border-radius: 8px;
}
.topbar-burger:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Estado recolhido ---------- */
/**
 * `overflow: visible` é obrigatório aqui. Com o overflow-y:auto do estado
 * expandido, tooltips e flyouts posicionados em `left: 100%` são recortados
 * pela própria sidebar e nunca aparecem.
 *
 * Trocar o scroll por visible é seguro neste estado: recolhida a sidebar tem
 * só ícones (~350px de altura), e abaixo de 900px ela vira gaveta.
 */
html.is-collapsed .sidebar { padding: 14px 10px; overflow: visible; }
html.is-collapsed .logo-text,
html.is-collapsed .nav-label,
html.is-collapsed .nav-caret { display: none; }
html.is-collapsed .nav-link { justify-content: center; padding: 10px; }
html.is-collapsed .nav-link.active::before { left: -10px; }

/* Recolhido, o submenu vira flyout no hover — não empurra o layout. */
html.is-collapsed .nav-sub {
  position: absolute; left: 100%; top: 0; z-index: 60;
  display: block; grid-template-rows: none;
  min-width: 208px; margin-left: 6px; padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateX(-6px);
  transition: opacity .14s, transform .14s, visibility .14s;
}
/* No flyout a altura é livre: o wrapper não pode mais cortar o conteúdo. */
html.is-collapsed .nav-sub-inner { overflow: visible; min-height: auto; }
html.is-collapsed .nav-section { position: relative; }

/**
 * Ponte invisível sobre o vão de 6px entre o ícone e o flyout. Sem ela o mouse
 * sai do .nav-section ao atravessar o espaço, o hover cai e o menu pisca —
 * torna impossível alcançar os itens.
 *
 * Fica no .nav-section, não no .nav-sub: o flyout tem overflow-y:auto e
 * recortaria um pseudo-elemento posicionado fora do seu box.
 *
 * pointer-events só no hover — do contrário esta faixa de 12px ficaria
 * permanentemente sobre o conteúdo, engolindo cliques ao lado do menu.
 */
html.is-collapsed .nav-section::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 100%;
  width: 12px;
  pointer-events: none;
}
html.is-collapsed .nav-section:hover::after,
html.is-collapsed .nav-section:focus-within::after { pointer-events: auto; }

html.is-collapsed .nav-section:hover > .nav-sub,
html.is-collapsed .nav-section:focus-within > .nav-sub {
  opacity: 1; visibility: visible; transform: translateX(0);
}

/* Grupo do rodapé não pode empurrar o flyout para fora da tela. */
html.is-collapsed .nav-sub {
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  scrollbar-width: thin;
}
html.is-collapsed .nav-sub-title {
  display: block; padding: 4px 10px 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
html.is-collapsed .nav-child { justify-content: flex-start; padding: 8px 10px; }
html.is-collapsed .nav-child .nav-label { display: block; }

/* Tooltip dos itens simples quando recolhido.
   Os grupos ficam de fora: neles o próprio flyout já mostra o nome no título. */
html.is-collapsed .nav-link[data-tip]:not(.nav-toggle)::after {
  content: attr(data-tip);
  position: absolute; left: 100%; top: 50%; transform: translate(-6px, -50%);
  margin-left: 10px; padding: 6px 10px; z-index: 70;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 12.5px; font-weight: 400; white-space: nowrap;
  box-shadow: var(--shadow); pointer-events: none;
  opacity: 0; visibility: hidden;
  /* Atraso na entrada evita tooltip piscando ao varrer o menu de cima a baixo;
     na saída some na hora. */
  transition: opacity .12s, transform .12s, visibility .12s;
  transition-delay: 0s;
}
html.is-collapsed .nav-link[data-tip]:not(.nav-toggle):hover::after,
html.is-collapsed .nav-link[data-tip]:not(.nav-toggle):focus-visible::after {
  opacity: 1; visibility: visible; transform: translate(0, -50%);
  transition-delay: .35s;
}

.sidebar-backdrop { display: none; }

/* ---------- Conteúdo ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.content { padding: 24px; flex: 1; }

/* ---------- Seletor de unidade (Admin) ----------------------------------- */
.unit-switch {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px;
}
.unit-switch label { font-size: 12px; color: var(--text-muted); }
.unit-switch select {
  background: transparent; border: 0; color: var(--text);
  font-size: 14px; font-weight: 600; outline: none; cursor: pointer;
}
.unit-switch select option { background: var(--surface-2); }

/* ---------- Cartões e KPIs ----------------------------------------------- */
/* gap real (era 1px): passa despercebido entre .card — que já tem margin
   próprio — mas grids de campo (ex.: "Local do Atendimento" em Ordens de
   Serviço, cols-4 de .field direto) dependiam só desse gap pra separar as
   colunas, então ficavam praticamente coladas horizontalmente. */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
/*
 * Catálogos de cards com quantidade variável (vitrine de serviços) — com
 * auto-fit, menos itens que colunas na última linha faz o(s) card(s)
 * sobrarem ESTICADOS pra ocupar a linha inteira (ex.: 1 serviço numa
 * categoria vira um card gigante). auto-fill mantém as colunas "fantasmas"
 * vazias em vez de colapsá-las, então o card fica do tamanho normal e só
 * sobra espaço em branco ao lado — comportamento de catálogo de produtos.
 */
.grid.catalogo { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin: 10px;
  /* Sem isso, um item de grid não encolhe abaixo do min-content do que tem
     dentro — uma tabela larga (célula com texto que não quebra, tipo
     "Instalação Portão Deslizante") empurrava o card (e a página inteira)
     pra fora da tela no celular, em vez de só rolar de lado dentro do
     próprio .table-wrap (que já tem overflow-x:auto, mas não adianta se o
     pai nunca deixa encolher até precisar dele). */
  min-width: 0;
}
.card h2, .card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }

/* ---------- Cards de Ordem de Serviço (listagem admin + "Minhas OS" do
   técnico) — mesmo componente nas duas telas, daí ficar aqui global em vez
   de duplicado/inline em cada view. ---------- */

   /* Mobile-first: 1 coluna por padrão, mais colunas conforme a tela cresce
      (ver breakpoints logo abaixo) — evita cards de OS espremidos demais
      em tablet/notebook só porque a régua antiga pulava direto pra 4
      colunas a partir de 768px (largura típica de tablet em retrato, onde
      4 colunas de ~170px não cabem nem o rótulo "Cliente:"). */
   .os-tecnico-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

.os-tecnico-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: all .2s ease;
  /* Mesma razão do min-width:0 em .card: sem isso, um nome comprido sem
     quebra (cliente/técnico com nome de empresa gigante, por exemplo) força
     o card — e a coluna inteira do grid — a crescer além do espaço
     disponível, desproporcional aos cards vizinhos e vazando pra fora da
     tela no celular, em vez de truncar com reticências. */
  min-width: 0;
}
.os-tecnico-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }

.os-tecnico-card-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.os-tecnico-numero { font-weight: 700; font-size: 14px; }
.os-tecnico-numero a { color: var(--brand); text-decoration: none; }
.os-tecnico-numero a:hover { text-decoration: underline; }

/* Cabeçalho "checkbox + avatar + nome" (técnicos/clientes/gerentes) — o
   nome trunca com reticências em vez de esticar o card; min-width:0 nos
   dois níveis (label E strong) é o que de fato deixa o flex encolher: só
   no <strong> não bastaria, o <label> pai também precisa abrir mão do
   min-content padrão do flexbox. */
.os-tecnico-card-header > label { min-width: 0; }
.os-tecnico-card-header > label strong {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.os-tecnico-card-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.os-tecnico-cliente, .os-tecnico-servico, .os-tecnico-data, .os-tecnico-endereco,
.os-tecnico-tecnico, .os-tecnico-valor {
  font-size: 13px; color: var(--text); line-height: 1.4;
}
.os-tecnico-cliente strong { color: var(--text); }

.os-tecnico-maps { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.os-tecnico-maps a { color: var(--brand); text-decoration: none; }
.os-tecnico-maps a:hover { text-decoration: underline; }

.os-tecnico-card-footer {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.os-tecnico-card-footer .btn { font-size: 12px; padding: 6px 10px; flex: 1 1 calc(50% - 3px); min-width: 0; }

/* celular grande / tablet retrato */
@media (min-width: 640px) {
  .os-tecnico-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
/* notebook / desktop pequeno */
@media (min-width: 1024px) {
  .os-tecnico-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .os-tecnico-card-footer .btn { flex: 1 1 auto; min-width: 80px; }
}
/* desktop grande */
@media (min-width: 1440px) {
  .os-tecnico-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

/* Alterna tabela (desktop/tablet) x cards (celular) numa mesma listagem —
   usado quando a tabela tem colunas demais pra caber legível no celular mas
   o padrão de card-em-toda-tela (como em Técnicos/Clientes/Serviços) não é
   o que foi pedido pra essa página específica. */
.table-desktop-only { display: block; }
.cards-mobile-only { display: none; }
@media (max-width: 639px) {
  .table-desktop-only { display: none; }
  .cards-mobile-only { display: block; }
}

/* Campos editáveis direto na listagem (ex.: Regiões) — sem borda até o
   usuário passar o mouse/focar, pra não parecer um formulário cheio de
   caixinhas no meio da tabela. */
.regiao-campo-inline { border-radius: 6px; }
.regiao-campo-inline:hover { border-color: var(--border) !important; }
.regiao-campo-inline:focus { border-color: var(--brand) !important; outline: none; }

/* ---------- Painel "Indicações" (cliente) ---------- */
.indicacao-hero {
  position: relative; overflow: hidden; border-radius: var(--radius);
  padding: 28px 24px; margin-bottom: 16px; color: #fff;
  background: linear-gradient(135deg, var(--brand), #2a1608);
}
.indicacao-hero h2 { color: #fff; margin: 0 0 4px; font-size: 15px; font-weight: 600; opacity: .9; }
.indicacao-hero-numero { font-size: 40px; font-weight: 800; line-height: 1.1; margin-bottom: 12px; }
.indicacao-hero-numero small { font-size: 18px; font-weight: 600; opacity: .85; }
.indicacao-hero .wizard-progress-bar { background: rgba(255,255,255,.25); }
.indicacao-hero .wizard-progress-fill { background: #fff; }
.indicacao-hero-legenda { margin: 10px 0 0; font-size: 13px; opacity: .9; }

.indicacao-creditos-banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-radius: var(--radius); margin-bottom: 16px;
  background: var(--ok-soft); border: 1px solid var(--ok);
}
.indicacao-creditos-banner strong { color: var(--ok); }

.indicacao-link-row { display: flex; gap: 8px; flex-wrap: wrap; }
.indicacao-link-row input {
  flex: 1; min-width: 220px; font-family: monospace; font-size: 13px;
  background: var(--surface-2); color: var(--text-muted);
}

.indicacao-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.indicacao-stat-tile { padding: 16px; text-align: center; }
.indicacao-stat-tile .numero { font-size: 26px; font-weight: 800; }
.indicacao-stat-tile .rotulo { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Cards de KPI do Dashboard — classe própria (não .grid.cols-4)
   porque essa classe genérica colapsa direto pra 1 coluna em qualquer tela
   ≤900px (bom pra grids de formulário, ruim aqui: tablet ficaria igual ao
   celular, empilhando ~13 cards pequenos à toa). ---------- */
.dashboard-kpis { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 16px; }
.dashboard-kpis .card { margin: 0; }
@media (min-width: 480px) {
  .dashboard-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .dashboard-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .dashboard-kpis { grid-template-columns: repeat(4, 1fr); }
}

.kpi .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .05em; }
.kpi .value { font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 6px; }
.kpi .hint  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi.ok     .value { color: var(--ok); }
.kpi.warn   .value { color: var(--warn); }
.kpi.danger .value { color: var(--danger); }

/* ---------- Abas (Configurações) ------------------------------------------ */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px; flex-wrap: wrap;
}
.tab-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Abas DENTRO de um modal (ex.: modal "Adicionar banner") — classe própria
   de propósito: reaproveitar .tab-btn/.tab-panel faria o JS genérico de abas
   da página (document.querySelectorAll('.tab-btn')) mexer nas duas abas ao
   mesmo tempo, fechando a aba de Configurações que estava aberta por trás. */
.modal-tab-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.modal-tab-btn:hover { color: var(--text); }
.modal-tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.modal-tab-panel { display: none; }
.modal-tab-panel.active { display: block; }

/* ---------- Formulário em passos (site público, /solicitacao) ------------- */
.wizard { max-width: 640px; margin: 0 auto; }
.wizard-progress { margin-bottom: 20px; }
.wizard-progress-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.wizard-progress-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .25s ease; }
.wizard-progress-label { margin: 8px 0 0; font-size: 13px; font-weight: 600; color: var(--text-muted); text-align: center; }
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.wizard-step h2 { font-size: 18px; }
.wizard-step-hint { color: var(--text-muted); font-size: 13px; margin: -8px 0 16px; }
.wizard-login-hint {
  text-align: center; font-size: 13px; color: var(--text-muted);
  margin: -8px 0 16px; max-width: 640px; margin-left: auto; margin-right: auto;
}
.wizard-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; }
.wizard-nav .btn { min-width: 130px; }
@media (max-width: 480px) {
  .wizard-nav { flex-direction: column-reverse; }
  .wizard-nav .btn { width: 100%; }
}

/* ---------- Filtro de serviços (site público, /nossos-servicos) ----------- */
/*
 * Mobile-first de propósito (ao contrário de .toolbar/.toolbar-form, que são
 * desktop-first com um ajuste pra celular por cima): só 2 campos aqui, então
 * dá pra ir direto para o layout empilhado — busca, categoria e o botão
 * "Filtrar" cada um em largura cheia, alvos de toque grandes. A partir de
 * 640px vira uma linha só, como no admin.
 */
.servicos-filtro { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.servicos-filtro-campos { display: flex; flex-direction: column; gap: 12px; }
.servicos-filtro-campos .field { flex: 1 1 auto; }
.servicos-filtro-campos input,
.servicos-filtro-campos select { width: 100%; }
.servicos-filtro-acoes { display: flex; gap: 8px; }
.servicos-filtro-btn { width: auto; flex: 1 1 0; } /* Filtrar + Limpar dividem a linha igualmente no celular */
@media (min-width: 640px) {
  .servicos-filtro { flex-direction: row; align-items: center; }
  .servicos-filtro-campos { flex-direction: row; flex: 1; }
  .servicos-filtro-acoes { flex-shrink: 0; }
  .servicos-filtro-btn { flex: 0 0 auto; }
}

/* ---------- Slider de banners (site público) ------------------------------ */
.banner-slider { position: relative; }
.banner-slider-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-behavior: smooth; border-radius: var(--radius);
  -ms-overflow-style: none; scrollbar-width: none;
}
.banner-slider-track::-webkit-scrollbar { display: none; }
.banner-slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always; }
.banner-slider-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 22px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.banner-slider-arrow:hover { background: rgba(0, 0, 0, .7); }
.banner-slider-arrow.prev { left: 10px; }
.banner-slider-arrow.next { right: 10px; }
.banner-slider-dots {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px;
}
.banner-slider-dot {
  width: 8px; height: 8px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(255, 255, 255, .5); cursor: pointer;
  transition: background .15s, transform .15s;
}
.banner-slider-dot.active { background: #fff; transform: scale(1.3); }

/* ---------- Slider de depoimentos/avaliações (home do site público) ------
   Mesmo mecanismo do slider de banners acima (scroll-snap + JS), mas com
   vários cards visíveis por "página" em vez de 1 só — 4 no desktop, 1 no
   celular (breakpoint em 900px, igual ao resto do painel/site). ---------- */
.avaliacoes-slider { position: relative; }
.avaliacoes-track {
  display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-behavior: smooth; padding-bottom: 4px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.avaliacoes-track::-webkit-scrollbar { display: none; }
.avaliacao-slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always; }
.avaliacao-card { height: 100%; margin: 0; position: relative; overflow: hidden; }
@media (min-width: 900px) {
  .avaliacao-slide { flex: 0 0 calc(25% - 12px); }
}

/* Seção com fundo destacado (não é só mais um bloco branco na página) —
   objetivo é chamar atenção e passar confiança antes do visitante virar
   cliente, com a nota média em destaque logo no topo. */
.depoimentos-secao {
  background: linear-gradient(180deg, var(--brand-soft), transparent 70%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px 20px; margin: 32px 0;
}
.depoimentos-header { text-align: center; max-width: 560px; margin: 0 auto 24px; }
.depoimentos-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  padding: 5px 12px; border-radius: 999px; letter-spacing: .02em; margin-bottom: 12px;
}
.depoimentos-header h2 { font-size: 24px; margin: 0 0 12px; }
.depoimentos-stats { display: flex; align-items: center; justify-content: center; gap: 10px; }
.depoimentos-nota { font-size: 34px; font-weight: 800; color: var(--text); line-height: 1; }
.depoimentos-stats-texto { text-align: left; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.depoimentos-stats-texto strong { color: var(--text); display: block; font-size: 13px; }

/* Aspas decorativas grandes no canto do card — clássico visual de
   depoimento, some atrás do conteúdo (z-index padrão, cor suave). */
.avaliacao-card .quote-icon {
  position: absolute; top: -6px; right: 12px; font-size: 64px; font-weight: 800;
  color: var(--border); line-height: 1; font-family: Georgia, 'Times New Roman', serif;
}
.avaliacao-avatar-ring {
  flex-shrink: 0; padding: 2px; border-radius: 999px; line-height: 0;
  background: linear-gradient(135deg, var(--brand), var(--ok));
}
/* Só borda/raio aqui — sem mexer em `display`: o fallback sem foto de
   avatar_html() usa display:flex inline pra centralizar a inicial, e um
   `display:block` (mesmo sem !important) quebrava essa centralização. */
.avaliacao-avatar-ring > * { border: 2px solid var(--surface); border-radius: 999px; }
.selo-verificado {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; color: var(--ok);
  background: var(--ok-soft); padding: 3px 8px; border-radius: 999px;
}

@media (max-width: 480px) {
  .depoimentos-secao { padding: 24px 14px; }
  .depoimentos-header h2 { font-size: 19px; }
  .depoimentos-nota { font-size: 28px; }
}

/* ---------- CTA de orçamento (fim da home do site público) --------------- */
/*
 * Seção decorativa/de conteúdo (texto + CTA de WhatsApp) — existe também
 * pra dar mais texto relevante à página pra SEO (Google, preview em redes
 * sociais etc.), não só como chamada visual. Cores fixas (não usam as
 * variáveis de tema): é um bloco propositalmente mais escuro/contrastante
 * que o resto da página, do jeito que uma seção de CTA de landing page
 * costuma ser, então funciona igual nos dois temas (claro/escuro) do site.
 */
.cta-orcamento {
  position: relative; overflow: hidden; margin: 40px -16px 0; padding: 48px 16px;
  background: linear-gradient(to bottom right, #0f172a, #1e293b, #0f172a);
  color: #fff;
}
.cta-orcamento::before {
  content: ''; position: absolute; inset: 0; opacity: .1; pointer-events: none;
  background-image: radial-gradient(#3b82f6 1px, transparent 1px);
  background-size: 16px 16px;
}
.cta-orcamento-inner { max-width: 1000px; margin: 0 auto; position: relative; z-index: 1; }
.cta-orcamento-box {
  background: rgba(30, 41, 59, .8); border: 1px solid rgba(51, 65, 85, .8);
  border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  display: grid; grid-template-columns: 1fr; gap: 28px; align-items: center;
}
@media (min-width: 900px) {
  .cta-orcamento-box { grid-template-columns: 7fr 5fr; padding: 44px; gap: 32px; }
}
.cta-orcamento-text { text-align: center; }
@media (min-width: 900px) { .cta-orcamento-text { text-align: left; } }
.cta-orcamento-badge {
  display: inline-block; background: rgba(59, 130, 246, .1); color: #60a5fa;
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  padding: 5px 12px; border-radius: 999px; border: 1px solid rgba(59, 130, 246, .2);
  margin-bottom: 14px;
}
.cta-orcamento-text h2 { font-size: 26px; font-weight: 800; line-height: 1.25; margin: 0 0 12px; color: #fff; }
.cta-orcamento-highlight { color: #60a5fa; }
.cta-orcamento-text > p { color: #cbd5e1; font-size: 15px; line-height: 1.6; margin: 0 0 16px; }
.cta-orcamento-beneficios {
  display: grid; grid-template-columns: 1fr; gap: 10px; font-size: 14px; color: #cbd5e1;
}
@media (min-width: 560px) { .cta-orcamento-beneficios { grid-template-columns: 1fr 1fr; } }
.cta-orcamento-beneficios div { display: flex; align-items: center; justify-content: center; gap: 8px; }
@media (min-width: 900px) { .cta-orcamento-beneficios div { justify-content: flex-start; } }
.cta-orcamento-beneficios svg { color: #34d399; flex-shrink: 0; }
.cta-orcamento-acao {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(15, 23, 42, .5); border: 1px solid rgba(51, 65, 85, .5);
  border-radius: 12px; padding: 24px; text-align: center;
}
.cta-orcamento-acao-label p { margin: 0; font-size: 11px; text-transform: uppercase; font-weight: 600; letter-spacing: .04em; color: #94a3b8; }
.cta-orcamento-acao-label strong { display: block; margin-top: 4px; font-size: 17px; color: #fff; }
.cta-orcamento-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #059669; color: #fff; font-weight: 700; font-size: 15px;
  padding: 14px 20px; border-radius: 10px; text-decoration: none;
  box-shadow: 0 10px 25px rgba(4, 120, 87, .3); transition: background .2s, transform .2s;
}
.cta-orcamento-btn:hover { background: #10b981; text-decoration: none; transform: translateY(-1px); }
.cta-orcamento-btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.cta-orcamento-nota { margin: 0; font-size: 11px; color: #94a3b8; }

/* ---------- Vitrine do "Meu Painel" (fim da home do site público) --------- */
/*
 * Mesmos cards/textos, paleta trocada: em vez de um gradiente saturado com
 * cor própria (marrom/vermelho — ficava pesado e "datado", e nem se
 * adaptava ao tema claro), usa as MESMAS variáveis de superfície do resto
 * do site (--surface/--bg/--border/--text) com a cor da marca só como
 * destaque pontual (badge, ícones, botão primário) — visual mais limpo,
 * moderno, e correto nos dois temas (claro/escuro) automaticamente.
 */
.painel-cliente {
  position: relative; margin: 40px -16px 0; padding: 48px 16px;
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  color: var(--text);
}
.painel-cliente-inner { max-width: 1000px; margin: 0 auto; }
.painel-cliente-header { text-align: center; max-width: 640px; margin: 0 auto 36px; }
.painel-cliente-badge {
  display: inline-block; background: var(--brand-soft); color: var(--brand);
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--brand-soft);
  margin-bottom: 14px;
}
.painel-cliente-header h2 { font-size: 26px; font-weight: 800; line-height: 1.25; margin: 0 0 12px; color: var(--text); }
.painel-cliente-header p { color: var(--text-muted); font-size: 15px; line-height: 1.6; margin: 0; }
.painel-cliente-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 32px;
}
@media (min-width: 640px) { .painel-cliente-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .painel-cliente-grid { grid-template-columns: repeat(3, 1fr); } }
.painel-cliente-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; transition: transform .2s, border-color .2s;
}
.painel-cliente-item:hover { transform: translateY(-3px); border-color: var(--brand); }
.painel-cliente-item-icon {
  width: 40px; height: 40px; border-radius: 10px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand);
}
.painel-cliente-item h3 { font-size: 15px; margin: 0 0 6px; color: var(--text); }
.painel-cliente-item p { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin: 0; }
.painel-cliente-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.painel-cliente-cta .btn { min-width: 200px; }
.painel-cliente-cta .btn.primary { box-shadow: 0 10px 25px var(--brand-soft); }

/* ---------- Editor HTML/CSS com preview (Política de Privacidade / Termos) --- */
.editor-html-textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.editor-html-field .btn { margin-top: 8px; }
.editor-html-preview {
  display: block; width: 100%; min-height: 320px; margin-top: 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; /* fundo branco fixo: o texto é publicado no site público, que pode estar em outro tema */
}

/* ---------- Marca (logo/favicon) ------------------------------------------ */
.brand-upload { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand-preview {
  width: 88px; height: 88px; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-preview img { width: 100%; height: 100%; object-fit: contain; }
.brand-preview.is-favicon { width: 56px; height: 56px; border-radius: 8px; }
.brand-preview .empty-icon { color: var(--text-muted); opacity: .5; }

/* ---------- Banners da landing --------------------------------------------- */
.banner-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.banner-row:last-child { border-bottom: 0; }
.banner-row-thumb {
  width: 72px; height: 44px; border-radius: 6px; object-fit: cover; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border);
}
.banner-row-info { flex: 1; min-width: 0; }
.banner-row-info strong { display: block; font-size: 14px; }
.banner-row-info span { font-size: 12px; color: var(--text-muted); }

/* Seletor "Escolher de Mídias" (modal Adicionar banner) */
.banner-midia-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px;
  max-height: 220px; overflow-y: auto; padding: 4px;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.banner-midia-item {
  aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; padding: 0; background: var(--surface-2);
}
.banner-midia-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-midia-item.selecionada { border-color: var(--brand); }

/* ---------- Barra de busca / ações no topo de listas --------------------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.toolbar-form {
  display: flex;  gap: 8px; flex: 1 1 320px; min-width: 0; max-width: 520px;
}
/*
 * O item flex de verdade é o `.field` que ENVOLVE o input (o filho direto de
 * `.toolbar-form`) — não o <input> em si. `flex:` num descendente que não é
 * item flex não faz nada; sem isso, o wrapper do campo de busca encolhe pro
 * min-content de um <input type="search"> (praticamente zero), enquanto o
 * de um <select> fica largo por causa do texto da opção mais comprida —
 * daí a busca aparecer espremida do lado dos filtros normais.
 */
.toolbar-form .field:has(> input[type="search"]) { flex: 1 1 200px; min-width: 140px; }
.toolbar-form input[type="search"] { min-width: 0; }
.toolbar-form select { flex: 0 0 auto; width: auto; }
.toolbar-hint { font-size: 12px; color: var(--text-muted); }
/*
 * Ordens de serviço (admin/gerente) tem 7 campos de filtro em .toolbar-form,
 * que cresce (flex-grow) pra ocupar o espaço disponível. Sem uma regra fixa
 * aqui, "Nova OS"/"Atualizar" ficavam ora na mesma linha do último filtro,
 * ora quebrando pra linha seguinte, dependendo do pixel exato de largura da
 * janela/monitor — o mesmo conteúdo parecia "quebrado" numa tela e normal
 * noutra. flex-basis:100% tira os botões da disputa por espaço com os
 * filtros: eles sempre ficam na própria linha, alinhados à direita, com
 * resultado idêntico em qualquer largura de desktop.
 */
.toolbar-acoes-os { flex: 0 0 100%; justify-content: flex-end; }

/* ---------- Tabelas ------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
tbody tr:hover { background: var(--surface-2); }
.empty { padding: 32px; text-align: center; color: var(--text-muted); }

/* ---------- Badges ------------------------------------------------------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge.ok     { background: var(--ok-soft);     color: var(--ok); }
.badge.warn   { background: var(--warn-soft);   color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted  { background: var(--surface-2);   color: var(--text-muted); }

/* ---------- Formulários -------------------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field .error { color: var(--danger); font-size: 12px; margin-top: 4px; display: block; }
input.invalid { border-color: var(--danger); }

/* ---------- Toggle switch (liga/desliga) --------------------------------- */
/* .field label{display:block} (classe+elemento) tem mais especificidade que
   .toggle-switch sozinho — sem o "label.toggle-switch" abaixo, um toggle
   dentro de um .field vira bloco e o track/bolinha (position:absolute)
   sobrepõe o texto do label em vez de ficar ao lado. */
label.toggle-switch,
.toggle-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-switch .track {
  width: 42px; height: 24px; border-radius: 999px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border); position: relative;
  transition: background .15s ease, border-color .15s ease;
}
.toggle-switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--text-muted);
  transition: transform .15s ease, background .15s ease;
}
.toggle-switch input:checked + .track { background: var(--brand-soft); border-color: var(--brand); }
.toggle-switch input:checked + .track::after { transform: translateX(18px); background: var(--brand); }
.toggle-switch .toggle-label { font-size: 14px; }

/* ---------- Contador no menu (ex.: descontos pendentes) ------------------- */
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 7px; border-radius: 999px;
}

/* ---------- Seletor de período em pílulas (dashboard) --------------------- */
.periodo-pills {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.periodo-pills a {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--text-muted);
}
.periodo-pills a:hover { color: var(--text); text-decoration: none; }
.periodo-pills a.active { background: var(--brand); color: #fff; }

/* ---------- Célula editável via AJAX (clique -> vira input) -------------- */
.celula-editavel { cursor: pointer; border-bottom: 1px dashed var(--text-muted); }
.celula-editavel:hover { color: var(--brand); }
.celula-editavel input {
  width: 90px; padding: 4px 6px; font-size: 14px;
}

/* ---------- Campo de busca com sugestões (Fit.buscaComCriacao / buscaRemota) --- */
.busca-campo { position: relative; }
.busca-lista {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 220px; overflow-y: auto;
}
.busca-opcao { padding: 9px 12px; font-size: 14px; cursor: pointer; }
.busca-opcao:hover { background: var(--surface-2); }
.busca-opcao-criar { color: var(--brand); font-weight: 600; border-top: 1px solid var(--border); }
.busca-opcao-vazia { color: var(--text-muted); cursor: default; }
.busca-opcao-vazia:hover { background: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:hover { border-color: var(--text-muted); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Botão que se comporta/parece um link de texto (<button> em vez de <a> quando a ação é JS, ex.: abrir um modal). */
.link-btn {
  background: none; border: 0; padding: 0; margin: 0; font: inherit;
  color: var(--brand); cursor: pointer; text-decoration: underline;
}
.link-btn:hover { filter: brightness(1.15); }

/* ---------- Alertas / toasts --------------------------------------------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.success { background: var(--ok-soft);     color: var(--ok);     border: 1px solid var(--ok); }
.alert.error   { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.alert.warn    { background: var(--warn-soft);   color: var(--warn);   border: 1px solid var(--warn); }

#toast-area { position: fixed; top: 18px; right: 18px; z-index: 999; display: grid; gap: 8px; z-index: 99999; }
.toast {
  padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500; background: var(--surface-2);
  border-left: 4px solid var(--brand); animation: slide-in .2s ease;
}
.toast.success { border-left-color: var(--ok); }
.toast.error   { border-left-color: var(--danger); }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }

/* ---------- Avisos periódicos (nova OS / desconto pendente) --------------
   Canto oposto ao dos toasts (evita colidir com uma mensagem de "salvo com
   sucesso" acontecendo ao mesmo tempo). Clicável — leva pra tela do aviso;
   some sozinho depois de alguns segundos (ver assets/js/avisos.js). */
#avisos-area {
  position: fixed; bottom: 18px; right: 18px; z-index: 9998;
  display: grid; gap: 10px; max-width: min(340px, calc(100vw - 36px));
}
.aviso-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand);
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: opacity .25s ease, transform .25s ease;
}
.aviso-card.open { opacity: 1; transform: translateY(0); }
.aviso-card-icone { font-size: 20px; flex-shrink: 0; }
.aviso-card-texto { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; }
.aviso-card-fechar {
  background: none; border: 0; color: var(--text-muted); cursor: pointer;
  padding: 2px; line-height: 0; flex-shrink: 0;
}
.aviso-card-fechar:hover { color: var(--text); }
@media (max-width: 480px) {
  #avisos-area { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ==========================================================================
   PORTARIA — precisa ser lida a 3 metros de distância.
   ========================================================================== */
.gate { min-height: 100vh; display: grid; grid-template-columns: 1.2fr 1fr; }
.gate-scan {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; gap: 24px; transition: background .25s;
}
.gate-scan.liberado  { background: linear-gradient(160deg, rgba(34,197,94,.22), transparent 60%); }
.gate-scan.bloqueado { background: linear-gradient(160deg, rgba(239,68,68,.22), transparent 60%); }

#scan-input {
  font-size: 26px; text-align: center; letter-spacing: .12em;
  padding: 18px; max-width: 460px;
}

.gate-result {
  width: 100%; max-width: 520px; border-radius: 16px; padding: 32px;
  text-align: center; border: 3px solid var(--border); background: var(--surface);
}
.gate-result.liberado  { border-color: var(--ok);     background: var(--ok-soft); }
.gate-result.bloqueado { border-color: var(--danger); background: var(--danger-soft); }
.gate-result .status { font-size: 46px; font-weight: 800; letter-spacing: -1px; }
.gate-result.liberado  .status { color: var(--ok); }
.gate-result.bloqueado .status { color: var(--danger); }
.gate-result .student-name { font-size: 26px; font-weight: 600; margin-top: 10px; }
.gate-result .detail { color: var(--text-muted); margin-top: 8px; font-size: 16px; }
.gate-result .photo {
  width: 110px; height: 110px; border-radius: 50%; object-fit: cover;
  border: 3px solid currentColor; margin-bottom: 14px;
}
.gate-result .photo-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-muted);
  font-size: 40px; font-weight: 700; margin-left: auto; margin-right: auto;
}

.gate-feed { background: var(--surface); border-left: 1px solid var(--border); padding: 20px; overflow-y: auto; }
.gate-feed h2 { font-size: 15px; margin: 0 0 12px; }
.feed-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 8px; margin-bottom: 6px; background: var(--surface-2);
  border-left: 4px solid var(--border); animation: slide-in .2s ease;
}
.feed-item.liberado  { border-left-color: var(--ok); }
.feed-item.bloqueado { border-left-color: var(--danger); }
.feed-item .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; background: var(--surface); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; border: 1px solid var(--border);
}

/* Miniatura de foto do aluno — listas e fichas do admin/gerente/instrutor. */
.avatar-mini {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; background: var(--surface-2); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; border: 1px solid var(--border);
}
.avatar-mini.lg { width: 56px; height: 56px; font-size: 20px; }
.feed-item .who { flex: 1; font-weight: 600; font-size: 14px; }
.feed-item .when { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.feed-item .why { font-size: 12px; color: var(--text-muted); display: block; font-weight: 400; }

/* ==========================================================================
   ÁREA DO ALUNO — mobile-first (o aluno usa o celular na academia).
   ========================================================================== */
.client-shell { max-width: 620px; margin: 0 auto; padding: 16px 16px 90px; }
.client-header { display: flex; align-items: center; gap: 12px; padding: 12px 0 20px; }
.client-header .avatar {
  width: 46px; height: 46px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 18px;
  flex-shrink: 0; overflow: hidden; text-decoration: none;
}
.client-header .avatar:hover { text-decoration: none; filter: brightness(1.1); }
.client-header .avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Botão de escanear no canto superior direito */
.scan-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); padding: 0;
}
.scan-btn:hover { border-color: var(--brand); color: var(--brand); }
.scan-btn:active { transform: scale(.94); }
.scan-btn svg { width: 22px; height: 22px; }

/* Editor de avatar (tela de perfil) */
.avatar-editor { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-preview {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: 34px; font-weight: 700;
  border: 2px solid var(--border);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Scanner em tela cheia ---------------------------------------- */
.scanner {
  position: fixed; z-index: 1000;
  /* top/right/bottom/left antes de `inset`: navegadores anteriores a 2021
     ignoram `inset` e continuam ocupando a tela toda. */
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  background: rgba(8, 9, 12, .97);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* `[hidden]` sozinho perde para `display:flex` — precisa desta regra. */
.scanner[hidden] { display: none !important; }

.scanner-top {
  width: 100%; max-width: 460px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 2px 16px;
}
.scanner-title { font-size: 17px; font-weight: 600; }
.scanner-close {
  background: none; border: 0; color: var(--text-muted);
  font-size: 32px; line-height: 1; cursor: pointer; padding: 0 8px;
}
.scanner-close:hover { color: var(--text); }

.scanner-stage {
  position: relative; width: 100%; max-width: 380px;
  border-radius: 18px; overflow: hidden; background: #000;
  display: grid; place-items: center;
  /* Quadrado sem aspect-ratio (Safari < 15): o padding cria a altura. */
  height: 0; padding-bottom: 100%;
}
@supports (aspect-ratio: 1) {
  .scanner-stage { aspect-ratio: 1; height: auto; padding-bottom: 0; }
}
.scanner-stage video {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; object-fit: cover; background: #000;
}
.scanner-placeholder {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: grid; place-items: center; color: var(--border);
}
.scanner-placeholder svg { width: 44%; height: 44%; }

/* Cantos do enquadramento */
.scanner-frame {
  position: absolute;
  top: 14%; right: 14%; bottom: 14%; left: 14%;
  inset: 14%;
  pointer-events: none;
}
.scanner-frame span {
  position: absolute; width: 34px; height: 34px;
  border: 3px solid var(--brand);
}
.scanner-frame span:nth-child(1) { top: 0; left: 0;  border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.scanner-frame span:nth-child(2) { top: 0; right: 0; border-left: 0;  border-bottom: 0; border-radius: 0 10px 0 0; }
.scanner-frame span:nth-child(3) { bottom: 0; right: 0; border-left: 0; border-top: 0;  border-radius: 0 0 10px 0; }
.scanner-frame span:nth-child(4) { bottom: 0; left: 0;  border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }

.scanner-hint {
  max-width: 380px; margin: 18px auto 0; text-align: center;
  font-size: 14px; color: var(--text-muted); line-height: 1.6;
}
.scanner-actions {
  margin-top: 18px; display: flex; gap: 10px;
  flex-wrap: wrap; justify-content: center;
}

/* Diagnóstico — só aparece quando a câmera falha */
.scanner-diag {
  margin-top: 18px; width: 100%; max-width: 380px;
  font-size: 13px; color: var(--text-muted);
}
.scanner-diag summary { cursor: pointer; padding: 6px 0; }
.scanner-diag ul { list-style: none; padding: 8px 0 0; margin: 0; }
.scanner-diag li { padding: 3px 0; font-family: monospace; font-size: 12px; }
.scanner-diag li.ok   { color: var(--ok); }
.scanner-diag li.no   { color: var(--danger); }
.scanner-diag li.info { color: var(--text-muted); word-break: break-all; }

/* Resultado do check-in dentro do scanner */
.scan-result {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px;
}
.scan-result.liberado  { background: var(--ok-soft); }
.scan-result.bloqueado { background: var(--danger-soft); }
.scan-result-icon {
  width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center; font-size: 42px; font-weight: 700;
}
.scan-result.liberado  .scan-result-icon { background: var(--ok);     color: #07130a; }
.scan-result.bloqueado .scan-result-icon { background: var(--danger); color: #1a0707; }
.scan-result-status { font-size: 21px; font-weight: 800; letter-spacing: .02em; }
.scan-result.liberado  .scan-result-status { color: var(--ok); }
.scan-result.bloqueado .scan-result-status { color: var(--danger); }
.scan-result-msg  { font-size: 15px; color: var(--text); }
.scan-result-unit { font-size: 13px; color: var(--text-muted); }
.client-nav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--surface); border-top: 1px solid var(--border);
}
.client-nav a {
  flex: 1; text-align: center; padding: 12px 4px; font-size: 12px; color: var(--text-muted);
}
.client-nav a.active { color: var(--brand); font-weight: 600; }

/* ==========================================================================
   Cronômetro de descanso entre séries
   ========================================================================== */
.rest-bar {
  position: fixed;
  left: 0; right: 0;
  /* Acima da navegação inferior do aluno, respeitando a área segura do iPhone. */
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: flex; align-items: center; gap: 16px;
  max-width: 620px; margin: 0 auto;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .45);
}
.rest-bar[hidden] { display: none !important; }

/* Sem isso o card cobre o fim do formulário. */
body.has-rest-bar { padding-bottom: 96px; }

.rest-ring { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.rest-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rest-track {
  fill: none; stroke: var(--surface-2); stroke-width: 9;
}
.rest-progress {
  fill: none; stroke: var(--brand); stroke-width: 9; stroke-linecap: round;
  transition: stroke-dashoffset .2s linear, stroke .2s;
}
.rest-time {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rest-info { flex: 1; min-width: 0; }
.rest-label { display: block; font-size: 14px; margin-bottom: 8px; }
.rest-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Últimos 5 segundos: pulsa em laranja. */
.rest-bar.urgente .rest-progress { stroke: var(--warn); }
.rest-bar.urgente .rest-time { color: var(--warn); }
.rest-bar.urgente .rest-ring { animation: rest-pulse .9s ease-in-out infinite; }

.rest-bar.paused { opacity: .75; }
.rest-bar.paused .rest-progress { stroke: var(--text-muted); }

/* Concluído: verde e piscando — no iOS não há vibração, então o visual
   precisa ser impossível de ignorar. */
.rest-bar.done {
  border-color: var(--ok);
  animation: rest-flash 1s ease-in-out 3;
}
.rest-bar.done .rest-progress { stroke: var(--ok); }
.rest-bar.done .rest-time { color: var(--ok); font-size: 15px; }
.rest-bar.done .rest-label { color: var(--ok); font-weight: 700; }

@keyframes rest-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}
@keyframes rest-flash {
  0%, 100% { background: var(--surface); }
  50%      { background: var(--ok-soft); }
}

/* Quem pediu menos movimento recebe a cor, não a animação. */
@media (prefers-reduced-motion: reduce) {
  .rest-bar.done, .rest-bar.urgente .rest-ring { animation: none; }
  .rest-progress { transition: none; }
}

/* Atalhos de tempo dentro do formulário */
.rest-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.metric-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.metric .value { font-size: 24px; font-weight: 700; }
.metric .label { font-size: 12px; color: var(--text-muted); }
.delta.up   { color: var(--ok); }
.delta.down { color: var(--danger); }

.qr-box { background: #fff; padding: 20px; border-radius: 12px; display: grid; place-items: center; }
.qr-box canvas, .qr-box img { max-width: 100%; }

/* ---------- Modal genérico (Novo contrato, Novo instrutor, etc.) -------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden;
  transition: opacity .18s ease, visibility .18s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 24px; position: relative;
  transform: translateY(14px) scale(.98);
  transition: transform .18s ease;
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: 8px; line-height: 0;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-box h2 { margin-top: 0; padding-right: 24px; }

/* ---------- Gráficos (SVG puro, sem biblioteca) -------------------------- */
.chart { width: 100%; height: 220px; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; }
.chart .area { fill: var(--brand-soft); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .label { fill: var(--text-muted); font-size: 10px; }
.chart .bar { fill: var(--brand); }
.chart .bar.alt { fill: var(--danger); }

.heatmap { display: grid; grid-template-columns: 40px repeat(24, 1fr); gap: 2px; font-size: 10px; }
.heatmap .cell { aspect-ratio: 1; border-radius: 2px; background: var(--surface-2); }
.heatmap .row-label { color: var(--text-muted); display: grid; place-items: center; }

/* ---------- Impressão ------------------------------------------------------
   Regra geral pra qualquer tela do painel (Admin/Gerente): some com a
   navegação (sidebar, topbar, botões de ação) e deixa só o conteúdo, largura
   cheia. Elementos específicos de uma tela usam .no-print pra se esconder
   também (ex.: botão "Imprimir" do próprio dashboard).
---------------------------------------------------------------------------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font-size: 12px; }
  .no-print, .print-only { display: none !important; }
  .sidebar, .topbar-burger, .unit-switch, .scan-btn, .client-nav, .client-header
    { display: none !important; }
  .layout, html.is-collapsed .layout { display: block; }
  .main { display: block; }
  .content { padding: 0; }
  .topbar { border: none; padding: 0 0 8px; min-height: 0; }
  .topbar h1 { font-size: 18px; }

  /* Só aparece impresso: título/unidade não cabiam de forma legível na tela
     comum, então esse bloco fica escondido o tempo todo e só é revelado aqui. */
  .print-only { display: block !important; margin: 0 0 12px; }

  /* Colunas fixas: o auto-fit da tela deixa "órfãos" numa página mais
     estreita (ex.: 4 cards em 190px cabem só 3 por linha em A4 retrato,
     sobrando 1 sozinho). Fixando o número de colunas, cada linha preenche
     por completo — o mesmo aproveitamento de espaço da tela. */
  .grid { gap: 8px; margin-bottom: 8px !important; }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

  .card {
    break-inside: avoid; box-shadow: none; border: 1px solid #ccc;
    padding: 10px; border-radius: 6px;
  }
  .card h2, .card h3 { margin: 0 0 6px; font-size: 12px; }
  .kpi .label { font-size: 9px; }
  .kpi .value { font-size: 18px; margin-top: 2px; }
  .kpi .hint { font-size: 9px; margin-top: 2px; }

  /* O card "Taxas e Custos" é escuro de propósito na tela — no papel isso
     é tinta/toner desperdiçado e ilegível em preto-e-branco; imprime claro. */
  .mp-fees-card {
    background: #fff !important; color: #000 !important;
    border: 1px solid #ccc !important;
  }
  .mp-fees-header h2, .mp-fees-total, .mp-fees-installments,
  .mp-fees-banner-value { color: #000 !important; }
  .mp-fees-panel { background: #fafafa !important; border-color: #ddd !important; }
  .mp-fees-banner { background: #fafafa !important; border-color: #ccc !important; }

  table { font-size: 11px; }
  .table-wrap { overflow: visible; }

  /* ---- Etiquetas para impressão ---- */
  .label-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10mm; }
  .label-card { border: 1px dashed #999; padding: 8mm; text-align: center; break-inside: avoid; }
}
/* Barra de seleção em massa */
#barra-selecao-despesas {
  transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease;
  overflow: hidden;
  max-height: 100px;
}

#barra-selecao-despesas[hidden] {
  display: none;
  max-height: 0;
  padding: 0;
  margin: 0;
  opacity: 0;
  transform: translateY(-20px);
}

/* Estilo para os botões da barra */
#barra-selecao-despesas .btn {
  transition: all 0.2s ease;
}

#barra-selecao-despesas .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Contador de seleção */
#contador-despesas {
  font-weight: 600;
  color: var(--text-primary);
  padding: 4px 12px;
  background: var(--bg-muted);
  border-radius: 20px;
  font-size: 14px;
}
/* ---------- Grid de vídeos (YouTube/Vimeo) --------------------------------
   Compartilhado entre o painel de equipamentos e o Inspire-se — ver
   assets/js/video-embed.js para a lógica de miniatura/player.
---------------------------------------------------------------------------- */
.video-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 640px) { .video-grid { grid-template-columns: repeat(4, 1fr); } }
.video-thumb {
  position: relative; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden;
  background: var(--surface-2); cursor: pointer;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .35); color: #fff; font-size: 18px;
}
.video-fullscreen-overlay { position: fixed; inset: 0; z-index: 2000; background: #000; }
.video-fullscreen-overlay iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-fullscreen-close {
  position: absolute; top: 12px; right: 12px; z-index: 2001;
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* ---------- Imagem em tela cheia (ver assets/js/image-viewer.js) ---------- */
.img-fullscreen-overlay {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.img-fullscreen-overlay img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.img-fullscreen-close {
  position: absolute; top: 12px; right: 12px; z-index: 2001;
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.img-fullscreen-delete {
  position: absolute; top: 12px; left: 12px; z-index: 2001;
  height: 40px; padding: 0 16px; border-radius: 999px; border: none;
  background: var(--danger, #dc3545); color: #fff; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.img-fullscreen-delete:hover { filter: brightness(1.1); }
@media (max-width: 768px) {
.toolbar-form {
   flex: 50px; 
}
}
/* ---------- Responsivo --------------------------------------------------- */
@media (max-width: 900px) {
  /* No celular a sidebar vira gaveta sobreposta — coluna fixa comeria a tela. */
  .layout,
  html.is-collapsed .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 80;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  /* A gaveta é sempre "expandida": ícone sozinho não ajuda em tela pequena. */
  body.drawer-open .sidebar { transform: translateX(0); }
  html.is-collapsed .logo-text,
  html.is-collapsed .nav-label,
  html.is-collapsed .nav-caret { display: revert; }
  html.is-collapsed .nav-link { justify-content: flex-start; padding: 9px 11px; }
  html.is-collapsed .nav-sub {
    position: static; opacity: 1; visibility: visible; transform: none;
    background: none; border: 0; box-shadow: none; padding: 0;
    margin-left: 21px; border-left: 1px solid var(--border); padding-left: 7px;
    display: grid; grid-template-rows: 0fr; min-width: 0;
  }
  html.is-collapsed .nav-section.open > .nav-sub { grid-template-rows: 1fr; }
  /* Volta a cortar: na gaveta o accordion é acordeão de novo, não flyout. */
  html.is-collapsed .nav-sub-inner { overflow: hidden; min-height: 0; }

  /* A gaveta mostra o menu inteiro e precisa rolar; o `overflow: visible` do
     estado recolhido só faz sentido para os flyouts do desktop. */
  html.is-collapsed .sidebar { overflow-x: hidden; overflow-y: auto; }
  html.is-collapsed .nav-sub { max-height: none; overflow: visible; }

  /* Sem hover no toque, a ponte só atrapalharia. */
  html.is-collapsed .nav-section::after { content: none; }
  html.is-collapsed .nav-sub-title { display: none; }
  html.is-collapsed .nav-link[data-tip]::after { content: none; }

  .sidebar-collapse { display: none; }   /* fechar é pelo backdrop ou por um link */
  .topbar-burger { display: grid; place-items: center; }

  /* Título embaixo do cabeçalho (menu + avatar + leitor QR), em vez de
     espremido na mesma linha — um título longo (ex.: "Agenda de Visitas")
     empurrava o avatar quase pra fora da tela e ainda quebrava em 2 linhas
     torto. `order` joga o <h1> pro fim da fileira; `flex-basis:100%` força
     ele a começar uma linha nova, já que não sobra espaço pra dividir com
     o que veio antes. */
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar h1 { order: 10; flex-basis: 100%; font-size: 17px; }

  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 70;
    background: rgba(0, 0, 0, .55);
    opacity: 0; visibility: hidden; transition: opacity .22s, visibility .22s;
  }
  body.drawer-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  body.drawer-open { overflow: hidden; }

  .gate { grid-template-columns: 1fr; }
  .gate-feed { border-left: 0; border-top: 1px solid var(--border); max-height: 40vh; }

  /**
   * iOS Safari dá zoom automático ao focar um <input> com font-size < 16px —
   * é o que fazia o campo "buscar" (e qualquer outro campo) parecer quebrado
   * no celular: a página inteira saltava de tamanho ao tocar o campo.
   * !important porque vários formulários têm font-size menor no próprio
   * atributo style="" do campo (13px, mais denso pra caber no toolbar) —
   * um estilo inline sempre ganha de uma regra externa comum, então sem
   * !important essa proteção contra zoom não valeria pra esses campos.
   */
  input, select, textarea { font-size: 16px !important; }

  /* Barra de busca empilha em tela estreita — em vez de espremer input,
     seletor e botão numa linha só que não cabe. */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-form { max-width: none; width: 100%; flex-wrap: wrap; }
  /* min-width:0 é essencial aqui: sem ele, o "floor" de encolhimento de um
     item flex é o min-content — pro <select> de técnico isso é a largura do
     nome mais comprido da lista, que estoura a tela no celular mesmo com
     flex-basis pequeno. */
  /* min-width:0 no <select> não basta sozinho: ele não é filho direto de
     .toolbar-form (é filho de .field), então quem precisa do min-width:0 pra
     valer no encolhimento do flex é o próprio .field — senão o "floor"
     automático do .field continua sendo o min-content do select por dentro
     (a largura do nome de técnico mais comprido da lista). */
  .toolbar-form select { flex: 1 1 110px; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .toolbar-form .field { flex: 1 1 140px; min-width: 0; }
  .toolbar-form .btn { width: 100%; }
  .toolbar > .btn { width: 100%; text-align: center; }

  /* Em Ordens de Serviço, "Nova OS"/"Atualizar" sobem pro topo do toolbar
     (antes dos campos de filtro) só na coluna do celular — no desktop
     (linha) continuam à direita, na ordem normal do HTML. */
  .toolbar-acoes-os { order: -1; width: 100%; }
  .toolbar-acoes-os .btn { flex: 1 1 auto; }

  /* Formulários (ex.: OS): cols-2/cols-3/cols-4 viram 1 coluna cheia — o
     auto-fit com minmax de 190-320px ainda deixava campos como "Valor
     unit.", "Forma de pagamento", "CEP"/"Número"/"Bairro" etc. espremidos
     em telas de ~360-400px, que sobram poucos px de largura útil depois do
     padding do card. !important trava o colapso mesmo que algum trecho da
     tela tenha um .grid.cols-N mais específico por perto. */
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 { grid-template-columns: 1fr !important; }

  /* Presets de entrada (Financeiro > Entradas Padrão): botões de tamanhos
     desiguais lado a lado ficavam difíceis de tocar — cada um ganha metade
     da largura (ou a linha toda, se só sobrar um). */
  [data-preset-entrada] { flex: 1 1 45%; }
}