@import url('fontes.css');

:root {
  --texto:          #0b1c30;
  --texto-suave:    #464554;
  --texto-fraco:    #767586;
  --fundo-pagina:   #f8f9ff;
  --fundo:          #eff4ff;
  --surface-low:    #eff4ff;
  --surface:        #e5eeff;
  --surface-high:   #dce9ff;
  --cartao:         #ffffff;
  --borda:          #c7c4d7;
  --borda-suave:    #dce9ff;
  --accent:         #4648d4;
  --accent-hover:   #3a3cb8;
  --accent-bg:      #e1e0ff;
  --pago-bg:        #6ffbbe26;
  --pago-fg:        #005236;
  --pendente-bg:    #dae2fd;
  --pendente-fg:    #3f465c;
  --vencido-bg:     #ffdad6;
  --vencido-fg:     #93000a;
  --perigo:         #ba1a1a;
  --perigo-bg:      #ffdad6;
  --sans:           'Inter', system-ui, sans-serif;
  --sans-display:   'Plus Jakarta Sans', system-ui, sans-serif;
  --mono:           'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--fundo-pagina);
  color: var(--texto);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }
h1, h2, h3 { color: var(--texto); margin: 0; }
p { margin: 0; }

/* ── Loading ── */
#a-carregar {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; color: var(--texto-suave); font-size: 14px;
}

/* ── Login ── */
#tela-login { display: none; align-items: center; justify-content: center; min-height: 100vh; }

.pagina-login { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; background: var(--fundo-pagina); }
.cartao-login {
  background: var(--cartao); border: 1px solid var(--borda-suave);
  border-radius: 12px; padding: 36px 32px; width: 380px;
  box-shadow: 0 4px 24px rgba(11,28,48,.06);
}
.cartao-login h1 {
  font-family: var(--sans-display); font-size: 20px; font-weight: 700;
  margin-bottom: 20px; letter-spacing: -.3px;
}
.cartao-login label {
  display: block; font-size: 11px; font-weight: 600; color: var(--texto-suave);
  text-transform: uppercase; letter-spacing: .05em; margin-top: 12px; margin-bottom: 4px;
}
.cartao-login input {
  display: block; width: 100%; padding: 9px 12px;
  font-size: 14px; border: 1px solid var(--borda); border-radius: 6px;
  background: var(--surface-low); color: var(--texto); transition: border-color .15s, box-shadow .15s;
}
.cartao-login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.cartao-login button {
  width: 100%; margin-top: 18px; padding: 11px;
  font-size: 14px; font-weight: 600; border: none; border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer; transition: background .15s;
}
.cartao-login button:hover { background: var(--accent-hover); }
.cartao-login button:disabled { opacity: .6; cursor: not-allowed; }
.erro-login { color: var(--perigo); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ── App shell ── */
#app { display: none; min-height: 100vh; }
.app-shell { min-height: 100vh; display: flex; }

/* ── Sidebar ── */
.sidebar {
  background: var(--cartao);
  border-right: 1px solid var(--borda-suave);
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  width: 72px; flex: none;
  padding: 16px 0;
  box-shadow: 1px 0 8px rgba(11,28,48,.03);
}

.sidebar-logo {
  background: var(--accent); color: #fff;
  border-radius: 10px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; font-family: var(--sans-display);
  flex-shrink: 0; text-decoration: none; letter-spacing: -.5px;
  box-shadow: 0 2px 8px rgba(70,72,212,.30);
  margin-bottom: 8px;
}

.sidebar-nav { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; }

.sidebar-icone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  width: 56px; min-height: 48px; border-radius: 10px;
  color: var(--texto-fraco); cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s; padding: 6px 0;
}
.sidebar-icone:hover { background: var(--surface-low); color: var(--texto-suave); }
.sidebar-icone.ativo {
  background: var(--accent-bg); color: var(--accent);
}
.sidebar-icone.ativo::before {
  content: '';
  position: absolute; left: -1px; top: 25%; bottom: 25%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sidebar-icone-inner {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 32px; border-radius: 8px;
}
.sidebar-icone svg { width: 18px; height: 18px; }
.sidebar-label {
  font-size: 9px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; line-height: 1; color: inherit;
}
.sidebar-icone-sair { margin-top: auto; }

/* ── Conteúdo ── */
.conteudo { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.cabecalho-pagina {
  background: var(--cartao);
  border-bottom: 1px solid var(--borda-suave);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  box-shadow: 0 1px 6px rgba(11,28,48,.04);
}
.cabecalho-pagina .titulo-grupo { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.cabecalho-pagina h1 { font-family: var(--sans-display); font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.resumo-mono { color: var(--texto-suave); font-size: 11.5px; font-family: var(--mono); }
.resumo-mono b { color: var(--texto); }
.resumo-mono .vencidas { color: var(--vencido-fg); }

.utilizador-info {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--texto-suave);
}
.avatar-utilizador {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; font-family: var(--sans-display);
  flex-shrink: 0; letter-spacing: -.3px;
}

.corpo-pagina {
  background: var(--fundo-pagina);
  flex: 1; padding: 20px 28px 40px;
  overflow-y: auto;
}

/* ── Pills ── */
.pills {
  display: flex; gap: 4px; padding: 3px;
  background: var(--surface); border-radius: 8px; width: fit-content;
}
.pill {
  cursor: pointer; border: none; background: none; border-radius: 6px;
  padding: 5px 12px; font-size: 11.5px; color: var(--texto-suave);
}
.pill.ativo { background: var(--cartao); color: var(--texto); font-weight: 600; box-shadow: 0 1px 3px rgba(11,28,48,.08); }

/* ── Botões ── */
.botao {
  cursor: pointer; border: none; border-radius: 7px;
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  background: var(--accent); color: #fff;
  transition: background .15s, box-shadow .15s, transform .1s;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 2px 6px rgba(70,72,212,.25);
}
.botao:hover { background: var(--accent-hover); box-shadow: 0 3px 10px rgba(70,72,212,.35); }
.botao:active { transform: translateY(1px); box-shadow: none; }
.botao.secundario {
  background: var(--surface-low); color: var(--accent);
  border: 1px solid var(--borda-suave); box-shadow: none;
}
.botao.secundario:hover { background: var(--surface); border-color: var(--accent); }
.botao.perigo { background: var(--perigo-bg); color: var(--perigo); box-shadow: none; }
.botao.perigo:hover { filter: brightness(.95); }
.botao.escuro { background: var(--texto); color: var(--fundo-pagina); box-shadow: 0 2px 6px rgba(11,28,48,.2); }
.botao.sm { padding: 6px 12px; font-size: 12px; }
.botao:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.botao-icone {
  cursor: pointer; background: none; border: none; border-radius: 6px;
  padding: 4px 6px; color: var(--texto-fraco); font-size: 14px;
  transition: background .12s, color .12s; display: inline-flex; align-items: center;
}
.botao-icone:hover { background: var(--surface-low); color: var(--accent); }

.fab {
  position: fixed; bottom: 18px; right: 18px;
  background: var(--accent); color: #fff; border: none; border-radius: 50%;
  width: 50px; height: 50px; font-size: 22px; cursor: pointer; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(70,72,212,.35);
}
.fab:hover { background: var(--accent-hover); }

/* ── Filtros / toolbar ── */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select {
  padding: 7px 10px; border: 1px solid var(--borda); border-radius: 6px;
  background: var(--cartao); color: var(--texto); font-size: 13px;
}
.sep { width: 1px; background: var(--borda-suave); align-self: stretch; margin: 0 4px; }

/* Filtros tick */
.filtro-tick { display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.filtro-tick input[type="checkbox"] { display: none; }
.filtro-tick .tick-badge {
  padding: 4px 10px; border-radius: 9999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  opacity: .35; transition: opacity .15s; border: 2px solid transparent;
}
.filtro-tick input:checked + .tick-badge { opacity: 1; border-color: currentColor; }

/* Barra seleção */
.barra-selecao {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 14px; background: var(--accent-bg); border: 1px solid var(--borda);
  border-radius: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 500; color: var(--accent);
}

/* ── Tabela ── */
.tabela-wrap {
  background: var(--cartao); border: 1px solid var(--borda-suave);
  border-radius: 10px; overflow: hidden;
}
.tabela-wrap table { width: 100%; border-collapse: collapse; }
.tabela-wrap thead { background: var(--surface-low); }
.tabela-wrap th {
  text-align: left; padding: 9px 12px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--texto-fraco);
  border-bottom: 1px solid var(--borda-suave); white-space: nowrap;
}
.tabela-wrap td { padding: 9px 12px; border-bottom: 1px solid var(--borda-suave); vertical-align: middle; }
.tabela-wrap tbody tr:last-child td { border-bottom: none; }
.tabela-wrap tbody tr:hover { background: var(--surface-low); }
.tabela-wrap thead th { position: sticky; top: 0; z-index: 1; }

/* Painel com scroll na tabela */
.painel-scroll {
  display: flex; flex-direction: column;
  height: calc(100vh - 73px);
  overflow: hidden; padding: 0;
}
.painel-scroll .corpo-scroll {
  flex: 1; overflow-y: auto; padding: 18px 28px 0;
  display: flex; flex-direction: column;
}
.painel-scroll .tabela-outer {
  flex: 1; overflow-y: auto; min-height: 0;
  background: var(--cartao); border: 1px solid var(--borda-suave); border-radius: 10px;
}
.painel-scroll .tabela-outer table { width: 100%; border-collapse: collapse; }
.painel-scroll .tabela-outer thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-low); padding: 9px 12px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--texto-fraco);
  border-bottom: 1px solid var(--borda-suave); white-space: nowrap; text-align: left;
}
.painel-scroll .tabela-outer td {
  padding: 9px 12px; border-bottom: 1px solid var(--borda-suave); vertical-align: middle;
}
.painel-scroll .tabela-outer tbody tr:last-child td { border-bottom: none; }
.painel-scroll .tabela-outer tbody tr:hover { background: var(--surface-low); }

.sem-dados { padding: 3rem; text-align: center; color: var(--texto-suave); }
.lixo-titulo { font-size: 13px; font-weight: 600; margin: 4px 0 10px; color: var(--texto-suave); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 9999px;
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.badge::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.badge-pago, .badge.pago       { background: #d1fae5; color: #065f46; }
.badge-por_pagar, .badge.pendente { background: #e0e7ff; color: #3730a3; }
.badge-vencido, .badge.vencido { background: #fee2e2; color: #991b1b; }
.badge-parcial { background: #e0f2fe; color: #075985; white-space: nowrap; }
.badge-parcial.parcial-vencido { background: #fee2e2; color: #991b1b; }
.falta-pagar { font-size: 11px; color: var(--texto-suave); margin-top: 2px; white-space: nowrap; }
.badge-por-preencher { background: #fef3c7; color: #92400e; }
.marca-recorrente { color: var(--texto-fraco); font-size: 12px; margin-left: 4px; cursor: help; }
.badge-portugal { background: #e1e0ff; color: #3730a3; }
.badge-italia   { background: #dae2fd; color: #3f465c; }
.badge-count {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.1rem; height: 1.1rem; background: var(--accent); color: #fff;
  border-radius: 9999px; font-size: 10px; font-weight: 700; margin-left: .2rem;
}
/* Filtros tick badges inline (não devem ter o dot) */
.tick-badge::before { display: none; }

/* Dados de pagamento */
.ref-dado { display: inline-flex; align-items: baseline; gap: .35rem; font-size: 12px; font-family: var(--mono); white-space: nowrap; }
.ref-dado + .ref-dado { margin-left: .6rem; }
.ref-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-fraco); font-family: var(--sans); min-width: 2.5rem; }

/* Montante */
.montante-pos { color: var(--pago-fg); font-weight: 600; font-family: var(--mono); }
.montante-neg { color: var(--perigo); font-weight: 600; font-family: var(--mono); }

/* Edição inline */
.td-descricao { cursor: text; }
.td-descricao:hover { background: var(--surface-low); }
.input-inline-descricao {
  width: 100%; padding: .25rem .4rem;
  border: 1px solid var(--accent); border-radius: 4px;
  font-size: 14px; outline: none; background: var(--cartao); color: var(--texto);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ── Calendário ── */
.calendario-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.calendario-nav button { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--texto-suave); }
.calendario-nav .mes { font-size: 16px; font-weight: 600; min-width: 140px; text-align: center; }

.grelha-calendario {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto; grid-auto-rows: minmax(110px, 1fr);
  flex: 1 0 auto; min-height: 560px;
  border-top: 1px solid var(--borda-suave); border-left: 1px solid var(--borda-suave);
}
.dia-semana {
  background: var(--surface-low); text-align: center; padding: 8px;
  font-size: 11px; color: var(--texto-fraco); font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  border-right: 1px solid var(--borda-suave); border-bottom: 1px solid var(--borda-suave);
}
.dia-mes {
  min-width: 0; padding: 8px 10px; font-size: 13px; cursor: pointer;
  display: flex; flex-direction: column; overflow: hidden;
  border-right: 1px solid var(--borda-suave); border-bottom: 1px solid var(--borda-suave);
  background: var(--cartao);
}
.dia-mes:hover, .dia-mes.selecionado { background: var(--surface-low); }
.dia-mes .cabecalho-dia { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.dia-mes .numero-dia { color: var(--texto-fraco); font-weight: 600; }
.dia-mes.hoje .numero-dia { color: var(--accent); }
.dia-mes .total-dia { color: var(--accent); font-family: var(--mono); font-size: 11.5px; }
.dia-mes .chip {
  border-radius: 4px; padding: 3px 6px; font-size: 12px; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dia-mes .chip.badge-pago       { background: var(--pago-bg); color: var(--pago-fg); }
.dia-mes .chip.badge-por_pagar  { background: var(--pendente-bg); color: var(--pendente-fg); }
.dia-mes .chip.badge-vencido    { background: var(--vencido-bg); color: var(--vencido-fg); }
.dia-mes .chip.badge-parcial    { background: #e0f2fe; color: #075985; }
.dia-mes .extra { color: var(--texto-fraco); font-size: 11px; margin-top: 3px; }
.dia-mes.vazio { background: var(--fundo-pagina); cursor: default; }

/* ── Modal ── */
.sobreposicao {
  position: fixed; inset: 0; background: rgba(11,28,48,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--cartao); border-radius: 12px;
  width: 460px; max-width: 100%; max-height: 90vh;
  padding: 26px 28px; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(11,28,48,.2);
}
.modal-lg { width: 600px; }
.modal-cabecalho { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-cabecalho h2 { font-family: var(--sans-display); font-size: 16px; font-weight: 700; }
.modal-fechar { background: none; border: none; cursor: pointer; color: var(--texto-fraco); font-size: 16px; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Form */
.grelha-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grelha-form .campo-largo { grid-column: 1 / -1; }
.grelha-form label, .form-label {
  display: block; color: var(--texto-fraco); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; margin: 10px 0 4px;
}
.grelha-form input, .grelha-form select,
.form-input {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--borda); border-radius: 6px;
  background: var(--surface-low); color: var(--texto); transition: border-color .15s;
}
.grelha-form input:focus, .grelha-form select:focus, .form-input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.grelha-form input[type="radio"], .grelha-form input[type="checkbox"] {
  width: auto; padding: 0; margin: 0; flex-shrink: 0; accent-color: var(--accent);
}
/* opções (rádio / caixa) dentro de um formulário: texto normal, não o estilo dos títulos dos campos */
.grelha-form .opcoes { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.grelha-form label.opcao {
  display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer;
  font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--texto);
}
.grelha-form label.opcao span { color: var(--texto-suave); }
.grelha-form .ajuda-campo { display: block; margin-top: 4px; font-size: 11px; color: var(--texto-suave); }
.form-erro { color: var(--perigo); font-size: 13px; margin-top: 8px; }

/* Faturas / Anexos */
.lista-faturas { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.fatura-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; background: var(--surface-low);
  border: 1px solid var(--borda-suave); border-radius: 8px;
}
.fatura-nome { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; text-decoration: none; color: var(--accent); }
.fatura-nome:hover { text-decoration: underline; }
.sem-faturas { padding: 1.5rem; text-align: center; color: var(--texto-suave); font-size: 13px; }
.upload-area { margin-top: 10px; }

/* Pagamentos com comprovativo (modal do pagamento): data · ficheiro · valor · ✕ */
.comp-item { gap: 10px; font-size: 13px; }
.comp-item .fatura-nome { flex: 1; min-width: 0; max-width: none; }
.comp-item .mono { white-space: nowrap; }
.comp-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; margin-top: 8px; padding: 2px 12px 12px;
  border: 1px solid var(--borda-suave); border-radius: 8px;
}
.comp-form .comp-largo { grid-column: 1 / -1; }
.comp-form .comp-botoes { display: flex; gap: 8px; margin-top: 12px; }

/* Definições */
.settings-secao { margin-bottom: 28px; }
.origens-ajuda { font-size: 12px; color: var(--texto-suave); margin-bottom: 12px; line-height: 1.5; }
.origem-nova { display: flex; gap: 8px; margin-top: 12px; max-width: 420px; }
.origem-nova .form-input { flex: 1; min-width: 0; }
.origem-nova .botao { white-space: nowrap; }
.origem-inativa .origem-nome { color: var(--texto-suave); }
.origem-nome .form-input { max-width: 260px; }
/* interruptor (ligado / desligado) */
.interruptor { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.interruptor input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.interruptor span { position: absolute; inset: 0; border-radius: 20px; background: var(--borda); transition: background .15s; }
.interruptor span::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.interruptor input:checked + span { background: var(--accent); }
.interruptor input:checked + span::after { transform: translateX(16px); }
.interruptor input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-bg); }
.settings-secao h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-fraco); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--borda-suave); }

/* PDF */
.pdf-card { background: var(--cartao); border: 1px solid var(--borda-suave); border-radius: 10px; padding: 20px; margin-bottom: 14px; }
.pdf-card-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; font-family: var(--sans-display); }
.pdf-card-desc { font-size: 12px; color: var(--texto-suave); margin-bottom: 16px; }

.drop-zone {
  border: 2px dashed var(--borda); border-radius: 8px;
  padding: 2rem 1rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; user-select: none;
}
.drop-zone:hover, .drop-zone.drop-over { border-color: var(--accent); background: var(--surface-low); }
.drop-zone-inner { display: flex; flex-direction: column; align-items: center; gap: .5rem; font-size: 13px; color: var(--texto-suave); }
.drop-icon { font-size: 2rem; }

.pdf-file-info { margin-top: .75rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pdf-file-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--accent-bg); border: 1px solid var(--borda); color: var(--accent);
  border-radius: 6px; padding: .25rem .6rem; font-size: 12px; font-weight: 500;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pdf-pages-badge {
  display: inline-flex; align-items: center;
  background: var(--surface-low); border: 1px solid var(--borda-suave);
  color: var(--texto-suave); border-radius: 6px; padding: .25rem .6rem; font-size: 12px;
}

.split-opts { margin-top: 1rem; }
.radio-group { border: none; padding: 0; margin: 0; }
.radio-group legend { font-size: 10px; font-weight: 600; color: var(--texto-fraco); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.radio-group label { display: flex; align-items: center; gap: .5rem; font-size: 13px; margin-bottom: .4rem; cursor: pointer; }

.pdf-hint { font-size: 12px; color: var(--texto-suave); margin-top: .4rem; }
.pdf-hint code { background: var(--surface-low); padding: .1rem .3rem; border-radius: 4px; font-size: 11px; font-family: var(--mono); }

.merge-list { margin-top: 1rem; display: flex; flex-direction: column; gap: .4rem; min-height: 40px; }
.merge-vazio { font-size: 13px; color: var(--texto-suave); text-align: center; padding: 1rem 0; }
.merge-item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--surface-low); border: 1px solid var(--borda-suave);
  border-radius: 8px; padding: .5rem .75rem; cursor: grab;
}
.merge-item.dragging { opacity: .5; }
.merge-handle { font-size: 16px; color: var(--texto-fraco); cursor: grab; }
.merge-remove { margin-left: auto; padding: .15rem .45rem; line-height: 1; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--texto); color: var(--fundo-pagina);
  padding: 10px 16px; border-radius: 8px; font-size: 13px;
  z-index: 200; box-shadow: 0 8px 24px rgba(11,28,48,.2);
  animation: fadeIn .2s ease;
}
.toast.erro-toast { background: var(--perigo); color: #fff; }
.toast-desfazer { display: flex; align-items: center; gap: 14px; }
.toast-acao {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: var(--accent-bg); font: inherit; font-weight: 600; text-decoration: underline;
}
.toast-acao:hover { opacity: .85; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.hidden { display: none !important; }
.modo-leitura .so-editor { display: none !important; }
.text-muted { color: var(--texto-suave); }
.mono { font-family: var(--mono); }

/* ── Tabela admin ── */
.tabela-simples { border-collapse: collapse; width: 100%; font-size: 13px; }
.tabela-simples th, .tabela-simples td { border-bottom: 1px solid var(--borda-suave); text-align: left; padding: 10px 8px; }
.tabela-simples th { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-fraco); }
.badge.role-admin  { color: #6048a0; background: #f3e8ff; }
.badge.role-editor { color: #2c5fa8; background: #dce9ff; }
.badge.role-leitor { background: var(--surface); color: var(--texto-suave); }

/* ── Responsivo ── */
/* ── Telemóvel (≤ 760 px): barra no topo com ☰, menu deslizante, tabelas em cartões,
      modais em ecrã inteiro. O ☰ e os rótulos dos cartões estão no auth.js. ── */
.barra-movel, .menu-fundo { display: none; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }

  /* barra no topo */
  .barra-movel {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 40; height: 52px; padding: 0 8px;
    background: var(--cartao); border-bottom: 1px solid var(--borda-suave);
    box-shadow: 0 1px 6px rgba(11,28,48,.06);
  }
  .menu-movel {
    width: 44px; height: 44px; border: none; border-radius: 10px; background: none;
    color: var(--texto); display: flex; align-items: center; justify-content: center; cursor: pointer;
  }
  .menu-movel svg { width: 22px; height: 22px; }
  .barra-movel-titulo { font-family: var(--sans-display); font-weight: 700; font-size: 16px; }

  /* barra lateral → menu deslizante */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
    width: 250px; max-width: 85vw; padding: 16px 12px; gap: 4px;
    align-items: stretch; overflow-y: auto;
    transform: translateX(-105%); transition: transform .2s ease;
  }
  body.menu-aberto .sidebar { transform: none; box-shadow: 4px 0 24px rgba(11,28,48,.18); }
  body.menu-aberto .menu-fundo { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(11,28,48,.35); }
  .sidebar-logo { margin: 0 4px 12px; }
  .sidebar-nav { align-items: stretch; }
  .sidebar-icone {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    width: 100%; min-height: 48px; padding: 6px 10px;
  }
  .sidebar-icone.ativo::before { left: 0; }
  .sidebar-label { font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0; }
  .sidebar-icone-sair { margin-top: auto; }

  /* a página toda faz scroll (no computador é cada painel) */
  .conteudo > div { height: auto !important; }
  .cabecalho-pagina { padding: 12px 14px; }
  .cabecalho-pagina h1 { font-size: 17px; }
  .corpo-pagina { padding: 12px 12px 40px; overflow: visible !important; }
  .utilizador-info { display: none; }
  .painel-scroll { height: auto; }
  .painel-scroll .corpo-scroll { overflow: visible; }

  /* toque: 16 px evita o zoom automático ao escrever; alvos maiores */
  input, select, textarea { font-size: 16px !important; }
  .botao { min-height: 40px; }
  .botao-icone { min-width: 40px; min-height: 40px; }
  .toolbar > * { flex: 1 1 140px; }
  .toolbar .sep { display: none; }
  .barra-selecao { flex-wrap: wrap; }

  /* tabelas → cartões: cada célula com o nome da coluna (data-label) */
  .tabela-wrap { background: none; border: none; border-radius: 0; overflow: visible; }
  .tabela-wrap table, .tabela-wrap tbody, .tabela-wrap tr, .tabela-wrap td { display: block; width: 100%; }
  .tabela-wrap thead { display: none; }
  .tabela-wrap tr {
    background: var(--cartao); border: 1px solid var(--borda-suave); border-radius: 10px;
    padding: 6px 12px; margin-bottom: 10px;
  }
  .tabela-wrap tbody tr:hover { background: var(--cartao); }
  .tabela-wrap td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 5px 0; min-height: 32px; border: none; text-align: right; max-width: none !important;
    white-space: normal !important;
  }
  .tabela-wrap td::before {
    content: attr(data-label); flex-shrink: 0; text-align: left; color: var(--texto-fraco);
    font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  }
  .tabela-wrap td[data-label=""]::before, .tabela-wrap td:not([data-label])::before { content: none; }
  .tabela-wrap td[data-label=""] { justify-content: flex-end; }
  .tabela-wrap td[colspan] { justify-content: center; }

  /* textos longos (IBAN, referências) partem dentro do cartão */
  .tabela-wrap tr { position: relative; }
  .tabela-wrap td { flex-wrap: wrap; overflow-wrap: anywhere; }
  .tabela-wrap td::before { margin-right: auto; }
  /* caixa de seleção no canto do cartão, sem ocupar uma linha */
  .tabela-wrap td:first-child:has(> input[type="checkbox"]) {
    position: absolute; top: 4px; right: 6px; width: auto; min-height: 0;
  }
  .tabela-wrap td:first-child:has(> input[type="checkbox"]) + td { padding-right: 40px; }
  /* tabelas sem <thead>: a linha dos títulos não aparece (os títulos vão para cada célula) */
  .tabela-wrap tr:has(> th) { display: none; }

  /* modais em ecrã inteiro, campos numa coluna */
  .sobreposicao { padding: 0; align-items: stretch; }
  .modal, .modal-lg { width: 100%; max-width: 100%; height: 100%; max-height: none; border-radius: 0; padding: 16px 16px 28px; }
  .grelha-form { grid-template-columns: 1fr; }

  .toast { left: 12px; right: 12px; bottom: 12px; }
}

/* Bancário: liquidar pagamentos com um movimento */
.liq-movimento { background: var(--surface-low); border-radius: 8px; padding: 12px 14px; font-size: 13px; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; }
.liq-movimento .liq-num { text-align: right; font-family: var(--mono); }
.liq-titulo { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-fraco); margin: 18px 0 6px; }
.liq-candidatos { max-height: 320px; overflow-y: auto; margin-top: 8px; border: 1px solid var(--borda-suave); border-radius: 8px; }
.liq-cand { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--borda-suave); font-size: 13px; }
.liq-cand:last-child { border-bottom: none; }
.liq-cand.desativado { opacity: .5; }
.liq-cand .liq-sub { font-size: 11px; color: var(--texto-suave); }
.liq-cand input { width: 100px; padding: 6px 8px; font-size: 13px; border: 1px solid var(--borda); border-radius: 6px; background: var(--surface-low); text-align: right; }
.liq-cand.exato { background: var(--pago-bg); }
.ban-liq { font-size: 12px; white-space: nowrap; }
.ban-liq.completo { color: var(--pago-fg); }
.ban-liq.parte { color: #92400e; }

/* Telemóvel: no calendário de pagamentos cada dia mostra só o número e o total; tocar no dia mostra
   os pagamentos por baixo. No modal "Liquidar", cada candidato ocupa duas linhas. */
@media (max-width: 760px) {
  .grelha-calendario { gap: 0; }
  .dia-mes { min-height: 58px; padding: 4px 3px; }
  .dia-mes .cabecalho-dia { flex-direction: column; align-items: flex-start; gap: 0; }
  .dia-mes .total-dia { font-size: 9.5px; }
  .dia-mes .chip, .dia-mes .extra { display: none; }
  .liq-cand { grid-template-columns: 1fr auto; }
  .liq-cand > div:first-child { grid-column: 1 / -1; }
  .liq-cand input { width: 100%; }
  .liq-movimento { grid-template-columns: 1fr; }
  .liq-movimento .liq-num { text-align: left; }
  /* registar um pagamento com comprovativo: campos numa coluna; cada comprovativo pode partir em duas linhas */
  .comp-form { grid-template-columns: 1fr; }
  .comp-item { flex-wrap: wrap; gap: 4px 10px; }
  .comp-item .fatura-nome { flex-basis: 100%; order: 3; }
  .comp-item .mono { margin-left: auto; }
  /* Config. → Origens */
  .origem-nova { max-width: none; flex-wrap: wrap; }
  .origem-nome .form-input { max-width: none; }
}
