:root {
  --bg: #f6f2e9;
  --surface: #fffdf8;
  --surface-2: #f2eadc;
  --ink: #2b241e;
  --muted: #73675d;
  --line: #dfd3c2;
  --red: #8f221e;
  --red-dark: #681713;
  --gold: #c99a35;
  --gold-soft: #f2dfae;
  --green: #2f6d4f;
  --blue: #2d5874;
  --danger: #a22d2d;
  --shadow: 0 14px 40px rgba(73, 43, 17, .10);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at top right, #fff8df 0, transparent 30%), var(--bg); font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.55; }
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 74px; display: flex; align-items: center; gap: 24px; padding: 10px max(24px, calc((100vw - 1240px)/2)); background: rgba(255,253,248,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 260px; color: var(--ink); }
.brand-mark, .seal { display: grid; place-items: center; color: #f7e6b4; background: linear-gradient(145deg, var(--red), var(--red-dark)); border: 2px solid var(--gold); box-shadow: inset 0 0 0 3px rgba(255,255,255,.15); }
.brand-mark { width: 48px; height: 48px; border-radius: 50%; font-size: 26px; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 12px; }
.move-relative {color: #7a4a00;background: #fff5d7;border-color: #dec27a;width: 28px;height: 28px;border-radius: 50px;}
.main-nav { margin-left: auto; display: flex; align-items: center; gap: 1px; flex-wrap: wrap;text-transform: capitalize; }
.main-nav a, .link-button { padding: 9px 10px; border-radius: 10px; color: #8f221e; background: none; border: 1px solid #fff255; }
.main-nav a:hover, .link-button:hover { background: var(--surface-2); }
.main-nav .nav-primary { color: white; background: var(--red); }
.logout-form { margin: 0; }
.page-shell { width: min(1240px, calc(100% - 32px)); min-height: calc(100vh - 150px); margin: 0 auto; padding: 34px 0 58px; }
.footer { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0 32px; border-top: 1px solid var(--line); color: var(--muted); display: flex; justify-content: space-between; gap: 20px; font-size: 13px; }
.hero { display: grid; grid-template-columns: 1.35fr .75fr; gap: 38px; align-items: center; padding: 44px 0 50px; }
.hero h1 { max-width: 780px; margin: 12px 0 20px; font-family: serif; font-size: clamp(40px, 6vw, 72px); line-height: 1.03; letter-spacing: -.035em; }
.hero p { max-width: 760px; color: var(--muted); font-size: 19px; }
.hero-actions, .modal-actions, .response-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.heritage-card, .card, .stat-card, .auth-card, .suggestion-card { background: rgba(255,253,248,.95); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.heritage-card { padding: 28px; }
.seal { width: 76px; height: 76px; border-radius: 50%; font-size: 40px; margin-bottom: 20px; }
.heritage-card h2, .card h2 { margin-top: 0; font-family: serif; }
.evidence-list, .clean-list { list-style: none; padding: 0; margin: 0; }
.evidence-list li { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.evidence-list li:last-child { border-bottom: 0; }
.evidence-list strong, .evidence-list span { display: block; }
.evidence-list span { color: var(--muted); font-size: 14px; }
.feature-grid, .stat-grid, .admin-menu, .suggestion-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card { padding: 24px; }
.card p { color: var(--muted); }
.page-heading { margin-bottom: 26px; }
.page-heading h1 { margin: 6px 0 8px; font-family: serif; font-size: clamp(32px, 4vw, 48px); line-height: 1.08; }
.page-heading p { max-width: 850px; margin: 0; color: var(--muted); }
.split-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.eyebrow { color: var(--red); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.content-narrow { width: min(880px, 100%); margin: 0 auto; }
.auth-wrap { min-height: 68vh; display: grid; place-items: center; }
.auth-card { width: min(440px, 100%); padding: 34px; }
.auth-card h1 { font-family: serif; font-size: 40px; margin: 5px 0 18px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 18px; font-size: 14px; }
.form-stack { display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.form-grid h2 { margin-bottom: 0; }
.span-2 { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 14px; }
label small, td small { display: block; color: var(--muted); font-weight: 400; }
input, select, textarea { width: 100%; border: 1px solid #cfc0ad; border-radius: 11px; padding: 11px 12px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,154,53,.18); }
textarea { resize: vertical; }
.check-row { grid-template-columns: 22px 1fr; align-items: start; font-weight: 500; }
.check-row input { width: 18px; height: 18px; margin-top: 3px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 43px; padding: 10px 17px; border-radius: 11px; border: 1px solid transparent; font-weight: 800; }
.button.primary { color: white; background: linear-gradient(135deg, var(--red), var(--red-dark)); }
.button.ghost { color: var(--red); background: var(--surface); border-color: var(--line); }
.button.danger { color: white; background: var(--danger); }
button.icon-button.add-relative {background: #ffedbb;color: #0070cd;}
.button.small { min-height: 34px; padding: 7px 11px; font-size: 13px; }
.button.full { width: 100%; }
.alert { margin-bottom: 20px; padding: 13px 16px; border-radius: 12px; border: 1px solid; }
.alert.success { color: #194d34; background: #e9f7ef; border-color: #b6dec7; }
.alert.error, .field-error { color: #7b1e1e; background: #fff0ef; border-color: #ecc0bd; }
.field-error { margin-top: 2px; padding: 5px 8px; border-radius: 7px; font-size: 12px; font-weight: 600; }
.privacy-note { padding: 13px 15px; color: #5c4a2f; background: #fff6dc; border: 1px solid #ead49a; border-radius: 11px; }
.stat-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; }
.stat-card { padding: 20px; display: grid; gap: 3px; }
.stat-card strong { font-family: serif; font-size: 34px; color: var(--red); }
.stat-card span { color: var(--muted); }
.stat-card a { margin-top: 8px; font-weight: 700; }
.two-column, .compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; margin-top: 20px; }
.clean-list li { position: relative; padding: 8px 0 8px 22px; }
.clean-list li::before { content: "◆"; position: absolute; left: 0; top: 9px; color: var(--gold); font-size: 10px; }
.clean-list.numbered { counter-reset: item; }
.clean-list.numbered li { counter-increment: item; padding-left: 32px; }
.clean-list.numbered li::before { content: counter(item); width: 22px; height: 22px; display: grid; place-items: center; color: white; background: var(--red); border-radius: 50%; font-size: 11px; }
.badge, .mini-badge, .evidence { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 800; white-space: nowrap; background: var(--surface-2); }
.badge.verified, .badge.approved, .badge.finalized { color: #195238; background: #dff2e6; }
.badge.pending, .badge.reviewing, .badge.admin_review { color: #725115; background: #fff0c8; }
.badge.branch_head { color: #69400a; background: #f4dda3; }
.badge.rejected { color: #7b1e1e; background: #fae1df; }
.evidence.historical_confirmed { color: #174d34; background: #dff2e6; }
.evidence.genealogy_tradition { color: #6e4a0f; background: #f5e4b8; }
.evidence.hypothesis { color: #27506a; background: #dfedf5; }
.evidence.unverified { color: #6f6258; background: #eee9e2; }
.danger-zone { margin-top: 28px; padding-top: 20px; border-top: 1px solid #efc4c4; }
.danger-text { color: var(--danger); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.tree-toolbar { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 16px; }
.tree-toolbar-actions { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.tree-print-controls { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.72); }
.tree-print-controls label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 800; }
.tree-print-controls input { width: 92px; min-height: 38px; padding: 7px 9px; }
.tree-print-controls .button { min-height: 38px; }
.tree-export-button.is-busy, .tree-export-button:disabled { opacity: .62; cursor: wait; }
.tree-print-error { flex-basis: 100%; min-height: 0; margin: 0; font-size: 12px; }
.tree-print-error.export-success { color: var(--green); }
.tree-toolbar-note { display: grid; justify-items: end; gap: 7px; }
.tree-legend { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.legend { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 800; }
.legend.ancestor { background: #fff2c8; border-color: #d9b85f; }
.legend.female-branch { background: #eaf6ff; border-color: #a9cde5; }
.legend.affinal { background: #f3e9ff; border-color: #c8b0df; }
.tree-browser { min-height: 260px; padding: 22px; background: linear-gradient(90deg, rgba(201,154,53,.07) 1px, transparent 1px), var(--surface); background-size: 28px 28px; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.tree-expand-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 20px; }
.tree-expand-controls .button[disabled] { opacity: .55; cursor: not-allowed; }
.tree-loading, .empty-state { padding: 30px; text-align: center; color: var(--muted); }
.tree-node { min-width: 39px; width: max-content; max-width: none; }
.tree-node-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; }
.tree-node.is-leaf > .tree-node-row { margin-left: 0; }
.tree-node.is-leaf > .tree-node-children { display: none !important; border-left: 0; margin-left: 0; padding-left: 0; }
.folder-toggle, .icon-button { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--red); font-weight: 900; }
.person-chip { min-width: 0px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 4px 14px rgba(60,35,15,.06); }
.person-chip.root { border-color: var(--gold); background: #fff8e7; }
.person-chip.ancestor { border-color: #d9b85f; background: #fff2c8; }
.person-chip.female-branch { border-color: #a9cde5; background: #eaf6ff; }
.person-chip.affinal { border-color: #c8b0df; background: #f3e9ff; }
.person-chip strong, .person-chip small { display: block; }
.person-chip small { color: var(--muted); }
.person-chip .evidence { margin-left: auto; }
.gender-icon { width: 28px; height: 28px; display: grid; place-items: center; color: white; background: var(--red); border-radius: 50%; }
.tree-node-children { margin-left: 48px; padding-left: 16px; border-left: 1px dashed #cbb897; width: max-content; min-width: calc(100% - 48px); }
.relation-group { width: max-content; min-width: 100%; }
.relation-group h4 { margin: 8px 0 5px; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.relation-items { display: flex; flex-flow: row nowrap; align-items: flex-start; gap: 12px; width: max-content; min-width: 100%; padding: 2px 2px 10px; }
.relation-items > .tree-node { flex: 0 0 auto; }
.relation-siblings .relation-items { border-bottom: 1px dashed rgba(201,154,53,.35); }
.tree-print-report { display: none; color: #2d241c; background: #fff; }
.tree-print-report-head { display: flex; align-items: center; gap: 16px; padding-bottom: 14px; border-bottom: 2px solid #9f1d20; }
.tree-print-report-head h1 { margin: 2px 0 4px; font-family: serif; font-size: 26px; }
.tree-print-report-head p { margin: 0; }
.tree-print-seal { flex: 0 0 48px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: #9f1d20; color: #f8df99; font-size: 27px; font-weight: 800; }
.tree-print-generations { display: grid; gap: 14px; margin-top: 16px; }
.tree-print-generation { break-inside: avoid; page-break-inside: avoid; }
.tree-print-generation-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 10px; border-left: 5px solid #9f1d20; background: #f7f0e4; }
.tree-print-generation-title span { color: #695d52; font-size: 11px; }
.tree-print-people { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; padding: 9px 0 2px; }
.tree-print-person { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 9px; border: 1px solid #d8cfc4; border-radius: 9px; background: #fff; break-inside: avoid; page-break-inside: avoid; }
.tree-print-person.root { border-color: #c99a35; background: #fff8e7; }
.tree-print-person.ancestor { border-color: #d9b85f; background: #fff2c8; }
.tree-print-person.female-branch { border-color: #a9cde5; background: #eaf6ff; }
.tree-print-person.affinal { border-color: #c8b0df; background: #f3e9ff; }
.tree-print-gender { flex: 0 0 24px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #9f1d20; color: #fff; font-weight: 800; }
.tree-print-person-main { min-width: 0; flex: 1; }
.tree-print-person-main strong, .tree-print-person-main small { display: block; }
.tree-print-person-main strong { overflow-wrap: anywhere; }
.tree-print-person-main small { margin-top: 2px; color: #695d52; font-size: 10px; line-height: 1.35; overflow-wrap: anywhere; }
.tree-print-evidence { flex: 0 0 auto; max-width: 105px; color: #695d52; font-size: 9px; text-align: right; }
.tree-print-report-foot { display: flex; justify-content: space-between; gap: 14px; margin-top: 18px; padding-top: 9px; border-top: 1px solid #d8cfc4; color: #695d52; font-size: 10px; }
.modal { width: min(760px, calc(100% - 24px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 30px 90px rgba(30,20,10,.3); }
.modal::backdrop { background: rgba(31,24,19,.55); backdrop-filter: blur(3px); }
.modal form { padding: 25px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; }
.modal-head h2 { margin: 4px 0; }
.modal-actions { justify-content: flex-end; }
.table-card { margin-top: 20px; padding: 0; overflow: hidden; }
.table-card h2 { padding: 22px 24px 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 13px 16px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
th { color: var(--muted); background: #faf5eb; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.mini-badge { margin-left: 7px; color: var(--red); background: var(--gold-soft); }
.row-actions { display: flex; align-items: center; gap: 4px; }
.suggestion-grid { grid-template-columns: repeat(2, 1fr); }
.suggestion-card { display: flex; gap: 16px; padding: 20px; }
.score-ring { flex: 0 0 68px; height: 68px; display: grid; place-items: center; align-content: center; border: 5px solid var(--gold-soft); outline: 1px solid var(--gold); border-radius: 50%; }
.score-ring strong { font-size: 21px; color: var(--red); line-height: 1; }
.score-ring span { font-size: 10px; color: var(--muted); }
.suggestion-body { flex: 1; }
.suggestion-body h3 { margin: 0 0 4px; }
.suggestion-body p { margin: 0 0 8px; color: var(--muted); }
.reason-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.reason-row span { padding: 3px 8px; border-radius: 999px; background: var(--surface-2); font-size: 11px; }
.inline-request { display: flex; gap: 8px; }
.inline-request input { min-width: 0; }
.preview-card h3 { margin-bottom: 14px; }
.preview-card h3 small { color: var(--muted); font-weight: 400; }
.card-head { display: flex; justify-content: space-between; gap: 12px; }
.preview-rel { display: grid; grid-template-columns: 100px 1fr; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.preview-rel span { color: var(--muted); }
.chat-log { max-height: 420px; overflow: auto; display: grid; gap: 10px; padding: 4px; }
.chat-message { max-width: 88%; padding: 10px 12px; border-radius: 13px 13px 13px 3px; background: var(--surface-2); }
.chat-message.mine { margin-left: auto; border-radius: 13px 13px 3px 13px; background: #f5e4b8; }
.chat-message p { margin: 4px 0; color: var(--ink); }
.chat-message small { color: var(--muted); }
.chat-form { display: grid; gap: 8px; margin-top: 14px; }
.admin-menu { margin-top: 20px; }
.admin-menu a { color: var(--ink); }
.admin-menu a:hover { transform: translateY(-2px); transition: .18s ease; }
.compact-form { display: flex; gap: 7px; align-items: center; min-width: 430px; }
.compact-form.vertical { min-width: 220px; flex-wrap: wrap; }
.compact-form.vertical input { flex-basis: 100%; }

.admin-user-actions { display: grid; gap: 10px; align-items: start; }
.delete-pending-user-form { margin: 0; padding-top: 8px; border-top: 1px dashed #e2b8b8; }
.delete-pending-user-form .button { width: 100%; }
code { font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.error-page { min-height: 100vh; display: grid; place-items: center; align-content: center; text-align: center; gap: 12px; padding: 24px; }
.error-page .seal { margin: 0 auto; }
.error-page h1 { font-family: serif; font-size: 40px; margin: 8px 0 0; }
@media (max-width: 980px) {
  .topbar { position: static; flex-wrap: wrap; }
  .brand { min-width: auto; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .hero, .two-column, .compare-grid { grid-template-columns: 1fr; }
  .feature-grid, .admin-menu { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .suggestion-grid { grid-template-columns: 1fr; }
  .main-nav a {background: #fff7dd;text-align: center;border-radius: 0;}
}
@media (max-width: 640px) {
  .page-shell { width: min(100% - 20px, 1240px); padding-top: 22px; }
  .topbar { padding: 10px; gap: 8px; }
  .brand small { display: none; }
  .hero { padding-top: 20px; }
  .feature-grid, .stat-grid, .admin-menu, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .split-heading, .tree-toolbar, .footer { align-items: stretch; flex-direction: column; }
  .tree-toolbar-actions { align-items: stretch; flex-direction: column; }
  .tree-print-controls { align-items: stretch; }
  .tree-print-controls label { flex: 1 1 120px; }
  .tree-print-controls input { width: 100%; }
  .tree-toolbar-note { justify-items: start; }
  .tree-legend { justify-content: flex-start; }
  .person-chip { min-width: 260px; }
  .tree-node { min-width: 350px; }
  .inline-request { flex-direction: column; }
  .auth-card, .card { padding: 20px; }
  .main-nav a {background: #fff7dd;text-align: center;border-radius: 0;}
}

/* Heritage and provenance module */
.search-bar { margin-bottom: 22px; }
.search-row { display: flex; gap: 10px; margin-top: 7px; }
.search-row input { flex: 1; }
.heritage-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.heritage-card { display: flex; flex-direction: column; gap: 10px; }
.heritage-card h2 { margin: 0; }
.heritage-card > .button { margin-top: auto; }
.heritage-meta, .detail-list { display: grid; gap: 10px; margin: 8px 0 18px; }
.heritage-meta div, .detail-list div { padding-top: 8px; border-top: 1px dashed var(--line); }
.heritage-meta dt, .detail-list dt { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.heritage-meta dd, .detail-list dd { margin: 3px 0 0; }
.heritage-form-section { margin-top: 24px; }
.page-heading.compact { margin-bottom: 18px; }
.page-heading.compact h2 { margin: 5px 0 8px; }
.form-actions, .button-row, .section-head { display: flex; gap: 10px; align-items: center; }
.section-head { justify-content: space-between; padding: 22px 24px 0; }
.section-head h2 { margin: 4px 0 0; }
.member-list, .revision-list { display: grid; gap: 8px; padding: 0; margin: 0 0 18px; list-style: none; }
.member-list li, .revision-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px dashed var(--line); }
.member-list small, .revision-list small { display: block; color: var(--muted); }
.member-identity { min-width: 0; }
.member-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.member-actions form { margin: 0; }
.section-head.no-pad { padding: 0 0 18px; }
.heritage-form-section .section-head.no-pad h2 { padding: 0; }
.attestation-form { min-width: 660px; display: grid; grid-template-columns: 110px 150px 1fr auto; gap: 7px; }
.badge.review { color: #725115; background: #fff0c8; }
@media (max-width: 980px) {
  .heritage-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 640px) {
  .heritage-grid { grid-template-columns: 1fr; }
  .search-row, .button-row, .section-head { align-items: stretch; flex-direction: column; }
  .member-list li { align-items: stretch; flex-direction: column; }
  .member-actions { justify-content: flex-start; }
}


@media print {
  html, body { background: #fff !important; }
  body.printing-tree-report .topbar,
  body.printing-tree-report .footer,
  body.printing-tree-report .page-shell > *:not(.tree-print-report) { display: none !important; }
  body.printing-tree-report .page-shell { width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
  body.printing-tree-report .tree-print-report { display: block !important; }
  body.printing-tree-report .tree-print-people { grid-template-columns: repeat(3, minmax(0,1fr)); }
  body.printing-tree-report .tree-print-person,
  body.printing-tree-report .tree-print-generation-title,
  body.printing-tree-report .tree-print-seal { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.printing-tree-report a { color: inherit; text-decoration: none; }
}

/* 1.1.7 — danh sách nhân vật, số điện thoại, phân trang và biên tập tư liệu */
.person-list-head { align-items: end; }
.person-search { min-width: min(360px, 100%); }
.person-search input { min-width: 280px; }
.person-list-frame { max-height: 720px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.person-list-frame thead th { position: sticky; top: 0; z-index: 2; background: #fffdf8; }
.person-list-frame tr[hidden] { display: none !important; }
.person-name, .person-chip strong { text-transform: capitalize; }
.phone-link { white-space: nowrap; font-weight: 700; }
.person-list-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 0 10px 5px 10px;}
.pagination { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pagination-button { min-width: 34px; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; }
.pagination-button.current { background: var(--red); border-color: var(--red); color: #fff; font-weight: 800; }
.pagination-button:disabled { opacity: .45; cursor: not-allowed; }
.heading-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.alert.warning { background: #fff4cc; border-color: #e6c766; color: #6b5100; }
.inline-editor { position: relative; }
.inline-editor > summary { cursor: pointer; color: var(--red); font-weight: 700; list-style: none; }
.inline-editor > summary::-webkit-details-marker { display: none; }
.inline-editor[open] { min-width: min(720px, 78vw); }
.source-edit-form { margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fffdf8; box-shadow: 0 12px 35px rgba(50,35,20,.12); }
.privacy-note { display: inline-block; max-width: 100%; }

@media (max-width: 720px) {
  .person-search, .person-search input { min-width: 100%; width: 100%; }
  .person-list-frame { max-height: 620px; }
  .person-list-footer { align-items: flex-start; flex-direction: column; }
  .inline-editor[open] { min-width: 86vw; }
}


/* 1.1.8 — nút lá, mở/thu gọn toàn bộ nhánh và chuyển quản lý chi họ */

.branch-transfer-box { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fffaf0; }
.branch-transfer-box h3 { margin: 0 0 6px; font-size: 16px; }
.branch-transfer-box .form-stack { margin-top: 10px; }

/* 1.1.9 — thông báo chi họ, chia sẻ cây có thời hạn, quyền riêng tư số điện thoại và tin nhắn riêng */
.privacy-toggle { grid-column: span 2; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fffaf0; }
.privacy-toggle > span:first-child { font-weight: 800; color: var(--ink); }
.check-line { display: flex; align-items: flex-start; gap: 9px; margin-top: 7px; color: var(--muted); font-size: 13px; font-weight: 600; }
.check-line input { width: auto; min-height: auto; margin-top: 2px; }

.branch-announcement-zone { margin: 0 0 20px; padding: 20px; border: 2px solid #d9b85f; border-radius: var(--radius); background: linear-gradient(135deg,#fff8d8,#fffdf7 65%); box-shadow: 0 10px 28px rgba(92,65,10,.1); }
.branch-announcement-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 14px; }
.branch-announcement-head h2 { margin: 2px 0 4px; color: #6f3e09; }
.branch-announcement-head p { margin: 0; color: #755c2f; }
.announcement-kicker { display: inline-flex; padding: 3px 9px; border-radius: 999px; background: #8f251f; color: #fff; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.announcement-empty { padding: 18px; border: 1px dashed #d7bc72; border-radius: 12px; color: #755c2f; text-align: center; background: rgba(255,255,255,.55); }
.announcement-list { display: grid; gap: 12px; }
.branch-announcement { padding: 16px; border: 1px solid #dfc981; border-left: 5px solid #a52e27; border-radius: 12px; background: rgba(255,255,255,.9); }
.announcement-title-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.announcement-title-row h3 { margin: 0; color: #6f211d; }
.announcement-content { margin-top: 10px; line-height: 1.65; }
.announcement-content p:first-child { margin-top: 0; }
.announcement-content p:last-child { margin-bottom: 0; }
.announcement-content a { color: var(--red); text-decoration: underline; }
.branch-announcement footer { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px dashed #dfc981; color: var(--muted); font-size: 12px; }
.announcement-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.announcement-dialog { width: min(760px, calc(100vw - 28px)); }
.simple-html-editor { display: grid; gap: 8px; }
.html-toolbar { display: flex; gap: 6px; flex-wrap: wrap; padding: 7px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: #f7f2e9; }
.html-toolbar button { min-width: 34px; min-height: 32px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); cursor: pointer; }
.simple-html-editor textarea { border-radius: 0 0 10px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.editor-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.editor-meta .over-limit { color: var(--danger); }

.member-phone-note { max-width: none; margin-top: 8px; }
.member-community-grid { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(0,.85fr); gap: 20px; margin: 20px 0; }
.tree-share-form { margin-top: 12px; }
.tree-share-form select[multiple] { min-height: 130px; }
.share-list { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.share-list h3 { margin-top: 0; }
.share-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.share-row > div:first-child { display: grid; gap: 3px; }
.share-row.expired { opacity: .68; }
.share-editor > summary { cursor: pointer; color: var(--red); font-weight: 800; }
.share-editor[open] { grid-column: 1 / -1; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fffaf3; }
.share-editor .compact-form { display: grid; grid-template-columns: repeat(4,minmax(110px,1fr)); gap: 10px; align-items: end; }

.branch-message-form { margin-top: 12px; }
.branch-message-log { display: grid; gap: 9px; max-height: 520px; overflow: auto; margin-top: 18px; padding-right: 4px; }
.branch-private-message { max-width: 92%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: #f7f3ec; }
.branch-private-message.mine { margin-left: auto; background: #eef6ff; border-color: #bad2e7; }
.branch-private-message.incoming { margin-right: auto; background: #fff8e8; border-color: #e5ce94; }
.branch-private-message header { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.branch-private-message p { margin: 7px 0 4px; white-space: normal; overflow-wrap: anywhere; }
.branch-private-message small { color: var(--muted); }

.tree-share-notice { margin: -6px 0 15px; padding: 10px 13px; border: 1px solid #a9cde5; border-radius: 10px; background: #eef7ff; color: #274b66; }

@media (max-width: 900px) {
  .member-community-grid { grid-template-columns: 1fr; }
  .share-editor .compact-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .branch-announcement-head { flex-direction: column; }
  .share-row { grid-template-columns: 1fr; align-items: stretch; }
  .share-editor[open] { grid-column: auto; }
  .share-editor .compact-form { grid-template-columns: 1fr; }
  .privacy-toggle { grid-column: auto; }
}

/* 1.1.10 — chia sẻ cây toàn chi họ và trung tâm thông báo */
.topbar-account-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.notification-bell { position: relative; min-width: 48px; height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 5px 8px; border: 1px solid #d3ac42; border-radius: 12px; background: #ffe79a; color: #4f3810; box-shadow: 0 4px 12px rgba(108,76,8,.12); text-decoration: none; }
.notification-bell:hover { transform: translateY(-1px); background: #ffdc69; }
.notification-bell.has-unread { border-color: #a52720; background: #ffd45f; box-shadow: 0 0 0 3px rgba(165,39,32,.09), 0 6px 16px rgba(108,76,8,.16); }
.notification-bell-icon { font-size: 19px; line-height: 1; }
.notification-bell-count { min-width: 20px; height: 20px; display: inline-grid; place-items: center; padding: 0 5px; border-radius: 999px; background: #fff9df; color: #6b4c00; border: 1px solid rgba(107,76,0,.25); font-size: 11px; line-height: 1; font-weight: 900; }
.notification-bell.has-unread .notification-bell-count { background: #a52720; border-color: #a52720; color: #fff; }

.branch-wide-tree-share { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 16px; margin: 14px 0 18px; padding: 16px; border: 1px solid #d6bd76; border-radius: 13px; background: linear-gradient(135deg,#fff9df,#fffdf8); }
.branch-wide-tree-share.active { border-color: #7eb78a; background: linear-gradient(135deg,#ecf9ee,#fbfffb); }
.branch-wide-tree-share h3 { margin: 3px 0 5px; }
.branch-wide-tree-share p { margin: 0; color: var(--muted); }
.branch-wide-tree-share form { margin: 0; }

.notification-page-heading { margin-bottom: 15px; }
.notification-summary-strip { display: inline-flex; align-items: baseline; gap: 9px; margin-bottom: 16px; padding: 10px 14px; border: 1px solid #d6bd76; border-radius: 999px; background: #fff6cf; color: #674900; }
.notification-summary-strip strong { font-size: 21px; color: #9f1d20; }
.notification-list { display: grid; gap: 10px; }
.notification-item { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 13px; align-items: start; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 5px 18px rgba(54,38,20,.06); }
.notification-item.unread { border-color: #d4ad43; border-left: 5px solid #a52720; background: #fffdf4; }
.notification-item.read { opacity: .86; background: #faf8f3; }
.notification-item.resolved { border-style: dashed; }
.notification-symbol { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #eee8de; color: #7c7268; font-size: 13px; font-weight: 900; }
.notification-item.unread .notification-symbol { background: #a52720; color: #fff; }
.notification-main { min-width: 0; }
.notification-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notification-title-row h2 { margin: 0; font-size: 17px; }
.notification-main > p { margin: 7px 0; color: var(--ink); line-height: 1.55; }
.notification-new-badge { display: inline-flex; padding: 2px 7px; border-radius: 999px; background: #a52720; color: #fff; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.notification-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12px; }
.notification-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.notification-actions form { margin: 0; }
.notification-empty { text-align: center; padding: 36px; }
.notification-empty-icon { display: block; font-size: 42px; margin-bottom: 8px; }
.notification-empty h2 { margin: 0 0 6px; }
.notification-empty p { margin: 0; color: var(--muted); }

@media (max-width: 980px) {
  .topbar-account-actions { margin-left: 0; }
}
@media (max-width: 720px) {
  .notification-item { grid-template-columns: 28px minmax(0,1fr); }
  .notification-actions { grid-column: 1 / -1; justify-content: flex-start; padding-left: 41px; }
  .branch-wide-tree-share { grid-template-columns: 1fr; align-items: stretch; }
  .branch-wide-tree-share .button { width: 100%; }
}
@media (max-width: 640px) {
  .topbar-account-actions { width: 100%; justify-content: flex-end; order: 2; }
  .notification-bell { min-width: 50px; }
}

/* 1.1.11 — Người quản lý chi họ duyệt thành viên tham gia chi họ */
.membership-review-form { display: grid; grid-template-columns: minmax(180px,1fr) auto auto; gap: 7px; align-items: center; width: min(100%, 680px); }
.membership-review-form input { min-width: 180px; }
@media (max-width: 760px) {
  .membership-review-form { grid-template-columns: 1fr 1fr; width: 100%; }
  .membership-review-form input { grid-column: 1 / -1; width: 100%; }
}


/* 1.1.12 — chuyển nút và nhánh hậu duệ trong cây của chính chủ sở hữu */
.move-relative { color: #7a4a00; background: #fff5d7; border-color: #dec27a; }
.move-branch-link { color: #7a4a00; }
.move-branch-dialog { width: min(920px, calc(100vw - 28px)); }
.move-context-summary { padding: 13px 15px; border: 1px solid #d8c189; border-radius: 12px; background: #fff9e8; }
.move-context-summary > div { display: grid; gap: 4px; }
.move-context-summary span { color: var(--muted); font-size: 13px; }
.loading-inline { color: var(--muted); }
.move-choice-box,
.move-parent-field { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fffdf9; }
.move-choice-box legend,
.move-parent-field legend { padding: 0 7px; color: #67211d; font-weight: 900; }
.move-choice-box > p { margin: 0 0 10px; }
.move-parent-field { display: grid; gap: 9px; }
.move-check-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 10px; }
.move-person-option { align-items: flex-start; padding: 9px 10px; border: 1px solid #ddd3c2; border-radius: 10px; background: #fff; }
.move-person-option span { display: grid; gap: 2px; }
.move-person-option small { color: var(--muted); font-size: 11px; }
.move-preview-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.move-preview-panel { padding: 15px; border: 2px solid #d4ad43; border-radius: 14px; background: linear-gradient(135deg,#fff9dd,#fffdf8); }
.move-preview-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 12px; }
.move-preview-head span { color: var(--muted); font-size: 12px; }
.move-preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.move-preview-grid article { display: grid; gap: 5px; padding: 12px; border: 1px solid #e0cf9c; border-radius: 11px; background: rgba(255,255,255,.82); }
.move-preview-grid article > span { color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.move-preview-grid small { color: var(--muted); line-height: 1.45; }
.move-preview-facts { margin: 12px 0 0; }
.move-warning-list { margin-top: 12px; padding: 11px 13px; border: 1px solid #df9c73; border-radius: 10px; background: #fff0e5; color: #713418; }
.move-warning-list ul { margin: 7px 0 0 18px; padding: 0; }
.move-safe-note { margin-top: 12px; padding: 9px 11px; border-radius: 9px; background: #edf8ef; color: #286237; }
.tree-move-undo { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 12px 0 18px; }
.tree-move-undo > div { display: grid; gap: 4px; }
.tree-move-undo span { font-size: 13px; }
.tree-move-undo form { margin: 0; }
@media (max-width: 760px) {
  .move-check-list,
  .move-preview-grid { grid-template-columns: 1fr; }
  .tree-move-undo { align-items: stretch; flex-direction: column; }
  .tree-move-undo .button { width: 100%; }
}

/* 1.1.13 — nhận diện tùy biến, popup hướng dẫn và thiết lập tối cao */
.brand-mark-image { overflow: hidden; padding: 0; background: #fff; }
.brand-mark-image img { width: 100%; height: 100%; display: block; object-fit: contain; }
.brand-mark-text { overflow: hidden; padding: 3px; font-size: clamp(15px, 2vw, 25px); font-weight: 900; text-align: center; overflow-wrap: anywhere; }
.support-help-button { width: 42px; height: 42px; display: inline-grid; place-items: center; border: 1px solid #d3ac42; border-radius: 12px; background: #fff7d8; color: #6b4c00; font-size: 22px; font-weight: 950; box-shadow: 0 4px 12px rgba(108,76,8,.08); }
.support-help-button:hover { transform: translateY(-1px); background: #ffe79a; }
.support-help-dialog { width: min(860px, calc(100vw - 28px)); max-height: min(86vh, 900px); padding: 0; overflow: hidden; }
.support-help-shell { display: grid; grid-template-rows: auto minmax(0,1fr) auto; max-height: min(86vh, 900px); padding: 24px; }
.support-help-shell .modal-head { margin-bottom: 12px; }
.support-help-content { min-height: 120px; overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.support-help-content > :first-child { margin-top: 0; }
.support-help-content > :last-child { margin-bottom: 0; }
.support-help-content img { max-width: 100%; height: auto; border-radius: 10px; }
.support-help-content table { width: 100%; border-collapse: collapse; }
.support-help-content th, .support-help-content td { padding: 8px 10px; border: 1px solid var(--line); vertical-align: top; }
.support-help-content pre { max-width: 100%; overflow: auto; padding: 12px; border-radius: 10px; background: #f4f0e9; }
.support-help-content blockquote { margin-left: 0; padding: 10px 14px; border-left: 4px solid var(--gold); background: #fff8e7; }
.settings-workspace { display: grid; gap: 20px; }
.settings-section { padding: 28px; }
.settings-section-head { display: flex; justify-content: space-between; gap: 24px; align-items: start; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.settings-section-head h2 { margin: 4px 0 0; }
.settings-section-head p { max-width: 620px; margin: 0; }
.branding-settings-grid { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 24px; align-items: start; }
.logo-preview-card { min-height: 200px; display: grid; place-items: center; align-content: center; gap: 12px; padding: 20px; border: 1px dashed #c9a44a; border-radius: 16px; background: #fff9e8; text-align: center; }
.logo-preview-card img { max-width: 160px; max-height: 130px; object-fit: contain; }
.logo-preview-card > span { width: 92px; height: 92px; display: grid; place-items: center; padding: 7px; border-radius: 50%; color: #f7e6b4; background: linear-gradient(145deg,var(--red),var(--red-dark)); border: 3px solid var(--gold); font-size: 34px; font-weight: 900; overflow-wrap: anywhere; }
.logo-preview-card small { color: var(--muted); }
.html-editor { display: grid; gap: 10px; }
.html-editor-toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 9px; border: 1px solid var(--line); border-radius: 11px; background: #f8f4ed; }
.html-editor-toolbar [data-word-counter] { margin-left: auto; }
.html-editor-toolbar [data-word-counter].over-limit { color: var(--danger); font-weight: 900; }
.settings-save-bar { position: sticky; bottom: 12px; z-index: 8; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 15px 18px; border: 1px solid #d2aa42; border-radius: 14px; background: rgba(255,249,224,.96); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.settings-save-bar span { color: var(--muted); font-size: 13px; }
@media (max-width: 760px) {
  .branding-settings-grid { grid-template-columns: 1fr; }
  .logo-preview-card { min-height: 160px; }
  .settings-section-head { flex-direction: column; gap: 8px; }
  .settings-save-bar { align-items: stretch; flex-direction: column; }
  .settings-save-bar .button { width: 100%; }
  .support-help-shell { padding: 16px; }
}

/* 1.1.15 — tìm nhánh chia sẻ, nhóm thiết lập, sao lưu cây và bộ lọc nhật ký */
.shared-tree-picker { position: relative; width: min(360px, 100%); }
.shared-tree-picker-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.shared-tree-picker-toggle { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); font: inherit; font-weight: 800; text-align: left; cursor: pointer; }
.shared-tree-picker-toggle:hover,
.shared-tree-picker-toggle[aria-expanded="true"] { border-color: #caa13b; box-shadow: 0 0 0 3px rgba(202,161,59,.12); }
.shared-tree-picker-toggle span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-tree-picker-panel { position: absolute; z-index: 40; top: calc(100% + 7px); right: 0; width: min(420px, calc(100vw - 28px)); padding: 10px; border: 1px solid #d2bb79; border-radius: 13px; background: #fff; box-shadow: 0 16px 38px rgba(48,34,18,.18); }
.shared-tree-picker-search { display: grid; gap: 5px; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
.shared-tree-picker-search input { min-height: 42px; }
.shared-tree-picker-list { display: grid; gap: 4px; }
.shared-tree-picker-list.is-scrollable { max-height: 430px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.shared-tree-picker-option { display: block; padding: 10px 12px; border-radius: 9px; color: var(--ink); text-decoration: none; line-height: 1.35; }
.shared-tree-picker-option:hover { background: #fff5d6; }
.shared-tree-picker-option.active { background: #f3e5b6; color: #6d1d18; font-weight: 900; }
.shared-tree-picker-empty { padding: 18px 12px; color: var(--muted); text-align: center; }

.settings-rule-groups { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.settings-rule-group { min-width: 0; margin: 0; padding: 18px; border: 1px solid #ddcfb2; border-radius: 14px; background: #fffdf8; }
.settings-rule-group legend { padding: 0 8px; color: #74241f; font-size: 16px; font-weight: 950; }
.settings-rule-group .form-grid { grid-template-columns: 1fr; }
.settings-rule-group .span-2 { grid-column: 1; }

.audit-filter { margin-bottom: 18px; }
.audit-filter .form-grid { align-items: end; }
.audit-filter-actions { align-self: end; }
.audit-filter-actions .button { min-width: 120px; }

.data-rights-card { display: grid; align-content: start; gap: 14px; }
.data-rights-card > h2,
.data-rights-card > p { margin: 0; }
.tree-restore-box { border: 1px solid #dfc57f; border-radius: 12px; background: #fffaf0; }
.tree-restore-box > summary { padding: 13px 15px; color: #6d241e; font-weight: 900; cursor: pointer; }
.tree-restore-box[open] > summary { border-bottom: 1px solid #ead9aa; }
.tree-restore-box > div,
.tree-restore-box > form { margin: 14px; }

@media (max-width: 900px) {
  .settings-rule-groups { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .shared-tree-picker { width: 100%; }
  .shared-tree-picker-panel { position: fixed; top: 76px; left: 14px; right: 14px; width: auto; max-height: calc(100vh - 100px); }
  .shared-tree-picker-list.is-scrollable { max-height: calc(100vh - 210px); }
  .audit-filter-actions { grid-column: 1 / -1; }
  .audit-filter-actions .button { flex: 1; }
}

/* 1.1.17 — tìm kiếm/phân trang, hồ sơ popup, danh bạ chi họ, tin nhắn quản trị và chia sẻ theo đời */
.table-list-summary { margin: 0 0 12px; padding: 5px 10px 0 15px; color: var(--muted); font-size: 13px; font-weight: 750; }
.pagination { justify-content: center; margin-top: 18px; }
.pagination a { min-width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); font-weight: 850; text-decoration: none; }
.pagination a:hover { border-color: #c79b2c; background: #fff7dc; }
.pagination a.active { border-color: var(--red); background: var(--red); color: #fff; }
.profile-name-button { padding: 0; border: 0; background: transparent; color: var(--red); font: inherit; text-align: left; cursor: pointer; }
.profile-name-button:hover { text-decoration: underline; }
.profile-dialog { width: min(880px, calc(100vw - 28px)); max-height: 88vh; padding: 0; overflow: hidden; }
.profile-dialog-shell { max-height: 88vh; display: grid; grid-template-rows: auto minmax(0,auto) minmax(0,1fr) auto; gap: 16px; padding: 24px; overflow: auto; }
.profile-detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 0; }
.profile-detail-grid > div { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf9; }
.profile-detail-grid > .span-2 { grid-column: 1 / -1; }
.profile-detail-grid dt { margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 850; }
.profile-detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.admin-user-actions { display: grid; gap: 9px; min-width: 230px; }
.admin-member-thread { min-height: 0; padding-top: 14px; border-top: 1px solid var(--line); }
.admin-member-thread h3 { margin: 0 0 10px; }
.mini-message-log, .admin-message-log { display: grid; gap: 8px; max-height: 300px; overflow-y: auto; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #f8f5ef; }
.mini-message { display: grid; gap: 3px; max-width: 90%; padding: 9px 11px; border-radius: 11px; background: #fff; }
.mini-message.from-admin { justify-self: end; background: #fff2c8; }
.mini-message.from-member { justify-self: start; }
.mini-message strong, .mini-message small { font-size: 12px; }
.mini-message small { color: var(--muted); }
.admin-message-center { margin-top: 20px; }
.admin-message-item { max-width: 82%; padding: 11px 13px; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(42,32,20,.06); }
.admin-message-item.admin-sent { justify-self: start; border-left: 4px solid var(--gold); }
.admin-message-item.member-reply { justify-self: end; background: #f3f6ff; border-right: 4px solid #5570a8; }
.admin-message-item header { display: flex; justify-content: space-between; gap: 12px; }
.admin-message-item header small { color: var(--muted); }
.admin-message-item p { margin-bottom: 0; }
.root-account-settings { margin-top: 20px; }

.compact-heritage-grid { grid-template-columns: repeat(auto-fit,minmax(285px,1fr)); gap: 16px; }
.heritage-card.compact { min-height: 0; gap: 8px; padding: 19px; background: #fff; }
.heritage-card.compact.joined-branch { border-color: #d7b24d; background: #fff8d9; box-shadow: 0 8px 24px rgba(125,91,11,.11); }
.heritage-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.heritage-title-row h2 { font-size: clamp(20px,2vw,25px); }
.joined-star { flex: 0 0 auto; color: #b57b00; font-size: 24px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(90,50,0,.12)); }
.heritage-card.compact > p { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.heritage-card.compact .heritage-meta { margin: 2px 0 6px; }
.heritage-card.compact .heritage-meta > div { padding: 7px 0; }
.heritage-summary { margin: 0 0 12px; }

.branch-member-card { min-width: 0; }
.member-search-form { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.member-search-form input { min-width: 0; flex: 1; }
.member-directory-frame { max-height: 520px; overflow: auto; overscroll-behavior: contain; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.compact-member-list { margin: 0; }
.compact-member-list li { min-height: 56px; padding: 9px 0; }
.member-identity { min-width: 0; }
.member-identity strong, .member-identity small { display: block; overflow-wrap: anywhere; }
.member-actions.compact { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.member-pagination { margin-top: 12px; }
.pending-membership-box { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.pending-membership-box h3 { margin: 0 0 10px; }
.pending-member-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(320px,1.4fr); gap: 12px; align-items: center; padding: 10px 0; border-top: 1px dashed var(--line); }
.pending-member-row small { display: block; color: var(--muted); }
.membership-review-form { display: grid; grid-template-columns: minmax(120px,1fr) auto auto; gap: 7px; }

.merge-share-card { display: grid; align-content: start; gap: 14px; }
.share-status-box { display: grid; gap: 4px; padding: 13px 15px; border: 1px solid #cfac4e; border-radius: 12px; background: #fff7d8; }
.share-status-box small, .share-choice small, .share-range-title small { display: block; color: var(--muted); }
.share-choice-stack { display: grid; gap: 13px; }
.share-choice, .share-range-form { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fffdf9; }
.share-choice { grid-template-columns: minmax(0,1fr) auto; align-items: center; }
.share-range-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.share-range-grid label { margin: 0; }

@media (max-width: 760px) {
  .profile-detail-grid { grid-template-columns: 1fr; }
  .profile-detail-grid > .span-2 { grid-column: 1; }
  .profile-dialog-shell { padding: 16px; }
  .admin-message-item { max-width: 96%; }
  .member-search-form { align-items: stretch; flex-direction: column; }
  .member-search-form .button { width: 100%; }
  .pending-member-row { grid-template-columns: 1fr; }
  .membership-review-form { grid-template-columns: 1fr 1fr; }
  .membership-review-form input { grid-column: 1 / -1; }
  .share-choice { grid-template-columns: 1fr; }
  .share-range-grid { grid-template-columns: 1fr; }
  .share-choice .button, .share-range-form .button { width: 100%; }
}

/* 1.1.18 — tin tức chi họ, khung nội bộ và hộp tin nhắn quản trị độc lập */
.branch-content-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.branch-content-actions .button[disabled] { cursor: not-allowed; opacity: .62; }
.branch-news-zone { margin: 18px 0 0; padding: 20px; border: 1px solid #cdb77c; border-radius: var(--radius); background: linear-gradient(145deg,#fffdf7,#f7f0df); box-shadow: 0 10px 28px rgba(67,48,20,.08); }
.branch-news-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.branch-news-head h2 { margin: 3px 0 4px; color: #593519; }
.branch-news-head p { margin: 0; color: var(--muted); }
.branch-news-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px 18px; }
.branch-news-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; min-width: 0; padding: 11px 12px; border: 1px solid #ddcfaa; border-radius: 11px; background: #fff; }
.branch-news-link { min-width: 0; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.branch-news-link strong, .branch-news-link span { display: block; overflow-wrap: anywhere; }
.branch-news-link strong { color: #7a281f; }
.branch-news-link span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.branch-news-link:hover strong { text-decoration: underline; }
.branch-news-actions { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.branch-news-actions form { margin: 0; }
.branch-news-dialog { width: min(860px,calc(100vw - 28px)); max-height: 90vh; overflow: hidden; }
.branch-news-dialog-shell { max-height: 90vh; display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 16px; padding: 24px; }
.branch-news-content { min-height: 0; overflow: auto; line-height: 1.7; overflow-wrap: anywhere; }
.branch-news-content img { display: block; max-width: 100%; height: auto; margin: 14px auto; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.branch-news-content a { color: var(--red); text-decoration: underline; }
.message-column { min-width: 92px; }
.admin-message-link { font-weight: 850; }
.profile-only-shell { grid-template-rows: auto minmax(0,1fr) auto; }
.admin-message-dialog { width: min(820px,calc(100vw - 28px)); max-height: 90vh; padding: 0; overflow: hidden; }
.admin-message-dialog-shell { max-height: 90vh; display: grid; grid-template-rows: auto minmax(160px,1fr) auto; gap: 14px; padding: 24px; }
.admin-message-thread { min-height: 160px; max-height: 480px; overflow: auto; display: grid; align-content: start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8f5ef; overscroll-behavior: contain; }
.admin-message-item { width: min(88%,620px); padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.admin-message-item.from-admin { margin-left: auto; border-color: #adc6de; background: #eef7ff; }
.admin-message-item.from-member { margin-right: auto; border-color: #dbc58b; background: #fff8e6; }
.admin-message-item header { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.admin-message-item p { margin: 7px 0; overflow-wrap: anywhere; }
.admin-message-item small { color: var(--muted); }
.admin-message-compose { margin: 0; }

@media (max-width: 760px) {
  .branch-news-grid { grid-template-columns: 1fr; }
  .branch-news-head { flex-direction: column; }
  .branch-news-item { grid-template-columns: 1fr; }
  .branch-news-actions { justify-content: flex-start; }
  .branch-content-actions { justify-content: flex-start; }
  .branch-news-dialog-shell, .admin-message-dialog-shell { padding: 16px; }
  .admin-message-item { width: 96%; }
}

/* ===== 1.1.19 · Trình thiết kế cây gia phả truyền thống ===== */
.traditional-page-heading .heading-actions{display:flex;align-items:center;gap:.65rem}
.traditional-tree-notice{margin:0 0 1rem;padding:.85rem 1rem;border:1px solid #e6cf88;border-radius:14px;background:#fff9df;color:#67470d;line-height:1.55}
.traditional-tree-workspace{display:grid;grid-template-columns:minmax(280px,350px) minmax(0,1fr);gap:1rem;align-items:start}
.traditional-tree-sidebar{position:sticky;top:84px;max-height:calc(100vh - 100px);overflow:auto;padding-right:.25rem}
.traditional-tree-main{min-width:0;display:grid;gap:1rem}
.compact-card{padding:1rem}
.traditional-settings-form{display:grid;gap:.75rem;margin-top:.75rem}
.traditional-settings-section{border:1px solid var(--border,#dfd7c6);border-radius:14px;background:#fff;overflow:hidden}
.traditional-settings-section>summary{cursor:pointer;padding:.85rem 0.69rem;font-weight:600;color:#5d2b1b;background:linear-gradient(180deg,#fffdf8,#fbf4e7);list-style:none}
.traditional-settings-section>summary::-webkit-details-marker{display:none}
.traditional-settings-section>summary:after{content:'＋';float:right;font-weight:500}
.traditional-settings-section[open]>summary:after{content:'−'}
.traditional-settings-section .details-body{display:grid;gap:.75rem;padding:1rem;border-top:1px solid #eee4d1}
.traditional-settings-section label{display:grid;gap:.35rem;font-size:.88rem;font-weight:700;color:#4d453b}
.traditional-settings-section input,.traditional-settings-section select,.traditional-settings-section textarea{width:100%}
.two-column-inputs,.color-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.65rem}
.color-grid input[type=color]{height:42px;padding:.2rem}
.traditional-upload-row{display:none;grid-template-columns:minmax(0,1fr) auto;gap:.5rem;align-items:center}
.traditional-upload-row input[type=file]{font-size:.78rem}
.full-width{width:100%;justify-content:center}
.button.danger.subtle{background:#fff4f2;color:#a52b21;border-color:#e9b3ac}
.traditional-save-actions{position:sticky;bottom:0;padding:.5rem 0;background:linear-gradient(180deg,rgba(247,244,236,0),#f7f4ec 30%)}
.traditional-selection-card,.traditional-preview-card{padding:1rem;min-width:0}
.traditional-generation-selector{display:grid;gap:.8rem;max-height:420px;overflow:auto;padding:.1rem}
.traditional-selector-generation{border:1px solid #e8dfcf;border-radius:12px;background:#fffdfa;overflow:hidden}
.traditional-selector-generation>header{display:flex;justify-content:space-between;gap:1rem;padding:.55rem .75rem;background:#f7efe0;color:#684522;font-size:.85rem}
.traditional-selector-generation>header span{color:#786e60;font-weight:500}
.traditional-selector-row{display:flex;flex-wrap:wrap;gap:.55rem;padding:.7rem}
.traditional-person-choice{display:flex;align-items:flex-start;gap:.45rem;min-width:170px;max-width:250px;padding:.55rem .65rem;border:1px solid #dfd2bd;border-radius:10px;background:#fff;cursor:pointer;transition:.15s ease;box-shadow:0 1px 2px rgba(50,35,15,.04)}
.traditional-person-choice:hover{border-color:#b98643;transform:translateY(-1px)}
.traditional-person-choice.is-selected{background:#fff4bd;border-color:#cf9d26;box-shadow:0 0 0 2px rgba(207,157,38,.11)}
.traditional-person-choice.is-disabled{opacity:.42;cursor:not-allowed;filter:grayscale(.25)}
.traditional-person-choice.is-dragging{opacity:.45;border-style:dashed}
.traditional-person-choice input{width:auto;margin-top:.18rem}
.traditional-person-choice span{display:grid;gap:.15rem;min-width:0}
.traditional-person-choice strong{font-size:.82rem;line-height:1.2;overflow-wrap:anywhere}
.traditional-person-choice small{font-size:.72rem;color:#756a5b}
.traditional-selection-summary{display:grid;gap:.2rem;padding:.65rem .75rem;border-radius:10px;background:#f8f4eb;font-size:.82rem}
.traditional-selection-summary span{color:#716657}
.traditional-preview-shell{width:100%;max-height:75vh;overflow:auto;border:1px solid #d8cfbf;border-radius:14px;background:#d8d3c7;padding:1rem;overscroll-behavior:contain;cursor:grab;touch-action:none;user-select:none}
.traditional-preview-stage{display:inline-block;min-width:100%;transform-origin:top left}
.traditional-preview-stage svg{display:block;max-width:none;background:#fff;box-shadow:0 12px 30px rgba(48,34,12,.2)}
.traditional-preview-stage svg.is-fitted{max-width:100%;box-shadow:0 6px 20px rgba(48,34,12,.16)}
.traditional-preview-shell.is-panning{cursor:grabbing}
.traditional-preview-shell:fullscreen{max-height:none;width:100vw;height:100vh;border:0;border-radius:0;padding:1rem;background:#c9c4b8}
.traditional-preview-shell:fullscreen .traditional-preview-stage{min-width:100%;min-height:100%;display:flex;align-items:flex-start;justify-content:flex-start}
.traditional-export-actions{display:flex;flex-wrap:wrap;gap:.45rem;justify-content:flex-end;align-items:center}
.traditional-export-actions .icon-button{min-width:38px;padding-inline:.65rem;font-size:1.1rem}
.traditional-zoom-status{display:inline-flex;align-items:center;justify-content:center;min-width:58px;padding:.42rem .5rem;border:1px solid #ddd2c0;border-radius:8px;background:#fff;font-size:.78rem;font-weight:800;color:#5d5142}
.traditional-export-scale{display:flex;align-items:center;gap:.35rem;font-size:.75rem;font-weight:700;color:#655b4f}
.traditional-export-scale select{width:auto;min-width:62px;padding:.42rem .45rem}
.traditional-footer-editor img,.traditional-preview-footer img{max-width:100%;height:auto}
.traditional-warning-list{margin:0 0 .8rem;padding:.75rem 1rem;border-radius:12px;border:1px solid #e6c575;background:#fff8da;color:#6e4b0b;font-size:.84rem}
.traditional-warning-list ul{margin:.45rem 0 0;padding-left:1.2rem}
.traditional-preview-footer{margin-top:.75rem;padding:.75rem 1rem;border:1px solid #e5dccb;border-radius:12px;background:#fff;line-height:1.55}
.simple-html-toolbar{display:flex;flex-wrap:wrap;gap:.35rem;padding:.4rem;border:1px solid #d9cfbd;border-bottom:0;border-radius:10px 10px 0 0;background:#f7f3ea}
.simple-html-toolbar button{border:1px solid #d2c5af;background:#fff;border-radius:6px;padding:.32rem .5rem;cursor:pointer}
.traditional-footer-editor{min-height:120px;padding:.75rem;border:1px solid #d9cfbd;border-radius:0 0 10px 10px;background:#fff;line-height:1.55;overflow:auto}
.traditional-footer-editor:focus{outline:2px solid rgba(164,105,38,.18);border-color:#b27a3a}
.traditional-tree-svg{font-family:serif}
.traditional-template-golden{font-family:Georgia,'Times New Roman',serif}
.traditional-template-parchment{font-family:'Times New Roman',serif}
.traditional-template-wood{font-family:Georgia,serif}

@media (max-width:1100px){
  .traditional-tree-workspace{grid-template-columns:1fr}
  .traditional-tree-sidebar{position:static;max-height:none;overflow:visible}
  .traditional-tree-sidebar .compact-card{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.65rem}
  .traditional-tree-sidebar .compact-card .section-heading{grid-column:1/-1}
}
@media (max-width:700px){
  .traditional-tree-sidebar .compact-card,.two-column-inputs,.color-grid{grid-template-columns:1fr}
  .traditional-person-choice{min-width:100%;max-width:none}
  .traditional-export-actions{justify-content:flex-start}
  .traditional-preview-shell{padding:.45rem;max-height:68vh}
  .traditional-tree-workspace{gap:.75rem}
}

@media print{
  body.traditional-print-mode .topbar,
  body.traditional-print-mode .footer,
  body.traditional-print-mode .page-shell > .alert,
  body.traditional-print-mode .traditional-page-heading,
  body.traditional-print-mode .traditional-tree-notice,
  body.traditional-print-mode .traditional-tree-sidebar,
  body.traditional-print-mode .traditional-selection-card,
  body.traditional-print-mode .traditional-preview-card>.section-heading,
  body.traditional-print-mode .traditional-warning-list,
  body.traditional-print-mode .traditional-preview-footer{display:none!important}
  body.traditional-print-mode .page-shell{max-width:none!important;margin:0!important;padding:0!important}
  body.traditional-print-mode .traditional-tree-workspace,
  body.traditional-print-mode .traditional-tree-main,
  body.traditional-print-mode .traditional-preview-card{display:block!important;margin:0!important;padding:0!important;border:0!important;box-shadow:none!important}
  body.traditional-print-mode .traditional-preview-shell{overflow:visible!important;max-height:none!important;border:0!important;border-radius:0!important;background:#fff!important;padding:0!important}
  body.traditional-print-mode .traditional-preview-stage svg{width:100%!important;height:auto!important;box-shadow:none!important;page-break-inside:avoid}
}

/* Kết Nối Phả Hệ 2.0.0 — thư viện ảnh mặc định và xem trước trực tiếp */
.traditional-image-setting{display:grid;gap:.65rem;padding:.75rem;border:1px solid #e4dac8;border-radius:12px;background:#fffdf8}
.traditional-image-field-preview{display:flex;align-items:center;justify-content:center;gap:.65rem;min-height:92px;padding:.55rem;border:1px dashed #d5c5ad;border-radius:10px;background:#f8f4ec;color:#756a5b;font-size:.78rem;text-align:center;overflow:hidden}
.traditional-image-field-preview img{display:block;max-width:100%;max-height:150px;width:auto;height:auto;object-fit:contain;border-radius:7px;box-shadow:0 2px 9px rgba(52,34,14,.12)}
.traditional-image-field-preview.has-error{border-color:#d99b92;background:#fff4f2;color:#9d3528}
.traditional-image-field-preview.has-error img{display:none}
.traditional-settings-section select[data-default-image-select]{background-color:#fff9e9;border-color:#d8bd80}
.traditional-settings-section input[inputmode="url"]{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.8rem}

/* 2.0.1 — quy ước trực quan cho trường bắt buộc. */
.required-mark{position:absolute;left:3px;top:.18em;display:inline-block;margin:0;color:#b42318;font-weight:900;line-height:1}
label[data-required-marked="1"]{position:relative;padding-left:.72rem}
.chat-message-field{display:grid;gap:.4rem;min-width:0;flex:1}
.html-editor-field{display:grid;gap:.4rem;margin:0}
.html-editor-field textarea{width:100%}

/* 2.1.0 — Không gian sinh hoạt chi họ */
.branch-section-nav { position: sticky; top: 72px; z-index: 8; display: flex; gap: 7px; overflow-x: auto; margin: 0 0 18px; padding: 9px; border: 1px solid #d9c28a; border-radius: 14px; background: rgba(255,252,242,.96); box-shadow: 0 8px 24px rgba(76,49,13,.08); scrollbar-width: thin; }
.branch-section-nav a { flex: 0 0 auto; padding: 8px 12px; border-radius: 999px; color: #6d421b; font-size: 13px; font-weight: 800; text-decoration: none; }
.branch-section-nav a:hover { background: #8f251f; color: #fff; }
.branch-foundation-card { overflow: hidden; border: 1px solid #b98b36; border-radius: 18px; background: #fffdf7; box-shadow: 0 16px 42px rgba(75,43,7,.14); }
.branch-foundation-visual { position: relative; min-height: 300px; overflow: hidden; background: linear-gradient(135deg,#5a2718,#c79a45); }
.branch-foundation-visual > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.branch-foundation-placeholder { display: grid; place-items: center; min-height: 300px; color: rgba(255,242,190,.75); font: 900 116px/1 serif; background: radial-gradient(circle at 50% 25%,#c99840,#642b1c 72%); }
.branch-foundation-overlay { position: absolute; inset: 0; background: linear-gradient(180deg,rgba(21,10,2,.12),rgba(21,10,2,.88)); }
.branch-foundation-title { position: absolute; inset: auto 0 0; padding: 28px; color: #fff; }
.branch-foundation-title .eyebrow { color: #ffe39a; }
.branch-foundation-title h2 { margin: 5px 0 8px; color: #fff; font-size: clamp(28px,4vw,44px); text-shadow: 0 2px 10px #000; }
.branch-foundation-title p { max-width: 760px; margin: 0; color: #fff9e8; line-height: 1.65; }
.branch-foundation-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.branch-foundation-badges span { padding: 6px 10px; border: 1px solid rgba(255,255,255,.34); border-radius: 999px; background: rgba(43,17,5,.46); font-size: 12px; font-weight: 800; }
.branch-foundation-details { padding: 20px 22px 22px; background: linear-gradient(180deg,#fffdf8,#fff8e5); }
.foundation-detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 0; }
.foundation-detail-grid div { padding: 12px 14px; border: 1px solid #eadbb5; border-radius: 12px; background: rgba(255,255,255,.82); }
.foundation-detail-grid dt { color: #8a6427; font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.foundation-detail-grid dd { margin: 5px 0 0; color: #432813; font-family: serif; font-weight: 700; }
.branch-foundation-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.branch-foundation-actions form { margin: 0; }
.incense-button { border-color: #9b2d22; background: linear-gradient(135deg,#a72b22,#6f1713); color: #fff4bd; box-shadow: 0 8px 20px rgba(126,31,23,.22); }
.incense-button:hover { color: #fff; filter: brightness(1.08); }
.branch-media-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; margin: 20px 0; }
.branch-media-empty { padding: 24px; border: 1px dashed #d8c18e; border-radius: 12px; background: #fffaf0; color: var(--muted); text-align: center; }
.branch-gallery-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-top: 14px; }
.branch-gallery-item { position: relative; overflow: hidden; margin: 0; border: 1px solid #e0cfaa; border-radius: 13px; background: #fff; }
.branch-gallery-open { display: block; width: 100%; padding: 0; border: 0; background: #eee; cursor: pointer; }
.branch-gallery-open img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; transition: transform .25s ease; }
.branch-gallery-open:hover img { transform: scale(1.035); }
.branch-gallery-item figcaption { display: grid; gap: 3px; padding: 10px 11px; }
.branch-gallery-item figcaption span { color: var(--muted); font-size: 12px; }
.branch-gallery-item form { position: absolute; top: 8px; right: 8px; padding: 4px 7px; border-radius: 8px; background: rgba(255,255,255,.92); }
.branch-gallery-dialog { width: min(980px,calc(100vw - 24px)); }
.branch-gallery-dialog-shell { padding: 18px; }
.branch-gallery-dialog-shell > img { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 12px; }
.gallery-caption { max-width: 760px; margin: 12px auto 0; }
.branch-video-list { display: grid; gap: 14px; margin-top: 14px; }
.branch-video-item { display: grid; grid-template-columns: minmax(190px,42%) minmax(0,1fr); gap: 13px; align-items: start; padding: 10px; border: 1px solid #e0cfaa; border-radius: 13px; background: #fff; }
.branch-video-frame { overflow: hidden; border-radius: 9px; aspect-ratio: 16/9; background: #111; }
.branch-video-frame iframe { width: 100%; height: 100%; border: 0; }
.branch-video-item p { margin: 6px 0; color: var(--muted); font-size: 13px; }
.branch-activity-card { margin: 20px 0; border-color: #d4b66a; background: linear-gradient(145deg,#fffdf7,#fff7df); }
.branch-activity-timeline { display: grid; gap: 0; margin: 16px 0 0; padding: 0; list-style: none; }
.branch-activity-timeline li { position: relative; display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 11px; min-height: 60px; padding: 8px 0; }
.branch-activity-timeline li:not(:last-child)::after { content: ''; position: absolute; left: 20px; top: 46px; bottom: -8px; width: 2px; background: #dfca93; }
.activity-icon { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #d4b66a; border-radius: 50%; background: #fff; font-size: 18px; }
.branch-activity-timeline strong, .branch-activity-timeline small { display: block; }
.branch-activity-timeline small { margin-top: 4px; color: var(--muted); }
.branch-management-dialog { width: min(720px,calc(100vw - 24px)); }
.branch-transfer-box.pending { border-color: #d1a83e; background: #fff6d9; }
.branch-leave-form { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.branch-prayer-history-dialog { width: min(700px,calc(100vw - 24px)); }
.branch-prayer-history-shell { padding: 22px; }
.prayer-history-list { display: grid; gap: 12px; max-height: 60vh; overflow: auto; }
.prayer-history-list article { padding: 14px; border: 1px solid #e1cf9e; border-left: 4px solid #9b2d22; border-radius: 11px; background: #fffdf7; }
.prayer-history-list time { color: #8a6427; font-size: 12px; font-weight: 800; }
.prayer-history-list p { margin: 7px 0 0; white-space: normal; overflow-wrap: anywhere; }
.branch-incense-dialog { width: min(980px,calc(100vw - 16px)); max-width: 980px; padding: 0; border: 0; background: transparent; }
.branch-incense-dialog::backdrop { background: rgba(11,5,2,.92); backdrop-filter: blur(4px); }
.incense-sanctuary { position: relative; min-height: min(720px,92vh); overflow: hidden; border: 3px solid #b9822d; border-radius: 18px; background: radial-gradient(circle at 50% 30%,#8b4a1f,#2a0d08 72%); color: #fff5cf; box-shadow: 0 24px 80px #000; }
.incense-hall-background { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.incense-shade { position: absolute; inset: 0; background: linear-gradient(180deg,rgba(16,4,1,.35),rgba(22,4,1,.72)); }
.incense-sanctuary header { position: relative; z-index: 2; padding: 25px 24px 0; text-align: center; text-shadow: 0 2px 10px #000; }
.incense-sanctuary header span { color: #ffd979; font-size: 12px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.incense-sanctuary header h2 { margin: 5px 0; color: #fff2b5; font: 800 clamp(28px,5vw,48px)/1.15 serif; }
.incense-sanctuary header p { margin: 0; color: #fff8df; }
.incense-stage { position: relative; z-index: 2; display: grid; place-items: end center; height: 260px; margin-top: 12px; }
.incense-burner { max-width: min(320px,55vw); max-height: 190px; object-fit: contain; filter: drop-shadow(0 14px 18px rgba(0,0,0,.55)); }
.incense-burner-placeholder { display: grid; place-items: center; width: 240px; height: 130px; border: 4px solid #d0a348; border-radius: 20px 20px 90px 90px; background: linear-gradient(#a32c20,#64150f); color: #f9db79; font: 900 58px serif; }
.incense-stick { position: absolute; left: 50%; bottom: 116px; width: 5px; height: 130px; border-radius: 4px; background: linear-gradient(#4b160e,#b84929); transform: translateX(-50%); }
.incense-ember { position: absolute; left: -2px; top: -5px; width: 9px; height: 9px; border-radius: 50%; background: #ffcc62; box-shadow: 0 0 9px 4px #ff5a19; animation: emberGlow 1.1s infinite alternate; }
.smoke { position: absolute; left: 50%; bottom: 100%; width: 13px; height: 80px; border-radius: 50%; border-left: 3px solid rgba(255,255,255,.5); filter: blur(2px); animation: incenseSmoke 4.4s infinite ease-in-out; transform-origin: bottom; }
.smoke-two { animation-delay: -1.5s; left: 30%; }
.smoke-three { animation-delay: -3s; left: 70%; }
.incense-countdown { position: relative; z-index: 2; width: fit-content; margin: 2px auto 14px; padding: 8px 16px; border: 1px solid rgba(255,226,142,.65); border-radius: 999px; background: rgba(36,8,2,.64); color: #ffe28e; font: 900 24px/1 monospace; letter-spacing: .08em; }
.incense-countdown.complete { color: #bff0bd; }
.incense-sanctuary form { position: relative; z-index: 2; width: min(720px,calc(100% - 32px)); margin: 0 auto; padding: 18px; border: 1px solid rgba(255,226,142,.45); border-radius: 14px; background: rgba(31,7,3,.72); }
.incense-sanctuary label { color: #fff4c9; }
.incense-sanctuary textarea { background: rgba(255,255,255,.93); color: #29130e; }
.incense-sanctuary small, .incense-wait-note { color: #f4dfaf; }
.incense-monthly-note { padding: 12px; border: 1px solid rgba(255,226,142,.4); border-radius: 10px; background: rgba(255,231,158,.12); text-align: center; }
@keyframes incenseSmoke { 0% { opacity: 0; transform: translate(-50%,0) scale(.7) rotate(-4deg); } 20% { opacity: .7; } 75% { opacity: .32; } 100% { opacity: 0; transform: translate(-30%,-95px) scale(1.8) rotate(17deg); } }
@keyframes emberGlow { from { box-shadow: 0 0 6px 2px #ff5a19; } to { box-shadow: 0 0 14px 6px #ffb127; } }
@media (max-width: 860px) { .branch-media-grid { grid-template-columns: 1fr; } .foundation-detail-grid { grid-template-columns: 1fr; } .branch-video-item { grid-template-columns: 1fr; } .branch-section-nav { top: 58px; } }
@media (max-width: 560px) { .branch-gallery-grid { grid-template-columns: 1fr; } .branch-foundation-title { padding: 20px; } .branch-foundation-actions .button, .branch-foundation-actions form { width: 100%; } .branch-foundation-actions form .button { width: 100%; } .incense-stage { height: 220px; } .incense-sanctuary form { padding: 13px; } }

/* 2.2.0 — Phạm vi media và tiến trình cây hương */
.incense-stick { transition: height .22s linear; transform-origin: bottom center; }
.incense-ember { transition: opacity .2s linear; }
.smoke { transition: opacity .2s linear; }
.media-visibility-badge { display: inline-flex !important; width: fit-content; margin: 5px 0 0; padding: 3px 8px; border: 1px solid #d7b75f; border-radius: 999px; background: #fff6d4; color: #765209; font-size: 11px; font-weight: 850; }

/* 2.2.0 — Xác minh cộng đồng và hướng dẫn theo cấp */
.peer-verification-primary { border-color: #d5b45d; background: linear-gradient(145deg,#fffdf7,#fff4cf); }
.peer-code-panel { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 16px 0; padding: 18px; border: 1px solid #d4b45c; border-radius: 14px; background: #fff; }
.peer-code-panel span, .peer-code-panel small { display: block; color: var(--muted); }
.peer-code-panel strong { display: block; margin: 5px 0; color: #7c1d16; font: 900 clamp(26px,5vw,40px)/1 monospace; letter-spacing: .16em; }
.peer-verification-steps { display: grid; gap: 8px; padding-left: 22px; }
.peer-confirmation-progress { margin-top: 16px; padding: 16px; border: 1px solid #dfc77f; border-radius: 13px; background: rgba(255,255,255,.78); }
.peer-confirmation-person { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed #dfc77f; }
.peer-confirmation-person:last-of-type { border-bottom: 0; }
.peer-confirmation-person span { color: var(--muted); font-size: 13px; }
.peer-verification-helper { border-left: 5px solid #a67315; }
.peer-verification-dialog { width: min(680px,calc(100vw - 24px)); }
.peer-verification-shell { padding: 22px; }
.peer-candidate-card { margin-top: 16px; padding: 18px; border: 1px solid #d5b45d; border-radius: 14px; background: #fffaf0; }
.peer-candidate-card h3 { margin: 4px 0; font-size: 24px; }
.support-audience-guide { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; padding: 14px; border: 1px solid #dcc687; border-radius: 12px; background: #fffaf0; }
.support-audience-guide strong, .support-audience-guide small { width: 100%; }
.support-audience-guide code { padding: 2px 6px; border-radius: 6px; background: #6e1d16; color: #fff5d1; }
.support-preview-box { margin-top: 10px; }
.support-preview-box > article { margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.support-preview-box h3 { margin-top: 0; }
@media (max-width: 620px) {
  .peer-code-panel, .peer-confirmation-person { align-items: stretch; flex-direction: column; }
  .peer-code-panel .button { width: 100%; }
}

/* 2.3.0: Hoạt động và nhận diện vai trò chi họ */
p.incense-wait-note { text-align: center; }
.heritage-card.compact.headed-branch { border-color: #9f2b25; background: #fff7f1; box-shadow: 0 8px 24px rgba(126,31,23,.12); }
.joined-star.branch-head-star { color: #b0221a; }
.joined-star.member-branch-star { color: #b57b00; }
.branch-head-member > strong { color: #8f1712; font-weight: 900; }
.pending-join-self { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.pending-join-self .privacy-note { margin: 0; }
.branch-overview-panels { display: grid; gap: 20px; margin: 20px 0 28px; }
.branch-ranking-card { border-color: #d6bd7e; background: linear-gradient(145deg,#fffef9,#fff8e8); }
.branch-inactive-card { border-color: #d7a49d; background: linear-gradient(145deg,#fffdfa,#fff3f0); }
.branch-ranking-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-top: 16px; }
.branch-ranking-column { min-width: 0; display: grid; align-content: start; gap: 8px; }
.branch-ranking-row { display: grid; grid-template-columns: minmax(150px,1.35fr) minmax(120px,1fr) minmax(100px,.7fr) minmax(130px,1fr); gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid #e5d6b4; border-radius: 11px; background: rgba(255,255,255,.82); color: inherit; text-decoration: none; }
.branch-ranking-row:hover { border-color: #bd9141; box-shadow: 0 5px 16px rgba(89,59,14,.08); }
.branch-ranking-row > span, .branch-ranking-row > strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-ranking-row.inactive { grid-template-columns: minmax(150px,1.2fr) minmax(120px,1fr) minmax(130px,1fr) minmax(180px,1.3fr); }
.branch-rank-name a { font-weight: 800; }
.branch-ranking-empty { margin: 0; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; }
.branch-ranking-note { margin: 12px 0 0; }
.heritage-list-heading { margin-top: 30px; }
.mini-badge.warning { background: #fff0e8; color: #9a2f22; border-color: #e4b1a8; }
@media (max-width: 980px) {
  .branch-ranking-columns { grid-template-columns: 1fr; }
  .branch-ranking-row, .branch-ranking-row.inactive { grid-template-columns: minmax(140px,1.3fr) minmax(110px,1fr) minmax(100px,.8fr) minmax(120px,1fr); }
}
@media (max-width: 680px) {
  .branch-ranking-row, .branch-ranking-row.inactive { grid-template-columns: 1fr 1fr; }
  .branch-ranking-row > span, .branch-ranking-row > strong { white-space: normal; }
}

/* 2.4.0 — Bộ lọc quản trị, danh bạ chi họ và Nhật ký dễ đọc */
.admin-filter-card {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid #decfb9;
    border-radius: 14px;
    background: linear-gradient(180deg, #fffefa, #fbf5e9);
}
.admin-filter-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}
.admin-filter-search { display: grid; grid-template-columns: 1fr; gap: 6px; min-width: 0; }
.admin-filter-search-row > .button { min-width: 130px; }
.admin-filter-options-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(170px, 1fr)) auto;
    gap: 12px;
    align-items: end;
}
.admin-filter-actions {
    display: flex;
    gap: 9px;
    align-items: end;
    flex-wrap: wrap;
}
.admin-filter-actions .button { min-width: 112px; }
.filter-field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 700; }

/* Chỉ thụt lề ghi chú ở nơi chủ động gắn lớp, tránh làm lệch mọi .muted. */
.muted-indent,
.table-card > .muted,
.admin-filter-card > .muted,
.table-list-summary.muted { padding-left: 10px; }

.search-select { position: relative; min-width: 0; }
.search-select-toggle {
    width: 100%; min-height: 47px; display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 10px 12px; border: 1px solid #cfc0ad; border-radius: 11px;
    color: var(--ink); background: #fff; text-align: left;
}
.search-select-toggle:hover,
.search-select-toggle[aria-expanded="true"] { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,154,53,.14); }
.search-select-toggle > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-select-panel {
    position: absolute; z-index: 90; top: calc(100% + 7px); left: 0; right: 0;
    min-width: min(420px, calc(100vw - 44px)); padding: 10px; border: 1px solid #d6c28d;
    border-radius: 13px; background: #fff; box-shadow: 0 18px 45px rgba(54,38,21,.20);
}
.search-select-search { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.search-select-search input { min-height: 42px; }
.search-select-options { display: grid; gap: 3px; max-height: 330px; overflow-y: auto; overscroll-behavior: contain; }
.search-select-option {
    width: 100%; padding: 9px 11px; border: 0; border-radius: 8px; color: var(--ink);
    background: transparent; text-align: left;
}
.search-select-option:hover { background: #fff5d6; }
.search-select-option.selected { color: #6d1d18; background: #f4e4b1; font-weight: 850; }
.search-select-empty { margin: 0; padding: 14px 10px; color: var(--muted); text-align: center; }

.audit-filter { margin-bottom: 18px; }
.audit-filter-grid { display: grid; grid-template-columns: minmax(260px, 1.5fr) minmax(190px, .75fr) auto; gap: 14px; align-items: end; }
.audit-filter-actions { margin: 0; align-self: end; }
.audit-filter-actions .button { min-width: 120px; }
.audit-table th:nth-child(1) { min-width: 128px; }
.audit-table th:nth-child(2) { min-width: 170px; }
.audit-table th:nth-child(3) { min-width: 230px; }
.audit-table th:nth-child(4) { min-width: 220px; }
.audit-table th:nth-child(5) { min-width: 320px; }
.audit-time-cell { white-space: nowrap; }
.audit-technical-code { margin-top: 4px; color: #887b70; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.audit-meta-list { display: grid; gap: 5px; margin: 0; }
.audit-meta-list > div { display: grid; grid-template-columns: minmax(105px, .7fr) minmax(150px, 1.3fr); gap: 8px; padding-bottom: 5px; border-bottom: 1px dashed #e5d9c7; }
.audit-meta-list > div:last-child { border-bottom: 0; }
.audit-meta-list dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.audit-meta-list dd { margin: 0; overflow-wrap: anywhere; }
.audit-technical-details { margin-top: 9px; }
.audit-technical-details summary { color: var(--red); font-size: 12px; font-weight: 800; cursor: pointer; }
.audit-technical-details > div { margin-top: 5px; font-size: 12px; }
.audit-technical-details code { overflow-wrap: anywhere; }
.audit-technical-details pre { max-width: 560px; max-height: 220px; overflow: auto; margin: 8px 0 0; padding: 10px; border-radius: 8px; background: #2d2925; color: #fff7e8; font-size: 11px; white-space: pre-wrap; }

.approved-branch-directory { margin-top: 26px; }
.directory-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 16px; }
.directory-heading h2 { margin: 4px 0 3px; }
.directory-heading p { margin: 0; }
.branch-directory-filter { box-shadow: none; }
.branch-directory-filter .admin-filter-options-row { grid-template-columns: minmax(190px,1fr) minmax(210px,1.1fr) minmax(190px,.9fr) auto; }
.admin-table-frame {
    width: 100%; max-height: 680px; overflow: auto; border: 1px solid var(--line);
    border-radius: 13px; background: #fff; overscroll-behavior: contain;
}
.admin-table-frame table { margin: 0; min-width: 1040px; }
.admin-table-frame thead th { position: sticky; top: 0; z-index: 3; background: #f5ead0; box-shadow: 0 1px 0 var(--line); }
.admin-table-frame tbody tr:nth-child(even) { background: #fffcf5; }
.admin-table-frame tbody tr:hover { background: #fff6dc; }
.directory-branch-link { display: inline-block; }
.directory-origin-cell { min-width: 230px; max-width: 380px; }
.directory-pagination { padding-bottom: 2px; }

.merge-owner-line {
    margin: 8px 0 14px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(126, 38, 34, .07);
    color: var(--text-muted, #6b625d);
    font-size: .92rem;
}
.merge-owner-line strong { color: #7a211f; }

@media (max-width: 1050px) {
    .admin-filter-options-row,
    .branch-directory-filter .admin-filter-options-row { grid-template-columns: repeat(2, minmax(190px, 1fr)); }
    .admin-filter-actions { grid-column: 1 / -1; }
    .audit-filter-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .audit-filter-actions { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
    .admin-filter-search-row { grid-template-columns: 1fr; }
    .admin-filter-search-row > .button { width: 100%; }
    .admin-filter-options-row,
    .branch-directory-filter .admin-filter-options-row { grid-template-columns: 1fr; }
    .admin-filter-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .audit-filter-grid { grid-template-columns: 1fr; }
    .audit-filter-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .search-select-panel { position: fixed; top: 76px; left: 14px; right: 14px; width: auto; min-width: 0; max-height: calc(100vh - 98px); }
    .search-select-options { max-height: calc(100vh - 210px); }
    .directory-heading { display: grid; }
    .audit-meta-list > div { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 460px) {
    .admin-filter-actions,
    .audit-filter-actions { grid-template-columns: 1fr; }
}


/* 2.5.0 — phân biệt cấp biên soạn và vai trò quản lý chi họ */
.profile-role-summary { margin-bottom: 18px; }
.profile-role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.profile-role-grid > div { padding: 12px 14px; border: 1px solid #eadfca; border-radius: 12px; background: #fffdf8; }
.profile-role-grid dt { color: #735833; font-size: .82rem; font-weight: 700; margin-bottom: 4px; }
.profile-role-grid dd { margin: 0; font-weight: 700; color: #372718; }
.profile-branch-role-list { margin-top: 16px; }
.profile-branch-role-list h3 { margin: 0 0 10px; }
.profile-branch-role-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 12px; border-top: 1px solid #eee2cf; text-decoration: none; color: inherit; }
.profile-branch-role-row:hover { background: #fff9e9; }
.profile-branch-role-row span:first-child { display: grid; gap: 3px; }
.profile-branch-role-row small { color: #806b4c; }
@media (max-width: 640px) {
  .profile-role-grid { grid-template-columns: 1fr; }
  .profile-branch-role-row { align-items: flex-start; flex-direction: column; }
}
