/* ==========================================================================
   Ammar Heritage - ITT588 Lab Work 04
   Family Heritage Tree Stylesheet
   Theme: Clean Modern Genealogy Visualizer (No Cartoon Figures, Clean Initials Badges)
   ========================================================================== */

:root {
  --marmalade: #8b3a3a;
  --cream: #faf3e0;
  --gold: #d4a853;
  --dark-charcoal: #1a1a1a;
  --slate: #2d3748;
  --muted: #a0aec0;
  --white: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(139, 58, 58, 0.2);
  --line-color: #cbd5e1;
  --line-active: #8b3a3a;
  --paternal-color: #8b3a3a;
  --maternal-color: #4caf50;

  --bg: #f8fafc;
  --surface: var(--white);
  --surface-alt: var(--cream);
  --text-main: var(--dark-charcoal);
  --text-muted: #64748b;
  --border: #e2e8f0;
  --tree-line: var(--line-color);
  --paternal: var(--paternal-color);
  --paternal-soft: #fbeae8;
  --maternal: var(--maternal-color);
  --maternal-soft: #e8f5e9;
  --immediate: var(--gold);
  --immediate-soft: #fff8e1;

  --male: #0284c7;
  --male-bg: #e0f2fe;
  --female: #db2777;
  --female-bg: #fce7f3;
  
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 35px -5px rgba(15, 23, 42, 0.12);
  --radius: 16px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-main);
  font: 14px/1.6 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: min(1440px, calc(100% - 32px));
  margin: auto;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
header {
  background: rgba(250, 243, 224, 0.85);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--marmalade);
  color: var(--cream);
  display: grid;
  place-items: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(139, 58, 58, 0.25);
}

.brand h1 {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}

.brand small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.navlinks {
  display: flex;
  gap: 8px;
}

.navlinks a,
.tab-btn {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 99px;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  font-size: 13px;
}

.navlinks a:hover,
.tab-btn:hover {
  color: var(--dark-charcoal);
  background: var(--surface-alt);
}

.navlinks a.active,
.tab-btn.active {
  color: var(--cream);
  background: var(--marmalade);
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(139, 58, 58, 0.2);
}

.hero-banner {
  background: linear-gradient(180deg, var(--white) 0%, var(--cream) 100%);
  border-bottom: 1px solid var(--border);
  padding: 24px 0 18px;
}

.hero-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
}

.hero-title h2 {
  font-size: clamp(20px, 2.6vw, 26px);
  margin: 0 0 4px;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.hero-title p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  max-width: 680px;
}

/* ==========================================================================
   Tree Lineage & Control Toolbar
   ========================================================================== */
.tree-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px 0 14px;
  padding: 12px 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.lineage-switcher {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lineage-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.lineage-btn:hover {
  background: var(--surface-alt);
  color: var(--text-main);
}

.lineage-btn.active {
  background: var(--marmalade);
  color: var(--cream);
  border-color: var(--gold);
}

.tree-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-pill {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}

.action-pill:hover {
  background: var(--marmalade);
  color: var(--cream);
  border-color: var(--gold);
}

/* ==========================================================================
   Filter & Search Toolbar
   ========================================================================== */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 14px 0 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

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

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--marmalade);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  outline: none;
  cursor: pointer;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  font-weight: 700;
  align-items: center;
  flex-wrap: wrap;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.dot-paternal { background: var(--paternal); }
.dot-maternal { background: var(--maternal); }
.dot-immediate { background: var(--immediate); }

/* ==========================================================================
   THE TRUE GENEALOGICAL FAMILY TREE (FULL WIDTH SCROLLABLE - NO CUT-OFF!)
   ========================================================================== */
.tree-viewport {
  display: block; /* Fixed: Not flex justify-center, which caused left cutoff! */
  overflow-x: auto;
  overflow-y: auto;
  padding: 40px 40px 90px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  min-height: 600px;
  width: 100%;
}

.genealogy-tree {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 100%;
  width: max-content;
  margin: 0 auto;
  transition: transform 0.2s ease-out;
}

.tree-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 10px 16px;
}

/* Couple Container (A + B connected horizontally) */
.tree-couple-box {
  display: flex;
  align-items: flex-start;
  position: relative;
  gap: 40px;
  padding: 8px;
}

.tree-marriage-bridge {
  position: absolute;
  left: 50%;
  top: 38px;
  transform: translateX(-50%);
  width: 40px;
  height: 2px;
  background: var(--tree-line);
}

.tree-marriage-bridge::after {
  content: "♥";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #e11d48;
  font-size: 14px;
  line-height: 1;
  background: #ffffff;
  padding: 0 2px;
}

/* Clean Person Member Node (No cartoon faces - clean initials badge) */
.tree-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  width: 135px;
  padding: 14px 8px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
}

.tree-member:hover {
  transform: translateY(-4px);
  border-color: var(--marmalade);
  box-shadow: 0 14px 28px rgba(139, 58, 58, 0.15);
}

.tree-avatar-circle {
  width: 74px;
  height: 74px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 850;
  font-size: 20px;
  letter-spacing: -0.02em;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  border: 2px solid var(--gold);
  position: relative;
  transition: box-shadow 0.18s, border-color 0.18s;
  user-select: none;
}

.tree-avatar-circle.male {
  background: var(--male-bg);
  color: var(--male);
}

.tree-avatar-circle.female {
  background: var(--female-bg);
  color: var(--female);
}

.tree-member:hover .tree-avatar-circle {
  border-color: var(--line-active);
  box-shadow: 0 0 15px rgba(212, 168, 83, 0.5);
}

.tree-member.is-me .tree-avatar-circle {
  border-color: var(--gold);
  background: var(--immediate-soft);
  color: #8a5d00;
  box-shadow: 0 0 0 3px var(--immediate-soft), 0 8px 20px rgba(212, 168, 83, 0.35);
}

.me-star-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--gold);
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 99px;
  border: 1.5px solid #ffffff;
}

.tree-member-role {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.06em;
  color: var(--slate);
  text-transform: uppercase;
}

.tree-member-name {
  font-size: 13px;
  font-weight: 750;
  color: var(--dark-charcoal);
  line-height: 1.25;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.tree-member-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

/* Connector Branches & Expand/Collapse Toggle */
.tree-branch-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 5;
}

.tree-stem-down {
  width: 2px;
  height: 28px;
  background: var(--tree-line);
}

.tree-toggle-pill {
  background: #ffffff;
  border: 1.5px solid var(--tree-line);
  border-radius: 99px;
  padding: 3px 11px;
  font-size: 11px;
  font-weight: 800;
  color: #1e293b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.18s;
  z-index: 5;
}

.tree-toggle-pill:hover {
  background: var(--marmalade);
  color: var(--cream);
  border-color: var(--gold);
  transform: scale(1.06);
}

.tree-toggle-pill.active-core {
  background: var(--immediate-soft);
  border-color: var(--gold);
  color: #8a5d00;
}

.tree-toggle-pill.collapsed {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #64748b;
}

/* Children Row Layout & Connectors */
.tree-children-wrapper {
  display: flex;
  justify-content: center;
  position: relative;
  padding-top: 24px;
  transition: opacity 0.25s, max-height 0.3s;
}

.tree-children-wrapper.collapsed {
  display: none !important;
}

/* Each child branch */
.tree-child-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 16px;
}

/* Vertical stem dropping into each child */
.tree-child-column::before {
  content: '';
  position: absolute;
  top: 0;
  height: 24px;
  width: 2px;
  background: var(--tree-line);
}

/* Horizontal crossbar connecting siblings */
.tree-child-column::after {
  content: '';
  position: absolute;
  top: 0;
  height: 2px;
  background: var(--tree-line);
  width: 100%;
}

.tree-child-column:first-child::after {
  left: 50%;
  width: 50%;
}

.tree-child-column:last-child::after {
  right: 50%;
  width: 50%;
}

.tree-child-column:only-child::after {
  display: none;
}

/* ==========================================================================
   REDESIGNED MEMBER DIRECTORY SYSTEM (MODERN EXECUTIVE CARDS, TABLE & ACCORDION)
   ========================================================================== */
.directory-control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
  padding: 12px 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.directory-summary-counter {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.directory-summary-counter b {
  color: #0f172a;
  font-weight: 850;
}

.active-filter-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-badge-pill {
  font-size: 11px;
  font-weight: 750;
  background: #f0fdfa;
  color: #0d9488;
  border: 1px solid #99f6e4;
  padding: 2px 8px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-badge-pill:hover {
  background: #ccfbf1;
  color: #0f766e;
}

.view-mode-toggle {
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  display: inline-flex;
  gap: 4px;
}

.view-mode-btn {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.view-mode-btn:hover {
  color: #0f172a;
}

.view-mode-btn.active {
  background: #ffffff;
  color: #0d9488;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* CARDS GRID LAYOUT */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 50px;
}

/* THE NEW MODERN MEMBER CARD */
.modern-member-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 6px -1px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.03);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease;
  display: flex;
  flex-direction: column;
}

.modern-member-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -8px rgba(15, 23, 42, 0.11), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  border-color: #cbd5e1;
}

.modern-member-card.is-author {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffdfa 0%, #ffffff 120px);
}

/* Top Accent Stripe */
.card-top-stripe {
  height: 5px;
  width: 100%;
  transition: height 0.2s ease;
}

.modern-member-card:hover .card-top-stripe {
  height: 6px;
}

/* Inner Card Container */
.card-inner {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Header Bar: Family Badge & Relation */
.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-family-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.01em;
  max-width: 65%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-relation-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.card-relation-badge.rel-me {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.card-relation-badge.rel-parent {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.card-relation-badge.rel-sibling {
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

.card-relation-badge.rel-inlaw {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.card-relation-badge.rel-niece {
  background: #ffe4e6;
  color: #e11d48;
  border: 1px solid #fecdd3;
}

.card-relation-badge.rel-grandparent {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.card-relation-badge.rel-auntuncle {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.card-relation-badge.rel-cousin {
  background: #fef9c3;
  color: #a16207;
  border: 1px solid #fef08a;
}

.card-relation-badge.rel-default {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

/* Profile Hero Row */
.card-profile-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-avatar-container {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  position: relative;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  border: 2.5px solid #ffffff;
}

.card-avatar-container.male {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #ffffff;
}

.card-avatar-container.female {
  background: linear-gradient(135deg, #be123c, #fb7185);
  color: #ffffff;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  display: block;
}

.avatar-initials {
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.author-crown-pill {
  position: absolute;
  bottom: -3px;
  right: -4px;
  background: #f59e0b;
  color: #ffffff;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 99px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(245, 158, 11, 0.4);
  display: flex;
  align-items: center;
  gap: 3px;
}

.card-profile-info {
  flex: 1;
  min-width: 0;
}

.card-name-title {
  font-size: 15px;
  font-weight: 850;
  color: #0f172a;
  margin: 0 0 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.card-meta-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.meta-tag.nickname {
  background: #f1f5f9;
  color: #334155;
  font-weight: 800;
}

.meta-tag.gen {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.meta-tag.branch {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meta-tag.branch.branch-paternal {
  background: #eff6ff;
  color: #2563eb;
}

.meta-tag.branch.branch-maternal {
  background: #fffbeb;
  color: #d97706;
}

.meta-tag.branch.branch-immediate {
  background: #f0fdfa;
  color: #0d9488;
  font-weight: 800;
}

/* Informational Data Grid */
.card-data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #f1f5f9;
}

.data-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-cell.full-width {
  grid-column: 1 / -1;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}

.data-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
}

.data-icon.pink { background: #fdf2f8; color: #db2777; }
.data-icon.sky { background: #f0f9ff; color: #0284c7; }
.data-icon.teal { background: #f0fdfa; color: #0d9488; }

.data-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.data-label {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.04em;
}

.data-val {
  font-size: 12px;
  font-weight: 750;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Genealogy Context Pill */
.card-genealogy-pill {
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-genealogy-pill i {
  color: #0d9488;
  font-size: 12px;
  flex-shrink: 0;
}

.card-bio-snippet {
  font-size: 11.5px;
  color: #475569;
  font-style: italic;
  margin: 0;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Action Buttons Footer */
.card-action-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.btn-card-action {
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-tree-spotlight {
  background: #f0fdfa;
  color: #0d9488;
  border-color: #99f6e4;
}

.btn-tree-spotlight:hover {
  background: #0d9488;
  color: #ffffff;
  border-color: #0d9488;
}

.btn-edit-card {
  background: #f8fafc;
  color: #334155;
  border-color: #cbd5e1;
}

.btn-edit-card:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-view-card {
  background: #ffffff;
  color: #475569;
  border-color: #e2e8f0;
  margin-left: auto;
}

.btn-view-card:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.btn-copy-card {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
  padding: 6px 9px;
}

.btn-copy-card:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* EMPTY STATE */
.directory-empty-state {
  text-align: center;
  padding: 60px 24px;
  max-width: 480px;
  margin: 40px auto;
  background: #ffffff;
  border: 1.5px dashed #cbd5e1;
  border-radius: 20px;
}

.directory-empty-state .empty-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #94a3b8;
  display: grid;
  place-items: center;
  font-size: 24px;
  margin: 0 auto 16px;
}

.directory-empty-state h3 {
  font-size: 18px;
  font-weight: 850;
  color: #0f172a;
  margin: 0 0 8px;
}

.directory-empty-state p {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 20px;
  line-height: 1.5;
}

/* GROUPED BY FAMILY HOUSEHOLD ACCORDION */
.family-group-section {
  margin-bottom: 24px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.family-group-header {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.family-group-header:hover {
  background: #f8fafc;
}

.family-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.family-group-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 850;
  color: #0f172a;
}

.family-group-cards {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
  background: #fbfcfd;
}

/* TABLE VIEW */
.directory-table-wrapper {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  margin-bottom: 50px;
}

.directory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.directory-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.directory-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.directory-table tbody tr:hover {
  background: #f8fafc;
}

/* ==========================================================================
   Statistics
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 30px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.stat-box:nth-child(1) .stat-icon { background: var(--paternal-soft); color: var(--paternal); }
.stat-box:nth-child(2) .stat-icon { background: var(--maternal-soft); color: var(--maternal); }
.stat-box:nth-child(3) .stat-icon { background: var(--immediate-soft); color: var(--immediate); }
.stat-box:nth-child(4) .stat-icon { background: #e0f2fe; color: #0284c7; }

.stat-num {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: #0f172a;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   Detail & Edit Modals
   ========================================================================== */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  width: min(600px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: modalRise 0.2s ease-out;
}

@keyframes modalRise {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

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

.modal-close {
  background: var(--surface-alt);
  border: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 16px;
  color: #475569;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.modal-body {
  padding: 24px;
}

.profile-hero {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.profile-avatar-circle {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 850;
  font-size: 22px;
  flex-shrink: 0;
}

.profile-avatar-circle.male { background: var(--male-bg); color: var(--male); }
.profile-avatar-circle.female { background: var(--female-bg); color: var(--female); }

/* Edit Form Fields */
.edit-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.form-field.full-width {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 11px;
  font-weight: 800;
  color: #334155;
  text-transform: uppercase;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  background: #fbfcfd;
  outline: none;
  color: var(--text-main);
  transition: border-color 0.15s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--marmalade);
  background: #ffffff;
}

.form-field textarea {
  min-height: 80px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.btn-primary {
  background: var(--marmalade);
  color: var(--cream);
  border: 1px solid var(--gold);
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 750;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn-primary:hover {
  background: #732f2f;
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

/* ==========================================================================
   Modern Redesigned Member Profile Modal
   ========================================================================== */
.profile-modal-dialog {
  width: min(680px, 96%);
  max-height: 90vh;
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.35);
  animation: modalRise 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-modal-head {
  padding: 12px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-head-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: -0.01em;
}

.profile-head-pill i {
  color: #0d9488;
  font-size: 14px;
}

.profile-modal-body {
  padding: 0 !important;
  max-height: calc(90vh - 65px);
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Profile Hero Banner */
.profile-hero-banner {
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.profile-hero-banner.banner-paternal {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 55%, #f8fafc 100%);
  border-bottom-color: #d1fae5;
}

.profile-hero-banner.banner-maternal {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 55%, #f8fafc 100%);
  border-bottom-color: #dbeafe;
}

.profile-hero-banner.banner-immediate {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 55%, #f8fafc 100%);
  border-bottom-color: #fde68a;
}

.profile-hero-banner.banner-author {
  background: linear-gradient(135deg, #fffbeb 0%, #fef9c3 40%, #ecfdf5 100%);
  border-bottom-color: #fde047;
}

.profile-hero-main {
  display: flex;
  gap: 18px;
  align-items: center;
}

.profile-avatar-wrap {
  width: 76px;
  height: 76px;
  border-radius: 14px;
  border: 3.5px solid #ffffff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.14);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
  background: #ffffff;
}

.profile-avatar-wrap.male {
  background: var(--male-bg);
  color: var(--male);
}

.profile-avatar-wrap.female {
  background: var(--female-bg);
  color: var(--female);
}

.profile-avatar-initials {
  font-size: 26px;
  font-weight: 850;
  letter-spacing: -0.03em;
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}

.profile-author-crown {
  position: absolute;
  bottom: -4px;
  right: -6px;
  background: #f59e0b;
  color: #ffffff;
  font-size: 10px;
  font-weight: 850;
  padding: 2px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.45);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1.5px solid #ffffff;
}

.profile-hero-details {
  flex: 1;
  min-width: 0;
}

.profile-hero-tags {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.profile-relation-pill {
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.profile-household-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.profile-hero-name {
  margin: 2px 0 2px;
  font-size: 21px;
  font-weight: 850;
  color: #0f172a;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.profile-hero-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.profile-hero-sub .profile-nickname {
  color: #0f172a;
}

.profile-pill-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.profile-meta-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.profile-meta-pill.branch-paternal {
  background: #dcfce7;
  color: #166534;
}

.profile-meta-pill.branch-maternal {
  background: #dbeafe;
  color: #1e40af;
}

.profile-meta-pill.branch-immediate {
  background: #fef3c7;
  color: #92400e;
}

.profile-meta-pill.age {
  background: #f1f5f9;
  color: #334155;
}

.profile-meta-pill.gender.male {
  background: #e0f2fe;
  color: #0369a1;
}

.profile-meta-pill.gender.female {
  background: #fce7f3;
  color: #be185d;
}

/* Content Container */
.profile-modal-content {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Genealogy Formula Bar */
.profile-genealogy-bar {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.gen-bar-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: #0d9488;
  flex-shrink: 0;
}

.gen-bar-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gen-bar-label {
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gen-bar-value {
  font-size: 12.5px;
  font-weight: 750;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Vitals Metric Cards */
.profile-vitals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.vital-metric-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.vital-metric-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.vital-metric-card.full-span {
  grid-column: 1 / -1;
}

.vital-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}

.vital-icon-box.blue {
  background: #e0f2fe;
  color: #0284c7;
}

.vital-icon-box.green {
  background: #d1fae5;
  color: #059669;
}

.vital-icon-box.amber {
  background: #fef3c7;
  color: #d97706;
}

.vital-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.vital-label {
  font-size: 10.5px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vital-value {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
}

.vital-sub {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

/* Biography Quote Card */
.profile-bio-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #0d9488;
  border-radius: 12px;
  padding: 14px 16px;
}

.bio-card-head {
  font-size: 10.5px;
  font-weight: 800;
  color: #0d9488;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bio-card-text {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: #334155;
  font-style: italic;
}

/* Kinship Sections */
.profile-kinship-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kinship-sec-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kinship-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kinship-member-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kinship-member-card:hover {
  border-color: #0d9488;
  background: #f0fdfa;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.1);
}

.kinship-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.kinship-avatar.male {
  background: var(--male-bg);
  color: var(--male);
}

.kinship-avatar.female {
  background: var(--female-bg);
  color: var(--female);
}

.kinship-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.kinship-relation {
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
}

.kinship-name {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kinship-sub {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
}

.kinship-arrow {
  color: #94a3b8;
  font-size: 11px;
}

.kinship-empty-banner {
  grid-column: 1 / -1;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

/* Children & Siblings Chips */
.kinship-chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}

.kinship-chip-btn {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s ease;
}

.kinship-chip-btn:hover {
  border-color: #0d9488;
  background: #f0fdfa;
  transform: translateY(-1px);
}

.chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.chip-avatar.male {
  background: var(--male-bg);
  color: var(--male);
}

.chip-avatar.female {
  background: var(--female-bg);
  color: var(--female);
}

.chip-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.chip-name {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-sub {
  font-size: 10.5px;
  color: #64748b;
  font-weight: 600;
}

/* Modal Actions Footer */
.profile-modal-footer {
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-left-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-profile-action {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 750;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-profile-action:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.btn-profile-action.btn-spotlight {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.btn-profile-action.btn-spotlight:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

.btn-profile-action.btn-edit {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.btn-profile-action.btn-edit:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.btn-profile-close {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 750;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-profile-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Footer */
footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.foot-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   FAMILY UNIT VISUAL ACCENT HUES (HIGH CRAFT PALETTE)
   ========================================================================== */
.stripe-core_ammar { background: #0d9488; }
.stripe-ms_maksulaili { background: #8b5cf6; }
.stripe-mt_makteh { background: #e11d48; }
.stripe-pl_paklong { background: #2563eb; }
.stripe-pn_pakngah { background: #0284c7; }
.stripe-an_aciknora { background: #d97706; }
.stripe-zn_zainal { background: #4f46e5; }
.stripe-az_azhar { background: #c026d3; }
.stripe-mz_mazri { background: #65a30d; }
.stripe-ym_yusma { background: #0891b2; }
.stripe-gp_paternal { background: #475569; }
.stripe-gp_maternal { background: #0f766e; }

/* Subtle card hover glow tinted by family unit */
.modern-member-card.unit-core_ammar:hover { border-color: #99f6e4; box-shadow: 0 16px 32px -8px rgba(13, 148, 136, 0.15); }
.modern-member-card.unit-ms_maksulaili:hover { border-color: #ddd6fe; box-shadow: 0 16px 32px -8px rgba(139, 92, 246, 0.15); }
.modern-member-card.unit-mt_makteh:hover { border-color: #fecdd3; box-shadow: 0 16px 32px -8px rgba(225, 29, 72, 0.15); }
.modern-member-card.unit-pl_paklong:hover { border-color: #bfdbfe; box-shadow: 0 16px 32px -8px rgba(37, 99, 235, 0.15); }
.modern-member-card.unit-pn_pakngah:hover { border-color: #bae6fd; box-shadow: 0 16px 32px -8px rgba(2, 132, 199, 0.15); }
.modern-member-card.unit-an_aciknora:hover { border-color: #fde68a; box-shadow: 0 16px 32px -8px rgba(217, 119, 6, 0.15); }
.modern-member-card.unit-zn_zainal:hover { border-color: #c7d2fe; box-shadow: 0 16px 32px -8px rgba(79, 70, 229, 0.15); }
.modern-member-card.unit-az_azhar:hover { border-color: #f5d0fe; box-shadow: 0 16px 32px -8px rgba(192, 38, 211, 0.15); }
.modern-member-card.unit-mz_mazri:hover { border-color: #d9f99d; box-shadow: 0 16px 32px -8px rgba(101, 163, 13, 0.15); }
.modern-member-card.unit-ym_yusma:hover { border-color: #a5f3fc; box-shadow: 0 16px 32px -8px rgba(8, 145, 178, 0.15); }
.modern-member-card.unit-gp_paternal:hover { border-color: #cbd5e1; box-shadow: 0 16px 32px -8px rgba(71, 85, 105, 0.15); }
.modern-member-card.unit-gp_maternal:hover { border-color: #99f6e4; box-shadow: 0 16px 32px -8px rgba(15, 118, 110, 0.15); }

/* Badges for Family Household Units */
.badge-core_ammar { background: #d1fae5; color: #047857; border: 1px solid #a7f3d0; }
.badge-ms_maksulaili { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }
.badge-mt_makteh { background: #ffe4e6; color: #be123c; border: 1px solid #fecdd3; }
.badge-pl_paklong { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-pn_pakngah { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-an_aciknora { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-zn_zainal { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
.badge-az_azhar { background: #fae8ff; color: #a21caf; border: 1px solid #f5d0fe; }
.badge-mz_mazri { background: #ecfccb; color: #4d7c0f; border: 1px solid #d9f99d; }
.badge-ym_yusma { background: #cffafe; color: #0e7490; border: 1px solid #a5f3fc; }
.badge-gp_paternal { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.badge-gp_maternal { background: #ccfbf1; color: #115e59; border: 1px solid #99f6e4; }

/* Avatar Photo */
.avatar-photo {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   Compact No-Scroll Edit Profile Modal with Auto-Save GUI
   ========================================================================== */
.edit-compact-dialog {
  width: min(600px, 95%);
  max-height: 90vh;
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.35);
  animation: modalRise 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.edit-compact-head {
  padding: 12px 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.edit-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.edit-head-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0d9488;
  background: #ccfbf1;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.edit-compact-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.edit-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Auto-save Status Pill */
.autosave-pill {
  font-size: 11.5px;
  font-weight: 750;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.autosave-pill.saved {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.autosave-pill.saving {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.edit-compact-body {
  padding: 16px 20px 14px !important;
  overflow-y: hidden !important; /* Muat dlm popup, no need to scroll! */
}

/* Identity & Avatar Strip */
.edit-identity-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.edit-avatar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.edit-avatar-bubble {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #0d9488;
  font-weight: 850;
  font-size: 18px;
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  border: 2px solid #0d9488;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease;
}

.edit-avatar-bubble:hover {
  transform: scale(1.04);
}

.edit-avatar-bubble img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-camera-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.edit-avatar-bubble:hover .avatar-camera-overlay {
  opacity: 1;
}

.avatar-clear-link {
  background: none;
  border: none;
  font-size: 10px;
  font-weight: 700;
  color: #ef4444;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.edit-photo-lock-tag {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #94a3b8;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex-shrink: 0;
}

.edit-names-group {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  flex: 1;
}

/* Fields & Labels */
.compact-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compact-field label {
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-shell {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-shell:focus-within {
  border-color: #0d9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.input-shell .field-icon {
  font-size: 12px;
  color: #94a3b8;
  flex-shrink: 0;
}

.input-shell input {
  width: 100%;
  border: none;
  outline: none;
  padding: 7px 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-main);
  background: transparent;
}

.textarea-shell {
  align-items: flex-start;
  padding: 6px 10px;
}

.textarea-shell .field-icon {
  margin-top: 5px;
}

.textarea-shell textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-main);
  background: transparent;
  line-height: 1.4;
  height: 46px;
}

/* Core 2-Column Grid */
.edit-grid-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.edit-grid-col {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* Date of Birth & Age Row */
.dob-pill-badge {
  font-size: 10px;
  font-weight: 800;
  color: #0d9488;
  background: #ccfbf1;
  padding: 1px 6px;
  border-radius: 4px;
}

.dob-age-combined {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-date-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
  background: #ffffff;
  transition: border-color 0.15s;
}

.compact-date-input:focus {
  border-color: #0d9488;
}

.inline-age-chip {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 750;
  color: #334155;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inline-age-chip i {
  color: #0d9488;
  font-size: 10px;
}

/* Segmented Gender Pill Switcher */
.gender-segmented-bar {
  display: flex;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.gender-pill-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 750;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s ease;
  outline: none;
}

.gender-pill-btn:hover {
  color: #0f172a;
}

.gender-pill-btn.active[data-gender="male"] {
  background: #ffffff;
  color: #0284c7;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.gender-pill-btn.active[data-gender="female"] {
  background: #ffffff;
  color: #db2777;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Compact Micro Footer */
.edit-compact-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.autosave-hint {
  font-size: 11px;
  font-weight: 650;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-compact-done {
  background: var(--marmalade);
  color: var(--cream);
  border: 1px solid var(--gold);
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s ease;
}

.btn-compact-done:hover {
  background: #732f2f;
}

/* Export / Download JSON button */
.btn-export-nav {
  background: var(--marmalade);
  color: var(--cream);
  border: 1px solid var(--gold);
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-export-nav:hover {
  background: #732f2f;
  border-color: var(--gold);
  color: var(--cream);
  transform: translateY(-1px);
}

/* ==========================================================================
   FLOATING TOAST NOTIFICATION SYSTEM (SONNER-STYLE, AUTO-DISMISS 2S)
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  background: var(--dark-charcoal);
  color: var(--cream);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 16px 36px -6px rgba(26, 26, 26, 0.4), 0 0 0 1px var(--glass-border);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  overflow: hidden;
  position: relative;
}

.toast-item.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast-item.hide {
  transform: translateY(16px) scale(0.9);
  opacity: 0;
}

.toast-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}

.toast-icon.success { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.toast-icon.info { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
.toast-icon.warn { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 750;
  color: #ffffff;
  font-size: 13px;
  margin-bottom: 2px;
}

.toast-desc {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: #10b981;
  width: 100%;
  animation: toastProgress 2s linear forwards;
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* ==========================================================================
   3D CARD TILT & TREE INTERACTIVE SPOTLIGHT
   ========================================================================== */
.member-tile {
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out, border-color 0.15s ease-out;
  transform-style: preserve-3d;
  will-change: transform;
}

.tree-member {
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  will-change: transform;
}

.tree-member.spotlight {
  animation: treePulse 1.8s infinite;
  border-color: var(--gold) !important;
  transform: scale(1.08) translateY(-4px) !important;
  z-index: 50;
  background: var(--immediate-soft) !important;
}

@keyframes treePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 168, 83, 0.8), 0 10px 25px rgba(212, 168, 83, 0.25);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(212, 168, 83, 0), 0 10px 25px rgba(212, 168, 83, 0.25);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(212, 168, 83, 0), 0 10px 25px rgba(212, 168, 83, 0.25);
  }
}

.btn-locate-tree {
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--marmalade);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}

.btn-locate-tree:hover {
  background: #fbeae8;
  color: #732f2f;
  border-color: var(--marmalade);
  transform: scale(1.03);
}

/* ==========================================================================
   ADVANCED HERITAGE INTELLIGENCE DASHBOARD
   ========================================================================== */
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.kpi-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.kpi-icon.emerald { background: #d1fae5; color: #059669; }
.kpi-icon.blue { background: #dbeafe; color: #2563eb; }
.kpi-icon.purple { background: #ede9fe; color: #7c3aed; }
.kpi-icon.amber { background: #fef3c7; color: #d97706; }
.kpi-icon.rose { background: #ffe4e6; color: #e11d48; }
.kpi-icon.cyan { background: #cffafe; color: #0891b2; }

.kpi-value {
  font-size: 22px;
  font-weight: 850;
  color: #0f172a;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.dashboard-section-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .dashboard-section-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.dashboard-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.dashboard-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Generation Tier Pyramid */
.gen-tier-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gen-tier-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.gen-tier-item:hover {
  background: #f0fdfa;
  border-color: #0d9488;
  transform: translateX(4px);
}

.gen-tier-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 750;
  color: #1e293b;
}

.gen-tier-bar-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
}

.gen-tier-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Family Units Leaderboard */
.family-leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.family-leader-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.family-leader-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.family-leader-count {
  font-size: 18px;
  font-weight: 850;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* SVG Donut Chart styling */
.lineage-donut-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 20px;
}

.donut-svg {
  transform: rotate(-90deg);
  border-radius: 50%;
}

.donut-segment {
  transition: stroke-width 0.2s, filter 0.2s;
  cursor: pointer;
}

.donut-segment:hover {
  stroke-width: 24;
  filter: drop-shadow(0 0 6px rgba(0,0,0,0.2));
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.donut-legend-item:hover {
  background: #f1f5f9;
  color: #0d9488;
  transform: translateX(4px);
}

.donut-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

/* Interactive Age Cohorts & City Items */
.age-cohort-item {
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 10px;
  transition: all 0.15s ease;
}

.age-cohort-item:hover {
  background: #f0fdfa;
  transform: translateX(4px);
}

.city-stat-item {
  cursor: pointer;
  transition: all 0.15s ease;
}

.city-stat-item:hover {
  background: #f0fdfa !important;
  border-color: #0d9488 !important;
  transform: translateX(4px);
}

/* Form Date Picker Styling */
.form-date-native {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.form-date-native:focus {
  border-color: #0d9488;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* Inline modal feedback banner */
.modal-feedback-banner {
  padding: 8px 12px;
  border-radius: 8px;
  background: #d1fae5;
  color: #065f46;
  font-size: 12px;
  font-weight: 750;
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

/* ==========================================================================
   COMPREHENSIVE RESPONSIVE DESIGN SYSTEM (ALL SCREEN SIZES: MOBILE, TABLET, DESKTOP)
   Adheres to Emil Kowalski & Impeccable Craft Floor Standards
   ========================================================================== */

/* 1. Touch & Hover Input Adaptations */
@media (hover: none) or (pointer: coarse) {
  /* On touch devices, disable mousemove 3D perspective tilt to preserve smooth scrolling */
  .member-tile {
    transform: none !important;
    transition: box-shadow 0.15s ease, border-color 0.15s ease !important;
  }
  
  .member-tile:active {
    transform: scale(0.99) !important;
    border-color: #0d9488 !important;
  }

  .kpi-card:hover {
    transform: none !important;
  }

  /* Ensure touch targets are at least 44px */
  .tab-btn,
  .lineage-btn,
  .action-pill,
  .btn-edit-profile,
  .btn-view-profile,
  .filter-select,
  .modal-close {
    min-height: 40px;
  }
}

/* 2. Tablet / Medium Screen Optimization (<= 1024px) */
@media (max-width: 1024px) {
  .wrap {
    width: min(100% - 24px, 1440px);
  }

  .dashboard-kpi-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .dashboard-section-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .family-leaderboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .tree-controls-bar {
    padding: 10px 14px;
  }

  .tree-search-bar {
    min-width: 200px;
  }
}

/* 3. Large Mobile & Tablet Portrait (<= 768px) */
@media (max-width: 768px) {
  /* Header & Navigation */
  header {
    position: relative;
  }

  .nav {
    height: auto;
    min-height: 64px;
    padding: 10px 0;
    flex-wrap: wrap;
    gap: 12px;
  }

  .brand {
    gap: 10px;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-radius: 10px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand small {
    font-size: 10px;
  }

  .navlinks {
    width: 100%;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    gap: 6px;
  }

  .navlinks::-webkit-scrollbar {
    display: none;
  }

  .navlinks a,
  .tab-btn {
    padding: 7px 12px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .btn-export-nav {
    margin-left: auto;
    flex-shrink: 0;
    padding: 7px 12px;
    font-size: 12px;
  }

  /* Hero Section */
  .hero-banner {
    padding: 18px 0 14px;
  }

  .hero-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .hero-title h2 {
    font-size: 18px;
  }

  .hero-title p {
    font-size: 12px;
    line-height: 1.5;
  }

  /* Tree Controls Toolbar */
  .tree-controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .lineage-switcher {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .lineage-switcher::-webkit-scrollbar {
    display: none;
  }

  .lineage-btn {
    flex: 1;
    min-width: 130px;
    justify-content: center;
    font-size: 11px;
    white-space: nowrap;
  }

  .tree-search-bar {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .tree-action-group {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }

  .action-pill {
    padding: 6px 10px;
    font-size: 11px;
    flex: 1;
    justify-content: center;
  }

  /* Tree Viewport Mobile Optimization */
  .tree-viewport {
    padding: 24px 16px 60px;
    min-height: 440px;
    border-radius: 14px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  /* Toolbar Filters in Directory */
  .toolbar {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-box {
    width: 100%;
    min-width: 0;
  }

  .search-box input {
    font-size: 14px;
    padding: 10px 14px 10px 36px;
  }

  .filter-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  #filterFamilyUnit {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 42px;
  }

  .filter-select {
    width: 100%;
    min-height: 40px;
    font-size: 12px;
  }

  #resetFilters {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 38px;
    text-align: center;
  }

  /* Directory Grid */
  .directory-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
  }

  /* Stats / KPIs */
  .dashboard-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .kpi-card {
    padding: 12px 14px;
    gap: 10px;
  }

  .kpi-icon {
    width: 38px;
    height: 38px;
    font-size: 16px;
    border-radius: 10px;
  }

  .kpi-value {
    font-size: 18px;
  }

  .kpi-title {
    font-size: 10px;
  }

  .dashboard-card {
    padding: 16px;
    border-radius: 14px;
  }

  .lineage-donut-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .donut-legend {
    width: 100%;
  }

  .family-leaderboard-grid {
    grid-template-columns: 1fr;
  }

  /* Modal Mobile Responsiveness */
  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .modal-dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 10px 10px;
    margin: 0;
  }

  .modal-head {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 16px 14px;
  }

  .edit-form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* iOS Safari auto-zoom prevention: inputs must be >= 16px font-size */
  .form-field input,
  .form-field select,
  .form-field textarea,
  .form-date-native {
    font-size: 16px !important;
    min-height: 44px;
    padding: 10px 12px;
  }

  .modal-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-actions button {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    font-size: 14px;
  }

  /* Toast Notification Positioning on Mobile */
  .toast-container {
    left: 14px;
    right: 14px;
    bottom: 14px;
    width: auto;
    align-items: stretch;
  }

  .toast-item {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 12px 14px;
  }

  /* Footer on Mobile */
  .foot-wrap {
    flex-direction: column;
    text-align: center;
    gap: 6px;
  }
}

/* 4. Small Mobile Phones (<= 480px & 360px) */
@media (max-width: 480px) {
  .wrap {
    width: calc(100% - 16px);
  }

  .directory-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .member-tile {
    padding: 14px;
  }

  .tile-head {
    gap: 10px;
  }

  .tile-avatar-circle {
    width: 42px;
    height: 42px;
    font-size: 14px;
  }

  .dashboard-kpi-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .filter-group {
    grid-template-columns: 1fr;
  }

  .tree-action-group {
    flex-wrap: wrap;
  }

  .action-pill {
    min-width: 45%;
  }

  .profile-modal-dialog {
    width: 100%;
    max-height: 94vh;
    border-radius: 20px 20px 0 0;
    margin: 0;
  }

  .profile-hero-main {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .profile-vitals-grid {
    grid-template-columns: 1fr;
  }

  .kinship-cards-grid {
    grid-template-columns: 1fr;
  }

  .profile-modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .footer-left-actions {
    width: 100%;
    justify-content: space-between;
  }

  .footer-left-actions .btn-profile-action {
    flex: 1;
    justify-content: center;
  }

  .btn-profile-close {
    width: 100%;
    text-align: center;
  }

  /* Compact Edit Modal on Mobile */
  .edit-compact-dialog {
    width: 100%;
    max-height: 94vh;
    border-radius: 18px 18px 0 0;
    margin: 0;
  }

  .edit-identity-strip {
    gap: 10px;
    padding: 8px 10px;
  }

  .edit-names-group {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .edit-grid-two-col {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .edit-compact-body {
    overflow-y: auto !important; /* Safety on small phones */
  }
}


/* ==========================================================================
   AMMAR FAMILY HERITAGE — MAROON GLASS DESIGN OVERRIDES
   Append this section to the bottom of public/css/style.css
   ========================================================================== */

:root {
  --marmalade: #8b3a3a;
  --cream: #faf3e0;
  --gold: #d4a853;
  --dark-charcoal: #1a1a1a;
  --muted: #a0aec0;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #faf3e0;
  --text-main: #1a1a1a;
  --text-muted: #64748b;

  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(139, 58, 58, 0.2);

  --border: rgba(139, 58, 58, 0.14);
  --tree-line: #d6c7c0;

  --shadow:
    0 10px 25px -5px rgba(60, 30, 30, 0.07),
    0 8px 10px -6px rgba(60, 30, 30, 0.04);

  --shadow-lg:
    0 20px 35px -5px rgba(60, 30, 30, 0.13);

  --radius: 18px;
}

/* ---------- Global foundation ---------- */

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  background:
    radial-gradient(
      ellipse at 0% 0%,
      rgba(212, 168, 83, 0.10),
      transparent 38%
    ),
    radial-gradient(
      ellipse at 100% 15%,
      rgba(139, 58, 58, 0.07),
      transparent 35%
    ),
    #f8fafc;

  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: rgba(139, 58, 58, 0.16);
  color: #542323;
}

:focus-visible {
  outline: 3px solid rgba(212, 168, 83, 0.75);
  outline-offset: 3px;
}

.wrap {
  width: min(1440px, calc(100% - 40px));
}

/* ---------- Sticky glass navigation ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 100;

  background: rgba(250, 243, 224, 0.82);
  border-bottom: 1px solid rgba(139, 58, 58, 0.15);

  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);

  box-shadow: 0 4px 24px rgba(60, 30, 30, 0.035);
}

.nav {
  min-height: 76px;
}

.brand-icon {
  background: linear-gradient(145deg, #9b4949, #6e2929);
  color: #fffaf0;
  border: 1px solid rgba(212, 168, 83, 0.65);
  border-radius: 14px;
  box-shadow: 0 7px 18px rgba(139, 58, 58, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand:hover .brand-icon {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(139, 58, 58, 0.24);
}

.brand h1 {
  color: #542727;
  letter-spacing: -0.035em;
}

.brand small {
  color: #806c68;
}

.navlinks a,
.tab-btn {
  border-radius: 11px;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.navlinks a:hover,
.tab-btn:hover {
  color: var(--marmalade);
  background: rgba(139, 58, 58, 0.07);
}

.navlinks a.active,
.tab-btn.active {
  color: var(--cream);
  background: linear-gradient(135deg, #934747, #742e2e);
  border-color: rgba(212, 168, 83, 0.8);
  box-shadow: 0 5px 15px rgba(139, 58, 58, 0.18);
}

/* ---------- Hero section ---------- */

.hero-banner {
  position: relative;
  overflow: hidden;

  background:
    linear-gradient(
      115deg,
      rgba(250, 243, 224, 0.96),
      rgba(255, 255, 255, 0.92) 60%,
      rgba(212, 168, 83, 0.09)
    );

  border-bottom: 1px solid rgba(139, 58, 58, 0.12);
  padding: 34px 0 28px;
}

.hero-banner::after {
  content: "";
  position: absolute;
  right: -75px;
  top: -135px;

  width: 290px;
  height: 290px;

  border: 1px solid rgba(139, 58, 58, 0.12);
  border-radius: 50%;

  box-shadow:
    0 0 0 28px rgba(139, 58, 58, 0.025),
    0 0 0 56px rgba(212, 168, 83, 0.04);

  pointer-events: none;
}

.hero-title {
  position: relative;
  z-index: 1;
}

.hero-title h2 {
  color: #542727;
  font-weight: 850;
  letter-spacing: -0.045em;
}

.hero-title p {
  color: #746461;
  line-height: 1.75;
}

/* ---------- Shared glass panels ---------- */

.tree-controls-bar,
.toolbar,
.directory-control-bar,
.tree-viewport,
.stat-box,
.kpi-card,
.dashboard-card,
.family-group-section,
.directory-table-wrapper,
.modern-member-card,
.family-leader-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--glass-border);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  box-shadow: var(--shadow);
}

.tree-controls-bar,
.toolbar,
.directory-control-bar {
  border-radius: 18px;
  padding: 15px 18px;
}

.tree-controls-bar {
  margin-top: 22px;
}

.tree-viewport {
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(139, 58, 58, 0.16);
  box-shadow: 0 12px 36px rgba(60, 30, 30, 0.045);
}

/* ---------- Lineage selector and action buttons ---------- */

.lineage-btn {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(139, 58, 58, 0.15);
  color: #705957;
  border-radius: 10px;
}

.lineage-btn:hover {
  background: var(--cream);
  color: var(--marmalade);
  border-color: rgba(139, 58, 58, 0.28);
}

.lineage-btn.active {
  color: var(--cream);
  background: linear-gradient(135deg, #934747, #742e2e);
  border-color: var(--gold);
  box-shadow: 0 5px 14px rgba(139, 58, 58, 0.15);
}

.action-pill {
  border-color: rgba(139, 58, 58, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #614c49;
}

.action-pill:hover {
  background: var(--marmalade);
  color: var(--cream);
  border-color: var(--gold);
}

/* ---------- Search and filter fields ---------- */

.search-box input,
.filter-select {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(139, 58, 58, 0.16);
  color: #443432;
  border-radius: 10px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.search-box input:focus,
.filter-select:focus {
  background: #ffffff;
  border-color: var(--marmalade);
  box-shadow: 0 0 0 3px rgba(139, 58, 58, 0.09);
}

.search-box i {
  color: #987f79;
}

/* ---------- Family tree member nametags ---------- */

.tree-member {
  width: 148px;
  min-height: 168px;
  padding: 15px 10px;

  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(139, 58, 58, 0.2);
  border-radius: 20px;

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  box-shadow:
    0 5px 18px rgba(60, 30, 30, 0.055),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.tree-member:hover {
  transform: translateY(-5px);
  border-color: var(--marmalade);
  box-shadow: 0 14px 30px rgba(139, 58, 58, 0.14);
}

.tree-avatar-circle {
  width: 72px;
  height: 72px;
  border: 3px solid var(--gold);
  box-shadow: 0 5px 15px rgba(60, 30, 30, 0.08);
}

.tree-avatar-circle.male {
  background: linear-gradient(145deg, #f2e6d9, #e6d0c1);
  color: #75413a;
}

.tree-avatar-circle.female {
  background: linear-gradient(145deg, #f9e9e5, #f0d5d0);
  color: #8b3a3a;
}

.tree-member:hover .tree-avatar-circle {
  border-color: var(--marmalade);
  box-shadow: 0 0 0 4px rgba(212, 168, 83, 0.15);
}

.tree-member.is-me .tree-avatar-circle {
  background: linear-gradient(145deg, #f9edc8, #f1d99b);
  color: #754b0c;
  border-color: var(--gold);
}

.tree-member-role {
  color: #8b3a3a;
  letter-spacing: 0.075em;
}

.tree-member-name {
  color: #382827;
  font-weight: 800;
  white-space: normal;
  overflow-wrap: anywhere;
}

.tree-member-meta {
  color: #8a7773;
}

.tree-marriage-bridge,
.tree-stem-down,
.tree-child-column::before,
.tree-child-column::after {
  background-color: #cdbab2;
}

.tree-toggle-pill {
  background: rgba(255, 255, 255, 0.94);
  color: #694c46;
  border-color: #d9c7bd;
}

.tree-toggle-pill:hover {
  background: var(--marmalade);
  color: var(--cream);
  border-color: var(--gold);
}

.tree-toggle-pill.active-core {
  background: #fff5d9;
  color: #815b17;
  border-color: var(--gold);
}

/* ---------- Directory view switcher ---------- */

.directory-summary-counter,
.directory-summary-counter b {
  color: #604b47;
}

.view-mode-toggle {
  background: rgba(139, 58, 58, 0.07);
  border: 1px solid rgba(139, 58, 58, 0.1);
  border-radius: 11px;
}

.view-mode-btn {
  border-radius: 8px;
}

.view-mode-btn:hover {
  color: var(--marmalade);
}

.view-mode-btn.active {
  background: #ffffff;
  color: var(--marmalade);
  box-shadow: 0 2px 8px rgba(60, 30, 30, 0.09);
}

/* ---------- Directory member cards ---------- */

.modern-member-card {
  border-radius: 20px;
  border-color: rgba(139, 58, 58, 0.15);
  overflow: hidden;
  transition:
    transform 0.24s ease,
    box-shadow 0.24s ease,
    border-color 0.24s ease;
}

.modern-member-card:hover {
  transform: translateY(-5px);
  border-color: rgba(139, 58, 58, 0.38);
  box-shadow: 0 18px 38px rgba(60, 30, 30, 0.1);
}

.modern-member-card.is-author {
  background: linear-gradient(
    150deg,
    rgba(250, 243, 224, 0.85),
    rgba(255, 255, 255, 0.95) 48%
  );
  border-color: rgba(212, 168, 83, 0.65);
}

.card-inner {
  padding: 18px;
}

.card-name-title {
  color: #492c29;
}

.card-data-grid {
  background: rgba(250, 243, 224, 0.4);
  border-color: rgba(139, 58, 58, 0.09);
  border-radius: 13px;
}

.card-genealogy-pill {
  background: rgba(139, 58, 58, 0.055);
  color: #70534e;
}

.card-genealogy-pill i {
  color: var(--marmalade);
}

.card-action-footer {
  border-color: rgba(139, 58, 58, 0.1);
}

.btn-tree-spotlight {
  background: #fbeae8;
  color: #8b3a3a;
  border-color: #edc6c0;
}

.btn-tree-spotlight:hover {
  background: #8b3a3a;
  color: #fff8ee;
  border-color: #d4a853;
}

.btn-edit-card {
  background: #faf3e0;
  color: #705047;
  border-color: #e8d8b8;
}

.btn-edit-card:hover {
  background: #f0e2c7;
  color: #542727;
}

.btn-view-card,
.btn-copy-card {
  background: #ffffff;
  color: #735b56;
  border-color: rgba(139, 58, 58, 0.16);
}

.btn-view-card:hover,
.btn-copy-card:hover {
  background: #f9efeb;
  color: #8b3a3a;
}

/* ---------- Family labels and relationship badges ---------- */

.card-relation-badge.rel-me {
  background: #fff2cf;
  color: #835719;
  border-color: #ecd08c;
}

.card-relation-badge.rel-parent {
  background: #f5eadc;
  color: #7a5035;
  border-color: #e4cdb4;
}

.card-relation-badge.rel-sibling {
  background: #f9e8e5;
  color: #8b3a3a;
  border-color: #ebc8c1;
}

.card-relation-badge.rel-inlaw,
.card-relation-badge.rel-grandparent,
.card-relation-badge.rel-default {
  background: #f7f1e9;
  color: #735e55;
  border-color: #e8ddd0;
}

.card-relation-badge.rel-niece {
  background: #f8e6e7;
  color: #943c48;
  border-color: #e9c7cb;
}

.card-relation-badge.rel-auntuncle {
  background: #eee7f3;
  color: #71517d;
  border-color: #ddd0e5;
}

.card-relation-badge.rel-cousin {
  background: #fff3d6;
  color: #88631d;
  border-color: #efdda9;
}

/* ---------- Gender avatars: warm neutral palette ---------- */

.card-avatar-container.male,
.kinship-avatar.male,
.chip-avatar.male,
.profile-avatar-circle.male {
  background: linear-gradient(145deg, #efe2d5, #ddc5b4);
  color: #75413a;
}

.card-avatar-container.female,
.kinship-avatar.female,
.chip-avatar.female,
.profile-avatar-circle.female {
  background: linear-gradient(145deg, #f7e6e1, #ebcbc4);
  color: #8b3a3a;
}

/* ---------- Empty state ---------- */

.directory-empty-state {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(139, 58, 58, 0.25);
  border-radius: 22px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.directory-empty-state .empty-icon {
  background: #f7e9e4;
  color: var(--marmalade);
}

.directory-empty-state h3 {
  color: #542727;
}

/* ---------- Family group accordions ---------- */

.family-group-section {
  border-radius: 18px;
}

.family-group-header {
  border-color: rgba(139, 58, 58, 0.1);
}

.family-group-header:hover {
  background: rgba(250, 243, 224, 0.6);
}

.family-group-title h3 {
  color: #542727;
}

.family-group-cards {
  background: rgba(250, 243, 224, 0.2);
}

/* ---------- Directory table ---------- */

.directory-table-wrapper {
  border-radius: 18px;
}

.directory-table th {
  background: #f8efe5;
  color: #75534c;
  border-color: rgba(139, 58, 58, 0.12);
}

.directory-table td {
  border-color: rgba(139, 58, 58, 0.08);
}

.directory-table tbody tr:hover {
  background: rgba(250, 243, 224, 0.55);
}

/* ---------- Statistics and dashboard ---------- */

.stat-box,
.kpi-card,
.dashboard-card {
  border-radius: 18px;
}

.stat-box:hover,
.kpi-card:hover {
  border-color: rgba(139, 58, 58, 0.28);
}

.stat-num,
.kpi-value {
  color: #542727;
}

.stat-label,
.kpi-title {
  color: #806c68;
}

.stat-box:nth-child(1) .stat-icon {
  background: #f5e6e1;
  color: #8b3a3a;
}

.stat-box:nth-child(2) .stat-icon {
  background: #f3e7d2;
  color: #94702e;
}

.stat-box:nth-child(3) .stat-icon {
  background: #fff2d2;
  color: #a47722;
}

.stat-box:nth-child(4) .stat-icon {
  background: #eee7e1;
  color: #75534c;
}

.dashboard-card-title {
  color: #542727;
}

.gen-tier-item {
  background: rgba(250, 243, 224, 0.42);
  border-color: rgba(139, 58, 58, 0.13);
}

.gen-tier-item:hover {
  background: #fbefdf;
  border-color: var(--marmalade);
}

/* ---------- Profile modal ---------- */

.modal-backdrop {
  background: rgba(38, 20, 20, 0.48);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.modal-dialog,
.profile-modal-dialog,
.edit-compact-dialog {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(212, 168, 83, 0.3);
  box-shadow: 0 28px 80px rgba(40, 20, 20, 0.24);
}

.modal-head,
.profile-modal-head,
.edit-compact-head {
  background: rgba(250, 243, 224, 0.76);
  border-color: rgba(139, 58, 58, 0.12);
}

.modal-head h2,
.modal-head h3,
.profile-hero-name,
.edit-compact-head h3 {
  color: #542727;
}

.modal-close {
  background: #f5e9df;
  color: #75433b;
}

.modal-close:hover {
  background: #ead4c8;
  color: #542727;
}

.profile-hero-banner.banner-paternal,
.profile-hero-banner.banner-maternal {
  background: linear-gradient(
    135deg,
    #faf3e0 0%,
    #fffaf5 60%,
    #f5e5dc 100%
  );
  border-bottom-color: rgba(139, 58, 58, 0.15);
}

.profile-hero-banner.banner-immediate,
.profile-hero-banner.banner-author {
  background: linear-gradient(
    135deg,
    #fff4d7 0%,
    #faf3e0 55%,
    #fffdf9 100%
  );
  border-bottom-color: rgba(212, 168, 83, 0.4);
}

.profile-genealogy-bar,
.vital-metric-card,
.kinship-member-card {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(139, 58, 58, 0.14);
}

.gen-bar-icon {
  background: #faf3e0;
  border-color: rgba(139, 58, 58, 0.13);
  color: var(--marmalade);
}

.kinship-member-card:hover {
  border-color: var(--marmalade);
  background: #fff8f0;
  box-shadow: 0 5px 14px rgba(139, 58, 58, 0.09);
}

.profile-bio-card {
  background: #faf3e0;
  border-color: #eadcc4;
  border-left-color: var(--marmalade);
}

.bio-card-head {
  color: var(--marmalade);
}

.profile-modal-footer {
  background: rgba(250, 243, 224, 0.7);
  border-color: rgba(139, 58, 58, 0.12);
}

.btn-profile-action {
  background: #ffffff;
  border-color: rgba(139, 58, 58, 0.16);
  color: #654a45;
}

.btn-profile-action.btn-spotlight,
.btn-profile-action.btn-edit {
  background: #f8ece4;
  border-color: #e8cfc0;
  color: #8b3a3a;
}

.btn-profile-action.btn-spotlight:hover,
.btn-profile-action.btn-edit:hover {
  background: #f1ddd2;
  border-color: #d6b5a5;
}

.btn-profile-close {
  background: #f5e9df;
  border-color: #e5d2c5;
  color: #70534d;
}

/* ---------- Edit form ---------- */

.form-field input,
.form-field select,
.form-field textarea,
.compact-date-input,
.form-date-native {
  border-color: rgba(139, 58, 58, 0.17);
  border-radius: 10px;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.compact-date-input:focus,
.form-date-native:focus {
  border-color: var(--marmalade);
  box-shadow: 0 0 0 3px rgba(139, 58, 58, 0.09);
}

.edit-identity-strip {
  background: rgba(250, 243, 224, 0.58);
  border-color: rgba(139, 58, 58, 0.14);
}

.edit-avatar-bubble {
  background: #f5e7dd;
  color: var(--marmalade);
  border-color: var(--marmalade);
}

.input-shell:focus-within {
  border-color: var(--marmalade);
  box-shadow: 0 0 0 3px rgba(139, 58, 58, 0.09);
}

.input-shell .field-icon {
  color: #987f79;
}

.dob-pill-badge {
  background: #f8e9cf;
  color: #815b17;
}

.inline-age-chip {
  background: #f7efe5;
  border-color: #e8d8c8;
  color: #70534d;
}

.inline-age-chip i {
  color: var(--marmalade);
}

.gender-segmented-bar {
  background: #f7efe7;
  border-color: rgba(139, 58, 58, 0.12);
}

.gender-pill-btn.active[data-gender="male"],
.gender-pill-btn.active[data-gender="female"] {
  color: var(--marmalade);
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(60, 30, 30, 0.09);
}

.btn-primary,
.btn-compact-done {
  background: linear-gradient(135deg, #934747, #742e2e);
  color: #fff8ed;
  border-color: var(--gold);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(139, 58, 58, 0.12);
}

.btn-primary:hover,
.btn-compact-done:hover {
  background: #682929;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f7efe7;
  color: #70534d;
  border-color: #e8d8c8;
  border-radius: 10px;
}

/* ---------- Export button ---------- */

.btn-export-nav {
  background: linear-gradient(135deg, #934747, #742e2e);
  color: #fff8ed;
  border-color: rgba(212, 168, 83, 0.85);
  border-radius: 11px;
  box-shadow: 0 4px 12px rgba(139, 58, 58, 0.12);
}

.btn-export-nav:hover {
  background: #682929;
  color: #ffffff;
  border-color: var(--gold);
  transform: translateY(-1px);
}

/* ---------- Footer ---------- */

footer {
  margin-top: auto;
  background: rgba(250, 243, 224, 0.76);
  border-top: 1px solid rgba(139, 58, 58, 0.15);
  color: #806c68;
}

/* ---------- Toast notifications ---------- */

.toast-item {
  background: rgba(48, 30, 29, 0.96);
  border: 1px solid rgba(212, 168, 83, 0.3);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

/* ---------- Scrollbars ---------- */

.tree-viewport,
.modal-dialog,
.profile-modal-body {
  scrollbar-width: thin;
  scrollbar-color: #c7a49a transparent;
}

.tree-viewport::-webkit-scrollbar,
.modal-dialog::-webkit-scrollbar,
.profile-modal-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.tree-viewport::-webkit-scrollbar-thumb,
.modal-dialog::-webkit-scrollbar-thumb,
.profile-modal-body::-webkit-scrollbar-thumb {
  background: #c7a49a;
  border-radius: 99px;
}

.tree-viewport::-webkit-scrollbar-track,
.modal-dialog::-webkit-scrollbar-track,
.profile-modal-body::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Responsive refinements ---------- */

@media (max-width: 768px) {
  header {
    position: sticky;
    top: 0;
  }

  .wrap {
    width: calc(100% - 24px);
  }

  .hero-banner {
    padding: 24px 0 20px;
  }

  .hero-banner::after {
    right: -170px;
    opacity: 0.55;
  }

  .tree-controls-bar,
  .toolbar,
  .directory-control-bar {
    border-radius: 15px;
    padding: 12px;
  }

  .tree-viewport {
    border-radius: 16px;
    padding: 24px 14px 48px;
  }

  .tree-member {
    width: 132px;
    min-height: 155px;
    padding: 12px 8px;
    border-radius: 16px;
  }

  .tree-avatar-circle {
    width: 62px;
    height: 62px;
    font-size: 18px;
  }

  .modern-member-card {
    border-radius: 17px;
  }

  .dashboard-card,
  .kpi-card,
  .stat-box {
    border-radius: 15px;
  }
}

@media (max-width: 480px) {
  .wrap {
    width: calc(100% - 16px);
  }

  .nav {
    gap: 8px;
  }

  .brand h1 {
    font-size: 14px;
  }

  .navlinks a,
  .tab-btn {
    padding: 8px 10px;
  }

  .tree-member {
    width: 120px;
    min-height: 145px;
  }

  .tree-avatar-circle {
    width: 56px;
    height: 56px;
    font-size: 16px;
  }

  .tree-member-name {
    font-size: 12px;
  }

  .tree-member-role {
    font-size: 9px;
  }
}

/* ---------- Accessibility: reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}