/* ============================================================
   Nek Mon Family Lineage — Light Mode
   Inter + Playfair Display
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

:root {
  --gold:       #b8860b;
  --gold-lt:    #d4a017;
  --gold-bg:    #fdf8ee;
  --gold-line:  #e8d5a3;
  --bg:         #ffffff;
  --bg2:        #fafaf9;
  --bg3:        #f5f3ef;
  --bg4:        #eeeae0;
  --text:       #1a1714;
  --text-2:     #3d3830;
  --dim:        #7a7060;
  --border:     #e2ddd4;
  --border-2:   #d0c8b8;
  --red:        #c0392b;
  --green:      #27ae60;
  --blue:       #2563eb;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --radius:     10px;
  --radius-sm:  6px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-lt); text-decoration: underline; }

/* ── Auth Pages ──────────────────────────────────────────── */
.auth-body {
  background: linear-gradient(135deg, var(--gold-bg) 0%, #f0ede6 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}
.auth-wrap  { width: 100%; max-width: 440px; }
.auth-card  {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: var(--shadow-md);
}
.auth-crest {
  width: 52px; height: 52px;
  border: 2px solid var(--gold-line);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--gold-bg);
  margin: 0 auto 20px;
}
.auth-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
  font-weight: 700;
}
.auth-sub {
  font-size: 13px;
  color: var(--dim);
  text-align: center;
  margin-bottom: 28px;
}
.auth-form  { display: flex; flex-direction: column; gap: 14px; }
.auth-links {
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--dim);
}
.auth-links a { color: var(--gold); font-weight: 500; }
.auth-links a:hover { text-decoration: underline; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 6px 0;
  font-size: 12px; color: var(--dim);
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 11px;
  color: var(--dim);
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ── Site Header ─────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 32px;
  height: 60px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: 0 1px 0 var(--border);
}
.site-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.crest {
  width: 32px; height: 32px;
  border: 1.5px solid var(--gold-line);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  background: var(--gold-bg);
  color: var(--gold);
}
.brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  color: var(--text);
  font-weight: 700;
  display: block;
  letter-spacing: -0.01em;
}
.brand-sub { font-size: 10px; color: var(--dim); font-weight: 400; letter-spacing: 0.02em; }

.nav { display: flex; gap: 2px; flex: 1; justify-content: center; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--dim);
  border: 1px solid transparent;
  transition: all .15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--bg3);
  border-color: var(--border);
  text-decoration: none;
}

.nav-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold-bg);
  border: 1px solid var(--gold-line);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--gold);
}
.nav-name  { font-size: 13px; color: var(--text-2); font-weight: 500; }
.nav-logout {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 12px; font-weight: 500;
  color: var(--dim);
  transition: all .15s;
}
.nav-logout:hover { color: var(--red); border-color: #fca5a5; background: #fff5f5; text-decoration: none; }

/* ── Main ────────────────────────────────────────────────── */
.main { flex: 1; }

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--gold-bg) 0%, var(--bg3) 100%);
  border-bottom: 1px solid var(--border);
  padding: 52px 40px 44px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '⬡';
  position: absolute;
  right: -30px; top: -40px;
  font-size: 260px;
  color: rgba(184,134,11,.05);
  pointer-events: none;
  line-height: 1;
}
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.hero-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(26px, 4vw, 40px);
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 12px;
  font-weight: 700;
}
.hero-sub { font-size: 15px; color: var(--dim); max-width: 480px; line-height: 1.7; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }

/* ── Stats Row ───────────────────────────────────────────── */
.stats-row {
  display: flex; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.stat {
  flex: 1 1 100px;
  padding: 20px 24px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.stat:last-child { border-right: none; }
.stat-n {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: 30px;
  color: var(--gold);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-l { display: block; font-size: 11px; color: var(--dim); font-weight: 500; letter-spacing: 0.03em; }

/* ── Section ─────────────────────────────────────────────── */
.section { padding: 36px 40px; }
.section-sm { padding: 20px 40px; }
.sec-title {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}

/* ── Branch Cards ────────────────────────────────────────── */
.branch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
  gap: 12px;
}
.branch-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, border-color .2s, transform .15s;
}
.branch-card:hover { box-shadow: var(--shadow-md); border-color: var(--gold-line); transform: translateY(-1px); }
.branch-empty { background: var(--bg2); opacity: 0.65; }
.branch-header { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.branch-name { font-family: 'Playfair Display', serif; font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 3px; }
.branch-spouse { font-size: 12px; color: var(--dim); margin-bottom: 10px; }
.branch-children-label { font-size: 10px; font-weight: 600; letter-spacing: .08em; color: var(--dim); text-transform: uppercase; margin-bottom: 7px; }
.child-chip {
  display: inline-block; padding: 3px 9px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; font-size: 11px; color: var(--dim); margin: 2px;
}
.branch-no-children { font-size: 12px; color: var(--dim); font-style: italic; margin-top: 8px; }

/* ── Info Row ────────────────────────────────────────────── */
.info-row { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 12px; }
.info-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.info-label { font-size: 10px; font-weight: 600; letter-spacing: .08em; color: var(--dim); text-transform: uppercase; margin-bottom: 6px; }
.info-val { font-size: 15px; color: var(--text); font-weight: 500; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 40px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 12px;
  background: var(--bg);
}
.page-title { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub   { font-size: 13px; color: var(--dim); margin-top: 3px; }
.page-header-actions { display: flex; gap: 8px; }

/* ── Filter Bar ──────────────────────────────────────────── */
.filter-bar { padding: 14px 40px; background: var(--bg2); border-bottom: 1px solid var(--border); }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { padding: 0 40px 40px; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--bg2); padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.data-table tr:hover td { background: var(--bg2); }
.tbl-link { color: var(--gold); font-size: 12px; font-weight: 500; }
.tbl-link:hover { color: var(--gold-lt); }
.text-dim { color: var(--dim); font-size: 12px; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 28px;
  margin: 0 40px 20px; box-shadow: var(--shadow);
}
.card-title {
  font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 600;
  color: var(--text); margin-bottom: 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.01em; }
.form-input,
.form-select,
.form-textarea {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.form-input::placeholder { color: #b0a898; }
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184,134,11,.1);
}
.form-select option { background: var(--bg); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.form-hint { font-size: 11px; color: var(--dim); margin-top: 3px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer; border: 1px solid transparent;
  transition: all .15s; line-height: 1; white-space: nowrap;
}
.btn-gold    { background: var(--gold);    color: #fff !important; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-lt); border-color: var(--gold-lt); text-decoration: none; }
.btn-outline { background: var(--bg);      color: var(--gold) !important; border-color: var(--gold-line); }
.btn-outline:hover { border-color: var(--gold); background: var(--gold-bg); text-decoration: none; }
.btn-ghost   { background: var(--bg);      color: var(--dim) !important;  border-color: var(--border); }
.btn-ghost:hover { color: var(--text) !important; border-color: var(--border-2); background: var(--bg2); text-decoration: none; }
.btn-danger  { background: #fff5f5;        color: var(--red) !important;  border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; text-decoration: none; }
.btn-green   { background: var(--green);   color: #fff !important; border-color: var(--green); }
.btn-green:hover { background: #219150; text-decoration: none; }
.w-full { width: 100%; justify-content: center; }

/* ── Badges ──────────────────────────────────────────────── */
.gen-badge {
  display: inline-block; padding: 2px 9px;
  border-radius: 20px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.03em; white-space: nowrap;
}
.gen-0 { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.gen-1 { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.gen-2 { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.gen-3 { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }
.gen-4 { background: #fdf4ff; color: #6b21a8; border: 1px solid #d8b4fe; }

.deceased-tag { display:inline-block;padding:2px 8px;border-radius:12px;font-size:10px;font-weight:600;background:#fee2e2;color:#991b1b;border:1px solid #fca5a5; }
.living-tag   { display:inline-block;padding:2px 8px;border-radius:12px;font-size:10px;font-weight:600;background:#dcfce7;color:#166534;border:1px solid #86efac; }
.pending-tag  { display:inline-block;padding:2px 8px;border-radius:12px;font-size:10px;font-weight:600;background:#fef9c3;color:#854d0e;border:1px solid #fde68a; }

.role-badge   { display:inline-block;padding:2px 8px;border-radius:12px;font-size:10px;font-weight:600; }
.role-admin   { background:#fef9c3;color:#854d0e;border:1px solid #fde68a; }
.role-member  { background:#dcfce7;color:#166534;border:1px solid #86efac; }
.role-viewer  { background:#f3f4f6;color:#4b5563;border:1px solid #d1d5db; }
.role-pending { background:#fff7ed;color:#9a3412;border:1px solid #fdba74; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin: 0 40px 14px; font-weight: 500; }
.alert-error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.alert-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }
.alert-warn    { background: #fef9c3; border: 1px solid #fde68a; color: #854d0e; }

/* ── Tree ────────────────────────────────────────────────── */
.tree-outer { padding: 20px 40px 40px; }
#pfs-tree {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tooltip {
  position: fixed; z-index: 9999;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 200px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  font-size: 13px;
  line-height: 1.7;
  box-shadow: var(--shadow-md);
}
.tooltip.show { opacity: 1; }
.tt-name { font-family: 'Playfair Display', serif; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.tt-row  { color: var(--dim); font-size: 12px; }
.tt-row strong { color: var(--text-2); font-weight: 600; }

/* ── Users Page ──────────────────────────────────────────── */
.user-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px;
}
.user-row:last-child { border-bottom: none; }
.user-inactive { opacity: 0.5; }
.user-pending  { background: #fffbeb; border-radius: var(--radius-sm); padding: 10px 14px; margin: 4px 0; }

/* ── Pending approval banner ─────────────────────────────── */
.pending-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  margin: 40px;
}
.pending-banner h2 { font-family: 'Playfair Display', serif; font-size: 20px; color: #9a3412; margin-bottom: 10px; }
.pending-banner p  { font-size: 14px; color: #7c2d12; line-height: 1.7; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 40px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--dim); font-weight: 500;
  background: var(--bg2); flex-shrink: 0;
}
.site-footer a { color: var(--dim); }
.site-footer a:hover { color: var(--gold); text-decoration: none; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .site-header { padding: 0 16px; }
  .nav { display: none; }
  .hero, .section, .section-sm { padding-left: 20px; padding-right: 20px; }
  .page-header, .filter-bar, .table-wrap { padding-left: 20px; padding-right: 20px; }
  .card { margin-left: 20px; margin-right: 20px; }
  .alert { margin-left: 20px; margin-right: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .tree-outer { padding: 14px 20px 28px; }
  #pfs-tree { height: 400px !important; }
  .stats-row { flex-direction: column; }
  .site-footer { flex-direction: column; gap: 4px; text-align: center; }
  .auth-card { padding: 28px 22px; }
  .pending-banner { margin: 20px; }
}

/* ── Brand Logo ──────────────────────────────────────────── */
.brand-logo-link { display: flex; align-items: center; flex-shrink: 0; }
.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 50%;
  transition: transform .2s;
}
.brand-logo:hover { transform: scale(1.05); }

/* ── Brand Logo (landscape format) ──────────────────────── */
.brand-logo {
  width: auto !important;
  height: 40px !important;
  max-width: 160px;
  object-fit: contain;
  border-radius: 0 !important;
  display: block;
}
.login-logo {
  width: 100% !important;
  max-width: 280px;
  height: auto !important;
  object-fit: contain;
  display: block;
  margin: 0 auto 10px;
}
.register-logo {
  width: 100%;
  max-width: 220px;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto 10px;
}
.small-logo {
  width: 100%;
  max-width: 180px;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto 10px;
}
