/* ============================================================
   Hope Nest CHMS — Modern Professional SaaS Design System
   Clean, High-Contrast, Flat & Solid (No Glows, No Gradients)
   Compatible with Tailwind CSS & Bootstrap 5
   ============================================================ */

:root {
  /* Typography */
  --font-sans: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* SaaS Theme Colors */
  --bg-sidebar: #0F172A;           /* Deep Slate 900 */
  --bg-sidebar-hover: #1E293B;     /* Slate 800 */
  --bg-sidebar-active: #2563EB;    /* Solid Blue 600 */
  
  --bg-main: #F8FAFC;              /* Clean Slate 50 Canvas */
  --bg-card: #FFFFFF;              /* Crisp White Surface */
  --bg-card-elevated: #F1F5F9;     /* Subtle Slate 100 */
  --border-subtle: #E2E8F0;        /* Crisp 1px Slate 200 Border */
  --border-focus: #2563EB;

  /* Typography Colors */
  --text-primary: #0F172A;         /* Slate 900 */
  --text-secondary: #475569;       /* Slate 600 */
  --text-muted: #64748B;           /* Slate 500 */
  --text-sidebar: #94A3B8;         /* Slate 400 */

  /* Semantic Solid Accent Palette */
  --color-orange: #D97706;         /* Amber 600 */
  --color-orange-subtle: #FFFBEB;  /* Amber 50 */

  --color-blue: #2563EB;           /* Blue 600 */
  --color-blue-subtle: #EFF6FF;    /* Blue 50 */

  --color-purple: #7C3AED;         /* Purple 600 */
  --color-purple-subtle: #FAF5FF;  /* Purple 50 */

  --color-green: #059669;          /* Emerald 600 */
  --color-green-subtle: #ECFDF5;   /* Emerald 50 */

  --color-danger: #DC2626;         /* Red 600 */
  --color-danger-subtle: #FEF2F2;  /* Red 50 */

  /* Hope Nest Brand Variables (Clean Solid SaaS Tones) */
  --hn-teal:          #0D9488;     /* Teal 600 */
  --hn-teal-subtle:   #F0FDFA;     /* Teal 50 */
  --hn-green:         #059669;     /* Emerald 600 */
  --hn-green-subtle:  #ECFDF5;     /* Emerald 50 */
  --hn-amber:         #D97706;     /* Amber 600 */
  --hn-amber-subtle:  #FFFBEB;     /* Amber 50 */
  --hn-navy:          #0F172A;     /* Slate 900 */
  --hn-coral:         #DC2626;     /* Red 600 */
  --hn-coral-subtle:  #FEF2F2;     /* Red 50 */
  --hn-soft-blue:     #EFF6FF;

  /* Crisp, Subtle SaaS Shadows (Zero Neon Glow) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 4px 8px -2px rgba(0, 0, 0, 0.06);
  --shadow-sidebar: none;

  /* Radii & Transitions */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease-in-out;
  --role-accent: #0F766E;
  --role-soft: #F0FDFA;
  --role-strong: #134E4A;
}

body[data-role="admin"] { --role-accent: #0F766E; --role-soft: #F0FDFA; --role-strong: #134E4A; }
body[data-role="caregiver"] { --role-accent: #7C3AED; --role-soft: #F5F3FF; --role-strong: #4C1D95; }
body[data-role="finance_officer"] { --role-accent: #2563EB; --role-soft: #EFF6FF; --role-strong: #1E3A8A; }
body[data-role="donor"] { --role-accent: #D97706; --role-soft: #FFFBEB; --role-strong: #78350F; }

/* ── Reset & Base (Safe alongside Bootstrap) ──────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ── App Layout ───────────────────────────────────────────── */
#app {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* ── Sidebar (Clean Slate SaaS Navbar) ────────────────────── */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid #1E293B;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  box-shadow: none;
  transition: width 0.2s ease, transform 0.2s ease;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #1E293B;
}

.sidebar-brand-text {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.sidebar-toggle-btn:hover {
  background: #1E293B;
  color: #FFFFFF;
}

.topbar-sidebar-toggle {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  margin-right: 8px;
}

.topbar-sidebar-toggle:hover {
  background: #F1F5F9;
  color: var(--text-primary);
}

.logo-badge, .hn-logo-badge {
  width: 36px;
  height: 36px;
  background: #2563EB !important;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: none !important;
  flex-shrink: 0;
}

.logo-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #FFFFFF;
}

.logo-subtitle, .hn-tagline {
  font-size: 0.7rem;
  color: #94A3B8;
  font-weight: 500;
  font-style: normal;
}

.nav-menu {
  padding: 16px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: #94A3B8;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.nav-item:hover {
  background: #1E293B !important;
  color: #F8FAFC !important;
}

.nav-item.active {
  background: #2563EB !important;
  color: #FFFFFF !important;
  font-weight: 600;
  box-shadow: none !important;
}

.nav-item.active svg,
.nav-item.active i {
  color: #FFFFFF !important;
}

/* ── Collapsed Sidebar ────────────────────────────────────── */
body.sidebar-collapsed .sidebar {
  width: 68px;
}

body.sidebar-collapsed .sidebar-header {
  padding: 16px 8px;
  justify-content: center;
}

body.sidebar-collapsed .logo-badge {
  width: 36px;
  height: 36px;
  margin: 0 auto;
}

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .sidebar-toggle-btn,
body.sidebar-collapsed .user-name,
body.sidebar-collapsed .user-role-badge,
body.sidebar-collapsed .user-info-text {
  display: none !important;
}

body.sidebar-collapsed .nav-menu {
  padding: 16px 0;
  gap: 6px;
  align-items: center;
}

body.sidebar-collapsed .nav-item {
  position: relative;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.sidebar-collapsed .nav-item:hover {
  background: #1E293B;
}

body.sidebar-collapsed .nav-item.active {
  background: #2563EB;
  box-shadow: none;
}

body.sidebar-collapsed .sidebar-footer .user-card {
  justify-content: center;
  padding: 8px 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

body.sidebar-collapsed .user-avatar {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  box-shadow: none;
}

body.sidebar-collapsed .main-wrapper {
  margin-left: 68px;
}

/* ── Floating Hover Flyout ────────────────────────────────── */
.nav-hover-flyout {
  position: fixed;
  z-index: 1050;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-6px) translateY(-50%);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  box-shadow: var(--shadow-lg);
}

.nav-hover-flyout.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) translateY(-50%);
}

.flyout-arrow {
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: #0F172A;
  border-left: 1px solid #334155;
  border-bottom: 1px solid #334155;
}

.flyout-content {
  background: #0F172A;
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-width: 220px;
  max-width: 280px;
}

.flyout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.flyout-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #F8FAFC;
}

.flyout-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #93C5FD;
  background: #1E3A8A;
  padding: 1px 6px;
  border-radius: 4px;
}

.flyout-desc {
  font-size: 0.75rem;
  color: #94A3B8;
  line-height: 1.4;
}

/* ── Sidebar Footer User Card ─────────────────────────────── */
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid #1E293B;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: #1E293B;
  border: 1px solid #334155;
}

.user-avatar-wrapper {
  position: relative;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: #334155;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: none;
}

.user-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background-color: #10B981;
  border: 2px solid #0F172A;
  border-radius: 50%;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.user-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: #FFFFFF;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #064E3B;
  color: #6EE7B7;
  border: 1px solid #047857;
  width: fit-content;
}

.role-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: currentColor;
}

/* ── Main Dashboard Canvas ────────────────────────────────── */
.main-wrapper {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-main);
  transition: margin-left 0.2s ease;
}

/* ── Topbar (Clean Crisp White SaaS Header) ───────────────── */
.topbar {
  height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: none;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Topbar User Profile Pill ─────────────────────────────── */
.topbar-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  background: #F8FAFC;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-user-pill:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: #0F172A;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.725rem;
  font-weight: 700;
  box-shadow: none;
}

.topbar-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topbar-user-name {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-user-role {
  font-size: 0.65rem;
  font-weight: 700;
  color: #2563EB;
  letter-spacing: 0.02em;
}

/* ── Role & Currency Segmented Controls ───────────────────── */
.role-switcher-container {
  display: flex;
  align-items: center;
  background: #F1F5F9;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.role-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.role-btn:hover {
  color: var(--text-primary);
}

.role-btn.active {
  background: #FFFFFF;
  color: #0F172A;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

#currency-switcher .role-btn.active {
  background: #FFFFFF;
  color: #0F172A;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.role-btn[data-role].active {
  background: var(--role-accent);
  border-color: var(--role-accent);
  color: #FFFFFF;
}

body[data-role] .topbar-avatar,
body[data-role] .logo-badge,
body[data-role] .hn-logo-badge {
  background: var(--role-accent) !important;
}

body[data-role] .topbar-user-role { color: var(--role-accent); }
body[data-role] .nav-item.active { background: var(--role-accent); }

.content-container {
  padding: 28px;
  flex: 1;
  max-width: 1440px;
  width: 100%;
}

/* ── Crisp SaaS Stat Cards ────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}

.stat-card:hover {
  border-color: #CBD5E1;
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.stat-meta {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.stat-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F8FAFC;
  border: 1px solid var(--border-subtle);
}

/* ── Chart Panels ─────────────────────────────────────────── */
.chart-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  height: 380px;
  display: flex;
  flex-direction: column;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.chart-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

/* ── Content Cards & Tables ───────────────────────────────── */
.card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 12px;
  background: #FFFFFF;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  padding: 10px 16px;
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-subtle);
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 500;
}

.data-table tr:hover td {
  background: #F8FAFC;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ── Activity Feed Timeline ───────────────────────────────── */
.activity-feed-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #F1F5F9;
}

.activity-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.activity-icon-pill {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F1F5F9;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.activity-meta {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.badge-active, .badge-verified, .badge-good, .badge-paid, .badge-approved {
  background: #ECFDF5;
  color: #059669;
  border-color: #A7F3D0;
}

.badge-pending, .badge-fair {
  background: #FFFBEB;
  color: #D97706;
  border-color: #FDE68A;
}

.badge-discharged, .badge-rejected, .badge-poor, .badge-critical {
  background: #FEF2F2;
  color: #DC2626;
  border-color: #FECACA;
}

.badge-role {
  background: #EFF6FF;
  color: #2563EB;
  border-color: #BFDBFE;
}

/* ── Solid Flat SaaS Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-primary, .btn-hn {
  background: #2563EB !important;
  color: #FFFFFF !important;
  border: 1px solid #1D4ED8 !important;
  box-shadow: var(--shadow-sm) !important;
}

.btn-primary:hover, .btn-hn:hover {
  background: #1D4ED8 !important;
  transform: none !important;
}

.btn-secondary {
  background: #FFFFFF;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: #F8FAFC;
  color: var(--text-primary);
  border-color: #CBD5E1;
}

.btn-emerald {
  background: #059669;
  color: #FFFFFF;
  border-color: #047857;
}

.btn-emerald:hover {
  background: #047857;
}

.btn-rose {
  background: #DC2626;
  color: #FFFFFF;
  border-color: #B91C1C;
}

.btn-rose:hover {
  background: #B91C1C;
}

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: var(--text-primary);
  background: #F1F5F9;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #F8FAFC;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.full-width {
  grid-column: span 2;
}

.form-label {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* ── Tabs inside Modals ───────────────────────────────────── */
.tabs-nav {
  display: flex;
  background: #F1F5F9;
  border-bottom: 1px solid var(--border-subtle);
  padding: 4px 8px;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tab-btn.active {
  background: #FFFFFF;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

/* ── Code / JSON Viewer in API Explorer ───────────────────── */
.code-box {
  background: #0F172A;
  border: 1px solid #1E293B;
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: #E2E8F0;
  overflow-x: auto;
  line-height: 1.5;
}

/* ── Toast Notifications ──────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
}

.toast-success i, .toast-success svg { color: #059669; }
.toast-error i, .toast-error svg { color: #DC2626; }
.toast-info i, .toast-info svg { color: #2563EB; }

/* ── Role Identity Badges ─────────────────────────────────── */
.director-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #F1F5F9;
  color: #0F172A;
  border: 1px solid #CBD5E1;
}

.donor-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #FFFBEB;
  color: #D97706;
  border: 1px solid #FDE68A;
}

.staff-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #FAF5FF;
  color: #7C3AED;
  border: 1px solid #E9D5FF;
}

/* ── Role-Gate Overlay Panel ─────────────────────────────── */
.role-gate-panel {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 48px 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.role-gate-icon {
  width: 52px;
  height: 52px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #D97706;
  margin-bottom: 4px;
}

.role-gate-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.role-gate-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 460px;
  line-height: 1.5;
}

/* ── Budget Progress Bars ─────────────────────────────────── */
.budget-progress-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 1px solid #F1F5F9;
}

.budget-progress-row:last-child { border-bottom: none; }

.budget-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.825rem;
}

.budget-category-name {
  font-weight: 600;
  color: var(--text-primary);
}

.budget-amounts {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.775rem;
}

.budget-actual { color: var(--text-secondary); }
.budget-of { color: var(--text-muted); }
.budget-total { font-weight: 700; color: var(--text-primary); }

.budget-bar-track {
  width: 100%;
  height: 6px;
  background: #F1F5F9;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
  background: #2563EB;
}

.budget-bar-fill.over-budget {
  background: #DC2626;
}

/* ── Reconciliation Variance Indicators ──────────────────── */
.recon-diff-positive {
  color: #059669;
  font-weight: 700;
}

.recon-diff-negative {
  color: #DC2626;
  font-weight: 700;
}

.recon-summary-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.recon-metric {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  text-align: center;
}

.recon-metric-label {
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.recon-metric-value {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ── Q&A Thread Cards ─────────────────────────────────────── */
.qa-thread-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qa-thread-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.qa-thread-card:hover {
  border-color: #CBD5E1;
  box-shadow: var(--shadow-sm);
}

.qa-thread-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2563EB;
  flex-shrink: 0;
}

.qa-thread-meta {
  flex: 1;
  min-width: 0;
}

.qa-thread-subject {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qa-thread-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.qa-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.qa-status-open     { background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE; }
.qa-status-answered { background: #ECFDF5; color: #059669; border: 1px solid #A7F3D0; }
.qa-status-closed   { background: #F1F5F9; color: var(--text-muted); border: 1px solid #E2E8F0; }

/* ── Q&A Conversation Bubbles ─────────────────────────────── */
.qa-conversation {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.qa-bubble-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.qa-bubble-wrapper.from-director {
  flex-direction: row-reverse;
}

.qa-bubble-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.675rem;
  font-weight: 700;
  flex-shrink: 0;
}

.qa-avatar-donor    { background: #FFFBEB; color: #D97706; border: 1px solid #FDE68A; }
.qa-avatar-director { background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE; }

.qa-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.qa-bubble-donor    { background: #F1F5F9; border: 1px solid #E2E8F0; }
.qa-bubble-director { background: #EFF6FF; border: 1px solid #BFDBFE; }

.qa-bubble-time {
  font-size: 0.675rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Impact Story Cards ───────────────────────────────────── */
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.story-card {
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
  cursor: pointer;
}

.story-card:hover {
  border-color: #CBD5E1;
}

.story-card-cover {
  width: 100%;
  height: 170px;
  object-fit: cover;
  display: block;
}

.story-card-cover-placeholder {
  width: 100%;
  height: 170px;
  background: #F1F5F9;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748B;
}

.story-card-body {
  padding: 16px 18px;
}

.story-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.story-tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #EFF6FF;
  color: #2563EB;
  border: 1px solid #BFDBFE;
}

.story-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.35;
}

.story-card-excerpt {
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #F8FAFC;
}

/* ── Impact Metric Pills (Donor Dashboard) ──────────────── */
.impact-metrics-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.impact-metric-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  flex: 1;
  min-width: 150px;
}

.impact-metric-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F8FAFC;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.impact-metric-content { flex: 1; }

.impact-metric-value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.1;
}

.impact-metric-label {
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Audit Trail Table ────────────────────────────────────── */
.audit-action-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.675rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.audit-CREATE { background: #ECFDF5; color: #059669; border: 1px solid #A7F3D0; }
.audit-UPDATE { background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE; }
.audit-DELETE { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.audit-READ   { background: #F1F5F9; color: #64748B; border: 1px solid #E2E8F0; }

/* ── Read-Only Indicator ─────────────────────────────────── */
.read-only-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: #92400E;
  margin-bottom: 18px;
}

/* ── Approval Status Chips ────────────────────────────────── */
.approval-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.approval-chip-draft    { background: #F1F5F9; color: var(--text-muted); border: 1px solid #E2E8F0; }
.approval-chip-approved { background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE; }
.approval-chip-active   { background: #ECFDF5; color: #059669; border: 1px solid #A7F3D0; }
.approval-chip-closed   { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }

.export-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-welcome {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  margin-bottom: 20px;
  border: 1px solid color-mix(in srgb, var(--role-accent) 22%, white);
  border-left: 4px solid var(--role-accent);
  border-radius: 12px;
  background: var(--role-soft);
}

.dashboard-welcome h2 {
  margin: 5px 0 4px;
  color: var(--role-strong);
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.dashboard-welcome p { color: var(--text-secondary); font-size: 0.9rem; }
.eyebrow { color: var(--role-accent); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.welcome-meta { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--role-strong); font-size: 0.75rem; font-weight: 700; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #10B981; box-shadow: 0 0 0 4px #D1FAE5; }

.resident-strip { margin-bottom: 24px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 12px; }
.section-heading h3 { margin-top: 3px; font-size: 1rem; font-weight: 750; }
.text-button { border: 0; background: transparent; color: var(--role-accent); font: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.resident-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.resident-card { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 14px; text-align: left; background: #FFFFFF; border: 1px solid var(--border-subtle); border-radius: 10px; cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; }
.resident-card:hover { transform: translateY(-2px); border-color: var(--role-accent); box-shadow: var(--shadow-hover); }
.resident-avatar { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 50%; background: color-mix(in srgb, var(--avatar-color) 14%, white); color: var(--avatar-color); border: 1px solid color-mix(in srgb, var(--avatar-color) 28%, white); font-size: 0.74rem; font-weight: 800; }
.resident-info { display: flex; flex-direction: column; min-width: 0; }
.resident-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); font-size: 0.82rem; }
.resident-info small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 0.66rem; }
.resident-info em { margin-top: 4px; color: var(--role-accent); font-size: 0.64rem; font-style: normal; font-weight: 700; }
.child-name-cell { display: flex; align-items: center; gap: 10px; }
.child-avatar, .child-profile-avatar { object-fit: cover; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--role-accent) 25%, white); }
.child-avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; }
.child-profile-avatar { display: grid; place-items: center; width: 64px; height: 64px; flex: 0 0 64px; font-size: 1rem; }
.child-avatar-fallback { background: var(--role-soft); color: var(--role-accent); font-weight: 800; }
.child-profile-heading { display: flex; align-items: center; gap: 15px; padding: 14px; margin-bottom: 20px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--role-soft); }
.child-profile-heading h3 { margin: 2px 0; font-size: 1.15rem; }
.child-profile-heading p { color: var(--text-muted); font-size: 0.75rem; }

@media (max-width: 1100px) {
  .topbar { height: auto; min-height: 64px; align-items: flex-start; padding-block: 12px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .resident-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.home-switcher { display: flex; align-items: center; gap: 10px; margin: 12px; padding: 10px; color: #FFFFFF; background: #1E293B; border: 1px solid #334155; border-radius: 8px; }
.home-mark { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 6px; background: #FFFFFF; color: #0F172A; font-size: 0.68rem; font-weight: 800; }
.home-switcher > span:nth-child(2) { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.home-switcher small { color: #94A3B8; font-size: 0.58rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.home-switcher strong { overflow: hidden; font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.home-chevron { color: #94A3B8; }
.mobile-home-name { display: none; color: var(--text-muted); font-size: 0.65rem; font-weight: 600; }
.sidebar-backdrop { display: none; }
.connection-status { position: fixed; right: 16px; bottom: 16px; z-index: 2000; display: none; padding: 9px 13px; color: #FFFFFF; background: #92400E; border: 0; border-radius: 6px; font-size: 0.72rem; font-weight: 700; box-shadow: var(--shadow-lg); }
body.is-offline .connection-status { display: block; }
body.sidebar-collapsed .home-switcher { padding: 8px 6px; justify-content: center; }
body.sidebar-collapsed .home-switcher > span:not(.home-mark) { display: none; }

@media (max-width: 760px) {
  body { overflow-x: hidden; }
  .sidebar { width: min(86vw, 300px); transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.mobile-nav-open { overflow: hidden; }
  body.mobile-nav-open .sidebar { transform: translateX(0); }
  body.mobile-nav-open .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; display: block; background: rgba(15, 23, 42, 0.52); border: 0; }
  .main-wrapper, body.sidebar-collapsed .main-wrapper { margin-left: 0; width: 100%; min-width: 0; }
  .topbar { min-height: 64px; padding-inline: 14px; align-items: center; }
  .topbar-left { min-width: 0; }
  .page-title { max-width: 52vw; overflow: hidden; font-size: 0.92rem; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-home-name { display: block; }
  .topbar-actions { flex-wrap: nowrap; }
  .topbar-actions > div:first-child, .topbar-actions > span, .topbar-actions > div[style*="height:24px"], .topbar-user-meta { display: none !important; }
  .role-switcher-container:not(#currency-switcher) { max-width: 36vw; overflow-x: auto; scrollbar-width: none; }
  .role-btn { padding-inline: 8px; white-space: nowrap; }
  .topbar-user-pill { padding-right: 6px; }
  .content-container { min-width: 0; padding: 18px 14px 76px; overflow: hidden; }
  .dashboard-welcome { align-items: flex-start; flex-direction: column; padding: 22px; }
  .resident-grid, .stats-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; gap: 8px; flex-direction: column; }
  .card, .chart-card { max-width: 100%; }
  .content-container > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; gap: 16px !important; }
  .impact-metrics-row { display: grid; grid-template-columns: 1fr; }
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .modal-container { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full-width { grid-column: auto; }
  .connection-status { right: 12px; bottom: 12px; left: 12px; text-align: center; }
}
