/* ============================================================
   Church CMS – Master Stylesheet
   All pages use this single file.
   ============================================================ */

/* ── Google Fonts: Outfit + Lora ── */

/* ── CSS Variables ── */
:root {
  --primary:        #4f46e5;
  --primary-dark:   #3730a3;
  --primary-light:  #e0e7ff;
  --secondary:      #7c3aed;
  --accent:         #f0a500;
  --accent-light:   #fef3c7;
  --success:        #059669;
  --success-light:  #d1fae5;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --info:           #0284c7;
  --info-light:     #e0f2fe;
  --purple:         #9333ea;
  --purple-light:   #f3e8ff;

  --sidebar-bg:     #14113a;
  --sidebar-text:   #a5b4fc;
  --sidebar-hover:  rgba(99,102,241,.15);
  --sidebar-active: #4f46e5;
  --sidebar-width:  260px;

  --body-bg:        #f1f5f9;
  --card-bg:        #ffffff;
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --border:         #e2e8f0;
  --border-focus:   #4f46e5;

  --topbar-height:  64px;
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --radius-xl:      20px;
  --radius-full:    9999px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow:     0 4px 12px rgba(0,0,0,.08);
  --shadow-md:  0 8px 24px rgba(0,0,0,.1);
  --shadow-lg:  0 16px 48px rgba(0,0,0,.12);

  --font-body:    'Outfit', system-ui, sans-serif;
  --font-heading: 'Outfit', system-ui, sans-serif;
  --transition:   .2s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--body-bg);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-body); }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.logo-text { display: flex; flex-direction: column; }
.logo-name { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.2; }
.logo-sub  { color: var(--sidebar-text); font-size: .72rem; opacity: .7; }

.sidebar-close {
  display: none;
  background: none; border: none;
  color: var(--sidebar-text); font-size: 1.2rem;
  padding: 4px; border-radius: var(--radius-sm);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  color: var(--sidebar-text);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 14px 10px 6px;
  opacity: .5;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: .9rem;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,.4);
}

.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-footer-text { color: var(--sidebar-text); font-size: .75rem; opacity: .5; }

/* ── Main Layout ── */
.main-layout {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none; border: none;
  padding: 6px; border-radius: var(--radius-sm);
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

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

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: 28px 28px 40px;
  max-width: 1400px;
  width: 100%;
}

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .875rem;
  font-family: var(--font-body);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(79,70,229,.4); color: #fff; }

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
  border-color: transparent;
}
.btn-secondary:hover { background: var(--primary); color: #fff; }

.btn-success {
  background: linear-gradient(135deg, var(--success), #10b981);
  color: #fff;
  box-shadow: 0 4px 12px rgba(5,150,105,.3);
}
.btn-success:hover { transform: translateY(-2px); color: #fff; }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #ef4444);
  color: #fff;
  box-shadow: 0 4px 12px rgba(220,38,38,.25);
}
.btn-danger:hover { transform: translateY(-2px); color: #fff; }

.btn-warning {
  background: linear-gradient(135deg, var(--warning), #f59e0b);
  color: #fff;
}
.btn-warning:hover { transform: translateY(-2px); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--body-bg); color: var(--text-primary); }

.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; gap: 0; border-radius: var(--radius-sm); }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

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

.card-subtitle { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100px; height: 100px;
  border-radius: 50%;
  opacity: .06;
  background: var(--stat-color, var(--primary));
  transform: translate(30px, -30px);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 14px;
  background: var(--stat-bg, var(--primary-light));
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

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

.stat-change {
  font-size: .75rem;
  font-weight: 600;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Stat card color variants */
.stat-card.indigo  { --stat-color: #4f46e5; --stat-bg: #e0e7ff; }
.stat-card.purple  { --stat-color: #7c3aed; --stat-bg: #f3e8ff; }
.stat-card.pink    { --stat-color: #db2777; --stat-bg: #fce7f3; }
.stat-card.teal    { --stat-color: #0d9488; --stat-bg: #ccfbf1; }
.stat-card.orange  { --stat-color: #ea580c; --stat-bg: #ffedd5; }
.stat-card.sky     { --stat-color: #0284c7; --stat-bg: #e0f2fe; }
.stat-card.green   { --stat-color: #059669; --stat-bg: #d1fae5; }
.stat-card.gold    { --stat-color: #d97706; --stat-bg: #fef3c7; }

/* ── Dashboard Grid ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

/* ── Birthday Cards ── */
.birthday-list { display: flex; flex-direction: column; gap: 12px; }

.birthday-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--body-bg);
  border-radius: var(--radius);
  transition: background var(--transition);
}
.birthday-item:hover { background: var(--primary-light); }

.birthday-days {
  min-width: 44px; height: 44px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.birthday-days .num { font-size: 1.2rem; font-weight: 800; line-height: 1; }
.birthday-days .day-label { font-size: .6rem; opacity: .8; text-transform: uppercase; }

.birthday-days.today  { background: var(--accent); }
.birthday-days.soon   { background: var(--secondary); }

.birthday-info { flex: 1; min-width: 0; }
.birthday-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.birthday-meta { font-size: .75rem; color: var(--text-muted); }

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 14px;
  padding-bottom: 16px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 18px; top: 34px;
  width: 2px; bottom: 0;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }

.timeline-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--primary-light);
  color: var(--primary);
  z-index: 1;
}

.timeline-body { flex: 1; min-width: 0; padding-top: 4px; }
.timeline-title { font-weight: 600; font-size: .9rem; }
.timeline-sub   { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Tables ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

thead th {
  background: var(--body-bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-primary);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(79,70,229,.03); }

.member-cell { display: flex; align-items: center; gap: 10px; }
.member-cell-info {}
.member-cell-name { font-weight: 600; font-size: .9rem; }
.member-cell-sub  { font-size: .75rem; color: var(--text-muted); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.badge-primary  { background: var(--primary-light); color: var(--primary); }
.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-danger   { background: var(--danger-light);  color: var(--danger); }
.badge-info     { background: var(--info-light);    color: var(--info); }
.badge-purple   { background: var(--purple-light);  color: var(--purple); }
.badge-secondary{ background: #f1f5f9; color: var(--text-secondary); }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }

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

.form-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-label .required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: .75rem; color: var(--text-muted); }
.form-error { font-size: .75rem; color: var(--danger); font-weight: 500; }

.form-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px dashed var(--border);
}
.form-section:last-child { border-bottom: none; }

.form-section-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Photo upload */
.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--body-bg);
}
.photo-upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.photo-upload-area input[type=file] { display: none; }
.photo-preview { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px; }

/* ── Search & Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .875rem;
  outline: none;
  transition: border-color var(--transition);
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.search-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .9rem;
  pointer-events: none;
}

.filter-select {
  padding: 10px 32px 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .875rem;
  color: var(--text-primary);
  background: var(--card-bg);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

/* ── Flash Messages ── */
.flash {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown .3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-success { background: var(--success-light); color: #064e3b; border: 1px solid #6ee7b7; }
.flash-error   { background: var(--danger-light);  color: #7f1d1d; border: 1px solid #fca5a5; }
.flash-info    { background: var(--info-light);    color: #0c4a6e; border: 1px solid #7dd3fc; }
.flash-warning { background: var(--warning-light); color: #78350f; border: 1px solid #fcd34d; }

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
  padding: 0 8px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Profile / Member View ── */
.profile-header {
  background: linear-gradient(135deg, #1a1363 0%, #4f46e5 100%);
  border-radius: var(--radius-xl);
  padding: 36px;
  color: #fff;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.profile-header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 250px; height: 250px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}

.profile-header::after {
  content: '';
  position: absolute;
  bottom: -80px; left: 40%;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
}

.profile-header-inner {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  position: relative;
  z-index: 1;
}

.profile-avatar {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.3);
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; font-weight: 700;
}

.profile-name {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.profile-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: .85rem;
  opacity: .85;
  margin-bottom: 12px;
}

.profile-meta-item { display: flex; align-items: center; gap: 5px; }

.profile-badges { display: flex; gap: 8px; flex-wrap: wrap; }

.profile-badge {
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: .75rem;
  font-weight: 700;
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
}

/* ── Family Tree ── */
.family-tree {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.family-section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.family-members-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.family-member-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--body-bg);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
}
.family-member-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.family-connector {
  padding: 10px 20px;
  border-left: 3px solid var(--primary-light);
  margin-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Info Grid (member details) ── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.info-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.info-item:nth-last-child(-n+2) { border-bottom: none; }

.info-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.info-value {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ── Household card ── */
.household-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.household-card:hover { box-shadow: var(--shadow-md); }

.household-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  padding: 18px 20px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.household-num {
  font-size: 1.3rem;
  font-weight: 800;
}

.household-count {
  font-size: .8rem;
  opacity: .85;
  margin-top: 2px;
}

.household-members { padding: 16px; display: flex; flex-direction: column; gap: 8px; }

.household-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--transition);
}
.household-member:hover { background: var(--body-bg); color: var(--primary); }
.household-member-name { font-weight: 600; }
.household-member-rel  { font-size: .75rem; color: var(--text-muted); }

/* ── Families grid ── */
.families-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

/* ── Reports ── */
.report-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.report-option {
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  text-decoration: none;
  display: block;
  color: var(--text-primary);
}

.report-option:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  color: var(--primary);
}

.report-option-icon { font-size: 2.5rem; margin-bottom: 12px; }
.report-option-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.report-option-desc { font-size: .8rem; color: var(--text-muted); }

/* ── Charts ── */
.chart-container {
  position: relative;
  height: 250px;
}

.chart-container.tall { height: 320px; }

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-icon { font-size: 3.5rem; margin-bottom: 16px; opacity: .5; }
.empty-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; color: var(--text-secondary); }
.empty-desc  { font-size: .875rem; color: var(--text-muted); max-width: 320px; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-header-left p {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: 4px;
}

.page-header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; flex-wrap: wrap; }

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-btn:hover { color: var(--primary); background: var(--primary-light); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalPop .25s ease;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 12px; }
.modal-body  { color: var(--text-secondary); font-size: .9rem; margin-bottom: 24px; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Print ── */
.print-header { display: none; }

@media print {
  body { background: #fff !important; }
  .sidebar, .topbar, .hamburger, .sidebar-overlay,
  .btn, .filter-bar, .pagination, .topbar-actions,
  .no-print { display: none !important; }
  .main-layout { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; }
  .print-header { display: block; text-align: center; padding: 20px; border-bottom: 2px solid #1a1363; margin-bottom: 20px; }
  .print-header h2 { font-size: 1.4rem; color: #1a1363; }
  table { font-size: 11pt; }
  thead th { background: #f1f5f9 !important; }
  .profile-header { background: #1a1363 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a[href]::after { content: none !important; }
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .dashboard-grid   { grid-template-columns: 1fr; }
  .dashboard-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid  { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .info-grid  { grid-template-columns: 1fr; }
  .info-item:nth-last-child(-n+2) { border-bottom: 1px solid var(--border); }
  .info-item:last-child { border-bottom: none; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 280px; }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-close { display: block; }
  .sidebar-overlay.open { display: block; }

  .main-layout { margin-left: 0; }

  .hamburger { display: flex; }

  .page-content { padding: 16px 16px 32px; }

  .profile-header { padding: 24px; }
  .profile-header-inner { flex-direction: column; gap: 16px; }
  .profile-name { font-size: 1.4rem; }

  .dashboard-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-value { font-size: 1.6rem; }

  .topbar { padding: 0 16px; }
  .topbar-title { font-size: .95rem; }

  .families-grid { grid-template-columns: 1fr; }
  .report-option-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .report-option-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .modal { padding: 24px; }
}

/* ── Utility classes ── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.d-flex { display: flex; align-items: center; gap: 10px; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-100 { width: 100%; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.section-gap { margin-bottom: 28px; }

/* ── Age Category Badges (inline style overridden but kept for fallback) ── */
.cat-infant   { background: #f3e8ff; color: #9333ea; }
.cat-children { background: #d1fae5; color: #059669; }
.cat-youth    { background: #dbeafe; color: #2563eb; }
.cat-adult    { background: #fef3c7; color: #d97706; }
.cat-unknown  { background: #f1f5f9; color: #64748b; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Smooth focus ring ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Animated loading spinner ── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Avatar sizes ── */
.avatar-sm  { width: 32px;  height: 32px;  border-radius: 50%; object-fit: cover; }
.avatar-md  { width: 48px;  height: 48px;  border-radius: 50%; object-fit: cover; }
.avatar-lg  { width: 80px;  height: 80px;  border-radius: 50%; object-fit: cover; }
.avatar-xl  { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }
