:root {
  --maroon: #6b1e2b;
  --maroon-dark: #4a1420;
  --maroon-light: #8a2e3d;
  --gold: #c9a227;
  --gold-light: #e6c869;
  --cream: #faf7f0;
  --charcoal: #2b2420;
  --muted: #7a6f63;
  --sidebar-w: 250px;
}

body {
  background: var(--cream);
  color: var(--charcoal);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

h1, h2, h3, h4, h5, .brand-font {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--maroon-dark);
}

a { color: var(--maroon); }
a:hover { color: var(--gold); }

/* ---------- Navbar ---------- */
.app-navbar {
  background: linear-gradient(135deg, var(--maroon-dark), var(--maroon));
  padding: .6rem 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.app-navbar .navbar-brand {
  color: var(--gold-light) !important;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: .3px;
}
.app-navbar .btn-link { color: #fff !important; text-decoration: none; }
.app-navbar .dropdown-menu { border: none; box-shadow: 0 6px 20px rgba(0,0,0,.15); }

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: calc(100vh - 58px); }

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #eee2d0;
  padding: 1.25rem 0;
}
.app-sidebar .nav-section-title {
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .08em;
  color: var(--gold);
  font-weight: 700;
  padding: .9rem 1.25rem .35rem;
}
.app-sidebar .nav-link {
  color: var(--charcoal);
  padding: .55rem 1.25rem;
  border-left: 3px solid transparent;
  font-size: .93rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.app-sidebar .nav-link i { font-size: 1.05rem; color: var(--muted); width: 1.1rem; text-align: center; }
.app-sidebar .nav-link:hover { background: #fbf3e0; color: var(--maroon); }
.app-sidebar .nav-link.active {
  background: #fbf0d9;
  border-left-color: var(--gold);
  color: var(--maroon-dark);
  font-weight: 600;
}
.app-sidebar .nav-link.active i { color: var(--maroon); }

.app-main { flex-grow: 1; min-width: 0; }
.app-main-inner { padding: 1.75rem; max-width: 1400px; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid #f0e5cf;
  border-radius: .6rem;
  box-shadow: 0 2px 10px rgba(107,30,43,.05);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #f0e5cf;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  color: var(--maroon-dark);
}
.stat-card {
  border-radius: .75rem;
  padding: 1.25rem 1.5rem;
  color: #fff;
  background: linear-gradient(135deg, var(--maroon), var(--maroon-dark));
  box-shadow: 0 4px 14px rgba(107,30,43,.25);
}
.stat-card.gold { background: linear-gradient(135deg, var(--gold), #a9821c); box-shadow: 0 4px 14px rgba(201,162,39,.3); }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; font-family: 'Playfair Display', serif; }
.stat-card .stat-label { font-size: .8rem; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Buttons ---------- */
.btn-primary {
  background-color: var(--maroon);
  border-color: var(--maroon);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--maroon-dark);
  border-color: var(--maroon-dark);
}
.btn-outline-primary { color: var(--maroon); border-color: var(--maroon); }
.btn-outline-primary:hover { background-color: var(--maroon); border-color: var(--maroon); }
.btn-gold { background-color: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background-color: #a9821c; border-color: #a9821c; color: #fff; }

/* ---------- Tables ---------- */
.table thead th {
  background: #fbf3e0;
  color: var(--maroon-dark);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 2px solid var(--gold);
}
.table-hover tbody tr:hover { background: #fdf8ec; }

.badge-status-active, .badge.bg-active { background-color: #3f7a4f !important; }
.badge-status-inactive { background-color: #9a9a9a !important; }
.badge.bg-gold { background-color: var(--gold) !important; }

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, var(--maroon-light), var(--maroon-dark) 70%);
  padding: 1rem;
}
.login-card {
  background: #fff;
  border-radius: 1rem;
  overflow: hidden;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-card .login-header {
  background: linear-gradient(135deg, var(--maroon-dark), var(--maroon));
  color: #fff;
  padding: 2rem 1.75rem 1.5rem;
  text-align: center;
}
.login-card .login-header .cross-icon {
  font-size: 2.2rem;
  color: var(--gold-light);
  margin-bottom: .5rem;
}
.login-card .login-body { padding: 1.75rem; }

/* ---------- Misc ---------- */
.section-divider { border-top: 2px solid var(--gold); opacity: .5; margin: 1.5rem 0; }
.text-gold { color: var(--gold) !important; }
.bg-parchment { background: #fbf3e0; }
.avatar-circle {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--gold); color: var(--maroon-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}

@media (max-width: 991.98px) {
  .app-sidebar { display: none; }
}

@media print {
  .app-navbar, .app-sidebar, .no-print { display: none !important; }
  .app-main-inner { padding: 0; }
}

/* ---------- Announcement marquee ---------- */
.announcement-ticker {
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  color: var(--maroon-dark);
  font-weight: 600;
  padding: .45rem 0;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}
.announcement-ticker .ticker-track {
  display: inline-block;
  padding-left: 100%;
  animation: ticker-scroll 35s linear infinite;
}
.announcement-ticker .ticker-item { margin-right: 4rem; }
@keyframes ticker-scroll {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-100%, 0); }
}

/* ===================================================================
   Phase 4 — page furniture, pickers, financial grids
   =================================================================== */

/* ---------- Page heading row ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-head h2 { font-size: 1.6rem; margin: 0; }
.page-head p { font-size: .9rem; max-width: 62ch; }

.breadcrumb { font-size: .85rem; margin-bottom: .5rem; }
.breadcrumb-item + .breadcrumb-item::before { content: "\203A"; color: var(--gold); }

/* ---------- Filter bar ---------- */
.filter-card { background: #fffdf8; }
.filter-card .form-label {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; margin-bottom: .2rem;
}
.form-card { max-width: 820px; }

/* ---------- Stat cards ---------- */
.stat-card .stat-sub { font-size: .78rem; opacity: .8; margin-top: .15rem; }
.stat-card.stat-income   { background: linear-gradient(135deg, #2f6b48, #1f4a31); box-shadow: 0 4px 14px rgba(47,107,72,.25); }
.stat-card.stat-expense  { background: linear-gradient(135deg, #9a4b2e, #6e3520); box-shadow: 0 4px 14px rgba(154,75,46,.25); }
.stat-card.stat-surplus  { background: linear-gradient(135deg, #2f6b48, #1f4a31); }
.stat-card.stat-deficit  { background: linear-gradient(135deg, #9c2b2b, #6d1c1c); }
.stat-card.stat-neutral  { background: linear-gradient(135deg, #5a5a5a, #3a3a3a); }

/* Quiet variant for dense dashboards */
.stat-tile {
  background: #fff; border: 1px solid #f0e5cf; border-radius: .6rem;
  padding: 1rem 1.15rem; height: 100%;
  display: flex; flex-direction: column; gap: .15rem;
}
.stat-tile .stat-value { font-size: 1.55rem; font-weight: 700; font-family: 'Playfair Display', serif; color: var(--maroon-dark); line-height: 1.1; }
.stat-tile .stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat-tile .stat-sub { font-size: .78rem; color: var(--muted); }
.stat-tile a { text-decoration: none; }

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center; padding: 3rem 1.5rem;
  background: #fff; border: 1px dashed #e3d5b8; border-radius: .75rem;
}
.empty-state i { font-size: 2.75rem; color: var(--gold); opacity: .65; }
.empty-state p { max-width: 46ch; margin-inline: auto; }

/* ---------- Badges ---------- */
.badge-soft {
  background: #fbf3e0; color: var(--maroon-dark);
  font-weight: 600; font-size: .72rem; border: 1px solid #f0e5cf;
}
.badge-cat-association   { background:#e8eef7; color:#27456f; border-color:#d3e0ef; }
.badge-cat-choir         { background:#f3ecf7; color:#5b3271; border-color:#e6dbee; }
.badge-cat-youth         { background:#e9f4ec; color:#2c5c3d; border-color:#d6e9dc; }
.badge-cat-pious_society { background:#fdf0e5; color:#8a4a1c; border-color:#f5ddc7; }
.badge-cat-other         { background:#f1f1f1; color:#555; border-color:#e3e3e3; }

/* ---------- Typeahead pickers ---------- */
.lookup-picker .lookup-clear {
  position: absolute; right: .25rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); padding: .25rem .4rem;
}
.lookup-results {
  position: absolute; z-index: 1060; left: 0; right: 0; top: calc(100% + 2px);
  background: #fff; border: 1px solid #e3d5b8; border-radius: .5rem;
  box-shadow: 0 10px 28px rgba(107,30,43,.14);
  max-height: 17rem; overflow-y: auto;
}
.lookup-item {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: .5rem .75rem; border-bottom: 1px solid #f6efe1;
}
.lookup-item:last-child { border-bottom: 0; }
.lookup-item:hover, .lookup-item.active { background: #fbf3e0; }
.lookup-item .lookup-label { display: block; font-weight: 600; color: var(--charcoal); font-size: .9rem; }
.lookup-item .lookup-sub { display: block; font-size: .78rem; color: var(--muted); }
.lookup-empty { padding: .75rem; font-size: .85rem; color: var(--muted); }

/* ---------- Financial grids ---------- */
.fin-grid { font-size: .84rem; }
.fin-grid td, .fin-grid th { padding: .38rem .5rem; white-space: nowrap; }
.fin-grid tbody tr.fin-section th {
  background: var(--maroon-dark); color: #fff;
  font-family: 'Playfair Display', serif; letter-spacing: .04em;
  font-size: .8rem; text-transform: uppercase;
}
.fin-grid tbody tr.fin-section.section-income th  { background: #2f6b48; }
.fin-grid tbody tr.fin-section.section-expense th { background: #9a4b2e; }
.fin-grid tbody tr.fin-total th, .fin-grid tbody tr.fin-total td {
  background: #fbf3e0; border-top: 2px solid var(--gold); font-weight: 700;
}
.fin-grid tbody tr.fin-grand th, .fin-grid tbody tr.fin-grand td {
  background: var(--maroon-dark); color: #fff; font-weight: 700;
}
.fin-grid .money-input { min-width: 8rem; }
.card-header.section-income  { background: #f0f7f2; color: #235437; }
.card-header.section-expense { background: #fdf2ec; color: #7b3a21; }

.coa-table tr.coa-header td { background: #fbf3e0; border-top: 2px solid var(--gold); }

/* ---------- Sticky form actions ---------- */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 20;
  background: rgba(250,247,240,.94); backdrop-filter: blur(4px);
  border-top: 1px solid #e9dcc2; padding: .75rem 0; margin-top: 1rem;
}

/* ---------- Lists ---------- */
.doc-list .list-group-item { border-color: #f6efe1; }
.min-w-0 { min-width: 0; }

/* ---------- Leadership slate ---------- */
.slate-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid #f6efe1; }
.slate-row:last-child { border-bottom: 0; }
.slate-title {
  flex: 0 0 9.5rem; font-weight: 600; font-size: .85rem; color: var(--maroon-dark);
}
.slate-vacant { color: var(--muted); font-style: italic; }

/* ---------- Directory rows ---------- */
.person-line { display: flex; align-items: center; gap: .65rem; }
.person-initials {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: #fbf3e0; color: var(--maroon); border: 1px solid #f0e5cf;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem;
}

/* ---------- Hierarchy tree ---------- */
.tree-node { border-left: 2px solid #f0e5cf; padding-left: 1rem; margin-left: .5rem; }
.tree-node > .tree-label { font-weight: 600; }

@media (max-width: 575.98px) {
  .app-main-inner { padding: 1rem; }
  .page-head h2 { font-size: 1.35rem; }
}

.scope-badge {
  background: rgba(255,255,255,.15); color: var(--gold-light);
  font-weight: 600; font-size: .75rem; padding: .35rem .7rem; border-radius: 2rem;
}

.border-gold { border-color: var(--gold) !important; }

/* ---------- Role switcher ---------- */
.scope-card { border: 1px solid #f0e5cf; background: #fff; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.scope-card:hover { border-color: var(--gold); box-shadow: 0 6px 18px rgba(107,30,43,.10); }
.scope-card-active { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }

/* ---------- Collection grid ---------- */
.collect-table td, .collect-table th { padding: .4rem .5rem; }
.collect-table .form-control-sm { min-width: 5.5rem; }
.collect-table tbody tr.table-active { --bs-table-bg-state: #fbf3e0; }

@media print {
  .no-print, .sticky-actions, .filter-card, .breadcrumb, .nav-pills { display: none !important; }
  .no-print-link { color: inherit !important; text-decoration: none !important; }
  .card { border: 0 !important; box-shadow: none !important; }
}
