:root {
  --bg: #F5F7F4; --surface: #fff; --ink: #121714; --muted: #4f5b55; --line: #d8dfda;
  --green: #2E8B3C; --pine: #102519; --mint: #bfd9c4; --grass: #7ccb8a; --red: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 Archivo, system-ui, sans-serif; }
a { color: var(--green); }
h1, h2 { margin: 0 0 .75rem; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 3rem; }

/* barra superior */
.topbar { background: var(--pine); color: var(--mint); display: flex; flex-wrap: wrap; align-items: center;
  gap: .75rem 1.25rem; padding: .85rem 16px; }
.brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.topbar .links { margin-left: auto; display: flex; gap: 1rem; }
.topbar .links a { color: var(--mint); text-decoration: none; }
.monthnav { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.monthnav a { color: var(--grass); text-decoration: none; font-size: 1.4rem; line-height: 1;
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9999px; }
.monthnav a:hover { background: rgba(255,255,255,.08); }

/* cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 1.25rem; margin-bottom: 1rem; }
.narrow { max-width: 520px; margin: 2rem auto; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stat { margin: 0; display: flex; flex-direction: column; gap: .25rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.5rem; }
.pos { color: var(--green); } .neg { color: var(--red); }
.flash { background: var(--mint); color: var(--pine); padding: .75rem 1rem; border-radius: 16px; }

/* formulários */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: .6rem .8rem; min-height: 44px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--grass); outline-offset: 1px; border-color: var(--green); }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid .wide { grid-column: 1 / -1; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 1.4rem;
  border-radius: 9999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green);
  box-shadow: 0 8px 24px rgba(46,139,60,.35); }
.btn.primary:hover { background: #27793a; }
.btn.small { min-height: 36px; padding: 0 .9rem; font-size: .85rem; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }

/* dicas de autocomplete e sugestão de stake */
.ac { position: relative; }
.ac ul { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: .25rem 0 0; padding: .3rem;
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 32px rgba(16,37,25,.12); max-height: 260px; overflow: auto; }
.ac li { padding: .5rem .7rem; border-radius: 10px; cursor: pointer; color: var(--ink); }
.ac li:hover { background: var(--bg); }
.ac li small { display: block; color: var(--muted); }
#hints:empty { display: none; }
#hints, .sugestao { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; }

/* tabela: cartões empilhados em ecrãs pequenos */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 500; padding: .4rem .3rem; }
td { padding: .3rem; border-top: 1px solid var(--line); vertical-align: middle; }
td input, td select { min-height: 40px; padding: .4rem .6rem; }
.actions { display: flex; gap: .4rem; }
.actions form { display: inline; }
tr.res-green td:first-child { box-shadow: inset 4px 0 var(--green); }
tr.res-red td:first-child { box-shadow: inset 4px 0 var(--red); }
tr.res-void td:first-child { box-shadow: inset 4px 0 var(--line); }

@media (max-width: 640px) {
  thead { display: none; }
  table, tbody, tr, td { display: block; }
  tr { border: 1px solid var(--line); border-radius: 16px; padding: .5rem; margin-bottom: .75rem; }
  td { border: 0; display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: .5rem; }
  td::before { content: attr(data-l); font-size: .8rem; color: var(--muted); }
  td.actions { display: flex; justify-content: flex-end; }
  tr.res-green td:first-child, tr.res-red td:first-child, tr.res-void td:first-child { box-shadow: none; }
  tr.res-green { border-color: var(--grass); }
  tr.res-red { border-color: var(--red); }
}
@media (min-width: 720px) {
  .cards { grid-template-columns: repeat(4, 1fr); }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .grid .wide { grid-column: span 2; }
  .grid button.wide, .grid #hints { grid-column: 1 / -1; }
}

/* Caixa de verificação ao tamanho normal; título "Serviços" com respiro */
.check input { width: 1.25rem; height: 1.25rem; min-height: 0; padding: 0; }
.card h2 + h2, .card .btn + h2 { margin-top: 1.5rem; }
