/* NEXT ERP — shell por módulos + editores (estilo Primavera/Eticadata). Tokens de cor e componentes base. */
:root { --brand:#1f4e79; --brand-2:#2d6ca8; --bg:#eef1f5; --panel:#fff; --line:#d9dee7; --text:#1a1a1a; --muted:#6b7280; --ok:#1e7d3a; --warn:#b26a00; --err:#b00020; --sel:#e6eef8; }
* { box-sizing:border-box; }
html,body { margin:0; height:100%; font-family:"Segoe UI",Arial,sans-serif; font-size:13px; color:var(--text); background:var(--bg); }
body { display:flex; flex-direction:column; height:100vh; overflow:hidden; }
a { color:var(--brand); }
.hidden { display:none !important; } .muted { color:var(--muted); font-size:12px; } .err { color:var(--err); } .num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
code { background:#f0f3f7; padding:1px 4px; border-radius:3px; font-family:Consolas,monospace; font-size:12px; }

/* ---- topo: marca, empresa, utilizador ---- */
#top { display:flex; align-items:center; gap:14px; height:44px; padding:0 14px; background:var(--brand); color:#fff; flex:none; }
#top .brand { font-weight:700; letter-spacing:.02em; } #top .co { background:rgba(255,255,255,.14); border-radius:4px; padding:3px 9px; cursor:pointer; }
#top .sp { flex:1; } #top .who { font-size:12px; opacity:.9; } #top .who .badge-novo { display:inline-block; margin-left:6px; padding:1px 6px; border-radius:8px; background:var(--brand); color:#fff; font-size:10px; vertical-align:middle; } #top button.link { color:#fff; background:none; border:0; text-decoration:underline; cursor:pointer; font:inherit; } #help { width:28px; height:28px; flex:none; border-radius:50%; border:1.5px solid var(--brand); background:#fff; color:var(--brand); font:inherit; font-size:15px; font-weight:700; line-height:1; padding:0; display:inline-flex; align-items:center; justify-content:center; cursor:pointer; } #help:hover { background:var(--sel); } #help:focus-visible { outline:2px solid #fff; outline-offset:2px; }
/* ---- barra de módulos ---- */
#modules { display:flex; gap:2px; padding:0 14px; background:#fff; border-bottom:1px solid var(--line); flex:none; }
#modules button { background:none; border:0; border-bottom:3px solid transparent; padding:9px 14px; font:inherit; font-weight:600; color:#334; cursor:pointer; }
#modules button.on { color:var(--brand); border-bottom-color:var(--brand); } #modules button:hover { background:#f5f7fa; } #modules button:disabled { color:#aab; cursor:default; }
/* ---- C-LIC-2 §5: faixa de licença (aviso de expiração / modo só-leitura) — depois da barra de módulos ---- */
.lic-warn { background:#fff7e0; color:#6b4d00; border-bottom:1px solid #f0dca0; padding:6px 14px; font-size:13px; }
.lic-off { background:#fdecec; color:#7a1f1f; border-bottom:1px solid #f3c1c1; padding:6px 14px; font-size:13px; }
/* ---- corpo: menu do módulo + conteúdo ---- */
#body { display:flex; flex:1; min-height:0; }
#menu { width:220px; flex:none; background:#fff; border-right:1px solid var(--line); padding:10px 0; overflow:auto; }
/* Painel lateral (10/11/2026): fixo (omissão) ou escondido; escondido, a faixa «Menu» abre-o por cima do ecrã. */
#body { position:relative; }
#menu .mctl { display:flex; justify-content:flex-end; padding:0 10px 4px; }
#menu .mctl button { font:inherit; font-size:12px; color:var(--brand); background:#fff; border:1px solid var(--line); border-radius:4px; padding:3px 9px; cursor:pointer; min-height:26px; }
#menu .mctl button:hover { background:var(--sel); }
#menuRail { display:none; flex:none; width:28px; padding:0; border:0; border-right:1px solid var(--line); background:#fff; color:var(--brand); cursor:pointer; font:inherit; font-size:12px; font-weight:600; letter-spacing:.06em; }
#menuRail span { writing-mode:vertical-rl; transform:rotate(180deg); display:inline-block; padding:12px 0; }
#menuRail:hover { background:var(--sel); }
body.menu-hidden #menuRail { display:block; }
body.menu-hidden #menu { display:none; }
body.menu-hidden.menu-peek #menu { display:block; position:absolute; left:28px; top:0; bottom:0; z-index:40; box-shadow:6px 0 18px rgba(20,35,55,.18); }
@media print { #menuRail { display:none !important; } }
#menu h3 { margin:6px 14px 4px; font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); }
#menu a { display:block; padding:7px 14px 7px 18px; color:#223; text-decoration:none; border-left:3px solid transparent; }
#menu a.on { background:var(--sel); border-left-color:var(--brand); color:var(--brand); font-weight:600; } #menu a:hover { background:#f5f7fa; }
#menu a .tag { float:right; font-size:10px; color:var(--warn); }
#menu a.off { color:#aab; cursor:default; } #menu a.off:hover { background:none; }   /* item de módulo não licenciado (desativado, nunca escondido) */
#menu h4 { margin:12px 14px 3px; font-size:10.5px; font-weight:600; text-transform:uppercase; letter-spacing:.05em; color:var(--brand); opacity:.8; }
/* VERSAO: rodapé do menu — versão/commit/data da aplicação e base da empresa (letra pequena, cinzenta). */
#menu .ver { margin-top:16px; padding:8px 14px 4px; border-top:1px solid var(--line); font-size:10.5px; line-height:1.5; color:var(--muted); word-break:break-word; }
#content { flex:1; min-width:0; overflow:auto; padding:12px 14px; }
/* ---- separadores dos ecrãs (29/10): barra discreta por cima do conteúdo; o ativo realçado; ● = alterações por gravar ---- */
#work { flex:1; min-width:0; display:flex; flex-direction:column; min-height:0; }
#work > #content { min-height:0; }
#tabs { display:flex; gap:2px; padding:4px 10px 0; background:#f3f5f8; border-bottom:1px solid var(--line); flex:none; overflow-x:auto; }
#tabs:empty { display:none; }
#tabs .tab { display:flex; align-items:center; gap:6px; max-width:240px; padding:4px 6px 4px 10px; border:1px solid var(--line); border-bottom:0; border-radius:6px 6px 0 0; background:#e9edf2; color:#445; cursor:pointer; font-size:12.5px; white-space:nowrap; }
#tabs .tab b { font-weight:500; overflow:hidden; text-overflow:ellipsis; }
#tabs .tab.on { background:#fff; color:var(--brand); margin-bottom:-1px; } #tabs .tab.on b { font-weight:600; }
#tabs .tab .dot { color:var(--warn); font-style:normal; font-size:10px; }
#tabs .tab .x { border:0; background:none; color:#889; cursor:pointer; padding:0 3px; font-size:14px; line-height:1; } #tabs .tab .x:hover { color:#c0392b; }
/* ---- editor de documentos ---- */
.editor { background:var(--panel); border:1px solid var(--line); border-radius:6px; display:flex; flex-direction:column; }
/* 01/11 (Artur): o editor ocupa EXATAMENTE a área do conteúdo — antes era calc(100vh − 44 − 40 − 24) e não contava com a barra dos
   separadores nem com o «Resumo do dia», e o rodapé dos totais ficava cortado. As linhas deslocam-se dentro da grelha (.grid);
   os editores compactos (style="min-height:auto", Configuração) ficam com a altura do que têm. Ecrãs muito baixos: mínimo 440 px. */
#content > .screen:has(> .editor:not([style*="min-height"])) { height:100%; }
.editor:not([style*="min-height"]) { min-height:440px; }   /* editores metidos noutro contentor: pelo menos isto */
#content > .screen > .editor:not([style*="min-height"]) { height:100%; min-height:440px; }
.toolbar { display:flex; align-items:center; gap:6px; padding:8px 10px; border-bottom:1px solid var(--line); background:#f8fafc; flex-wrap:wrap; }
.toolbar .grp { display:flex; gap:4px; padding-right:8px; margin-right:4px; border-right:1px solid var(--line); } .toolbar .grp:last-child { border-right:0; }
.toolbar button { font:inherit; padding:5px 10px; border:1px solid #c9d1dc; background:#fff; color:#223; border-radius:4px; cursor:pointer; }
.toolbar button.primary { background:var(--brand); color:#fff; border-color:var(--brand); } .toolbar button.danger { color:var(--err); border-color:#e8b4bb; }
.toolbar button:disabled { opacity:.45; cursor:default; } .toolbar button kbd { font:inherit; font-size:10px; color:var(--muted); margin-left:4px; } .toolbar button.primary kbd { color:#dbe6f2; }
.state { display:flex; align-items:center; gap:10px; padding:6px 12px; font-size:12px; border-bottom:1px solid var(--line); }
.state.draft { background:#fff7e6; } .state.confirmed { background:#e8f5ec; } .state.cancelled { background:#fde8ea; } .state.new { background:#eef3fa; }
.head { display:grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap:8px 12px; padding:12px; border-bottom:1px solid var(--line); }
.field { display:flex; flex-direction:column; gap:3px; } .field label { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; } .fl { display:flex; flex-direction:column; gap:3px; } .fl label { font-size:11px; color:var(--muted); letter-spacing:.04em; }
.field input, .field select { font:inherit; padding:6px 8px; border:1px solid var(--line); border-radius:4px; background:#fff; } .field input:read-only { background:#f5f7fa; } .uf-bad { border-color:var(--err) !important; background:#fff5f5 !important; }
.lk-inline { display:inline-flex; gap:4px; align-items:center; } .field .lk-inline select { flex:1; min-width:0; }   /* REF-1: o select ao lado dos 🔍/✎ estica sem tapar os botões */ .lk-inline button { border:1px solid var(--line); background:#fff; border-radius:4px; cursor:pointer; padding:2px 8px; } .field .lk-inline { display:flex; } .field .lk-inline input { flex:1; }
.field .lk { display:flex; gap:4px; } .field .lk input { flex:1; } .field .lk button { border:1px solid var(--line); background:#fff; border-radius:4px; cursor:pointer; padding:0 8px; }
.field .sub { font-size:12px; color:#334; min-height:16px; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; }
.num-nav { display:flex; align-items:center; gap:2px; } .num-nav input { width:70px; text-align:center; font-weight:700; } .num-nav button { border:1px solid var(--line); background:#fff; border-radius:4px; cursor:pointer; padding:4px 6px; }
/* UX-3 (13/11): editor de documentos — friso de separadores; a barra nunca passa de uma linha, o painel do separador ativo fica abaixo. */
.toolbar.doctb { flex-wrap:nowrap; overflow-x:auto; }
.toolbar.doctb .dtabs { flex:none; display:flex; align-self:stretch; gap:2px; padding-right:6px; margin-right:4px; border-right:1px solid var(--line); }
.toolbar.doctb .dtabs button { background:none; border:0; border-bottom:2px solid transparent; padding:6px 10px 4px; font:inherit; font-size:12px; color:#334; cursor:pointer; white-space:nowrap; }
.toolbar.doctb .dtabs button:hover { background:#eef3f9; }
.toolbar.doctb .dtabs button.on { color:var(--brand); border-bottom-color:var(--brand); font-weight:600; }
/* FA-13: separadores de vista do mapa de amortizações (vive na .head, não numa .toolbar) — reutilizam o look das tabs de documentos. */
.head .dtabs { display:flex; align-self:end; gap:2px; }
.head .dtabs button { background:none; border:0; border-bottom:2px solid transparent; padding:6px 10px 4px; font:inherit; font-size:12px; color:#334; cursor:pointer; white-space:nowrap; }
.head .dtabs button:hover { background:#eef3f9; }
.head .dtabs button.on { color:var(--brand); border-bottom-color:var(--brand); font-weight:600; }
.dtabpanel { display:flex; align-items:center; gap:6px; flex:1 1 auto; min-width:0; flex-wrap:nowrap; overflow-x:auto; }   /* UX-3: na mesma linha, a seguir aos separadores */
.dtabpanel.hidden { display:none; }
.dtabpanel .grp { display:flex; gap:4px; flex:none; }
.dtabpanel button { font:inherit; padding:5px 10px; border:1px solid #c9d1dc; background:#fff; color:#223; border-radius:4px; cursor:pointer; white-space:nowrap; }
.dtabpanel button.primary { background:var(--brand); color:#fff; border-color:var(--brand); } .dtabpanel button.danger { color:var(--err); border-color:#e8b4bb; }
.dtabpanel button:disabled { opacity:.45; cursor:default; }
.dtabpanel button kbd { font:inherit; font-size:10px; color:var(--muted); margin-left:4px; } .dtabpanel button.primary kbd { color:#dbe6f2; }
.dtabpanel select { font:inherit; padding:4px 6px; border:1px solid #c9d1dc; border-radius:4px; background:#fff; }
.grid { flex:1; overflow:auto; }
.editor > .grid { min-height:120px; }   /* 01/11: a grelha das linhas encolhe (o flex por omissão não deixava) e só ela desloca — cabeçalho e rodapé ficam no ecrã */
/* 18/11: a ficha do chassis das listas (#rFormBox) desloca-se dentro do editor como a grelha — numa ficha comprida (ex. mapa de gestão com 16 linhas) o conteúdo passava por baixo do fundo do painel; a barra fica sempre no ecrã. */
.editor > #rFormBox:not(.hidden) { flex:1; overflow:auto; min-height:0; }
table.lines { width:100%; border-collapse:collapse; } table.lines th { position:sticky; top:0; z-index:3; background:#f3f5f8; text-align:left; font-size:11px; color:var(--muted); padding:6px; border-bottom:1px solid var(--line); }
table.lines td { padding:2px 4px; border-bottom:1px solid #eef1f5; } table.lines input, table.lines select { width:100%; font:inherit; padding:5px 6px; border:1px solid transparent; border-radius:3px; background:transparent; }
table.lines.entry input.amt, table.lines.entry input.amtD, table.lines.entry input.amtC { border-color:var(--line); background:#fff; }   /* valores do lançamento: caixa sempre visível */
table.lines input:focus, table.lines select:focus { border-color:var(--brand-2); background:#fff; outline:none; } table.lines input.num { text-align:right; }
table.lines .lmeas { display:flex; flex-wrap:wrap; gap:4px; align-items:center; font-size:12px; color:var(--muted); margin:2px 0 3px 6px; }   /* medidas por baixo do artigo */
table.lines .lmeas input { width:68px; padding:2px 4px; border-color:var(--line); background:#fff; } table.lines .lmeas .mw-w, table.lines .lmeas .mh-w { display:inline-flex; gap:4px; align-items:center; } table.lines .lmeas b { color:var(--text); }
table.lines tr:focus-within td { background:#f7faff; } table.lines td.ro { color:#334; text-align:right; padding-right:8px; font-variant-numeric:tabular-nums; }
table.lines .rm { border:0; background:none; color:#b55; cursor:pointer; font-size:14px; }
/* ORD-1: pega para reordenar as linhas do rascunho (arrastar ou Alt+↑/↓); emitido → desativada, visível */
table.lines td.no { white-space:nowrap; }
table.lines .mv { cursor:grab; color:var(--muted); padding:0 3px 0 0; user-select:none; letter-spacing:-2px; }
table.lines .mv:hover { color:var(--brand); }
table.lines .mv.off { cursor:default; opacity:.35; }
table.lines tr.dragging { opacity:.5; outline:1px dashed var(--brand); }
.foot { display:flex; justify-content:space-between; gap:20px; padding:10px 12px; border-top:1px solid var(--line); background:#f8fafc; }
.foot table { border-collapse:collapse; } .foot td { padding:2px 10px; } .foot td.num { font-variant-numeric:tabular-nums; } .foot tr.total td { font-weight:700; font-size:15px; border-top:1px solid var(--line); }
.foot .fp { display:flex; gap:22px; justify-content:flex-end; align-items:flex-end; flex-wrap:wrap; } .foot .fp table { min-width:180px; } .foot .fp td { padding:1px 8px; } .foot .fp .fbox-h { font-size:11px; color:var(--muted); margin-bottom:2px; } .foot .fp tr.hd td { padding-top:1px; } .foot .fp tr.dtot td { font-weight:700; }
/* ---- listas / explorador / fichas ---- */
.panel { background:var(--panel); border:1px solid var(--line); border-radius:6px; padding:12px; }
.panel h2 { font-size:12px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); margin:0 0 10px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; } .panel h2 .sp { flex:1; }
.filters { display:flex; gap:6px; flex-wrap:wrap; align-items:end; margin-bottom:10px; } .filters .field input, .filters .field select { padding:5px 7px; }
table.list { width:100%; border-collapse:collapse; } table.list th { text-align:left; font-size:11px; color:var(--muted); padding:6px; border-bottom:1px solid var(--line); white-space:nowrap; } table.list th.num, table.list td.num { text-align:right; } /* títulos e totais das colunas numéricas alinhados com os valores (Artur 01/11) */
/* Cabeçalho das listas e mapas sempre visível: só os dados fazem scroll (o #content, a ficha ou o diálogo é que rolam).
   top:-12px = o padding do #content (o cabeçalho cola na margem de cima da área visível); a linha de baixo vai por sombra,
   porque com border-collapse a borda não acompanha o th fixo. */
table.list thead th { position:sticky; top:calc(var(--hh, 0px) - 12px); z-index:3; background:var(--panel); box-shadow:inset 0 -1px 0 var(--line); }
/* Conta corrente (ficha entidade): a linha «Saldo / Em aberto» fica acima da tabela, fora da área que rola, com fundo e acima do cabeçalho fixo da lista para não ser tapada. */
#ccInfo { position:relative; z-index:6; background:var(--panel); padding:0 0 6px; margin:0 0 8px; }
#modal table.list thead th, .grid table.list thead th, #content [style*="overflow"] table.list thead th, #rFormBox table.list thead th { top:0; }   /* 18/11: #rFormBox rola por si (o cabeçalho ficava cortado 12 px) */
#modal .panel > h2, #rFormBox .panel > h2 { top:0; }
/* Título do mapa com os botões fixo no topo (só nos painéis com lista); --hh = altura do título, medida em erp.js (stickyPanels). */
.panel:has(table.list) > h2 { position:sticky; top:-12px; z-index:4; background:var(--panel); padding:6px 0; margin-top:-6px; }
#plSplit .panel > h2 { position:static; z-index:auto; padding:0; margin-top:0; }   /* UX-4 (14/11): com o h2 colado, as linhas passavam por baixo dele e o painel da entidade chegava por cima — fluxo normal */
/* Mapas em ecrã inteiro (erp.js stickyPanels põe cada lista num .tscroll): o ecrã ocupa a altura disponível, os painéis com
   lista repartem-na e só o .tscroll faz scroll. Se não couber (muitos painéis / ecrã baixo), o #content volta a ter scroll. */
#content:has(.tscroll, .vscroll) { display:flex; flex-direction:column; }
/* Cada contentor no caminho até uma lista estica (flex 1, ou linhas 1fr nas grelhas — o display:grid em linha mantém-se);
   o que não tem lista fica com a altura natural. */
#content:has(.tscroll, .vscroll) > .screen, #content div:not(.tscroll):not(.vscroll):has(.tscroll, .vscroll) { flex:1 1 0; min-height:0; grid-auto-rows:minmax(0, 1fr); }
#content:has(.tscroll, .vscroll) > .screen, #content div:not(.tscroll):not(.vscroll):not([style*="display"]):has(.tscroll, .vscroll) { display:flex; flex-direction:column; }
#content div:not(.tscroll):not(.vscroll):has(.tscroll, .vscroll) > :not(:has(.tscroll, .vscroll)):not(.tscroll):not(.vscroll) { flex:none; }
#content .tscroll { flex:1 1 0; min-height:140px; overflow:auto; }
/* ERP.panes: quadro minimizado = só o título; não ocupa a altura repartida (os outros crescem). */
#content .pane-min { flex:0 0 auto !important; min-height:0 !important; }
#content .pane-min > :not(h2) { display:none !important; }
.pane-btns { display:inline-flex; gap:6px; margin-right:6px; }
#content .vscroll { flex:1 1 0; min-height:200px; overflow:auto; }
.tscroll table.list thead th { top:0; }
.tscroll table.list tfoot th, .tscroll table.list tfoot td, .tscroll table.list tbody tr.total:last-child td, .tscroll table.list tbody tr.tot:last-child td { bottom:0; }
/* Rodapé dos mapas (linha de totais) fixo em baixo enquanto se percorrem os dados. */
table.list tfoot th, table.list tfoot td, table.list tbody tr.total:last-child td, table.list tbody tr.tot:last-child td {
  position:sticky; bottom:-12px; z-index:3; background:#e9eef6; box-shadow:inset 0 1px 0 #6b7a90; font-weight:700; }
table.list td { padding:6px; border-bottom:1px solid #eef1f5; } table.list tr.row { cursor:pointer; } table.list tr.row:hover td { background:#f7faff; } table.list tr.sel td { background:var(--sel); }
.pill { display:inline-block; font-size:11px; border-radius:10px; padding:1px 8px; background:#e4e9f0; color:#333; }
.pill.ok { background:#e2f3e6; color:var(--ok); } .pill.warn { background:#fff1dc; color:var(--warn); } .pill.err { background:#fde3e6; color:var(--err); } .pill.sys { background:#dfe8f3; color:var(--brand); }
button.btn { font:inherit; padding:5px 10px; border:1px solid var(--brand); background:var(--brand); color:#fff; border-radius:4px; cursor:pointer; } button.btn.sec { background:#fff; color:var(--brand); } button.btn:disabled { opacity:.5; } button.btn.danger { background:#fff; color:var(--err); border-color:#e8b4bb; }   /* ações destrutivas: contorno vermelho, legível dentro e fora das barras */
.tabs { display:flex; gap:2px; border-bottom:1px solid var(--line); margin-bottom:10px; } .tabs button { background:none; border:0; border-bottom:2px solid transparent; padding:7px 12px; font:inherit; cursor:pointer; color:#334; } .tabs button.on { color:var(--brand); border-bottom-color:var(--brand); font-weight:600; } .tabs button:disabled { opacity:.45; cursor:not-allowed; }
/* ---- lookup modal / toast ---- */
#modal { position:fixed; inset:0; background:rgba(20,30,50,.35); display:flex; align-items:center; justify-content:center; z-index:50; }
/* REF-9: diálogos do RH (contrato/SEPA) com classe .modal — abaixo da ficha (#sheet, 45) e das pesquisas (#modal, 50) para os 🔍/✎ abrirem por cima. */
.modal { position:fixed; inset:0; background:rgba(20,30,50,.35); display:flex; align-items:center; justify-content:center; z-index:40; }
/* LK-1: painel «⚙ Colunas» da pesquisa — caixas para ligar/desligar, ↑↓ para ordenar, ações no fim. */
#modal .lkpanel { padding:8px 14px; border-bottom:1px solid var(--line); background:#f7f9fc; }
#modal .lkpanel .lkp-list { display:flex; flex-direction:column; gap:2px; max-height:220px; overflow:auto; margin-bottom:8px; }
#modal .lkpanel .lkp-row { display:flex; align-items:center; gap:6px; padding:2px 4px; border-radius:4px; }
#modal .lkpanel .lkp-row:hover { background:#eef2f8; }
#modal .lkpanel .lkp-row label { display:flex; align-items:center; gap:6px; font-size:12px; cursor:pointer; flex:1; }
#modal .lkpanel .lkp-row label i { font-style:normal; font-size:10.5px; color:var(--muted); }
#modal .lkpanel .lkp-nav button { border:1px solid var(--line); background:#fff; border-radius:3px; cursor:pointer; padding:0 6px; font-size:11px; line-height:18px; }
#modal .lkpanel .lkp-nav button:disabled { opacity:.4; cursor:default; }
#modal .lkpanel .lkp-actions { display:flex; gap:8px; flex-wrap:wrap; }
#modal .box { background:#fff; border-radius:8px; width:760px; max-width:95vw; max-height:85vh; display:flex; flex-direction:column; box-shadow:0 10px 40px rgba(0,0,0,.25); }
#modal .box h2 { margin:0; padding:12px 14px; font-size:14px; border-bottom:1px solid var(--line); display:flex; gap:8px; align-items:center; } #modal .box h2 .sp { flex:1; }
#modal .box .q { padding:10px 14px; } #modal .box .q input { width:100%; font:inherit; padding:7px 9px; border:1px solid var(--line); border-radius:4px; }
.modal .box { background:#fff; border-radius:8px; width:760px; max-width:95vw; max-height:85vh; display:flex; flex-direction:column; box-shadow:0 10px 40px rgba(0,0,0,.25); }
.modal .box h2 { margin:0; padding:12px 14px; font-size:14px; border-bottom:1px solid var(--line); display:flex; gap:8px; align-items:center; } .modal .box h2 .sp { flex:1; }
.modal .box .q { padding:10px 14px; } .modal .box .q input { width:100%; font:inherit; padding:7px 9px; border:1px solid var(--line); border-radius:4px; }
#modal .box .res { overflow:auto; flex:1; padding:0 14px 12px; } #modal .box .res tr.sel td { background:var(--sel); }
#toast { position:fixed; bottom:14px; right:16px; background:#333; color:#fff; padding:9px 13px; border-radius:6px; font-size:12px; max-width:60%; opacity:0; transition:opacity .2s; z-index:60; }
body:has(#content .editor) #toast, body:has(#sheet) #toast { bottom:14px; top:auto; right:auto; left:50%; transform:translateX(-50%); }   /* 14/11: nos editores a mensagem em baixo à direita tapava os totais e em cima à direita tapava o «Fechar ×» da ficha sobreposta e a navegação: fica em baixo ao centro (só a linha de ajuda dos atalhos, que não se clica) */
#toast.show { opacity:1; pointer-events:auto; } #toast.err { background:var(--err); } #toast { pointer-events:none; }
#toast button.tiny { margin-left:8px; padding:1px 7px; font-size:11px; border:1px solid rgba(255,255,255,.6); border-radius:4px; background:transparent; color:#fff; cursor:pointer; }
#toast button.tiny:disabled { opacity:.5; cursor:default; }
/* ---- empresas (entrada) ---- */
.pick { max-width:560px; margin:40px auto; } .pick h1 { color:var(--brand); font-size:22px; margin:0 0 4px; } .pick button.co { display:block; width:100%; text-align:left; padding:12px 14px; margin:8px 0; background:#fff; border:1px solid var(--line); border-radius:8px; font:inherit; cursor:pointer; }
.pick button.co:hover { border-color:var(--brand); } .pick button.co b { display:block; } .pick button.co small { color:var(--muted); }

/* ---- sugestões ao escrever (typeahead) ---- */
.ta-wrap { position:relative; }
.ta-list { position:absolute; left:0; top:100%; z-index:40; min-width:100%; max-width:520px; max-height:260px; overflow:auto; background:#fff; border:1px solid var(--line); border-radius:0 0 6px 6px; box-shadow:0 8px 24px rgba(0,0,0,.15); }
.ta-list div { padding:6px 9px; cursor:pointer; white-space:nowrap; display:flex; gap:10px; } .ta-list div b { min-width:70px; } .ta-list div small { color:var(--muted); margin-left:auto; }
.ta-list div:hover, .ta-list div.sel { background:var(--sel); }
/* 10/11/2026: a célula continua célula de tabela (display:flex tirava-lhe a altura da linha e o centrado vertical: o código do artigo ficava colado ao topo, desalinhado das outras colunas) */
table.lines td.lkc { white-space:nowrap; vertical-align:middle; } table.lines td.lkc input { width:calc(100% - 56px); min-width:60px; vertical-align:middle; } table.lines td.lkc button { vertical-align:middle; margin-left:2px; } table.lines td.lkc button { border:1px solid var(--line); background:#fff; border-radius:3px; cursor:pointer; padding:2px 5px; font-size:12px; }
.grid-actions { padding:6px 10px; border-top:1px dashed var(--line); } .grid-actions button { font:inherit; padding:4px 10px; border:1px solid var(--line); background:#fff; border-radius:4px; cursor:pointer; }

table.list tr.lvl1 td { font-weight:bold; background:#f7f9fc; } table.list tr.lvl2 td { font-weight:600; }
.c1 { grid-column: span 1; } .c5 { grid-column: span 5; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; } .c10 { grid-column: span 10; } .c11 { grid-column: span 11; } .c12 { grid-column: 1 / -1; }
table.lines td.ltrack { white-space:nowrap; vertical-align:middle; } table.lines td.ltrack > * { vertical-align:middle; margin-right:3px; } table.lines td.ltrack input { width:auto; max-width:130px; } table.lines td.ltrack input.llot { min-width:70px; } table.lines td.ltrack button.lsn { border:1px solid var(--line); background:#fff; border-radius:3px; cursor:pointer; padding:3px 6px; font-size:12px; white-space:nowrap; }
#modules button.adminmod { margin-left:auto; color:var(--warn); } #modules button.adminmod + button.adminmod { margin-left:0; } #modules button.adminmod.on { border-bottom-color:var(--warn); }
.matrix select { font:inherit; padding:3px 5px; border:1px solid var(--line); border-radius:4px; }

/* seletor de idioma na barra (I18N-1) */
#top .lang { background:rgba(255,255,255,.12); color:#fff; border:1px solid rgba(255,255,255,.35); border-radius:4px; padding:2px 6px; font-size:12px; margin-left:10px; }
#top .lang option { color:#222; }
#top #coYear { margin-left:0; } #top #coYear.other-year { background:#fff3cd; color:#664d03; border-color:#ffda6a; font-weight:600; }
/* Demonstrações financeiras (Balanço/DR): títulos de secção, subtotais e totais. */
.list tr.hdr td { background:#eef2f7; font-weight:600; padding-top:8px; }
.list tr.sub td { font-weight:600; background:#f7f8fa; border-top:1px solid #d9dee6; }
.list tr.total td { font-weight:700; background:#e9eef6; border-top:2px solid #6b7a90; }
/* NV-1 (01/11): notas de versão / «O que há de novo» */
#modal .verblock { border:1px solid var(--line); border-radius:6px; margin:0 14px 10px; }
#modal .verblock:first-of-type { margin-top:14px; } #modal .verblock:last-of-type { margin-bottom:14px; }
#modal .verblock h3 { margin:0; padding:9px 12px; font-size:13px; border-bottom:1px solid var(--line); }
#modal .verblock .vn { font-weight:600; color:var(--brand); }
#modal .verblock .vdate { color:var(--muted); font-weight:400; margin-left:8px; font-size:12px; }
#modal .verblock .vitems { margin:0; padding:8px 12px 10px; list-style:none; }
#modal .verblock .vitems li { font-size:12.5px; line-height:1.45; margin:3px 0; }
#modal .verblock .vitems .vmod { font-weight:600; color:var(--brand); margin-right:6px; }
#modal .verblock .vh { margin:6px 0 0; font-size:11.5px; color:var(--muted); }
/* Ficha do artigo por cima do ecrã atual (abre a partir das linhas dos editores); as pesquisas (#modal) ficam por cima dela. */
#sheet, .sheet-stack { position:fixed; inset:0; background:rgba(20,30,50,.35); z-index:45; display:flex; padding:18px; }
#sheet .sheet-box, .sheet-stack .sheet-box { background:var(--bg); border-radius:8px; flex:1; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 10px 40px rgba(0,0,0,.25); }
#sheet .sheet-bar, .sheet-stack .sheet-bar { display:flex; align-items:center; gap:10px; padding:8px 12px; background:var(--panel); border-bottom:1px solid var(--line); } #sheet .sheet-bar .sp, .sheet-stack .sheet-bar .sp { flex:1; }
#sheet .sheet-body, .sheet-stack .sheet-body { flex:1; overflow:auto; padding:12px; }
#toast { z-index:60; max-height:30vh; overflow:auto; }   /* 14/11: nenhum aviso tapa o ecrã inteiro */
button.le { font-size:12px; }

/* V4: janela de envio por e-mail */
#modal .mail-form { display:grid; grid-template-columns:90px 1fr; gap:6px 10px; padding:12px 14px; align-items:center; }
#modal .mail-form > .state { grid-column:1 / -1; margin:0; }
#modal .mail-form label { color:var(--muted); font-size:12px; }
#modal .mail-form input, #modal .mail-form textarea { font:inherit; padding:6px 8px; border:1px solid var(--line); border-radius:4px; width:100%; box-sizing:border-box; }
#modal .mail-form textarea { resize:vertical; }
#modal .mail-form label.chk { color:inherit; margin-left:10px; }
#modal .mail-form label.chk input { width:auto; }
/* REF-9: diálogos do RH (classe .modal) — mesmos estilos do #mail-form do #modal */
.modal .mail-form { display:grid; grid-template-columns:90px 1fr; gap:6px 10px; padding:12px 14px; align-items:center; }
.modal .mail-form > .state { grid-column:1 / -1; margin:0; }
.modal .mail-form label { color:var(--muted); font-size:12px; }
.modal .mail-form input, .modal .mail-form textarea { font:inherit; padding:6px 8px; border:1px solid var(--line); border-radius:4px; width:100%; box-sizing:border-box; }
.modal .mail-form textarea { resize:vertical; }
.modal .mail-form label.chk { color:inherit; margin-left:10px; }
.modal .mail-form label.chk input { width:auto; }

/* P1: títulos de secção dentro das fichas (produção) */
.editor h3.sec { font-size:12px; text-transform:uppercase; color:var(--muted); margin:14px 0 6px; display:flex; gap:8px; align-items:center; }
.field.na, td.na, #hTrRow.na { opacity:.45; } .field.na input, .field.na select, .field.na button { cursor:not-allowed; }
.btn kbd, .grid-actions button kbd { font:inherit; font-size:10px; opacity:.75; margin-left:4px; }
/* Cabeçalho do editor de documentos (norma 21/10/2026: ≤ 30% do ecrã, igual para todos os tipos) — linha principal + separadores de uma linha */
.head.hmain { padding:8px 12px 4px; border-bottom:0; gap:4px 10px; }
.head.hpane { padding:6px 12px 8px; gap:4px 10px; min-height:58px; align-content:start; }
.head.hmain .field input, .head.hmain .field select, .head.hpane .field input, .head.hpane .field select { padding:4px 7px; }
/* Altura fixa no que chega depois (resumo da entidade; crédito/mercado/repetidos, que vêm de pedidos): as linhas não se podem mexer
   debaixo do rato — um clique a meio caía fora do botão (29/10/2026). Os separadores não encolhem (quebravam para 2 linhas). */
.head.hmain .field .sub { height:17px; line-height:17px; font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.htabs { display:flex; align-items:center; gap:12px; padding:0 12px; border-bottom:1px solid var(--line); }
.htabs .tabs { margin:0; border-bottom:0; flex:none; } .htabs .tabs button { padding:5px 10px; white-space:nowrap; }
.htabs .hinfo { margin-left:auto; min-width:0; font-size:11px; color:var(--muted); white-space:normal; max-width:60%; }   /* UX-4 (14/11): os avisos quebram linha — com nowrap+ellipsis o texto cortava («…de uso pro…») */
.head.hpane .sub:empty { display:none; }

/* DP-1: declaração periódica do IVA — o impresso oficial como fundo e as caixas posicionadas em % da página (escalam com a
   largura); painel lateral ao lado do impresso, nunca por cima. Tamanho de letra em cqw (largura da página). */
#dpWrap{display:flex;align-items:flex-start}
#dpPages .dp-page{position:relative;width:100%;max-width:980px;aspect-ratio:842/1191;margin:0 auto;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,.18);container-type:inline-size;flex:none}
#dpPages .dp-page img{position:absolute;inset:0;width:100%;height:100%;user-select:none;pointer-events:none}
#dpPages .dp-val,#dpPages .dp-t,#dpPages .dp-x,#dpPages .dp-rate{display:flex;align-items:center;font-family:Arial,Helvetica,sans-serif;color:#0b2a8a;white-space:nowrap;overflow:hidden;line-height:1}
#dpPages .dp-val{justify-content:flex-end;padding-right:.5cqw;font-size:1.55cqw}
#dpPages .dp-t{justify-content:flex-start;padding-left:.5cqw;font-size:1.55cqw}
#dpPages .dp-x{justify-content:center;font-size:1.5cqw;font-weight:bold}
#dpPages .dp-rate{justify-content:center;font-size:1cqw}
#dpPages .dp-val.clk{cursor:pointer}
/* DPA-R2: impresso do Anexo R (A4, 595×842) no painel dos anexos da DP — as mesmas caixas da DP */
#dpRPage{position:relative;width:100%;margin:0 auto;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,.18);container-type:inline-size}
#dpRPage img{position:absolute;inset:0;width:100%;height:100%;user-select:none;pointer-events:none}
#dpRPage .dp-val,#dpRPage .dp-x{display:flex;align-items:center;font-family:Arial,Helvetica,sans-serif;color:#0b2a8a;white-space:nowrap;overflow:hidden;line-height:1}
#dpRPage .dp-val{justify-content:flex-end;padding-right:.6cqw;font-size:1.7cqw}
#dpRPage .dp-x{justify-content:center;font-size:1.3cqw;font-weight:bold}
#dpRPage .dp-val.clk:not(.auto){cursor:pointer}
#dpRPage .dp-val.clk:not(.auto):hover{outline:2px solid #e8a33d;background:rgba(232,163,61,.15)}
#dpPages .dp-val.clk:hover{outline:2px solid #e8a33d;background:rgba(232,163,61,.15)}
/* DP-HDR-ED: quadrículas do cabeçalho (quadros 01–06) clicáveis — cursor e hover como .dp-val.clk */
#dpPages .dp-x.clk,#dpPages .dp-t.clk{cursor:pointer}
#dpPages .dp-x.clk:hover,#dpPages .dp-t.clk:hover{outline:2px solid #e8a33d;background:rgba(232,163,61,.15)}
/* DECL-ED: caixa alterada à mão (âmbar claro), o cálculo mudou depois da alteração (contorno laranja tracejado),
   totais/resultados calculados (cursor normal — não se alteram) */
#dpPages .dp-val.ovr,.ax-page .ovr,#dpRPage .dp-val.ovr{background:rgba(255,214,102,.45)}
#dpPages .dp-val.ovr-stale,.ax-page .ovr-stale,#dpRPage .dp-val.ovr-stale{outline:2px dashed #d9822b;outline-offset:-2px}
#dpPages .dp-val.auto{cursor:default}
table.list td.ovr,table.list tr.ovr-stale td{background:rgba(255,214,102,.45)}
table.list td.ovr-stale{outline:2px dashed #d9822b;outline-offset:-2px}
table.list td.rEd{cursor:pointer}
table.list td.rEd:hover{outline:2px solid #e8a33d}
.ax-page .ax-box.clk{cursor:pointer}
.ax-page .ax-box.clk:hover{outline:2px solid #e8a33d;background:rgba(232,163,61,.15)}
#dpPages .dp-note{border:1px solid #b8c4e0;background:#eef1fa;font-size:1.1cqw;padding:.4cqw;color:#223}
/* DP-3 sec.4 — Declaração Recapitulativa sobre o impresso oficial (A4, 2 páginas): a página escala com a largura e a
   letra acompanha (cqw); valores ao euro alinhados em baixo, na linha do «,00» pré-impresso. */
#rImp .rc-page{position:relative;width:100%;max-width:820px;aspect-ratio:595.32/841.92;margin:0 auto 14px;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,.18);container-type:inline-size}
#rImp .rc-page img{position:absolute;inset:0;width:100%;height:100%;user-select:none;pointer-events:none}
#rImp .rc-v,#rImp .rc-t,#rImp .rc-c,#rImp .rc-x{position:absolute;display:flex;box-sizing:border-box;font-family:Arial,Helvetica,sans-serif;color:#0b2a8a;white-space:nowrap;overflow:hidden;line-height:1}
#rImp .rc-v{align-items:flex-end;justify-content:flex-end;padding:0 .3cqw .35cqw 0;font-size:1.45cqw}
#rImp .rc-t{align-items:center;padding-left:.5cqw;font-size:1.45cqw}
#rImp .rc-c{align-items:center;justify-content:center;font-size:1.45cqw}
#rImp .rc-x{align-items:center;justify-content:center;font-size:1.6cqw;font-weight:bold}
/* RECAP-ED — caixas clicáveis sobre o impresso: todas as caixas dos quadros 02/03/04(valor)/05/07 recebem overlay;
   'on' = clicável (contorno âmbar no hover, como .dp-val.clk); sem 'on' = visível, sem clique (o title diz porquê). */
#rImp .rc-clk{position:absolute;pointer-events:none;box-sizing:border-box}
#rImp .rc-clk.on{pointer-events:auto;cursor:pointer;border:1px solid transparent;border-radius:2px;transition:border-color .12s,background .12s}
#rImp .rc-clk.on:hover{border-color:var(--warn,#d8a13a);background:rgba(216,161,58,.12)}
#rSide{display:flex;flex-direction:column;gap:10px}
/* F13 — painel lateral do assistente de IA */
#aiDrawer{position:fixed;top:44px;right:0;bottom:0;width:min(440px,100vw);background:var(--card,#fff);border-left:1px solid #d6dbe4;box-shadow:-2px 0 8px rgba(0,0,0,.08);display:flex;flex-direction:column;z-index:900}
#aiDrawer.hidden{display:none}
#aiDrawer .ai-head{display:flex;align-items:center;padding:10px 12px;border-bottom:1px solid #e3e7ee}
#aiDrawer .ai-log{flex:1;overflow:auto;padding:12px;display:flex;flex-direction:column;gap:10px}
#aiDrawer .ai-msg{padding:8px 10px;border-radius:8px;line-height:1.4;font-size:13.5px;max-width:92%}
#aiDrawer .ai-msg.me{align-self:flex-end;background:#e8eefb}
#aiDrawer .ai-msg.bot{align-self:flex-start;background:#f3f5f8}
#aiDrawer .ai-msg .ai-h{display:block;font-size:14px;margin-top:2px}
#aiDrawer .ai-msg.pending{color:var(--muted)}
#aiDrawer .ai-msg.err{background:#fdecec;color:#9b1c1c}
#aiDrawer .ai-meta{margin-top:6px;font-size:11.5px;color:var(--muted)}
#aiDrawer .ai-actions-row{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
#aiDrawer .ai-actions-row .ai-act{margin:0;font-size:12px;padding:3px 8px}
#aiDrawer .ai-actions-row .ai-act:disabled{opacity:.55;cursor:not-allowed}
#aiDrawer .ai-form{display:flex;flex-direction:column;gap:6px;padding:10px 12px;border-top:1px solid #e3e7ee}
#aiDrawer .ai-form textarea{flex:1;resize:none}
#aiDrawer .ai-chips{display:flex;flex-wrap:wrap;gap:6px;padding:8px 12px;border-bottom:1px solid #e3e7ee}
#aiDrawer .ai-chip{cursor:pointer;border:1px solid #c9d3e6;background:#f5f8fe}
#aiDrawer .ai-chip:hover{background:#e8eefb}
#aiDrawer .ai-ctx{padding:0 12px;font-size:12px;color:var(--muted)}
#aiDrawer .ai-ctx:empty{display:none}
#aiDrawer .ai-ctx{padding:6px 12px}
.btn.ai-ask{border-color:#8fa6d8;color:#21407a}
#briefBar { display:flex; align-items:center; gap:6px; flex-wrap:wrap; padding:5px 14px; background:#eef3fb; border-bottom:1px solid #d6dfef; font-size:12px; color:#2b3a55; }
#briefBar .t { font-weight:700; margin-right:4px; } #briefBar .sp { flex:1; } #briefBar b.warn { color:#a33; }
#briefBar .x { border:0; background:none; font-size:16px; cursor:pointer; color:#556; padding:0 4px; }
#briefBar .btn.ai-ask { padding:2px 8px; font-size:12px; }
#aiDrawer .ai-actions{display:flex;align-items:center;gap:8px;margin-top:6px}
#aiDrawer .ai-actions .sp{flex:1}
#aiDrawer #aiMic.rec{background:#fde8e8;border-color:#e3a1a1;color:#a33}
#aiDrawer .ai-speak{font-size:14px;cursor:pointer}
#aiDrawer .ai-tools-row{margin-top:8px;display:flex;gap:6px}
#aiDrawer .ai-listen.ai-speaking{background:#fff1dc;border-color:var(--warn)}

/* REFUND-ED — linhas dos Anexos I e II do reembolso: riscadas (excluídas), âmbar (alteradas/à mão). */
tr.rfx td { text-decoration:line-through; color:var(--muted); }
tr.rfm td { background:#fdf6e3; }
i.tag { font-style:normal; font-size:9.5px; font-weight:700; padding:0 4px; border-radius:3px; margin-left:4px; }
i.tag.rfm { background:#f5e9c8; color:var(--warn); }
i.tag.rfx { background:#f3d6da; color:var(--err); }
.rf-act { white-space:nowrap; display:inline-flex; gap:2px; }
#cpDrop { border:2px dashed var(--line); border-radius:8px; padding:18px; text-align:center; color:var(--muted); margin:10px 0; }
#cpDrop.over { border-color:var(--brand); background:var(--sel); }
/* DF-5b — REVISÃO LADO A LADO: o original à esquerda (55 %) e os motivos/notas/documento à direita. */
.cp-rev { display:flex; gap:14px; margin-top:10px; min-height:480px; }
.cp-rev-l { flex:0 0 55%; max-width:55%; border:1px solid var(--line); border-radius:8px; background:#f4f6f9; padding:8px; overflow:auto; }
.cp-rev-view { width:100%; height:100%; min-height:460px; border:0; background:#fff; }
.cp-rev-r { flex:1; min-width:0; padding:2px 4px; overflow-y:auto; max-height:70vh; }
.cp-rev-sec { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); margin:12px 0 4px; }
.cp-rev-reasons { margin:0; padding-left:18px; color:var(--err); }
.cp-rev-notes { margin:0; padding-left:18px; color:var(--text); }
.cp-rev-notes li.cp-rev-warn { color:var(--warn); font-weight:600; }
.cp-rev-doc { background:var(--sel); border:1px solid var(--line); border-radius:6px; padding:8px 10px; }
.field.req > label::after { content:" *"; color:var(--err); }   /* obrigatório: «*» visual, sem mudar o texto do rótulo (E2E comparam o texto) */

/* CT-3: célula da matriz cor × tamanho sem combinação criada (diferente de quantidade 0) */
.vmNex { color:#8a6d1b; background:#fdf6e3; border:1px dashed #b9a352; font-style:italic; }
