/* Gia Phả – giao diện người xem. Theme có thể ghi đè các biến màu bên dưới. */
:root {
	--gp-accent: #8b1a1a;
	--gp-gold: #b8892b;
	--gp-paper: #fffaf0;
	--gp-card: #fffdf8;
	--gp-ink: #2b2118;
	--gp-muted: #7a6a58;
	--gp-line: #dccbaa;
	--gp-male: #2f5d8a;
	--gp-female: #a8436b;
	--gp-dead-bg: #f3ede2;
	--gp-radius: 10px;
}

.gp-notice { padding: 14px 18px; border-left: 4px solid var(--gp-gold); background: var(--gp-paper); margin: 1em 0; border-radius: 4px; }
.gp-notice-ok { border-color: #2e7d32; background: #eff8f0; }
.gp-notice-err { border-color: #c62828; background: #fdeeee; }
.gp-empty, .gp-muted { color: var(--gp-muted); }

.gp-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px; background: var(--gp-accent); color: #fff !important; border: 1px solid var(--gp-accent); text-decoration: none !important; font: inherit; font-size: .92em; cursor: pointer; line-height: 1.3; }
.gp-btn:hover { filter: brightness(1.1); }
.gp-btn-ghost { background: transparent; color: var(--gp-accent) !important; }

/* ---------- Cây ---------- */
.gp-tree { position: relative; height: 78vh; min-height: 480px; border: 1px solid var(--gp-line); border-radius: var(--gp-radius); overflow: hidden; background: var(--gp-paper) radial-gradient(circle at 1px 1px, rgba(120, 90, 40, .12) 1px, transparent 0) 0 0 / 22px 22px; color: var(--gp-ink); font-size: 14px; user-select: none; -webkit-user-select: none; }
.gp-tree.gp-full { position: fixed; inset: 0; height: auto; z-index: 99999; border-radius: 0; border: 0; }
.gp-tree-loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--gp-muted); padding: 20px; text-align: center; }
.gp-tree-bar { position: absolute; z-index: 5; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; pointer-events: none; }
.gp-tree-bar > * { pointer-events: auto; }
.gp-tree-search { position: relative; flex: 1 1 220px; max-width: 340px; }
.gp-tree-search input { width: 100%; box-sizing: border-box; padding: 8px 12px; border: 1px solid var(--gp-line); border-radius: 999px; background: #fff; font: inherit; box-shadow: 0 2px 8px rgba(60, 40, 10, .08); }
.gp-tree-results { position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid var(--gp-line); border-radius: 8px; box-shadow: 0 8px 24px rgba(60, 40, 10, .15); max-height: 320px; overflow: auto; }
.gp-tree-results li { padding: 6px 12px; cursor: pointer; display: flex; flex-direction: column; margin: 0; }
.gp-tree-results li small { color: var(--gp-muted); }
.gp-tree-results li:hover, .gp-tree-results li.active { background: var(--gp-paper); }
.gp-tree-results li.gp-none { cursor: default; color: var(--gp-muted); }
.gp-tree-btns { display: flex; gap: 4px; flex-wrap: wrap; background: #fff; border: 1px solid var(--gp-line); border-radius: 999px; padding: 3px; box-shadow: 0 2px 8px rgba(60, 40, 10, .08); }
.gp-tree-btns button, .gp-tree-btns select { border: 0; background: transparent; color: var(--gp-ink); min-width: 34px; height: 32px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 16px; padding: 0 8px; line-height: 1; }
.gp-tree-btns select { font-size: 13px; padding: 0 4px; }
.gp-tree-btns button:hover, .gp-tree-btns select:hover { background: var(--gp-paper); }
.gp-tree-btns button[data-act=home] { font-size: 13px; color: var(--gp-accent); font-weight: 600; }
.gp-tree-hint { position: absolute; left: 10px; bottom: 8px; font-size: 12px; color: var(--gp-muted); background: rgba(255, 250, 240, .85); padding: 2px 8px; border-radius: 6px; pointer-events: none; }
.gp-tree-stage { position: absolute; inset: 0; cursor: grab; touch-action: none; }
.gp-tree-stage.gp-grabbing { cursor: grabbing; }
.gp-tree-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.gp-tree-canvas.gp-anim { transition: transform .4s cubic-bezier(.2, .7, .2, 1); }
.gp-links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.gp-links path { fill: none; stroke: #b9a27a; stroke-width: 1.6; }
.gp-links path.gp-on { stroke: var(--gp-accent); stroke-width: 3; }

.gp-node { position: absolute; box-sizing: border-box; background: var(--gp-card); border: 1px solid var(--gp-line); border-top: 4px solid var(--gp-gold); border-radius: var(--gp-radius); box-shadow: 0 2px 6px rgba(60, 40, 10, .08); cursor: pointer; padding: 8px 8px 6px; transition: box-shadow .15s, border-color .15s; outline: none; }
.gp-node.gp-m { border-top-color: var(--gp-male); }
.gp-node.gp-f { border-top-color: var(--gp-female); }
.gp-node.gp-dead { background: var(--gp-dead-bg); }
.gp-node:hover, .gp-node:focus-visible { box-shadow: 0 4px 14px rgba(60, 40, 10, .2); border-color: var(--gp-gold); }
.gp-node.gp-path { border-color: var(--gp-accent); }
.gp-node.gp-sel { box-shadow: 0 0 0 3px var(--gp-accent), 0 6px 18px rgba(60, 40, 10, .25); }
.gp-node.gp-pulse { animation: gp-pulse 1.2s ease-out 1; }
@keyframes gp-pulse { 0% { box-shadow: 0 0 0 0 rgba(139, 26, 26, .6); } 100% { box-shadow: 0 0 0 18px rgba(139, 26, 26, 0); } }
.gp-node-main { display: flex; gap: 8px; align-items: flex-start; height: 50px; }
.gp-node-av { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #efe3cc; color: var(--gp-accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.gp-node-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gp-m > .gp-node-main .gp-node-av, .gp-node-av.gp-m { background: #e3ebf3; color: var(--gp-male); }
.gp-f > .gp-node-main .gp-node-av, .gp-node-av.gp-f { background: #f5e3ea; color: var(--gp-female); }
.gp-node-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gp-node-name { font-weight: 700; font-size: 13.5px; line-height: 1.25; color: var(--gp-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.gp-node-years { font-size: 12px; color: var(--gp-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp-node-gen { position: absolute; right: 6px; top: 4px; font-size: 10px; color: var(--gp-muted); opacity: .8; }
.gp-node-sp { border-top: 1px dashed var(--gp-line); margin-top: 4px; padding-top: 3px; }
.gp-sp { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 0 2px; height: 20px; line-height: 20px; font: inherit; font-size: 12px; color: var(--gp-ink); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; }
.gp-sp:hover { background: rgba(184, 137, 43, .15); }
.gp-sp.gp-f { color: var(--gp-female); }
.gp-sp.gp-m { color: var(--gp-male); }
.gp-sp-more { display: block; font-size: 11px; color: var(--gp-muted); height: 20px; line-height: 20px; padding: 0 2px; }
.gp-node-toggle { position: absolute; left: 50%; bottom: -13px; transform: translateX(-50%); min-width: 26px; height: 22px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--gp-gold); background: #fff; color: var(--gp-accent); font-size: 12px; font-weight: 700; cursor: pointer; line-height: 20px; z-index: 2; }
.gp-node-toggle:hover { background: var(--gp-gold); color: #fff; }
.gp-orient-h .gp-node-toggle { left: auto; right: -14px; bottom: auto; top: 50%; transform: translateY(-50%); }

.gp-tree-panel { position: absolute; z-index: 6; top: 58px; right: 10px; bottom: 10px; width: 330px; max-width: calc(100% - 20px); overflow: auto; background: #fff; border: 1px solid var(--gp-line); border-radius: var(--gp-radius); box-shadow: 0 10px 30px rgba(60, 40, 10, .2); padding: 16px; box-sizing: border-box; user-select: text; -webkit-user-select: text; }
.gp-tree-panel[hidden] { display: none; }
.gp-panel-close { position: absolute; right: 8px; top: 6px; border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--gp-muted); }
.gp-panel-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; padding-right: 20px; }
.gp-panel-head .gp-node-av { flex-basis: 64px; width: 64px; height: 64px; font-size: 26px; }
.gp-panel-head h3 { margin: 0; font-size: 18px; line-height: 1.3; color: var(--gp-accent); }
.gp-panel-years { color: var(--gp-muted); font-size: 13px; }
.gp-panel-bio { font-size: 13px; line-height: 1.55; color: var(--gp-ink); border-top: 1px solid var(--gp-line); padding-top: 8px; }
.gp-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 640px) {
	.gp-tree { height: 82vh; }
	.gp-tree-panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: 60%; border-radius: 14px 14px 0 0; }
	.gp-tree-hint { display: none; }
	.gp-tree-search { max-width: none; flex-basis: 100%; }
}

/* ---------- Bảng thông tin ---------- */
.gp-info { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0; }
.gp-info th, .gp-info td { text-align: left; vertical-align: top; padding: 5px 6px; border-bottom: 1px solid #efe6d4; }
.gp-info th { width: 38%; font-weight: 600; color: var(--gp-muted); }
.gp-info a { color: var(--gp-accent); }

/* ---------- Thẻ thành viên ---------- */
.gp-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.gp-cards-sm { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.gp-card { display: flex; gap: 12px; align-items: flex-start; background: var(--gp-card); border: 1px solid var(--gp-line); border-left: 4px solid var(--gp-gold); border-radius: 8px; padding: 10px 12px; margin: 0; }
.gp-card.gp-m { border-left-color: var(--gp-male); }
.gp-card.gp-f { border-left-color: var(--gp-female); }
.gp-card.gp-dead { background: var(--gp-dead-bg); }
.gp-card[hidden] { display: none; }
.gp-card-photo { text-decoration: none !important; flex: 0 0 auto; }
.gp-card-photo img, .gp-initial { border-radius: 50%; object-fit: cover; display: block; }
.gp-initial { display: flex; align-items: center; justify-content: center; background: #efe3cc; color: var(--gp-accent); font-weight: 700; font-size: 1.2em; }
.gp-m .gp-initial { background: #e3ebf3; color: var(--gp-male); }
.gp-f .gp-initial { background: #f5e3ea; color: var(--gp-female); }
.gp-card-body { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; line-height: 1.45; }
.gp-card-name { font-weight: 700; color: var(--gp-ink) !important; text-decoration: none !important; font-size: 15px; }
.gp-card-name:hover { color: var(--gp-accent) !important; }
.gp-card-years { color: var(--gp-muted); }
.gp-card-meta { color: var(--gp-ink); opacity: .85; }
.gp-card-tree { font-size: 12.5px; color: var(--gp-accent) !important; margin-top: 2px; }
.gp-list-tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.gp-list-search { flex: 1 1 260px; padding: 10px 14px; border: 1px solid var(--gp-line); border-radius: 999px; font: inherit; }
.gp-list-branch select { padding: 9px 12px; border: 1px solid var(--gp-line); border-radius: 999px; font: inherit; background: #fff; }
.gp-gen { margin-bottom: 26px; }
.gp-gen[hidden] { display: none; }
.gp-gen-title { font-size: 1.15em; color: var(--gp-accent); border-bottom: 2px solid var(--gp-gold); padding-bottom: 4px; margin: 0 0 12px; }
.gp-gen-title span { font-size: .8em; color: var(--gp-muted); font-weight: 400; }

/* ---------- Hồ sơ ---------- */
.gp-profile-head { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; margin-bottom: 24px; }
.gp-profile-img { width: 100%; height: auto; border-radius: var(--gp-radius); border: 6px solid #fff; box-shadow: 0 0 0 1px var(--gp-line), 0 6px 18px rgba(60, 40, 10, .15); display: block; }
.gp-profile-noimg { aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; background: var(--gp-paper); }
.gp-profile-noimg .gp-initial { font-size: 64px; }
.gp-profile-years { font-size: 1.1em; color: var(--gp-muted); margin-bottom: 8px; }
.gp-profile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.gp-family { display: grid; gap: 18px; margin: 24px 0; }
.gp-family h4 { margin: 0 0 8px; color: var(--gp-accent); font-size: 1em; text-transform: uppercase; letter-spacing: .04em; }
.gp-bio h3 { color: var(--gp-accent); border-bottom: 2px solid var(--gp-gold); padding-bottom: 4px; }
@media (max-width: 640px) { .gp-profile-head { grid-template-columns: 1fr; } .gp-profile-img { max-width: 220px; } }

/* ---------- Bảng, thống kê ---------- */
.gp-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.gp-table th, .gp-table td { padding: 8px 10px; border-bottom: 1px solid var(--gp-line); text-align: left; }
.gp-table thead th { background: var(--gp-paper); color: var(--gp-accent); font-weight: 700; }
.gp-table tr.gp-soon td { background: #fff6e0; }
.gp-table small { color: var(--gp-muted); }
.gp-table .gp-num { text-align: right; white-space: nowrap; }
.gp-today { color: var(--gp-accent); }
.gp-lunar-today { color: var(--gp-muted); }
.gp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.gp-stat { background: var(--gp-card); border: 1px solid var(--gp-line); border-radius: var(--gp-radius); padding: 16px 12px; text-align: center; }
.gp-stat-num { display: block; font-size: 1.9em; font-weight: 700; color: var(--gp-accent); line-height: 1.1; }
.gp-stat-label { display: block; font-size: .9em; color: var(--gp-muted); margin-top: 4px; }
.gp-fund-sum .gp-stat-num { font-size: 1.25em; }
.gp-fund-year { margin-bottom: 8px; }
@media (max-width: 640px) { .gp-table { font-size: 13px; } .gp-table th, .gp-table td { padding: 6px; } }

/* ---------- Biểu mẫu đóng góp ---------- */
.gp-form { max-width: 760px; }
.gp-form label { display: block; font-weight: 600; margin-bottom: 4px; }
.gp-form input[type=text], .gp-form input[type=number], .gp-form select, .gp-form textarea { width: 100%; box-sizing: border-box; padding: 9px 12px; border: 1px solid var(--gp-line); border-radius: 8px; font: inherit; background: #fff; }
.gp-form .gp-row { margin-bottom: 14px; }
.gp-form .gp-row[hidden], .gp-form [data-show][hidden] { display: none; }
.gp-form .gp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .gp-form .gp-cols { grid-template-columns: 1fr; } }
.gp-form .gp-check, .gp-form .gp-radios label, .gp-types label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 6px 14px 0 0; }
.gp-types { border: 1px solid var(--gp-line); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.gp-types legend { font-weight: 700; padding: 0 6px; }
.gp-types label { display: flex; }
.gp-pick { position: relative; }
.gp-pick ul { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--gp-line); border-radius: 8px; list-style: none; margin: 2px 0 0; padding: 4px 0; max-height: 260px; overflow: auto; box-shadow: 0 8px 20px rgba(0, 0, 0, .12); }
.gp-pick li { padding: 6px 12px; cursor: pointer; margin: 0; }
.gp-pick li:hover { background: var(--gp-paper); }
.gp-hp { position: absolute !important; left: -9999px !important; height: 0; overflow: hidden; }
.gp-lunar { white-space: nowrap; }
