:root {
  --paper: #f6efe0;
  --paper-2: #efe4cc;
  --card: #fffdf7;
  --ink: #2b1d0e;
  --muted: #7a6650;
  --red: #9b1c1c;
  --red-dark: #7a1414;
  --gold: #c9a227;
  --gold-soft: #ead9a0;
  --male: #2f5d8a;
  --male-bg: #eef4fa;
  --female: #a8325e;
  --female-bg: #fbeff3;
  --line: #8a6d3b;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(60, 40, 10, 0.12);
  --serif: 'Noto Serif', Georgia, serif;
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Thanh trên ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fbeecb;
  border-bottom: 3px solid var(--gold);
  flex-wrap: wrap;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-title { font-family: var(--serif); font-weight: 700; font-size: 20px; letter-spacing: 0.3px; }
.brand-sub { font-size: 12px; opacity: 0.85; }
.seal {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 2px solid var(--gold-soft);
  border-radius: 8px;
  font-family: var(--serif);
  font-size: 24px;
  background: rgba(0, 0, 0, 0.15);
  color: #f7e7b4;
}
.seal.big { width: 72px; height: 72px; font-size: 44px; background: var(--red); margin: 0 auto 8px; }
.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.tabs button {
  background: transparent;
  border: 1px solid transparent;
  color: #fbeecb;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.tabs button:hover { border-color: rgba(255, 230, 170, 0.5); }
.tabs button.active { background: var(--gold-soft); color: var(--red-dark); font-weight: 600; }
.user { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; }
.tabs + .user { margin-left: 8px; }
.user img, .user .ava { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--gold-soft); object-fit: cover; background: #fff3; display: grid; place-items: center; }
.user button { background: transparent; border: 1px solid rgba(255, 230, 170, 0.6); color: #fbeecb; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.user .me-link { cursor: pointer; text-decoration: underline dotted; }

main { flex: 1; position: relative; min-height: 0; }
.view, .screen { position: absolute; inset: 0; }
.screen { display: grid; place-items: center; overflow: auto; padding: 16px; }
.page { overflow: auto; }
.page-inner { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1, h2, h3 { font-family: var(--serif); color: var(--red-dark); }
h2 { margin: 8px 0 12px; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff8e6;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}
.btn:hover { background: var(--red-dark); }
.btn.secondary { background: var(--card); color: var(--red); }
.btn.secondary:hover { background: var(--paper-2); }
.btn.danger { background: #fff; color: #b00020; border-color: #b00020; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Đăng nhập ---------- */
.login-card {
  background: var(--card);
  border: 1px solid var(--gold-soft);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  outline: 6px double var(--gold-soft);
  outline-offset: -14px;
}
.login-card h1 { margin: 8px 0; font-size: 26px; }
.login-buttons { display: grid; gap: 10px; margin: 20px 0 8px; }
.login-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 16px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  color: #222;
  text-decoration: none;
  font-weight: 500;
}
.login-btn.facebook { background: #1877f2; border-color: #1877f2; color: #fff; }
.login-btn svg { width: 20px; height: 20px; }
.note { background: #fff6d6; border: 1px solid var(--gold-soft); padding: 10px; border-radius: 8px; font-size: 14px; }
.dev-login { display: grid; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--gold-soft); }
.pw-login { display: grid; gap: 8px; margin-top: 18px; }
.pw-login input { padding: 10px 12px; border-radius: 8px; border: 1px solid #d6c7a6; background: #fff; width: 100%; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0 -8px; }
.or-line::before, .or-line::after { content: ''; flex: 1; border-top: 1px solid var(--gold-soft); }
.setup-card { max-width: 560px; text-align: left; }
.setup-card h1, .setup-card > p, .setup-card .seal { text-align: center; }
.setup-card .seal { display: grid; }
.settings-section { margin-bottom: 18px; }
.settings-section h3 { margin: 0 0 12px; }
.settings-section .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; font-size: 13px; background: var(--paper) !important; }
.status-ok { color: #2e7d32; font-weight: 600; }
.status-off { color: var(--muted); }
.dev-login input, input[type='search'], .form input, .form select, .form textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d6c7a6;
  background: #fff;
  width: 100%;
}

/* ---------- Cây phả hệ ---------- */
.tree-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background:
    radial-gradient(circle at 20% 10%, rgba(201, 162, 39, 0.08), transparent 40%),
    var(--paper);
}
.tree-viewport:active { cursor: grabbing; }
.tree-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.gen-band { position: absolute; left: 0; right: 0; border-top: 1px dashed rgba(138, 109, 59, 0.25); }
.gen-band.odd { background: rgba(234, 217, 160, 0.16); }
.gen-label {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  writing-mode: vertical-rl;
  font-family: var(--serif);
  font-weight: 700;
  color: var(--red);
  background: var(--card);
  border: 1px solid var(--gold-soft);
  border-radius: 6px;
  padding: 8px 4px;
  font-size: 13px;
}
.tree-lines { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.line-child { fill: none; stroke: var(--line); stroke-width: 1.6; }
.line-marriage { fill: none; stroke: var(--red); stroke-width: 1.5; }

.person-card {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  text-align: left;
  background: var(--card);
  border: 1.5px solid #c8b58a;
  border-top-width: 4px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}
.person-card:hover { box-shadow: 0 4px 14px rgba(60, 40, 10, 0.25); transform: translateY(-1px); }
.person-card.male { border-top-color: var(--male); background: linear-gradient(180deg, var(--male-bg), var(--card) 60%); }
.person-card.female { border-top-color: var(--female); background: linear-gradient(180deg, var(--female-bg), var(--card) 60%); }
.person-card.in-law { border-style: dashed; border-top-style: solid; }
.person-card.ref { opacity: 0.8; }
.person-card.deceased { filter: saturate(0.55); }
.person-card.deceased .name { color: #3d3326; }
.person-card .mourning {
  position: absolute; right: -14px; top: 6px; width: 50px; height: 8px;
  background: #222; transform: rotate(45deg);
}
.person-card.me { outline: 3px solid var(--gold); outline-offset: 2px; }
.person-card.selected { box-shadow: 0 0 0 3px var(--red), var(--shadow); }
.person-card .avatar {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper-2);
  color: var(--red-dark);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  overflow: hidden;
  border: 1px solid var(--gold-soft);
}
.person-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-card .info { min-width: 0; }
.person-card .name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.person-card .years { font-size: 12px; color: var(--muted); margin-top: 2px; }
.person-card .rel { font-size: 11px; color: var(--red); font-weight: 600; margin-top: 2px; }
.person-card .claimed { position: absolute; right: 6px; bottom: 4px; font-size: 10px; color: #2e7d32; }

/* Tuỳ chọn xem phả đồ */
.view-tools {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: rgba(255, 253, 247, 0.95);
  padding: 6px 8px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: calc(100% - 24px);
}
.view-tools select { padding: 5px 6px; border-radius: 7px; border: 1px solid #d6c7a6; background: #fff; }
.seg-mini { display: inline-flex; border: 1px solid #d6c7a6; border-radius: 8px; overflow: hidden; }
.seg-mini button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; }
.seg-mini button + button { border-left: 1px solid #d6c7a6; }
.seg-mini button.active { background: var(--red); color: #fff8e6; }
.branch-opts { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.branch-opts label { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); }
.branch-opts a { font-weight: 600; cursor: pointer; }
.link-btn { border: 0; background: none; color: var(--red); cursor: pointer; text-decoration: underline; padding: 4px; }

/* Nút nhỏ trên thẻ: mở đời trước / đời sau, thu gọn */
.node-btn {
  position: absolute; z-index: 1;
  min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 11px;
  border: 1.5px solid var(--red);
  background: var(--card);
  color: var(--red);
  font-size: 12px; font-weight: 700; line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(60, 40, 10, 0.25);
}
.node-btn:hover { background: var(--red); color: #fff8e6; }
.node-btn.more { background: var(--red); color: #fff8e6; }
.node-btn.more:hover { background: var(--red-dark); }
.lg.nb { width: auto; height: auto; padding: 0 4px; border: 1.5px solid var(--red); border-radius: 8px; color: var(--red); font-size: 10px; font-weight: 700; line-height: 14px; }

/* Phả đồ ngang: các đời là cột, nhãn "Đời N" ở trên */
.tree-canvas.horizontal .gen-band { top: 0; bottom: 0; left: auto; right: auto; border-top: 0; border-left: 1px dashed rgba(138, 109, 59, 0.25); }
.tree-canvas.horizontal .gen-label { writing-mode: horizontal-tb; left: 50%; top: 14px; transform: translateX(-50%); padding: 4px 10px; }

.tree-tools {
  position: absolute; top: 12px; right: 12px;
  display: flex; gap: 6px; align-items: center;
  background: rgba(255, 253, 247, 0.92);
  padding: 6px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
}
.tree-tools input { width: 180px; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid #d6c7a6;
  background: #fff;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.icon-btn:hover { background: var(--paper-2); }
.legend {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; gap: 12px; flex-wrap: wrap;
  background: rgba(255, 253, 247, 0.92);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: var(--shadow);
}
.lg { display: inline-block; width: 14px; height: 10px; margin-right: 4px; border-radius: 2px; vertical-align: middle; font-style: normal; }
.lg.male { background: var(--male); }
.lg.female { background: var(--female); }
.lg.deceased { background: #222; }
.lg.inlaw { border: 1.5px dashed #a58c55; }
.lg.dot { color: #2e7d32; width: auto; font-size: 10px; }

/* ---------- Bảng thông tin ---------- */
.panel {
  position: fixed;
  top: 64px; right: 0; bottom: 0;
  width: 380px;
  max-width: 100%;
  background: var(--card);
  border-left: 3px solid var(--gold);
  box-shadow: -4px 0 16px rgba(60, 40, 10, 0.15);
  overflow-y: auto;
  z-index: 10;
  padding: 18px 18px 40px;
}
.panel .close { position: absolute; right: 10px; top: 10px; }
.panel-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.panel-head .avatar {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--paper-2); display: grid; place-items: center;
  font-family: var(--serif); font-size: 32px; color: var(--red-dark);
  overflow: hidden; border: 2px solid var(--gold-soft); flex: none;
}
.panel-head .avatar img { width: 100%; height: 100%; object-fit: cover; }
.panel h3 { margin: 0; font-size: 20px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--paper-2);
  color: var(--red-dark);
  margin: 2px 4px 2px 0;
}
.badge.gold { background: var(--gold-soft); }
.badge.green { background: #e2f3e4; color: #2e7d32; }
dl.facts { display: grid; grid-template-columns: 118px 1fr; gap: 6px 10px; margin: 12px 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; word-break: break-word; }
.rel-links a { cursor: pointer; color: var(--red); text-decoration: underline dotted; }
.section-title { font-family: var(--serif); font-weight: 700; color: var(--red-dark); margin: 16px 0 8px; border-bottom: 1px solid var(--gold-soft); padding-bottom: 4px; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bio { white-space: pre-wrap; font-size: 14px; line-height: 1.55; }

/* ---------- Hộp thoại ---------- */
dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(40, 25, 10, 0.45); }
.dlg-head { background: var(--red); color: #fbeecb; padding: 12px 18px; font-family: var(--serif); font-weight: 700; font-size: 17px; }
.dlg-body { padding: 16px 18px; overflow-y: auto; max-height: calc(100vh - 170px); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--gold-soft); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form .full { grid-column: 1 / -1; }
.form fieldset { grid-column: 1 / -1; border: 1px solid var(--gold-soft); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form legend { font-family: var(--serif); color: var(--red-dark); font-weight: 700; padding: 0 6px; }
.form .check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.form .check input { width: auto; }
.form .hint { font-size: 12px; color: var(--muted); grid-column: 1 / -1; margin-top: -4px; }
.seg { display: flex; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 8px; border: 1px solid #d6c7a6; background: #fff; border-radius: 8px; cursor: pointer; }
.seg button.active { background: var(--red); color: #fff8e6; border-color: var(--red); }
.invite-box { display: flex; gap: 6px; margin: 10px 0; }
.invite-box input { flex: 1; font-size: 13px; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Danh sách ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); }
.people-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.people-table th, .people-table td { padding: 8px 10px; border-bottom: 1px solid #eadfc6; text-align: left; white-space: nowrap; }
.people-table th { background: var(--paper-2); font-family: var(--serif); color: var(--red-dark); position: sticky; top: 0; }
.people-table tbody tr { cursor: pointer; }
.people-table tbody tr:hover { background: #fff6dd; }
.people-table td.name { font-weight: 600; white-space: normal; }

/* ---------- Ngày giỗ ---------- */
.gio-list { display: grid; gap: 10px; }
.gio-item {
  display: grid; grid-template-columns: 90px 1fr auto; gap: 14px; align-items: center;
  background: var(--card); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
  border-left: 5px solid var(--red); cursor: pointer;
}
.gio-date { text-align: center; font-family: var(--serif); }
.gio-date .d { font-size: 26px; font-weight: 700; color: var(--red); line-height: 1; }
.gio-date .m { font-size: 12px; color: var(--muted); }
.gio-when { text-align: right; font-size: 13px; }
.gio-when .soon { color: var(--red); font-weight: 700; }

/* ---------- Ảnh đại diện ---------- */
.avatar-picker { display: flex; gap: 14px; align-items: center; }
.avatar-preview {
  flex: none; width: 88px; height: 88px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: var(--paper-2); border: 2px solid var(--gold-soft);
  font-family: var(--serif); font-size: 34px; color: var(--red-dark);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-actions { display: grid; gap: 6px; flex: 1; min-width: 0; }
.panel-head .avatar { position: relative; }
.panel-head .avatar.editable { cursor: pointer; }
.panel-head .avatar.editable:hover { box-shadow: 0 0 0 3px var(--gold); }
.avatar-cam {
  position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; background: var(--card); border: 1px solid var(--gold-soft);
}
.panel-head .avatar { overflow: visible; }
.panel-head .avatar img { border-radius: 50%; }

/* ---------- Đề xuất & nhật ký ---------- */
.tab-badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #fff3c4; color: var(--red-dark);
  font-size: 11px; font-weight: 700; margin-left: 2px;
}
.tabs button.active .tab-badge { background: var(--red); color: #fff8e6; }
.review-card { background: var(--card); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px; border-left: 5px solid var(--gold); }
.review-card.pending { border-left-color: var(--red); }
.review-card .meta { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.review-card .note { background: var(--paper); border-radius: 8px; padding: 6px 10px; font-size: 14px; margin: 6px 0; white-space: pre-wrap; }
.review-card .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
.diff-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.diff-table th, .diff-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #eadfc6; vertical-align: top; word-break: break-word; }
.diff-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.diff-table td.old { color: #8b3a3a; text-decoration: line-through; text-decoration-color: rgba(139, 58, 58, 0.4); }
.diff-table td.new { color: #1f6b2e; font-weight: 600; }
.diff-table .warn { color: #b26a00; font-size: 12px; font-weight: 400; display: block; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.pending { background: #fff3c4; color: #8a5a00; }
.chip.approved { background: #e2f3e4; color: #2e7d32; }
.chip.rejected { background: #fde2e2; color: #a01818; }
.chip.cancelled { background: #eee; color: #666; }
.log-list { display: grid; gap: 8px; }
.log-item { background: var(--card); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 14px; }
.log-item .head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.log-item .when { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-style: italic; }
.mgr-row button { white-space: nowrap; }
.mgr-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--gold-soft); }

/* ---------- Dòng họ ---------- */
.about-card { background: var(--card); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--gold-soft); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0; }
.stat { background: var(--card); border-radius: 12px; padding: 14px; text-align: center; box-shadow: var(--shadow); }
.stat .n { font-family: var(--serif); font-size: 28px; font-weight: 700; color: var(--red); }
.stat .l { font-size: 13px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #2b1d0e; color: #fff8e6; padding: 10px 16px; border-radius: 10px; z-index: 100;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.error { background: #8b0000; }

@media (max-width: 760px) {
  .topbar { padding: 6px 10px; gap: 8px; }
  .brand-title { font-size: 16px; }
  .tabs { order: 3; width: 100%; margin: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs button { flex: none; }
  .tabs button { padding: 5px 8px; font-size: 13px; }
  .user .who { display: none; }
  .panel { top: auto; height: 70vh; width: 100%; border-left: none; border-top: 3px solid var(--gold); border-radius: 14px 14px 0 0; }
  .form, .form fieldset { grid-template-columns: 1fr; }
  .tree-tools input { width: 120px; }
  .view-tools { top: auto; bottom: 10px; left: 8px; right: 8px; max-width: none; }
  .branch-opts { gap: 6px; }
  .legend { display: none; }
  .gio-item { grid-template-columns: 70px 1fr; }
  .gio-when { grid-column: 1 / -1; text-align: left; }
}

@media print {
  body { overflow: visible; background: #fff; }
  .topbar .tabs, .topbar .user, .tree-tools, .view-tools, .node-btn, .legend, .panel { display: none !important; }
  main, .view { position: static; }
  .tree-viewport { overflow: visible; height: auto; }
  .tree-canvas { position: relative; transform: none !important; }
  .person-card { box-shadow: none; }
}

/* ---------- Bản Pro: tài khoản, thành viên, lời mời ---------- */
.login-card .reg-toggle { margin-top: 14px; font-size: 14px; }
.user a.top-link { color: #fbeecb; text-decoration: none; opacity: 0.9; }
.user a.top-link:hover { opacity: 1; text-decoration: underline; }
.page-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0 16px; border-bottom: 2px solid var(--gold-soft); }
.page-tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; color: var(--muted); }
.page-tabs button.active { color: var(--red-dark); border-bottom-color: var(--red); font-weight: 600; }
.plain-table tbody tr { cursor: default; }
.plain-table tbody tr:hover { background: none; }
.plain-table td { white-space: normal; vertical-align: middle; }
.plain-table select { padding: 4px 6px; border-radius: 6px; border: 1px solid #d6c7a6; background: #fff; }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 8px; background: var(--paper-2); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.picker { display: grid; gap: 6px; }
.picker-results { display: grid; gap: 2px; max-height: 180px; overflow-y: auto; }
.picker-results button { text-align: left; border: 1px solid #eadfc6; background: #fff; border-radius: 6px; padding: 5px 8px; cursor: pointer; }
.picker-results button:hover, .picker-results button.chosen { background: var(--gold-soft); }
.picker-results button:disabled { opacity: 0.55; cursor: not-allowed; }
.danger-zone { border-color: #e7b3b3; }
.card-stack { display: grid; gap: 18px; }
@media (max-width: 640px) {
  .form, .form fieldset { grid-template-columns: 1fr; }
}
