:root {
  --forest: #123e2b;
  --forest-light: #1d563b;
  --green: #4f8a2f;
  --green-dark: #386620;
  --green-soft: #edf6e8;
  --blue: #2d6cdf;
  --blue-soft: #edf4ff;
  --red: #d34b55;
  --red-soft: #fff0f1;
  --amber: #ef9725;
  --amber-soft: #fff6e5;
  --ink: #1c291d;
  --muted: #6e7d6c;
  --line: #e1e9df;
  --surface: #ffffff;
  --background: #f6f8f3;
  --shadow: 0 16px 42px rgba(35, 72, 30, 0.08);
  --font-body: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 70% 0, rgba(91, 143, 53, 0.07), transparent 25rem),
    var(--background);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body.drawer-open,
body.menu-open,
body.modal-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.auth-pending .app-shell,
.auth-pending .mobile-add-button {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 252px;
  flex-direction: column;
  padding: 30px 20px 22px;
  color: white;
  background:
    radial-gradient(circle at 20% 8%, rgba(123, 174, 78, 0.24), transparent 30%),
    var(--forest);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 69px;
  padding: 0 5px;
  color: white;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-copy {
  min-width: 0;
  line-height: 1.08;
}

.brand-copy small,
.brand-copy strong {
  display: block;
}

.brand-copy small {
  margin-bottom: 4px;
  color: #b9cdb3;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-copy strong {
  color: #c1df91;
  font-size: 15px;
}

.brand-logo {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-logo {
  width: 48px;
  height: 68px;
  filter: drop-shadow(0 7px 10px rgba(4, 28, 21, 0.26));
}

.auth-logo {
  width: 53px;
  height: 72px;
  padding: 4px;
  border-radius: 13px;
  background: #f4f8ef;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin-top: 52px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px 14px;
  color: #b7c9c2;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: 0.2s ease;
}

.nav-item svg {
  width: 19px;
}

.nav-item:hover,
.nav-item.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
  box-shadow: inset 3px 0 #8ebd56;
}

.sidebar-note {
  margin-top: auto;
  padding: 17px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.note-icon {
  display: grid;
  width: 31px;
  height: 31px;
  margin-bottom: 11px;
  place-items: center;
  border-radius: 9px;
  color: #8ae0c3;
  background: rgba(88, 195, 159, 0.16);
}

.note-icon svg {
  width: 18px;
}

.sidebar-note strong {
  font-size: 12px;
}

.sidebar-note p {
  margin: 6px 0 0;
  color: #9eb3ab;
  font-size: 10px;
  line-height: 1.5;
}

.backup-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  color: #c8d8d2;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 10px;
  font-weight: 600;
  text-align: left;
}

.backup-button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.07);
}

.backup-button svg {
  width: 16px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 17px 5px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-footer > div {
  min-width: 0;
  flex: 1;
}

.sidebar-footer strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  color: #9bb0a8;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.logout-button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.logout-button svg {
  width: 16px;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: #dff5ed;
  background: #285347;
  font-size: 11px;
  font-weight: 800;
}

.sidebar-footer strong,
.sidebar-footer small {
  display: block;
}

.sidebar-footer strong {
  font-size: 11px;
}

.sidebar-footer small {
  margin-top: 3px;
  color: #91a89f;
  font-size: 9px;
}

.mobile-overlay {
  display: none;
}

.main-content {
  min-height: 100vh;
  margin-left: 252px;
  padding: 42px clamp(26px, 4vw, 64px) 56px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 35px;
  padding: 0 11px;
  color: var(--green-dark);
  border: 1px solid #cfe7dd;
  border-radius: 999px;
  background: #f1faf6;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.sync-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 135, 107, 0.12);
}

.sync-status.offline {
  color: #936614;
  border-color: #f0dbac;
  background: var(--amber-soft);
}

.sync-status.offline > span {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(217, 154, 43, 0.12);
}

.topbar-title {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(28px, 3vw, 36px);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.mobile-menu {
  display: none;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 43px;
  padding: 0 17px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  transition: 0.2s ease;
}

.primary-button {
  color: white;
  border: 1px solid var(--green);
  background: var(--green);
  box-shadow: 0 8px 18px rgba(22, 135, 107, 0.2);
}

.primary-button:hover {
  border-color: var(--green-dark);
  background: var(--green-dark);
  transform: translateY(-1px);
}

.primary-button > span {
  font-size: 23px;
  font-weight: 400;
  line-height: 0;
}

.primary-button svg,
.secondary-button svg {
  width: 17px;
}

.secondary-button {
  color: #52625b;
  border: 1px solid var(--line);
  background: white;
}

.secondary-button:hover {
  color: var(--ink);
  border-color: #c5d2cc;
  background: #fafcfb;
}

.danger-button {
  color: white;
  border: 1px solid var(--red);
  background: var(--red);
}

.period-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 31px;
  padding: 13px 16px;
  border: 1px solid #dce8e2;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.period-bar > div {
  display: flex;
  align-items: center;
  gap: 11px;
}

.calendar-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  color: var(--green);
  background: var(--green-soft);
}

.calendar-icon svg {
  width: 18px;
}

.period-bar small,
.period-bar strong {
  display: block;
}

.period-bar small {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
}

.period-bar strong {
  font-size: 12px;
}

.period-bar input {
  min-height: 35px;
  padding: 0 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: white;
  font-size: 11px;
}

.period-filters {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.church-filter-wrap {
  display: grid;
  gap: 4px;
}

.church-filter-wrap > span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.church-filter-wrap select {
  min-width: 180px;
  min-height: 35px;
  padding: 0 28px 0 10px;
  border-radius: 8px;
  font-size: 10px;
}

.migration-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 22px;
  padding: 15px 17px;
  border: 1px solid #eed59b;
  border-radius: 12px;
  background: #fffaed;
}

.migration-banner strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
}

.migration-banner p {
  margin: 0;
  color: #806b3b;
  font-size: 9px;
}

.migration-banner .primary-button {
  min-height: 37px;
  flex: 0 0 auto;
  font-size: 10px;
}

.period-bar input:focus {
  border-color: #79b9a4;
  box-shadow: 0 0 0 3px rgba(22, 135, 107, 0.09);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin: 18px 0 22px;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 120px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(28, 64, 52, 0.045);
}

.summary-card.balance-card {
  position: relative;
  border-color: #cfe3da;
}

.summary-card.balance-card::after {
  position: absolute;
  top: -32px;
  right: -32px;
  width: 95px;
  height: 95px;
  border-radius: 50%;
  background: #eef7f3;
  content: "";
}

.summary-icon {
  display: grid;
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
}

.summary-icon svg {
  width: 21px;
}

.summary-icon.balance {
  color: var(--green);
  background: var(--green-soft);
}

.summary-icon.income {
  color: var(--blue);
  background: var(--blue-soft);
}

.summary-icon.expense {
  color: var(--red);
  background: var(--red-soft);
}

.summary-icon.records {
  color: var(--amber);
  background: var(--amber-soft);
}

.summary-card p,
.summary-card span {
  color: var(--muted);
}

.summary-card p {
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 700;
}

.summary-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-bottom: 3px;
  font-size: clamp(18px, 1.7vw, 24px);
  letter-spacing: -0.035em;
  white-space: nowrap;
}

.summary-card span {
  font-size: 9px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 18px;
  align-items: start;
}

.transactions-panel,
.categories-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  box-shadow: var(--shadow);
}

.transactions-panel {
  min-height: 420px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 21px 23px;
  border-bottom: 1px solid var(--line);
}

.panel-heading.compact {
  padding: 21px;
}

.panel-heading h2 {
  margin-bottom: 4px;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 10px;
}

.export-button {
  min-height: 37px;
  padding: 0 12px;
  font-size: 10px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 155px;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.search-box:focus-within {
  border-color: #79b9a4;
  box-shadow: 0 0 0 3px rgba(22, 135, 107, 0.08);
}

.search-box svg {
  width: 16px;
  flex: 0 0 auto;
  color: #84938c;
}

.search-box input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 10px;
}

select {
  color: #52625b;
  border: 1px solid var(--line);
  outline: 0;
  background: white;
}

.filters select {
  min-width: 0;
  padding: 0 28px 0 10px;
  border-radius: 8px;
  font-size: 10px;
}

.filters select:focus,
.field select:focus {
  border-color: #79b9a4;
  box-shadow: 0 0 0 3px rgba(22, 135, 107, 0.08);
}

.transactions-table {
  width: 100%;
  border-collapse: collapse;
}

.transactions-table th {
  padding: 12px 18px;
  color: #87958f;
  background: #fafcfb;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

.transactions-table th.value-column,
.transactions-table td.value-column {
  text-align: right;
}

.transactions-table td {
  padding: 15px 18px;
  border-top: 1px solid #edf1ef;
  font-size: 10px;
  vertical-align: middle;
}

.transactions-table tbody tr {
  transition: background 0.2s ease;
}

.transactions-table tbody tr:hover {
  background: #fbfdfc;
}

.description-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 190px;
}

.transaction-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
}

.transaction-icon svg {
  width: 17px;
}

.transaction-icon.entrada {
  color: var(--blue);
  background: var(--blue-soft);
}

.transaction-icon.saida {
  color: var(--red);
  background: var(--red-soft);
}

.description-cell strong,
.description-cell small {
  display: block;
}

.description-cell strong {
  max-width: 250px;
  margin-bottom: 3px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.description-cell small,
.payment-cell small {
  color: var(--muted);
  font-size: 9px;
}

.category-badge {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  color: #486158;
  background: #f0f5f2;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.value {
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.value.entrada {
  color: var(--blue);
}

.value.saida {
  color: var(--red);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 3px;
}

.table-action {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  color: #72817a;
  border: 0;
  border-radius: 7px;
  background: transparent;
}

.table-action:hover {
  color: var(--green);
  background: var(--green-soft);
}

.table-action.delete:hover {
  color: var(--red);
  background: var(--red-soft);
}

.table-action svg {
  width: 14px;
}

.empty-state {
  display: grid;
  min-height: 300px;
  padding: 42px 20px;
  place-items: center;
  text-align: center;
}

.empty-illustration {
  display: grid;
  width: 72px;
  height: 72px;
  margin: 0 auto 17px;
  place-items: center;
  border-radius: 21px;
  color: var(--green);
  background: var(--green-soft);
  transform: rotate(-4deg);
}

.empty-illustration svg {
  width: 35px;
  transform: rotate(4deg);
}

.empty-state h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.empty-state p {
  max-width: 360px;
  margin: 0 auto 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.empty-state .primary-button {
  min-height: 39px;
  font-size: 10px;
}

.no-results {
  padding: 58px 20px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.categories-panel {
  min-height: 320px;
}

.category-summary-list {
  display: grid;
  gap: 18px;
  padding: 21px;
}

.category-summary-item {
  display: grid;
  gap: 7px;
}

.category-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-summary-header span {
  max-width: 145px;
  overflow: hidden;
  color: #42544c;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-summary-header strong {
  font-size: 9px;
  white-space: nowrap;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f0;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e1636c, var(--red));
}

.category-total {
  padding: 15px 21px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
}

.category-total strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 17px;
}

.categories-empty {
  display: grid;
  min-height: 245px;
  padding: 28px;
  place-items: center;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.drawer-backdrop,
.modal-backdrop,
.admin-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
  opacity: 0;
  background: rgba(8, 27, 21, 0.48);
  backdrop-filter: blur(2px);
  transition: 0.25s ease;
}

.drawer-backdrop.open,
.modal-backdrop.open,
.admin-backdrop.open {
  visibility: visible;
  opacity: 1;
}

.admin-backdrop {
  z-index: 75;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-modal {
  width: min(760px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 17px;
  background: white;
  box-shadow: 0 24px 70px rgba(8, 27, 21, 0.23);
  transform: translateY(12px) scale(0.985);
  transition: 0.25s ease;
}

.admin-backdrop.open .admin-modal {
  transform: translateY(0) scale(1);
}

.admin-modal .drawer-header {
  padding: 24px 26px 20px;
}

.churches-list {
  max-height: calc(100vh - 180px);
  padding: 8px 26px 26px;
  overflow-y: auto;
}

.church-row {
  display: grid;
  grid-template-columns: 42px minmax(160px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.church-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 10px;
  font-weight: 800;
}

.church-name-input {
  min-width: 0;
  min-height: 38px;
  padding: 0 11px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  font-size: 10px;
}

.church-name-input:focus {
  border-color: #79b9a4;
  box-shadow: 0 0 0 3px rgba(22, 135, 107, 0.08);
}

.church-row .secondary-button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 9px;
}

.church-row-actions {
  display: flex;
  gap: 6px;
}

.church-active {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.church-active input {
  accent-color: var(--green);
}

.new-code-box {
  grid-column: 2 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #715216;
  background: var(--amber-soft);
  font-size: 9px;
}

.new-code-box strong {
  font-size: 16px;
  letter-spacing: 0.18em;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  padding: 24px;
  overflow-y: auto;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(125, 176, 76, 0.24), transparent 30%),
    linear-gradient(145deg, #0e3424, #1c5136);
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(470px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  background: white;
  box-shadow: 0 28px 80px rgba(4, 24, 18, 0.32);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 29px;
  padding-bottom: 21px;
  border-bottom: 1px solid var(--line);
}

.auth-brand strong,
.auth-brand small {
  display: block;
}

.auth-brand strong {
  margin-bottom: 3px;
  color: var(--green-dark);
  font-size: 15px;
  letter-spacing: -0.02em;
}

.auth-brand small {
  color: var(--muted);
  font-size: 9px;
}

.auth-loading {
  display: grid;
  min-height: 180px;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 10px;
}

.auth-loading p {
  margin: 0;
}

.loading-ring {
  width: 31px;
  height: 31px;
  border: 3px solid #dce9e4;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-form h1,
.access-codes-panel h1 {
  margin-bottom: 8px;
  font-size: 25px;
}

.auth-intro {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.login-role-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.login-role-control input {
  position: absolute;
  opacity: 0;
}

.login-role-control span {
  display: grid;
  min-height: 41px;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fafcfb;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.login-role-control input:checked + span {
  color: var(--green-dark);
  border-color: #91c5b4;
  background: var(--green-soft);
}

.auth-error {
  min-height: 16px;
  margin: -5px 0 8px;
  color: var(--red);
  font-size: 9px;
}

.auth-submit {
  width: 100%;
}

.codes-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 360px;
  padding-right: 4px;
  overflow-y: auto;
}

.code-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fafcfb;
}

.code-item span,
.code-item strong {
  display: block;
}

.code-item span {
  margin-bottom: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-item strong {
  color: var(--green-dark);
  font-size: 15px;
  letter-spacing: 0.12em;
}

.codes-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
}

.form-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 60;
  width: min(590px, 100%);
  padding: 30px 38px;
  overflow-y: auto;
  visibility: hidden;
  background: white;
  box-shadow: -18px 0 45px rgba(17, 49, 39, 0.15);
  transform: translateX(100%);
  transition: 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.form-drawer.open {
  visibility: visible;
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  margin-bottom: 5px;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.drawer-header > div > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

.icon-button {
  display: grid;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  place-items: center;
  color: #617168;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.icon-button:hover {
  color: var(--ink);
  background: #f6f9f7;
}

.icon-button svg {
  width: 17px;
}

.type-fieldset {
  margin: 23px 0 21px;
  padding: 0;
  border: 0;
}

.type-fieldset legend {
  margin-bottom: 9px;
  font-size: 11px;
  font-weight: 700;
}

.type-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfb;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}

.type-option svg {
  width: 18px;
}

.income-option input:checked + span {
  color: var(--blue);
  border-color: #9fbeef;
  background: var(--blue-soft);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.06);
}

.expense-option input:checked + span {
  color: var(--red);
  border-color: #efafb4;
  background: var(--red-soft);
  box-shadow: 0 0 0 3px rgba(211, 75, 85, 0.06);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.field {
  margin-bottom: 17px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: #34463e;
  font-size: 10px;
  font-weight: 700;
}

.field label span {
  color: #91a098;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: white;
  font-size: 11px;
  transition: 0.2s ease;
}

.field input,
.field select {
  min-height: 42px;
}

.field textarea {
  min-height: 82px;
  padding-top: 11px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field textarea:focus {
  border-color: #79b9a4;
  box-shadow: 0 0 0 3px rgba(22, 135, 107, 0.08);
}

.field small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
}

.money-input {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  transition: 0.2s ease;
}

.money-input:focus-within {
  border-color: #79b9a4;
  box-shadow: 0 0 0 3px rgba(22, 135, 107, 0.08);
}

.money-input span {
  padding-left: 12px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.money-input input {
  min-width: 0;
  border: 0;
  box-shadow: none;
}

.money-input input:focus {
  box-shadow: none;
}

.form-actions {
  position: sticky;
  bottom: -30px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin: 8px -38px -30px;
  padding: 17px 38px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.modal-backdrop {
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}

.confirm-modal {
  width: min(370px, 100%);
  padding: 30px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 24px 65px rgba(8, 27, 21, 0.22);
  text-align: center;
  transform: translateY(10px) scale(0.98);
  transition: 0.25s ease;
}

.modal-backdrop.open .confirm-modal {
  transform: translateY(0) scale(1);
}

.danger-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 14px;
  color: var(--red);
  background: var(--red-soft);
}

.danger-icon svg {
  width: 22px;
}

.confirm-modal h3 {
  margin-bottom: 7px;
  font-size: 17px;
}

.confirm-modal p {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 11px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
}

.toast {
  position: fixed;
  right: 25px;
  bottom: 25px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(350px, calc(100% - 32px));
  padding: 15px 17px;
  visibility: hidden;
  opacity: 0;
  border: 1px solid #cde6dc;
  border-radius: 12px;
  background: white;
  box-shadow: 0 18px 45px rgba(17, 55, 42, 0.17);
  transform: translateY(16px);
  transition: 0.25s ease;
}

.toast.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.toast-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--green);
  font-size: 14px;
  font-weight: 800;
}

.toast strong,
.toast p {
  display: block;
}

.toast strong {
  margin-bottom: 3px;
  font-size: 11px;
}

.toast p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
}

.mobile-add-button {
  display: none;
}

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .categories-panel {
    order: -1;
    min-height: 0;
  }

  .category-summary-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-total {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 220px;
  }

  .main-content {
    margin-left: 220px;
    padding-right: 24px;
    padding-left: 24px;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .search-box {
    grid-column: 1 / -1;
  }

  .transactions-table th:nth-child(3),
  .transactions-table td:nth-child(3) {
    display: none;
  }
}

@media (max-width: 700px) {
  .sidebar {
    width: min(290px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    visibility: hidden;
    opacity: 0;
    background: rgba(8, 27, 21, 0.45);
    transition: 0.25s ease;
  }

  .mobile-overlay.open {
    visibility: visible;
    opacity: 1;
  }

  .main-content {
    margin-left: 0;
    padding: 24px 16px 92px;
  }

  .mobile-menu {
    display: grid;
  }

  .topbar {
    align-items: center;
  }

  .topbar .eyebrow,
  .topbar .subtitle {
    display: none;
  }

  h1 {
    margin: 5px 0 0;
    font-size: 23px;
  }

  .top-action {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .sync-status {
    width: 35px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .period-bar {
    margin-top: 22px;
  }

  .period-filters {
    align-items: stretch;
  }

  .church-filter-wrap select {
    min-width: 150px;
  }

  .migration-banner {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .summary-card {
    min-height: 108px;
    padding: 15px;
  }

  .summary-icon {
    width: 38px;
    height: 38px;
  }

  .summary-card strong {
    font-size: clamp(16px, 4.6vw, 21px);
  }

  .content-grid {
    gap: 14px;
  }

  .category-summary-list {
    grid-template-columns: 1fr 1fr;
  }

  .panel-heading {
    padding: 18px;
  }

  .filters {
    padding: 12px;
  }

  .transactions-table,
  .transactions-table tbody,
  .transactions-table tr,
  .transactions-table td {
    display: block;
    width: 100%;
  }

  .transactions-table thead {
    display: none;
  }

  .transactions-table tbody {
    padding: 4px 14px 14px;
  }

  .transactions-table tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 14px;
    margin-top: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
  }

  .transactions-table td {
    padding: 0;
    border: 0;
  }

  .transactions-table td:nth-child(1) {
    grid-column: 1 / -1;
  }

  .transactions-table td:nth-child(2),
  .transactions-table td:nth-child(3) {
    display: block;
  }

  .transactions-table td:nth-child(4) {
    align-self: center;
  }

  .transactions-table td.value-column {
    align-self: center;
    text-align: right;
  }

  .transactions-table td:last-child {
    position: absolute;
    top: 10px;
    right: 8px;
  }

  .description-cell {
    min-width: 0;
    padding-right: 58px;
  }

  .description-cell strong {
    max-width: 45vw;
  }

  .payment-cell::before {
    display: block;
    margin-bottom: 3px;
    color: #93a098;
    content: "Pagamento";
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .category-badge {
    font-size: 8px;
  }

  .value {
    font-size: 12px;
  }

  .mobile-add-button {
    position: fixed;
    right: 19px;
    bottom: 19px;
    z-index: 20;
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    color: white;
    border: 0;
    border-radius: 18px;
    background: var(--green);
    box-shadow: 0 12px 30px rgba(16, 91, 71, 0.32);
  }

  .mobile-add-button span {
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
  }

  .form-drawer {
    padding: 24px 20px;
  }

  .admin-backdrop {
    padding: 12px;
  }

  .admin-modal {
    max-height: calc(100vh - 24px);
  }

  .admin-modal .drawer-header {
    padding: 20px;
  }

  .churches-list {
    max-height: calc(100vh - 140px);
    padding: 6px 20px 20px;
  }

  .church-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
  }

  .church-active {
    grid-column: 2;
  }

  .church-row-actions {
    grid-column: 3;
    grid-row: 1;
  }

  .new-code-box {
    grid-column: 2 / -1;
  }

  .form-actions {
    bottom: -24px;
    margin: 8px -20px -24px;
    padding: 15px 20px 18px;
  }

  .toast {
    right: 16px;
    bottom: 86px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar-title {
    gap: 11px;
  }

  .period-bar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px;
  }

  .period-bar small {
    display: none;
  }

  .period-bar input {
    width: 100%;
  }

  .period-filters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .church-filter-wrap select {
    width: 100%;
    min-width: 0;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 92px;
  }

  .summary-card strong {
    font-size: 21px;
  }

  .categories-panel {
    display: none;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .search-box {
    grid-column: auto;
  }

  .filters select {
    min-height: 38px;
  }

  .export-button {
    width: 37px;
    padding: 0;
    font-size: 0;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
  }

  .form-actions button {
    padding: 0 10px;
  }

  .auth-screen {
    padding: 12px;
    place-items: start center;
  }

  .auth-card {
    margin: 12px 0;
    padding: 23px 19px;
  }

  .codes-list {
    grid-template-columns: 1fr;
  }

  .codes-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .church-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .church-row-actions {
    grid-column: 2;
    grid-row: auto;
    flex-wrap: wrap;
  }

  .church-active,
  .new-code-box {
    grid-column: 2;
  }
}

@media print {
  .sidebar,
  .topbar,
  .period-bar input,
  .filters,
  .export-button,
  .row-actions,
  .mobile-add-button {
    display: none !important;
  }

  .main-content {
    margin: 0;
    padding: 20px;
  }

  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .categories-panel {
    display: none;
  }

  .transactions-panel,
  .summary-card {
    box-shadow: none;
  }
}
