:root {
  /* Royal blue & gold */
  --royal-950: #071541;
  --royal-900: #0b1d51;
  --royal-800: #10286e;
  --royal-700: #17369a;
  --royal-600: #1e43b5;
  --royal-500: #2f5bd3;
  --royal-100: #e7edfc;
  --gold-600: #a87c0c;
  --gold-500: #c99a1e;
  --gold-400: #e2b43f;
  --gold-300: #f0cd72;
  --gold-100: #fbf3dc;

  --app-sidebar-bg: var(--royal-900);
  --app-sidebar-fg: #c3cdea;
  --app-sidebar-active: #ffffff;
  --app-sidebar-active-bg: rgba(226, 180, 63, 0.14);
  --app-accent: var(--royal-600);
  --app-accent-soft: var(--royal-100);
  --app-gold: var(--gold-400);
  --app-gold-soft: var(--gold-100);
  --app-gold-ink: var(--gold-600);
  --app-body-bg: #f4f6fb;
  --app-card-bg: #ffffff;
  --app-border: #e1e6f2;
  --app-positive: #1b7f4b;
  --app-negative: #b42318;
  --bs-primary: #1e43b5;
  --bs-primary-rgb: 30, 67, 181;
  --bs-link-color: #1e43b5;
  --bs-link-color-rgb: 30, 67, 181;
  --bs-link-hover-color: #10286e;
  --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-bs-theme="dark"] {
  --app-sidebar-bg: var(--royal-950);
  --app-body-bg: #0e1630;
  --app-card-bg: #141f3a;
  --app-border: #24325a;
  --app-accent: #5b84f0;
  --app-accent-soft: #1b2b57;
  --app-gold-soft: #3a2f12;
  --app-gold-ink: var(--gold-300);
  --app-positive: #4cc38a;
  --app-negative: #f97066;
  --bs-body-bg: #0e1630;
  --bs-link-color: #8eaaf6;
  --bs-link-color-rgb: 142, 170, 246;
  --bs-link-hover-color: #b7c9fa;
}

body {
  background: var(--app-body-bg);
  font-size: 0.925rem;
}

.btn-primary {
  --bs-btn-bg: var(--royal-600);
  --bs-btn-border-color: var(--royal-600);
  --bs-btn-hover-bg: var(--royal-700);
  --bs-btn-hover-border-color: var(--royal-700);
  --bs-btn-active-bg: var(--royal-800);
  --bs-btn-active-border-color: var(--royal-800);
  --bs-btn-disabled-bg: var(--royal-600);
  --bs-btn-disabled-border-color: var(--royal-600);
}
.btn-gold {
  --bs-btn-color: var(--royal-950);
  --bs-btn-bg: var(--gold-400);
  --bs-btn-border-color: var(--gold-400);
  --bs-btn-hover-color: var(--royal-950);
  --bs-btn-hover-bg: var(--gold-300);
  --bs-btn-hover-border-color: var(--gold-300);
  --bs-btn-active-bg: var(--gold-500);
  --bs-btn-active-border-color: var(--gold-500);
  font-weight: 600;
}
.text-gold { color: var(--app-gold-ink) !important; }
.bg-gold-soft { background: var(--app-gold-soft) !important; }
.btn-outline-primary {
  --bs-btn-color: var(--app-accent);
  --bs-btn-border-color: var(--app-accent);
  --bs-btn-hover-bg: var(--app-accent);
  --bs-btn-hover-border-color: var(--app-accent);
  --bs-btn-active-bg: var(--app-accent);
}
.text-bg-primary { background-color: var(--app-accent) !important; }
.form-check-input:checked { background-color: var(--app-accent); border-color: var(--app-accent); }

/* ---------- layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-fg);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 0 0 2rem;
  z-index: 1040;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.1rem 1.1rem 1rem;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.5rem;
}
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; display: block; }
.brand-text { font-weight: 600; line-height: 1.15; font-size: 0.95rem; }
.brand-text small { display: block; font-weight: 600; color: var(--app-gold); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
.sidebar .nav-heading {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #8d9bc9; padding: 1rem 1.25rem 0.35rem; font-weight: 600;
}
.sidebar .nav-link {
  color: var(--app-sidebar-fg);
  padding: 0.42rem 1.25rem;
  display: flex; align-items: center; gap: 0.6rem;
  border-left: 3px solid transparent;
  font-size: 0.875rem;
}
.sidebar .nav-link i { font-size: 1rem; opacity: 0.85; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.sidebar .nav-link.active {
  color: var(--app-sidebar-active);
  background: var(--app-sidebar-active-bg);
  border-left-color: var(--app-gold);
  font-weight: 500;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1.5rem;
  background: var(--app-card-bg);
  border-bottom: 1px solid var(--app-border);
  position: sticky; top: 0; z-index: 1030;
}
.content { padding: 1.5rem; max-width: 1500px; width: 100%; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-title { font-size: 1.5rem; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.breadcrumb { font-size: 0.8rem; margin-bottom: 0.25rem; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: -260px; transition: left 0.2s ease; box-shadow: none; }
  .sidebar.show { left: 0; box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
  .content { padding: 1rem; }
  .topbar { padding: 0.5rem 1rem; }
}

/* ---------- cards & stats ---------- */
.card { border-color: var(--app-border); background: var(--app-card-bg); border-radius: 0.75rem; }
.card-header { background: transparent; border-bottom-color: var(--app-border); font-weight: 600; padding: 0.85rem 1.1rem; }
.card-header .small { font-weight: 400; }
.card-body { padding: 1.1rem; }

.stat-card { height: 100%; container-type: inline-size; }
.stat-card .stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bs-secondary-color); font-weight: 600; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
/* Large amounts (KSh 32,091,551.75) shrink to fit the card instead of wrapping mid-number. */
@supports (container-type: inline-size) {
  .stat-card .stat-value { font-size: min(1.6rem, 8cqi); white-space: nowrap; }
}
.stat-card .stat-sub { font-size: 0.8rem; color: var(--bs-secondary-color); }
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--app-gold-soft); color: var(--app-gold-ink); font-size: 1.15rem;
}

.text-positive { color: var(--app-positive) !important; }
.text-negative { color: var(--app-negative) !important; }

/* ---------- tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--bs-secondary-color); font-weight: 600; border-bottom-width: 1px; white-space: nowrap;
}
.table td, .table th { vertical-align: middle; }
.num, .table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-card { overflow-x: auto; }
.table-card .table > :not(caption) > * > * { padding: 0.55rem 0.9rem; }
tr.row-link { cursor: pointer; }
.table tfoot td, .table tfoot th { font-weight: 650; border-top: 2px solid var(--app-border); }

/* financial statements */
.report-table td { padding-top: 0.35rem !important; padding-bottom: 0.35rem !important; }
.report-table tr.r-section td { font-weight: 650; padding-top: 1rem !important; border-bottom: 1px solid var(--app-border); text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.05em; color: var(--bs-secondary-color); }
.report-table tr.r-group td { font-weight: 600; padding-top: 0.6rem !important; }
.report-table tr.r-subtotal td { font-weight: 600; border-top: 1px solid var(--app-border); }
.report-table tr.r-total td { font-weight: 700; border-top: 2px solid var(--bs-body-color); border-bottom: 3px double var(--bs-body-color); }
.report-table tr.r-grand td { font-weight: 700; font-size: 1.02rem; background: var(--app-gold-soft); }
.report-table tr.r-spacer td { border: 0; padding: 0.3rem !important; }
.report-table tr.r-note td { font-style: italic; color: var(--bs-secondary-color); }
.report-table td.indent-1 { padding-left: 1.75rem !important; }
.report-table td.indent-2 { padding-left: 2.75rem !important; }
.report-table td.indent-3 { padding-left: 3.75rem !important; }
.report-meta { color: var(--bs-secondary-color); font-size: 0.85rem; }

.filter-bar { background: var(--app-card-bg); border: 1px solid var(--app-border); border-radius: 0.75rem; padding: 0.75rem 1rem; margin-bottom: 1rem; }
.filter-bar .form-label { font-size: 0.75rem; margin-bottom: 0.15rem; color: var(--bs-secondary-color); font-weight: 600; }

/* ---------- forms ---------- */
.form-label { font-weight: 500; font-size: 0.85rem; }
.form-text { font-size: 0.78rem; }
.line-table input.form-control, .line-table select.form-select { font-size: 0.875rem; padding: 0.3rem 0.5rem; }
.line-table td { padding: 0.3rem !important; }
.line-table .amount-col { width: 140px; }
.errorlist { color: var(--app-negative); list-style: none; padding: 0; margin: 0.25rem 0 0; font-size: 0.8rem; }
.is-deleted { display: none; }

.budget-grid input { width: 92px; text-align: right; font-size: 0.8rem; padding: 0.2rem 0.35rem; }
.budget-grid th, .budget-grid td { padding: 0.25rem 0.3rem !important; white-space: nowrap; }
.budget-grid .acct-col { position: sticky; left: 0; background: var(--app-card-bg); z-index: 1; min-width: 220px; }

.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 0; }
.dl-grid dt { font-weight: 500; color: var(--bs-secondary-color); font-size: 0.85rem; }
.dl-grid dd { margin: 0; }

.progress { height: 0.55rem; border-radius: 1rem; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: 0.5rem; opacity: 0.6; }

.chart-box { position: relative; height: 280px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem;
  background: radial-gradient(circle at 20% 15%, #2f5bd3 0%, #10286e 45%, #071541 100%); }
.login-card { border-top: 4px solid var(--gold-400); }
.login-footer { color: #c3cdea; font-size: 0.8rem; margin-top: 1.25rem; display: flex; align-items: center; gap: 0.5rem; }
.login-footer img { height: 34px; width: auto; }

/* ---------- public demo ---------- */
.demo-banner { background: var(--app-gold-soft); color: var(--app-gold-ink); border-bottom: 1px solid var(--app-border);
  font-size: 0.82rem; font-weight: 500; padding: 0.4rem 1rem; text-align: center; }
.storage-banner { background: #fdecea; color: #8a1c12; border-bottom: 1px solid var(--app-border); font-size: 0.82rem; font-weight: 500; padding: 0.4rem 1rem; text-align: center; }
[data-bs-theme="dark"] .storage-banner { background: #3b1512; color: #f4b4ab; }
.demo-logins { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px dashed var(--app-border); }
.demo-logins-title { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--app-gold-ink); margin-bottom: 0.6rem; }
.demo-logins-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.demo-login { display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-width: 0; padding: 0.45rem 0.6rem;
  border: 1px solid var(--app-border); border-radius: 0.5rem; background: var(--app-card-bg); color: var(--bs-body-color); font-size: 0.85rem; }
.demo-login:hover, .demo-login:focus-visible { border-color: var(--app-accent); background: var(--app-accent-soft); }
.demo-login span { font-size: 0.72rem; color: var(--bs-secondary-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.demo-logins-note { font-size: 0.75rem; color: var(--bs-secondary-color); margin-top: 0.6rem; }

/* ---------- splash screen ---------- */
.splash {
  position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, #2f5bd3 0%, #10286e 50%, #071541 100%);
  color: #fff; transition: opacity 0.45s ease, visibility 0.45s ease; cursor: pointer; text-align: center; padding: 1rem;
}
.splash.is-hidden { opacity: 0; visibility: hidden; }
.splash-logo { width: 116px; height: 116px; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.35)); animation: splash-pop 0.7s ease-out both; }
.splash-name { font-size: 2.1rem; font-weight: 700; letter-spacing: 0.02em; margin: 1rem 0 0.1rem; animation: splash-rise 0.7s 0.1s ease-out both; }
.splash-tag { color: var(--gold-300); letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.78rem; font-weight: 600; animation: splash-rise 0.7s 0.2s ease-out both; }
.splash-maker { position: absolute; bottom: 6vh; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; animation: splash-rise 0.6s 0.2s ease-out both; }
.splash-maker span { font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: #c3cdea; }
.splash-maker img { width: 150px; height: auto; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35)); }
.splash-bar { width: 140px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); margin-top: 1.4rem; overflow: hidden; }
.splash-bar::after { content: ""; display: block; height: 100%; width: 40%; background: var(--gold-400); border-radius: 3px; animation: splash-load 1.1s ease-in-out infinite; }
@keyframes splash-pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes splash-rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes splash-load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-name, .splash-tag, .splash-maker, .splash-bar::after { animation: none; }
}
.login-card { width: 100%; max-width: 400px; border-radius: 1rem; }

/* ---------- print ---------- */
@media print {
  body { background: #fff; font-size: 11pt; }
  .sidebar, .topbar, .page-actions, .filter-bar, .btn, .alert { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .card-body { padding: 0; }
  .page-break { page-break-after: always; break-after: page; }
  a { color: inherit; text-decoration: none; }
  .report-table tr.r-grand td { background: none; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }

/* ---------- charts (validated palette: categorical slots 1–2, both modes) ---------- */
:root {
  --series-1: #2a52c9;
  --series-2: #b8860b;
  --series-muted: #a3a29b;
  --chart-grid: #e6eaf3;
  --chart-text: #52514e;
}
[data-bs-theme="dark"] {
  --series-1: #5b84f0;
  --series-2: #b88a1c;
  --series-muted: #6b6a64;
  --chart-grid: #24325a;
  --chart-text: #c3c2b7;
}
.legend-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.35rem; vertical-align: baseline; }
.legend-line { display: inline-block; width: 16px; height: 2px; margin-right: 0.35rem; vertical-align: middle; }

/* ---------- Bootstrap components in royal blue ---------- */
.nav-pills { --bs-nav-pills-link-active-bg: var(--royal-600); --bs-nav-link-color: var(--bs-link-color); }
.pagination { --bs-pagination-active-bg: var(--royal-600); --bs-pagination-active-border-color: var(--royal-600); --bs-pagination-color: var(--bs-link-color); }
.form-control:focus, .form-select:focus { border-color: #8ea6ec; box-shadow: 0 0 0 0.2rem rgba(30, 67, 181, 0.2); }
.form-check-input:focus { box-shadow: 0 0 0 0.2rem rgba(30, 67, 181, 0.2); }
.progress-bar { background-color: var(--royal-600); }
.page-title { color: var(--bs-emphasis-color); }
.badge-gold { background: var(--app-gold-soft); color: var(--app-gold-ink); border: 1px solid rgba(201, 154, 30, 0.35); }

/* ---------- people ---------- */
/* One neutral avatar style for everyone: no gendered colour coding. */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--app-accent-soft); color: var(--royal-700); font-size: 0.72rem; font-weight: 700; vertical-align: middle; }
[data-bs-theme="dark"] .avatar { color: #b7c9fa; }
.avatar-lg { width: 44px; height: 44px; font-size: 1rem; }
.split-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--app-border); gap: 2px; }
.split-bar span { display: block; height: 100%; }
.split-a { background: var(--series-1); }
.split-b { background: var(--series-2); }
.split-c { background: var(--series-muted); }
.group-card .group-icon { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--app-gold-soft); color: var(--app-gold-ink); font-size: 1.2rem; }

/* ---------- bank feeds ---------- */
.link-methods { display: grid; gap: 0.5rem; }
.link-method { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem 0.9rem; border: 1px solid var(--app-border); border-radius: 0.6rem; cursor: pointer; }
.link-method:has(input:checked) { border-color: var(--app-accent); background: var(--app-accent-soft); }
.link-method input { margin-top: 0.2rem; flex: 0 0 auto; }
.link-method span { display: flex; flex-direction: column; gap: 0.15rem; }
.link-method small { color: var(--bs-secondary-color); }
.feed-date { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 44px; height: 46px; flex: 0 0 44px;
  border-radius: 10px; background: var(--app-accent-soft); color: var(--royal-700); line-height: 1.05; }
[data-bs-theme="dark"] .feed-date { color: #b7c9fa; }
.feed-date span { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.feed-date strong { font-size: 1.05rem; }
.feed-actions { margin: 0.5rem 0 0 calc(44px + 1rem); display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.feed-more { display: block; }
.feed-more > summary { cursor: pointer; width: max-content; }
.feed-more[open] > summary { margin-bottom: 0.25rem; }
@media (max-width: 575.98px) { .feed-actions { margin-left: 0; } }
.min-w-0 { min-width: 0; }
.mpesa-steps .step-num { flex: 0 0 22px; height: 22px; border-radius: 50%; background: var(--app-gold-soft); color: var(--app-gold-ink); font-weight: 700; font-size: 0.75rem; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.support-banner { background: #3b1f6e; color: #fff; font-size: 0.85rem; font-weight: 500; padding: 0.45rem 1rem; text-align: center; }
.announcement { font-size: 0.85rem; font-weight: 500; padding: 0.45rem 1rem; text-align: center; border-bottom: 1px solid var(--app-border); }
.announcement-info { background: var(--app-accent-soft); color: var(--bs-emphasis-color); }
.announcement-warning { background: var(--app-gold-soft); color: var(--app-gold-ink); }
.announcement-danger { background: #fdecea; color: #8a1c12; }
[data-bs-theme="dark"] .announcement-danger { background: #3b1512; color: #f4b4ab; }
