/* ==========================================================================
   project.css — Shared tokens, sidebar chrome, and reusable components
   Linked first on every HTML page. Visual language follows the CTO dashboard draft.
   ========================================================================== */

:root {
  --primary-color: #2d6a4f;
  --primary-hover: #1b4332;
  --primary-soft: #d8f3dc;
  --secondary-color: #5c6b73;
  --success-color: #2d6a4f;
  --success-soft: #d8f3dc;
  --warning-color: #e76f51;
  --warning-soft: #fde8e1;
  --danger-color: #e11d48;
  --danger-soft: #ffe4e6;
  --info-color: #3b82f6;
  --info-soft: #dbeafe;
  --purple-color: #7c3aed;
  --purple-soft: #ede9fe;
  --teal-color: #0d9488;
  --teal-soft: #ccfbf1;

  --bg-body: #f4f6f5;
  --bg-surface: #ffffff;
  --bg-sidebar: #ffffff;

  --text-primary: #1a1d1a;
  --text-secondary: #5c6b73;
  --text-muted: #8a969c;
  --text-on-dark: #ffffff;

  --border-color: #e6ebe8;
  --border-radius: 0.5rem;
  --border-radius-lg: 0.85rem;

  --shadow-sm: 0 1px 2px rgba(27, 67, 50, 0.05);
  --shadow-md: 0 8px 24px rgba(27, 67, 50, 0.06);
  --shadow-lg: 0 16px 40px rgba(27, 67, 50, 0.08);

  --sidebar-width: 268px;
  --sidebar-collapsed: 76px;
  --topbar-height: 64px;

  --font-family: Arial, "Helvetica Neue", "Microsoft JhengHei", sans-serif;
  --transition-speed: 0.2s;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family) !important;
  color: var(--text-primary);
  background-color: var(--bg-body);
  line-height: 1.6;
  min-height: 100vh;
}

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

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-speed) ease;
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* --------------------------------------------------------------------------
   App shell: sidebar + main column
   -------------------------------------------------------------------------- */

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 1030;
  transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 84px;
  padding: 0.9rem 1.05rem;
  background: linear-gradient(145deg, #f7fcf8 0%, #edf7f0 100%);
  border-bottom: 1px solid #dce9df;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  cursor: default;
}

.app-brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-brand-copy strong {
  color: #183c2e;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.app-brand-ec {
  color: var(--primary-color);
}

.app-brand-copy small {
  color: #40594d;
  font-size: 0.72rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.2rem;
}

.app-brand-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 0.8rem;
  background: linear-gradient(145deg, #2d6a4f, #1b4332);
  color: var(--text-on-dark);
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(27, 67, 50, 0.2);
  overflow: hidden;
}

.app-brand-mark--logo {
  width: 3.85rem;
  height: 3.85rem;
  background: #ffffff;
  padding: 0.05rem;
  box-shadow: 0 4px 12px rgba(27, 67, 50, 0.14);
}

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

.app-brand-church {
  position: absolute;
  left: 0.73rem;
  bottom: 0.42rem;
  width: 1.72rem;
  height: 1.25rem;
  background: #fff;
  border-radius: 0.08rem 0.08rem 0.16rem 0.16rem;
}

.app-brand-steeple {
  position: absolute;
  left: 1.03rem;
  top: 0.79rem;
  width: 0;
  height: 0;
  border-left: 0.57rem solid transparent;
  border-right: 0.57rem solid transparent;
  border-bottom: 0.8rem solid #fff;
}

.app-brand-cross::before,
.app-brand-cross::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.25rem;
  background: #fff;
  border-radius: 1px;
  transform: translateX(-50%);
  z-index: 2;
}

.app-brand-cross::before {
  width: 3px;
  height: 0.75rem;
}

.app-brand-cross::after {
  top: 0.47rem;
  width: 0.65rem;
  height: 3px;
}

.app-brand-window {
  position: absolute;
  left: 0.3rem;
  top: 0.3rem;
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 50%;
  background: #2d6a4f;
}

.app-brand-door {
  position: absolute;
  right: 0.28rem;
  bottom: 0;
  width: 0.42rem;
  height: 0.72rem;
  border-radius: 0.25rem 0.25rem 0 0;
  background: #2d6a4f;
}

.app-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.85rem 1rem;
}

.app-nav-home {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.75rem;
  border-radius: 0.7rem;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  text-decoration: none !important;
}

.app-nav-home:hover,
.app-nav-home.active {
  background: #eef5f0;
  color: var(--primary-color);
}

.app-nav-group {
  margin-bottom: 0.35rem;
}

.app-nav-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.55rem 0.45rem;
  border-radius: 0.5rem;
  text-align: left;
}

.app-nav-toggle:hover,
.app-nav-toggle[aria-expanded="true"] {
  color: var(--text-primary);
  background: #f3f7f4;
}

.app-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 0.3rem;
  background: var(--primary-soft);
  color: var(--primary-color);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.app-nav-caret {
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform var(--transition-speed) ease;
}

.app-nav-toggle[aria-expanded="true"] .app-nav-caret {
  transform: rotate(180deg);
}

.app-nav-sub {
  list-style: none;
  margin: 0;
  padding: 0 0 0.35rem 1.6rem;
}

.app-nav-sub a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.55rem;
  border-radius: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.84rem;
  text-decoration: none !important;
}

.app-nav-sub a i {
  width: 1.1rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.app-nav-sub a:hover,
.app-nav-sub a.active {
  color: var(--primary-color);
  background: var(--primary-soft);
  text-decoration: none !important;
}

.app-nav-sub a:hover i,
.app-nav-sub a.active i {
  color: var(--primary-color);
}

.app-sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 0.85rem 1rem;
}

.app-sidebar-collapse {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 0.45rem 0.4rem;
  border-radius: 0.45rem;
}

.app-sidebar-collapse:hover {
  background: #f3f7f4;
  color: var(--text-primary);
}

.app-main-wrap {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-topbar-actions {
  min-width: 0;
}

.app-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
}

.app-icon-btn:hover {
  background: #f3f7f4;
  color: var(--text-primary);
}

.app-fy-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  border-radius: 2rem;
  padding: 0.35rem 0.85rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: default;
  user-select: none;
}

.app-language-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  border-radius: 0.5rem;
  padding: 0.35rem 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
}

.app-language-btn:hover,
.app-language-btn[aria-expanded="true"] {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.app-language-btn.dropdown-toggle::after {
  margin-left: 0.35rem;
  vertical-align: 0.15em;
  border-top-color: currentColor;
  opacity: 0.65;
}

/* Bootstrap dropdown loads after project.css; scoped selectors win the cascade. */
.app-topbar .dropdown-menu,
.app-topbar-dropdown {
  min-width: 10.5rem;
  padding: 0.35rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
}

.app-topbar .dropdown-menu .dropdown-item,
.app-topbar-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
}

.app-topbar .dropdown-menu .dropdown-item:hover,
.app-topbar .dropdown-menu .dropdown-item:focus,
.app-topbar-dropdown .dropdown-item:hover,
.app-topbar-dropdown .dropdown-item:focus {
  background: #f3f7f5;
  color: var(--primary-color);
}

.app-topbar .dropdown-menu .dropdown-item.active,
.app-topbar .dropdown-menu .dropdown-item:active,
.app-topbar-dropdown .dropdown-item.active,
.app-topbar-dropdown .dropdown-item:active {
  background: var(--primary-soft);
  color: var(--primary-color);
}

.app-language-menu .language-option.active {
  font-weight: 700;
}

.app-notify-wrap {
  position: relative;
}

.app-notify-badge {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
}

.app-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--text-primary);
  padding: 0.3rem 0.45rem;
}

.app-user:hover,
.app-user[aria-expanded="true"] {
  background: #f3f7f4;
}

.app-avatar {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--text-on-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}

.app-user-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.2;
}

.app-user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.app-user-menu .dropdown-item i {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.app-user-menu .dropdown-item:hover i,
.app-user-menu .dropdown-item:focus i {
  color: var(--primary-color);
}

.app-footer {
  background-color: transparent;
  color: var(--text-muted);
  padding: 1rem 1.5rem 1.15rem;
  margin-top: auto;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.app-footer-copy {
  display: block;
  text-align: center;
  font-size: inherit;
}

.app-footer--with-brand .app-powered-by {
  text-align: right;
  align-self: flex-end;
}

.app-page-foot {
  flex-shrink: 0;
  width: 100%;
  padding: 0.65rem clamp(1rem, 2vw, 1.5rem) 1rem;
  text-align: right;
  margin-top: auto;
  background: transparent;
  border: 0;
}

.app-powered-by {
  margin: 0;
  font-size: 0.6875rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.app-powered-by-brand {
  color: var(--primary-color);
  font-weight: 600;
}

body:has(.auth-page),
body:has(.no-access-page),
body:has(.return-page) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body:has(.auth-page) .auth-page,
body:has(.no-access-page) .no-access-page,
body:has(.return-page) .return-page {
  flex: 1 1 auto;
  min-height: 0;
}

.app-footer a {
  color: var(--text-secondary);
}

.app-footer a:hover {
  color: var(--primary-color);
}

body.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .app-sidebar-brand .app-brand-copy,
body.sidebar-collapsed .app-nav-home span,
body.sidebar-collapsed .app-nav-toggle span:not(.app-nav-icon):not(.app-nav-caret),
body.sidebar-collapsed .app-nav-sub,
body.sidebar-collapsed .app-sidebar-collapse span {
  display: none;
}

body.sidebar-collapsed .app-nav-home,
body.sidebar-collapsed .app-sidebar-brand,
body.sidebar-collapsed .app-nav-toggle,
body.sidebar-collapsed .app-sidebar-collapse {
  justify-content: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

body.sidebar-collapsed .app-nav-caret {
  display: none;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 1.65rem;
  margin-bottom: 0.25rem;
}

.page-header-meta {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 0;
}

.app-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
}

.app-card-header {
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.app-card-body {
  padding: 1.15rem;
}

.app-btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--text-on-dark);
}

.app-btn-primary:hover,
.app-btn-primary:focus {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--text-on-dark);
}

.app-btn-outline {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.app-btn-outline:hover,
.app-btn-outline:focus {
  background-color: var(--primary-soft);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.status-badge,
.type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-badge.cleared {
  background-color: var(--success-soft);
  color: var(--success-color);
}

.status-badge.uncleared {
  background-color: var(--warning-soft);
  color: var(--warning-color);
}

.status-badge.draft {
  background-color: #edf2f7;
  color: var(--text-secondary);
}

.type-badge {
  background-color: var(--primary-soft);
  color: var(--primary-color);
}

.amount-in {
  color: var(--success-color);
  font-weight: 600;
}

.amount-out {
  color: var(--danger-color);
  font-weight: 600;
}

.text-muted-custom {
  color: var(--text-muted);
}

.sr-only-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  overflow: visible;
  z-index: 1080;
}

/* --------------------------------------------------------------------------
   Common data table + pagination (reuse on list/settings pages)
   -------------------------------------------------------------------------- */

.app-table-card .app-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.app-table-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.settings-page-actions .settings-btn-primary {
  order: 1;
}

/* Page toolbar flex order: Add/New (1) → Import (5) → Export (10). Place Add first in HTML too. */
.settings-page-actions .settings-btn-import {
  order: 5;
}

.settings-page-actions .settings-btn-export {
  order: 10;
}

/* Bootstrap .btn loads after project.css; compound selectors win the cascade. */
.btn.settings-btn,
a.btn.settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn.settings-btn.settings-btn-secondary,
a.btn.settings-btn.settings-btn-secondary {
  background-color: #e8efeb;
  color: #2f4f3f;
  border: none !important;
  box-shadow: none;
}

.btn.settings-btn.settings-btn-secondary:hover,
.btn.settings-btn.settings-btn-secondary:focus,
a.btn.settings-btn.settings-btn-secondary:hover,
a.btn.settings-btn.settings-btn-secondary:focus {
  background-color: #d8e6de;
  color: var(--primary-hover);
}

.btn.settings-btn.settings-btn-primary {
  background-color: #35825f;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.22);
}

.btn.settings-btn.settings-btn-primary:hover,
.btn.settings-btn.settings-btn-primary:focus {
  background-color: #2d6a4f;
  color: #ffffff;
}

.btn.settings-btn.settings-btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border: none !important;
  box-shadow: none;
}

.btn.settings-btn.settings-btn-ghost:hover,
.btn.settings-btn.settings-btn-ghost:focus {
  background-color: #eef2f0;
  color: var(--text-primary);
}

.app-data-table {
  font-size: 0.84rem;
  vertical-align: middle;
  margin-bottom: 0;
}

.app-data-table thead th,
.app-data-table tbody td {
  vertical-align: middle;
  padding: 0.7rem 0.75rem;
}

.app-data-table thead th {
  background: #f6f9f7;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  border-bottom-color: var(--border-color);
}

.app-data-table thead th.app-th-sortable {
  cursor: pointer;
  user-select: none;
}

.app-data-table thead th.app-th-sortable:focus-visible {
  outline: 2px solid rgba(92, 107, 115, 0.35);
  outline-offset: -2px;
}

.app-data-table thead th.app-th-sortable .app-th-sort-icon {
  margin-left: 0.3rem;
  vertical-align: -0.08em;
  color: inherit;
  opacity: 0.9;
  pointer-events: none;
}

.app-data-table thead th.app-th-sortable > i.app-th-sort-icon {
  display: inline-block;
  font-size: 0.72rem;
  line-height: 1;
}

.app-data-table thead th.app-th-sortable .app-th-sort-icon-pair {
  display: inline-flex;
  align-items: center;
  gap: 0.02rem;
  font-size: 0.62rem;
  line-height: 1;
}

.app-data-table thead th.app-th-sorted .app-th-sort-icon {
  opacity: 1;
}

.app-data-table tbody td {
  border-bottom-color: var(--border-color);
}

.app-data-table .app-col-start {
  text-align: left;
}

.app-data-table .app-col-center {
  text-align: center;
}

.app-data-table .app-col-end {
  text-align: right;
}

.app-data-table .app-col-check {
  width: 2.5rem;
  min-width: 2.5rem;
  max-width: 2.5rem;
  padding-left: 0.65rem;
  padding-right: 0.35rem;
}

.app-data-table .app-table-check-cell .form-check-input {
  margin: 0;
  float: none;
}

.app-data-table td.app-col-end .app-table-actions,
.app-data-table td.app-col-center.app-table-actions-cell .app-table-actions {
  justify-content: center;
  width: 100%;
}

.app-data-table td.app-col-center .cat-status-badge,
.app-data-table td.app-col-center .fy-status-badge,
.app-data-table td.app-col-center .fy-active-badge {
  margin-inline: auto;
}

.app-data-table tbody tr:last-child td {
  border-bottom: 0;
}

.app-table-empty {
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
}

.app-table-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.3rem;
}

.app-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
  transition:
    background-color var(--transition-speed) ease,
    color var(--transition-speed) ease;
}

.app-icon-btn:hover,
.app-icon-btn:focus {
  background: #eef2f0;
  color: var(--text-primary);
}

.app-icon-btn:focus-visible {
  outline: 2px solid rgba(45, 106, 79, 0.35);
  outline-offset: 2px;
}

.app-icon-btn:disabled,
.app-icon-btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.app-icon-btn-edit:hover,
.app-icon-btn-edit:focus {
  background: #e8f0ff;
  color: #2563eb;
}

.app-icon-btn-danger {
  color: var(--danger-color);
}

.app-icon-btn-danger:hover,
.app-icon-btn-danger:focus {
  background: var(--danger-soft);
  color: var(--danger-color);
}

.app-icon-btn-success:hover,
.app-icon-btn-success:focus {
  background: var(--success-soft);
  color: var(--success-color);
}

.app-icon-btn-warning:hover,
.app-icon-btn-warning:focus {
  background: #fef3c7;
  color: #b45309;
}

.app-table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  background: #fafcfb;
}

.app-pagination-summary {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.app-pagination-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.app-pagination-size {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.app-pagination-size-label {
  margin: 0;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.app-pagination-size-select {
  min-width: 4.5rem;
  height: 2rem;
  padding: 0 1.65rem 0 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.4rem;
  background-color: #ffffff;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
}

.app-pagination-size-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.15rem rgba(45, 106, 79, 0.15);
  outline: 0;
}

.app-pagination-size-suffix {
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.app-pagination-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.app-pagination {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  border: 1px solid var(--border-color);
  border-radius: 0.4rem;
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease,
    color var(--transition-speed) ease;
}

.app-pagination-btn:hover:not(:disabled),
.app-pagination-btn:focus:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.app-pagination-btn.is-active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--text-on-dark);
}

.app-pagination-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 767.98px) {
  .app-data-table thead {
    display: none;
  }

  .app-data-table tbody tr {
    display: block;
    border-bottom: 1px solid var(--border-color);
    padding: 0.65rem 0.75rem;
  }

  .app-data-table tbody td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    border: 0;
    padding: 0.25rem 0;
  }

  .app-data-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
  }

  .app-data-table tbody td.app-table-actions-cell {
    justify-content: flex-end;
    padding-top: 0.5rem;
  }

  .app-data-table tbody td.app-table-actions-cell::before {
    display: none;
  }

  .app-data-table tbody td.app-table-check-cell {
    justify-content: flex-start;
    padding-bottom: 0.35rem;
  }

  .app-data-table tbody td.app-table-check-cell::before {
    display: none;
  }

  .app-table-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .app-pagination-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-pagination-wrap {
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Themed modals — use class "app-modal" on .modal-content (all popups)
   Header matches brand mark green; footer matches sidebar brand strip.
   -------------------------------------------------------------------------- */

.app-modal .modal-content {
  border: none;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.app-modal .modal-header {
  background: linear-gradient(145deg, #2d6a4f 0%, #1b4332 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.9rem 1.15rem;
}

.app-modal .modal-title {
  color: var(--text-on-dark);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.app-modal .modal-header .btn-close {
  filter: invert(1) grayscale(1) brightness(2);
  opacity: 0.88;
}

.app-modal .modal-header .btn-close:hover {
  opacity: 1;
}

.app-modal .modal-body {
  background: var(--bg-surface);
  padding: 1.15rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.app-confirm-intro {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: 1.55;
}

/* Read-only detail modals (view popups) — use .app-modal-detail on .modal-body */
.app-modal .modal-body.app-modal-detail {
  padding: 1rem 1.15rem;
}

.app-modal-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
}

.app-modal-detail-item-full {
  grid-column: 1 / -1;
}

.app-modal-detail-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.12rem;
  line-height: 1.35;
}

.app-modal-detail-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.45;
}

@media (max-width: 767.98px) {
  .app-modal-detail-grid {
    grid-template-columns: 1fr;
  }
}

.app-modal .modal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(145deg, #f7fcf8 0%, #edf7f0 100%);
  border-top: 1px solid #dce9df;
  padding: 0.8rem 1.15rem;
}

.app-modal .modal-footer .btn,
.app-modal .modal-footer .settings-btn,
.app-modal .modal-footer .app-modal-btn,
.app-modal .modal-footer .app-modal-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 5.5rem;
  padding: 0.5rem 1.2rem;
  border: none !important;
  border-radius: 0.55rem;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: none;
  transition:
    background-color var(--transition-speed) ease,
    color var(--transition-speed) ease,
    box-shadow var(--transition-speed) ease,
    transform var(--transition-speed) ease;
}

.app-modal .modal-footer .app-modal-btn,
.app-modal .modal-footer .settings-btn-primary {
  background-color: #35825f;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.22);
}

.app-modal .modal-footer .app-modal-btn:hover,
.app-modal .modal-footer .app-modal-btn:focus,
.app-modal .modal-footer .settings-btn-primary:hover,
.app-modal .modal-footer .settings-btn-primary:focus {
  background-color: #2d6a4f;
  color: #ffffff;
  box-shadow: 0 3px 12px rgba(27, 67, 50, 0.26);
  transform: translateY(-1px);
}

.app-modal .modal-footer .settings-btn-secondary,
.app-modal .modal-footer .settings-btn-ghost {
  background: #e8efeb;
  color: #2f4f3f;
}

.app-modal .modal-footer .settings-btn-secondary:hover,
.app-modal .modal-footer .settings-btn-secondary:focus,
.app-modal .modal-footer .settings-btn-ghost:hover,
.app-modal .modal-footer .settings-btn-ghost:focus {
  background: #d8e6de;
  color: var(--primary-hover);
}

.app-modal .modal-footer .app-modal-btn-danger {
  background-color: var(--danger-color);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.22);
}

.app-modal .modal-footer .app-modal-btn-danger:hover,
.app-modal .modal-footer .app-modal-btn-danger:focus {
  background-color: #be123c;
  color: #ffffff;
  box-shadow: 0 3px 12px rgba(190, 18, 60, 0.26);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Settings form modals — shared field typography & column alignment (4.6.x)
   Add class "settings-modal-form" on .modal-body inside form modals.
   -------------------------------------------------------------------------- */

.app-modal .modal-body.settings-modal-form {
  padding: 1rem 1.15rem;
}

.app-modal .modal-body.settings-modal-form .row {
  --bs-gutter-x: 1rem;
  --bs-gutter-y: 0.85rem;
}

.app-modal .modal-body.settings-modal-form > .row + .row,
.app-modal .modal-body.settings-modal-form > fieldset + .row,
.app-modal .modal-body.settings-modal-form > .row + .settings-field {
  margin-top: 0.85rem;
}

.app-modal .modal-body.settings-modal-form .settings-field {
  margin-bottom: 0;
}

.app-modal .modal-body.settings-modal-form > .settings-field,
.app-modal .modal-body.settings-modal-form > .fy-template-row,
.app-modal .modal-body.settings-modal-form > .form-check,
.app-modal .modal-body.settings-modal-form > .settings-modal-hint,
.app-modal .modal-body.settings-modal-form > .cat-form-hint {
  padding-left: calc(var(--bs-gutter-x, 1rem) * 0.5);
  padding-right: calc(var(--bs-gutter-x, 1rem) * 0.5);
}

.app-modal .modal-body.settings-modal-form > .settings-field {
  margin-bottom: 0.75rem;
}

.app-modal .modal-body.settings-modal-form > .settings-field:last-child {
  margin-bottom: 0;
}

.app-modal .modal-body.settings-modal-form .settings-label {
  font-size: 0.76rem;
  margin-bottom: 0.42rem;
}

.app-modal .modal-body.settings-modal-form .settings-input,
.app-modal .modal-body.settings-modal-form .form-control,
.app-modal .modal-body.settings-modal-form .form-select {
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 0.38rem 0.6rem;
}

.app-modal .modal-body.settings-modal-form .settings-modal-hint,
.app-modal .modal-body.settings-modal-form .cat-form-hint {
  font-size: 0.72rem;
  margin: 0.25rem 0 0.75rem;
  color: var(--text-muted);
}

.app-modal .modal-body.settings-modal-form .settings-modal-note,
.app-modal .modal-body.settings-modal-form .cat-form-readonly-note,
.app-modal .modal-body.settings-modal-form .fy-form-readonly-note {
  margin: 0.75rem calc(var(--bs-gutter-x, 1rem) * 0.5) 0;
  padding: 0.65rem 0.75rem;
  border-radius: 0.45rem;
  background: #fff8eb;
  border: 1px solid #fde6b0;
  color: #92400e;
  font-size: 0.72rem;
}

.app-modal .modal-body.settings-modal-form .settings-modal-section,
.app-modal .modal-body.settings-modal-form .cat-form-status-row {
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  padding-left: calc(var(--bs-gutter-x, 1rem) * 0.5);
  padding-right: calc(var(--bs-gutter-x, 1rem) * 0.5);
  border-top: 1px solid var(--border-color);
}

.app-modal .modal-body.settings-modal-form .settings-modal-radios,
.app-modal .modal-body.settings-modal-form .cat-status-radios {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 0.35rem;
}

.app-modal .modal-body.settings-modal-form .settings-modal-radio,
.app-modal .modal-body.settings-modal-form .cat-status-radio {
  margin: 0;
  padding-left: 0;
  min-height: 1.35rem;
}

.app-modal .modal-body.settings-modal-form .settings-modal-radio .form-check-input,
.app-modal .modal-body.settings-modal-form .cat-status-radio .form-check-input {
  width: 0.9rem;
  height: 0.9rem;
  margin-top: 0.12rem;
  margin-left: 0;
  float: none;
}

.app-modal .modal-body.settings-modal-form .settings-modal-radio .form-check-input:checked,
.app-modal .modal-body.settings-modal-form .cat-status-radio .form-check-input:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.app-modal .modal-body.settings-modal-form .settings-modal-radio .form-check-label,
.app-modal .modal-body.settings-modal-form .cat-status-radio .form-check-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding-left: 0.35rem;
}

.app-modal .modal-body.settings-modal-form .settings-check .form-check-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.app-modal .modal-body.settings-modal-form .settings-check .form-check-input:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

/* Grid rows — inputs and blocks align to the same left/right edges */
.app-modal .modal-body.settings-modal-form .row .settings-field .form-control,
.app-modal .modal-body.settings-modal-form .row .settings-field .form-select,
.app-modal .modal-body.settings-modal-form .row .settings-field textarea.settings-input {
  width: 100%;
  max-width: 100%;
}

.app-modal .modal-body.settings-modal-form .row .cat-form-hint,
.app-modal .modal-body.settings-modal-form .row .settings-modal-hint,
.app-modal .modal-body.settings-modal-form .row .perm-form-note,
.app-modal .modal-body.settings-modal-form .row .fy-close-intro {
  margin: 0;
}

.app-modal .modal-body.settings-modal-form .row .cat-form-status-row,
.app-modal .modal-body.settings-modal-form .row .settings-modal-section {
  margin-top: 0;
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
  border-top: 0;
}

.app-modal .modal-body.settings-modal-form .row .cat-form-readonly-note,
.app-modal .modal-body.settings-modal-form .row .fy-form-readonly-note {
  margin: 0;
}

.app-modal .modal-body.settings-modal-form .row .perm-matrix-wrap,
.app-modal .modal-body.settings-modal-form .row .perm-ecchurch-pick-list,
.app-modal .modal-body.settings-modal-form .row .perm-role-users-list,
.app-modal .modal-body.settings-modal-form .row .perm-assigned-users,
.app-modal .modal-body.settings-modal-form .row .perm-user-add-tabs {
  width: 100%;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    width: min(var(--sidebar-width), calc(100vw - 2.5rem));
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1025;
    background: rgba(16, 35, 27, 0.32);
  }

  body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-width);
  }

  body.sidebar-collapsed .app-sidebar-brand .app-brand-copy,
  body.sidebar-collapsed .app-nav-home span,
  body.sidebar-collapsed .app-nav-toggle span:not(.app-nav-icon):not(.app-nav-caret),
  body.sidebar-collapsed .app-nav-sub,
  body.sidebar-collapsed .app-sidebar-collapse span {
    display: revert;
  }
}

@media (max-width: 767.98px) {
  :root {
    --topbar-height: 56px;
  }

  .app-topbar {
    padding: 0 0.75rem;
  }

  .app-fy-chip,
  .app-language-btn {
    width: 2.25rem;
    height: 2.25rem;
    justify-content: center;
    padding: 0;
    border-radius: 0.5rem;
  }

  .app-fy-label,
  .app-language-label {
    display: none;
  }
}

@media (max-width: 419.98px) {
  .app-topbar {
    gap: 0.25rem;
    padding: 0 0.5rem;
  }

  .app-topbar-actions {
    gap: 0.2rem !important;
  }

  .app-user {
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }

  .app-avatar {
    width: 2rem;
    height: 2rem;
  }
}

/* Inline field validation errors (validation-inline.js) */
.field-inline-error {
  color: #dc3545;
  font-size: 0.75rem;
  margin-top: 0.15rem;
}
