/* Non-profit management system: navy + teal, matching the organization's spreadsheets. */
:root {
    --np-navy: #1c355e;
    --np-navy-2: #24447a;
    --np-teal: #4a7c7e;
    --np-gold: #c9a227;
    --np-bg: #f4f6f9;
    --np-border: #e3e7ee;
    --bs-font-sans-serif: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-primary: #1c355e;
    --bs-primary-rgb: 28, 53, 94;
    --bs-link-color: #24447a;
    --bs-link-color-rgb: 36, 68, 122;
}
body { background: var(--np-bg); font-size: .925rem; color: #1f2937; }
.btn-primary { --bs-btn-bg: var(--np-navy); --bs-btn-border-color: var(--np-navy); --bs-btn-hover-bg: var(--np-navy-2); --bs-btn-hover-border-color: var(--np-navy-2); --bs-btn-active-bg: #142849; }
.btn-outline-primary { --bs-btn-color: var(--np-navy); --bs-btn-border-color: var(--np-navy); --bs-btn-hover-bg: var(--np-navy); --bs-btn-hover-border-color: var(--np-navy); }
.text-primary { color: var(--np-navy) !important; }
.bg-primary { background-color: var(--np-navy) !important; }

/* Top menu: one sticky navy bar (brand, sections as dropdowns, house switch, user) */
.app-header { z-index: 1030; box-shadow: 0 1px 3px rgba(16,24,40,.18); }
.app-nav { background: var(--np-navy); padding-top: .35rem; padding-bottom: .35rem; }
.app-nav .brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; margin-right: .75rem; }
.app-nav .brand img { width: 34px; height: 34px; object-fit: contain; background: #fff; border-radius: 8px; padding: 2px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--np-gold); color: var(--np-navy); display: grid; place-items: center; font-size: 1.1rem; }
.brand-text { font-family: 'Source Serif 4', Georgia, serif; font-weight: 700; font-size: 1.1rem; line-height: 1.1; white-space: nowrap; }
.app-nav .navbar-nav .nav-link { color: #d7deeb; font-size: .9rem; padding: .5rem .75rem; border-radius: .4rem; white-space: nowrap; }
.app-nav .navbar-nav .nav-link:hover, .app-nav .navbar-nav .nav-link:focus { color: #fff; background: rgba(255,255,255,.08); }
.app-nav .navbar-nav .nav-link.active, .app-nav .navbar-nav .show > .nav-link { color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 0 -2px 0 var(--np-gold); font-weight: 600; }
.app-nav .dropdown-menu { font-size: .9rem; border-color: var(--np-border); padding: .4rem; }
.app-nav .dropdown-item { border-radius: .35rem; padding: .38rem .7rem; }
.app-nav .dropdown-item i { color: var(--np-teal); width: 1.1rem; text-align: center; }
.app-nav .dropdown-item.active, .app-nav .dropdown-item:active { background: #eef2f8; color: var(--np-navy); font-weight: 600; }
.app-nav .dropdown-item.active i { color: var(--np-navy); }
.btn-nav { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.15); }
.btn-nav:hover, .btn-nav:focus, .btn-nav.show { background: rgba(255,255,255,.2); color: #fff; }
.house-btn { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.2); max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.house-btn:hover, .house-btn.show { background: rgba(255,255,255,.2); color: #fff; }
.house-btn:disabled { color: #fff; opacity: 1; border-color: transparent; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--np-teal); color: #fff; display: inline-grid; place-items: center; font-weight: 600; font-size: .78rem; }
.app-nav .dropdown-header { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--np-gold-dark, #9a6b00); padding: .45rem .7rem .2rem; }
.app-nav .menu-group + .menu-group { margin-top: .25rem; }
.nav-badge { background: var(--np-gold); color: var(--np-navy); font-size: .68rem; font-weight: 700; vertical-align: 1px; }
.house-btn .house-name { display: inline-block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
/* Gold 3D icon (Modules launcher, menu dropdowns): bevelled gold tile, glossy top, engraved glyph */
.gold-ic {
    position: relative; width: 54px; height: 54px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 1.5rem; flex: none;
    background: linear-gradient(145deg, #fff3c4 0%, #f3cf6b 22%, #d9a62e 52%, #b07d14 78%, #e6bd52 100%);
    color: #5a3d05; overflow: hidden; transition: transform .16s ease, box-shadow .16s ease;
    box-shadow: inset 0 2px 1px rgba(255,255,255,.85), inset 0 -3px 4px rgba(110,70,0,.45), inset 2px 0 2px rgba(255,240,190,.5),
                0 1px 0 #8a5f0c, 0 3px 0 #7a5208, 0 8px 14px rgba(90,60,0,.35);
}
.gold-ic::before {
    content: ""; position: absolute; left: 5%; right: 5%; top: 8%; height: 42%; border-radius: 30% 30% 40% 40%;
    background: linear-gradient(180deg, rgba(255,255,255,.65), rgba(255,255,255,0)); pointer-events: none;
}
.gold-ic i, .app-nav .dropdown-item .gold-ic i, [data-bs-theme="dark"] .app-nav .dropdown-item .gold-ic i { position: relative; color: #5a3d05; width: auto; text-shadow: 0 1px 0 rgba(255,236,170,.9), 0 -1px 0 rgba(80,50,0,.55); }
.gold-ic-sm { width: 26px; height: 26px; border-radius: 7px; font-size: .85rem; vertical-align: middle;
    box-shadow: inset 0 1px 1px rgba(255,255,255,.85), inset 0 -2px 2px rgba(110,70,0,.45), 0 1px 0 #8a5f0c, 0 2px 0 #7a5208, 0 3px 6px rgba(90,60,0,.3); }
.gold-ic-sm::before { border-radius: 5px 5px 40% 40%; }
.app-nav .dropdown-item:has(.gold-ic) { display: flex; align-items: center; gap: .6rem; padding-top: .3rem; padding-bottom: .3rem; }
.app-nav .dropdown-item:hover .gold-ic, .app-nav .dropdown-item:focus .gold-ic { transform: translateY(-1px) rotate(-4deg); }
@media (min-width: 1200px) {
    .app-nav .dropdown-menu.menu-groups { display: none; min-width: 690px; }
    .app-nav .dropdown-menu.menu-groups.show { display: grid; grid-template-columns: repeat(3, 1fr); column-gap: .5rem; }
    .app-nav .dropdown-menu.menu-groups .menu-group + .menu-group { margin-top: 0; border-left: 1px solid var(--np-border); padding-left: .4rem; }
}
@media (max-width: 1199.98px) {
    .app-nav .navbar-collapse { max-height: calc(100vh - 60px); overflow-y: auto; padding-bottom: .5rem; }
    .app-nav .dropdown-menu { background: transparent; border: 0; box-shadow: none !important; padding: 0 0 .25rem 1rem; }
    .app-nav .dropdown-item { color: #d7deeb; }
    .app-nav .dropdown-item i { color: #8fb3b5; }
    .app-nav .dropdown-item:hover { background: rgba(255,255,255,.08); color: #fff; }
    .app-nav .dropdown-item.active { background: rgba(255,255,255,.12); color: #fff; }
    .app-nav .house-switch .dropdown-menu, .app-nav .dropdown-menu-end { background: #fff; border: 1px solid var(--np-border); padding: .4rem; }
    .app-nav .dropdown-menu-end .dropdown-item, .app-nav .house-switch .dropdown-item { color: #1f2937; }
}

.app-main { min-width: 0; min-height: calc(100vh - 56px); display: flex; flex-direction: column; }
.app-content { padding: 1.5rem; flex: 1; }
.app-footer { padding: .75rem 1.5rem; color: #8a94a6; font-size: .8rem; }
.app-credit a { color: inherit; font-weight: 600; text-decoration: none; }
.app-credit a:hover { text-decoration: underline; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: flex-end; margin-bottom: 1.25rem; }
.page-title { font-family: 'Source Serif 4', Georgia, serif; font-weight: 700; font-size: 1.6rem; color: var(--np-navy); margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.card { border: 1px solid var(--np-border); border-radius: .6rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--np-border); font-weight: 600; }
.table { --bs-table-striped-bg: #f8fafc; margin-bottom: 0; }
.table > thead th { background: var(--np-navy); color: #fff; font-weight: 600; font-size: .8rem; white-space: nowrap; vertical-align: middle; border-color: #2b4675; }
.table.table-teal > thead th { background: var(--np-teal); border-color: #5b8d8f; }
.table td { vertical-align: middle; }
.table tfoot td, .table tfoot th { font-weight: 700; background: #f1f4f9; border-top: 2px solid var(--np-navy); }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.group-row td { background: #eef2f8; font-weight: 700; color: var(--np-navy); }
.table tr.subtotal-row td { background: #f7f9fc; font-weight: 600; }

/* KPI band, as in the spreadsheet dashboards */
.report-banner { background: var(--np-navy); color: #fff; text-align: center; padding: 1rem; border-radius: .6rem .6rem 0 0; }
.report-banner h2 { font-family: 'Source Serif 4', Georgia, serif; font-weight: 700; margin: 0; font-size: 1.5rem; }
.report-banner .org { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.15rem; font-weight: 600; }
.report-banner .sub { font-style: italic; color: #c8d3e6; font-size: .9rem; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--np-border); border: 1px solid var(--np-border); }
.kpi { background: #eceef1; padding: .85rem 1rem; text-align: center; }
.kpi .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #4b5563; font-weight: 600; }
.kpi .value { font-family: 'Source Serif 4', Georgia, serif; font-size: 1.55rem; font-weight: 700; color: #374151; font-variant-numeric: tabular-nums; }
.kpi.status { background: #e8f6ef; }
.status-text { font-family: 'Source Serif 4', Georgia, serif; font-weight: 700; font-size: 1.4rem; letter-spacing: .02em; }
.status-on_track { color: #0f7a4d; }
.status-watch { color: #b7791f; }
.status-over_budget { color: #c0392b; }
.kpi.status.watch { background: #fdf6e3; }
.kpi.status.over_budget { background: #fdecea; }

.stat-card { padding: 1rem 1.1rem; }
.stat-card .stat-label { font-size: .75rem; text-transform: uppercase; color: #6b7280; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.45rem; font-weight: 700; color: var(--np-navy); font-variant-numeric: tabular-nums; }
.stat-card .stat-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 1.25rem; background: #eef2f8; color: var(--np-navy); }

.progress-thin { height: 6px; }
.form-label { font-weight: 500; font-size: .85rem; }
.required::after { content: ' *'; color: #c0392b; }
.lines-table td { padding: .3rem; }
.lines-table .form-control, .lines-table .form-select { font-size: .875rem; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: #6b7280; }
.empty-state i { font-size: 2.2rem; color: #b6c0d1; display: block; margin-bottom: .5rem; }
.filter-bar { background: #fff; border: 1px solid var(--np-border); border-radius: .6rem; padding: .75rem; margin-bottom: 1rem; }

.cat-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--cat, #6c757d); margin-right: .35rem; vertical-align: baseline; }
.cat-chip { border: 1px solid var(--np-border); background: #fff; color: #1f2937; }
.cat-chip:hover { border-color: var(--cat); }
.cat-chip.active { background: var(--cat); border-color: var(--cat); color: var(--cat-text, #fff); }
.cat-chip.active .cat-dot { background: var(--cat-text, #fff); }

@media (max-width: 991.98px) {
    .app-content { padding: 1rem; }
}
@media print {
    .app-header, .app-footer, .page-actions, .no-print, .filter-bar { display: none !important; }
    .app-main { min-height: 0; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border: 0; }
    .table > thead th, .report-banner, .kpi { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* drill-down: a report figure that opens the entries behind it */
a.drill { color: inherit; text-decoration: underline dotted rgba(28, 53, 94, .45); text-underline-offset: 3px; }
a.drill:hover { color: var(--np-navy); text-decoration-style: solid; }
@media print { a.drill { text-decoration: none; } }
.table td.num-muted { color: #6c757d; }

/* ------------------------------------------------------------------ night mode (data-bs-theme="dark", partials/theme)
   Bootstrap 5.3 switches its own components; these cover the app's own colours and light-only utility classes.
   Print views and PDFs never use it. */
[data-bs-theme="dark"] {
    --np-bg: #0f1522;
    --np-border: #2a3447;
    --np-surface: #171f2e;
    --np-surface-2: #1e283a;
    --np-ink: #e2e7ef;
    --np-muted: #9aa4b5;
    --np-accent: #9dbbea;
    --bs-body-bg: #171f2e;
    --bs-body-color: #e2e7ef;
    --bs-secondary-color: #9aa4b5;
    --bs-tertiary-bg: #1e283a;
    --bs-secondary-bg: #222d42;
    --bs-border-color: #2a3447;
    --bs-link-color: #9dbbea;
    --bs-link-color-rgb: 157, 187, 234;
    --bs-link-hover-color: #c3d6f5;
    --bs-emphasis-color: #f3f6fa;
    color-scheme: dark;
}
[data-bs-theme="dark"] body { background: var(--np-bg); color: var(--np-ink); }
[data-bs-theme="dark"] .app-nav { background: #12223f; }
[data-bs-theme="dark"] .app-header { box-shadow: 0 1px 0 var(--np-border); }
[data-bs-theme="dark"] .page-title,
[data-bs-theme="dark"] .text-primary,
[data-bs-theme="dark"] .stat-card .stat-value { color: var(--np-accent) !important; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #2f5597; --bs-btn-border-color: #2f5597; --bs-btn-hover-bg: #3a65ad; --bs-btn-hover-border-color: #3a65ad; --bs-btn-active-bg: #264a85; }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: var(--np-accent); --bs-btn-border-color: #3f5f93; --bs-btn-hover-bg: #2f5597; --bs-btn-hover-border-color: #2f5597; --bs-btn-hover-color: #fff; }
[data-bs-theme="dark"] .btn-light { --bs-btn-bg: var(--np-surface-2); --bs-btn-border-color: var(--np-border); --bs-btn-color: var(--np-ink); --bs-btn-hover-bg: #27334a; --bs-btn-hover-border-color: #34425c; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #2c3a54; --bs-btn-active-color: #fff; }
[data-bs-theme="dark"] .bg-white { background-color: var(--np-surface) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--np-surface-2) !important; }
[data-bs-theme="dark"] .bg-light.text-dark, [data-bs-theme="dark"] .bg-white.text-dark { color: var(--np-ink) !important; }
[data-bs-theme="dark"] .card, [data-bs-theme="dark"] .card-header, [data-bs-theme="dark"] .filter-bar,
[data-bs-theme="dark"] .cat-chip { background: var(--np-surface); color: var(--np-ink); border-color: var(--np-border); }
[data-bs-theme="dark"] .card { box-shadow: none; }
[data-bs-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-striped-bg: rgba(255,255,255,.03); --bs-table-hover-bg: rgba(255,255,255,.05); --bs-table-color: var(--np-ink); }
[data-bs-theme="dark"] .table > thead th { background: #1d3561; border-color: #2a4677; }
[data-bs-theme="dark"] .table.table-teal > thead th { background: #2f5d5f; border-color: #3c6f71; }
[data-bs-theme="dark"] .table tfoot td, [data-bs-theme="dark"] .table tfoot th { background: var(--np-surface-2); border-top-color: #3f5f93; }
[data-bs-theme="dark"] .table tr.group-row td { background: #1c2a42; color: var(--np-accent); }
[data-bs-theme="dark"] .table tr.subtotal-row td { background: var(--np-surface-2); }
[data-bs-theme="dark"] .report-banner { background: #1d3561; }
[data-bs-theme="dark"] .kpi-row { background: var(--np-border); border-color: var(--np-border); }
[data-bs-theme="dark"] .kpi { background: var(--np-surface-2); }
[data-bs-theme="dark"] .kpi .label, [data-bs-theme="dark"] .stat-card .stat-label, [data-bs-theme="dark"] .empty-state { color: var(--np-muted); }
[data-bs-theme="dark"] .kpi .value { color: var(--np-ink); }
[data-bs-theme="dark"] .kpi.status { background: #15322a; }
[data-bs-theme="dark"] .kpi.status.watch { background: #362c12; }
[data-bs-theme="dark"] .kpi.status.over_budget { background: #3a1c1c; }
[data-bs-theme="dark"] .status-on_track { color: #4cc38a; }
[data-bs-theme="dark"] .status-watch { color: #e3b341; }
[data-bs-theme="dark"] .status-over_budget { color: #f07167; }
[data-bs-theme="dark"] .stat-card .stat-icon { background: #1f2f4d; color: var(--np-accent); }
[data-bs-theme="dark"] .app-footer { color: #7d889b; }
[data-bs-theme="dark"] a.drill { text-decoration-color: rgba(157, 187, 234, .5); }
[data-bs-theme="dark"] a.drill:hover { color: var(--np-accent); }
[data-bs-theme="dark"] .table td.num-muted { color: var(--np-muted); }
[data-bs-theme="dark"] .app-nav .dropdown-menu { --bs-dropdown-bg: var(--np-surface); --bs-dropdown-link-color: var(--np-ink); --bs-dropdown-link-hover-bg: var(--np-surface-2); --bs-dropdown-border-color: var(--np-border); }
[data-bs-theme="dark"] .app-nav .dropdown-item.active, [data-bs-theme="dark"] .app-nav .dropdown-item:active { background: #1f2f4d; color: #fff; }
[data-bs-theme="dark"] .app-nav .dropdown-item i { color: #7fb3b5; }
[data-bs-theme="dark"] .app-nav .dropdown-header { color: #d9b54a; }
[data-bs-theme="dark"] .app-nav .menu-group + .menu-group { border-color: var(--np-border); }
@media (max-width: 1199.98px) {
    [data-bs-theme="dark"] .app-nav .house-switch .dropdown-menu, [data-bs-theme="dark"] .app-nav .dropdown-menu-end { background: var(--np-surface); border-color: var(--np-border); }
    [data-bs-theme="dark"] .app-nav .dropdown-menu-end .dropdown-item, [data-bs-theme="dark"] .app-nav .house-switch .dropdown-item { color: var(--np-ink); }
}
/* Tom Select (searchable selects) */
[data-bs-theme="dark"] .ts-control, [data-bs-theme="dark"] .ts-dropdown, [data-bs-theme="dark"] .ts-control input { background: var(--np-surface) !important; color: var(--np-ink) !important; border-color: var(--np-border); }
[data-bs-theme="dark"] .ts-dropdown .active { background: var(--np-surface-2); color: #fff; }
[data-bs-theme="dark"] .ts-wrapper.multi .ts-control > div { background: var(--np-surface-2); color: var(--np-ink); }
/* sign-in page */
[data-bs-theme="dark"] .login-card { background: var(--np-surface); }
[data-bs-theme="dark"] .org-title { color: var(--np-accent) !important; }
/* Appearance switch in the user menu */
.theme-switch .btn { font-size: .78rem; white-space: nowrap; }
.theme-switch .btn.active { background: var(--np-navy); border-color: var(--np-navy); color: #fff; }
[data-bs-theme="dark"] .theme-switch .btn.active { background: #2f5597; border-color: #2f5597; }
@media print {
    [data-bs-theme="dark"] body { background: #fff; color: #000; }
}
/* night mode: pages with their own colours */
[data-bs-theme="dark"] .mod-card { background: var(--np-surface); color: var(--np-ink); border-color: var(--np-border); }
[data-bs-theme="dark"] .mod-card:hover, [data-bs-theme="dark"] .mod-card:focus { color: #fff; box-shadow: 0 12px 28px rgba(0,0,0,.4); }
[data-bs-theme="dark"] .mod-section-title, [data-bs-theme="dark"] .manual h2, [data-bs-theme="dark"] .manual h3 { color: var(--np-accent); }
[data-bs-theme="dark"] .mod-section-count { background: var(--np-surface-2); color: var(--np-muted); }
[data-bs-theme="dark"] .manual .ui { background: var(--np-surface-2); border-color: var(--np-border); }
[data-bs-theme="dark"] .manual .duties { background: var(--np-surface-2); }
[data-bs-theme="dark"] .manual .remember { background: #2b2510; }
[data-bs-theme="dark"] .plan .desc, [data-bs-theme="dark"] .budget-grid th:first-child, [data-bs-theme="dark"] .budget-grid td:first-child { background: var(--np-surface); }
[data-bs-theme="dark"] .plan thead .desc, [data-bs-theme="dark"] .budget-grid thead th:first-child { background: #1d3561; }
[data-bs-theme="dark"] .plan tr.group-row .desc, [data-bs-theme="dark"] .budget-grid tr.group-row td:first-child { background: #1c2a42; }
[data-bs-theme="dark"] .plan tfoot .desc, [data-bs-theme="dark"] .budget-grid tfoot td:first-child, [data-bs-theme="dark"] .plan .sub { background: var(--np-surface-2); }
[data-bs-theme="dark"] .plan thead th.sub { background: #2f5d5f; }
/* cells painted with a fixed light colour (spreadsheet-style reports) keep dark text */
[data-bs-theme="dark"] td[style*="background:#f"], [data-bs-theme="dark"] td[style*="background:#e"] { color: #1f2937; }
[data-bs-theme="dark"] .import-house { background: #1c2a42 !important; border-color: var(--np-border) !important; border-left-color: #3f5f93 !important; }
[data-bs-theme="dark"] .imp-card .ic { background: #1f2f4d; color: var(--np-accent); }
[data-bs-theme="dark"] .gantt-row[style*="background"] { background: var(--np-surface-2) !important; }
[data-bs-theme="dark"] body.login-page { background: linear-gradient(160deg, #0f1c33 0%, #13233f 55%, #1d3a3c 100%); }
/* payroll grid: employer's share columns shown on request */
.payroll-grid.hide-er .er-col { display: none; }
.payroll-grid td, .payroll-setup td { padding: .25rem .3rem; }
