/* Tema. Estas são as cores do defeito; /tema.css, carregado a seguir a esta
   folha, substitui o bloco inteiro pelas cores da farmácia da sessão. Só
   `--marca` e `--destaque` são escolhidas — as restantes são misturas delas,
   calculadas em src/tema.js. Ver "Tema por farmácia" em deploy/README.md. */
:root {
  --marca: #327bbf;
  --destaque: #b1ce36;
  --marca-escura: #24598a;
  --marca-suave: #e0ebf5;
  --marca-tenue: #f1f6fb;
  --marca-sombra: rgba(50, 123, 191, 0.28);
  --cinza: #f4f4f7;
  --borda: #dcdce3;
  --texto: #23232b;
  --verde: #1f8a4c;
  --vermelho: #c0392b;
  --amarelo: #b8860b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: var(--cinza);
}

header {
  background: var(--marca);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Quem está ligado, em que farmácia, e o botão de sair — encostado à direita,
   com o botão de definições logo a seguir. */
#sessao {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-size: .85rem;
}

#sessao .quem {
  opacity: .85;
  white-space: nowrap;
}

#sessao .farmacia {
  font-weight: 600;
  white-space: nowrap;
}

#sessao select {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: .85rem;
  font-family: inherit;
  max-width: 220px;
}

/* As opções herdariam o fundo translúcido e ficariam ilegíveis no menu aberto */
#sessao select option {
  color: var(--texto);
  background: #fff;
}

#sessao .btn.ghost {
  background: rgba(255, 255, 255, .18);
  color: #fff;
}

#sessao .btn.ghost:hover {
  background: rgba(255, 255, 255, .32);
}

header .toggle-sidebar {
  float: right;
  margin-left: 8px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 1.05rem;
  line-height: 1;
}

header .toggle-sidebar:hover {
  background: rgba(255, 255, 255, .32);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  /* O cabeçalho é flex e o bloco da sessão disputa-lhe a largura: sem isto, o
     subtítulo quebra para duas linhas em janelas estreitas e o cabeçalho cresce,
     desalinhando a altura de que o `main` depende. */
  min-width: 0;
}

.brand-text {
  min-width: 0;
}

header h1,
header .sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#header-logo {
  height: 46px;
  max-width: 160px;
  object-fit: contain;
  border-radius: 8px;
  padding: 4px;
}

header h1 {
  margin: 0;
  font-size: 1.3rem;
}

header .sub {
  margin: 2px 0 0;
  opacity: .8;
  font-size: .85rem;
}

main {
  display: flex;
  gap: 0;
  height: calc(100vh - 66px);
}

/* Barrinha de ícones (aparece quando a sidebar recolhe) */
#rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 5px 8px;
  background: #fff;
  border-right: 1px solid var(--borda);
  flex-shrink: 0;
  z-index: 100;
  margin-left: -61px;
  transition: all .5s ease-in-out;
}

#rail.showing {
  margin-left: 0;
}

#rail button {
  border: none;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  cursor: pointer;
  /* Os ícones são SVG com fill/stroke a currentColor, para seguirem o tema */
  color: var(--destaque);
}

/* Os de administração distinguem-se pela cor principal, não pela de destaque */
#rail button.rail-admin {
  color: var(--marca);
}

#rail button:hover {
  background: var(--cinza);
}

/* Sidebar */
#sidebar {
  border-right: 1px solid var(--borda);
  background: #fff;
  padding: 5px 16px 16px;
  overflow-y: auto;
  width: 30%;
  transition: all .5s ease-in-out;
}

#sidebar.closed {
  margin-left: -30%;
}

.closing-sidebar {
  display: flex;
  justify-content: flex-end;
  border-bottom: #555;
}

.closing-sidebar .toggle-sidebar {
  background-color: transparent;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.closing-sidebar .toggle-sidebar:hover {
  background: var(--cinza);
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 1rem;
}

#pesquisa,
#pesquisa-prod,
#pesquisa-lote {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  margin-bottom: 12px;
}

#lista-utentes {
  list-style: none;
  margin: 0;
  padding: 0;
}

#lista-utentes li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
}

#lista-utentes li:hover {
  background: var(--cinza);
}

#lista-utentes li.ativo {
  background: var(--marca);
  color: #fff;
}

#lista-utentes li small {
  display: block;
  opacity: .7;
  font-size: .78rem;
}

/* Detalhe */
#detalhe {
  overflow-y: auto;
  flex: 1;
  padding: 24px 32px;
}

.placeholder {
  color: #888;
  margin-top: 60px;
  text-align: center;
}

.card {
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: var(--marca);
}

.card h3 .count {
  font-size: .8rem;
  color: #888;
  font-weight: normal;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
  flex: 1;
  min-width: 160px;
}

.field label {
  font-size: .78rem;
  color: #666;
  margin-bottom: 3px;
}

.field input,
.field select,
.field textarea {
  padding: 8px 10px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: .92rem;
  font-family: inherit;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .9rem;
  margin: 6px 0;
}

/* Identificação visual do comprimido (cor · forma) na ficha do utente */
small.pilula {
  color: var(--marca);
}

/* Autocomplete (pesquisa sugestiva de medicamentos no formulário do utente) */
.field.autocomplete {
  position: relative;
}

.ac-lista {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 2px;
}

.ac-item {
  padding: 8px 10px;
  cursor: pointer;
  font-size: .9rem;
  border-bottom: 1px solid var(--cinza);
}

.ac-item:last-child {
  border-bottom: none;
}

.ac-item:hover {
  background: var(--marca-tenue);
}

.ac-item small {
  color: #888;
}

.ac-meta {
  font-size: .78rem;
}

.lista-descartes {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.lista-descartes li {
  padding: 8px 10px;
  border: 1px solid var(--cinza);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: .9rem;
}

svg.signed-icon {
  width: 24px;
  height: 24px;
  fill: var(--marca);
}

p.signed-on-text {
  display: flex;
  gap: 5px;
}

/* Botões */
.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: .9rem;
  cursor: pointer;
  background: #e6e6ee;
  color: var(--texto);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease-in-out;
}

/* Faz parte do bloco da direita do cabeçalho (era posicionado em absoluto,
   antes de o cabeçalho ser flex e de haver o bloco da sessão). */
.btn.settings {
  flex: none;
  background-color: transparent;
}

.btn.settings svg {
  width: 24px;
  height: 24px;
  fill: white;
  transition: all .3s ease;
}

.btn.settings:hover svg {
  fill: var(--destaque);
}

.btn.primary {
  background: var(--marca);
  color: #fff;
  font-size: 0.8rem;
}

.btn.primary:hover {
  background: var(--destaque);
}

.btn.ghost {
  background: transparent;
  color: var(--marca);
}

.btn.ghost:hover {
  color: var(--destaque);
}

.btn.mini {
  padding: 4px 9px;
  font-size: .8rem;
}

/* Ícones SVG dentro dos botões (editar/arquivar) */
.btn svg.ic {
  display: block;
  width: 16px;
  height: 16px;
}

.btn.danger {
  background: transparent;
  color: var(--vermelho);
}

/* Tabelas */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

th,
td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--borda);
}

th {
  font-size: .78rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* Badges de estado */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}

.badge.em_preparacao {
  background: #fff3d6;
  color: var(--amarelo);
}

.badge.verificacao_final {
  background: #dfe9ff;
  color: #2f5bd0;
}

.badge.selado {
  background: #dff5e6;
  color: var(--verde);
}

.badge.entregue {
  background: #e6e6ee;
  color: #555;
}

.badge.excluido {
  background: #fde3e0;
  color: var(--vermelho);
}

.badge.incluido {
  background: #dff5e6;
  color: var(--verde);
}

/* Posologia por dias do mês (em vez de dias da semana) */
.badge.mensal {
  background: var(--marca-suave);
  color: var(--marca-escura);
}

/* Escolha do destino do stock ao apagar um PIM */
.opcoes-apagar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.opcao-apagar {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--borda);
  border-radius: 10px;
  cursor: pointer;
}

.opcao-apagar:hover {
  background: var(--marca-tenue);
}

.opcao-apagar input {
  margin-top: 3px;
}

.opcao-apagar small {
  color: #666;
}

/* Marca de PIM apagado na pesquisa por lote */
.pim-apagado {
  color: var(--vermelho);
}

/* Nota "≡ igual a …" nos medicamentos equivalentes (partilham stock) */
.equiv-nota {
  color: var(--marca-escura);
}

/* Modal */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 10;
}

#modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  z-index: 11;
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}

#modal h3 {
  margin-top: 0;
  color: var(--marca);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* Grelha semanal (medicamentos x momentos) — clicável */
.grelha-wrap {
  overflow-x: auto;
}

table.grelha {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

table.grelha th,
table.grelha td {
  border: 1px solid var(--borda);
  text-align: center;
  vertical-align: middle;
}

table.grelha thead th {
  background: var(--cinza);
  font-size: .78rem;
  color: #555;
  padding: 6px 4px;
  text-transform: none;
  letter-spacing: 0;
}

table.grelha th.med-nome {
  background: var(--cinza);
  font-size: .82rem;
  color: var(--texto);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 1;
}

table.grelha th.med-nome small {
  color: #888;
  font-weight: 400;
}

table.grelha thead th.med-nome {
  color: #555;
}

table.grelha td.cel-toma {
  padding: 6px 5px;
  cursor: pointer;
  min-width: 82px;
  height: 46px;
}

table.grelha td.cel-toma:hover {
  background: var(--marca-tenue);
}

table.grelha td.cel-toma.preenchida {
  background: var(--marca-tenue);
}

.cel-qtd {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--marca);
  line-height: 1.1;
}

.cel-dias {
  display: block;
  font-size: .66rem;
  color: #777;
  margin-top: 2px;
  line-height: 1.15;
}

.cel-dias.todos {
  font-style: italic;
}

/* Dias com quantidade diferente da principal (ex.: "exceto Qua ½") */
.cel-excecoes {
  display: block;
  font-size: .66rem;
  color: #a5342a;
  line-height: 1.15;
  margin-top: 1px;
}

.cel-vazia {
  color: #bbb;
  font-size: 1.1rem;
}

/* Grelha de totais (dias x momentos) — só leitura */
table.grelha.totais td.cel-total {
  font-size: .95rem;
  font-weight: 600;
  color: var(--texto);
  height: 34px;
}

table.grelha.totais td.cel-total.zero {
  color: #ccc;
  font-weight: 400;
}

table.grelha.totais td.cel-total.soma {
  background: var(--marca-tenue);
  color: var(--marca);
  font-weight: 700;
}

table.grelha.totais tr.linha-totais th.med-nome,
table.grelha.totais thead th:last-child {
  background: var(--marca-tenue);
  color: var(--marca);
}

table.grelha.totais td.cel-total.grand {
  background: var(--marca-suave);
  color: var(--marca);
  font-weight: 800;
}

/* Editor de toma: quantidade + escolha de dias */
.toma-qtd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
}

.dias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 6px;
  margin: 4px 0 2px;
}

/* Grelha dos dias do mês (1 a 31) — botões mais pequenos e em mais colunas */
.dias-grid.mes {
  grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
}

.dia-check.dia-mes {
  padding: 5px 4px;
  justify-content: center;
  gap: 3px;
  font-size: .8rem;
}

/* Lista de medicamentos a associar como equivalentes */
.dias-grid.equiv {
  grid-template-columns: 1fr;
  max-height: 44vh;
  overflow-y: auto;
}

.equiv-item {
  align-items: flex-start;
  padding: 8px 10px;
}

.equiv-item input {
  margin-top: 3px;
}

/* Menu de escolha do tipo de horário no editor de tomas */
.seg-modo {
  display: flex;
  gap: 0;
  margin: 8px 0 0;
  border: 1px solid var(--borda);
  border-radius: 10px;
  overflow: hidden;
}

.seg-modo .seg {
  flex: 1;
  padding: 9px 10px;
  border: none;
  background: #fff;
  font: inherit;
  font-size: .88rem;
  color: #555;
  cursor: pointer;
}

.seg-modo .seg+.seg {
  border-left: 1px solid var(--borda);
}

.seg-modo .seg:hover {
  background: var(--marca-tenue);
}

.seg-modo .seg.ativo {
  background: var(--marca);
  color: #fff;
  font-weight: 600;
}

.dia-check {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
}

.dia-check input {
  margin: 0;
}

/* Popup de toma com contadores */
.toma-lista {
  max-height: 50vh;
  overflow-y: auto;
  margin: 4px 0;
}

.toma-linha {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--borda);
}

.toma-nome small {
  color: #888;
}

.toma-nome .badge {
  margin-left: 6px;
}

.counter {
  display: flex;
  align-items: center;
  gap: 4px;
}

.counter .cnt {
  width: 52px;
  text-align: center;
  padding: 6px 4px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
}

.counter .btn.mini {
  min-width: 30px;
  font-size: 1rem;
  padding: 4px 0;
}

/* Dica de que a quantidade aceita frações escritas à mão */
.qtd-ajuda {
  margin: 2px 0 0;
  color: #888;
  font-size: .8rem;
}

/* Lista dos dias desmarcados, cada um com a sua quantidade */
.excecoes {
  margin-top: 10px;
}

.excecoes-tit {
  font-weight: 600;
  font-size: .9rem;
  color: var(--marca);
}

.excecoes-ajuda {
  margin: 2px 0 6px;
  color: #888;
  font-size: .8rem;
}

.excecao {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--borda);
}

.excecao:last-child {
  border-bottom: none;
}

.excecao-dia {
  min-width: 44px;
  font-weight: 600;
  font-size: .88rem;
}

.stock-baixo {
  color: var(--vermelho);
  font-weight: 600;
}

.linha-esgotada {
  opacity: .55;
}

.stock-topo {
  margin-bottom: 5px;
}

.caixas-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

/* Chip de caixa */
.caixa-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  background: #eef0f5;
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 3px 9px;
  font-size: .74rem;
  color: #444;
}

table.tab-consumos {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: .85rem;
}

table.tab-consumos th,
table.tab-consumos td {
  border-bottom: 1px solid var(--borda);
  padding: 4px 6px;
  text-align: left;
}

table.tab-consumos thead th {
  color: #666;
  font-size: .78rem;
}

.caixa-chip.clicavel {
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.caixa-chip.clicavel:hover {
  border-color: var(--marca);
  box-shadow: 0 1px 4px var(--marca-sombra);
}

.caixa-chip.em-uso {
  background: #e2f6e9;
  border-color: #a9dcbc;
  color: #1f7a45;
  width: 100%;
}

.caixa-chip .tag-uso {
  background: var(--verde);
  color: #fff;
  border-radius: 5px;
  padding: 0 6px;
  font-size: .64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  align-self: flex-end;
}

.caixa-chip.gasta {
  background: #f6f6f8;
  color: #aaa;
  text-decoration: line-through;
}

.btn.add-caixa {
  margin-top: 7px;
  background: var(--marca-suave);
  width: 100%;
  color: var(--marca);
  font-weight: 600;
}

.btn.add-caixa:hover {
  background: var(--destaque);
}

td.gasto-sem {
  text-align: center;
}

.acoes-med .btn {
  margin-left: 4px;
}

.caixas-hist {
  margin-top: 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.caixas-hist summary {
  font-size: .74rem;
  color: #888;
  cursor: pointer;
}

.caixas-hist[open] summary {
  margin-bottom: 4px;
}

/* Tabs da barra lateral (Utentes / Grupos / Farmacêuticos) */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 12px;
  background: var(--cinza);
  border-radius: 10px;
  padding: 3px;
}

.tab {
  display: flex;
  gap: 5px;
  flex: 1 1 40%;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .82rem;
  color: #666;
  font-weight: 600;
  font-family: inherit;
}

.sidebar-svg {
  width: 20px;
  height: 20px;
}

/* Os ícones do trabalho do dia-a-dia ficam na cor de destaque, em qualquer
   estado da aba — era a cor que tinham fixa antes de seguirem o tema. */
.tab:not(.tab-admin) .sidebar-svg {
  color: var(--destaque);
}

.tab.ativo {
  background: #fff;
  color: var(--marca);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

/* Administração — outra natureza de trabalho que a gestão de utentes, por isso
   fica em cima, na cor da marca e separada por um traço. */
.tab-admin {
  color: var(--marca);
}

.tab-admin .sidebar-svg {
  color: var(--marca);
}

.tab-admin.ativo {
  background: var(--marca);
  color: #fff;
}

.tab-admin.ativo .sidebar-svg {
  color: #fff;
}

/* Ocupa a linha toda: força a quebra no flex-wrap e desenha o traço */
.tabs-sep {
  flex: 1 1 100%;
  height: 1px;
  background: var(--borda);
  margin: 5px 4px;
}

/* O mesmo na barrinha de ícones, quando a barra lateral está recolhida */
.rail-sep {
  height: 1px;
  background: var(--borda);
  margin: 2px 4px;
}

/* Painel de boas-vindas do admin, enquanto não escolheu farmácia */
.placeholder-admin {
  max-width: 460px;
  margin: 60px auto;
  padding: 0 24px;
  color: #666;
}

.placeholder-admin h2 {
  color: var(--marca);
  font-size: 1.2rem;
  margin: 0 0 10px;
}

.placeholder-admin p {
  font-size: .9rem;
  line-height: 1.5;
  margin: 0 0 10px;
}

#sidebar-body ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Cabeçalho de cada tab (botões de ação) */
.sb-head {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* Itens de lista genéricos (grupos, farmacêuticos) */
.lista-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 3px;
}

.lista-item:hover {
  background: var(--cinza);
}

.lista-item.ativo {
  background: var(--marca);
  color: #fff;
}

.lista-item.ativo small {
  color: rgba(255, 255, 255, .78);
}

.lista-item .li-main small {
  display: block;
  opacity: .7;
  font-size: .78rem;
}

.li-acoes {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.lista-item.ativo .li-acoes .btn[title="Editar"] {
  color: var(--destaque);
}

.grupo-cab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 6px 4px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #999;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
}

.grupo-cab:hover {
  background: var(--cinza) !important;
  color: #666;
}

.grupo-cab .chevron {
  font-size: .7rem;
  width: 10px;
}

.grupo-cab .grupo-nome {
  flex: 1;
}

.grupo-cab small {
  background: #e6e6ee;
  border-radius: 10px;
  padding: 0 7px;
  color: #777;
}

li.utente-item {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 3px;
}

li.utente-item:hover {
  background: var(--cinza);
}

li.utente-item.ativo {
  background: var(--marca);
  color: #fff;
}

li.utente-item small {
  display: block;
  opacity: .7;
  font-size: .78rem;
}

.vazio-lista {
  color: #999;
  padding: 12px 6px;
  font-size: .85rem;
}

/* Farmácia ou conta desativada, nas listas de administração */
.lista-item.arquivado strong {
  color: #999;
  text-decoration: line-through;
}

/* Explicação curta dentro de um formulário */
.nota-form {
  color: #666;
  font-size: .8rem;
  margin: 4px 0 12px;
}

/* Confirmação (sobreposta) */
#confirm {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}

#confirm.hidden {
  display: none;
}

.confirm-box {
  background: #fff;
  border-radius: 14px;
  padding: 22px 24px;
  width: min(440px, 92vw);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}

.confirm-box h3 {
  margin-top: 0;
  color: var(--marca);
}

.btn.danger-solid {
  background: var(--vermelho);
  color: #fff;
}

.btn.danger-solid:hover {
  background: #a5342a;
}

a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* Toasts (notificações) */
#toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff;
  font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  animation: toast-in .2s ease;
}

.toast.erro {
  background: var(--vermelho);
}

.toast.aviso {
  background: var(--amarelo);
}

.toast.ok {
  background: var(--verde);
}

.toast.a-sair {
  opacity: 0;
  transition: opacity .4s;
}

@keyframes toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Erro dentro do modal */
.modal-erro {
  background: #fde3e0;
  border: 1px solid #f0b3ab;
  color: var(--vermelho);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: .88rem;
  margin-bottom: 12px;
}

/* Controlos da toma: contador + checkbox "todos os dias" */
.toma-ctrl {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.check-dias {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .74rem;
  color: #666;
  white-space: nowrap;
  cursor: pointer;
}

/* Pré-visualização do logótipo nas Definições */
.logo-prev {
  margin-top: 6px;
}

.logo-prev img {
  max-height: 64px;
  max-width: 180px;
  border: 1px solid var(--borda);
  border-radius: 6px;
  padding: 4px;
  background: #fff;
}

/* Ações de cada dispositivo (inclui etiqueta) */
.disp-acoes {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Identificador do dispositivo clicável (abre popup de detalhes) */
.disp-link {
  cursor: pointer;
  text-decoration: underline dotted;
  color: var(--marca);
}

.disp-link:hover {
  background: var(--marca-tenue);
  border-radius: 4px;
}

/* Linhas de detalhe (popup do dispositivo) */
.det-linha {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--borda);
  font-size: .9rem;
}

.det-rot {
  min-width: 200px;
  color: #666;
  font-size: .82rem;
}

.hidden {
  display: none !important;
}

.aviso {
  background: #fff3d6;
  border: 1px solid #e6cf8f;
  color: #7a5b00;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: .85rem;
  margin-bottom: 12px;
}
/* Escolha das duas cores do tema, nas Definições da farmácia */
.cores-tema {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.cor-par {
  display: grid;
  grid-template-columns: 42px 90px;
  /* O rótulo em cima para os seletores e o botão "Repor" ficarem todos
     alinhados pela base da mesma linha. */
  grid-template-areas: "rotulo rotulo" "seletor hex";
  align-items: center;
  gap: 3px 8px;
}

.cor-par input[type="color"] {
  grid-area: seletor;
  width: 42px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.cor-par input[type="text"] {
  grid-area: hex;
  padding: 7px 8px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
}

.cor-par small {
  grid-area: rotulo;
  color: #666;
  font-size: .78rem;
}
