/* Mobile-first (360px primeiro). Sem framework, sem animações. */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1d2420;
  --muted: #5d6860;
  --line: #d9ddd5;
  --brand: #2f6b3a;
  --brand-dark: #234f2b;
  --brand-soft: #e4efe3;
  --warn: #8a5a00;
  --warn-soft: #fff2d6;
  --danger: #a12622;
  --danger-soft: #fde7e6;
  --info: #1f4f7a;
  --info-soft: #e3eef8;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--brand-dark); }
h1 { font-size: 1.4rem; margin: 0.4rem 0 0.8rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 0.6rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }
p { margin: 0.4rem 0 0.8rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.right { text-align: right; }
.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
[x-cloak] { display: none !important; }

.container { max-width: 960px; margin: 0 auto; padding: 0 16px 48px; }
.container.narrow { max-width: 460px; padding-top: 24px; }

/* Cabeçalho e navegação */
.topbar { background: var(--brand-dark); color: #fff; }
.topbar .container { padding-bottom: 0; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; }
.brand { color: #fff; font-weight: 700; text-decoration: none; }
.who { font-size: 0.85rem; opacity: 0.9; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0 0 10px; }
.nav a { color: #e9f3e8; text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a[aria-current="page"] { color: #fff; border-bottom-color: #fff; font-weight: 600; }
.logout-form { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; font: inherit; cursor: pointer; text-align: left; }
.who .linklike { color: #fff; }
button.linklike:not(.who *) { display: block; padding: 8px 0; color: var(--brand-dark); font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px 8px; margin: 0; min-width: 0; background: var(--surface); }
legend { padding: 0 6px; }

/* Mensagens */
.flash { margin: 12px 0; padding: 10px 12px; border-radius: var(--radius); border: 1px solid; }
.flash.ok { background: var(--brand-soft); border-color: #b9d5b7; }
.flash.err, .error { background: var(--danger-soft); border-color: #f0b9b6; color: var(--danger); }
.error { padding: 8px 10px; border: 1px solid #f0b9b6; border-radius: var(--radius); margin: 8px 0; }

/* Botões */
.btn, button.btn {
  display: inline-block; min-height: 44px; padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--surface); color: var(--brand-dark); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.big { width: 100%; font-size: 1.1rem; min-height: 52px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

/* Formulários */
form.stack > * + * { margin-top: 12px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date],
input[type=tel], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 10px; font: inherit; color: inherit;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus, a:focus { outline: 3px solid #9cc5f2; outline-offset: 1px; }
.checks label { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; }
.checks input { margin-top: 5px; width: 18px; height: 18px; }
.row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.help { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

/* Cartões e listas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; }
.list > li > a.item, .list > li > .item { display: block; padding: 12px 14px; text-decoration: none; color: inherit; }
.list .title { font-weight: 700; display: block; }
.list .meta { color: var(--muted); font-size: 0.9rem; display: block; }

/* Selos de estado (texto sempre presente: não depende só de cor) */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid; }
.badge.client { background: var(--warn-soft); color: var(--warn); border-color: #ecc976; }
.badge.professional { background: var(--info-soft); color: var(--info); border-color: #aac7e3; }
.badge.registry, .badge.agency, .badge.third_party, .badge.other { background: #eee; color: #444; border-color: #ccc; }
.badge.none, .badge.ok { background: var(--brand-soft); color: var(--brand-dark); border-color: #b9d5b7; }
.badge.late, .badge.err { background: var(--danger-soft); color: var(--danger); border-color: #f0b9b6; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #ecc976; }
.badge.off { background: #eee; color: #555; border-color: #ccc; }

/* Painel do profissional: lista de serviços */
.svc .stage { display: block; margin-top: 2px; }
.svc .line { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 6px; }
.dep-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* Portal do cliente (deliberadamente simples) */
.portal h1 { font-size: 1.15rem; text-transform: uppercase; letter-spacing: 0.02em; }
.portal .block { margin: 18px 0; }
.portal .label { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.portal .value { font-size: 1.3rem; font-weight: 700; }
.portal .dep { font-size: 1.6rem; font-weight: 800; }
.portal .dep.me { color: var(--warn); }
.portal .ask { background: var(--surface); border: 2px solid var(--brand); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.portal .ask .what { font-size: 1.1rem; font-weight: 700; }

/* Tabelas simples (financeiro, histórico) */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.sum { width: 100%; border-collapse: collapse; }
.sum td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.sum td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.sum tr.total td { border-top: 2px solid var(--text); border-bottom: 0; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 3px solid var(--line); margin-left: 4px; }
.timeline time { display: block; font-size: 0.8rem; color: var(--muted); }

.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }

dialog { border: 1px solid var(--line); border-radius: var(--radius); max-width: 92vw; }

@media (min-width: 640px) {
  h1 { font-size: 1.7rem; }
  .row.two { grid-template-columns: 1fr 1fr; }
  .row.three { grid-template-columns: 1fr 1fr 1fr; }
  .btn.big { width: auto; min-width: 280px; }
}
