/* BW_UIU_20261027 · uma só escala de botões em toda a aplicação (EMP e BlocoTelha).
   Só mexe em tamanho, espaçamento, raio, tipo de letra e foco. As cores continuam as do branding de cada empresa.
   Não altera "display": os botões escondidos por outras regras continuam escondidos.
   Especificidade: "html body:not(#bwu)" (1 id) ganha às regras antigas por classe (ds.css, pal.css, CSS inline dos módulos). */
:root{--bwu-h:42px;--bwu-h-sm:34px;--bwu-h-chip:32px;--bwu-r:10px;--bwu-fs:14px;--bwu-fs-sm:13px;--bwu-fw:650;--bwu-px:16px;--bwu-px-sm:12px}

/* Botão normal: primário, secundário, perigo, sucesso, Voltar, Terminar sessão, Tirar foto, Descarregar */
html body:not(#bwu) :is(.btn,.btn-secondary,.btn-primary,.btn-danger,.btn-success,.btn-ghost,.v157-back-btn,.v157-logout-btn,.btui-cam,.rv2-main-dl):not(.btv-btn):not(.btv-tbtn):not(.bw-qmark-btn):not(#av-salvador-root *):not(.ifc-shell *),
html body:not(#bwu) #v166151-name-editor button,
html body:not(#bwu) :is(.container,main,.page,.q-wrap) form :is(button:not([class]),input[type=submit]:not([class])){
  box-sizing:border-box!important;
  min-height:var(--bwu-h)!important;height:auto!important;max-height:none!important;
  padding:calc((var(--bwu-h) - 2px - 1.2em) / 2) var(--bwu-px)!important;
  font-family:inherit!important;font-size:var(--bwu-fs)!important;font-weight:var(--bwu-fw)!important;
  line-height:1.2!important;letter-spacing:0!important;
  border-radius:var(--bwu-r)!important;
  align-items:center;justify-content:center;gap:8px;
  vertical-align:middle;text-decoration:none!important;
}
html body:not(#bwu) :is(.btn,.v157-back-btn,.v157-logout-btn,.btui-cam,.rv2-main-dl) > svg{width:18px;height:18px;flex:0 0 auto;vertical-align:middle}

/* Compacto: dentro de tabelas e .btn-sm (mesmo raio e peso, só mais baixo) */
html body:not(#bwu) :is(td,th) :is(.btn,.btn-secondary,.btn-danger,.btn-success):not(.btv-btn),
html body:not(#bwu) :is(.btn-sm,.btn.small,.btn-xs):not(.btv-btn){
  min-height:var(--bwu-h-sm)!important;
  padding:calc((var(--bwu-h-sm) - 2px - 1.2em) / 2) var(--bwu-px-sm)!important;
  font-size:var(--bwu-fs-sm)!important;border-radius:8px!important;
}

/* Chips / filtros: uma só altura */
html body:not(#bwu) :is(.v1666-cpill,.bwh-chip){
  box-sizing:border-box!important;min-height:var(--bwu-h-chip)!important;height:auto!important;
  padding:calc((var(--bwu-h-chip) - 2px - 1.2em) / 2) 12px!important;
  font-size:13px!important;line-height:1.2!important;border-radius:999px!important;
}

/* Câmara (fotos da obra, segurança): mesmo bloco em todas as páginas */
html body:not(#bwu) .av57-camera-open{min-height:64px!important;font-size:15px!important;font-weight:var(--bwu-fw)!important;border-radius:12px!important}

/* Foco visível igual para todos (teclado) */
html body:not(#bwu) :is(.btn,.v157-back-btn,.v157-logout-btn,.btui-cam,.rv2-main-dl,.v1666-cpill,.bwh-chip):focus-visible{
  outline:2px solid var(--brand-primary,#111827)!important;outline-offset:2px!important}

/* Navegação: barra de progresso no topo enquanto a página seguinte carrega */
#bwu-prog{position:fixed;left:0;top:0;height:3px;width:0;z-index:2147483647;pointer-events:none;
  background:var(--brand-primary,#111827);opacity:0;border-radius:0 2px 2px 0}
html.bwu-leaving #bwu-prog{opacity:1;animation:bwuProg 9s cubic-bezier(.08,.7,.2,1) forwards}
html.bwu-leaving body{cursor:progress}
@keyframes bwuProg{0%{width:0}8%{width:35%}40%{width:70%}100%{width:94%}}
@media (prefers-reduced-motion:reduce){html.bwu-leaving #bwu-prog{animation:none;width:60%}}

/* ───────── BW_MOB_20261027 · telemóvel: nada mais largo do que o ecrã, botões inteiros, alvos >= 42px ───────── */
/* símbolos monocromáticos desde a primeira pintura (antes vinha do bt_ui.js, meio segundo depois) */
html body{font-variant-emoji:text}
/* «Trabalhos à hora» escondido em todo o lado (antes: bt_ui.js depois de pintar) */
html body:not(#bwu) li:has(> a[href*="/project/trabalhos-hora"]:only-child),html body:not(#bwu) a[href*="/project/trabalhos-hora"]{display:none!important}

@media (max-width:900px){
  /* grelhas com colunas fixas escritas no HTML (ex.: foto da máquina 180–360px + 1fr) -> uma coluna */
  html body:not(#bwu) :is([style*="grid-template-columns:minmax(1"],[style*="grid-template-columns:minmax(2"],[style*="grid-template-columns:minmax(3"],[style*="grid-template-columns: minmax(1"],[style*="grid-template-columns: minmax(2"],[style*="auto-fill,minmax(320px"],[style*="auto-fit,minmax(320px"],[style*="auto-fill,minmax(300px"],[style*="auto-fit,minmax(300px"]){grid-template-columns:minmax(0,1fr)!important}
  html body:not(#bwu) [style*="display:grid"] > *{min-width:0}
  html body:not(#bwu) :is(.card,.panel,main,.container) img{max-width:100%;height:auto}
  /* formulários empilhados (campo + botão): botões a toda a largura, texto nunca cortado */
  html body:not(#bwu) form:has(> .field) > :is(.btn,button,input[type=submit]),
  html body:not(#bwu) .field > :is(.btui-cam,input[type=file]),
  html body:not(#bwu) :is(.card,.panel) > form:only-child > :is(.btn,button):only-child,
  html body:not(#bwu) [style*="display:grid"] > div > form > :is(.btn,button):only-of-type{width:100%;max-width:100%}
  html body:not(#bwu) :is(.btn,.btn-secondary,.btn-primary,.btn-danger,.btn-success,.btui-cam){max-width:100%;white-space:normal!important;overflow-wrap:anywhere;text-overflow:clip!important}
  html body:not(#bwu) input[type=file]{max-width:100%;min-height:42px}
  /* utilizadores: a lista não pode ter a largura da linha mais comprida */
  html body:not(#bwu) .u-list{grid-template-columns:minmax(0,1fr)!important}
  html body:not(#bwu) .u-list > *{min-width:0;max-width:100%}
  html body:not(#bwu) .u-row{flex-wrap:wrap!important;min-width:0}
  html body:not(#bwu) .u-row > *{min-width:0}
  /* reservas: menus «Colunas/Exportar» abrem para dentro do ecrã */
  html body:not(#bwu) details.rv2-cols > div{right:0!important;left:auto!important;max-width:calc(100vw - 24px)!important}
  /* libertar reservas: barra de ações em várias linhas, botões inteiros */
  html body:not(#bwu) .lb-bar{flex-wrap:wrap!important;min-width:0}
  html body:not(#bwu) .lb-bar .lb-go{flex:1 1 100%!important;flex-wrap:wrap!important;min-width:0;max-width:100%}
  html body:not(#bwu) .lb-bar .lb-go > *{flex:1 1 100%;min-width:0;max-width:100%}
  html body:not(#bwu) .lb-btn{white-space:normal!important;text-overflow:clip!important;height:auto!important;min-height:42px}
  /* botão flutuante (+): espaço no fim da página para não tapar os últimos botões */
  html body:has(#bt46-fab){padding-bottom:calc(92px + env(safe-area-inset-bottom,0px))!important}
  /* alvos de toque */
  html body:not(#bwu) :is(main,.container,.page) :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select){min-height:42px}
  html body:not(#bwu) :is(main,.container,.page) textarea{max-width:100%}
}

/* tabelas -> cartões (as células trazem data-bwl do servidor; ver bt_ui_text.py) */
@media (max-width:700px){
  html body:not(#bwu) table.bwl-stack{display:block;width:100%!important;min-width:0!important;max-width:100%!important;border:0!important;background:transparent!important}
  html body:not(#bwu) table.bwl-stack > thead{display:none!important}
  html body:not(#bwu) table.bwl-stack > :is(tbody,tfoot){display:block;width:100%}
  html body:not(#bwu) table.bwl-stack > :is(tbody,tfoot) > tr{display:block;width:auto;border:1px solid rgba(100,116,139,.28);border-radius:12px;margin:0 0 10px;padding:8px 12px}
  html body:not(#bwu) table.bwl-stack > :is(tbody,tfoot) > tr > :is(td,th){display:grid;grid-template-columns:minmax(84px,36%) minmax(0,1fr);gap:4px 10px;align-items:start;width:auto!important;min-width:0!important;max-width:none!important;padding:5px 0!important;border:0!important;white-space:normal!important;overflow-wrap:anywhere;text-align:left!important;height:auto!important}
  html body:not(#bwu) table.bwl-stack > :is(tbody,tfoot) > tr > :is(td,th)::before{content:attr(data-bwl);font-size:12px;font-weight:700;line-height:1.35;opacity:.65;padding-top:1px}
  html body:not(#bwu) table.bwl-stack > :is(tbody,tfoot) > tr > :is(td,th)[data-bwl=""]{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
  html body:not(#bwu) table.bwl-stack > :is(tbody,tfoot) > tr > :is(td,th)[data-bwl=""]::before{content:none}
  html body:not(#bwu) table.bwl-stack > :is(tbody,tfoot) > tr > :is(td,th):empty{display:none}
  html body:not(#bwu) table.bwl-stack > :is(tbody,tfoot) > tr > :is(td,th) > form{display:inline-flex!important;flex-wrap:wrap;gap:8px}
  html body:not(#bwu) table.bwl-stack :is(.btn,.btn-secondary,.btn-danger,.btn-success){min-height:var(--bwu-h)!important;padding:calc((var(--bwu-h) - 2px - 1.2em) / 2) var(--bwu-px)!important;font-size:var(--bwu-fs)!important;margin:0!important}
  html body:not(#bwu) :has(> table.bwl-stack){overflow:visible!important;max-height:none!important}
  html body:not(#bwu) :is(.table-wrap,.tbl-wrap,.table-responsive,[class*="table-scroll"]):has(> table.bwl-stack){border:0!important;box-shadow:none!important;padding:0!important;background:transparent!important}
}
