:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #667085;
  --line: #d9e0e7;
  --brand: #146c6c;
  --brand-2: #2c7a4b;
  --warn: #a65f00;
  --danger: #b42318;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}
a { color: var(--brand); text-decoration: none; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 238px;
  background: #15202b;
  color: #fff;
  padding: 20px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand);
  font-weight: 700;
}
.brand small { display: block; color: #b8c4d2; margin-top: 3px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar a {
  color: #d8e0ea;
  padding: 11px 12px;
  border-radius: 8px;
}
.sidebar a.active, .sidebar a:hover { background: #233446; color: #fff; }
.app { margin-left: 238px; padding: 24px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.topbar h1 { margin: 0; font-size: 26px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.panel, .metrics article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metrics article { padding: 16px; }
.metrics span, label { color: var(--muted); font-size: 12px; }
.metrics strong { display: block; margin-top: 8px; font-size: 21px; }
.panel { padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.panel-head h2 { margin: 0; }
.split {
  display: grid;
  grid-template-columns: minmax(360px, 450px) 1fr;
  gap: 16px;
  align-items: start;
}
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 16px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid h2, .span2 { grid-column: 1 / -1; }
.form-stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}
button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 13px;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.ghost { background: transparent; }
button.small { min-height: 30px; padding: 5px 9px; }
.filters, .inline-form, .pay-form { display: flex; gap: 10px; align-items: end; }
.filters label { min-width: 160px; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-size: 12px; }
.right { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f6;
}
.badge.ok { color: var(--brand-2); background: #e8f5ed; }
.badge.warn { color: var(--warn); background: #fff3df; }
.badge.wait { color: #475467; background: #f1f5f9; }
.list-lines { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #15202b;
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border-radius: 8px;
  padding: 28px;
}
.login-card h1 { margin: 0 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-card form { display: grid; gap: 14px; }
.alert { padding: 10px; border-radius: 7px; margin-bottom: 14px; }
.alert.danger { background: #fee4e2; color: var(--danger); }
.alert.ok { background: #dcfae6; color: #067647; }
.login-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  border-radius: 7px;
  padding: 10px 14px;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 800;
  text-align: center;
}
.login-secondary:hover { background: #c7ddff; color: #1e40af; }
.login-step-title {
  margin: -4px 0 8px;
  color: #172033;
  font-size: 18px;
  text-align: left;
}
.login-card .login-help {
  margin-bottom: 16px;
  text-align: left;
}

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .split, .cards-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar { position: static; width: auto; }
  .app { margin-left: 0; padding: 16px; }
  .topbar, .top-actions, .filters { align-items: stretch; flex-direction: column; }
  .metrics { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media print {
  .sidebar, .top-actions, .filters, button { display: none !important; }
  .app { margin: 0; padding: 0; }
  body { background: #fff; }
  .panel { box-shadow: none; border-color: #bbb; }
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tabs a {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.tabs a.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  white-space: nowrap;
}
.actions form { display: inline-flex; }
.small-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-weight: 700;
}
button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }

/* OnEclesia financial shell */
.login-card { text-align: center; }
.login-logo {
  width: 132px;
  height: 132px;
  object-fit: contain;
  display: block;
  margin: 0 auto 18px;
}
.login-card form { text-align: left; }
.finance-shell {
  background: #0d1626;
  border-right: 1px solid #2a3850;
  padding: 18px 10px;
}
.menu-top {
  display: grid;
  grid-template-columns: 34px 1fr 48px;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.hamburger {
  color: #e7eef8;
  font-size: 25px;
  line-height: 1;
  text-align: center;
}
.brand-copy strong {
  display: block;
  color: #f5f8ff;
  font-size: 20px;
  line-height: 1.05;
}
.brand-copy small {
  display: block;
  color: #b8c4d6;
  line-height: 1.35;
  margin-top: 4px;
}
.side-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  padding: 5px;
  border: 1px solid #33445f;
}
.church-card,
.user-card,
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  color: #eef4ff;
  background: #1b2a3d;
  border: 1px solid #32445c;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.church-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #05070c;
  display: inline-block;
}
.avatar-dot {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #233f66;
  color: #d8e9ff;
  font-size: 12px;
  font-weight: 700;
}
.user-card small { display: block; color: #b7c4d5; margin-top: 3px; }
.side-nav { display: grid; gap: 7px; margin-top: 10px; }
.side-nav a {
  min-height: 50px;
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #f1f5ff;
}
.side-nav a.active {
  background: #27459b;
  border-color: #3154ba;
}
.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #24415f;
  color: #9fc7ff;
  font-size: 10px;
}
.finance-shell .brand { display: none; }

.nav-group {
  display: grid;
  gap: 6px;
}
.nav-plus {
  margin-left: auto;
  color: #b7c4d5;
  font-size: 20px;
  line-height: 1;
}
.nav-submenu {
  display: none;
  margin: 0 0 4px 42px;
  padding-left: 10px;
  border-left: 1px solid #33445f;
}
.nav-group.open .nav-submenu {
  display: grid;
  gap: 6px;
}
.side-nav .nav-submenu a {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #111d2e;
  border-color: #273851;
  color: #d7e3f4;
  font-size: 13px;
  font-weight: 700;
}
.side-nav .nav-submenu a:hover {
  background: #1e3351;
  color: #fff;
}
.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
/* Compact sidebar controls */
.finance-shell {
  padding: 14px 10px;
  overflow-y: auto;
}
.menu-top {
  grid-template-columns: 28px 1fr 38px;
  gap: 8px;
  margin-bottom: 12px;
}
.hamburger { font-size: 22px; }
.brand-copy strong { font-size: 18px; }
.brand-copy small { font-size: 12px; line-height: 1.25; }
.side-logo { width: 36px; height: 36px; }
.church-card,
.user-card,
.side-nav a {
  min-height: 40px;
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 5px;
}
.church-dot,
.avatar-dot {
  width: 28px;
  height: 28px;
}
.side-nav {
  gap: 5px;
  margin-top: 8px;
}
.side-nav a {
  font-size: 15px;
  font-weight: 800;
}
.nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 7px;
}
.nav-submenu {
  margin: 0 0 6px 34px;
  padding-left: 0;
  border-left: 0;
}
.nav-submenu select {
  min-height: 34px;
  background: #111d2e;
  border-color: #33445f;
  color: #f1f5ff;
  font-size: 13px;
  font-weight: 700;
}
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 13px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.chart-wide { grid-column: 1 / -1; }
.chart-card .badge { background: #eef2ff; color: #27459b; }
.bar-chart { display: grid; gap: 9px; }
.chart-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}
.chart-row summary {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 2fr) auto;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}
.chart-row summary::-webkit-details-marker { display: none; }
.chart-label { font-weight: 700; color: var(--ink); }
.chart-track {
  height: 14px;
  border-radius: 999px;
  background: #eef2f6;
  overflow: hidden;
}
.chart-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}
.bar-chart.expense .chart-track span { background: #d97706; }
.bar-chart.income .chart-track span { background: #16a34a; }
.bar-chart.mixed .chart-track span { background: #2563eb; }
.mini-table { margin-top: 10px; font-size: 12px; }
.empty.compact { padding: 10px; margin: 0; }
.month-chart { display: grid; gap: 10px; }
.month-row {
  display: grid;
  grid-template-columns: 70px 1fr 170px;
  gap: 10px;
  align-items: center;
}
.dual-bars {
  display: grid;
  gap: 4px;
}
.dual-bars span {
  display: block;
  height: 10px;
  border-radius: 999px;
}
.dual-bars .income { background: #16a34a; }
.dual-bars .expense { background: #d97706; }
.nav-submenu {
  display: grid;
  gap: 6px;
  margin: 0 0 8px 34px;
  padding: 8px 0 8px 10px;
  border-left: 1px solid #33445f;
}
.side-nav .nav-submenu a {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: #d7e3f4;
}
.side-nav .nav-submenu a.active-sub,
.side-nav .nav-submenu a:hover {
  background: #27459b;
  color: #fff;
}
@media (max-width: 1180px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-row summary { grid-template-columns: 1fr; }
  .month-row { grid-template-columns: 1fr; }
}
/* Suspended menu and chart modes */
.side-nav .nav-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border: 1px solid #32445c;
  border-radius: 8px;
  padding: 7px 10px;
  margin: 0 0 5px;
  background: #1b2a3d;
  color: #f1f5ff;
  font-size: 15px;
  font-weight: 800;
  text-align: left;
}
.side-nav .nav-toggle.active,
.side-nav .nav-toggle:hover {
  background: #27459b;
  border-color: #3154ba;
}
.nav-group .nav-submenu {
  display: none;
}
.nav-group.open .nav-submenu {
  display: grid;
}
.chart-modes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chart-modes button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
  background: #f8fafc;
}
.chart-modes button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.chart-view {
  display: none;
}
.chart-view.active {
  display: block;
}
.line-chart {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#fff, #fff), repeating-linear-gradient(to top, #eef2f6 0, #eef2f6 1px, transparent 1px, transparent 44px);
  margin-bottom: 12px;
}
.line-chart polyline {
  fill: none;
  stroke: #2563eb;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.line-chart .income-line { stroke: #16a34a; }
.line-chart .expense-line { stroke: #d97706; }
.pie-chart {
  width: min(260px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 4px auto 14px;
  background: conic-gradient(var(--segments));
  border: 1px solid var(--line);
}
.pie-chart.donut {
  position: relative;
}
.pie-chart.donut::after {
  content: '';
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
}
.pie-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
  text-align: center;
}
.chart-legend {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
@media (max-width: 760px) {
  .panel-head { align-items: flex-start; flex-direction: column; }
  .chart-modes { justify-content: flex-start; }
  .pie-split { grid-template-columns: 1fr; }
}
/* Theme, icons and polished menu */
body.theme-clean {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #667085;
  --line: #d9e0e7;
  background: var(--bg);
  color: var(--ink);
}
body.theme-dark {
  --bg: #0d1626;
  --panel: #152033;
  --ink: #f5f8ff;
  --muted: #aebbd0;
  --line: #31425d;
  background: var(--bg);
  color: var(--ink);
}
body.theme-dark .panel,
body.theme-dark .metrics article,
body.theme-dark .chart-row,
body.theme-dark .login-card {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
body.theme-dark input,
body.theme-dark select,
body.theme-dark .button-link,
body.theme-dark button:not(.primary):not(.danger):not(.theme-button):not(.power-button):not(.nav-toggle) {
  background: #0f1a2d;
  color: var(--ink);
  border-color: var(--line);
}
body.theme-dark th,
body.theme-dark .topbar p,
body.theme-dark .metrics span,
body.theme-dark label,
body.theme-dark .empty,
body.theme-dark .chart-legend {
  color: var(--muted);
}
.hamburger {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 28px;
  cursor: pointer;
}
.church-card strong,
.user-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.church-dot {
  display: grid;
  place-items: center;
  color: #9fc7ff;
}
.avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #395171;
  background: #fff;
}
.nav-icon {
  flex: 0 0 auto;
}
.nav-icon svg,
.church-dot svg,
.power-button svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
}
.nav-icon.small-icon {
  width: 22px;
  height: 22px;
}
.side-nav a,
.side-nav .nav-toggle {
  min-width: 0;
}
.nav-toggle span:nth-child(2),
.side-nav a {
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-submenu {
  max-height: 0;
  overflow: hidden;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  transition: max-height .18s ease, padding .18s ease;
}
.nav-group.open .nav-submenu {
  max-height: 420px;
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}
.theme-button,
.power-button {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}
.theme-button {
  min-width: 112px;
}
.power-button {
  width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
}
body.theme-dark .theme-button,
body.theme-dark .power-button {
  border-color: #d8bd68;
  background: #111d2e;
  color: #f5f8ff;
}
.theme-switch {
  width: 112px;
  min-width: 112px;
  height: 42px;
  min-height: 42px;
  display: grid;
  grid-template-columns: 24px 42px 24px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 21px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 4px 12px rgba(0,0,0,.12);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.theme-switch:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 6px 16px rgba(0,0,0,.2); }
.theme-switch-icon { display: grid; place-items: center; width: 24px; height: 24px; color: var(--muted); transition: color .18s ease, transform .18s ease; }
.theme-switch-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.theme-switch-track { position: relative; display: block; width: 42px; height: 22px; border: 1px solid var(--line); border-radius: 11px; background: var(--heading); }
.theme-switch-knob { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #f8fafc; box-shadow: 0 1px 4px rgba(0,0,0,.35); transition: transform .2s ease, background .2s ease; }
.theme-switch[data-active-theme="clean"] .theme-switch-sun { color: #d97706; transform: scale(1.08); }
.theme-switch[data-active-theme="clean"] .theme-switch-track { background: #f4c95d; border-color: #d6a72d; }
.theme-switch[data-active-theme="dark"] .theme-switch-moon { color: #b9d4ff; transform: scale(1.08); }
.theme-switch[data-active-theme="dark"] .theme-switch-track { background: #294a78; border-color: #527bb0; }
.theme-switch[data-active-theme="dark"] .theme-switch-knob { transform: translateX(20px); background: #eaf2ff; }
body.theme-clean .finance-shell {
  background: #f7f9fc;
  color: #172033;
  border-right-color: #d9e0e7;
}
body.theme-clean .brand-copy strong,
body.theme-clean .hamburger {
  color: #172033;
}
body.theme-clean .brand-copy small,
body.theme-clean .user-card small {
  color: #667085;
}
body.theme-clean .church-card,
body.theme-clean .user-card,
body.theme-clean .side-nav a,
body.theme-clean .side-nav .nav-toggle {
  background: #ffffff;
  border-color: #d9e0e7;
  color: #172033;
}
body.theme-clean .side-nav a.active,
body.theme-clean .side-nav .nav-toggle.active,
body.theme-clean .side-nav .nav-submenu a.active-sub,
body.theme-clean .side-nav a:hover,
body.theme-clean .side-nav .nav-toggle:hover {
  background: #27459b;
  color: #fff;
  border-color: #3154ba;
}
body.theme-clean .nav-icon {
  background: #e9f2ff;
  color: #2563eb;
}
body.theme-clean .side-nav a.active .nav-icon,
body.theme-clean .side-nav .nav-toggle.active .nav-icon,
body.theme-clean .side-nav a:hover .nav-icon,
body.theme-clean .side-nav .nav-toggle:hover .nav-icon {
  background: rgba(255,255,255,.16);
  color: #fff;
}
body.sidebar-collapsed .sidebar {
  width: 78px;
}
body.sidebar-collapsed .app {
  margin-left: 78px;
}
body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .church-card strong,
body.sidebar-collapsed .user-card div,
body.sidebar-collapsed .side-nav a > :not(.nav-icon),
body.sidebar-collapsed .nav-toggle > :not(.nav-icon),
body.sidebar-collapsed .nav-submenu {
  display: none !important;
}
body.sidebar-collapsed .menu-top {
  grid-template-columns: 1fr;
  justify-items: center;
}
body.sidebar-collapsed .side-logo {
  display: none;
}
body.sidebar-collapsed .church-card,
body.sidebar-collapsed .user-card,
body.sidebar-collapsed .side-nav a,
body.sidebar-collapsed .side-nav .nav-toggle {
  justify-content: center;
  padding: 8px;
}
/* Off-canvas suspended menu for desktop and mobile */
.sidebar.finance-shell {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(318px, calc(100vw - 34px));
  max-width: 318px;
  z-index: 60;
  transform: translateX(-110%);
  transition: transform .22s ease;
  box-shadow: 18px 0 40px rgba(0,0,0,.28);
}
body.menu-open .sidebar.finance-shell {
  transform: translateX(0);
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 7, 18, .58);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
body.menu-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}
.app,
body.sidebar-collapsed .app {
  margin-left: 0;
  padding: 24px;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.menu-open-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}
.menu-open-button span {
  display: block;
  width: 21px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
.menu-top .hamburger {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 8px;
  color: #e7eef8;
  font-size: 24px;
}
.drill-hint {
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
body.theme-clean .menu-open-button {
  background: #fff;
}
body.theme-dark .menu-open-button {
  background: #111d2e;
  border-color: #31425d;
  color: #f5f8ff;
}
@media (max-width: 760px) {
  .app,
  body.sidebar-collapsed .app {
    margin-left: 0;
    padding: 16px;
  }
  .topbar {
    align-items: flex-start;
  }
  .title-row {
    width: 100%;
  }
  .top-actions {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .top-actions .inline-form:first-child {
    width: 100%;
  }
}.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
/* Dashboard cards and fixed chart types */
.metrics article {
  display: flex;
  align-items: center;
  gap: 12px;
}
.metric-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #e9f2ff;
  color: #2563eb;
}
.metric-icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}
.metrics article > div {
  min-width: 0;
}
.chart-type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9f2ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}
.drill-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.drill-list .chart-row summary {
  grid-template-columns: minmax(160px, 1fr) auto;
}
body.theme-dark .metric-icon,
body.theme-dark .chart-type-badge {
  background: #223b60;
  color: #9fc7ff;
}

/* Suspended menu header requested for desktop and mobile */
.menu-top {
  grid-template-columns: 34px 1fr;
  align-items: start;
}
.menu-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.menu-actions .inline-form:first-child {
  flex: 0 0 auto;
}
.menu-actions .theme-button {
  width: 112px;
}
.menu-actions .power-button {
  width: 44px;
}
.church-card,
.user-card {
  align-items: flex-start;
}
.church-card .church-dot,
.user-card .avatar-dot,
.user-card .avatar-img {
  margin-top: 1px;
}
.user-card div {
  min-width: 0;
}
.user-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-icon svg,
.church-dot svg,
.power-button svg,
.metric-icon svg {
  display: block;
}
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap input {
  padding-right: 46px;
}
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  color: #475467;
}
.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
.password-toggle.is-visible {
  color: var(--brand);
  background: #e9f2ff;
}
.dashboard-metrics {
  grid-template-columns: repeat(4, minmax(210px, 1fr));
}
.metric-detail {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.metric-compare {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 800;
  white-space: nowrap;
}
.metric-compare.up {
  background: #dcfae6;
  color: #067647;
}
.metric-compare.down {
  background: #fee4e2;
  color: #b42318;
}
body.theme-dark .password-toggle {
  color: #aebbd0;
}
body.theme-dark .password-toggle.is-visible,
body.theme-dark .metric-compare.up {
  background: #123c2b;
  color: #75e0a7;
}
body.theme-dark .metric-compare.down {
  background: #4a1f22;
  color: #fda29b;
}
@media (max-width: 1180px) {
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(210px, 1fr)); }
}
@media (max-width: 760px) {
  .dashboard-metrics { grid-template-columns: 1fr; }
}
/* Executive dashboard summary */
.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}
.dash-card {
  min-height: 158px;
  border-radius: 20px;
  padding: 28px 26px;
  background: #1c293b;
  color: #fff;
  box-shadow: 0 18px 35px rgba(3, 7, 18, .18);
}
.dash-card .dash-title {
  display: block;
  color: #f8fbff;
  font-size: 16px;
  margin-bottom: 6px;
}
.dash-card strong {
  display: block;
  margin: 2px 0 5px;
  font-size: clamp(24px, 2.1vw, 32px);
  line-height: 1.1;
  color: #2f6df6;
}
.dash-card small {
  display: block;
  color: #ffffff;
  font-size: 15px;
  line-height: 1.45;
}
.dash-card.income strong { color: #22c55e; }
.dash-card.expense strong { color: #ff3037; }
.dash-card.balance strong { color: #2f6df6; }
.dash-card.warning strong { color: #fb650d; }
.dash-alert {
  min-height: 158px;
  border-radius: 20px;
  padding: 28px;
  background: #fff9bd;
  color: #a34200;
  font-size: 20px;
  line-height: 1.45;
  box-shadow: 0 18px 35px rgba(3, 7, 18, .12);
}
body.theme-clean .dash-card {
  background: #1f2b3c;
  color: #fff;
}
@media (max-width: 1500px) {
  .dashboard-summary { grid-template-columns: repeat(3, minmax(210px, 1fr)); }
}
@media (max-width: 980px) {
  .dashboard-summary { grid-template-columns: repeat(2, minmax(210px, 1fr)); gap: 16px; }
}
@media (max-width: 620px) {
  .dashboard-summary { grid-template-columns: 1fr; }
  .dash-card, .dash-alert { min-height: auto; padding: 22px; border-radius: 14px; }
}
.cadastro-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}
.cadastro-tools label {
  min-width: 180px;
  flex: 1 1 180px;
}
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.table-head h2 { margin: 0; }
.table-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
@media (max-width: 760px) {
  .cadastro-tools { flex-direction: column; align-items: stretch; }
  .cadastro-tools label { min-width: 0; width: 100%; }
}
.native-search-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.search-select-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.search-select-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.search-select-button span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-select-arrow {
  color: var(--muted);
  flex: 0 0 auto;
}

.search-select-panel {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  display: none;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

.search-select-wrap.open .search-select-panel {
  display: block;
}

.search-select-input {
  width: 100%;
  margin-bottom: 8px;
}

.search-select-list {
  display: grid;
  gap: 4px;
  max-height: 240px;
  overflow: auto;
}

.search-select-option {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.search-select-option:hover,
.search-select-option[aria-selected="true"] {
  background: rgba(20, 108, 108, .14);
  color: var(--brand);
}

.search-select-empty {
  padding: 10px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .search-select-panel {
    position: fixed;
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 18px;
    max-height: 72vh;
  }

  .search-select-list {
    max-height: 54vh;
  }
}
.report-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.totals-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.totals-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 108, 108, .08);
  color: var(--ink);
}

tfoot th {
  border-top: 1px solid var(--line);
  background: rgba(20, 108, 108, .08);
  font-weight: 700;
}

@media print {
  .no-print,
  .no-export,
  .report-actions,
  .actions {
    display: none !important;
  }

  .app {
    margin-left: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .panel {
    box-shadow: none !important;
    overflow: visible !important;
    break-inside: auto;
  }

  html,
  body,
  main,
  .content,
  .responsive-table,
  [data-report-scope] {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  table {
    display: table !important;
    width: 100% !important;
    overflow: visible !important;
    white-space: normal !important;
  }

  thead { display: table-header-group !important; }
  tfoot { display: table-footer-group !important; }
  tbody { display: table-row-group !important; }
  tr {
    display: table-row !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  table[data-paginate] tbody tr[hidden] { display: table-row !important; }
  .page-size-label,
  .pager,
  .settings-pagination { display: none !important; }
}
.page-size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
}

.page-size-label select {
  min-height: 32px;
  padding: 4px 8px;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pager-button {
  min-height: 30px;
  padding: 4px 9px;
}

.pager-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.pager-info {
  min-width: 42px;
  text-align: center;
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.settings-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.panel, .split > *, .form-grid > *, .filters > *, .user-card > div { min-width: 0; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-head, .filters, .pay-form { flex-wrap: wrap; }
.responsive-table { width: 100%; max-width: 100%; overflow-x: auto; }
.responsive-table table { min-width: 680px; }
.user-card small, .church-card strong { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .split, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .filters label { min-width: 0; width: 100%; }
  input, select, textarea, .search-select-button { font-size: 16px; max-width: 100%; }
  input, select, button, .button-link, .small-link { min-height: 44px; }
  textarea { width: 100%; }
  .form-grid .primary { width: 100%; }
  .report-actions { width: 100%; flex-wrap: wrap; }
  .settings-pagination { gap: 8px; }
}
@media print { .responsive-table { overflow: visible; } .responsive-table table { min-width: 0; } }
.report-nav-section { min-width: 0; }
.report-nav-section summary { cursor: pointer; padding: 10px 12px; font-size: 13px; font-weight: 600; }
.report-nav-section > a { margin-left: 12px; }
.balance-section { margin: 12px 0 26px; }
.report-chart-grid > .panel:only-child { grid-column: 1 / -1; }
.report-bar-group { margin: 18px 0; overflow-wrap: anywhere; }
.report-bar-value { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12px; margin: 7px 0 4px; }
.report-bar-track { position: relative; height: 14px; background: rgba(128,128,128,.12); }
.report-bar-track > span { position: absolute; top: 0; height: 14px; }
.report-bar-zero { position: absolute; top: -2px; height: 18px; width: 1px; background: var(--muted); z-index: 1; }
@media print {
  .report-chart-grid { display: block; }
  .report-chart-grid .finance-chart { break-inside: avoid; margin-bottom: 20px; }
  .report-bar-track > span, .report-chart-grid .pie-chart, .report-chart-grid .category-track > span { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
.balance-section table { table-layout: fixed; }
.balance-section th:first-child, .balance-section td:first-child { width: 65%; overflow-wrap: anywhere; }
.balance-section .right { white-space: nowrap; }
.balance-category { background: rgba(128,128,128,.12); }
.balance-subcategory td:first-child { padding-left: 24px; }
@media (max-width: 480px) { .balance-section th, .balance-section td { padding: 10px 5px; font-size: 12px; } .balance-section th:first-child, .balance-section td:first-child { width: 55%; } .balance-subcategory td:first-child { padding-left: 14px; } }
.donation-report-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: end; }
.finance-chart { min-width: 0; }
.finance-chart h2 { font-size: 16px; line-height: 1.4; margin: 0 0 14px; overflow-wrap: anywhere; }
.finance-chart-scroll { max-width: 100%; overflow-x: auto; }
.finance-series { display: block; width: 100%; min-width: 640px; height: auto; }
.finance-series text { fill: var(--muted); font: 10px Arial, sans-serif; }
.chart-gridline { stroke: var(--muted); opacity: .2; }
.chart-baseline { stroke: var(--muted); opacity: .6; }
.chart-caption { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
.chart-data { margin-top: 10px; font-size: 12px; }
.chart-data summary { cursor: pointer; }
.chart-data table { min-width: 400px; }
.category-bars { min-height: 260px; display: flex; flex-direction: column; gap: 14px; }
.category-bar-row > div:first-child { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12px; margin-bottom: 5px; }
.category-bar-row span { overflow-wrap: anywhere; }
.category-bar-row strong { white-space: nowrap; }
.category-track { height: 16px; background: rgba(128,128,128,.12); }
.category-track > span { display: block; height: 16px; }
.settings-tabs .active { background: #176f72; color: #fff; border-color: #176f72; }
.theme-dark .settings-tabs .button-link.active, .theme-clean .settings-tabs .button-link.active { background: #176f72; color: #fff; border-color: #176f72; }
.form-grid .settings-checkbox, .form-stack .settings-checkbox { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.form-grid .settings-checkbox input[type="checkbox"], .form-stack .settings-checkbox input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; flex: 0 0 18px; padding: 0; margin: 0; }
.church-settings { max-width: 640px; }
.panel code {
  display: block;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(128, 128, 128, .1);
  color: var(--ink);
  overflow-wrap: anywhere;
  white-space: normal;
}
.settings-image { display: block; width: 80px; height: 80px; max-width: 80px; max-height: 80px; object-fit: contain; margin: 8px 0; border-radius: 6px; background: #fff; }
.church-card .church-logo { width: 40px; height: 40px; max-width: 40px; max-height: 40px; flex: 0 0 40px; }
.user-card .avatar-img { width: 40px; height: 40px; max-width: 40px; max-height: 40px; flex: 0 0 40px; object-fit: cover; }
.church-logo { width: 36px; height: 36px; flex: 0 0 36px; object-fit: contain; background: #fff; border-radius: 6px; }
.settings-avatar { width: 32px; height: 32px; flex: 0 0 32px; object-fit: cover; border-radius: 50%; }
.member-photo-column { width: 58px; min-width: 58px; text-align: center; }
.member-list-avatar { position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; overflow: hidden; border: 1px solid var(--line); border-radius: 50%; background: var(--category); color: var(--category-ink); font-size: 15px; font-weight: 800; }
.member-list-avatar > span { grid-area: 1 / 1; }
.member-list-avatar > img { grid-area: 1 / 1; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; background: var(--panel); }
.donation-member-picker { display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 9px; }
.donation-member-picker select { min-width: 0; width: 100%; }
.donation-member-avatar { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; overflow: hidden; border: 1px solid var(--line); border-radius: 50%; background: var(--category); color: var(--category-ink); font-size: 16px; font-weight: 800; }
.donation-member-avatar > span { grid-area: 1 / 1; }
.donation-member-avatar > img { grid-area: 1 / 1; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; background: var(--panel); }
.donation-member-avatar > img[hidden] { display: none; }
.settings-user-name { display: flex; align-items: center; gap: 8px; }
.church-menu-logo { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; overflow: hidden; border-radius: 7px; background: #fff; }
.church-menu-logo > * { grid-area: 1 / 1; }
.church-menu-logo .church-dot { width: 40px; height: 40px; display: grid; place-items: center; }
.church-menu-logo .church-logo { position: relative; z-index: 1; display: block; margin: 0; object-fit: contain; background: #fff; }
.user-menu-avatar { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; overflow: hidden; border-radius: 50%; }
.user-menu-avatar > * { grid-area: 1 / 1; }
.user-menu-avatar .avatar-dot { width: 40px; height: 40px; }
.user-menu-avatar .avatar-img { position: relative; z-index: 1; display: block; margin: 0; }
.user-list-avatar { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; overflow: hidden; border: 1px solid var(--line); border-radius: 50%; background: var(--category); color: var(--category-ink); font-size: 13px; font-weight: 800; }
.user-list-avatar > * { grid-area: 1 / 1; }
.user-list-avatar img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; background: var(--panel); }
.user-photo-preview { object-fit: cover; border-radius: 50%; }
.settings-table-scroll, .settings-users-panel { overflow-x: auto; min-width: 0; }
.access-agent { max-width: 320px; overflow-wrap: anywhere; white-space: normal; }
.finance-chart-tooltip { position: fixed; z-index: 10000; pointer-events: none; padding: 9px 12px; max-width: min(320px, calc(100vw - 16px)); background: #111827; color: #fff; border: 1px solid #64748b; border-radius: 6px; box-shadow: 0 4px 14px #0005; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.finance-chart-tooltip[hidden] { display: none; }
[data-chart-tooltip], [data-pie-tooltips] { cursor: help; }
[data-chart-tooltip]:focus-visible, [data-pie-tooltips]:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
@media print { .finance-chart-tooltip { display: none !important; } }
.donation-map { min-width: 1540px; }
.donation-map th, .donation-map td { white-space: nowrap; }
.donation-map th:first-child, .donation-map td:first-child { position: sticky; left: 0; background: var(--panel, #172235); z-index: 1; min-width: 190px; max-width: 250px; white-space: normal; overflow-wrap: anywhere; }
.map-status { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; font-size: 21px; font-weight: 700; }
.contributed { color: #16a34a; }
.not-contributed { color: #94a3b8; }
.map-legend { display: flex; flex-wrap: wrap; gap: 20px; }
.report-chart-switcher { min-width: 0; }
.chart-type-control { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 0 0 10px; }
.chart-type-control select { width: 170px; min-height: 40px; }
.report-chart-switcher [hidden] { display: none !important; }
.chart-item-key { padding-left: 30px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 24px; overflow-wrap: anywhere; }
.report-chart-switcher .pie-chart { width: min(100%, 320px); height: auto; aspect-ratio: 1; margin: 18px auto; }
@media print { .chart-type-control { display: none; } .donation-map { min-width: 0; font-size: 9px; } .donation-map th:first-child, .donation-map td:first-child { position: static; min-width: 0; } }
.settings-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.church-settings input[type="file"] { max-width: 100%; min-width: 0; }
@media (max-width: 600px) {
  .settings-tabs a { flex: 1 1 auto; text-align: center; }
  .settings-table-scroll table { min-width: 600px; }
  .settings-users-panel table { min-width: 580px; }
}

/* Accessible surfaces for both application themes. */
body.theme-clean { --bg:#f1f4f6; --panel:#fff; --ink:#19282f; --muted:#475961; --line:#c5d0d6; --brand:#116568; --field:#fff; --row:#edf4f4; --heading:#e4edee; --category:#d9eae7; --category-ink:#174b43; color-scheme:light; }
body.theme-dark { --bg:#151a1e; --panel:#20282d; --ink:#f0f4f5; --muted:#bac8ce; --line:#4c6069; --brand:#19777a; --field:#192126; --row:#29373d; --heading:#2c3b42; --category:#24473e; --category-ink:#cbf2df; color-scheme:dark; }
body.theme-clean input, body.theme-clean select, body.theme-clean textarea,
body.theme-dark input, body.theme-dark select, body.theme-dark textarea { background:var(--field); color:var(--ink); border-color:var(--line); }
body.theme-clean label, body.theme-dark label { color:var(--ink); }
body input::placeholder, body textarea::placeholder { color:var(--muted); opacity:1; }
body.theme-clean thead th, body.theme-dark thead th { background:var(--heading); color:var(--ink); }
body.theme-clean tbody tr:hover, body.theme-dark tbody tr:hover { background:var(--row); }
body.theme-clean .balance-category th, body.theme-dark .balance-category th { background:var(--category); color:var(--category-ink); font-weight:800; border-top:2px solid var(--line); border-bottom:1px solid var(--line); padding-top:13px; padding-bottom:13px; }
.balance-category th:first-child { border-left:4px solid #298368; }
.balance-subcategory td:first-child { padding-left:28px; }
body.theme-dark .button-link, body.theme-dark button:not(.primary):not(.danger):not(.theme-button):not(.power-button):not(.nav-toggle) { background:var(--heading); color:var(--ink); border-color:var(--line); }
body.theme-clean .small-link { background:#e0f1ee; color:#145344; border-color:#b6d6cf; }
body.theme-dark .small-link { background:#2b4943; color:#d6fae9; border-color:#5b8b7e; }
body.theme-dark .side-nav a, body.theme-dark .side-nav .nav-toggle, body.theme-dark .church-card, body.theme-dark .user-card { background:#253137; color:var(--ink); border-color:var(--line); }
body.theme-dark .sidebar, body.theme-dark .nav-submenu { background:#1a2227; color:var(--ink); }
body.theme-dark .side-nav a.active, body.theme-dark .side-nav .nav-toggle.active, body.theme-dark .side-nav a:hover, body.theme-dark .nav-submenu a.active-sub { background:#22534d; color:#f0fff8; }
body.theme-clean .side-nav a.active, body.theme-clean .side-nav .nav-toggle.active, body.theme-clean .side-nav a:hover { background:#d8ebe7; color:#174b43; }
body.theme-dark .chart-gridline { stroke:#46575f; }
body.theme-dark .finance-series text { fill:#c8d6db; }
body.theme-clean .finance-series text { fill:#40545c; }
body.theme-dark .alert { background:#263f47; color:#e3f2f8; border-color:#5c8999; }
body :is(input,select,textarea,button,a,summary):focus-visible { outline:3px solid #388db1; outline-offset:2px; }
.subcategory-picker { align-self:start; min-width:0; border:1px solid var(--line); border-radius:6px; padding:10px; color:var(--ink); }
.subcategory-picker summary { cursor:pointer; font-weight:700; }
.subcategory-picker > div { max-height:220px; overflow-y:auto; margin-top:10px; }
.subcategory-picker label { display:flex; align-items:center; gap:9px; padding:7px 0; font-weight:400; }
.subcategory-picker input[type=checkbox] { width:18px; min-width:18px; height:18px; min-height:18px; accent-color:var(--brand); }
.flow-nature { display:block; width:100%; min-height:44px; padding:12px; border:1px solid var(--line); border-left:5px solid var(--brand); border-radius:6px; background:var(--heading); color:var(--ink); font-size:16px; font-weight:700; }
.flow-nature[data-nature="D"] { border-left-color:#e68b39; }
.flow-nature[data-nature="R"] { border-left-color:#2caa79; }
body.theme-dark .tabs a { background:#2c3b42; color:#f0f4f5; border-color:#60737d; }
body.theme-dark .tabs a:hover, body.theme-dark .tabs a:focus-visible { background:#3b505a; color:#fff; }
body.theme-dark .tabs a.active { background:#22695b; color:#fff; border-color:#6ec7ae; }
body.theme-clean .tabs a { background:#fff; color:#203940; border-color:#b9cbd0; }
body.theme-clean .tabs a.active { background:#116568; color:#fff; border-color:#116568; }
@media print { .balance-category th { background:#dcebe5 !important; color:#153e32 !important; print-color-adjust:exact; -webkit-print-color-adjust:exact; } }

/* Central de Ajuda */
.help-fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 1200;
  width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.78);
  border-radius: 50%;
  background: #147476;
  color: #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.help-fab:hover { transform: translateY(-2px); background:#0f5f61; box-shadow:0 14px 32px rgba(0,0,0,.34); }
.help-fab[aria-expanded="true"] { transform:scale(.94); }
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: flex;
  justify-content: flex-end;
  background: rgba(5,15,20,.58);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.help-overlay[hidden] { display:none; }
.help-overlay.is-open { opacity:1; visibility:visible; }
.help-center {
  width: min(440px, calc(100vw - 28px));
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--ink);
  border-left: 1px solid var(--line);
  box-shadow: -14px 0 38px rgba(0,0,0,.3);
  transform: translateX(100%);
  transition: transform .24s ease;
}
.help-overlay.is-open .help-center { transform:translateX(0); }
.help-header {
  min-height: 88px;
  padding: 18px 18px 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--heading);
}
.help-header h2 { margin:3px 0 0; font-size:22px; line-height:1.2; letter-spacing:0; }
.help-eyebrow { color:var(--brand); font-size:12px; font-weight:800; text-transform:uppercase; }
.help-close {
  width: 42px;
  height: 42px;
  min-height: 42px;
  flex: 0 0 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--field);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.help-content { padding:20px 22px 26px; overflow-y:auto; overscroll-behavior:contain; }
.help-search-label { display:block; margin:0 0 7px; font-size:13px; font-weight:700; color:var(--ink); }
.help-search-wrap input { width:100%; min-height:46px; margin:0; }
.help-list { margin-top:18px; border-top:1px solid var(--line); }
.help-list details { border-bottom:1px solid var(--line); }
.help-list summary {
  position: relative;
  padding:16px 34px 16px 2px;
  color:var(--ink);
  font-size:15px;
  font-weight:800;
  cursor:pointer;
  list-style:none;
}
.help-list summary::-webkit-details-marker { display:none; }
.help-list summary::after { content:'+'; position:absolute; right:4px; top:13px; color:var(--brand); font-size:22px; }
.help-list details[open] summary::after { content:'−'; }
.help-list p { margin:0; padding:0 34px 17px 2px; color:var(--muted); font-size:14px; line-height:1.6; }
.help-empty { padding:22px 0; color:var(--muted); text-align:center; }
.help-support { margin-top:22px; padding:16px; border-left:4px solid var(--brand); background:var(--heading); }
.help-support strong, .help-support span { display:block; }
.help-support span { margin-top:4px; color:var(--muted); font-size:13px; }
body.help-open { overflow:hidden; }
@media (max-width:600px) {
  .help-fab { right:max(14px, env(safe-area-inset-right)); bottom:max(14px, env(safe-area-inset-bottom)); width:52px; height:52px; min-height:52px; }
  .help-overlay { align-items:flex-end; }
  .help-center { width:100%; height:min(84dvh, 720px); border-left:0; border-top:1px solid var(--line); border-radius:8px 8px 0 0; transform:translateY(100%); }
  .help-overlay.is-open .help-center { transform:translateY(0); }
  .help-header { min-height:76px; padding:14px 16px; }
  .help-content { padding:16px 18px calc(24px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion:reduce) {
  .help-fab, .help-overlay, .help-center { transition:none; }
}
@media print { .help-fab, .help-overlay { display:none !important; } }

.settings-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.payable-alert-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.payable-alert-stats > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--heading);
}
.payable-alert-stats small,
.payable-alert-stats span { color: var(--muted); }
.payable-alert-stats strong { color: var(--ink); font-size: 20px; overflow-wrap: anywhere; }
.settings-table-scroll { max-width: 100%; overflow-x: auto; }
.settings-table-scroll .actions { flex-wrap: nowrap; }

/* Compact, touch-friendly layout for phones. */
@media (max-width: 760px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .app, body.sidebar-collapsed .app { width: 100%; padding: 12px; }
  .topbar { gap: 12px; margin-bottom: 14px; }
  .topbar h1 { font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
  .topbar p { font-size: 13px; line-height: 1.4; }
  .title-row { align-items: flex-start; gap: 10px; }
  .menu-open-button { width: 42px; height: 42px; min-height: 42px; flex: 0 0 42px; border-radius: 7px; }
  .top-actions, .top-actions form, .top-actions select { width: 100%; }
  .sidebar.finance-shell { width: min(320px, calc(100vw - 16px)); padding: 12px 9px calc(18px + env(safe-area-inset-bottom)); }
  .menu-top { margin-bottom: 10px; }
  .brand-copy strong { font-size: 17px; }
  .brand-copy small { font-size: 11px; line-height: 1.3; }
  .church-card, .user-card { min-height: 52px; padding: 8px 9px; }
  .side-nav { gap: 4px; }
  .side-nav a, .side-nav .nav-toggle { min-height: 44px; font-size: 14px; }
  .panel { padding: 12px; margin-bottom: 12px; }
  .panel h2 { font-size: 17px; line-height: 1.3; }
  .panel-head { align-items: stretch; flex-direction: column; gap: 9px; }
  .split, .cards-grid, .form-grid { gap: 12px; }
  .metrics, .dashboard-summary { gap: 10px; margin-bottom: 12px; }
  .metrics article { padding: 13px; }
  .dash-card, .dash-alert { padding: 16px; border-radius: 8px; }
  .filters, .pay-form { width: 100%; gap: 10px; }
  .filters label, .pay-form label { width: 100%; min-width: 0; }
  .filters > button, .filters > .button-link { width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > *, .form-grid .span2 { grid-column: 1; }
  .report-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .report-actions > * { width: 100%; min-width: 0; padding-left: 6px; padding-right: 6px; font-size: 12px; }
  .settings-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .settings-tabs a { width: 100%; min-width: 0; padding: 8px 6px; }
  .settings-columns, .payable-alert-stats { grid-template-columns: minmax(0, 1fr); }
  table { max-width: 100%; font-size: 13px; }
  th, td { padding: 9px 7px; }
  .actions { justify-content: flex-start; }
  .finance-series { min-width: 560px; }
  .help-fab { z-index: 1100; }
}

@media (max-width: 420px) {
  .app, body.sidebar-collapsed .app { padding: 9px; }
  .panel { padding: 10px; }
  .report-actions { grid-template-columns: 1fr; }
  .settings-tabs { grid-template-columns: 1fr; }
  .finance-series { min-width: 500px; }
}
