:root {
  --creme: #faf7f1;
  --branco: #ffffff;
  --verde: #4a5d43;
  --verde-escuro: #37452f;
  --terracota: #b0713f;
  --texto: #2f2b26;
  --texto-suave: #7d766c;
  --linha: #e6dfd3;
  --erro: #a33c2e;
  --ok: #3d7a4a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--creme);
  color: var(--texto);
  min-height: 100vh;
}
h1, h2, h3, .serif { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #f4efe6 0%, #faf7f1 60%);
}
.login-card {
  background: var(--branco); border: 1px solid var(--linha); border-radius: 14px;
  padding: 48px 40px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(60,50,30,.08);
}
.login-card .monograma {
  width: 64px; height: 64px; border-radius: 50%; background: var(--verde); color: #fff;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 18px;
  font-family: Georgia, serif; font-size: 26px;
}
.login-card h1 { font-size: 26px; margin-bottom: 4px; color: var(--verde-escuro); }
.login-card .sub { color: var(--texto-suave); font-size: 14px; margin-bottom: 28px; }
.login-card input {
  width: 100%; padding: 13px 16px; font-size: 17px; text-align: center; letter-spacing: 2px;
  border: 1.5px solid var(--linha); border-radius: 9px; margin-bottom: 14px; background: #fdfcf9;
}
.login-card input:focus { outline: none; border-color: var(--verde); }
.login-card .dica { font-size: 12.5px; color: var(--texto-suave); margin-top: 18px; line-height: 1.5; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--verde); color: #fff; border: none; border-radius: 9px;
  padding: 11px 20px; font-size: 14.5px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--verde-escuro); }
.btn.sec { background: transparent; color: var(--verde); border: 1.5px solid var(--verde); }
.btn.sec:hover { background: #eef0ea; }
.btn.peq { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.btn.perigo { background: transparent; color: var(--erro); border: 1px solid #e6c4bd; }
.btn.perigo:hover { background: #faeeec; }
.btn.cheio { width: 100%; }

/* ---------- Estrutura ---------- */
header.topo {
  background: var(--verde-escuro); color: #fff; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
header.topo .marca { font-family: Georgia, serif; font-size: 19px; letter-spacing: .5px; }
header.topo .marca span { opacity: .65; font-size: 13px; margin-left: 10px; letter-spacing: 1.5px; text-transform: uppercase; }
header.topo .acoes { display: flex; gap: 10px; align-items: center; }
header.topo .btn { background: rgba(255,255,255,.14); }
header.topo .btn:hover { background: rgba(255,255,255,.25); }
main { max-width: 1080px; margin: 0 auto; padding: 28px 20px 80px; }

/* ---------- Lista de eventos ---------- */
.lista-cabeca { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.lista-cabeca h1 { font-size: 26px; color: var(--verde-escuro); }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.filtros input, .filtros select {
  padding: 9px 12px; border: 1.5px solid var(--linha); border-radius: 8px; font-size: 14px; background: #fff;
}
.evento-card {
  background: var(--branco); border: 1px solid var(--linha); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 12px; display: flex; align-items: center; gap: 18px;
  cursor: pointer; transition: box-shadow .15s;
}
.evento-card:hover { box-shadow: 0 6px 24px rgba(60,50,30,.09); }
.evento-card .data-bloco {
  min-width: 66px; text-align: center; background: #f1ede3; border-radius: 10px; padding: 9px 6px;
}
.evento-card .data-bloco .dia { font-size: 22px; font-family: Georgia, serif; color: var(--verde-escuro); line-height: 1; }
.evento-card .data-bloco .mes { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--texto-suave); margin-top: 3px; }
.evento-card .info { flex: 1; min-width: 0; }
.evento-card .info .nomes { font-family: Georgia, serif; font-size: 17.5px; color: var(--texto); }
.evento-card .info .detalhe { font-size: 13px; color: var(--texto-suave); margin-top: 3px; }
.evento-card .meta { text-align: right; font-size: 13px; color: var(--texto-suave); }

.badge {
  display: inline-block; font-size: 11.5px; padding: 3px 10px; border-radius: 20px;
  font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
}
.badge.casamento { background: #ede7f3; color: #6a4d8f; }
.badge.batizado { background: #e3eef7; color: #3a6b96; }
.badge.almoco { background: #f5ead9; color: #9c6a2c; }
.badge.jantar { background: #e8e4da; color: #5d5850; }
.badge.ativo { background: #e5efe2; color: var(--ok); }
.badge.concluido { background: #e8e4da; color: #6b665e; }
.badge.cancelado { background: #f7e3df; color: var(--erro); }

/* ---------- Ficha ---------- */
.ficha-cabeca { margin-bottom: 6px; }
.ficha-cabeca .voltar { color: var(--verde); font-size: 14px; text-decoration: none; cursor: pointer; }
.ficha-cabeca h1 { font-size: 28px; color: var(--verde-escuro); margin-top: 8px; }
.ficha-cabeca .sub { color: var(--texto-suave); font-size: 14.5px; margin-top: 5px; }
.ficha-cabeca .codigo {
  font-family: monospace; background: #f1ede3; padding: 2px 9px; border-radius: 6px; color: var(--verde-escuro);
}
.tabs { display: flex; gap: 2px; margin: 24px 0 0; border-bottom: 2px solid var(--linha); flex-wrap: wrap; }
.tab {
  padding: 10px 15px; font-size: 14px; color: var(--texto-suave); cursor: pointer;
  border: none; background: none; border-bottom: 2.5px solid transparent; margin-bottom: -2px;
  display: flex; gap: 6px; align-items: center; font-weight: 600;
}
.tab.ativa { color: var(--verde-escuro); border-bottom-color: var(--verde); }
.tab .ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--terracota); }
.painel { background: var(--branco); border: 1px solid var(--linha); border-top: none; border-radius: 0 0 12px 12px; padding: 26px; }

.seccao-titulo {
  font-family: Georgia, serif; font-size: 17px; color: var(--verde-escuro);
  margin: 26px 0 14px; padding-bottom: 7px; border-bottom: 1px solid var(--linha);
}
.seccao-titulo:first-child { margin-top: 0; }
.grelha { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 18px; }
.campo label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--texto-suave); margin-bottom: 5px; }
.campo input, .campo select, .campo textarea {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--linha); border-radius: 8px;
  font-size: 14.5px; background: #fdfcf9; font-family: inherit;
}
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--verde); }
.campo.largo { grid-column: 1 / -1; }
.campo .valor { font-size: 15px; padding: 4px 0; min-height: 24px; white-space: pre-wrap; }
.campo .valor.vazio { color: #c0b9ac; font-style: italic; }
textarea { resize: vertical; min-height: 74px; }

.barra-guardar { margin-top: 26px; display: flex; gap: 10px; align-items: center; }
.msg-guardado { color: var(--ok); font-size: 14px; }

.nota-regra {
  background: #f6f2e8; border-left: 3px solid var(--terracota); border-radius: 0 8px 8px 0;
  padding: 12px 16px; font-size: 13.5px; color: #6b6252; margin: 16px 0; line-height: 1.55;
}

/* ---------- Linhas editáveis (timeline, staff, pagamentos) ---------- */
.linha-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid #f0ebe1; flex-wrap: wrap;
}
.linha-item input, .linha-item select, .linha-item textarea {
  padding: 8px 10px; border: 1.5px solid var(--linha); border-radius: 7px; font-size: 14px; background: #fdfcf9; font-family: inherit;
}
.linha-item .crescer { flex: 1; min-width: 140px; }
.check-inline { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--texto-suave); white-space: nowrap; padding-top: 9px; }

/* Timeline (vista noivos) */
.tl-lista { position: relative; margin-left: 8px; padding-left: 24px; border-left: 2px solid var(--linha); }
.tl-item { position: relative; padding: 0 0 22px; }
.tl-item::before {
  content: ''; position: absolute; left: -30px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--terracota); border: 2px solid var(--creme);
}
.tl-item .hora { font-family: Georgia, serif; font-size: 15px; color: var(--terracota); }
.tl-item .titulo { font-size: 15.5px; font-weight: 600; margin-top: 2px; }
.tl-item .notas { font-size: 13.5px; color: var(--texto-suave); margin-top: 2px; }

/* ---------- Mesas ---------- */
.mesas-grelha { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.mesa-card { background: #fdfcf8; border: 1px solid var(--linha); border-radius: 12px; padding: 16px; }
.mesa-card .mesa-topo { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.mesa-card .mesa-nome { font-family: Georgia, serif; font-size: 16.5px; color: var(--verde-escuro); }
.mesa-card .lotacao { font-size: 12.5px; color: var(--texto-suave); white-space: nowrap; }
.mesa-card .lotacao.excesso { color: var(--erro); font-weight: 700; }
.mesa-card ol { margin: 6px 0 0 20px; font-size: 14px; line-height: 1.7; }
.mesa-card textarea { width: 100%; margin-top: 8px; font-size: 13.5px; min-height: 110px; }
.mesa-card input { width: 100%; }

/* ---------- Cartões financeiro ---------- */
.fin-grelha { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.fin-card { background: #f6f2e8; border-radius: 10px; padding: 16px; text-align: center; }
.fin-card .rotulo { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--texto-suave); margin-bottom: 6px; }
.fin-card .montante { font-family: Georgia, serif; font-size: 21px; color: var(--verde-escuro); }
.fin-card.destaque { background: var(--verde); }
.fin-card.destaque .rotulo { color: #cdd8c8; }
.fin-card.destaque .montante { color: #fff; }

/* ---------- Notificações ---------- */
.notif { background: #fdfcf8; border: 1px solid var(--linha); border-radius: 10px; padding: 15px 18px; margin-bottom: 11px; }
.notif.nova { border-left: 4px solid var(--terracota); }
.notif .n-topo { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.notif .n-titulo { font-weight: 700; font-size: 15px; }
.notif .n-data { font-size: 12px; color: var(--texto-suave); white-space: nowrap; }
.notif .n-msg { font-size: 14px; margin-top: 6px; color: #4d473f; line-height: 1.55; white-space: pre-wrap; }
.notif .n-estado { font-size: 12px; margin-top: 8px; color: var(--texto-suave); }

/* ---------- Ficheiros ---------- */
.fich-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid #f0ebe1; font-size: 14px; }
.fich-item .cat { font-size: 11.5px; background: #f1ede3; color: var(--texto-suave); padding: 3px 9px; border-radius: 12px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.fich-item a { color: var(--verde); font-weight: 600; text-decoration: none; }
.fich-item a:hover { text-decoration: underline; }
.fich-item .crescer { flex: 1; }

.contacto-card { background: #f6f2e8; border-radius: 10px; padding: 18px; margin-top: 22px; font-size: 14.5px; line-height: 1.8; }
.contacto-card a { color: var(--verde); font-weight: 600; }

/* ---------- Galeria de fotografias ---------- */
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.foto { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--linha); background: #f1ede3; aspect-ratio: 1; }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto .apagar-foto {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 13px; line-height: 1;
}
.foto .apagar-foto:hover { background: var(--erro); }
label.btn input[type=file] { display: none; }

/* ---------- Calendário ---------- */
.cal-topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-titulo { font-family: Georgia, serif; font-size: 20px; color: var(--verde-escuro); }
.cal-grelha { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cabecalho { margin-bottom: 6px; }
.cal-cabecalho div {
  text-align: center; font-size: 11.5px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--texto-suave); padding: 4px 0;
}
.cal-dia {
  background: var(--branco); border: 1px solid var(--linha); border-radius: 10px;
  min-height: 86px; padding: 6px; font-size: 12px;
}
.cal-dia.vazio { background: transparent; border: none; }
.cal-dia.hoje { border-color: var(--terracota); box-shadow: 0 0 0 1px var(--terracota); }
.cal-num { font-size: 12px; color: var(--texto-suave); margin-bottom: 4px; }
.cal-dia.hoje .cal-num { color: var(--terracota); font-weight: 700; }
.cal-evento {
  border-radius: 6px; padding: 3px 6px; margin-bottom: 3px; cursor: pointer;
  font-size: 11.5px; line-height: 1.3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: #ede7f3; color: #6a4d8f;
}
.cal-evento:hover { filter: brightness(.93); }
.cal-evento.batizado { background: #e3eef7; color: #3a6b96; }
.cal-evento.almoco { background: #f5ead9; color: #9c6a2c; }
.cal-evento.jantar { background: #e8e4da; color: #5d5850; }

.vazio-msg { color: var(--texto-suave); font-style: italic; font-size: 14px; padding: 10px 0; }
.erro-msg { color: var(--erro); font-size: 14px; margin-top: 8px; }

@media (max-width: 640px) {
  .painel { padding: 18px 14px; }
  .evento-card { flex-wrap: wrap; }
  .evento-card .meta { text-align: left; }
}

/* ================================================================
   Refinamentos de UI (revisão de design)
   ================================================================ */

/* Transições suaves em todos os elementos interativos */
.btn, .tab, .evento-card, .cal-evento, .cal-dia, .foto img,
.campo input, .campo select, .campo textarea,
.linha-item input, .linha-item select, .linha-item textarea,
.filtros input, .filtros select, .login-card input, .fich-item {
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease,
              transform .15s ease, color .15s ease;
}

/* Cabeçalho fixo com sombra subtil */
header.topo {
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 12px rgba(40, 48, 35, .18);
}

/* Botões: relevo ligeiro e estado de pressão */
.btn { box-shadow: 0 1px 2px rgba(60, 50, 30, .08); }
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(60, 50, 30, .14); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(60, 50, 30, .1); }
.btn.peq:hover { transform: none; }

/* Foco visível e consistente em formulários */
.campo input:focus, .campo select:focus, .campo textarea:focus,
.linha-item input:focus, .linha-item select:focus, .linha-item textarea:focus,
.filtros input:focus, .filtros select:focus,
.mesa-card input:focus, .mesa-card textarea:focus, .login-card input:focus {
  outline: none; border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(74, 93, 67, .14);
}
.btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--verde); outline-offset: 2px;
}

/* Separadores: uma só linha com deslize horizontal (útil no telemóvel) */
.tabs {
  flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { white-space: nowrap; flex: 0 0 auto; }
.tab:hover { color: var(--verde-escuro); background: rgba(74, 93, 67, .05); border-radius: 8px 8px 0 0; }

/* Cartões de evento: elevação no hover */
.evento-card:hover { transform: translateY(-1px); border-color: #d8d0bf; }

/* Lista de ficheiros: hover suave */
.fich-item:hover { background: #faf7f0; }

/* Galeria: aproximação subtil da fotografia */
.foto:hover img { transform: scale(1.04); }

/* Calendário: hover nos dias e nos eventos */
.cal-dia:not(.vazio):hover { border-color: #d8d0bf; }
.cal-evento { box-shadow: 0 1px 2px rgba(60, 50, 30, .06); }
.cal-evento:hover { transform: translateY(-1px); filter: none; box-shadow: 0 2px 6px rgba(60, 50, 30, .15); }

/* Login: botão principal com relevo e monograma com anel */
.login-card .monograma { box-shadow: 0 0 0 5px rgba(74, 93, 67, .12); }

/* Notas de regra: tipografia mais respirada */
.nota-regra { line-height: 1.6; }

/* Textareas um pouco mais confortáveis */
textarea { line-height: 1.55; }

/* Ecrãs pequenos */
@media (max-width: 640px) {
  main { padding: 20px 12px 64px; }
  .ficha-cabeca h1 { font-size: 23px; }
  .lista-cabeca h1 { font-size: 22px; }
  .tab { padding: 10px 12px; font-size: 13.5px; }
  .cal-dia { min-height: 62px; padding: 4px; }
  .cal-evento { font-size: 10.5px; padding: 2px 4px; }
  .cal-titulo { font-size: 16px; }
  .fin-grelha { grid-template-columns: repeat(2, 1fr); }
  header.topo .marca span { display: none; }
  .linha-item input, .linha-item select { min-width: 0; }
  .galeria { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* ================================================================
   Logotipo + correções para telemóvel
   ================================================================ */

/* Logotipo no cabeçalho (linha-arte a branco sobre o verde) */
header.topo .marca { display: flex; align-items: center; gap: 14px; min-width: 0; }
header.topo .logo { height: 46px; width: auto; display: block; filter: brightness(0) invert(1); opacity: .95; }

/* Logotipo no ecrã de entrada */
.login-card .logo-login { width: 230px; max-width: 78%; margin: 0 auto 10px; display: block; }

/* Campos de data e hora: aparência consistente no iPhone/Android */
.campo input[type="date"], .campo input[type="time"],
.linha-item input[type="date"], .linha-item input[type="time"] {
  -webkit-appearance: none; appearance: none;
  min-height: 41px; min-width: 0;
}

/* Botões Guardar/✕ das linhas editáveis ficam sempre lado a lado */
.linha-acoes { display: flex; gap: 8px; align-items: center; }

@media (max-width: 640px) {
  header.topo { padding: 10px 14px; }
  header.topo .logo { height: 36px; }
  header.topo .marca span { display: inline; font-size: 10.5px; margin-left: 0; }

  /* Barra de separadores → "pílulas" que quebram linha (nada fica escondido) */
  .tabs {
    flex-wrap: wrap; overflow: visible; border-bottom: none;
    gap: 6px; margin: 18px 0 10px;
  }
  .tab {
    border: 1.5px solid var(--linha); border-radius: 20px; background: var(--branco);
    padding: 7px 13px; margin-bottom: 0; font-size: 13px;
  }
  .tab:hover { border-radius: 20px; background: var(--branco); }
  .tab.ativa {
    background: var(--verde); border-color: var(--verde); color: #fff;
    border-bottom-color: var(--verde);
  }
  .tab .ponto { background: #ffb08a; }
  .painel { border-top: 1px solid var(--linha); border-radius: 12px; padding: 18px 14px; }

  /* Cartões de eventos: informação principal em cima, números em baixo */
  .evento-card { flex-wrap: wrap; gap: 12px; padding: 14px; }
  .evento-card .data-bloco { min-width: 58px; padding: 7px 4px; }
  .evento-card .info { flex: 1; min-width: 0; }
  .evento-card .info .nomes { font-size: 16px; }
  .evento-card .meta {
    width: 100%; text-align: left; border-top: 1px dashed var(--linha);
    padding-top: 8px; margin-top: 2px;
  }

  /* Linhas editáveis (staff, menus especiais, timeline, pagamentos): empilham */
  .linha-item { flex-direction: column; align-items: stretch; gap: 8px; }
  .linha-item input, .linha-item select, .linha-item textarea { width: 100% !important; }
  .linha-item input[type="checkbox"] { width: auto !important; }
  .linha-item .check-inline { padding-top: 0; justify-content: flex-start; }
  .linha-acoes { justify-content: flex-end; }

  /* Grelhas de formulário a uma coluna cheia */
  .grelha { grid-template-columns: 1fr; }

  /* Cabeçalho da lista: botões em linha própria */
  .lista-cabeca { flex-direction: column; align-items: stretch; }
  .lista-cabeca > div { display: flex; flex-wrap: wrap; gap: 8px; }
  .lista-cabeca .btn { flex: 1; }
  .filtros input, .filtros select { flex: 1; min-width: 120px; }
}

/* ================================================================
   Menu centrado + histórico de alterações
   ================================================================ */

/* Separadores centrados (desktop e telemóvel) */
.tabs { justify-content: center; }

/* Histórico de alterações */
.log-item { padding: 12px 4px; border-bottom: 1px solid #f0ebe1; }
.log-item:last-child { border-bottom: none; }
.log-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.log-data { font-size: 12.5px; color: var(--texto-suave); }
.log-acao { font-size: 14.5px; font-weight: 600; }
.log-detalhe { font-size: 13px; color: var(--texto-suave); margin-top: 3px; line-height: 1.5; word-break: break-word; }
