/* ==========================================================================
   Sistema de design — interface de operações
   Tipos de letra do sistema, sem CDN: tem de abrir depressa com rede fraca.
   ========================================================================== */

:root {
  --bg:        #f5f7f9;
  --surface:   #ffffff;
  --surface-2: #fafbfc;
  --border:    #e2e6eb;
  /* Valores fixados por cálculo, não por gosto: ./mifos verificar contraste
     falha se algum par declarado descer abaixo do mínimo WCAG AA. O limite das
     caixas de entrada é escuro de propósito — a norma exige 3:1 para o que
     identifica um componente, e num balcão com sol na janela isso nota-se. */
  --border-2:  #7e858c;
  --text:      #12171d;
  --muted:     #5c6875;
  --faint:     #6a727c;

  --primary:      #0f766e;
  --primary-soft: #d5f2ee;
  --primary-hover:#0c5f59;
  --primary-text: #ffffff;

  --success: #147d3b;  --success-soft: #dcf5e4;
  --warning: #a35a07;  --warning-soft: #fdf0d9;
  --danger:  #b3261e;  --danger-soft:  #fce8e6;
  --info:    #1d4ed8;  --info-soft:    #e0e8fd;

  /* Classes de risco do BdM — severidade crescente */
  --risco-1: #147d3b; --risco-2: #547c0e;
  --risco-3: #a35a07; --risco-4: #c2410c; --risco-5: #b3261e;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow:    0 1px 2px rgba(16,24,32,.06), 0 2px 8px rgba(16,24,32,.04);
  --shadow-lg: 0 8px 28px rgba(16,24,32,.14);
  --rail-bg:   #e9edf2;
  --rail:      76px;
  --painel:    236px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg:#0e1216; --surface:#161b21; --surface-2:#1b2128; --rail-bg:#090c10;
    --border:#262d36; --border-2:#697079;
    --text:#e7ecf1; --muted:#9aa6b4; --faint:#7d8995;
    --primary:#2dd4bf; --primary-soft:#0d3b38; --primary-hover:#5eead4;
    --primary-text:#06221f;
    --success:#4ade80; --success-soft:#0f2e1c;
    --warning:#fbbf24; --warning-soft:#33240a;
    --danger:#fb7185;  --danger-soft:#3a1418;
    --info:#93b4fd;    --info-soft:#141f3d;
    --risco-1:#4ade80; --risco-2:#a3e635;
    --risco-3:#fbbf24; --risco-4:#fb923c; --risco-5:#fb7185;
    --shadow:0 1px 2px rgba(0,0,0,.4); --shadow-lg:0 8px 28px rgba(0,0,0,.5);
  }
}
:root[data-tema="escuro"] {
  --bg:#0e1216; --surface:#161b21; --surface-2:#1b2128; --rail-bg:#090c10;
  --border:#262d36; --border-2:#697079;
  --text:#e7ecf1; --muted:#9aa6b4; --faint:#7d8995;
  --primary:#2dd4bf; --primary-soft:#0d3b38; --primary-hover:#5eead4;
  --primary-text:#06221f;
  --success:#4ade80; --success-soft:#0f2e1c;
  --warning:#fbbf24; --warning-soft:#33240a;
  --danger:#fb7185;  --danger-soft:#3a1418;
  --info:#93b4fd;    --info-soft:#141f3d;
  --risco-1:#4ade80; --risco-2:#a3e635;
  --risco-3:#fbbf24; --risco-4:#fb923c; --risco-5:#fb7185;
  --shadow:0 1px 2px rgba(0,0,0,.4); --shadow-lg:0 8px 28px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { margin: 0; font-weight: 640; letter-spacing: -.011em; }
h1 { font-size: 1.5rem; }  h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }    h4 { font-size: .9rem; }
a { color: var(--primary); text-underline-offset: 2px; }

/* ---------- Estrutura: navegação em dois níveis ---------------------------
   Nível 1 (.rail)   — as seis áreas do trabalho, sempre à vista.
   Nível 2 (.painel) — os ecrãs da área escolhida.

   Porquê dois níveis e não uma lista só: a lista única tinha 20 entradas e seis
   cabeçalhos, e obrigava a percorrer tudo com os olhos para encontrar um ecrã.
   Com o rail, a área está sempre visível e o painel mostra só o que lhe
   pertence — cinco ou seis linhas de cada vez.

   O rail leva rótulo por baixo do ícone, ao contrário do padrão original só com
   ícones. Num balcão, quem usa isto todos os dias decora os ícones; quem usa uma
   vez por semana, não. O rótulo custa oito pixels e poupa uma adivinha.
   -------------------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--rail) var(--painel) 1fr;
  min-height: 100vh;
}

/* ---------- Nível 1: rail ------------------------------------------------- */
.rail {
  /* O rail tem tom próprio, mais fundo do que o painel E do que o conteúdo.
     Com --bg ficava da cor exacta da área de trabalho, e o painel branco lia-se
     como uma tira a flutuar entre dois cinzentos iguais.

     A divisória é um traço leve. Já foi --border-2 (3,7:1) numa tentativa de
     aplicar aqui o mínimo de 3:1 da WCAG 1.4.11 — mas esse critério é para o
     contorno que IDENTIFICA um controlo, como a caixa de entrada de um
     formulário. Uma linha entre duas regiões de navegação não identifica
     controlo nenhum: as regiões distinguem-se pelo fundo e pelo conteúdo. O
     resultado eram duas linhas escuras a emoldurar o painel. */
  background: var(--rail-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 14px 8px 12px; gap: 4px;
}
.rail::-webkit-scrollbar { width: 0; }

.rail-marca {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--primary); color: var(--primary-text);
  display: grid; place-items: center; margin-bottom: 10px;
}
.rail-marca .ico { width: 20px; height: 20px; stroke-width: 2.1; }

.rail-nav { display: flex; flex-direction: column; gap: 3px; width: 100%; flex: 1; }

.rail-item {
  position: relative; width: 100%; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 7px; border-radius: var(--radius-sm);
  color: var(--muted); font: inherit;
  transition: background .13s, color .13s;
}
.rail-item .ico { width: 20px; height: 20px; stroke-width: 1.8; }
.rail-item span { font-size: .62rem; font-weight: 600; letter-spacing: -.005em;
  line-height: 1.15; text-align: center; }
.rail-item:hover { background: rgba(127,140,155,.16); color: var(--text); }
.rail-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.rail-item.activo { background: var(--primary-soft); color: var(--primary); }

/* Marca da área activa: barra à esquerda, como no padrão Untitled UI. */
.rail-item.activo::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--primary);
}

/* Contador do que precisa de atenção. Vermelho só quando há prazo ultrapassado. */
/* O ícone vive numa caixa própria para o contador se poder ancorar ao canto
   dele. Ancorado ao item — que é mais largo — o contador caía em cima do
   ícone, porque o ícone está centrado e sobra espaço nos dois lados. */
.rail-icone { position: relative; display: grid; place-items: center;
  width: 20px; height: 20px; }
.rail-sino {
  position: absolute; top: -6px; left: 11px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; font-size: .61rem; font-weight: 700;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
  background: var(--muted); color: var(--surface);
  border: 2px solid var(--rail-bg);
}
.rail-sino.urgente { background: var(--danger); color: #fff; }
.rail-item.activo .rail-sino { border-color: var(--primary-soft); }

.rail-pe { display: flex; flex-direction: column; gap: 4px; width: 100%;
  padding-top: 10px; border-top: 1px solid var(--border); }
.rail-pe .btn { width: 100%; padding: 8px 0; }

/* ---------- Nível 2: painel da área -------------------------------------- */
.painel {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; min-width: 0;
}
.painel-topo { padding: 18px 16px 12px; }
.painel-topo h2 { font-size: 1.04rem; letter-spacing: -.02em; }
.painel-topo p { margin: 2px 0 0; font-size: .76rem; color: var(--faint); line-height: 1.35; }

.nav { padding: 6px 10px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; background: none; border-radius: var(--radius-sm);
  color: var(--muted); font: inherit; font-size: .885rem; font-weight: 520;
  cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.nav-item.activo { background: var(--primary-soft); color: var(--primary); font-weight: 620; }
.nav-item .ico { width: 17px; height: 17px; flex: none; stroke-width: 1.9; }
.nav-item .conta {
  margin-left: auto; font-size: .72rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--muted);
  background: var(--bg); padding: 1px 7px; border-radius: 20px;
  border: 1px solid var(--border);
}
.nav-item .conta.urgente { background: var(--danger-soft); color: var(--danger);
  border-color: transparent; }
.nav-item.activo .conta { background: var(--surface); color: var(--primary);
  border-color: var(--border); }

/* Resumo de pendências, no fundo do painel.

   A secção "Operação" tem dois ecrãs; sem isto o painel ficava com 250 px de
   branco entre o último item e o cartão da conta. Em vez de encher o espaço
   com decoração, enche-se com o que a pessoa precisaria de ir procurar ao
   painel — e que aqui está sempre à vista, seja qual for a área aberta. */
.resumo { margin: 0 10px 12px; padding: 11px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); }
.resumo-tit { font-size: .69rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: var(--faint); margin-bottom: 8px; }
.resumo-linha { display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; padding: 4px 0; cursor: pointer;
  font: inherit; font-size: .81rem; color: var(--muted); text-align: left; }
.resumo-linha:hover { color: var(--text); }
.resumo-linha:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px;
  border-radius: 4px; }
.resumo-linha .n { font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text); min-width: 1.6em; }
.resumo-linha .n.urgente { color: var(--danger); }
.resumo-calmo { font-size: .81rem; color: var(--muted); display: flex;
  align-items: center; gap: 7px; }
.resumo-calmo .ico { width: 15px; height: 15px; color: var(--success); }

/* Cartão da conta, no fundo do painel. */
.painel-pe { padding: 12px; border-top: 1px solid var(--border); }
.conta-cartao {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--border); margin-bottom: 9px;
}
.conta-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}

/* A marca da instituição vive aqui, não no rail: o rail é para navegar. */
.marca-nome { font-weight: 680; font-size: 1.02rem; letter-spacing: -.02em; }
.marca-sub  { font-size: .76rem; color: var(--faint); margin-top: 1px; }

.principal { display: flex; flex-direction: column; min-width: 0; }
.topo {
  display: flex; align-items: center; gap: 14px; padding: 14px 26px;
  border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topo-titulo { flex: 1; min-width: 0; }
.topo-titulo h1 { font-size: 1.22rem; }
.topo-titulo p { margin: 1px 0 0; font-size: .82rem; color: var(--muted); }
.conteudo { padding: 24px 26px 60px; max-width: 1220px; width: 100%; }

/* ---------- Botões (padronizados) ---------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-size: .875rem; font-weight: 580; line-height: 1.2;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .13s, border-color .13s, color .13s, transform .06s;
}
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn .ico { width: 16px; height: 16px; flex: none; stroke-width: 2; }

.btn-primario   { background: var(--primary); color: var(--primary-text); }
.btn-primario:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secundario { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-secundario:hover:not(:disabled) { background: var(--surface-2); border-color: var(--faint); }
.btn-suave      { background: var(--primary-soft); color: var(--primary); }
.btn-suave:hover:not(:disabled) { filter: brightness(.96); }
.btn-fantasma   { background: none; color: var(--muted); }
.btn-fantasma:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-perigo     { background: var(--danger); color: #fff; }
.btn-perigo:hover:not(:disabled) { filter: brightness(1.08); }

.btn-sm { padding: 5px 11px; font-size: .81rem; }
.btn-sm .ico { width: 14px; height: 14px; }
.btn-lg { padding: 11px 20px; font-size: .95rem; }
.btn-bloco { width: 100%; }
.btn-icone { padding: 7px; }
.btn-icone .ico { width: 17px; height: 17px; }

.btn-grupo { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ---------- Cartões ------------------------------------------------------ */
.cartao {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.cartao-topo {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.cartao-topo h3 { flex: 1; min-width: 0; }
.cartao-corpo { padding: 18px; }
.cartao-corpo.sem-pad { padding: 0; }

.grelha { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); }

/* ---------- Indicadores -------------------------------------------------- */
.kpi { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow); }
.kpi-rot { font-size: .76rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--faint); }
.kpi-val { font-size: 1.62rem; font-weight: 660; letter-spacing: -.02em;
  margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.kpi-val.pequeno { font-size: 1.24rem; }

/* ---------- Tabelas ------------------------------------------------------ */
.tabela-env { overflow-x: auto; }
table.tabela { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tabela th {
  text-align: left; font-weight: 600; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--faint); padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2);
}
.tabela td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela tbody tr.clicavel { cursor: pointer; }
.tabela tbody tr.clicavel:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .86em; }

/* ---------- Distintivos -------------------------------------------------- */
.dist {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 20px; font-size: .765rem; font-weight: 600; white-space: nowrap;
}
.dist-neutro  { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.dist-ok      { background: var(--success-soft); color: var(--success); }
.dist-aviso   { background: var(--warning-soft); color: var(--warning); }
.dist-perigo  { background: var(--danger-soft);  color: var(--danger); }
.dist-info    { background: var(--info-soft);    color: var(--info); }
.dist-primario{ background: var(--primary-soft); color: var(--primary); }
.ponto { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- Formulários -------------------------------------------------- */
.campo { margin-bottom: 15px; }
.campo label { display: block; font-size: .82rem; font-weight: 580; margin-bottom: 5px; }
.campo .ajuda { font-size: .775rem; color: var(--faint); margin-top: 4px; }
.campo .erro  { font-size: .775rem; color: var(--danger); margin-top: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password],
input[type=tel], input[type=email], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: .9rem;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); transition: border-color .13s, box-shadow .13s;
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
input:disabled, select:disabled { background: var(--bg); color: var(--muted); }
input.invalido, select.invalido { border-color: var(--danger); }
.linha { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.sufixo-env { position: relative; }
.sufixo-env input { padding-right: 52px; }
.sufixo { position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  font-size: .82rem; color: var(--faint); font-weight: 600; pointer-events: none; }

/* ---------- Modal -------------------------------------------------------- */
.modal-fundo {
  position: fixed; inset: 0; background: rgba(10,14,19,.5); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; border: 1px solid var(--border);
  animation: sobe .16s ease-out;
}
.modal.largo { max-width: 780px; }
@keyframes sobe { from { opacity: 0; transform: translateY(8px); } }
.modal-topo { display: flex; align-items: center; gap: 12px; padding: 17px 20px;
  border-bottom: 1px solid var(--border); }
.modal-topo h2 { flex: 1; font-size: 1.06rem; }
.modal-corpo { padding: 20px; }
.modal-pe { display: flex; gap: 9px; justify-content: flex-end; padding: 15px 20px;
  border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Avisos ------------------------------------------------------- */
.aviso { display: flex; gap: 11px; padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: .865rem; border: 1px solid transparent; }
.aviso .ico { width: 17px; height: 17px; flex: none; margin-top: 1px; stroke-width: 2; }
.aviso-info   { background: var(--info-soft);    color: var(--info);    border-color: currentColor; }
.aviso-ok     { background: var(--success-soft); color: var(--success); border-color: currentColor; }
.aviso-atencao{ background: var(--warning-soft); color: var(--warning); border-color: currentColor; }
.aviso-erro   { background: var(--danger-soft);  color: var(--danger);  border-color: currentColor; }
.aviso strong { font-weight: 640; }

/* ---------- Notificações ------------------------------------------------- */
.notas { position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px; }
.nota { display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--muted);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .875rem;
  max-width: 380px; animation: entra .18s ease-out; }
@keyframes entra { from { opacity: 0; transform: translateX(16px); } }
.nota.ok   { border-left-color: var(--success); }
.nota.erro { border-left-color: var(--danger); }
.nota.aviso { border-left-color: var(--warning); }
.nota .ico { width: 17px; height: 17px; flex: none; }

/* ---------- Estados ------------------------------------------------------ */
.vazio { text-align: center; padding: 48px 20px; color: var(--muted); }
.vazio .ico { width: 38px; height: 38px; stroke-width: 1.4; color: var(--faint); margin-bottom: 12px; }
.vazio h3 { margin-bottom: 5px; color: var(--text); }
.vazio p { margin: 0 0 16px; font-size: .88rem; }

.esqueleto { background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%);
  background-size: 200% 100%; animation: brilha 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes brilha { to { background-position: -200% 0; } }

.rodinha { width: 17px; height: 17px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: roda .6s linear infinite; display: inline-block; }
@keyframes roda { to { transform: rotate(360deg); } }

/* ---------- Ciclo guiado ------------------------------------------------- */
.passos { display: flex; flex-direction: column; gap: 0; }
.passo { display: flex; gap: 15px; padding: 15px 0; border-bottom: 1px solid var(--border); }
.passo:last-child { border-bottom: 0; }
.passo-num { width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .82rem; font-weight: 650;
  background: var(--bg); color: var(--faint); border: 1px solid var(--border); }
.passo.feito .passo-num { background: var(--success-soft); color: var(--success); border-color: transparent; }
.passo.actual .passo-num { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.passo-corpo { flex: 1; min-width: 0; }
.passo-corpo h4 { margin-bottom: 2px; }
.passo-corpo p { margin: 0; font-size: .85rem; color: var(--muted); }
.passo.feito .passo-corpo h4 { color: var(--muted); }
.passo-accao { display: flex; align-items: center; }

/* ---------- Barras de risco ---------------------------------------------- */
.barra { display: flex; height: 9px; border-radius: 20px; overflow: hidden; background: var(--bg); }
.barra span { display: block; }
.legenda { display: flex; flex-wrap: wrap; gap: 13px; margin-top: 13px; font-size: .8rem; }
.legenda-item { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.legenda-cor { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.c1{background:var(--risco-1)} .c2{background:var(--risco-2)} .c3{background:var(--risco-3)}
.c4{background:var(--risco-4)} .c5{background:var(--risco-5)}

/* ---------- Autenticação ------------------------------------------------- */
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.entrada-cartao { width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 30px; }
.entrada-marca { text-align: center; margin-bottom: 24px; }
.entrada-marca .simbolo { width: 46px; height: 46px; border-radius: 12px; background: var(--primary);
  color: var(--primary-text); display: grid; place-items: center; margin: 0 auto 12px; }
.entrada-marca .simbolo .ico { width: 24px; height: 24px; stroke-width: 2; }

/* ---------- Utilitários -------------------------------------------------- */
.pilha  { display: flex; flex-direction: column; gap: 16px; }
.pilha-sm { display: flex; flex-direction: column; gap: 8px; }
.entre  { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fila   { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.esticar{ flex: 1; min-width: 0; }
.mudo   { color: var(--muted); }  .fraco { color: var(--faint); }
.pequeno{ font-size: .82rem; }    .forte { font-weight: 620; }
.cortar { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oculto { display: none !important; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- Comprovativo (impressão) ------------------------------------- */
.comprovativo { font-family: var(--font); color: #000; background: #fff;
  padding: 18mm 15mm; max-width: 148mm; margin: 0 auto; }
.comp-topo { text-align: center; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 14px; }
.comp-topo h2 { font-size: 15pt; margin-bottom: 2px; }
.comp-topo p { margin: 0; font-size: 9pt; }
.comp-linha { display: flex; justify-content: space-between; gap: 12px;
  padding: 5px 0; border-bottom: 1px dotted #999; font-size: 10pt; }
.comp-linha .rot { color: #444; }
.comp-linha .val { font-weight: 650; text-align: right; }
.comp-total { display: flex; justify-content: space-between; margin-top: 12px;
  padding: 9px 0; border-top: 2px solid #000; border-bottom: 2px solid #000;
  font-size: 12pt; font-weight: 700; }
.comp-pe { margin-top: 22px; font-size: 8.5pt; color: #444; text-align: center; }
.comp-assin { margin-top: 30px; display: flex; gap: 30px; font-size: 9pt; }
.comp-assin div { flex: 1; border-top: 1px solid #000; padding-top: 5px; text-align: center; }

/* ---------- Mapa de cobrança (Fase 2.6) ----------------------------------
   Desenhado para sair em papel: A4 deitado, com espaço para escrever à mão o
   que aconteceu à porta do cliente. O agente sai com isto se não houver rede.
   -------------------------------------------------------------------------- */
.mapa { padding: 16mm 14mm; color: #000; background: #fff; }
.mapa-topo { display: flex; justify-content: space-between; gap: 20px;
  align-items: flex-start; border-bottom: 2px solid #000;
  padding-bottom: 10px; margin-bottom: 14px; }
.mapa-topo h2 { font-size: 14pt; }
.mapa-topo p { margin: 2px 0 0; font-size: 9.5pt; }
.mapa-topo-dir { text-align: right; }
.mapa-topo-dir p { margin: 0; font-size: 9.5pt; }
table.mapa-tabela { font-size: 9.5pt; }
table.mapa-tabela th { background: #f0f0f0; color: #000; border-bottom: 1px solid #000; }
table.mapa-tabela td { border-bottom: 1px solid #bbb; padding: 9px 8px; }
table.mapa-tabela .pequeno { font-size: 8.5pt; color: #444; }
/* A coluna onde se escreve à mão. Sem altura não há onde escrever. */
.mapa-escrever { border-left: 1px solid #bbb; min-height: 34px; }
.mapa-total td { border-top: 2px solid #000; border-bottom: 0; }

/* No ecrã o mapa herda as cores do tema; em papel é sempre preto no branco. */
@media screen {
  .mapa { color: var(--text); background: var(--surface); }
  .mapa-topo { border-color: var(--border-2); }
  table.mapa-tabela th { background: var(--surface-2); color: var(--faint); border-color: var(--border); }
  table.mapa-tabela td { border-color: var(--border); }
  table.mapa-tabela .pequeno { color: var(--muted); }
  .mapa-escrever { border-color: var(--border); }
  .mapa-total td { border-color: var(--border-2); }
}

/* ---------- Impressão ----------------------------------------------------- */
@media print {
  body { background: #fff; }
  .rail, .painel, .topo, .notas, .nao-imprimir { display: none !important; }
  .app { display: block; }
  .conteudo { padding: 0; max-width: none; }
  .comprovativo { padding: 0; max-width: none; }
  .cartao { border: 0; box-shadow: none; }
  /* O recibo e a quitação são A5; o mapa de cobrança e os mapas de provisões
     são tabelas largas e precisam de A4 deitado. A regra por omissão é A5, e
     as páginas que têm .mapa ou .tabela-larga pedem A4. */
  @page { size: A5; margin: 12mm; }
  /* O mapa de cobrança é uma tabela larga: pede A4 deitado através de uma
     página nomeada. Onde o browser não suportar `page:`, sai em A5 — apertado,
     mas legível. */
  @page paisagem { size: A4 landscape; margin: 10mm; }
  .mapa { padding: 0; page: paisagem; }
  .mapa-escrever { min-height: 30px; }
  /* Uma linha da tabela não deve partir entre páginas: metade de um cliente
     numa folha e metade na outra manda o agente ao sítio errado. */
  table.mapa-tabela tr, .tabela tr { break-inside: avoid; }
  .tabela thead { display: table-header-group; }
}

/* ---------- Ecrãs pequenos -----------------------------------------------
   Os dois níveis saem juntos como uma gaveta. Separá-los num telemóvel
   obrigaria a dois toques para chegar a qualquer sítio.
   -------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .rail, .painel {
    position: fixed; top: 0; height: 100vh; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .rail { left: 0; }
  /* O painel começa depois do rail, por isso translateX(-100%) — que o desloca
     só a própria largura — deixava-o a espreitar do lado esquerdo tantos
     pixels quantos os do rail. Tem de percorrer a sua largura MAIS o rail. */
  .painel {
    left: var(--rail); width: var(--painel);
    transform: translateX(calc(-100% - var(--rail)));
  }
  .app.menu-aberto .rail,
  .app.menu-aberto .painel { transform: none; }
  .app.menu-aberto .painel { box-shadow: var(--shadow-lg); }
  .veu { position: fixed; inset: 0; background: rgba(10,14,19,.45); z-index: 50; }
  .conteudo { padding: 18px 16px 50px; }
  .topo { padding: 12px 16px; }
}
@media (min-width: 981px) { .so-movel { display: none !important; } }

/* Ecrãs estreitos de secretária: o painel encolhe antes de desaparecer. */
@media (min-width: 981px) and (max-width: 1180px) {
  :root { --painel: 196px; --rail: 68px; }
}
