/* ═══════════════════════════ ADMIN DASHBOARD ══════════════════════════════
   A full screen of its own, not a dialog — its own sticky header with a
   back button, a scrolling body, and a centred max-width content column.  */
.admin-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-screen);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-elevated) 100%);
}
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: var(--safe-t);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}
.admin-topbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.admin-topbar__left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.admin-topbar__back {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  width: 40px; height: 40px;
  flex: none;
}
.admin-topbar__back:hover { background: var(--surface-3); }
.admin-topbar__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: var(--tracking-display);
  line-height: 1.15;
}
.admin-topbar__eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 2px;
}
.admin-topbar__right { display: flex; align-items: center; gap: 8px; flex: none; }
.admin-topbar__role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  color: var(--gold);
  font-size: var(--fs-xs);
  font-weight: 800;
  white-space: nowrap;
}
.admin-screen__inner { max-width: 1180px; margin: 0 auto; padding: 20px; }

@media (max-width: 720px) {
  .admin-topbar__inner { padding: 12px 14px; }
  .admin-screen__inner { padding: 14px; }
  .admin-topbar__role { display: none; }
}

.admin-tabs {
  display: flex;
  gap: 6px;
  padding: 0 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
  background: transparent;
  /* Row is wider than the screen on mobile — without this the last tab is
     just hard-clipped by the viewport edge, which reads as a rendering
     glitch rather than "scroll for more". Fading the last ~28px instead
     signals there's more to scroll to, the way a native tab strip would. */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  position: relative;
  flex: none;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.admin-tab:hover { color: var(--text); background: var(--surface-2); }
/* Same theme-inverted colour as the primary button (see tokens.css) — the
   mockup's active admin tab is solid dark-slate in light mode, solid amber
   in dark mode, not a fixed gold gradient either way. */
.admin-tab.is-active { color: var(--btn-primary-text); background: var(--btn-primary-bg); border-color: transparent; box-shadow: 0 7px 18px -10px rgba(0,0,0,.4); }
.admin-tab__count {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  font-size: 10px;
  font-weight: 800;
}
.admin-tab.is-active .admin-tab__count { background: rgba(0,0,0,.18); color: var(--text-on-gold); }

/* ── Section card ────────────────────────────────────────────────────────────
   The mockup groups every admin section into its own padded, rounded card
   rather than letting rows float loose on the page background — that
   grouping is most of what makes it read as "clean". */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl);
  box-shadow: 0 12px 38px -24px rgba(0,0,0,.35);
  padding: 20px;
  margin-bottom: 18px;
}
.admin-card__head { margin-bottom: 14px; }
.admin-card__title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: var(--tracking-display);
}
.admin-card__desc { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 3px; line-height: 1.5; }
.admin-card > .arow:last-child { margin-bottom: 0; }

/* ── Stat tiles ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  position: relative;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  box-shadow: 0 12px 38px -24px rgba(0,0,0,.35);
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.stat::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--line-strong);
}
.stat__value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: var(--tracking-display);
}
.stat__label {
  margin-top: 7px;
  font-size: var(--fs-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
}
.stat--gold::before   { background: linear-gradient(90deg, var(--gold-bright), var(--gold)); }
.stat--warn::before   { background: var(--warn); }
.stat--ok::before     { background: var(--ok); }
.stat--info::before   { background: var(--info); }
.stat--gold   .stat__value { color: var(--gold); }
.stat--warn   .stat__value { color: var(--warn); }
.stat--ok     .stat__value { color: var(--ok); }
.stat--info   .stat__value { color: var(--info); }

/* ── Admin rows (ghosts / users / links) ─────────────────────────────────── */
.arow {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 8px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.arow:hover { border-color: var(--line-strong); background: var(--bg-elevated); }
.arow__main { flex: 1; min-width: 0; }
.arow__name { font-weight: 700; font-size: var(--fs-base); }
.arow__meta { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 3px; line-height: 1.45; }
.arow__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.arow input[type="checkbox"] { margin-top: 4px; accent-color: var(--gold); width: 17px; height: 17px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .input, .toolbar .select { min-height: 36px; width: auto; flex: 1; min-width: 150px; }

/* ── Bar chart (analytics) ───────────────────────────────────────────────── */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 148px;
  padding: 12px 4px 0;
  border-bottom: 1px solid var(--line);
}
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart__bar {
  width: 100%;
  max-width: 40px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  transition: height var(--t-base) var(--ease-out);
  position: relative;
}
.chart__bar span {
  position: absolute;
  top: -17px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}
.chart__label { font-size: 10px; color: var(--text-dim); }

.rank-list { display: grid; gap: 6px; }
.rank {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
}
.rank__pos {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 800;
  flex: none;
}
.rank:first-child .rank__pos { background: var(--gold); color: var(--text-on-gold); }
.rank__value { margin-left: auto; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ── Settings blocks ─────────────────────────────────────────────────────── */
.setting-block {
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.setting-block__title {
  font-size: var(--fs-sm);
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Activity log ────────────────────────────────────────────────────────── */
.log-day {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 16px 0 8px;
}
.log-item {
  display: flex;
  gap: 11px;
  padding: 9px 12px;
  border-left: 2px solid var(--line);
  font-size: var(--fs-sm);
}
.log-item__time { color: var(--text-dim); font-size: var(--fs-xs); min-width: 66px; flex: none; font-variant-numeric: tabular-nums; }
.log-item__text { color: var(--text-muted); flex: 1; }
.log-item__text strong { color: var(--text); }

/* ── Family timeline ─────────────────────────────────────────────────────────
   Matches family_tree_interface.html's timeline panel: a year column, a
   card row (avatar, name + ID chip, role/status line, city), and a
   hover-reveal "Locate" pill tinted to the person's role colour. */
.timeline { position: relative; }
.timeline__decade {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 18px 0 8px;
}
.timeline__decade:first-child { margin-top: 2px; }

.timeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 3px 3px 3px 0;
  margin-bottom: 6px;
  border-radius: var(--r-lg);
  text-align: left;
  transition: background var(--t-fast);
}
.timeline-row__year {
  width: 34px; flex: none;
  text-align: right;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.timeline-row__card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.timeline-row:hover .timeline-row__card { border-color: var(--line-strong); background: var(--bg-elevated); }
.timeline-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.timeline-row__name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: var(--fs-sm); color: var(--text); }
.timeline-row__id {
  font-size: 9px; font-weight: 800; letter-spacing: .04em;
  padding: 1px 6px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-dim);
  flex: none;
}
.timeline-row__meta {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); color: var(--text-dim); flex-wrap: wrap;
}
.timeline-row__status { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text-muted); }
.timeline-row__status svg { width: 10px; height: 10px; }
.timeline-row__status--memory { color: #94a3b8; font-style: italic; }
.timeline-row__status--plain { color: var(--text-dim); font-weight: 500; }

.timeline-row__locate {
  flex: none;
  display: flex; align-items: center; gap: 5px;
  padding: 5px 9px;
  border-radius: var(--r-md);
  font-size: 10px; font-weight: 700;
  color: var(--gold); background: rgba(245,158,11,.12);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.timeline-row:hover .timeline-row__locate, .timeline-row:focus-visible .timeline-row__locate { opacity: 1; }
.timeline-row__locate svg { width: 13px; height: 13px; }

/* Role tint on the status line + locate pill — same rank→colour mapping as
   the tree cards and member panel (Seedling slate, Rooted Sapling emerald,
   Trusted Leaf sky, Branch Keeper violet, Tree Guardian amber). */
.timeline-row--rooted   .timeline-row__status { color: #34d399; }
.timeline-row--rooted   .timeline-row__locate { color: #34d399; background: rgba(16,185,129,.14); }
.timeline-row--verified .timeline-row__status { color: #38bdf8; }
.timeline-row--verified .timeline-row__locate { color: #38bdf8; background: rgba(14,165,233,.14); }
.timeline-row--subadmin .timeline-row__status { color: #a78bfa; }
.timeline-row--subadmin .timeline-row__locate { color: #a78bfa; background: rgba(139,92,246,.14); }
.timeline-row--admin    .timeline-row__status { color: var(--gold); }
.timeline-row--member   .timeline-row__status { color: #94a3b8; }
.timeline-row--member   .timeline-row__locate { color: #94a3b8; background: rgba(100,116,139,.14); }
.timeline-row--memory   .timeline-row__locate { color: #a8a29e; background: rgba(120,113,108,.14); }

/* ── Role picker ─────────────────────────────────────────────────────────── */
.role-option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.role-option:hover { border-color: var(--line-strong); }
.role-option input { accent-color: var(--gold); margin-top: 3px; }
.role-option.is-selected { border-color: var(--gold); background: rgba(245,158,11,.08); }
.role-option__name { font-weight: 700; font-size: var(--fs-sm); }
.role-option__desc { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 2px; }

/* ── Permission matrix ───────────────────────────────────────────────────── */
.matrix-wrap { overflow-x: auto; }
.matrix { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); min-width: 440px; }
.matrix th, .matrix td { padding: 9px 10px; text-align: center; border-bottom: 1px solid var(--line-soft); }
.matrix th:first-child, .matrix td:first-child { text-align: left; color: var(--text-muted); }
.matrix thead th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.matrix .yes { color: var(--ok); font-weight: 800; }
.matrix .no  { color: var(--text-dim); opacity: .6; }
