:root {
  --navy: #071340;
  --sidebar: #073c7d;
  --sidebar-deep: #042553;
  --blue: #1769e8;
  --sky: #38a5d6;
  --green: #1fa978;
  --red: #e03b3b;
  --purple: #7651cf;
  --amber: #f0a51f;
  --slate: #64748b;
  --ink: #07133d;
  --muted: #52607c;
  --line: #dfe6f1;
  --soft: #f5f8fc;
  --white: #ffffff;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.07);
  --card-shadow: 0 10px 25px rgba(18, 31, 67, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% 8%, rgba(55, 122, 237, 0.07), transparent 32%),
    #f7f9fd;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(7, 60, 125, 0.94), rgba(4, 37, 83, 0.98)),
    #042553;
}

.login-card {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(300px, 420px);
  width: min(860px, 100%);
  min-height: 520px;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.login-brand {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 34px;
  color: #fff;
  text-align: center;
  background:
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.16), transparent 32%),
    linear-gradient(160deg, #0d5ab0, #05275a);
}

.login-brand .brand-mark {
  transform: scale(1.5);
  margin-bottom: 22px;
}

.login-brand strong {
  display: block;
  font-size: 30px;
  line-height: 1.15;
}

.login-brand span {
  display: block;
  margin-top: 8px;
  font-size: 17px;
  opacity: 0.92;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 42px;
}

.login-form h1 {
  margin: 0;
  font-size: 30px;
}

.login-form p {
  margin: -6px 0 8px;
  color: var(--muted);
}

.login-form small {
  color: var(--muted);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.remember-row input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.login-error {
  min-height: 20px;
  color: #c52828;
  font-weight: 800;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 16px;
  color: #fff;
  background:
    linear-gradient(155deg, rgba(11, 77, 148, 0.92), rgba(4, 39, 88, 0.98) 55%, #031b3f),
    linear-gradient(45deg, rgba(255, 255, 255, 0.12), transparent);
  overflow-y: auto;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.app-shell.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.brand {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
  padding: 0 4px;
}

.brand strong {
  display: block;
  font-size: 23px;
  line-height: 1.15;
}

.brand span {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
}

.brand-mark {
  position: relative;
  width: 68px;
  height: 72px;
}

.church-roof {
  position: absolute;
  left: 4px;
  top: 25px;
  width: 58px;
  height: 38px;
  background: #fff;
  clip-path: polygon(50% 0, 100% 45%, 85% 45%, 85% 100%, 15% 100%, 15% 45%, 0 45%);
}

.church-body::before,
.church-body::after {
  content: "";
  position: absolute;
  background: #fff;
}

.church-body::before {
  left: 31px;
  top: 4px;
  width: 8px;
  height: 34px;
}

.church-body::after {
  left: 22px;
  top: 14px;
  width: 26px;
  height: 8px;
}

.church-wave {
  position: absolute;
  left: 5px;
  bottom: 0;
  width: 58px;
  height: 18px;
  border-top: 7px solid #fff;
  border-radius: 50%;
  transform: rotate(10deg);
}

.nav-list {
  display: grid;
  gap: 9px;
}

.nav-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  min-height: 56px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  color: #eef6ff;
  background: transparent;
  text-align: left;
  font-size: 17px;
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(135deg, #1f7cff, #1260d5);
  box-shadow: 0 14px 28px rgba(7, 52, 131, 0.34);
}

.nav-item.locked {
  opacity: 0.48;
}

.nav-item.locked:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #fff;
  line-height: 1;
}

.icon svg,
.metric-icon svg,
.qa svg,
.menu-button svg,
.notify-button svg,
.mailbox-button svg,
.profile-button svg,
.profile-avatar svg,
.secondary-button svg,
.primary-button svg,
.icon-button svg,
.date-range svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main {
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.2;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.menu-button,
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--navy);
  background: transparent;
  font-size: 24px;
}

.menu-button:hover,
.icon-button:hover {
  background: var(--soft);
}

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

.date-range {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  box-shadow: var(--card-shadow);
}

.date-range input {
  width: 136px;
  border: 0;
  color: var(--navy);
  background: transparent;
  font-weight: 700;
}

.notification-wrap,
.profile-wrap {
  position: relative;
}

.notify-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--navy);
  background: #fff;
  box-shadow: var(--card-shadow);
  font-size: 20px;
}

.mailbox-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--navy);
  background: #fff;
  box-shadow: var(--card-shadow);
  font-size: 20px;
}

.install-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: #fff;
  box-shadow: var(--card-shadow);
  font-weight: 800;
}

.install-button[hidden] {
  display: none;
}

.install-button:hover {
  border-color: #b8c8e2;
  background: #f6f9ff;
}

.mailbox-button:hover {
  border-color: #b8c8e2;
  background: #f6f9ff;
}

.notify-button:hover,
.notify-button[aria-expanded="true"] {
  border-color: #b8c8e2;
  background: #f6f9ff;
}

.notify-button b {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: #e03b3b;
  font-size: 11px;
  font-weight: 900;
}

.notification-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  z-index: 30;
  width: min(390px, calc(100vw - 32px));
  max-height: 480px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.14);
}

.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.notification-list {
  display: grid;
  gap: 10px;
  max-height: 380px;
  margin-top: 12px;
  overflow-y: auto;
}

.notification-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.notification-item.unread {
  border-color: #b7cdf6;
  background: #f3f7ff;
}

.notification-item strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.notification-item span,
.notification-list .empty {
  color: var(--muted);
  font-size: 12px;
}

.profile-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--navy);
  background: #fff;
  box-shadow: var(--card-shadow);
  font-size: 21px;
}

.profile-button:hover,
.profile-button[aria-expanded="true"] {
  border-color: #b8c8e2;
  background: #f6f9ff;
}

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  z-index: 30;
  width: 310px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.14);
}

.profile-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: var(--blue);
  background: #e8f1ff;
  font-size: 22px;
}

.profile-card strong,
.profile-card span {
  display: block;
}

.profile-card span,
.profile-menu dt {
  color: var(--muted);
  font-size: 12px;
}

.profile-menu dl {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.profile-menu dl div {
  display: grid;
  gap: 3px;
}

.profile-menu dt,
.profile-menu dd {
  margin: 0;
}

.profile-menu dd {
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.profile-menu .secondary-button {
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.view {
  display: none;
  padding: 28px;
}

.view.active {
  display: block;
}

.metric-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 21px;
  margin-bottom: 28px;
}

.metric-card,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--card-shadow);
}

.metric-card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  min-height: 150px;
  padding: 22px;
}

.metric-card p,
.statement-card span {
  margin: 0 0 10px;
  color: var(--navy);
}

.metric-card strong,
.statement-card strong {
  display: block;
  font-size: clamp(22px, 1.7vw, 28px);
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.metric-card small {
  display: block;
  margin-top: 14px;
  color: var(--muted);
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  font-size: 34px;
  font-weight: 700;
}

.green .metric-icon,
.qa.green {
  color: var(--green);
  background: #dff5eb;
}

.red .metric-icon,
.qa.red {
  color: var(--red);
  background: #fee5e5;
}

.blue .metric-icon,
.qa.blue {
  color: var(--blue);
  background: #e1efff;
}

.purple .metric-icon,
.qa.purple {
  color: var(--purple);
  background: #eee7ff;
}

.qa.amber {
  color: var(--amber);
  background: #fff4d6;
}

.qa.slate {
  color: var(--slate);
  background: #edf2f7;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 24px;
}

@media (min-width: 1501px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(390px, 0.82fr);
  }

  .dashboard-wide-panel {
    grid-column: 1 / -1;
  }

  .quick-actions-panel .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .quick-actions-panel .quick-action {
    min-height: 92px;
    padding: 10px 7px;
    font-size: 12px;
  }

  .quick-actions-panel .qa {
    width: 40px;
    height: 40px;
  }

  .dashboard-chart-panel .chart-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    justify-items: center;
  }

  .dashboard-chart-panel .donut {
    width: 190px;
  }

  .dashboard-chart-panel .legend-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
    width: 100%;
  }

  .dashboard-chart-panel .legend-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
    min-height: 38px;
    font-size: 12px;
  }

  .dashboard-chart-panel .legend-row span:last-child {
    display: none;
  }
}

.trend-panel {
  grid-column: 1 / -1;
}

.monthly-profit-panel {
  grid-column: 1 / -1;
}

.monthly-profit-panel .panel-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#monthlyProfitTotal {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4f7fb;
  font-size: 15px;
}

.profit-table {
  min-width: 720px;
}

.profit-positive {
  color: #14805e;
}

.profit-negative {
  color: #c53030;
}

.trend-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.trend-status > span {
  display: grid;
  grid-template-columns: 22px auto;
  align-items: center;
  column-gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.trend-status svg {
  grid-row: 1 / span 2;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.trend-status small {
  color: var(--muted);
  font-size: 11px;
}

.trend-status .trend-up { color: #15805f; background: #effaf6; border-color: #bfe7d8; }
.trend-status .trend-down { color: #c53030; background: #fff5f5; border-color: #f2c5c5; }
.trend-status .trend-neutral { color: var(--slate); }

.trend-chart {
  width: 100%;
  min-height: 260px;
  overflow: hidden;
}

.trend-chart svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
}

.trend-grid line { stroke: #e3e9f2; stroke-width: 1; }
.trend-grid text,
.trend-labels text { fill: #64748b; font-size: 13px; }
.trend-grid text { text-anchor: end; }
.trend-path { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.trend-path.income { stroke: #1a9b71; }
.trend-path.expense { stroke: #dc3b3b; }
.trend-point { stroke: #fff; stroke-width: 3; }
.trend-point.income { fill: #1a9b71; }
.trend-point.expense { fill: #dc3b3b; }

.trend-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  color: var(--muted);
  font-size: 13px;
}

.trend-legend span { display: inline-flex; align-items: center; gap: 7px; }
.trend-legend i { width: 24px; height: 3px; border-radius: 2px; }
.trend-legend .income-line { background: #1a9b71; }
.trend-legend .expense-line { background: #dc3b3b; }
.trend-empty { display: grid; min-height: 260px; place-items: center; color: var(--muted); }

.panel {
  padding: 22px;
}

.panel-header,
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h2 {
  margin: 0;
  font-size: 20px;
}

.panel-header select {
  max-width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--navy);
  background: #fff;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(260px, 1fr);
  gap: 24px;
  align-items: center;
}

.donut {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0deg, var(--blue) 0deg);
}

.donut::after {
  content: "";
  position: absolute;
  width: 48%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut span {
  position: relative;
  z-index: 1;
  width: 46%;
  text-align: center;
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.donut span b {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.2;
}

.legend-list {
  display: grid;
}

.legend-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  color: var(--navy);
}

.legend-row strong,
.legend-row span:last-child {
  white-space: nowrap;
}

.legend-row span:nth-child(2) {
  min-width: 0;
  overflow-wrap: anywhere;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--navy);
  font-weight: 800;
}

td {
  color: #1d2b55;
}

.amount {
  text-align: right;
  font-weight: 800;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.type-pill.in {
  color: #0e7b53;
  background: #e2f6ef;
}

.type-pill.out {
  color: #bd2525;
  background: #fee7e7;
}

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

.table-action {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.table-action:hover {
  border-color: #b8c8e2;
  background: #f6f9ff;
}

.table-action.danger {
  color: #bd2525;
}

.table-action.danger:hover {
  border-color: #f2b8b8;
  background: #fff5f5;
}

.quick-grid,
.category-grid,
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 16px;
}

.roles-panel {
  margin-bottom: 24px;
}

.role-form {
  display: grid;
  gap: 18px;
}

.role-form-head {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.role-form-head strong {
  color: var(--navy);
  font-size: 16px;
}

.role-form-head span {
  color: var(--muted);
  font-size: 13px;
}

.permission-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.permission-editor fieldset {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.permission-editor .actions-fieldset,
.permission-editor fieldset:has(#roleActionPermissions) {
  grid-column: 1 / -1;
}

.permission-editor legend {
  padding: 0 6px;
  color: var(--navy);
  font-weight: 900;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.permission-section {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.permission-section h3 {
  margin: 0;
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 900;
}

.permission-section-wide {
  grid-column: 1 / -1;
}

#roleActionPermissions {
  grid-template-columns: minmax(0, 1fr);
}

#roleActionPermissions .permission-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.permission-ministry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(210px, 1fr));
  gap: 10px;
}

.permission-ministry-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.permission-ministry-row strong {
  color: var(--navy);
  font-size: 0.92rem;
}

.permission-ministry-row small {
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 980px) {
  #roleActionPermissions .permission-grid,
  .permission-ministry-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 640px) {
  #roleActionPermissions .permission-grid,
  .permission-ministry-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--ink);
  font-weight: 600;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.role-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.role-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.role-card strong {
  display: block;
}

.role-card span {
  color: var(--muted);
  font-size: 13px;
}

button[hidden],
[hidden] {
  display: none !important;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 1500px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

@media (min-width: 1181px) and (max-width: 1680px) {
  .app-shell:not(.sidebar-collapsed) .metric-grid,
  .app-shell:not(.sidebar-collapsed) .summary-grid {
    grid-template-columns: repeat(2, minmax(270px, 1fr));
  }
}

@media (max-width: 780px) {
  .chart-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.quick-action,
.category-card,
.user-card {
  min-height: 112px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--navy);
  background: #fff;
}

.quick-action {
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  font-size: 13px;
}

.quick-action:hover,
.category-card:hover {
  border-color: #b8c8e2;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
}

.quick-action.locked {
  color: #7b8797;
  background: #f2f5f9;
  border-color: #d7dee8;
  cursor: not-allowed;
  opacity: 0.72;
}

.quick-action.locked:hover {
  border-color: #d7dee8;
  box-shadow: none;
}

.quick-action.locked .qa {
  color: #7b8797;
  background: #e3e8ef;
  filter: grayscale(1);
}

.qa {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  font-size: 24px;
}

.section-head {
  margin-bottom: 22px;
}

.module-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--card-shadow);
}

.module-hero div {
  display: grid;
  gap: 6px;
}

.module-hero span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.module-hero h2,
.module-hero p {
  margin: 0;
}

.module-hero h2 {
  font-size: 24px;
}

.module-hero p {
  max-width: 680px;
  color: var(--muted);
}

.income-hero {
  border-left: 4px solid var(--green);
}

.ministry-hero {
  border-left: 4px solid var(--purple);
}

.expense-hero {
  border-left: 4px solid var(--red);
}

.national-hero {
  border-left: 4px solid var(--blue);
}

.loan-hero {
  border-left: 4px solid var(--slate);
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.module-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.search-box {
  position: relative;
  display: block;
}

.search-box span {
  position: absolute;
  left: 14px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-box input {
  min-height: 48px;
  padding-left: 42px;
  box-shadow: var(--card-shadow);
}

.module-total {
  display: grid;
  gap: 3px;
  min-width: 210px;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--card-shadow);
}

.module-total span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.module-total strong {
  color: var(--navy);
  font-size: 18px;
}

.category-grid {
  margin-bottom: 24px;
}

.module-categories {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.category-card {
  display: grid;
  align-content: space-between;
  gap: 14px;
  min-height: 96px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.category-card span,
.user-card span {
  color: var(--muted);
  font-size: 13px;
}

.category-card strong {
  display: block;
  font-size: 22px;
}

.module-table {
  padding: 0;
  overflow: hidden;
}

.module-table .table-wrap {
  max-height: 520px;
}

.module-table table {
  min-width: 800px;
}

.module-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 14px 16px;
  background: #f8fbff;
}

.module-table td {
  padding: 13px 16px;
}

.module-table tbody tr:hover td {
  background: #f8fbff;
}

.console-panel table {
  min-width: 900px;
}

.console-scope {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}

.console-scope.admin {
  background: #fef3c7;
  color: #92400e;
}

.empty-cell {
  padding: 26px 16px;
  color: var(--muted);
  text-align: center;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 22px;
}

.tab,
.ghost-button,
.secondary-button,
.primary-button,
.link-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 16px;
  background: #fff;
  color: var(--navy);
  font-weight: 700;
}

.secondary-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.secondary-button {
  background: var(--soft);
}

.ghost-button,
.link-button {
  color: var(--blue);
}

.ghost-button {
  background: #fff;
  box-shadow: var(--card-shadow);
}

.link-button {
  border: 0;
  padding: 0;
  min-height: auto;
  background: transparent;
}

.tab.active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.statement-card {
  display: grid;
  gap: 10px;
}

.report-builder,
.form-panel,
.printable-report {
  max-width: 980px;
}

.result-sheet {
  width: min(100%, 1420px);
  border: 1px solid #c9d5e7;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.sheet-title {
  display: grid;
  gap: 5px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid #d8e1ef;
  color: #07133d;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.25;
}

.sheet-title strong {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.4px;
}

.sheet-scroll {
  overflow-x: auto;
  background:
    linear-gradient(#e6ebf3 1px, transparent 1px),
    linear-gradient(90deg, #e6ebf3 1px, transparent 1px),
    #fff;
  background-size: 100% 30px, 150px 100%;
  padding: 18px 22px 24px;
}

.statement-table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.94);
  color: #0b122f;
  font-family: "Segoe UI", Arial, sans-serif;
  box-shadow: 0 0 0 1px #b9c6d8;
}

.statement-table th,
.statement-table td {
  height: 30px;
  padding: 4px 8px;
  border: 1px solid #d8dee8;
  color: #0b122f;
  font-size: 15px;
  line-height: 1.2;
}

.statement-table th:first-child,
.statement-table td:first-child {
  width: 45%;
  text-align: left;
}

.statement-table th:not(:first-child),
.statement-table td:not(:first-child) {
  width: 13.75%;
  text-align: right;
  border-left: 2px solid #2b3448;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.statement-table thead th {
  height: 36px;
  border-top: 2px solid #1b2437;
  border-bottom: 2px solid #1b2437;
  background: #f9fbff;
  font-weight: 800;
  vertical-align: middle;
}

.statement-table thead th:first-child {
  color: #fff;
  background: #376da8;
  text-align: left;
}

.sheet-section td:first-child,
.sheet-total td:first-child,
.sheet-grand td:first-child {
  font-weight: 900;
}

.sheet-section td {
  padding-top: 18px;
  font-weight: 900;
  background: rgba(241, 246, 252, 0.75);
}

.sheet-total td,
.sheet-grand td {
  font-weight: 900;
}

.sheet-total td {
  background: #fbfdff;
}

.sheet-grand td {
  border-top: 2px solid #1b2437;
  border-bottom: 2px solid #1b2437;
  background: #eef4fb;
}

.sheet-gap td {
  height: 24px;
  background: transparent;
  border-left-color: transparent;
  border-right-color: transparent;
}

.statement-line {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.statement-line.total {
  font-weight: 800;
}

.statement-line.grand {
  margin-top: 12px;
  padding: 20px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--navy);
  font-size: 21px;
}

.report-heading {
  display: grid;
  gap: 4px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.report-heading h2,
.report-heading p {
  margin: 0;
}

.report-heading p {
  color: var(--muted);
}

.report-total-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
  margin-top: 10px;
}

.printable-report h3 {
  margin: 26px 0 12px;
  font-size: 17px;
}

.report-table {
  min-width: 760px;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 48px;
  margin-top: 52px;
}

.signature-grid span {
  padding-top: 10px;
  border-top: 1px solid #1d2b55;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.report-builder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.report-builder p {
  margin: 8px 0 0;
  color: var(--muted);
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.backup-panel {
  margin-top: 24px;
}

.backup-note {
  margin: -6px 0 16px;
  color: var(--muted);
}

.backup-list {
  display: grid;
  gap: 10px;
}

.backup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.backup-row span {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 700;
}

.backup-row a {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--navy);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

textarea {
  padding: 12px;
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.user-card {
  display: grid;
  gap: 10px;
}

.user-card strong {
  font-size: 18px;
}

.role-badge {
  width: max-content;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--blue);
  background: #e8f1ff;
  font-size: 12px;
  font-weight: 800;
}

.user-delete {
  justify-self: start;
  min-height: 34px;
  padding: 0 12px;
}

.suggestions-panel {
  max-width: 1100px;
}

.suggestion-list {
  display: grid;
  gap: 14px;
}

.suggestion-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.suggestion-card.reviewed {
  background: #f8fafc;
  opacity: 0.78;
}

.suggestion-card span,
.suggestion-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.suggestion-card strong {
  display: block;
  margin-top: 4px;
  color: var(--navy);
  font-size: 17px;
}

.suggestion-card p {
  margin: 8px 0;
  color: #1d2b55;
  line-height: 1.5;
}

.loan-tracker-panel {
  margin-bottom: 24px;
}

.loan-tracker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.loan-account-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.loan-account-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.loan-account-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.loan-account-head strong {
  display: block;
  margin-top: 4px;
  color: var(--navy);
}

.loan-account-head b {
  padding: 5px 9px;
  border-radius: 999px;
  color: #a32929;
  background: #fee7e7;
  font-size: 12px;
}

.loan-account-head b.settled {
  color: #0e7b53;
  background: #e2f6ef;
}

.loan-account-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.loan-account-stats div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.loan-account-stats span,
.loan-payment-list span {
  color: var(--muted);
  font-size: 12px;
}

.loan-account-stats strong {
  color: var(--navy);
}

.loan-payment-list {
  display: grid;
  gap: 6px;
  max-height: 130px;
  overflow-y: auto;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(7, 19, 64, 0.28);
}

dialog::backdrop {
  background: rgba(7, 19, 64, 0.42);
}

.modal-card {
  padding: 24px;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-actions {
  justify-content: flex-end;
  margin: 22px 0 0;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 20;
    width: min(310px, calc(100vw - 24px));
    transform: translateX(-104%);
    transition: transform 0.2s ease;
  }

  .app-shell.sidebar-collapsed .sidebar {
    transform: translateX(-104%);
    opacity: 1;
    pointer-events: auto;
  }

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

  .metric-grid,
  .summary-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    background: #f7f9fd;
  }

  .login-card {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-brand {
    min-height: 170px;
    padding: 26px 22px;
  }

  .login-brand .brand-mark {
    transform: scale(1.12);
    margin-bottom: 10px;
  }

  .login-brand strong {
    font-size: 24px;
  }

  .login-form {
    padding: 28px 22px;
  }

  .topbar {
    position: sticky;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .topbar > div:nth-child(2) {
    min-width: 0;
  }

  .topbar h1 {
    font-size: 20px;
    overflow-wrap: anywhere;
  }

  .topbar p {
    font-size: 13px;
    line-height: 1.35;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr auto repeat(3, 46px);
    gap: 10px;
    width: 100%;
  }

  .view {
    padding: 14px 12px 24px;
  }

  input,
  select,
  textarea,
  button {
    max-width: 100%;
  }

  label {
    min-width: 0;
  }

  .metric-grid,
  .summary-grid,
  .dashboard-grid,
  .chart-layout,
  .quick-grid,
  .category-grid,
  .user-grid,
  .permission-editor,
  .form-grid,
  .module-toolbar,
  .report-total-grid,
  .signature-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .panel {
    padding: 16px;
  }

  .panel-header,
  .section-head {
    align-items: stretch;
    gap: 12px;
  }

  .panel-header > *,
  .section-head > * {
    min-width: 0;
  }

  .section-head .primary-button,
  .section-head .secondary-button,
  .panel-header .primary-button,
  .panel-header .secondary-button {
    width: 100%;
  }

  .module-hero {
    display: grid;
    gap: 14px;
    padding: 16px;
  }

  .module-actions,
  .module-hero .primary-button,
  .module-hero .secondary-button {
    width: 100%;
  }

  .metric-card {
    grid-template-columns: 58px minmax(0, 1fr);
    min-height: auto;
    gap: 14px;
    padding: 16px;
  }

  .metric-icon {
    width: 56px;
    height: 56px;
    font-size: 28px;
  }

  .metric-card strong,
  .statement-card strong {
    font-size: 22px;
  }

  .metric-card small {
    margin-top: 8px;
    font-size: 13px;
  }

  .date-range {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
    padding: 10px 12px;
    min-width: 0;
    width: 100%;
    box-shadow: none;
  }

  .date-range span {
    display: inline;
  }

  .date-range input {
    width: 100%;
    min-width: 0;
  }

  .ghost-button {
    width: auto;
    flex: 0 0 auto;
  }

  .notify-button,
  .mailbox-button,
  .install-button,
  .profile-avatar,
  .menu-button,
  .icon-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .notification-menu,
  .profile-menu {
    position: fixed;
    top: 112px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - 132px);
    overflow-y: auto;
  }

  .chart-layout {
    justify-items: center;
  }

  .trend-header .trend-status,
  .trend-status > span {
    width: 100%;
  }

  .trend-chart {
    min-height: 210px;
    overflow-x: auto;
  }

  .trend-chart svg {
    min-width: 620px;
  }

  .legend-list {
    width: 100%;
  }

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

  .legend-row span:last-child {
    display: none;
  }

  .quick-action {
    min-height: 84px;
  }

  .module-toolbar {
    gap: 10px;
  }

  .module-total {
    min-width: 0;
    width: 100%;
  }

  .module-categories {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-card {
    min-height: 86px;
    padding: 14px;
  }

  .category-card strong {
    font-size: 19px;
    overflow-wrap: anywhere;
  }

  .table-wrap {
    width: 100%;
    margin: 0 -2px;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-action {
    min-height: 34px;
    padding-inline: 10px;
    white-space: nowrap;
  }

  table {
    min-width: 650px;
  }

  .module-table table {
    min-width: 760px;
  }

  th,
  td,
  .module-table th,
  .module-table td {
    padding: 11px 12px;
    font-size: 13px;
  }

  .statement-table {
    min-width: 720px;
  }

  .statement-card {
    min-height: auto;
  }

  .form-panel,
  .printable-report {
    padding: 16px;
  }

  .loan-tracker-grid,
  .roles-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    overflow-y: auto;
  }

  .modal-card {
    padding: 18px;
  }

  .modal-header,
  .modal-actions {
    align-items: stretch;
  }

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

  .modal-actions button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .topbar-actions {
    grid-template-columns: 1fr repeat(3, 42px);
    gap: 8px;
  }

  .install-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .date-range {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .date-range span {
    display: none;
  }

  .ghost-button {
    width: 100%;
  }

  .notification-wrap,
  .profile-wrap {
    justify-self: stretch;
  }

  .notify-button,
  .mailbox-button,
  .profile-avatar {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }

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

  .module-hero h2 {
    font-size: 21px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .tab {
    padding-inline: 12px;
  }

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

  .tab {
    width: 100%;
  }

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

  .login-screen {
    padding: 14px;
  }

  .login-form h1 {
    font-size: 25px;
  }
}

@media print {
  .sidebar,
  .topbar,
  .view:not(#view-reporte),
  .report-builder {
    display: none !important;
  }

  .app-shell,
  .main,
  #view-reporte {
    display: block !important;
    padding: 0;
  }

  .panel {
    box-shadow: none;
  }

  body {
    background: #fff;
  }

  .printable-report {
    max-width: none;
    border: 0;
    padding: 24px;
  }
}
