html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* Auth pages (Identity UI) */
.auth-body {
  margin-bottom: 0;
}

.auth-shell {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background: #0b2e1d;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(800px 500px at 15% 15%, rgba(34,197,94,0.35), rgba(34,197,94,0) 60%),
    radial-gradient(900px 600px at 85% 25%, rgba(59,130,246,0.25), rgba(59,130,246,0) 60%),
    linear-gradient(180deg, rgba(30,93,58,1) 0%, rgba(21,69,44,1) 100%);
  filter: saturate(1.05);
}

.auth-content {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 28px 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.92);
  margin-bottom: 14px;
}

.auth-brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: .02em;
}

.auth-brand-title {
  font-weight: 800;
  font-size: 18px;
  line-height: 1.1;
}

.auth-brand-subtitle {
  font-size: 12px;
  opacity: .78;
}

.auth-card {
  width: min(520px, 100%);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.auth-title {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.auth-subtitle {
  color: #64748b;
}

.btn-auth-primary {
  background: #16a34a;
  border-color: #16a34a;
}

.btn-auth-primary:hover,
.btn-auth-primary:focus {
  background: #15803d;
  border-color: #15803d;
}

.auth-link {
  color: #0f766e;
  text-decoration: none;
}

.auth-link:hover,
.auth-link:focus {
  text-decoration: underline;
}

/* Inline Data Privacy Notice on Register / Consent (scrollable block, one screen) */
.privacy-notice-inline {
  max-height: min(52vh, 28rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* App shell (sidebar + topbar) */
.app-shell {
  min-height: 100vh;
  background: #f4f6fb;
  display: flex;
}

.app-sidebar-theme {
  background: linear-gradient(180deg, #1e5d3a 0%, #15452c 100%);
  color: #fff;
}

.app-sidebar {
  width: 280px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.app-sidebar-offcanvas {
  /* Offcanvas needs the same look as the sidebar, but not sticky positioning. */
  position: fixed;
  top: 0;
  height: 100vh;
  width: 280px;
  border-right: 0;
  --bs-offcanvas-bg: transparent;
  --bs-offcanvas-color: #fff;
}

.app-sidebar-offcanvas.offcanvas {
  /* Ensure Bootstrap offcanvas background can't override our theme */
  background: linear-gradient(180deg, #1e5d3a 0%, #15452c 100%);
  background-color: #15452c;
}

.app-sidebar-offcanvas-header {
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.app-sidebar-offcanvas .offcanvas-body {
  /* _Sidebar already has its own padding */
  padding: 0 !important;
  background: transparent;
  /* Mobile: fill drawer below header so nav scrolls and About footer stays visible */
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  max-height: calc(100dvh - 58px);
}

.app-sidebar-offcanvas .app-sidebar-inner {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

@media (max-width: 575.98px) {
  .app-sidebar-offcanvas {
    width: min(88vw, 320px);
  }
}

.app-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px 14px;
  min-height: 0; /* allow children to scroll in flex container */
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.app-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.app-brand-text {
  font-weight: 700;
  font-size: 18px;
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.group-logo-preview {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  margin-top: 10px;
  object-fit: cover;
  border: 1px solid #d1d5db;
}

.logo-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2d6a4f;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  text-transform: uppercase;
}

.app-nav {
  padding: 14px 6px;
  display: grid;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 10px; /* room for scrollbar */
}

.app-sidebar-hero {
  position: relative;
  height: 120px;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 8px;
  background:
    radial-gradient(120px 120px at 15% 30%, rgba(255,255,255,0.25), rgba(255,255,255,0) 60%),
    radial-gradient(160px 160px at 85% 20%, rgba(255,255,255,0.18), rgba(255,255,255,0) 60%),
    linear-gradient(135deg, rgba(34,197,94,0.45), rgba(59,130,246,0.25));
}

.app-sidebar-hero-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.05), rgba(0,0,0,0.22));
}

.app-profile.card {
  border-radius: 18px;
  box-shadow: none;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.10);
}

.app-profile-name,
.app-profile-email {
  color: rgba(255,255,255,0.72) !important; /* gray on green */
}

.app-profile-email {
  color: rgba(255,255,255,0.62) !important;
}

.app-sidebar-footer-link {
  color: rgba(255,255,255,0.70);
}

.app-sidebar-footer-link:hover,
.app-sidebar-footer-link:focus {
  color: rgba(255,255,255,0.92);
  text-decoration: underline;
}

.app-profile .btn-outline-secondary {
  color: rgba(255,255,255,0.92);
  border-color: rgba(255,255,255,0.25);
}

.app-profile .btn-outline-secondary:hover {
  background: rgba(255,255,255,0.14);
}

.app-profile .btn-outline-primary {
  color: rgba(255,255,255,0.92);
  border-color: rgba(255,255,255,0.25);
}

.app-profile .btn-outline-primary:hover {
  background: rgba(255,255,255,0.14);
}

.app-nav-section {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .75;
  padding: 8px 8px 4px;
}

.app-nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  background: rgba(255,255,255,0.06);
}

.app-nav-link:hover,
.app-nav-link:focus {
  background: rgba(255,255,255,0.14);
  color: #fff;
}

.app-sidebar-footer {
  margin-top: auto;
  padding: 10px 10px 6px;
  opacity: .85;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-topbar .dropdown-menu {
  border-radius: 14px;
}

/* Help modal: ensure it appears above app-shell (topbar z-index 1030) and is never clipped */
#appHelpModal {
  z-index: 1060;
}

.app-topbar-title {
  font-weight: 700;
  color: #111827;
}

.app-content {
  padding: 18px;
}

.app-page {
  max-width: 1400px;
  margin: 0 auto;
}

.admin-dashboard .card-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.admin-dashboard .dashboard-card {
  min-height: 180px;
  height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 16px;
  padding: 16px;
  position: relative;
  transition: transform 0.2s ease;
}

/* Normal tier: default metrics (colored gradients set inline on each card). */
.admin-dashboard .dashboard-card.priority-normal {
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

.admin-dashboard .dashboard-card:hover {
  transform: translateY(-3px);
}

.admin-dashboard .dashboard-card.card-span-2 {
  grid-column: span 2;
}

.admin-dashboard .dashboard-card .card-title {
  font-size: 14px;
  opacity: 0.9;
}

.admin-dashboard .dashboard-card .card-value {
  font-size: 28px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
}

.admin-dashboard .dashboard-card .card-footer {
  margin-top: auto;
  border: 0;
  background: transparent;
  padding: 0;
}

.admin-dashboard .dashboard-card .card-subtext {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-dashboard .dashboard-card .balance-breakdown {
  margin-bottom: 4px;
}

.admin-dashboard .dashboard-card .balance-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.admin-dashboard .dashboard-card .balance-card-actions .btn {
  min-width: 0;
  flex: 1 1 0;
  max-width: calc(50% - 4px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-dashboard .dashboard-card .btn {
  min-width: 130px;
}

.admin-dashboard .dashboard-card .card-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  opacity: 0.2;
  font-size: 20px;
  line-height: 1;
  pointer-events: none;
}

/* Critical: deficit fund balance — red, wider (span-2), taller, subtle pulse. */
.admin-dashboard .dashboard-card.priority-critical {
  height: auto;
  min-height: 232px;
  box-shadow: 0 0 0 1px rgba(127, 29, 29, 0.32), 0 12px 28px rgba(127, 29, 29, 0.26);
  animation: dashboard-critical-pulse 3s ease-in-out infinite;
}

.admin-dashboard .dashboard-card.priority-critical .card-value {
  font-size: clamp(28px, 3.2vw, 34px);
}

.admin-dashboard .dashboard-card.priority-critical .card-title,
.admin-dashboard .dashboard-card.priority-critical .card-value,
.admin-dashboard .dashboard-card.priority-critical .card-subtext {
  color: #fff;
}

/* High: pending approvals / action queue — orange accent. */
.admin-dashboard .dashboard-card.priority-high {
  border: 1px solid rgba(251, 146, 60, 0.5);
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  box-shadow: 0 8px 20px rgba(234, 88, 12, 0.08);
}

.admin-dashboard .dashboard-card.priority-high .card-title {
  color: #9a3412 !important;
  opacity: 1;
}

.admin-dashboard .dashboard-card.priority-high .card-value {
  color: #c2410c;
}

/* Info: secondary reference metrics — gray. */
.admin-dashboard .dashboard-card.priority-info.text-white {
  background: linear-gradient(135deg, #6b7280, #4b5563);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.12);
}

.admin-dashboard .dashboard-card.priority-info:not(.text-white) {
  border: 1px solid rgba(107, 114, 128, 0.35);
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
}

@keyframes dashboard-critical-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(127, 29, 29, 0.14), 0 10px 26px rgba(127, 29, 29, 0.22);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(127, 29, 29, 0.06), 0 12px 30px rgba(127, 29, 29, 0.28);
  }
}

@media (max-width: 992px) {
  .admin-dashboard .card-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-dashboard .dashboard-card.card-span-2 {
    grid-column: span 2;
  }
}

@media (max-width: 576px) {
  .admin-dashboard .card-container {
    grid-template-columns: 1fr;
  }

  .admin-dashboard .dashboard-card.card-span-2 {
    grid-column: span 1;
  }
}

/* Mobile safety: never allow sidebar layout to squeeze main content */
@media (max-width: 991.98px) {
  .app-shell {
    flex-direction: column;
  }

  .app-main {
    width: 100%;
  }

  /* Even if Bootstrap utilities fail for any reason, don't reserve sidebar width on mobile */
  .app-shell > .app-sidebar {
    display: none !important;
  }
}

.card {
  border: 0;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.06);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* @mention in comments */
.mention {
  color: #1877f2;
  font-weight: 600;
}

/* Admin announcement recipient picker (To: chips) */
.ann-recipient-picker__box {
  min-height: 2.75rem;
}
.ann-recipient-picker__chips:empty {
  display: none !important;
}
.ann-recipient-picker__chips:not(:empty) {
  display: flex !important;
}
.ann-recipient-picker__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 999px;
  background: #e7f1ff;
  border: 1px solid #b6d4fe;
  color: #084298;
  max-width: 100%;
}
.ann-recipient-picker__chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}
.ann-recipient-picker__chip button {
  border: 0;
  background: transparent;
  color: #6c757d;
  padding: 0 0.15rem;
  line-height: 1;
  font-size: 1rem;
  cursor: pointer;
}
.ann-recipient-picker__chip button:hover {
  color: #dc3545;
}
.ann-recipient-picker__search:focus {
  box-shadow: none;
}
.ann-recipient-picker__suggestions .list-group-item {
  cursor: pointer;
  border-left: 0;
  border-right: 0;
}
.ann-recipient-picker__suggestions .list-group-item:first-child {
  border-top: 0;
}
.ann-recipient-picker__suggestions .list-group-item:hover,
.ann-recipient-picker__suggestions .list-group-item:focus {
  background: #f8f9fa;
}

/* Privacy mode — monetary amounts */
.privacy-amount--plain {
  font-variant-numeric: tabular-nums;
}

.amount {
  white-space: nowrap;
  font-weight: 600;
}

.privacy-amount__value {
  display: inline-block;
  min-width: 4.5ch;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: filter 0.15s ease;
}

.privacy-amount__value--masked {
  filter: blur(6px);
  user-select: none;
  color: var(--bs-secondary-color);
}

.privacy-amount__value--revealed {
  filter: none;
  user-select: text;
}

.privacy-amount__value--locked {
  letter-spacing: 0.08em;
  color: var(--bs-secondary-color);
  user-select: none;
}

.privacy-amount__toggle {
  text-decoration: none !important;
  line-height: 1;
  opacity: 0.85;
}

.privacy-amount__toggle:hover,
.privacy-amount__toggle:focus {
  opacity: 1;
}

.tooltip.privacy-amount-tooltip {
  max-width: 280px;
}

/* Balance sheet KPI cards - align with admin dashboard format */
.report-balance-sheet .report-kpi-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.report-balance-sheet .dashboard-card {
  min-height: 180px;
  height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 16px;
  padding: 16px;
  position: relative;
  transition: transform 0.2s ease;
}

.report-balance-sheet .dashboard-card:hover {
  transform: translateY(-3px);
}

.report-balance-sheet .dashboard-card.card-span-2 {
  grid-column: span 2;
}

.report-balance-sheet .dashboard-card .card-title {
  font-size: 14px;
  opacity: 0.9;
}

.report-balance-sheet .dashboard-card .card-value {
  font-size: 28px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
}

.report-balance-sheet .dashboard-card .card-footer {
  margin-top: auto;
  border: 0;
  background: transparent;
  padding: 0;
}

.report-balance-sheet .dashboard-card .card-subtext {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-balance-sheet .dashboard-card .card-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  opacity: 0.2;
  font-size: 20px;
  line-height: 1;
  pointer-events: none;
}

.report-balance-sheet .report-kpi-value {
  font-size: clamp(1.7rem, 2.1vw, 2.25rem);
}

.report-balance-sheet .dashboard-card.priority-normal {
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

.report-balance-sheet .dashboard-card.priority-high {
  border: 1px solid rgba(251, 146, 60, 0.5);
  box-shadow: 0 8px 20px rgba(234, 88, 12, 0.12);
}

.report-balance-sheet .dashboard-card.priority-info {
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.1);
}

.report-balance-sheet .dashboard-card.priority-critical {
  height: auto;
  min-height: 232px;
  box-shadow: 0 0 0 1px rgba(127, 29, 29, 0.32), 0 12px 28px rgba(127, 29, 29, 0.26);
  animation: report-critical-pulse 3s ease-in-out infinite;
}

.report-balance-sheet .dashboard-card.priority-critical .card-value {
  font-size: clamp(28px, 3.2vw, 34px);
}

@keyframes report-critical-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(127, 29, 29, 0.14), 0 10px 26px rgba(127, 29, 29, 0.22);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(127, 29, 29, 0.06), 0 12px 30px rgba(127, 29, 29, 0.28);
  }
}

@media (max-width: 1200px) {
  .report-balance-sheet .report-kpi-container {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 992px) {
  .report-balance-sheet .report-kpi-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-balance-sheet .dashboard-card.card-span-2 {
    grid-column: span 2;
  }
}

@media (max-width: 576px) {
  .report-balance-sheet .report-kpi-container {
    grid-template-columns: 1fr;
  }

  .report-balance-sheet .dashboard-card.card-span-2 {
    grid-column: span 1;
  }
}