/* Registo de Ponto — v2
   Identidade: azul-marinho do ícone (#011a51) + branco; verde = entrar/certo, vermelho = sair/erro, âmbar = a verificar.
   Regras partilhadas: espaçamento em múltiplos de 4 px, cantos 10 / 14 / 22 px, alvos de toque ≥ 44 px,
   contraste de texto ≥ 4,5:1 (WCAG 2.2 AA), foco sempre visível, movimento reduzido respeitado. */
:root {
  --brand: #011a51; --brand-2: #0b2c7a;
  --bg: #f2f4f8; --card: #ffffff; --card2: #eef1f6; --fg: #0b1736; --fg2: #56617b; --fg3: #8089a0; --line: #dde2ec;
  --primary: #011a51; --primary-h: #0b2c7a; --on-primary: #ffffff;
  --tint: #1746b8; --tint-bg: #e5ecfb;
  --go: #177e3f; --go-h: #136a35; --go-bg: #ddf4e5; --go-fg: #11612f;
  --stop: #c62a20; --stop-h: #a9221a; --stop-bg: #fce4e1; --stop-fg: #a31f16;
  --warn: #b25a06; --warn-bg: #fcefd6; --warn-fg: #854700;
  --bar: rgba(255,255,255,.88);
  --shadow: 0 1px 2px rgba(11,23,54,.06), 0 0 0 1px rgba(11,23,54,.03);
  --shadow-lg: 0 24px 64px rgba(1,26,81,.24);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, sans-serif;
  --r: 14px; --r-sm: 10px; --r-lg: 22px; --tabbar: 0px; --side: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #060b18; --card: #101a31; --card2: #1a2644; --fg: #f1f4fb; --fg2: #a9b3ca; --fg3: #7d88a3; --line: #27335280;
    --primary: #3d6be0; --primary-h: #4d7af0; --tint: #9bb8ff; --tint-bg: rgba(77,125,242,.2);
    --go: #177e3f; --go-h: #1a8a45; --go-bg: rgba(46,204,113,.17); --go-fg: #63e092;
    --stop: #d23a2f; --stop-h: #e0463a; --stop-bg: rgba(239,68,68,.2); --stop-fg: #ff8f85;
    --warn: #f0a531; --warn-bg: rgba(251,191,36,.15); --warn-fg: #fbc54a;
    --bar: rgba(10,16,32,.88); --shadow: 0 0 0 1px rgba(255,255,255,.05); --shadow-lg: 0 24px 64px rgba(0,0,0,.6);
    color-scheme: dark; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 17px; line-height: 1.38; -webkit-font-smoothing: antialiased; }
@media (min-width: 960px) { html, body { font-size: 16px; } }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--fg2); font-size: .88rem; }
.centro { text-align: center; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--tint); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
.ico, .pill svg, .mat-estado svg, .chip svg { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: none; }
a { color: var(--tint); }
.skip { position: fixed; left: 12px; top: -80px; z-index: 100; background: var(--primary); color: var(--on-primary); border: 0; border-radius: var(--r-sm); padding: 10px 14px; font-weight: 600; }
.skip:focus { top: calc(12px + env(safe-area-inset-top, 0px)); }

/* ---------- estrutura: barra lateral (computador), barra de topo e separadores em baixo (telemóvel) ---------- */
.side { display: none; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.topbar .in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 12px; min-height: 56px;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
.topbar h1 { flex: 1; min-width: 0; margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .tit { flex: 1; min-width: 0; display: grid; }
.topbar .tit small { font-size: .8rem; line-height: 1.2; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .mark { width: 32px; height: 32px; flex: none; display: grid; padding: 0; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.topbar .mark { position: relative; }
.topbar .mark::after { content: ""; position: absolute; inset: -6px; }
.topbar .mark svg, .logo svg { width: 100%; height: 100%; display: block; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--tint-bg); color: var(--tint); font-weight: 700; font-size: .88rem;
  display: grid; place-items: center; flex: none; }
.offline { background: var(--warn-bg); color: var(--warn-fg); font-size: .9rem; font-weight: 600; text-align: center; padding: 8px 16px; display: flex; gap: 8px; justify-content: center; align-items: center; }
.offline svg { width: 18px; height: 18px; flex: none; }

.wrap { max-width: 1180px; margin: 0 auto; display: grid; gap: 20px; align-content: start;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(32px + var(--tabbar) + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.wrap.narrow { max-width: 560px; }
.wrap:focus { outline: none; }
.sec-title { margin: 0 4px -12px; font-size: .84rem; font-weight: 650; color: var(--fg2); letter-spacing: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 4px -12px; min-height: 32px; }
.sec-head .sec-title { margin: 0; }
.sec-head .btn { margin-right: -6px; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; min-width: 0; box-shadow: var(--shadow); }
.card h2 { margin: 0; font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; }
.card h3 { margin: 0; font-size: .95rem; color: var(--fg2); font-weight: 600; }
.card.muted { box-shadow: none; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line); display: flex; padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
.tabbar button { flex: 1; min-width: 0; background: none; border: 0; display: grid; justify-items: center; gap: 2px; padding: 2px; color: var(--fg2); font-size: .68rem; font-weight: 600; position: relative; min-height: 50px; border-radius: 12px; }
.tabbar button .ti { width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background .15s; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button span.lb { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabbar button[aria-current="page"] { color: var(--tint); }
.tabbar button[aria-current="page"] .ti { background: var(--tint-bg); }
.tabbar .badge { position: absolute; top: 0; left: calc(50% + 8px); }
body.has-tabbar { --tabbar: 66px; }

@media (min-width: 960px) {
  body.has-side { --side: 252px; padding-left: var(--side); }
  body.has-side .tabbar { display: none; }
  body.has-side { --tabbar: 0px; }
  body.has-side .topbar .mark, body.has-side .topbar .avatar, body.has-side .topbar .tit small { display: none; }
  body.has-side .topbar .in { min-height: 68px; padding-left: 32px; padding-right: 32px; }
  body.has-side .topbar h1 { font-size: 1.6rem; }
  body.has-side .wrap { padding: 24px 32px 48px; }
  .side { display: flex; flex-direction: column; gap: 4px; position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 25; overflow-y: auto;
    background: var(--brand); color: #fff; padding: 20px 12px 12px; }
  .side .brand { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 8px; margin-bottom: 12px; border: 0; border-radius: var(--r-sm); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
  .side .brand:hover { background: rgba(255,255,255,.09); }
  .side .brand .tx { display: block; min-width: 0; }
  .side .brand .logo { width: 44px; height: 44px; flex: none; border-radius: 11px; box-shadow: 0 0 0 1px rgba(255,255,255,.22); overflow: hidden; }
  .side .brand b { display: block; font-size: 1.02rem; letter-spacing: -.01em; }
  .side .brand .tx span { font-size: .74rem; letter-spacing: .08em; color: rgba(255,255,255,.66); font-weight: 600; }
  .side nav { display: grid; gap: 2px; }
  .side .grp { margin: 14px 12px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.55); }
  .side nav button, .side .me { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 8px 12px; border: 0; border-radius: var(--r-sm);
    background: none; color: rgba(255,255,255,.8); font-weight: 600; text-align: left; }
  .side nav button svg { width: 22px; height: 22px; flex: none; }
  .side nav button:hover, .side .me:hover { background: rgba(255,255,255,.09); color: #fff; }
  .side nav button[aria-current="page"] { background: rgba(255,255,255,.17); color: #fff; }
  .side .badge { margin-left: auto; }
  .side .me { margin-top: auto; padding: 10px; border-top: 1px solid rgba(255,255,255,.14); border-radius: 0 0 var(--r-sm) var(--r-sm); }
  .side .me .avatar { background: rgba(255,255,255,.16); color: #fff; width: 36px; height: 36px; }
  .side .me .grow { min-width: 0; }
  .side .me b, .side .me small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side .me b { font-size: .92rem; color: #fff; } .side .me small { font-size: .76rem; color: rgba(255,255,255,.66); font-weight: 500; }
  .side :focus-visible { outline-color: #fff; }
}
@media (prefers-color-scheme: dark) { .side { background: #0a1330; border-right: 1px solid var(--line); } }

/* ---------- listas agrupadas ---------- */
.group { background: var(--card); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.modal .group { background: var(--card2); box-shadow: none; }
.group > .cell { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 16px; position: relative; background: none; border: 0; width: 100%; text-align: left; color: var(--fg); font-size: 1rem; font-weight: 400; }
.group > .cell + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.cell .grow { flex: 1; min-width: 0; }
.cell .t1 { font-weight: 550; }
.cell .t2 { color: var(--fg2); font-size: .85rem; margin-top: 1px; font-weight: 400; }
.cell .end { color: var(--fg2); font-variant-numeric: tabular-nums; text-align: right; flex: none; }
.cell .end.forte { color: var(--fg); font-weight: 700; }
.cell .end.vivo { color: var(--go-fg); font-weight: 650; }
.cell .lead { width: 36px; height: 36px; border-radius: 10px; background: var(--tint-bg); color: var(--tint); display: grid; place-items: center; flex: none; }
.cell .lead svg { width: 20px; height: 20px; }
.cell.tap:active { background: var(--card2); }
@media (hover: hover) { button.cell.tap:hover, label.cell.tap:hover { background: color-mix(in srgb, var(--card2) 60%, transparent); } }
.cell:focus-visible { outline-offset: -3px; }
.chev::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--fg3); border-top: 2px solid var(--fg3); transform: rotate(45deg); flex: none; margin-right: 2px; }
.radio { appearance: none; -webkit-appearance: none; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%; border: 2px solid var(--fg3); margin: 0; flex: none; display: grid; place-items: center; background: var(--card); }
.radio:checked { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 4px var(--card); }
.check { appearance: none; -webkit-appearance: none; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 7px; border: 2px solid var(--fg3); margin: 0; flex: none; display: grid; place-items: center; background: var(--card); }
.check:checked { border-color: var(--primary); background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27white%27 stroke-width=%273.2%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpath d=%27M5 12.5l4.5 4.5L19 7.5%27/%3E%3C/svg%3E") center/16px no-repeat; }
.check:disabled { background: var(--card2); border-color: var(--line); }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 999px; background: var(--fg3); position: relative; flex: none; transition: background .15s; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch:checked { background: var(--go); }
.switch:checked::after { transform: translateX(20px); }
.switch-l { display: inline-flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 600; color: var(--fg); }

.list { display: grid; gap: 12px; }
@media (min-width: 1100px) { .list.cartoes { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } .list.cartoes > .empty, .list.cartoes > .sk-list { grid-column: 1 / -1; } }
.item { background: var(--card2); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; }
.item .top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 150px; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- formulários ---------- */
label { display: grid; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--fg2); }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--r-sm); background: var(--card2); color: var(--fg); font-size: 1rem; font-weight: 400; }
input::placeholder, textarea::placeholder { color: var(--fg2); opacity: .9; }
textarea { min-height: 84px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 8%27%3E%3Cpath d=%27M1 1.5 6 6.5l5-5%27 fill=%27none%27 stroke=%27%237c869c%27 stroke-width=%271.8%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; text-overflow: ellipsis; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--tint); outline-offset: 0; border-color: transparent; }
input:disabled, select:disabled { opacity: .6; }
.field { display: grid; gap: 6px; }
.field > label { font-size: .88rem; color: var(--fg); }
.hint { margin: 0; font-size: .84rem; color: var(--fg2); font-weight: 400; }
.pw { position: relative; }
.pw input { padding-right: 52px; }
.pw-ver { position: absolute; right: 2px; top: 1px; width: 46px; height: 44px; border: 0; background: none; color: var(--fg2); display: grid; place-items: center; border-radius: var(--r-sm); }
.pw-ver svg { width: 22px; height: 22px; }
.pw-ver[aria-pressed="true"] { color: var(--tint); }
/* barra de filtros (pesquisa + escolhas) por cima das listas e tabelas */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar > * { flex: 0 1 auto; }
.toolbar input, .toolbar select { background-color: var(--card); border-color: var(--line); }
.toolbar select { width: auto; max-width: 100%; flex: 1 1 150px; }
.toolbar .esp { flex: 1 1 0; }
@media (max-width: 599px) { .toolbar > .btn { flex: 1 1 100%; } }
.search { position: relative; display: block; flex: 2 1 220px; min-width: 0; }
.search > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--fg3); pointer-events: none; }
.search input { padding-left: 38px; }
.conta { color: var(--fg2); font-size: .86rem; font-variant-numeric: tabular-nums; }

/* ---------- botões ---------- */
.btn { min-height: 46px; border: 0; border-radius: 12px; padding: 10px 18px; font-weight: 650; background: var(--primary); color: var(--on-primary); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: background .12s, transform .08s; }
.btn.sec { background: var(--tint-bg); color: var(--tint); }
.btn.plain { background: none; color: var(--tint); padding: 10px 8px; }
.btn.plain.perigo { color: var(--stop-fg); }
.btn.go { background: var(--go); color: #fff; }
.btn.stop { background: var(--stop); color: #fff; }
.btn.go-t { background: var(--go-bg); color: var(--go-fg); }
.btn.stop-t { background: var(--stop-bg); color: var(--stop-fg); }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: .9rem; border-radius: var(--r-sm); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.98); }
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--primary-h); }
  .btn.go:hover:not(:disabled) { background: var(--go-h); } .btn.stop:hover:not(:disabled) { background: var(--stop-h); }
  .btn.sec:hover:not(:disabled), .btn.go-t:hover:not(:disabled), .btn.stop-t:hover:not(:disabled) { filter: brightness(.96); background: var(--tint-bg); }
  .btn.go-t:hover:not(:disabled) { background: var(--go-bg); } .btn.stop-t:hover:not(:disabled) { background: var(--stop-bg); }
  .btn.plain:hover:not(:disabled) { background: var(--tint-bg); }
}
.btn > svg { width: 20px; height: 20px; flex: none; }
.btn.a-carregar { position: relative; color: transparent !important; pointer-events: none; }
.btn.a-carregar::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(255,255,255,.45); border-top-color: #fff; animation: roda .7s linear infinite; }
@keyframes roda { to { transform: rotate(360deg); } }
.big { width: 100%; min-height: 66px; font-size: 1.3rem; font-weight: 750; border-radius: 18px; letter-spacing: .02em; }
.big.duas { flex-direction: column; gap: 0; line-height: 1.15; padding: 10px 18px; }
.big.duas small { font-size: .8rem; font-weight: 550; letter-spacing: 0; opacity: .92; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
label.btn { cursor: pointer; }

/* ---------- estados ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 650; margin: 2px 4px 2px 0; background: var(--card2); color: var(--fg2); white-space: nowrap; }
.pill.bad { background: var(--stop-bg); color: var(--stop-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.ok { background: var(--go-bg); color: var(--go-fg); }
.pill.tint { background: var(--tint-bg); color: var(--tint); }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-fg); font-size: .92rem; display: flex; gap: 10px; align-items: flex-start; }
.notice > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.notice.bad { background: var(--stop-bg); color: var(--stop-fg); }
.notice.info { background: var(--tint-bg); color: var(--tint); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--stop); color: #fff; font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 36px 20px; color: var(--fg2); background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.empty > svg { width: 40px; height: 40px; color: var(--fg3); margin-bottom: 4px; }
.empty b { color: var(--fg); font-size: 1.05rem; }
.empty span { font-size: .92rem; max-width: 42ch; }
.empty .btn { margin-top: 8px; }
.empty.ok > svg { color: var(--go); } .empty.bad > svg { color: var(--stop); }
.modal .empty, .card .empty { box-shadow: none; background: none; padding: 20px 8px; }
.sk-list { display: grid; gap: 10px; }
.sk { height: 60px; border-radius: var(--r); background: linear-gradient(90deg, var(--card) 20%, var(--card2) 50%, var(--card) 80%); background-size: 200% 100%; animation: sk 1.3s ease-in-out infinite; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- ecrã Ponto ---------- */
.hero { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 24px 20px 22px; display: grid; gap: 4px; justify-items: center; text-align: center;
  color: #fff; background: linear-gradient(165deg, var(--brand) 0%, var(--brand-2) 100%); box-shadow: 0 10px 28px rgba(1,26,81,.22); }
.hero .marca { position: absolute; right: -34px; bottom: -78px; width: 300px; height: 300px; opacity: .08; pointer-events: none; }
.hero .time { font-family: var(--font-num); font-size: clamp(3.6rem, 19vw, 5rem); font-weight: 650; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; position: relative; }
.hero .date { color: rgba(255,255,255,.78); font-size: 1rem; position: relative; }
.state { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 14px; border-radius: 999px; font-weight: 650; font-size: .95rem; margin-top: 12px; position: relative; }
.state span.tx { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.state.in { background: #fff; color: #11612f; }
.state.in .dot { background: #1c9a4c; animation: pulse 1.6s ease-in-out infinite; }
.state.out { background: rgba(255,255,255,.15); color: #fff; }
@keyframes pulse { 50% { opacity: .35; } }
.elapsed { font-size: 1rem; color: rgba(255,255,255,.86); font-variant-numeric: tabular-nums; position: relative; margin-top: 6px; }
.cta-bar { position: sticky; bottom: var(--tabbar); z-index: 15; margin: 0 -16px; padding: 12px 16px calc(10px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 6px;
  background: linear-gradient(to top, var(--bg) 78%, transparent); }
body.has-tabbar .cta-bar { padding-bottom: 10px; }
.cta-bar .hint { text-align: center; }
.obra-conf { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 4px 0; }
.obra-conf .lead { width: 60px; height: 60px; border-radius: 18px; background: var(--tint-bg); color: var(--tint); display: grid; place-items: center; }
.obra-conf .lead svg { width: 32px; height: 32px; }
.obra-conf b { font-size: 1.4rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
.obra-conf .pill { margin: 4px 0 0; font-size: .86rem; padding: 4px 12px; }
.resumo2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.day-total { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.day-total b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }

/* ---------- folhas (sheets), diálogos e câmara ---------- */
body.modal-open { overflow: hidden; }
.modal-bg { position: fixed; inset: 0; background: rgba(4,10,28,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .2s ease; }
.modal { position: relative; background: var(--card); color: var(--fg); width: min(560px, 100%); max-height: min(92vh, 92dvh); overflow: auto; overscroll-behavior: contain; border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; align-content: start; box-shadow: var(--shadow-lg); animation: up .28s cubic-bezier(.2,.8,.2,1); }
.modal.largo { width: min(720px, 100%); }
.modal:focus { outline: none; }
.modal::before { content: ""; width: 38px; height: 5px; border-radius: 3px; background: var(--line); justify-self: center; }
.modal h2 { margin: 0; font-size: 1.2rem; text-align: center; letter-spacing: -.01em; padding: 0 40px; overflow-wrap: anywhere; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--card2); color: var(--fg2); display: grid; place-items: center; z-index: 2; }
.modal-x svg { width: 18px; height: 18px; }
.modal .actions > .btn { flex: 1 1 auto; }
.modal .actions > .btn.sm { flex: 0 0 auto; }
/* os botões principais ficam sempre à vista no fundo da folha */
.modal > .actions:last-child, .modal > form:last-child > .actions:last-child { position: sticky; bottom: 0; z-index: 1; margin: 0 -18px; padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--card); border-top: 1px solid var(--line); }
.modal:has(> .actions:last-child), .modal:has(> form:last-child > .actions:last-child) { padding-bottom: 0; }
@media (min-width: 700px) { .modal-bg { align-items: center; padding: 24px; } .modal { border-radius: var(--r-lg); padding-top: 22px; }
  .modal::before { display: none; } .modal > .actions:last-child, .modal > form:last-child > .actions:last-child { padding-bottom: 16px; border-radius: 0 0 var(--r-lg) var(--r-lg); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.diff { display: grid; gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; }
.diff > div { background: var(--card2); padding: 10px 12px; display: grid; gap: 2px; }
.diff small { font-size: .76rem; font-weight: 650; color: var(--fg2); }
.diff .v { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.diff .novo .v { font-weight: 700; }
.diff .novo small { color: var(--go-fg); }
.citacao { margin: 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--line); color: var(--fg); overflow-wrap: anywhere; }
.quick { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.quick label { flex: 1 1 130px; }
.quick .btn { flex: 1 1 150px; }

.camera { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
.camera .cbottom > * { max-width: 100%; }
.camera .view.sem .oval, .camera .view.sem .hint { display: none; }
.camera .ctop { display: flex; justify-content: space-between; align-items: center; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; gap: 10px; }
.camera .ctop b { flex: 1; min-width: 0; text-align: center; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camera .passo { min-width: 76px; text-align: right; font-size: .82rem; color: rgba(255,255,255,.75); font-variant-numeric: tabular-nums; }
.camera .cbtn { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 600; min-height: 44px; }
.camera :focus-visible { outline-color: #fff; }
.camera .view { position: relative; overflow: hidden; }
.camera video, .camera img.prev { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera video { transform: scaleX(-1); }
.camera .oval { position: absolute; left: 50%; top: 46%; width: min(62vw, 300px); aspect-ratio: 3/4; transform: translate(-50%, -50%); border-radius: 50%;
  box-shadow: 0 0 0 200vmax rgba(0,0,0,.45); border: 3px solid rgba(255,255,255,.85); pointer-events: none; }
.camera .hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-weight: 600; font-size: 1rem; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.camera .cbottom { display: grid; gap: 12px; justify-items: center; padding: 16px 16px calc(18px + env(safe-area-inset-bottom, 0px)); }
.camera .gps { font-size: .86rem; display: flex; gap: 6px; align-items: center; text-align: left; background: rgba(255,255,255,.12); padding: 6px 12px; border-radius: 999px; }
.camera .gps.ok { background: rgba(46,204,113,.24); } .camera .gps.falhou { background: rgba(251,191,36,.26); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active span { transform: scale(.9); }
.shutter:disabled { opacity: .35; }
.camera .confirm { display: flex; gap: 10px; width: min(420px, 100%); }
.camera .confirm .btn { flex: 1; min-height: 56px; font-size: 1.05rem; }
.camera .err { margin: 0 16px; max-width: 420px; flex-direction: column; align-items: stretch; background: #3a1512; color: #ffc9c4; }

.done { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--bg); animation: fade .15s ease; }
.done .box { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 24px; }
.done .ring { width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; color: #fff; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.done .ring svg { width: 58px; height: 58px; }
.done .tit { font-size: 1.25rem; font-weight: 700; }
.done .big-t { font-size: 3.2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.done .sub { color: var(--fg2); font-size: 1.05rem; }
.done .notice { max-width: 340px; text-align: left; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* ---------- tabelas ---------- */
.tablewrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; color: var(--fg2); font-weight: 650; white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
tr.inativo td { color: var(--fg2); }
td select, td input { min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
td .sub { display: block; color: var(--fg2); font-size: .82rem; font-weight: 400; white-space: nowrap; }
@media (min-width: 760px) { td select { min-width: 9.5em; } }
th .sort { border: 0; background: none; padding: 4px 2px; margin: -4px -2px; font: inherit; color: inherit; display: inline-flex; gap: 4px; align-items: center; border-radius: 6px; }
th .sort::after { content: "↕"; opacity: .45; font-size: .9em; }
th[aria-sort="ascending"] .sort::after { content: "↑"; opacity: 1; color: var(--tint); }
th[aria-sort="descending"] .sort::after { content: "↓"; opacity: 1; color: var(--tint); }
@media (hover: hover) { tbody tr:hover td { background: color-mix(in srgb, var(--card2) 55%, transparent); } }
@media (max-width: 759px) {
  /* no telemóvel cada linha passa a um cartão com o nome de cada campo à esquerda */
  table.resp thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.resp, table.resp tbody { display: block; }
  table.resp tr { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.resp tbody tr:last-child { border-bottom: 0; }
  table.resp td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 2px 0; border: 0; text-align: right; min-height: 28px; }
  table.resp td::before { content: attr(data-l); color: var(--fg2); font-size: .8rem; font-weight: 600; text-align: left; flex: none; }
  table.resp td.main { justify-content: flex-start; text-align: left; font-size: 1rem; flex-wrap: wrap; gap: 4px 8px; }
  table.resp td.main::before, table.resp td:empty, table.resp td.so-pc { display: none; }
  table.resp td select, table.resp td input { max-width: 62%; }
  table.resp tr.total { border-top: 2px solid var(--line); } table.resp tr.total td { border: 0; }
  table.resp td.vazio { justify-content: center; } table.resp td.vazio::before { display: none; }
}
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; cursor: pointer; background: var(--card2); border: 0; padding: 0; }
.thumb { overflow: hidden; display: inline-block; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-grande { width: 100%; max-height: 70vh; object-fit: contain; border-radius: var(--r); background: var(--card2); }

.seg { display: flex; background: var(--card2); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; min-height: 38px; padding: 4px 12px; font-weight: 600; font-size: .9rem; color: var(--fg2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(11,23,54,.16); }
.toolbar .seg { background: color-mix(in srgb, var(--fg3) 18%, transparent); }

.daynav { display: flex; align-items: center; gap: 8px; }
.daynav .lbl { flex: 1; min-width: 0; text-align: center; font-weight: 700; color: var(--fg); font-size: 1.05rem; position: relative; cursor: pointer; border-radius: var(--r-sm); padding: 2px 4px; }
.daynav .lbl small { display: block; color: var(--fg2); font-weight: 500; font-size: .82rem; }
.daynav .lbl input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; min-height: 0; padding: 0; cursor: pointer; }
.daynav .lbl:focus-within { outline: 3px solid var(--tint); outline-offset: 2px; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card2); color: var(--tint); display: grid; place-items: center; flex: none; }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:disabled { opacity: .35; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats.q4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .stats.q4 { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border-radius: var(--r); padding: 12px 8px; text-align: center; box-shadow: var(--shadow); border: 2px solid transparent; color: var(--fg); min-width: 0; }
button.stat[aria-pressed="true"] { border-color: var(--primary); }
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.2; }
.stat span { color: var(--fg2); font-size: .8rem; font-weight: 500; }
.stat b.go { color: var(--go-fg); } .stat b.bad { color: var(--stop-fg); } .stat b.warn { color: var(--warn-fg); }
.who-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--line); }
.who-dot.in { background: var(--go); box-shadow: 0 0 0 4px var(--go-bg); } .who-dot.fez { background: var(--tint); }

/* toast (aviso curto) */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--tabbar, 0px) + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); background: rgba(13,21,44,.96); color: #fff;
  padding: 12px 16px; border-radius: 14px; font-size: .95rem; font-weight: 550; width: max-content; max-width: min(92vw, 480px); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  display: flex; gap: 10px; align-items: flex-start; text-align: left; box-shadow: var(--shadow-lg); margin-left: calc(var(--side) / 2); }
#toast svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: #6ee7a0; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--stop); } #toast.bad svg { color: #fff; }

/* login, escolha de password e RGPD */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-left, 0px)) 24px;
  background: radial-gradient(1200px 520px at 50% -180px, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%), var(--bg); }
.login form, .login .rgpd { width: min(400px, 100%); display: grid; gap: 16px; }
.login .rgpd { width: min(500px, 100%); }
.login .brand { display: grid; justify-items: center; gap: 4px; text-align: center; margin-bottom: 8px; }
.login .brand .logo { width: 84px; height: 84px; border-radius: 20px; overflow: hidden; box-shadow: 0 12px 28px rgba(1,26,81,.3); margin-bottom: 12px; }
.login .brand h1 { margin: 0; font-size: 1.7rem; letter-spacing: -.02em; }
.login .brand .org { font-size: .8rem; font-weight: 700; letter-spacing: .14em; color: var(--fg2); }
.login input { background: var(--card); border-color: var(--line); min-height: 52px; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.rgpd-txt { font-size: .95rem; line-height: 1.5; max-height: 52vh; overflow: auto; }
.rgpd-txt p { margin: 0 0 10px; } .rgpd-txt ul { margin: 0 0 10px; padding-left: 20px; } .rgpd-txt li { margin-bottom: 6px; }
.rgpd-txt p:last-child { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- empresas: etiqueta (sigla + cor), filtros e blocos na Equipa ---------- */
.c-laranja  { --ec: #f28c00; --ec-bg: rgba(242,140,0,.16);  --ec-fg: #8f4b00; }
.c-azul     { --ec: #1f5fbf; --ec-bg: rgba(31,95,191,.13);  --ec-fg: #1a4f9e; }
.c-verde    { --ec: #2a9d55; --ec-bg: rgba(42,157,85,.15);  --ec-fg: #166534; }
.c-roxo     { --ec: #8e44ad; --ec-bg: rgba(142,68,173,.13); --ec-fg: #7a3596; }
.c-rosa     { --ec: #d6336c; --ec-bg: rgba(214,51,108,.13); --ec-fg: #a82050; }
.c-petroleo { --ec: #138a8a; --ec-bg: rgba(19,138,138,.14); --ec-fg: #0b5f5f; }
.c-castanho { --ec: #8d5b3a; --ec-bg: rgba(141,91,58,.15);  --ec-fg: #6b4127; }
.c-cinzento { --ec: #6b7280; --ec-bg: rgba(107,114,128,.15); --ec-fg: #4b5260; }
@media (prefers-color-scheme: dark) {
  .c-laranja  { --ec-bg: rgba(242,140,0,.24);  --ec-fg: #ffb347; }
  .c-azul     { --ec: #4a8bf0; --ec-bg: rgba(74,139,240,.24); --ec-fg: #9cc2ff; }
  .c-verde    { --ec-bg: rgba(42,157,85,.26);  --ec-fg: #6fdc97; }
  .c-roxo     { --ec: #b06fd0; --ec-bg: rgba(176,111,208,.26); --ec-fg: #d6a6ef; }
  .c-rosa     { --ec: #ec5a8d; --ec-bg: rgba(236,90,141,.24); --ec-fg: #ff9cbf; }
  .c-petroleo { --ec: #22b3b3; --ec-bg: rgba(34,179,179,.24); --ec-fg: #73dddd; }
  .c-castanho { --ec: #b3825f; --ec-bg: rgba(179,130,95,.26); --ec-fg: #ddb594; }
  .c-cinzento { --ec: #9097a3; --ec-bg: rgba(144,151,163,.26); --ec-fg: #c3c8d0; }
}
.emp { display: inline-block; vertical-align: middle; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap; background: var(--ec-bg, var(--card2)); color: var(--ec-fg, var(--fg2)); }
h2 > .emp { margin-left: 6px; }
.edot { width: 10px; height: 10px; border-radius: 50%; background: var(--ec, var(--fg2)); flex: none; display: inline-block; }
.chips { display: flex; gap: 8px; overflow-x: auto; min-width: 0; margin: -4px -16px; padding: 4px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.modal .chips { margin: 0 -18px; padding: 4px 18px; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); font-size: .9rem; font-weight: 600; color: var(--fg); }
.chip[aria-pressed="true"] { border-color: var(--ec, var(--primary)); background: var(--ec-bg, var(--primary)); color: var(--ec-fg, var(--on-primary)); }
.emp-head { display: flex; align-items: center; gap: 7px; color: var(--ec-fg); }
.emp-head .emp-res { margin-left: auto; font-weight: 500; color: var(--fg2); }
.group.emp-bloco { box-shadow: inset 4px 0 0 var(--ec), var(--shadow); }

/* ---------- mapa dos trabalhadores ativos ---------- */
.mapa-topo { display: grid; gap: 12px; }
.mapa-resumo { display: flex; align-items: baseline; gap: 8px; }
.mapa-resumo b { font-size: 2rem; font-variant-numeric: tabular-nums; color: var(--go-fg); line-height: 1; }
.mapa { height: calc(100dvh - 300px - var(--tabbar)); min-height: 360px; border-radius: var(--r); overflow: hidden; background: #1b2a33; z-index: 0; box-shadow: var(--shadow); }
.mk-p { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #17222b;
  border: 4px solid var(--mc); font: 700 .72rem/1 var(--font); box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.mk-cl { border-radius: 50%; display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.5); cursor: pointer; }
.mk-cl span { width: calc(100% - 12px); height: calc(100% - 12px); border-radius: 50%; background: #fff; color: #17222b;
  display: grid; place-items: center; font: 800 1rem/1 var(--font-num); }
.mp-pop { font-family: var(--font); min-width: 220px; color: #17222b; }
.mp-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.mp-lista { display: grid; gap: 8px; margin-top: 8px; }
.mp-l { border-top: 1px solid rgba(0,0,0,.1); padding-top: 6px; }
.mp-pop .muted { font-size: .8rem; color: #5b6670; }
.mp-pop .btn.sec { background: #e5ecfb; color: #1746b8; }
.leaflet-popup-content { margin: 12px 14px; }

/* ---------- fotos de obra e pedidos de material ---------- */
.obra-acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.obra-acoes .btn.big { flex-direction: column; gap: 8px; min-height: 120px; font-size: 1.05rem; border-radius: 18px; letter-spacing: 0; }
.obra-acoes .btn.big > svg { width: 38px; height: 38px; }
.item.mat { background: var(--card); box-shadow: var(--shadow); border-left: 4px solid transparent; }
button.item.mat { width: 100%; border-top: 0; border-right: 0; border-bottom: 0; text-align: left; font: inherit; color: var(--fg); cursor: pointer; }
.item.mat.novo { border-left-color: var(--warn); }
.item.mat.lido { border-left-color: var(--tint); }
.item.mat.resolvido { border-left-color: var(--go); }
.mat-txt { white-space: pre-wrap; font-size: 1rem; line-height: 1.45; overflow-wrap: anywhere; }
.item audio, #pmAudio audio { width: 100%; height: 40px; }
.item .actions { display: flex; gap: 8px; }
.fotos-grelha { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.foto-mini { position: relative; padding: 0; border: 0; background: var(--card2); border-radius: 12px; overflow: hidden; display: grid; text-align: left; color: var(--fg); }
.foto-mini img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.foto-mini span { font-size: .72rem; padding: 4px 6px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foto-x { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 1.2rem; line-height: 1; }
.sec-title + .fotos-grelha { margin-top: 18px; }
#oFotos, #foGrelha { display: grid; gap: 14px; }
.mat-resumo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mat-estado { font-size: .85rem; font-weight: 600; color: var(--fg2); }
.mat-estado.ok { color: var(--go-fg); } .mat-estado.tint { color: var(--tint); }
.volta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.volta h2 { margin: 0; flex: 1; min-width: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
