:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  color: #18332e;
  background: #edf2ef;
  --verde: #175a4a;
  --dark: #0e362e;
  --muted: #506961;
  --borda: #cfded6;
  --gold: #dcb779;
  --surface: #fff;
}
* { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
h1, h2 { font-family: Georgia, serif; line-height: 1.15; }
h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.035em; }
h2 { font-size: 1.55rem; }
a { color: var(--verde); font-weight: 650; text-underline-offset: .18em; }
button, input, select, textarea { font: inherit; }
button {
  min-height: 2.65rem;
  padding: .55rem .9rem;
  border: 1px solid transparent;
  border-radius: .55rem;
  background: var(--verde);
  color: white;
  font-weight: 650;
  cursor: pointer;
}
button:hover { background: #104437; }
button:disabled { opacity: .55; cursor: wait; }
.secundario { background: var(--surface); border-color: var(--borda); color: var(--verde); }
.secundario:hover { background: #e5efe9; }
:focus-visible { outline: 3px solid #207768; outline-offset: 3px; }
label { display: grid; gap: .35rem; font-weight: 650; font-size: .9rem; }
input, select, textarea {
  min-width: 0;
  max-width: 100%;
  padding: .58rem .72rem;
  border: 1px solid #aabfb5;
  border-radius: .55rem;
  background: white;
  color: #18332e;
  font-size: 1rem;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem clamp(1rem, 3vw, 2.5rem);
  color: white;
  background: var(--dark);
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: .85rem; }
.brand img, .access-brand img { object-fit: contain; background: white; border-radius: .65rem; }
.brand strong { display: block; font-size: 1.13rem; }
.brand small { display: block; color: #d2e3d9; font-size: .86rem; }
.sair .secundario { border-color: #819e91; background: transparent; color: white; }
.sair .secundario:hover { background: #225348; }
.sair button:focus-visible { outline-color: var(--gold); }

.workspace {
  display: grid;
  grid-template-columns: 13.25rem minmax(0, 1fr);
  align-items: start;
  gap: clamp(1rem, 2.25vw, 2.25rem);
  max-width: 105rem;
  margin: auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}
.navigation {
  display: grid;
  gap: .35rem;
  padding: .65rem;
  background: var(--surface);
  border: 1px solid var(--borda);
  border-radius: .9rem;
}
.navigation button {
  text-align: left;
  font-size: .92rem;
  color: var(--dark);
  background: transparent;
}
.navigation button:hover { background: #edf5ef; }
.navigation button[aria-current="true"] {
  color: var(--dark);
  background: #dcece2;
  box-shadow: inset 3px 0 var(--verde);
}
.dashboard { min-width: 0; }
#status { color: var(--muted); margin-bottom: .65rem; font-size: .9rem; }
#status:empty { display: none; }
#painel {
  padding: clamp(1rem, 2.25vw, 1.8rem);
  background: var(--surface);
  border: 1px solid var(--borda);
  border-radius: 1.05rem;
  box-shadow: 0 .65rem 2rem #19392e0a;
}
.section-head, .toolbar, .acoes {
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
}
.section-head { justify-content: space-between; }
.toolbar {
  align-items: end;
  margin: 1.15rem 0;
  padding: .85rem;
  border: 1px solid #e1eae4;
  border-radius: .75rem;
  background: #f5f8f6;
}
.toolbar label { flex: 0 1 auto; min-width: 0; }
#ministerio { width: min(15rem, 100%); }
.sub { margin-top: .45rem; color: var(--muted); }
.table { overflow: auto; border: 1px solid var(--borda); border-radius: .65rem; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .7rem; border-bottom: 1px solid #e1eae4; vertical-align: top; }
th { background: #e4efe8; color: var(--dark); font-size: .88rem; white-space: nowrap; }
td { overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: #f8fbf9; }
td button { white-space: nowrap; }
th:first-child, td:first-child { min-width: 10rem; }
#registros th:nth-child(4), #registros td:nth-child(4) { min-width: 9rem; }
#registros th:nth-child(7), #registros td:nth-child(7) { min-width: 9.5rem; }
.folha th:first-child, .folha td:first-child { min-width: 0; }
.folha td { height: 2.4rem; }
.folha th:last-child { width: 32%; }
.diretorio { margin-bottom: 1rem; padding: .75rem; border: 1px solid var(--borda); border-radius: .55rem; }
.diretorio summary { cursor: pointer; font-weight: 650; }
.diretorio h2 { margin-top: .8rem; font-size: 1.14rem; }
.resumo { display: flex; flex-wrap: wrap; gap: .65rem; margin: .8rem 0; }
.resumo span, .badge { padding: .35rem .65rem; border-radius: .5rem; background: #e7f0e9; color: var(--dark); }
.historico { margin: .8rem 0; }
.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.vazio { margin-top: .6rem; padding: 1rem; background: #f5f8f6; border-radius: .65rem; }
dialog { width: min(36rem, calc(100% - 1.5rem)); padding: 1.3rem; border: 1px solid var(--borda); border-radius: .95rem; color: inherit; }
dialog::backdrop { background: #0c2822ad; }
#campos { display: grid; gap: .75rem; margin: 1rem 0; }
.acoes { justify-content: flex-end; }
.ministerios { margin: 0; padding: .65rem .8rem; border: 1px solid var(--borda); border-radius: .55rem; }
.ministerios label { display: block; margin: .3rem 0; }

.access { min-height: 100svh; display: grid; place-items: center; padding: clamp(1rem, 5vw, 4rem); }
.access-shell {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1fr);
  width: min(59rem, 100%);
  background: var(--surface);
  border: 1px solid var(--borda);
  border-radius: 1.4rem;
  overflow: hidden;
  box-shadow: 0 1.25rem 4rem #1d49341c;
}
.access-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1.25rem;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  color: #fcfaf3;
  background:
    radial-gradient(ellipse at 100% 100%, #24694f 0, transparent 62%),
    linear-gradient(145deg, #0d322a, #164e3e);
  border-bottom: .35rem solid var(--gold);
}
.access-brand img { padding: .3rem; }
.parish { color: #e2d1a8; font-size: .92rem; font-weight: 650; }
.access-title { font: 700 clamp(2.5rem, 5vw, 4.35rem)/.98 Georgia, serif; letter-spacing: -.05em; }
.entrada { align-self: center; padding: clamp(1.35rem, 5vw, 3.5rem); }
.entrada h1 { margin-bottom: 1.15rem; }
.entrada form { display: grid; gap: .9rem; margin-top: 1rem; }
.entrada form[action="/contas"] { grid-template-columns: 1fr auto; align-items: center; padding: .65rem 0; border-top: 1px solid var(--borda); }
.entrada p { margin: .65rem 0; color: var(--muted); }
.entrada p[role="alert"] { padding: .7rem; border-radius: .5rem; background: #faeae7; color: #8a2d22; }
.entrada code { overflow-wrap: anywhere; }
.print-only { display: none; }

@media (max-width: 820px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .navigation { display: flex; flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .access-shell { grid-template-columns: minmax(0, 1fr); }
  .access-brand { gap: .7rem; }
  .access-brand img { width: 64px; height: 64px; }
  .access-title br { display: none; }
  .access-title { font-size: 2.2rem; }
  .toolbar label { flex: 1 1 10rem; }
}
@media print {
  body { background: white; }
  .workspace, #painel { display: block; padding: 0; border: 0; box-shadow: none; }
  .masthead { color: black; background: white; border: 0; padding: 0 0 1rem; }
  .brand small { color: black; }
  .navigation, .sair, #status, .toolbar, .section-head button, .historico, .diretorio,
  #painel:not([data-tab="folha"]) th:last-child, #painel:not([data-tab="folha"]) td:last-child { display: none !important; }
  .print-only { display: block; }
  .table { overflow: visible; }
  table th, table td, #registros table th, #registros table td { min-width: 0 !important; padding: .3rem; white-space: normal; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}
