/* ENAPOR Konekta — base: tipografia, botões, campos, estados, tabelas e a casca (barra lateral, faixa de cima e ecrã).
   Os nomes das classes são os do Kwalit Care onde o código vem de lá (.btn, .alerta, .pill, .toast, .a-carregar…). O que é de
   um ecrã em particular fica na folha desse ecrã. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  /* uma palavra que não cabe na linha parte-se, em vez de empurrar a página para o lado */
  overflow-wrap: break-word;
}

a { color: var(--azul-texto); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
code, pre, .mono { font-family: var(--mono); font-size: 0.86em; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5rem; letter-spacing: -0.012em; }
h1 { font-size: var(--t-g); font-weight: 700; }
h2 { font-size: var(--t-m); font-weight: 650; }
h3 { font-size: var(--t-base); font-weight: 650; }
h4 { font-size: var(--t-peq); color: var(--dim); margin-top: 0.75rem; }
/* o router põe o foco no título do ecrã quando se muda de ecrã: não é um controlo, e não leva anel */
h1[tabindex="-1"]:focus { outline: none; }
p { margin: 0 0 0.6rem; }
.dim { color: var(--dim); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.texto-erro { color: var(--erro); }
.so-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
::selection { background: var(--correr-fundo); }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 4px; }

.ico {
  width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.18em;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------------- botões e campos ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--raio-peq); border: 1px solid var(--borda-forte);
  background: var(--superficie); color: var(--texto); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-rapida), border-color var(--dur-rapida), transform var(--dur-rapida) var(--curva);
}
.btn:hover { border-color: var(--azul-claro); background: var(--superficie-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primario { background: var(--botao); border-color: var(--botao); color: var(--acento-texto); }
.btn-primario:hover { background: var(--azul); border-color: var(--azul); }
.btn-contorno { border-color: var(--botao); color: var(--botao); }
.btn-contorno:hover { background: var(--correr-fundo); border-color: var(--botao); color: var(--azul-texto); }
.btn-leve { background: transparent; border-color: transparent; color: var(--dim); }
.btn-leve:hover { background: var(--superficie-2); border-color: transparent; color: var(--texto); }
.btn-peq { padding: 0.25rem 0.65rem; font-size: var(--t-peq); }
.btn-perigo { color: var(--erro); }
.btn-perigo:hover { border-color: var(--erro); background: var(--erro-fundo); }
/* O botão a trabalhar (o KN.ocupado): fica desativado, com uma rodinha por cima do texto. O texto fica lá, só que invisível —
   a largura não muda e nada à volta salta — e a rodinha usa a cor do botão. */
.btn.a-carregar { position: relative; -webkit-text-fill-color: transparent; }
.btn.a-carregar:disabled { opacity: 1; cursor: progress; }
.btn.a-carregar > svg { visibility: hidden; }
.btn.a-carregar::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 1em; height: 1em; margin: -0.5em 0 0 -0.5em;
  border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: btn-rodar 0.7s linear infinite;
}
@keyframes btn-rodar { to { transform: rotate(360deg); } }

.campo { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.campo > span { font-weight: 600; font-size: 0.93rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea, select {
  font: inherit; color: var(--texto); background: var(--superficie);
  border: 1px solid var(--borda-campo); border-radius: var(--raio-peq); padding: 0.5rem 0.7rem; max-width: 100%;
  transition: border-color var(--dur-rapida);
}
input::placeholder, textarea::placeholder { color: var(--dim); opacity: 1; }
input:hover, textarea:hover, select:hover { border-color: var(--dim); }
textarea { resize: vertical; width: 100%; }
/* O foco de um campo vê-se: a borda e mais 1 px por fora, em --acento. Um outline, e não uma sombra: no alto contraste do
   Windows as sombras desaparecem. */
input:where(:not([type="checkbox"]):not([type="radio"])):focus, textarea:focus, select:focus {
  outline: 1px solid var(--acento); outline-offset: 0; border-color: var(--acento);
}
input[type="checkbox"] { accent-color: var(--acento); }
.linha { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ---------------- avisos, estados, etiquetas e notificações ---------------- */

.alerta {
  border-radius: var(--raio-peq); padding: 0.7rem 0.9rem; margin: 0 0 0.8rem;
  border: 1px solid var(--borda); border-left-width: 3px; background: var(--superficie);
}
.alerta-info { border-left-color: var(--azul); background: var(--correr-fundo); }
.alerta-ok { border-color: var(--ok); background: var(--ok-fundo); }
.alerta-aviso { border-color: var(--aviso); background: var(--aviso-fundo); }
.alerta-erro { border-color: var(--erro); background: var(--erro-fundo); }
.alerta strong { font-weight: 700; }
.alerta-ok > strong:first-child { color: var(--ok); }
.alerta-aviso > strong:first-child { color: var(--aviso); }
.alerta-erro > strong:first-child { color: var(--erro); }
.avisos:empty { display: none; }
/* o aviso de um ecrã que não abriu: a frase, o pormenor e o que fazer */
.erro-ecra { max-width: 48rem; }
.erro-ecra > p { margin: 0.3rem 0 0; }
.erro-ecra > .linha { margin-top: 0.8rem; }

/* O estado diz-se em palavras e com a cor: nunca só com a cor. O .pill-ponto acrescenta o ponto à frente. */
.pill {
  display: inline-flex; align-items: center; gap: 0.4em; padding: 0.1rem 0.65rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 650; background: var(--superficie-2); color: var(--dim); white-space: nowrap;
}
.pill-ok { background: var(--ok-fundo); color: var(--ok); }
.pill-aviso { background: var(--aviso-fundo); color: var(--aviso); }
.pill-erro { background: var(--erro-fundo); color: var(--erro); }
.pill-correr { background: var(--correr-fundo); color: var(--azul-texto); }
.pill-ponto::before { content: ""; width: 0.5em; height: 0.5em; border-radius: 50%; background: currentColor; }
.pill-correr.pill-ponto::before { animation: sinal 1.6s var(--curva) infinite; }
/* o ponto sozinho, antes de um texto («Exact — ligado») */
.ponto { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--neutro); flex: none; }
.ponto-ok { background: var(--ok); }
.ponto-aviso { background: var(--aviso); }
.ponto-erro { background: var(--erro); }
.ponto-correr { background: var(--azul); animation: sinal 1.6s var(--curva) infinite; }
/* o ponto do «a correr» emite uma onda, como um sinal */
@keyframes sinal {
  0% { box-shadow: 0 0 0 0 rgba(20, 100, 244, 0.5); }
  70% { box-shadow: 0 0 0 0.45em rgba(20, 100, 244, 0); }
  100% { box-shadow: 0 0 0 0 rgba(20, 100, 244, 0); }
}

/* a etiqueta (a fonte de uma resposta, um filtro); com .chip-acao é um botão de contorno (uma sugestão) */
.chip {
  display: inline-flex; align-items: center; gap: 0.35em; padding: 0.12rem 0.65rem; border-radius: 999px;
  font-size: 0.8rem; background: var(--superficie-2); color: var(--ativo); border: 1px solid transparent;
}
.chip-acao { font: inherit; font-size: 0.8rem; background: var(--superficie); color: var(--azul-texto); border-color: var(--azul-claro); cursor: pointer; }
.chip-acao:hover { background: var(--correr-fundo); border-color: var(--botao); }
.chip-ok { background: var(--ok-fundo); color: var(--ok); }
.chip-aviso { background: var(--aviso-fundo); color: var(--aviso); }
.chip-erro { background: var(--erro-fundo); color: var(--erro); }

.toasts {
  position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 50; max-width: min(28rem, calc(100vw - 2rem));
}
.toast {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.95rem; border-radius: var(--raio-peq);
  background: var(--marinho); color: #fff; box-shadow: var(--sombra-alta); font-size: 0.93rem;
  animation: toast-entra var(--dur-lenta) var(--curva-mola) both;
}
.toast::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--azul-claro); flex: none; }
.toast-texto { flex: 1; min-width: 0; }
.toast .btn { flex: none; }
.toast .btn-leve { color: var(--azul-claro); }
.toast-ok::before { background: #5CD08A; }
.toast-erro::before { background: #FF8A80; }
.toast.a-sair { animation: toast-sai var(--dur) var(--curva) both; }
@keyframes toast-entra { from { opacity: 0; transform: translateY(0.8rem) scale(0.97); } }
@keyframes toast-sai { to { opacity: 0; transform: translateX(1.5rem); } }

/* ---------------- painéis, tabelas e o que ainda carrega ---------------- */

.painel {
  background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--sombra);
}
.vazio { padding: 2.4rem 1rem; text-align: center; color: var(--dim); }
.grelha-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1rem; }

.tabela-wrap { overflow-x: auto; background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); }
.tabela { width: 100%; border-collapse: collapse; }
.tabela th, .tabela td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--borda); text-align: left; vertical-align: middle; }
.tabela th { font-size: 0.78rem; color: var(--dim); font-weight: 650; background: var(--superficie); }
.tabela th.num, .tabela td.num { text-align: right; }
.tabela tbody tr:hover td { background: var(--superficie-2); }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tr.clicavel { cursor: pointer; }
.tabela tr.ativa td { background: var(--superficie-2); }

.esqueleto { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.4rem 0 1rem; }
.esqueleto span {
  display: block; height: 0.9rem; border-radius: 6px;
  background: linear-gradient(90deg, var(--superficie-2) 0%, var(--superficie-3) 45%, var(--superficie-2) 90%);
  background-size: 250% 100%; animation: brilho-esqueleto 1.3s linear infinite;
}
.esqueleto span:nth-child(1) { width: 38%; height: 1.3rem; }
.esqueleto span:nth-child(2) { width: 92%; }
.esqueleto span:nth-child(3) { width: 78%; }
.esqueleto span:nth-child(4) { width: 85%; }
@keyframes brilho-esqueleto { from { background-position: 100% 0; } to { background-position: -150% 0; } }

/* ---------------- a casca: barra lateral, faixa de cima e o ecrã ---------------- */

/* «Saltar para o conteúdo»: o primeiro Tab da página, fora do ecrã até ter o foco. */
.saltar {
  position: fixed; left: 0.75rem; top: -4rem; z-index: 60;
  padding: 0.55rem 0.95rem; border-radius: var(--raio-peq); background: var(--marinho); color: #fff;
  font-weight: 620; text-decoration: none; box-shadow: var(--sombra-alta);
}
.saltar:focus { top: 0.6rem; }

.shell { display: grid; grid-template-columns: var(--lateral) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

.lateral {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 1.4rem;
  padding: 0.9rem 0.5rem; background: var(--marinho); z-index: 30;
}
.marca { display: grid; place-items: center; text-decoration: none; }
.marca img { width: 2.3rem; height: 2.3rem; display: block; }
.nav { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.nav a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: 0.6rem 0.2rem; border-radius: 10px; text-decoration: none;
  color: var(--azul-claro); font-size: 0.7rem; font-weight: 600; line-height: 1.2;
  transition: color var(--dur-rapida), background var(--dur-rapida);
}
.nav a:hover { color: #fff; background: rgba(156, 188, 244, 0.14); }
.nav a.ativo { color: #fff; background: var(--ativo); }
.nav a.ativo::before {
  content: ""; position: absolute; left: -0.5rem; top: 0.5rem; bottom: 0.5rem; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--azul);
}
.nav a:focus-visible { outline-color: #fff; }
.nav .ico { width: 1.35rem; height: 1.35rem; }

.palco { min-width: 0; display: flex; flex-direction: column; }

.faixa {
  position: sticky; top: 0; z-index: 20; height: var(--faixa); display: flex; align-items: center; gap: 0.9rem;
  padding: 0 1.4rem; background: rgba(255, 255, 255, 0.92); border-bottom: 1px solid var(--borda);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 0.85rem; color: var(--dim);
}
.faixa-marca { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--texto); text-decoration: none; }
.faixa-marca strong { font-size: 1.15rem; font-weight: 750; letter-spacing: -0.01em; }
.faixa-sep { width: 1px; height: 1.1rem; background: var(--borda-forte); }
.faixa-espaco { flex: 1; }
.faixa-perfil {
  padding: 0.2rem 0.8rem; border: 1px solid var(--borda-forte); border-radius: 999px;
  color: var(--texto); font-size: 0.8rem; font-weight: 560; white-space: nowrap;
}
.faixa-botao {
  display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  border: 0; background: transparent; color: var(--dim); font: inherit; cursor: pointer;
}
.faixa-botao:hover:not(:disabled) { background: var(--superficie-2); color: var(--texto); }
.faixa-botao:disabled { opacity: 0.5; cursor: not-allowed; }
.faixa-botao .ico { width: 1.15rem; height: 1.15rem; }

.eu { position: relative; }
.avatar {
  display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 0;
  background: #DCE8FB; color: var(--ativo); font: inherit; font-size: 0.75rem; font-weight: 750; cursor: pointer;
}
.avatar:hover, .avatar[aria-expanded="true"] { background: var(--azul-claro); }
.eu-menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 40; min-width: 15rem; padding: 0.4rem;
  display: flex; flex-direction: column; background: var(--superficie); color: var(--texto);
  border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra-alta);
  animation: sobe var(--dur) var(--curva) both;
}
.eu-quem { display: flex; flex-direction: column; padding: 0.5rem 0.6rem 0.6rem; border-bottom: 1px solid var(--borda); margin-bottom: 0.3rem; line-height: 1.3; }
.eu-quem small { color: var(--dim); overflow-wrap: anywhere; }
.eu-menu button {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.6rem; border: 0; border-radius: var(--raio-peq);
  background: transparent; color: var(--texto); font: inherit; cursor: pointer; text-align: left;
}
.eu-menu button:hover, .eu-menu button:focus-visible { background: var(--superficie-2); }
@keyframes sobe { from { opacity: 0; transform: translateY(0.5rem); } }

.vista { padding: 1.6rem 1.8rem 3rem; width: 100%; max-width: 96rem; margin-inline: auto; }
/* o cabeçalho de cada ecrã: o título (e a frase por baixo) à esquerda, as ações à direita */
.vista-cab { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.6rem 1rem; margin: 0 0 1.2rem; }
.vista-cab h1 { margin: 0; overflow-wrap: anywhere; }
.vista-cab p { margin: 0.2rem 0 0; color: var(--dim); }
.vista-acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

/* ---------------- ecrã estreito: a barra lateral passa para baixo ---------------- */

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .lateral {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; gap: 0;
    padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  }
  .marca { display: none; }
  .nav { flex-direction: row; justify-content: space-around; gap: 0.2rem; }
  .nav a { flex: 1 1 0; padding: 0.35rem 0.2rem; }
  .nav a.ativo::before { left: 0.5rem; right: 0.5rem; top: -0.35rem; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .faixa { padding: 0 1rem; gap: 0.6rem; }
  .faixa-perfil, .faixa-data { display: none; }
  .vista { padding: 1rem 1rem calc(6rem + env(safe-area-inset-bottom, 0px)); }
  .toasts { bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
