/* ═══════════════════════════════════════════════════════════════════════════
   FamilyTree – Main Stylesheet
   Edit the :root variables below to change the colour scheme globally.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Auth / user nav additions ──────────────────────────────────────────── */
.navbar-right        { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.nav-username        { font-size: .85rem; color: rgba(255,255,255,.7); white-space: nowrap; }
.btn-logout          { font-size: .82rem; background: rgba(255,255,255,.12); color: rgba(255,255,255,.85);
                       border: 1px solid rgba(255,255,255,.2); border-radius: 5px; padding: .28rem .7rem;
                       text-decoration: none; transition: background .2s; cursor: pointer; }
.btn-logout:hover    { background: rgba(255,255,255,.22); color: #fff; }
.nav-trial-badge     { font-size: .78rem; background: rgba(255,200,0,.15); color: #ffd54f;
                       border: 1px solid rgba(255,200,0,.3); border-radius: 5px;
                       padding: .25rem .6rem; text-decoration: none; white-space: nowrap; }
.nav-trial-urgent    { background: rgba(255,80,0,.2); color: #ff8a65;
                       border-color: rgba(255,80,0,.4); }
.nav-user-mobile     { display: none; }
.nav-user-name-mobile { display: none; }
@media (max-width: 768px) { .nav-user-mobile { display: block; } }
.lang-toggle { font-size: .8rem; color: rgba(255,255,255,.6); border: 1px solid rgba(255,255,255,.2);
               border-radius: 4px; padding: .2rem .55rem; text-decoration: none; }
.lang-toggle:hover { color: #fff; border-color: rgba(255,255,255,.4); }
.nav-msg-badge {
  display: inline-block; margin-left: .35rem; background: #e04040; color: #fff;
  font-size: .7rem; font-weight: 700; line-height: 1; border-radius: 999px;
  padding: .18rem .42rem; vertical-align: middle;
}

/* ── Impersonation banner (superadmin "switch to user") ─────────────────── */
.impersonation-banner {
  background: #7a3b00;
  color: #ffe0b3;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  text-align: center;
}
.impersonation-banner strong { color: #fff; }
.impersonation-banner form { margin: 0; }
.impersonation-exit-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  padding: 0.25rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.impersonation-exit-btn:hover { background: rgba(255,255,255,0.28); }

/* ── Flash messages ─────────────────────────────────────────────────────── */
.flash-messages      { max-width: 900px; margin: .8rem auto; padding: 0 1rem; }
.flash               { border-radius: 8px; padding: .75rem 1.1rem; margin-bottom: .5rem; font-size: .92rem; }
.flash-success       { background: #d0f0e0; color: #1a5c35; border: 1px solid #a8d8bc; }
.flash-error         { background: #fde8e8; color: #9b1c1c; border: 1px solid #f5a5a5; }
.flash-info          { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ── Colour palette – Slate & Ocean Blue ── */
  --color-bg:            #eef2f7;
  --color-surface:       #ffffff;
  --color-surface-alt:   #f0f5fb;
  --color-surface-2:     #e4ecf6;
  --color-border:        #c4d4e8;
  --color-border-light:  #dce8f4;
  --color-shadow:        rgba(20, 50, 90, 0.10);
  --color-shadow-md:     rgba(20, 50, 90, 0.16);

  --color-primary:       #1b3d6f;
  --color-primary-dark:  #102548;
  --color-primary-light: #2a5fa0;
  --color-primary-text:  #ffffff;

  --color-accent:        #1f7fc4;
  --color-accent-hover:  #1565a0;
  --color-accent-light:  #d0eaf9;

  --color-success:       #1a7a4a;
  --color-success-light: #d0f0e0;
  --color-warning:       #b06010;
  --color-warning-light: #fdecd0;
  --color-danger:        #a02040;
  --color-danger-light:  #fad0d8;

  --color-text:          #18283c;
  --color-text-muted:    #4a6080;
  --color-text-light:    #8aaac8;

  /* ── Gender node colours ── */
  --color-male:          #1565a0;
  --color-male-light:    #c8dff5;
  --color-female:        #7020a0;
  --color-female-light:  #e8d0f8;
  --color-unknown:       #207070;
  --color-unknown-light: #c0e8ec;
  --color-root-node:     #1b3d6f;
  --color-root-light:    #c8d8f0;

  /* ── Typography ── */
  --font-body:      'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', 'Consolas', 'Courier New', monospace;
  --font-size-base: 15px;
  --line-height:    1.65;

  /* ── Layout ── */
  --nav-height:   64px;
  --max-width:    1240px;
  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    16px;
  --transition:   0.18s ease;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-accent-hover); text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.3; }

/* ── Navigation ──────────────────────────────────────────────────────────── */

.navbar {
  background: linear-gradient(90deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
  color: var(--color-primary-text);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  box-shadow: 0 2px 12px var(--color-shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-brand {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  margin-right: 2.5rem;
  letter-spacing: -0.02em;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.navbar-brand:hover { color: #fff; text-decoration: none; opacity: 0.92; }
.navbar-brand small {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.75;
  letter-spacing: 0.01em;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  flex: 1;
}

.navbar-nav a {
  color: rgba(255,255,255,0.80);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.navbar-nav a:hover { background: rgba(255,255,255,0.12); color: #fff; text-decoration: none; }
.navbar-nav a.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-weight: 600;
}

.navbar-lang-desktop { margin-left: auto; }
.nav-lang-mobile { display: none; }

.btn-lang {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.90);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.3rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
  letter-spacing: 0.02em;
}
.btn-lang:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.45);
  color: #fff;
  text-decoration: none;
}

/* ── Tab prev/next arrow buttons (in header, next to the brand) ─────────── */

.navbar-tab-arrows {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1rem;
}

.navbar-tab-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}
.navbar-tab-arrow:hover {
  background: rgba(255,255,255,0.22);
  color: #fff;
  text-decoration: none;
}
.navbar-tab-arrow-disabled {
  opacity: 0.3;
  cursor: default;
}

@media (max-width: 800px) {
  .navbar-tab-arrows { margin-right: 0.4rem; gap: 0.25rem; }
  .navbar-tab-arrow { width: 26px; height: 26px; font-size: 1rem; }
}

/* ── Page wrapper ────────────────────────────────────────────────────────── */

.page-content {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  padding: 2rem 2rem 3rem;
}

.page-header { margin-bottom: 1.75rem; }
.page-header h1 {
  font-size: 1.7rem;
  color: var(--color-primary);
  font-weight: 800;
  margin-bottom: 0.3rem;
  letter-spacing: -0.02em;
}
.page-header p { color: var(--color-text-muted); font-size: 0.95rem; }

/* ── Card ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px var(--color-shadow), 0 4px 16px rgba(20,50,90,0.06);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 1.1rem;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--color-surface-2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

/* Prominent callout for "here's why/what to do" messages - e.g. the iOS
   push-notification instructions - so they read as the answer, not a
   footnote easy to miss next to a disabled/hidden button. */
.ft-push-hint {
  margin-top: 0.85rem;
  margin-bottom: 0;
  padding: 0.75rem 0.9rem;
  background: var(--color-accent-light);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--color-text);
}

/* First-visit "enable notifications?" banner - sits at the top of the page
   content (not inside a card), so it gets its own layout on top of the
   shared .ft-push-hint callout look. */
.ft-push-firstvisit {
  margin-top: 0;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.ft-push-firstvisit-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Stats grid ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 1.4rem 1rem 1.2rem;
  text-align: center;
  box-shadow: 0 1px 4px var(--color-shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-primary-light));
}
.stat-box:hover { transform: translateY(-2px); box-shadow: 0 4px 16px var(--color-shadow-md); }
.stat-number {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}

/* Compact stats variant - home page summary (full stats page keeps the larger boxes) */
.home-stats-section { margin-bottom: 1.1rem; }
.home-stats-title { margin-bottom: 0.6rem; padding-bottom: 0.4rem; }
.stats-grid-compact { gap: 0.6rem; margin-bottom: 0; }
.stats-grid-compact .stat-box { padding: 0.7rem 0.75rem 0.6rem; }
.stats-grid-compact .stat-number { font-size: 1.6rem; }
.stats-grid-compact .stat-label { font-size: 0.68rem; margin-top: 0.25rem; }

/* ── Birthday list ───────────────────────────────────────────────────────── */

/* Birthday list — shared column grid applied to header row + each item */
.birthday-grid-cols { grid-template-columns: 72px 2fr 1fr 1fr 1fr; }

.birthday-list-header {
  display: grid;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem 0.4rem;
  border-bottom: 2px solid var(--color-border);
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.birthday-list { list-style: none; }
.birthday-list li {
  display: grid;
  gap: 0.5rem;
  align-items: center;
  padding: 0.34rem 0.4rem;
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.birthday-list li:last-child { border-bottom: none; }
.birthday-list li:hover { background: var(--color-surface-alt); }
.bday-col-date    { color: var(--color-text-muted); white-space: nowrap; }
.bday-col-age     { color: var(--color-text-muted); white-space: nowrap; }
.bday-col-lineage { }
@media (max-width: 600px) {
  .birthday-grid-cols { grid-template-columns: 60px 2fr 1fr; }
  .bday-col-age, .bday-col-lineage { display: none; }
}

.bday-badge {
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary-light));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 12px;
  min-width: 62px;
  text-align: center;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(31,127,196,0.25);
}
.bday-name { font-weight: 600; font-size: 0.9rem; flex-shrink: 0; }
.bday-meta { color: var(--color-text-muted); font-size: 0.8rem; }

/* ── Calendar export ─────────────────────────────────────────────────────── */

.export-box {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  background: linear-gradient(135deg, var(--color-surface-alt) 0%, var(--color-accent-light) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.4rem 1.75rem;
}
.export-icon { font-size: 2.8rem; flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.12)); }
.export-text h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.35rem; color: var(--color-primary); }
.export-text p  { font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 0.85rem; line-height: 1.5; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.3rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  border: none;
  letter-spacing: 0.01em;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-primary-light) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(31,127,196,0.30);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(31,127,196,0.40); color: #fff; }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1.5px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.btn-sm { padding: 0.32rem 0.85rem; font-size: 0.8rem; }

/* ── ASCII tree ──────────────────────────────────────────────────────────── */

.ascii-controls {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.ascii-tree-container {
  background: #0f1c2e;
  border-radius: var(--radius);
  padding: 1.75rem;
  overflow: auto;
  max-height: 78vh;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), 0 2px 12px var(--color-shadow-md);
  border: 1px solid #1e3a5f;
}

.ascii-tree {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.75;
  color: #c8dff5;
  white-space: pre;
  margin: 0;
}
/* Colour highlights in ASCII tree */
.ascii-tree .male   { color: #6ab0e8; }
.ascii-tree .female { color: #c890f0; }
.ascii-tree .date   { color: #7cd0a0; }

/* ── Tree toolbar ────────────────────────────────────────────────────────── */

.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  box-shadow: 0 1px 4px var(--color-shadow);
}

.tree-search-input {
  flex: 1;
  min-width: 200px;
  max-width: 340px;
  padding: 0.42rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-family: var(--font-body);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.tree-search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(31,127,196,0.18);
  background: #fff;
}
.tree-search-input::placeholder { color: var(--color-text-light); }

/* ── SVG tree containers ─────────────────────────────────────────────────── */

#interactive-tree-svg,
#chart-tree-svg {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px var(--color-shadow);
  overflow: hidden;
  cursor: grab;
  display: block;
}
#interactive-tree-svg:active,
#chart-tree-svg:active { cursor: grabbing; }

.tree-node text { font-family: var(--font-body); pointer-events: none; }
.tree-link { fill: none; stroke: var(--color-border); stroke-width: 1.5px; }

/* ── Person detail panel ─────────────────────────────────────────────────── */

#person-panel {
  position: fixed;
  right: 1.5rem;
  top: calc(var(--nav-height) + 1.5rem);
  width: 300px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--color-shadow-md), 0 2px 8px var(--color-shadow);
  padding: 1.4rem;
  z-index: 500;
  display: none;
  animation: slideIn 0.22s cubic-bezier(.22,.68,0,1.2);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px) scale(0.97); }
  to   { opacity: 1; transform: translateX(0)   scale(1); }
}
#person-panel.visible { display: block; }

#person-panel-close {
  position: absolute;
  top: 0.9rem; right: 0.9rem;
  background: var(--color-surface-2);
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1;
  border-radius: 50%;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
#person-panel-close:hover { background: var(--color-danger-light); color: var(--color-danger); }

.panel-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-bottom: 0.9rem;
  padding-right: 2rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.panel-divider {
  height: 1px;
  background: var(--color-border-light);
  margin: 0.75rem 0;
}
.panel-row {
  display: flex;
  gap: 0.5rem;
  font-size: 0.84rem;
  margin-bottom: 0.45rem;
  align-items: baseline;
}
.panel-label {
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 90px;
  flex-shrink: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 14px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-male     { background: var(--color-male-light);    color: var(--color-male); }
.badge-female   { background: var(--color-female-light);  color: var(--color-female); }
.badge-lineage  { background: var(--color-accent-light);  color: var(--color-primary); }
.badge-deceased { background: var(--color-surface-2);     color: var(--color-text-muted); }
.badge-alive    { background: var(--color-success-light); color: var(--color-success); }

/* ── Hero section ────────────────────────────────────────────────────────── */

.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, #0d2040 50%, var(--color-primary-light) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.5rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 24px var(--color-shadow-md);
}
.hero::before {
  content: '';
  position: absolute;
  top: -40%; right: -10%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(41,128,185,0.25) 0%, transparent 70%);
  pointer-events: none;
}
.hero::after {
  content: "🌳";
  position: absolute;
  right: 2rem; top: 50%;
  transform: translateY(-50%);
  font-size: 6rem;
  opacity: 0.12;
  pointer-events: none;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
  letter-spacing: -0.03em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.hero p { font-size: 1rem; opacity: 0.88; max-width: 580px; line-height: 1.6; }

/* Compact hero variant - home page banner (landing page keeps the full-size .hero).
   Uses the compound .hero.hero-compact selector so it wins over the .hero
   mobile-breakpoint overrides further down, regardless of source order. */
.hero.hero-compact { padding: 1.15rem 1.5rem; margin-bottom: 1.25rem; }
.hero.hero-compact::after { font-size: 3.4rem; opacity: 0.10; right: 1.25rem; }
.hero.hero-compact h1 { font-size: 1.35rem; margin-bottom: 0.2rem; }
.hero.hero-compact p { font-size: 0.92rem; opacity: 0.85; }

/* ── Quick-link cards on home ────────────────────────────────────────────── */

.quicklink-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.1rem;
  margin-top: 0.5rem;
}
.quicklink-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  text-decoration: none;
  display: block;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}
.quicklink-card::after {
  content: '→';
  position: absolute;
  bottom: 1rem; right: 1.25rem;
  font-size: 1.1rem;
  color: var(--color-border);
  transition: color var(--transition), right var(--transition);
}
.quicklink-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px var(--color-shadow-md);
  border-color: var(--color-accent);
  text-decoration: none;
}
.quicklink-card:hover::after { color: var(--color-accent); right: 1rem; }
.quicklink-icon { font-size: 2.2rem; margin-bottom: 0.65rem; display: block; }
.quicklink-title { font-weight: 700; color: var(--color-primary); font-size: 0.95rem; margin-bottom: 0.3rem; }
.quicklink-desc  { font-size: 0.82rem; color: var(--color-text-muted); line-height: 1.5; }

/* ── Stats page charts ───────────────────────────────────────────────────── */

.chart-container { position: relative; margin: 0.5rem 0; }
.bar-chart { display: flex; flex-direction: column; gap: 0.45rem; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.bar-label { min-width: 90px; text-align: right; color: var(--color-text-muted); font-weight: 500; flex-shrink: 0; }
.bar-track {
  flex: 1;
  background: var(--color-surface-2);
  border-radius: 4px;
  height: 24px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-primary-light));
  transition: width 0.8s cubic-bezier(.22,.68,0,1.1);
  display: flex;
  align-items: center;
  padding-left: 8px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 28px;
}
.bar-fill.female { background: linear-gradient(90deg, var(--color-female), #a040d0); }
.bar-fill.male   { background: linear-gradient(90deg, var(--color-male), var(--color-accent)); }

.people-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.people-table th {
  background: var(--color-surface-2);
  color: var(--color-primary);
  font-weight: 700;
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--color-border);
}
.people-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
}
.people-table tr:last-child td { border-bottom: none; }
.people-table tr:hover td { background: var(--color-surface-alt); }
.people-table .badge { font-size: 0.76rem; padding: 0.1rem 0.5rem; }

/* ── Donut / pie chart (CSS-only) ────────────────────────────────────────── */

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}
.donut-legend { display: flex; flex-direction: column; gap: 0.6rem; }
.legend-item  { display: flex; align-items: center; gap: 0.55rem; font-size: 0.875rem; }
.legend-dot   { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ── Info pages ──────────────────────────────────────────────────────────── */

.info-page { max-width: 680px; }
.info-page h1 { margin-bottom: 1.25rem; color: var(--color-primary); font-size: 1.6rem; font-weight: 800; }
.info-page p  { margin-bottom: 1rem; color: var(--color-text-muted); line-height: 1.7; }
.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary-light));
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  margin-top: 0.75rem;
  box-shadow: 0 2px 8px rgba(31,127,196,0.30);
  transition: box-shadow var(--transition), transform var(--transition);
}
.contact-link:hover { box-shadow: 0 4px 16px rgba(31,127,196,0.42); transform: translateY(-1px); color: #fff; text-decoration: none; }

/* ── Footer ──────────────────────────────────────────────────────────────── */

footer {
  background: var(--color-primary-dark);
  color: rgba(255,255,255,0.65);
  padding: 1.4rem 2rem;
  text-align: center;
  font-size: 0.82rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
footer a { color: rgba(255,255,255,0.65); margin: 0 0.75rem; transition: color var(--transition); }
footer a:hover { color: #fff; text-decoration: underline; }
.footer-links { margin-top: 0.5rem; }
.footer-sep { opacity: 0.3; }

/* ── Hamburger / mobile nav ──────────────────────────────────────────────── */

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 1.5rem;
  margin-left: auto;
  padding: 0.3rem;
  line-height: 1;
}

@media (max-width: 800px) {
  .nav-toggle { display: block; }
  .navbar { padding: 0 1.25rem; }
  .navbar-brand { font-size: 0.95rem; }
  .navbar-brand small { display: none; }
  .navbar-brand { margin-right: 0.6rem; }
  .navbar-nav {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--color-primary-dark);
    flex-direction: column;
    padding: 0.75rem 1.25rem 1rem;
    gap: 0.15rem;
    align-items: flex-start;
    box-shadow: 0 6px 16px var(--color-shadow-md);
    z-index: 999;
  }
  .navbar-nav.open { display: flex; }
  .navbar-nav li { width: 100%; }
  .navbar-nav a { width: 100%; padding: 0.65rem 0.85rem; display: block; }
  .navbar-lang-desktop { display: none; }
  /* Username sits after the hamburger in the top bar and overflows narrow
     screens; hide it here and surface identity inside the dropdown instead. */
  .nav-username { display: none; }
  .nav-user-name-mobile { display: block; padding: 0.5rem 0.85rem 0.25rem; }
  .nav-user-name-mobile .nav-username { display: inline; }
  .nav-lang-mobile { display: block; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid rgba(255,255,255,0.1); }
  .nav-lang-mobile a { display: inline-flex !important; width: auto !important; }

  .hero { padding: 1.5rem 1.25rem; }
  .hero::after { display: none; }
  .hero h1 { font-size: 1.4rem; }
  .hero p { font-size: 0.9rem; }

  .hero.hero-compact { padding: 0.9rem 1.1rem; }
  .hero.hero-compact h1 { font-size: 1.2rem; }
  .hero.hero-compact p { font-size: 0.85rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .stat-number { font-size: 1.9rem; }

  .page-content { padding: 1.1rem 1rem 2rem; }
  .card { padding: 1.1rem 1.25rem; }

  /* Two-column grids become single column on mobile */
  div[style*="grid-template-columns:1fr 1fr"] {
    display: block !important;
  }
  div[style*="grid-template-columns:1fr 1fr"] > .card {
    margin-bottom: 1rem;
  }

  /* Tree pages: full viewport height minus nav */
  #interactive-tree-svg,
  #chart-tree-svg { height: 70vh; min-height: 380px; }

  .tree-toolbar { gap: 0.35rem; padding: 0.5rem 0.75rem; }
  .tree-search-input { max-width: 100%; min-width: 0; flex: 1; }

  /* Person panel slides up from bottom on mobile */
  #person-panel {
    position: fixed;
    bottom: 0; top: auto;
    left: 0; right: 0;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 60vh;
    overflow-y: auto;
    animation: slideUp 0.25s cubic-bezier(.22,.68,0,1.2);
  }
  @keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  /* Quicklink grid: 2 columns on mobile */
  .quicklink-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .quicklink-card { padding: 1rem; }
  .quicklink-card::after { display: none; }
  .quicklink-icon { font-size: 1.6rem; margin-bottom: 0.4rem; }

  /* Bar charts: smaller labels */
  .bar-label { min-width: 70px; font-size: 0.78rem; }
  .bar-fill { font-size: 0.72rem; }

  /* ASCII tree */
  .ascii-tree-container { padding: 1rem; }
  .ascii-tree { font-size: 0.78rem; line-height: 1.6; }

  /* Stats tables (oldest/youngest/most-children): tighten so all 3
     columns - including age - stay visible and comfortable on phones. */
  .people-table th, .people-table td { padding: 0.55rem 0.6rem; }
  .people-table { font-size: 0.82rem; }

  /* Export box: stack vertically */
  .export-box { flex-direction: column; gap: 0.75rem; }
  .export-icon { font-size: 2rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .quicklink-grid { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 1.2rem; }
  .page-header h1 { font-size: 1.35rem; }
}

/* ── Misc utilities ──────────────────────────────────────────────────────── */

.highlight { background: rgba(31,127,196,0.18); border-radius: 3px; }

.spinner {
  border: 3px solid var(--color-border);
  border-top: 3px solid var(--color-accent);
  border-radius: 50%;
  width: 36px; height: 36px;
  animation: spin 0.8s linear infinite;
  margin: 2.5rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.d3-tooltip {
  position: absolute;
  background: var(--color-primary-dark);
  color: rgba(255,255,255,0.92);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 240px;
  line-height: 1.55;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.d3-tooltip.visible { opacity: 1; }

/* ── Scrollbar styling (Webkit) ──────────────────────────────────────────── */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-surface-2); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-light); }
