:root {
    --bg: #f5f7fa;
    --fg: #1c1f23;
    --muted: #6b7280;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --border: #e5e7eb;
    --card: #ffffff;
    --radius: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'SF Mono', Consolas, monospace; background: #eef1f5; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
h1 { font-size: 1.75rem; margin: 0 0 1rem; font-weight: 600; }
h2 { font-size: 1.25rem; margin: 0 0 0.75rem; font-weight: 600; }

.app-shell { display: flex; min-height: 100vh; }
.app-nav { width: 220px; background: #1f2937; color: #e5e7eb; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 4px; }
.app-nav .brand { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; padding: 0 4px; }
.app-nav .nav-link { display: block; padding: 8px 10px; color: #cbd5e1; border-radius: var(--radius); font-size: 0.92rem; }
.app-nav .nav-link:hover { background: #374151; color: #fff; text-decoration: none; }
.app-nav .nav-link.active { background: var(--primary); color: #fff; }

.app-main { flex: 1; display: flex; flex-direction: column; }
.app-topbar { background: #fff; padding: 10px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.app-content { padding: 1.5rem 2rem; max-width: 1400px; }
.user-chip { font-size: 0.9rem; color: var(--muted); }

.lang-switch { font-size: 0.85rem; color: var(--muted); }
.lang-switch a { color: var(--fg); margin: 0 4px; }

button, .btn-primary, .btn-ghost, .btn-danger {
    display: inline-block; padding: 8px 16px; font-size: 0.9rem; border: none; border-radius: var(--radius); cursor: pointer;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; color: var(--fg); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f3f4f6; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
/* Só para leitores de ecrã (ex.: «continuação da descrição:» antes do texto que continua uma linha do talão). */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.rd-line-cont > button { margin-left: 6px; padding: 0 6px; font-size: 0.75rem; }

input, select, textarea {
    padding: 8px 10px; font-size: 0.9rem; border: 1px solid var(--border); border-radius: var(--radius);
    font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
input.wide { flex: 1; }
label { font-size: 0.85rem; color: var(--muted); }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 1.25rem; }
.kpi { background: #fff; border: 1px solid var(--border); padding: 14px; border-radius: var(--radius); }
.kpi-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.kpi-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }
.kpi.ok .kpi-value { color: var(--success); }
.kpi.bad .kpi-value { color: var(--danger); }
.kpi.warn .kpi-value { color: var(--warning); }

table.clean { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
table.clean th, table.clean td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
table.clean thead th { background: #f9fafb; font-weight: 600; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.3px; }
table.clean.tight th, table.clean.tight td { padding: 6px 10px; font-size: 0.85rem; }
/* Treino: loja candidata a um modelo custom (5 ou mais talões e produtos corrigidos) */
table.clean tr.row-attention td { background: #fffbeb; }
table.clean tr.row-attention td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }

.filters, .form-row { display: flex; gap: 8px; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; }

.badge, .pill { display: inline-block; padding: 2px 8px; font-size: 0.75rem; border-radius: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-approved, .pill-pass { background: #d1fae5; color: #065f46; }
.badge-rejected, .pill-fail { background: #fee2e2; color: #991b1b; }
.badge-manualreview, .pill-inconclusive { background: #fef3c7; color: #92400e; }
.badge-pending, .pill-skipped { background: #e5e7eb; color: #374151; }
.pill-delivered { background: #d1fae5; color: #065f46; }
.pill-failed, .pill-deadletter { background: #fee2e2; color: #991b1b; }
.pill-pending { background: #fef3c7; color: #92400e; }
.pill-cancelled { background: #e5e7eb; color: #374151; }
/* Confirmação de uma ação que apaga ou desliga (ConfirmButton): só aparece depois do primeiro clique */
.confirm-ask { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.confirm-q { font-size: 0.85rem; font-weight: 600; color: var(--danger); }
/* Talão: o produto do catálogo por baixo de cada EAN esperado, para comparar com o que foi lido */
.rd-cat { margin-top: 3px; max-width: 22rem; font-size: 0.8rem; line-height: 1.35; white-space: normal; }
.rd-cat > span { display: block; }
/* Talão: um EAN pedido mais de uma vez (repetido uma vez por unidade) — pedidas, vistas no talão e válidas; só nesses EANs */
.rd-units { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.8rem; }
.rd-units > label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; white-space: nowrap; }
.rd-units input { width: 4.5rem; padding: 4px 6px; }
.rd-units input:disabled { opacity: 0.5; cursor: not-allowed; }
/* Talão: «Voltar à lista» e «Seguinte para revisão» por baixo do título (no telemóvel estão na barra de decisão) */
.rd-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 1rem; }
/* Lojas autorizadas: mudar o nome (canónico) de uma loja */
.store-rename { margin-left: 6px; padding: 0 6px; font-size: 0.8rem; line-height: 1.5; }
.store-edit { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.store-edit > input { min-width: 16rem; }
.store-edit-only { flex-basis: 100%; font-size: 0.8rem; color: var(--fg); }
.pill-found { background: #d1fae5; color: #065f46; }
.pill-notfound { background: #fee2e2; color: #991b1b; }
.pill-notincatalog { background: #e5e7eb; color: #374151; }
.pill-ambiguous { background: #fde68a; color: #78350f; }

dl dt { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 8px; }
dl dd { margin: 0 0 4px 0; }

.muted { color: var(--muted); font-size: 0.85rem; }
.small { font-size: 0.78rem; }
.ok-msg { color: var(--success); margin-left: 8px; }
.error, .error-list { color: var(--danger); font-size: 0.85rem; }
.warning-box { background: #fef3c7; padding: 12px; border-radius: var(--radius); margin-top: 10px; }
.warning-box .key { display: block; margin-top: 6px; font-size: 0.85rem; word-break: break-all; background: #fff; padding: 8px; border-radius: 4px; }

.pager { margin-top: 1rem; display: flex; gap: 10px; align-items: center; }
.actions { margin-top: 1.5rem; display: flex; gap: 8px; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-card { background: #fff; padding: 2rem 2.5rem; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); width: 360px; }
.login-card h1 { margin-bottom: 1.5rem; }
.login-card form { display: flex; flex-direction: column; gap: 8px; }
.login-card input[type=email], .login-card input[type=password] { width: 100%; }
.login-card button { margin-top: 10px; }

/* Estado / revisão no Dashboard */
tr.late td { color: var(--danger); font-weight: 600; }

/* Página Recibos unificada */
.filters .search { flex: 1 1 280px; min-width: 220px; }
.id-cell { cursor: help; }
.actions { flex-wrap: wrap; align-items: center; }

/* Imagem do recibo + lightbox (zoom + rodar) */
.receipt-thumb { max-height: 180px; max-width: 100%; width: auto; border: 1px solid var(--border); border-radius: var(--radius); cursor: zoom-in; display: block; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.88); z-index: 2000; display: flex; flex-direction: column; overscroll-behavior: contain; }
.lightbox-bar { display: flex; gap: 8px; align-items: center; padding: 10px 14px; background: rgba(0,0,0,0.65); color: #fff; flex-wrap: wrap; flex: 0 0 auto; }
.lightbox-bar span { color: #fff; min-width: 52px; text-align: center; }
.lightbox-bar a.btn-ghost, .lightbox-bar button.btn-ghost { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.3); }
/* align 'safe center' garante que o conteúdo ampliado continua alcançável pelo scroll;
   overscroll-behavior impede o scroll de mexer a página por baixo. */
.lightbox-stage { flex: 1 1 auto; overflow: auto; overscroll-behavior: contain; display: flex; align-items: safe center; justify-content: safe center; padding: 12px; }
/* O zoom altera a ALTURA real da imagem (não um transform), para o visor ganhar scroll a sério. */
.lightbox-img { height: calc((100vh - 90px) * var(--z, 1)); width: auto; max-width: none; transform-origin: center center; cursor: zoom-in; }

/* Seletor de tenant (SuperAdmin) e faixa de contexto */
.tenant-switch { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; }
.tenant-switch select { max-width: 200px; padding: .2rem .4rem; border-radius: 4px; border: 1px solid #cfd8dc; background: #fff; }
.impersonation-band { background: #fff8e1; border-bottom: 1px solid #ffe082; padding: .4rem 1rem; font-size: .85rem; }
.impersonation-band a { margin-left: .75rem; }
.pill-foundwithlowconfidence { background: #fff3e0; color: #e65100; }

/* Comparação lado a lado (benchmark/{id}) e avisos no detalhe do talão */
.compare-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.compare-grid { display: grid; grid-template-columns: minmax(300px, 1fr) 1.5fr; gap: 1rem; align-items: start; }
.compare-grid > .card:first-child { position: sticky; top: 1rem; }
@media (max-width: 1000px) { .compare-grid { grid-template-columns: 1fr; } .compare-grid > .card:first-child { position: static; } }
.receipt-thumb-large { max-height: 78vh; }
.compare-table th:first-child { text-align: left; width: 120px; }
tr.diff td { background: #fff7ed; }
.notice-warn { background: #fef3c7; border-left: 4px solid #d97706; padding: .6rem .8rem; margin-top: .5rem; border-radius: 6px; }
.notice-warn button { margin-left: .5rem; }
dl.inline { display: grid; grid-template-columns: max-content 1fr; gap: .1rem 1rem; margin: 0 0 .75rem; }
dl.inline dt { margin-top: 0; }
/* Talões em PDF: o <img> não os mostra; vão num iframe (o visualizador do browser trata do zoom) */
.receipt-pdf { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.receipt-pdf.receipt-thumb-large { height: 78vh; }
.lightbox-pdf { width: 96vw; height: calc(100vh - 90px); border: 0; background: #fff; }

/* Auditar resultados (/spot-checks): um cartão por talão da amostra — a imagem à esquerda, o resultado enviado à direita */
.actions.sc-bar { margin: 0 0 1rem; }
.sc-item { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.sc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 6px; }
.sc-store { margin-bottom: 6px; }
.sc-reason { margin-left: 6px; }
.sc-item ul.sc-products { list-style: none; padding: 0; margin: .6rem 0 0; font-size: .9rem; }
.sc-item ul.sc-products > li { margin: 4px 0; }
.actions.sc-actions { margin-top: .9rem; }
.sc-note { flex: 1 1 260px; min-width: 0; }
/* Um talão em PDF no cartão: um quadrado pequeno que abre o PDF (o visualizador de 60vh não cabe na coluna de 220px) */
.receipt-pdf-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 140px; padding: 12px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); text-align: center; }
.receipt-pdf-tag { font-weight: 700; letter-spacing: .08em; color: var(--danger); border: 2px solid currentColor; border-radius: 4px; padding: 2px 8px; }

/* O mesmo talão (pedido do Rui, 2026-10-04): a nota do topo da página do talão com as outras submissões do mesmo talão — pela
   identidade do documento (azul) ou, possivelmente, pelas linhas impressas ou só pelo número do documento (âmbar). Só classes
   rd-same: um talão sem outras submissões fica igual. */
.rd-same { display: grid; gap: .5rem; margin: 0 0 1rem; }
.rd-same-group { padding: .65rem .9rem; background: #eff6ff; border: 1px solid #bfdbfe; border-left: 4px solid var(--primary); border-radius: var(--radius); }
.rd-same-group.rd-same-lines, .rd-same-group.rd-same-number { background: #fffbeb; border-color: #fde68a; border-left-color: var(--warning); }
.rd-same-lead { margin: 0; font-weight: 600; }
.rd-same-date { font-weight: 400; color: var(--muted); }
.rd-same-others { margin: .35rem 0 0; padding-left: 1.1rem; font-size: .85rem; overflow-wrap: anywhere; }
.rd-same-others li { margin: 2px 0; }
p.rd-same-failed { margin: 0 0 1rem; }

/* Portal do cliente na Admin (só SuperAdmin): o cartão «Contestação do cliente» no talão — com a faixa de aviso enquanto está
   por responder —, a linha «Visto pelo cliente» e a etiqueta «Contestado» (no talão e na lista Recibos). Só classes
   rd-contest, rd-access e pill-contest: um talão sem contestações nem aberturas, e a lista sem elas, ficam iguais. */
.rd-contest.rd-contest-open { border-left: 3px solid var(--warning); }
.rd-contest h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rd-contest .rd-contest-meta { margin: 0 0 .5rem; }
.rd-contest .rd-contest-lang { margin: 0 0 .5rem; font-size: .9rem; font-weight: 600; color: #92400e; }
.rd-contest .rd-contest-reason { margin: 0 0 .5rem; padding: .5rem .75rem; background: #f9fafb; border-left: 3px solid var(--border); border-radius: 4px;
    white-space: pre-wrap; overflow-wrap: anywhere; }
.rd-contest .rd-contest-what { margin: 0 0 .75rem; }
.rd-contest .rd-contest-label { display: block; margin-bottom: 4px; }
.rd-contest textarea { display: block; width: 100%; resize: vertical; }
.rd-contest .rd-contest-error { margin: 4px 0 0; }
.rd-contest .rd-contest-actions { margin-top: .75rem; }
.rd-contest .rd-contest-accepting { margin-top: .75rem; }
.rd-contest .rd-contest-answer { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.rd-contest .rd-contest-msg { margin: .75rem 0 0; color: var(--success); }
.rd-contest .rd-contest-older { margin-top: .75rem; }
.rd-contest .rd-contest-older ul, details.rd-access ul { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .85rem; overflow-wrap: anywhere; }
.rd-contest .rd-contest-older summary, details.rd-access summary { cursor: pointer; color: var(--primary); font-size: .85rem; }
p.rd-access { margin: .75rem 0 .25rem; }
.pill-contest { background: #fef3c7; color: #92400e; }
.pill + .pill-contest { margin-left: 4px; }
/* O estado de uma contestação (a fila /contestacoes e o cartão do talão): numa linha só, como as outras etiquetas. */
.pill-contest-state { white-space: nowrap; }

/* Contas (/contas, /contas/clientes, /contas/azure; só SuperAdmin): separadores das três páginas, números à direita, margem
   a verde ou vermelho, a linha do total, versões antigas esbatidas, os comandos do «sem acesso», uma secção por tabela de
   preços. Só classes acc-: nenhuma página que já existia muda. */
.acc-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1rem; }
.acc-bar { margin-bottom: .75rem; }
.acc-state { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 .75rem; }
.acc-notes { margin: 0 0 1rem; }
.acc-notes ul, .acc-continuity ul { margin: .25rem 0; padding-left: 1.2rem; }
table.clean th.acc-num, table.clean td.acc-num { text-align: right; white-space: nowrap; }
table.clean td.acc-pos { color: var(--success); }
table.clean td.acc-neg { color: var(--danger); }
table.clean tr.acc-total td { font-weight: 600; background: #f9fafb; }
table.clean tr.acc-old td, section.acc-old { opacity: .6; }
.acc-tag { margin-left: 6px; }
.acc-note { margin-top: 2px; }
.acc-late { display: inline-block; margin-left: 6px; font-size: .8rem; font-weight: 600; color: var(--warning); }
pre.acc-cmd { margin: .5rem 0 0; padding: 10px 12px; background: #1f2937; color: #e5e7eb; border-radius: var(--radius); font-size: .8rem; white-space: pre-wrap; word-break: break-all; }
.acc-table + .acc-table { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.acc-table h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
input.acc-in { width: 8rem; }
.acc-preview-result { font-size: 1rem; }
.acc-history ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.acc-msg { margin: .5rem 0 0; }

/* Campanhas (/campanhas; spec-campanhas.md, §15.5): os componentes partilhados do editor (Components/Campaigns) e as páginas
   das campanhas. Só classes cmp-: nenhuma página que já existia muda. O portal do cliente (etapa 2b) dá às mesmas classes o
   seu aspeto no portal.css. As regras do telemóvel estão dentro do bloco de 768 px, mais abaixo. */
.cmp-form { display: flex; flex-direction: column; gap: .75rem; }
.cmp-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.cmp-field { display: flex; flex-direction: column; gap: 4px; min-width: 12rem; }
.cmp-grow { flex: 1 1 18rem; }
.cmp-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.cmp-input { width: 100%; }
.cmp-num { width: 8rem; }
textarea.cmp-text { resize: vertical; min-height: 4rem; }
.cmp-hint { font-size: .8rem; color: var(--muted); margin: 0; }
.cmp-errors { margin: 0; padding-left: 1.1rem; color: var(--danger); font-size: .85rem; }
.cmp-error { margin: 0; color: var(--danger); font-size: .85rem; }
.cmp-warn { margin: 0; padding: .5rem .75rem; background: #fef3c7; border-left: 4px solid var(--warning); border-radius: 6px; font-size: .85rem; }
.cmp-group { display: flex; flex-direction: column; gap: .5rem; min-width: 0; margin: 0; padding: .75rem 1rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.cmp-group > legend { padding: 0 6px; font-weight: 600; }
.cmp-check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--fg); }
.cmp-check.cmp-strong { font-weight: 600; }
.cmp-check.cmp-off { color: var(--muted); }
.cmp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cmp-btn { background: #fff; color: var(--fg); border: 1px solid var(--border); }
.cmp-btn:hover { background: #f3f4f6; }
.cmp-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.cmp-btn-primary:hover { background: var(--primary-hover); }
.cmp-btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.cmp-btn-danger:hover { background: #b91c1c; }
.cmp-btn-small { padding: 4px 10px; font-size: .8rem; }
.cmp-link { padding: 0 0 0 8px; background: none; border: 0; color: var(--primary); font-size: .85rem; }
.cmp-link:hover { text-decoration: underline; }
.cmp-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.cmp-empty { margin: 0; color: var(--muted); font-size: .9rem; }
.cmp-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 1rem; }
.cmp-tab { padding: 6px 12px; background: #fff; color: var(--fg); border: 1px solid var(--border); font-size: .85rem; }
.cmp-tab:hover { background: #f3f4f6; }
.cmp-tab-current, .cmp-tab-current:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.cmp-tab-count { display: inline-block; min-width: 1.4em; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--warning); color: #fff;
    font-size: .75rem; font-weight: 700; text-align: center; }
.cmp-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.cmp-table th, .cmp-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; font-size: .9rem; }
.cmp-table thead th { background: #f9fafb; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; }
td.cmp-row-actions, span.cmp-row-actions { white-space: nowrap; }
.cmp-row-actions > button + button { margin-left: 4px; }
.cmp-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.cmp-results > li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 10px; background: #fff;
    border: 1px solid var(--border); border-radius: var(--radius); }
.cmp-search { display: flex; flex-direction: column; gap: 6px; }
.cmp-details > summary { color: var(--primary); font-size: .9rem; cursor: pointer; }
.cmp-details[open] > summary { margin-bottom: 8px; }
.cmp-check.cmp-stale { color: var(--danger); }
.cmp-fields { gap: 10px; }
.cmp-field-card { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.cmp-field-card.cmp-on { border-left: 4px solid var(--primary); }
.cmp-field-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cmp-subtitle { margin: 1rem 0 .25rem; font-size: 1.05rem; }
.cmp-logo-preview { display: block; max-width: 320px; max-height: 80px; padding: 6px; background: #f9fafb; border: 1px solid var(--border); border-radius: 6px; }
.cmp-hero-preview { display: block; max-width: 100%; max-height: 220px; border: 1px solid var(--border); border-radius: 6px; }
.cmp-color { width: 3.5rem; height: 2.4rem; padding: 2px; }
.cmp-hex { width: 7rem; font-family: 'SF Mono', Consolas, monospace; }
.cmp-sample { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 14px 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.cmp-sample-title { color: var(--cmp-brand-ink); font-size: 1.15rem; font-weight: 700; }
.cmp-sample-button { display: inline-block; padding: 8px 18px; border-radius: 8px; background: var(--cmp-brand); color: var(--cmp-on-brand);
    border: 1px solid var(--cmp-brand-border); font-weight: 700; }
.cmp-checklist { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.cmp-checklist > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: .9rem; }
.cmp-mark { width: 1.1rem; font-weight: 700; }
.cmp-pass .cmp-mark { color: var(--success); }
.cmp-fail { color: #991b1b; }
.cmp-confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cmp-confirm-q { color: var(--danger); font-size: .85rem; font-weight: 600; }
.cmp-prefixed { display: flex; align-items: center; gap: 4px; }
.cmp-prefix { color: var(--muted); font-family: 'SF Mono', Consolas, monospace; }
.cmp-campaigns code.cmp-slug { margin-left: 6px; font-size: .75rem; }
.actions.cmp-list-actions { margin: 0 0 1rem; }
.notice-warn.cmp-freeze { margin: 0 0 1rem; }
.cmp-overview dl.inline { margin: 1rem 0 .75rem; }
.cmp-overview .kpi-grid { margin-bottom: .5rem; }
p.cmp-after-publish { margin: -.5rem 0 1rem; }
.cmp-section > h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.cmp-platform .form-row { margin: .5rem 0; }
label.cmp-access { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.pill.cmp-access-pill { margin-left: 4px; background: #e0e7ff; color: #3730a3; }
.cmp-catalog-filter { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px 12px; font-size: .9rem; }   /* Catálogo: os produtos da marca (etapa 2b) */
.pill.cmp-portal-pill { margin-left: 6px; background: #e0e7ff; color: #3730a3; }
.cmp-templates .cmp-group { gap: .9rem; }   /* Mensagens (etapa 5): os modelos, os marcadores e o email de exemplo no papel branco */
.cmp-tpl-placeholders { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 4px 18px; margin: .5rem 0 0; }
.cmp-tpl-placeholder { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: .85rem; color: var(--muted); }
.cmp-tpl-placeholder > dt, .cmp-tpl-placeholder > dd { margin: 0; }
.cmp-tpl-placeholder code { color: var(--fg); font-size: .8rem; }
.cmp-tpl { display: flex; flex-direction: column; gap: .5rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.cmp-tpl:first-of-type { padding-top: 0; border-top: 0; }
.cmp-tpl-title { margin: 0; font-size: 1rem; }
.cmp-tpl-result { margin: 0; color: var(--success); font-size: .85rem; font-weight: 600; }
.cmp-mail { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: #f4f4f5; border: 1px solid var(--border); border-radius: var(--radius); }
.cmp-mail-meta { display: flex; flex-direction: column; gap: 2px; }
.cmp-mail-title { margin: 0; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.cmp-mail-subject { margin: 0; font-weight: 600; }
.cmp-mail-paper { max-width: 600px; padding: 20px 24px; background: #fff; color: #1f2937; border: 1px solid #e5e7eb; border-radius: 8px; }
.cmp-mail-head { margin-bottom: 16px; }
.cmp-mail-logo { display: block; width: auto; max-width: 240px; height: 48px; }
.cmp-mail-brand { margin: 0; color: var(--cmp-brand-ink); font-size: 1.1rem; font-weight: 700; }
.cmp-mail-body > p { margin: 0 0 14px; line-height: 1.5; overflow-wrap: anywhere; }
.cmp-mail-button { display: inline-block; padding: 8px 16px; border-radius: 6px; background: var(--cmp-brand); color: var(--cmp-on-brand);
    border: 1px solid var(--cmp-brand-border); font-weight: 700; }
.cmp-mail-link { color: var(--cmp-brand-ink); text-decoration: underline; word-break: break-all; }
.cmp-mail-foot { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid #e5e7eb; color: #6b7280; font-size: .8rem; }
.cmp-mail-text { max-height: 20rem; margin: 0; padding: 10px 12px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: #fff;
    border: 1px solid var(--border); border-radius: 6px; font-size: .8rem; }
.cmp-area-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 1rem; }   /* Participações e pagamentos (etapa 7): as páginas de uma campanha, os filtros, as etiquetas, o detalhe */
.cmp-area-link { padding: 6px 14px; background: #fff; color: var(--fg); border: 1px solid var(--border); border-radius: 999px; font-size: .9rem; text-decoration: none; }
.cmp-area-link:hover { background: #f3f4f6; text-decoration: none; }
.cmp-area-link.cmp-area-current, .cmp-area-link.cmp-area-current:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.cmp-page-sub { font-size: 1rem; font-weight: 400; }
code.cmp-page-ref { font-size: 1.1rem; }
.cmp-parts, .cmp-payouts, .cmp-detail { display: flex; flex-direction: column; gap: .75rem; }
.cmp-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.cmp-filters .cmp-field { min-width: 9rem; }
.cmp-filters .cmp-grow { flex: 1 1 16rem; }
.cmp-filters-hint { flex: 1 0 100%; margin: -4px 0 0; }
.cmp-filter-actions { padding-bottom: 2px; }
.cmp-parts-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0; }
.cmp-done { margin: 0; padding: .5rem .75rem; background: #ecfdf5; border-left: 4px solid var(--success); border-radius: 6px; font-size: .9rem; }
.cmp-reason-box > .cmp-input { width: auto; flex: 1 1 16rem; }
.cmp-table-wrap { overflow-x: auto; }
.cmp-col-select { width: 2.2rem; }
.cmp-check-input { width: 18px; height: 18px; margin: 0; }
.cmp-table .cmp-num-col { text-align: right; white-space: nowrap; }
.cmp-ref-link { font-family: 'SF Mono', Consolas, monospace; font-weight: 600; }
.cmp-part-email { white-space: nowrap; }
.cmp-part-name { min-width: 7rem; }
.cmp-part-items { min-width: 9.5rem; }
.cmp-chip { display: inline-block; padding: 1px 8px; background: #f3f4f6; color: #374151; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.cmp-chip.cmp-chip--ok { background: #dcfce7; color: #166534; }
.cmp-chip.cmp-chip--wait { background: #fef3c7; color: #92400e; }
.cmp-chip.cmp-chip--no { background: #fee2e2; color: #991b1b; }
.cmp-chip.cmp-chip--off { background: #f3f4f6; color: #6b7280; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 .5rem; }
.cmp-pager { display: flex; align-items: center; gap: 10px; }
.cmp-pager-where { color: var(--muted); font-size: .9rem; }
.cmp-detail-block { padding-top: .75rem; border-top: 1px solid var(--border); }
.cmp-detail-block:first-of-type { padding-top: 0; border-top: 0; }
.cmp-detail-title { margin: 0 0 .5rem; font-size: 1.05rem; }
.cmp-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 6px 18px; margin: 0; }
.cmp-kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cmp-kv dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; }
.cmp-kv dd { margin: 0; overflow-wrap: anywhere; }
.cmp-part-products > li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 6px 10px; background: #fff;
    border: 1px solid var(--border); border-radius: 6px; }
.cmp-part-product-code { margin-left: 6px; color: var(--muted); font-size: .75rem; }
.cmp-amount { margin: .25rem 0 0; }
.cmp-payout-facts { gap: 2px; font-size: .9rem; }
.cmp-payout-note { display: block; margin-top: 2px; }
.cmp-payout-states { margin: 0; }
.cmp-alerts-table td { vertical-align: top; }
.cmp-warn.cmp-erasure { margin: 0 0 1rem; }   /* O apagamento (etapa 8): o aviso por cima das páginas de uma campanha e os pedidos do participante */
.cmp-detail-requests .cmp-actions { margin-bottom: .5rem; }
.cmp-confirm.cmp-erase-box { flex-direction: column; align-items: flex-start; max-width: 48rem; }
.cmp-erase-box > .cmp-warn { width: 100%; }
.cmp-erase-explain { font-size: .85rem; }

/* ===================== Telemóvel (até 768 px) =====================
   Pedido do Rui (2026-09-24): validar talões no telemóvel sem mudar nada no PC. Fora dos blocos para telemóvel só
   há regras neutras no PC: invólucros que não geram caixa (display: contents) e elementos só de telemóvel escondidos.
   Ferramentas para as páginas (tudo inerte no PC):
     .m-only                 elemento que só aparece no telemóvel
     .m-hide                 elemento escondido no telemóvel
     div.table-scroll        invólucro de uma tabela larga: no telemóvel desliza para o lado dentro da própria caixa
     table.clean.m-stack     cada linha vira um cartão; td[data-label] dá a etiqueta, td.m-title o título do cartão,
                             td.m-actions a fila de botões, td.m-wide um campo a toda a largura
     .m-hit                  invólucro de um checkbox: no telemóvel a área inteira carrega no checkbox
     .m-kpis / .m-split / .m-stats   grelhas com estilo inline: 2 colunas / 1 coluna / 2 colunas no telemóvel
     .m-save-bar             barra de gravar de um formulário longo, fixa no fundo do ecrã
     dl.m-kv                 lista etiqueta/valor em duas colunas */
.nav-head, .nav-links, .rd-page, div.table-scroll, .m-hit, div.dash-top { display: contents; }
.nav-burger, .rd-summary, .rd-mobile-bar { display: none; }
@media not all and (max-width: 768px) { .m-only { display: none !important; } }

@media (max-width: 768px) {
    /* ---------- Estrutura: menu recolhido no botão ☰, barra de topo e margens ---------- */
    .app-shell { flex-direction: column; min-height: 100vh; min-height: 100dvh; }
    .app-main { min-width: 0; }
    .app-nav { width: auto; padding: .5rem .85rem; gap: 0; position: sticky; top: 0; z-index: 1500; }
    .nav-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .app-nav .brand { margin: 0; padding: 0; font-size: 1rem; }
    .app-nav .brand br { display: none; }
    .nav-burger { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; min-height: 40px; padding: 4px 12px;
                  background: transparent; color: #e5e7eb; border: 1px solid #4b5563; font-size: 1.3rem; line-height: 1; }
    .nav-links { display: none; }
    .app-nav.open .nav-links { display: flex; flex-direction: column; gap: 2px; padding: .5rem 0 .25rem; max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px); overflow-y: auto; }
    .app-nav .nav-link { padding: 11px 10px; font-size: 1rem; }
    .app-topbar { justify-content: flex-start; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
    .app-topbar .user-email { display: none; }
    .app-topbar .btn-ghost { padding: 6px 12px; }
    .tenant-switch { flex: 1 1 auto; min-width: 0; }
    .tenant-switch select { max-width: none; width: 100%; min-height: 40px; }
    .impersonation-band { padding: .4rem .75rem; }
    .impersonation-band a { display: inline-block; padding: 6px 0; }
    .app-content { padding: 1rem .75rem 1.5rem; max-width: 100%; overflow-wrap: break-word; }
    .login-body { min-height: 100vh; min-height: 100dvh; }
    .login-card { width: calc(100% - 24px); max-width: 360px; padding: 1.5rem 1.25rem; }

    /* ---------- Letra, toque e formulários (16 px nos campos: o iPhone não faz zoom ao tocar) ---------- */
    h1 { font-size: 1.35rem; overflow-wrap: anywhere; }
    h2 { font-size: 1.1rem; overflow-wrap: anywhere; }
    .card { padding: .9rem; }
    .card .card { padding: .75rem; }
    input, select, textarea { font-size: 16px; max-width: 100%; }
    input:not([type=checkbox]):not([type=radio]):not([type=file]), select { min-height: 44px; }
    button, .btn-primary, .btn-ghost, .btn-danger { min-height: 44px; }
    a.btn-primary, a.btn-ghost, a.btn-danger { display: inline-flex; align-items: center; justify-content: center; }
    input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
    input[type=file] { max-width: 100%; }
    input[type=file]::file-selector-button { min-height: 40px; padding: 8px 14px; margin-right: 10px; }
    code, dd, .error, .error-list li, .warning-box, .notice-warn { overflow-wrap: anywhere; }
    .error-list { padding-left: 1.1rem; }
    .card ul { padding-left: 1.1rem; }
    .filters > input, .filters > select, .form-row > input:not([type=checkbox]):not([type=radio]), .form-row > select { flex: 1 1 100%; min-width: 0; }
    .filters .search { flex-basis: 100%; min-width: 0; }
    .form-row > label:has(> select), .form-row > label:has(> input:not([type=checkbox]):not([type=radio])) { display: flex; flex-direction: column; gap: 4px; flex: 1 1 100%; min-width: 0; }
    .form-row > label:has(> select) > select, .form-row > label:has(> input:not([type=checkbox]):not([type=radio])) > input { width: 100% !important; }
    .form-row > label:has(> input[type=checkbox]), label.inline { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
    .form-row > button, .form-row > a.btn-primary, .form-row > a.btn-ghost { flex: 1 1 auto; }
    .actions, .pager { flex-wrap: wrap; }
    .notice-warn button { display: block; width: 100%; margin: .5rem 0 0; }
    .card > input.wide { width: 100%; }
    .grid-2 > *, .compare-grid > * { min-width: 0; }
    .compare-grid { grid-template-columns: minmax(0, 1fr); }
    .receipt-thumb-large { max-height: 60vh; max-height: 60dvh; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .kpi { padding: 10px; min-width: 0; }
    .kpi-label { font-size: .72rem; letter-spacing: 0; }
    .kpi-value { font-size: 1.25rem; overflow-wrap: anywhere; }
    dl.inline { grid-template-columns: max-content minmax(0, 1fr); }
    dl.m-kv { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr); gap: 6px 10px; align-items: baseline; }
    dl.m-kv dt { margin: 0; }
    dl.m-kv dd { margin: 0; }
    .m-hide { display: none !important; }
    .m-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: .5rem !important; }
    .m-kpis > * { min-width: 0; overflow-wrap: anywhere; }
    .m-split { grid-template-columns: minmax(0, 1fr) !important; }
    .m-split > * { min-width: 0; }
    .m-stats { display: grid !important; grid-template-columns: 1fr 1fr; gap: .75rem 1rem !important; }
    .m-save-bar { position: sticky; bottom: 0; z-index: 10; background: var(--bg); margin: 1rem -.75rem 0; padding: 10px .75rem calc(10px + env(safe-area-inset-bottom));
                  border-top: 1px solid var(--border); }
    .m-save-bar > .btn-primary { flex: 1 1 auto; }

    /* ---------- Tabelas ---------- */
    /* Por omissão uma tabela larga desliza para o lado; com o invólucro div.table-scroll continua a ocupar a largura toda. */
    table.clean { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    div.table-scroll { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; margin-bottom: 1rem;
                       border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
    div.table-scroll > table.clean { display: table; overflow: visible; border: 0; border-radius: 0; margin: 0; }
    div.table-scroll > table.clean th, div.table-scroll > table.clean td { white-space: nowrap; }
    div.table-scroll > table.clean td.wrap { white-space: normal; min-width: 12rem; }
    /* Cartões: cada linha é um cartão, a etiqueta de cada célula vem do data-label */
    table.clean.m-stack { display: block; overflow: visible; border: 0; background: transparent; border-radius: 0; }
    table.clean.m-stack thead { display: none; }
    table.clean.m-stack tbody { display: block; }
    table.clean.m-stack tbody tr { display: block; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; }
    table.clean.m-stack tbody tr.row-attention { background: #fffbeb; border-color: #fcd34d; border-left: 4px solid #f59e0b; }
    table.clean.m-stack tbody tr.row-attention td, table.clean.m-stack tbody tr.row-attention td:first-child { background: transparent; box-shadow: none; }
    table.clean.m-stack tbody td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
    table.clean.m-stack tbody td::before { content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left; color: var(--muted);
                                           font-size: .75rem; text-transform: uppercase; letter-spacing: .3px; }
    table.clean.m-stack tbody td:not([data-label])::before { content: none; }
    table.clean.m-stack tbody td:empty { display: none; }
    table.clean.m-stack td.m-title { display: block; text-align: left; font-weight: 600; font-size: .95rem; color: var(--fg); }
    table.clean.m-stack td.m-wide, table.clean.m-stack td:has(> input:not([type=checkbox]):not([type=radio]), > select) { display: block; text-align: left; }
    table.clean.m-stack td.m-wide::before, table.clean.m-stack td:has(> input:not([type=checkbox]):not([type=radio]), > select)::before { display: block; max-width: none; margin-bottom: 4px; }
    table.clean.m-stack td > input:not([type=checkbox]):not([type=radio]), table.clean.m-stack td > select { width: 100% !important; max-width: none !important; }
    table.clean.m-stack td.m-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border); }
    table.clean.m-stack td.m-actions > * { flex: 1 1 auto; }
    table.clean.m-stack td.m-actions > .btn-danger { flex-basis: 100%; }
    table.clean.m-stack tr.diff { background: #fff7ed; border-color: #fdba74; }
    table.clean.m-stack tr.diff td { background: transparent; }
    .m-hit { display: flex; align-items: center; justify-content: center; gap: 8px; }

    /* ---------- Recibos: filtros, ações em lote e a lista em cartões compactos (o cartão inteiro abre o talão) ---------- */
    .rl-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .rl-filters > * { width: 100%; min-width: 0; margin: 0; }
    .rl-filters .search { grid-column: 1 / -1; min-width: 0; }
    .rl-filters > label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: .9rem; }
    .rl-bulk { flex-wrap: wrap; }
    .rl-bulk > button { flex: 1 1 0; font-size: .85rem; padding: 6px 8px; }
    .rl-bulk > span { flex-basis: 100%; font-size: .85rem; }
    .rl-bulk:has(button:not([disabled])) { position: sticky; top: 56px; z-index: 20; background: var(--bg); padding: 6px 0; }
    table.clean.rl-cards, table.clean.rl-cards tbody { display: block; border: 0; background: transparent; overflow: visible; border-radius: 0; }
    table.clean.rl-cards thead, table.clean.rl-cards thead tr { display: block; }
    table.clean.rl-cards thead th { display: none; }
    table.clean.rl-cards thead th.rl-sel { display: block; background: transparent; border: 0; padding: 0 0 8px; text-transform: none; letter-spacing: 0;
                                           font-size: .9rem; font-weight: 400; color: var(--fg); }
    table.clean.rl-cards thead th.rl-sel .m-hit { justify-content: flex-start; min-height: 44px; }
    table.clean.rl-cards tbody tr { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 64px; margin-bottom: 8px;
                                    padding: 10px 12px 10px 54px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
    table.clean.rl-cards tbody td { display: block; border: 0; padding: 0; font-size: .8rem; color: var(--muted); order: 4; }
    table.clean.rl-cards tbody td.rl-store { order: 1; flex: 1 1 0; min-width: 0; font-size: .95rem; font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
    table.clean.rl-cards tbody td.rl-decision { order: 2; }
    table.clean.rl-cards tbody tr::after { content: ""; order: 3; flex-basis: 100%; height: 0; }
    table.clean.rl-cards tbody td.rl-id, table.clean.rl-cards tbody td.rl-items, table.clean.rl-cards tbody td.rl-score,
    table.clean.rl-cards tbody td.rl-delivery, table.clean.rl-cards tbody td:empty { display: none; }
    table.clean.rl-cards tbody td[data-label]::before { content: attr(data-label) " "; }
    table.clean.rl-cards tbody td.rl-total::after { content: " €"; }
    table.clean.rl-cards tbody td.rl-open { order: 5; margin-left: auto; font-weight: 600; font-size: .85rem; }
    table.clean.rl-cards tbody td.rl-open a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
    table.clean.rl-cards tbody td.rl-sel { position: absolute; left: 0; top: 0; bottom: 0; width: 44px; z-index: 2; border-right: 1px solid var(--border); }
    table.clean.rl-cards tbody td.rl-sel .m-hit { width: 100%; height: 100%; }

    /* ---------- Talão: pela ordem de uma validação e com a decisão fixa no fundo ---------- */
    .rd-page { display: flex; flex-direction: column; padding-bottom: calc(210px + env(safe-area-inset-bottom)); }
    .rd-page > * { order: 20; }
    .rd-page > h1 { order: 0; }
    .rd-page .grid-2 { display: contents; }
    .rd-guid { display: none; }
    .rd-summary { display: block; order: 1; }
    .rd-summary-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-bottom: 6px; }
    .rd-summary > div + div { margin-top: 4px; }
    .rd-summary .rd-reason { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    /* O mesmo talão (outras submissões) logo a seguir ao resumo, antes da contestação: no topo, não no fim com os sinais */
    .rd-same, p.rd-same-failed { order: 1; }
    /* A contestação do cliente (só SuperAdmin) logo a seguir ao resumo; os botões a toda a largura */
    .rd-contest { order: 1; }
    .rd-contest .rd-contest-actions > button { flex: 1 1 auto; }
    /* O cartão «Campanha» (só nos talões das campanhas) também no topo: as regras e a guarda das vagas antes de decidir */
    .rd-campaign { order: 1; }
    .rd-campaign .rd-campaign-override { display: flex; align-items: center; gap: 8px; min-height: 44px; }
    .rd-image { order: 2; }
    .rd-eans { order: 3; }
    .rd-store { order: 4; }
    .rd-actions { order: 5; margin-top: 0; margin-bottom: 1rem; }
    .rd-ident { order: 6; }
    .rd-client { order: 7; }
    .rd-lines { order: 8; }
    .rd-delivery { order: 9; }
    .rd-signals { order: 10; }
    .rd-actions .rd-decide { display: none; }
    .rd-actions > button { flex: 1 1 40%; }
    .rd-eans > p.muted { display: none; }
    .rd-line-cont > button { min-width: 44px; }
    .rd-image .receipt-thumb { width: 100%; height: auto; max-height: 60vh; max-height: 60dvh; object-fit: contain; background: #f3f4f6; margin: 0 auto; }
    /* EANs esperados: cartão com a faixa «Válido» à esquerda; fica verde quando o produto conta */
    table.clean.rd-eans-cards, table.clean.rd-eans-cards tbody { display: block; border: 0; background: transparent; overflow: visible; border-radius: 0; }
    table.clean.rd-eans-cards thead { display: none; }
    table.clean.rd-eans-cards tbody tr { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 72px; margin-bottom: 8px;
                                         padding: 10px 12px 10px 66px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
    table.clean.rd-eans-cards tbody tr:has(td.rd-valid input:checked) { border-color: var(--success); background: #f0fdf4; }
    table.clean.rd-eans-cards tbody td { display: block; border: 0; padding: 0; font-size: .85rem; overflow-wrap: anywhere; min-width: 0; max-width: 100%; }
    table.clean.rd-eans-cards tbody td.rd-valid { position: absolute; left: 0; top: 0; bottom: 0; width: 56px; border-right: 1px solid var(--border); }
    table.clean.rd-eans-cards tbody td.rd-valid .m-hit { flex-direction: column; gap: 4px; width: 100%; height: 100%; font-size: .7rem; color: var(--fg); }
    table.clean.rd-eans-cards tbody td.rd-valid input { width: 26px; height: 26px; margin: 0; }
    table.clean.rd-eans-cards tbody td.rd-ean code { font-size: .95rem; }
    table.clean.rd-eans-cards tbody td.rd-ean { flex-basis: calc(100% - 4px); }
    table.clean.rd-eans-cards tbody td.rd-ean .rd-cat { min-width: 0; max-width: none; }
    table.clean.rd-eans-cards tbody td.rd-detected, table.clean.rd-eans-cards tbody td.rd-notes, table.clean.rd-eans-cards tbody td.rd-map { flex-basis: 100%; }
    table.clean.rd-eans-cards tbody td.rd-method, table.clean.rd-eans-cards tbody td:empty, table.clean.rd-eans-cards tbody td.rd-map:not(:has(*)) { display: none; }
    table.clean.rd-eans-cards tbody td[data-label]::before { content: attr(data-label) " "; font-size: .72rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
    table.clean.rd-eans-cards tbody td.rd-map:has(select) { display: flex; flex-wrap: wrap; gap: 6px; }
    table.clean.rd-eans-cards tbody td.rd-map select { flex: 1 1 100%; min-width: 0; max-width: none !important; }
    table.clean.rd-eans-cards tbody td.rd-map button { flex: 1 1 auto; }
    /* Linhas do talão: um cartão por linha, com os campos editáveis */
    table.clean.rd-lines-cards, table.clean.rd-lines-cards tbody { display: block; border: 0; background: transparent; overflow: visible; border-radius: 0; }
    table.clean.rd-lines-cards thead { display: none; }
    table.clean.rd-lines-cards tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 44px; gap: 6px; padding: 8px; margin-bottom: 8px;
                                          background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
    table.clean.rd-lines-cards tbody td { display: block; border: 0; padding: 0; }
    table.clean.rd-lines-cards tbody td:nth-child(1) { grid-column: 1 / 4; }
    table.clean.rd-lines-cards tbody td:nth-child(7) { grid-area: 1 / 4; align-self: end; }
    table.clean.rd-lines-cards tbody td:nth-child(2), table.clean.rd-lines-cards tbody td:nth-child(6) { grid-column: 1 / -1; }
    table.clean.rd-lines-cards tbody td:nth-child(6):empty { display: none; }
    table.clean.rd-lines-cards tbody td[data-label]::before { content: attr(data-label); display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; }
    table.clean.rd-lines-cards tbody input { width: 100% !important; }
    table.clean.rd-lines-cards tbody td:nth-child(7) button { width: 44px; height: 44px; padding: 0; }
    /* Barra de decisão: Aprovar e Confirmar em cima; o motivo ao lado de Rejeitar; a nota só em «Outro motivo» */
    .rd-mobile-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1400;
                     background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,.08);
                     padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
    .rd-mobile-bar > * { width: 100%; min-width: 0; margin: 0; }
    .rd-mobile-bar > button { min-height: 46px; font-weight: 600; }
    .rd-bar-msg, .rd-bar-note, .rd-bar-undo { grid-column: 1 / -1; }
    .rd-bar-msg { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--success); max-height: 4.5em; overflow: auto; }
    .rd-bar-msg span { flex: 1 1 auto; }
    .rd-bar-msg button { min-height: 32px; padding: 2px 10px; flex: 0 0 auto; }
    /* Por baixo da decisão: voltar à lista e o seguinte da fila de revisão (a azul depois de decidir) */
    .rd-bar-nav { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
    .rd-bar-nav > a { padding: 6px 10px; font-size: .9rem; text-align: center; }
    .rd-bar-nav > .rd-back { flex: 0 0 auto; }
    .rd-bar-nav > .rd-next-review, .rd-bar-nav > .rd-next-none { flex: 1 1 0; min-width: 0; text-align: center; }
    .rd-page:has(.rd-lines input:focus, .rd-store input:focus, .rd-eans select:focus, .rd-eans input[type=number]:focus) .rd-mobile-bar { display: none; }

    /* ---------- Imagem e PDF do talão ---------- */
    .receipt-pdf { display: none; }
    .m-pdf-open { display: flex; width: 100%; min-height: 48px; }
    .lightbox-bar { gap: 6px; padding: max(8px, env(safe-area-inset-top)) 8px 8px; touch-action: none; }
    .lightbox-bar .btn-ghost, .lightbox-bar .btn-danger { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 8px 12px; font-size: 1rem; }
    .lightbox-bar .btn-danger { margin-left: auto; }
    .lightbox-stage { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
    .lightbox-img { height: auto; width: calc((100vw - 16px) * var(--z, 1)); max-width: none; touch-action: manipulation; }
    .lightbox-pdf { width: 100%; height: calc(100dvh - 120px); }
    html:has(.lightbox), body:has(.lightbox) { overflow: hidden; }

    /* ---------- Confirmação de apagar ou desligar: a pergunta numa linha, «Sim» e «Cancelar» lado a lado ---------- */
    .confirm-ask { display: flex; width: 100%; flex: 1 1 100%; }
    .confirm-ask > .confirm-q { flex: 1 1 100%; }
    .confirm-ask > button { flex: 1 1 0; }

    /* ===== Páginas secundárias: só ajustes próprios de cada página; o resto vem das ferramentas acima ===== */

    /* ---------- Dashboard: o cartão da revisão por fazer vem primeiro; o estado do worker em 3 linhas ---------- */
    body div.dash-top { display: flex; flex-direction: column; margin-bottom: .5rem; }
    body div.dash-top > .dash-review { order: -1; }
    .dash-review > a.btn-ghost { display: flex; width: 100%; margin-top: 10px; }
    .kpi-grid > .kpi.dash-wide { grid-column: 1 / -1; }
    table.clean.dash-narrow { display: table; overflow: hidden; }

    /* ---------- Auditar resultados: os 3 números numa linha; a imagem por cima do resultado; «OK» e «Não OK» lado a lado, a nota a toda a largura ---------- */
    .kpi-grid.sc-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sc-item { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
    .sc-actions > button { flex: 1 1 0; }
    .sc-actions > .sc-note { flex: 1 1 100%; }
    .receipt-pdf-tile { min-height: 0; flex-direction: row; }
    .receipt-pdf-tile > .receipt-pdf-open { flex: 1 1 auto; min-height: 48px; }

    /* ---------- Relatórios: tabela de motivos a toda a largura, lojas a deslizar, explicação das opções visível ---------- */
    table.clean.rep-narrow { display: table; overflow: hidden; }
    div.table-scroll > table.clean.rep-stores td.wrap { min-width: 8rem; }
    .card > .form-row > label.rep-hint { display: flex; flex: 1 1 100%; flex-wrap: wrap; row-gap: 0; }
    .card > .form-row > label.rep-hint::after { content: attr(title); flex-basis: 100%; padding: 0 0 6px 30px; font-size: .75rem; color: var(--muted); }
    .rep-admin-kpis > div > div:nth-child(2) { font-size: 1.15rem !important; }

    /* ---------- Treino: uma loja por cartão (números em duas colunas), legenda dos campos, tabelas do DI a deslizar ---------- */
    .train-di table.clean td.wrap:empty { min-width: 0; }
    .train-legend { margin-bottom: 10px; }
    .train-legend > summary { padding: 10px 0; cursor: pointer; color: var(--primary); font-size: .9rem; }
    .train-legend > dl.m-kv { margin: 0 0 6px; font-size: .85rem; }
    table.clean.m-stack.train-stores tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
    table.clean.m-stack.train-stores tbody td.m-title, table.clean.m-stack.train-stores tbody td.m-wide, table.clean.m-stack.train-stores tbody td.m-actions { grid-column: 1 / -1; }
    table.clean.m-stack.train-stores tbody td[data-label]:not(.m-wide) { display: block; text-align: left; }
    table.clean.m-stack.train-stores tbody td[data-label]:not(.m-wide)::before { display: block; max-width: none; }
    table.clean.m-stack.train-stores tbody td.m-wide:has(> select) { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
    table.clean.m-stack.train-stores tbody td.m-wide:has(> select)::before { flex-basis: 100%; margin-bottom: 0; }
    table.clean.m-stack.train-stores tbody td.m-wide > label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--fg); font-size: .9rem; }
    table.clean.m-stack.train-stores tbody td.m-wide > button { flex: 1 1 auto; }
    .train-studio ol { padding-left: 1.2rem; }
    .train-exports > a { flex: 1 1 100%; }

    /* ---------- Benchmark (Comparação com o cliente) ---------- */
    button.bench-recalc { display: flex; width: 100%; justify-content: center; align-items: center; margin-top: 8px; }
    .bench-kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    div.table-scroll > table.clean.bench-matrix th, div.table-scroll > table.clean.bench-matrix td { padding: 6px 8px; }
    div.table-scroll > table.clean.bench-matrix thead th { white-space: normal; letter-spacing: 0; }
    div.table-scroll.bench-eans { max-width: 520px; }
    table.clean.m-stack.bench-disagreements tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; }
    table.clean.m-stack.bench-disagreements tbody td { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; text-align: left; min-width: 0; }
    table.clean.m-stack.bench-disagreements tbody td::before { max-width: none; }
    table.clean.m-stack.bench-disagreements tbody td.bench-date { align-items: flex-end; text-align: right; color: var(--muted); font-size: .8rem; }
    table.clean.m-stack.bench-disagreements tbody td.m-wide, table.clean.m-stack.bench-disagreements tbody td.m-actions { grid-column: 1 / -1; }
    table.clean.m-stack.bench-disagreements tbody td.m-actions { flex-direction: row; align-items: stretch; gap: 8px; }
    table.clean.m-stack.bench-disagreements tbody td.m-actions > a { flex: 1 1 0; }

    /* ---------- BenchmarkCompare (talão: nós vs cliente) ---------- */
    .bc-when { display: block; margin-top: 2px; }
    .bc-nav > a.btn-ghost { flex: 1 1 auto; }
    .compare-grid.bc-grid { gap: 0; }
    .bc-grid > .bc-cards { display: contents; }
    .bc-grid .card { order: 3; min-width: 0; }
    .bc-grid .card.bc-decision { order: 1; }
    .bc-grid .card.bc-image { order: 2; }
    .bc-decision table.clean.compare-table, .bc-decision table.clean.compare-table thead, .bc-decision table.clean.compare-table tbody { display: block; }
    .bc-decision table.clean.compare-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .bc-decision table.clean.compare-table th:first-child { width: auto; }
    .bc-decision table.clean.compare-table thead th:first-child { display: none; }
    .bc-decision table.clean.compare-table tbody th { grid-column: 1 / -1; background: #f9fafb; }
    .bc-decision table.clean.compare-table td { min-width: 0; overflow-wrap: anywhere; }
    .bc-decision table.clean.compare-table td[colspan] { grid-column: 1 / -1; }
    table.clean.m-stack.bc-products tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-flow: row dense; gap: 6px 12px; }
    table.clean.m-stack.bc-products tbody td { grid-column: 1 / -1; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; text-align: left; min-width: 0; }
    table.clean.m-stack.bc-products tbody td::before { max-width: none; }
    table.clean.m-stack.bc-products tbody td.bc-ours { grid-column: 1; }
    table.clean.m-stack.bc-products tbody td.bc-theirs { grid-column: 2; }
    table.clean.bc-items, table.clean.bc-items tbody { display: block; }
    table.clean.bc-items thead { display: none; }
    table.clean.bc-items tbody tr { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr) auto; column-gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
    table.clean.bc-items tbody tr:last-child { border-bottom: 0; }
    table.clean.bc-items tbody td { display: block; border: 0; padding: 1px 0; min-width: 0; }
    table.clean.bc-items tbody td.bc-i-n { grid-column: 1; grid-row: 1 / span 3; color: var(--muted); }
    table.clean.bc-items tbody td.bc-i-ean { grid-column: 2; grid-row: 1; }
    table.clean.bc-items tbody td.bc-i-ean code:empty { display: none; }
    table.clean.bc-items tbody td.bc-i-price { grid-column: 3; grid-row: 1; text-align: right; white-space: nowrap; }
    table.clean.bc-items tbody td.bc-i-price:not(:empty)::after { content: " €"; }
    table.clean.bc-items tbody td.bc-i-name { grid-column: 2; grid-row: 2; overflow-wrap: anywhere; }
    table.clean.bc-items tbody td.bc-i-qty { grid-column: 3; grid-row: 2; text-align: right; white-space: nowrap; }
    table.clean.bc-items tbody td.bc-i-qty:not(:empty)::before { content: attr(data-label) " "; color: var(--muted); font-size: .75rem; }
    table.clean.bc-items tbody td.bc-i-cat { grid-column: 2 / -1; grid-row: 3; }
    table.clean.bc-items tbody td.bc-i-cat:empty { display: none; }
    .bc-signals li { overflow-wrap: anywhere; margin-bottom: 6px; }
    nav.bc-pager { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; position: sticky; bottom: 0; z-index: 50;
                   background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 12px rgba(0,0,0,.06);
                   margin: 1rem -.75rem 0; padding: 8px .75rem calc(8px + env(safe-area-inset-bottom)); }
    nav.bc-pager > a.btn-ghost { justify-content: center; white-space: nowrap; }
    nav.bc-pager > .muted { text-align: center; font-size: .85rem; white-space: nowrap; }

    /* Catálogo: a pesquisa ocupa a largura toda e afasta-se da tabela */
    input.catalog-search { display: block; width: 100%; margin-bottom: 8px; }

    /* Lojas autorizadas: o «Eliminar» de cada cartão fica à direita (não a toda a largura); «Substituir» com toque de 44 px e a vermelho quando marcado */
    table.clean.m-stack.merchant-list td.m-actions { justify-content: flex-end; }
    table.clean.m-stack.merchant-list td.m-actions > * { flex: 0 0 auto; }
    .store-edit { display: flex; width: 100%; }
    .store-edit > input { flex: 1 1 100%; min-width: 0; }
    .store-edit > button { flex: 1 1 0; }
    label.store-edit-only { display: flex; align-items: center; gap: 8px; min-height: 44px; }
    .store-rename { min-width: 44px; min-height: 36px; }
    label.merchant-replace { display: flex; align-items: center; gap: 10px; min-height: 44px; }
    label.merchant-replace:has(> input:checked) { color: var(--danger); font-weight: 600; }

    /* Thresholds: um cartão por stage com os quatro limites em grelha 2x2 e «Activa» a toda a largura (a linha inteira carrega no checkbox) */
    table.clean.m-stack.thresholds-stages tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 10px; }
    table.clean.m-stack.thresholds-stages tbody td.m-title, table.clean.m-stack.thresholds-stages tbody td.thresholds-enabled { grid-column: 1 / -1; }
    table.clean.m-stack.thresholds-stages tbody td.thresholds-enabled { align-items: center; }
    table.clean.m-stack.thresholds-stages tbody td.thresholds-enabled > .m-hit { flex: 1 1 auto; justify-content: flex-end; min-height: 44px; }
    table.clean.thresholds-stages ~ button { display: block; width: 100%; margin: 0 0 8px; }
    table.clean.thresholds-stages ~ h2 { margin-top: 1.5rem; }
    span.thresholds-saved:not([hidden]) { display: block; margin: 0 0 8px; }
    /* Pesos: tabela compacta de 3 colunas que cabe no ecrã; o nome do sinal parte onde for preciso */
    div.table-scroll > table.clean.thresholds-weights th, div.table-scroll > table.clean.thresholds-weights td { padding: 6px 8px; }
    div.table-scroll > table.clean.thresholds-weights td.thresholds-signal { white-space: normal; overflow-wrap: anywhere; }
    table.clean.thresholds-weights input[type=number] { width: 5.5rem; }
    table.clean.thresholds-weights .m-hit { justify-content: flex-start; min-width: 44px; min-height: 44px; }

    /* Webhooks: secret mostrado uma vez — um toque longo seleciona-o inteiro */
    .card code.wh-secret { display: block; margin-top: 8px; padding: 10px; font-size: .85rem; word-break: break-all; -webkit-user-select: all; user-select: all; }
    /* Webhooks: checkbox Ativo com alvo de 44px; Desativar sozinho numa linha, em vermelho */
    table.clean.wh-hooks td.wh-on { align-items: center; padding: 0; }
    table.clean.wh-hooks td.wh-on > .m-hit { min-width: 44px; min-height: 44px; justify-content: flex-end; }
    table.clean.wh-hooks td.m-actions > .wh-off { flex-basis: 100%; margin-top: 4px; color: var(--danger); border-color: #fecaca; }
    /* Webhooks: payload com altura pelo ecrã visível (o style inline usa 60vh) */
    pre.wh-payload { max-height: 60vh !important; max-height: 60dvh !important; font-size: .75rem !important; }
    /* Chaves API: chave mostrada uma vez — um toque longo seleciona-a inteira; sem célula de ações vazia nas revogadas */
    .warning-box code.ak-key { padding: 10px; -webkit-user-select: all; user-select: all; }
    table.clean.m-stack.ak-keys tbody td.m-actions:not(:has(*)) { display: none; }
    /* Integrações: cartão «Sincronizar agora» no topo */
    .int-quick > .form-row { margin-bottom: 8px; }
    .int-quick > p { margin: 0; }
    .int-quick > p + p { margin-top: 6px; }
    .card > a.int-bench { display: flex; width: 100%; margin-top: 8px; }
    /* Integrações: «de [n] em N horas» é uma frase — fica numa linha, não em coluna */
    .card > .form-row > label.int-every:has(> input[type=number]) { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
    .card > .form-row > label.int-every > input[type=number] { width: 6rem !important; flex: 0 0 auto; }

    /* Utilizadores: o resultado das ações das linhas (link de uso único / erro) fica fixo no fundo do ecrã; vazio não tem caixa */
    div.users-feedback:has(> *) { position: sticky; bottom: 0; z-index: 10; margin: 1rem -.75rem 0; padding: 10px .75rem calc(10px + env(safe-area-inset-bottom));
                                  background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,.08);
                                  max-height: 45vh; max-height: 45dvh; overflow-y: auto; }
    div.users-feedback .warning-box { margin-top: 0; }
    div.users-feedback .error + .warning-box { margin-top: 8px; }
    div.users-feedback .key { -webkit-user-select: all; user-select: all; }
    /* Tenants: o nome é o título do cartão e as 4 contagens ficam numa grelha 2×2 */
    table.clean.m-stack.tenants-list tbody tr { display: flex; flex-wrap: wrap; column-gap: 16px; }
    table.clean.m-stack.tenants-list tbody td { flex: 1 1 100%; min-width: 0; }
    table.clean.m-stack.tenants-list tbody td.m-title { order: -1; }
    table.clean.m-stack.tenants-list tbody td.tn-count { flex: 1 1 calc(50% - 8px); }
    table.clean.m-stack.tenants-list tbody td.tn-count::before { max-width: none; }
    /* Tenant (editar): links do topo, checkbox «Tenant ativo» e botões da Configuração com área de toque e espaço entre linhas */
    p.te-links { display: flex; flex-wrap: wrap; gap: 8px; }
    p.te-links > a { flex: 1 1 auto; }
    label.te-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 6px 0; }
    label.te-check > input[type=checkbox] { flex: 0 0 auto; margin: 0; }
    .card.te-config { display: flex; flex-wrap: wrap; gap: 8px; }
    .card.te-config > h2 { flex: 1 1 100%; margin: 0; }
    .card.te-config > p { flex: 1 1 100%; margin: 0 0 4px; }
    .card.te-config > .btn-ghost { flex: 1 1 auto; text-align: center; }
    /* Auditoria: a coluna Data fica fixa à esquerda enquanto a tabela desliza para o lado */
    div.table-scroll > table.clean.audit-table th:first-child, div.table-scroll > table.clean.audit-table td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; box-shadow: inset -1px 0 0 var(--border); }
    div.table-scroll > table.clean.audit-table thead th:first-child { background: #f9fafb; }

    /* ---------- Contas: separadores a toda a largura; cada cliente um cartão (o total também); o escalão do editor em 2 colunas ---------- */
    .acc-tabs > a { flex: 1 1 auto; }
    .acc-bar > .acc-updated { flex: 1 1 100%; }
    .acc-kpis > .kpi.acc-projection { grid-column: 1 / -1; }
    table.clean.m-stack tbody tr.acc-total { background: #f9fafb; }
    table.clean.m-stack td.m-title .acc-note { font-weight: 400; }
    table.clean.m-stack.acc-clients td.m-wide { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
    table.clean.m-stack.acc-clients td.m-wide::before { flex-basis: 100%; }
    pre.acc-cmd { font-size: .72rem; }
    input.acc-in { width: 100%; }
    table.clean.m-stack.acc-tiers tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 10px; }
    table.clean.m-stack.acc-tiers tbody td.m-title, table.clean.m-stack.acc-tiers tbody td.m-actions { grid-column: 1 / -1; }
    .acc-table-actions > *, .acc-apply > .btn-primary, .acc-editor-tools > button { flex: 1 1 auto; }
    .card.acc-tenant-plan > a.btn-ghost { display: flex; width: 100%; margin-top: 8px; }
    .acc-history summary { padding: 8px 0; cursor: pointer; color: var(--primary); }

    /* ---------- Campanhas: o editor numa coluna, os separadores a deslizar, a tabela dos produtos em cartões, toques de 44 px ---------- */
    .cmp-row { flex-direction: column; align-items: stretch; }
    .cmp-field, .cmp-grow { flex: 1 1 auto; min-width: 0; }
    .cmp-num, .cmp-hex { width: 100%; }
    .cmp-group { padding: .6rem .75rem .75rem; }
    .cmp-check { min-height: 44px; }
    .cmp-actions > .cmp-btn { flex: 1 1 auto; }
    .cmp-btn-small { min-width: 44px; }
    .cmp-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; padding-bottom: 4px; }
    .cmp-tab { flex: 0 0 auto; }
    table.cmp-table, table.cmp-table tbody { display: block; background: transparent; border: 0; border-radius: 0; }
    table.cmp-table thead { display: none; }
    table.cmp-table tbody tr { display: block; margin-bottom: 8px; padding: 8px 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
    table.cmp-table tbody td { display: block; padding: 4px 0; border: 0; }
    table.cmp-table tbody td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .3px; }
    td.cmp-row-actions { display: flex; gap: 6px; }
    .cmp-results > li { flex-direction: column; align-items: stretch; }
    .cmp-checklist > li { display: grid; grid-template-columns: 1.1rem minmax(0, 1fr); column-gap: 6px; align-items: baseline; }
    .cmp-checklist > li > .cmp-link { grid-column: 2; justify-self: start; min-height: 44px; padding: 0; }
    .cmp-field-head { flex-wrap: wrap; }
    .cmp-sample { flex-direction: column; align-items: flex-start; }
    .cmp-logo-preview { max-width: 100%; }
    .cmp-confirm { display: flex; width: 100%; }
    .cmp-confirm > .cmp-confirm-q { flex: 1 1 100%; }
    .cmp-confirm > button { flex: 1 1 0; }
    label.cmp-access, label.cmp-access > select { width: 100%; }
    .cmp-tpl-placeholders { grid-template-columns: 1fr; }
    .cmp-mail { padding: 8px; }
    .cmp-mail-paper { padding: 14px; }
    .cmp-area-nav { flex-wrap: nowrap; }
    .cmp-area-link { display: inline-flex; flex: 1 1 0; align-items: center; justify-content: center; min-height: 44px; padding: 6px 8px; text-align: center; }
    .cmp-filters { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
    .cmp-filters .cmp-field, .cmp-filters .cmp-grow { flex: 1 1 auto; min-width: 0; }
    .cmp-filters-hint { flex: none; order: 1; margin: -6px 0 0; }
    .cmp-filters > .cmp-filter-actions { order: 2; }
    .cmp-part-email { white-space: normal; overflow-wrap: anywhere; }
    .cmp-part-name, .cmp-part-items { min-width: 0; }
    .cmp-filter-actions > .cmp-btn, .cmp-parts-actions > .cmp-btn, .cmp-pager > .cmp-btn { flex: 1 1 auto; min-height: 44px; }
    .cmp-reason-box > .cmp-input { flex: 1 1 100%; }
    .cmp-check-input { width: 22px; height: 22px; }
    table.cmp-table tbody td.cmp-col-select { padding: 0 0 4px; }
    table.cmp-table tbody td.cmp-num-col { text-align: left; }
    .cmp-kv { grid-template-columns: 1fr; }
    .cmp-pager { justify-content: space-between; }
    .cmp-payout-states { flex-wrap: wrap; overflow-x: visible; padding-bottom: 0; }
}

/* Toque: um botão ou link não fica com o aspeto de «rato por cima» depois de tocado */
@media (max-width: 768px) and (hover: none) {
    a:hover { text-decoration: none; }
    .btn-primary:hover { background: var(--primary); }
    .btn-ghost:hover { background: #fff; }
    .app-nav .nav-link:hover:not(.active) { background: transparent; color: #cbd5e1; }
}
