/* 家谱族谱系统 · 网络版 —— 中式典雅风格 */
:root {
  --paper: #f7f4ec;
  --paper-deep: #efe9db;
  --ink: #2b2b28;
  --ink-soft: #5c5a52;
  --brown: #6d4c2f;
  --brown-deep: #553a22;
  --cinnabar: #b5432a;
  --gold: #a8894c;
  --line: #ddd5c3;
  --card: #fffdf8;
  --ok: #3d7a44;
  --err: #b5432a;
  --serif: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", "Songti SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle at 20% 10%, rgba(168,137,76,.06), transparent 40%),
                    radial-gradient(circle at 85% 90%, rgba(109,76,47,.07), transparent 45%);
}
#app { position: relative; z-index: 1; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; }
a { color: var(--brown); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 20px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brown); color: #fff; font-size: 14px;
  transition: all .18s;
}
.btn:hover { background: var(--brown-deep); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brown); border-color: var(--brown); }
.btn.ghost:hover { background: rgba(109,76,47,.08); }
.btn.danger { background: #fff; color: var(--cinnabar); border-color: var(--cinnabar); }
.btn.danger:hover { background: var(--cinnabar); color: #fff; }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn.linklike { background: none; border: none; color: var(--brown); padding: 2px 6px; }
.btn.linklike:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247,244,236,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px; height: 58px;
}
.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--brown-deep);
  letter-spacing: 2px;
}
.topbar .brand .seal {
  width: 34px; height: 34px; border-radius: 8px; background: var(--brown);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700;
}
.topbar .spacer { flex: 1; }
.topbar .user-chip { color: var(--ink-soft); font-size: 14px; display: flex; align-items: center; gap: 10px; }

/* ---------- 登录页 ---------- */
.auth-wrap {
  min-height: calc(100vh - 58px);
  display: flex; align-items: center; justify-content: center;
  padding: 30px 16px;
}
.auth-card {
  width: 400px; max-width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(85,58,34,.12);
  padding: 40px 38px 34px;
}
.auth-card h1 { font-size: 26px; color: var(--brown-deep); text-align: center; letter-spacing: 4px; }
.auth-card .sub { text-align: center; color: var(--ink-soft); font-size: 13px; margin: 8px 0 26px; letter-spacing: 1px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.auth-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; background: #fff; font-family: inherit; outline: none;
}
.auth-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(168,137,76,.15); }
.auth-card .alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--ink-soft); }
.auth-card .divider { text-align: center; margin: 22px 0 14px; color: var(--gold); font-size: 12px; letter-spacing: 2px; }

/* ---------- 页面容器 ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 26px 22px 60px; }
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h2 { font-size: 24px; color: var(--brown-deep); letter-spacing: 2px; }
.page-head .desc { color: var(--ink-soft); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; }

/* ---------- 家谱卡片 ---------- */
.tree-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.tree-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px; cursor: pointer; position: relative;
  transition: all .2s;
}
.tree-card:hover { box-shadow: 0 8px 26px rgba(85,58,34,.14); transform: translateY(-2px); border-color: var(--gold); }
.tree-card h3 { font-size: 19px; color: var(--ink); margin-bottom: 4px; }
.tree-card .role-tag {
  display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 20px;
  background: rgba(168,137,76,.15); color: var(--brown); margin-bottom: 12px;
}
.tree-card .role-tag.owner { background: rgba(181,67,42,.12); color: var(--cinnabar); }
.tree-card .meta { color: var(--ink-soft); font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; }
.tree-card .ops { position: absolute; top: 14px; right: 14px; display: flex; gap: 4px; }
.empty-hint {
  text-align: center; color: var(--ink-soft); padding: 70px 0;
  font-family: var(--serif); font-size: 16px; letter-spacing: 2px;
}

/* ---------- 工作台 ---------- */
.workbench-tabs {
  display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 22px;
  overflow-x: auto;
}
.workbench-tabs .tab {
  padding: 10px 22px; font-size: 15px; color: var(--ink-soft); border: none;
  background: none; border-bottom: 3px solid transparent; margin-bottom: -2px;
  white-space: nowrap; font-family: var(--serif); letter-spacing: 1px;
}
.workbench-tabs .tab.active { color: var(--brown-deep); border-bottom-color: var(--cinnabar); font-weight: 700; }
.workbench-tabs .tab:hover { color: var(--brown-deep); }

/* ---------- 世系树 ---------- */
.tree-scroll { overflow: auto; padding: 30px 10px 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.generation-row { display: flex; align-items: flex-start; position: relative; }
.gen-label {
  writing-mode: vertical-lr; text-orientation: upright;
  font-family: var(--serif); font-size: 13px; color: var(--gold);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 5px;
  background: rgba(168,137,76,.08); margin-right: 18px; flex: none;
  align-self: flex-start; position: sticky; left: 0; z-index: 5;
}
.tree-canvas { position: relative; }
.node {
  position: absolute; width: 120px; text-align: center; cursor: pointer;
}
.node .photo {
  width: 62px; height: 62px; border-radius: 50%; margin: 0 auto 6px;
  border: 2px solid var(--gold); background: var(--paper-deep) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 24px; color: var(--brown);
  overflow: hidden; position: relative; z-index: 2;
}
.node.female .photo { border-color: var(--cinnabar); }
.node.deceased .photo { filter: grayscale(.7); opacity: .85; }
.node .nm { font-size: 14px; font-weight: 600; color: var(--ink); font-family: var(--serif); }
.node .yr { font-size: 11px; color: var(--ink-soft); margin-top: 1px; }
.node .spouse-tag {
  display: inline-block; font-size: 10px; color: var(--gold); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 6px; margin-left: 3px;
}
.node.selected .photo { border-color: var(--cinnabar); box-shadow: 0 0 0 4px rgba(181,67,42,.18); }
.tree-svg { position: absolute; inset: 0; pointer-events: none; }

/* ---------- 成员表格 ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
table.members { width: 100%; border-collapse: collapse; font-size: 14px; }
table.members th {
  text-align: left; padding: 12px 14px; background: rgba(109,76,47,.06);
  color: var(--brown-deep); font-weight: 600; font-family: var(--serif); white-space: nowrap;
}
table.members td { padding: 11px 14px; border-top: 1px solid var(--paper-deep); white-space: nowrap; }
table.members tr:hover td { background: rgba(168,137,76,.05); }
table.members .lunar { color: var(--ink-soft); font-size: 12px; display: block; }
.badge { display: inline-block; min-width: 22px; text-align: center; font-size: 12px; border-radius: 6px; padding: 1px 7px; background: rgba(168,137,76,.15); color: var(--brown); }
.badge.male { background: rgba(85,110,160,.15); color: #3e5488; }
.badge.female { background: rgba(181,67,42,.13); color: var(--cinnabar); }
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text], .toolbar select {
  padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  background: #fff; outline: none; font-family: inherit;
}
.toolbar input[type=text]:focus { border-color: var(--gold); }
.toolbar .count { color: var(--ink-soft); font-size: 13px; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
.stat-card .num { font-size: 34px; font-family: var(--serif); color: var(--brown-deep); font-weight: 700; }
.stat-card .lab { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-bottom: 20px; }
.chart-card h3 { font-size: 16px; color: var(--brown-deep); margin-bottom: 18px; letter-spacing: 1px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding: 0 6px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bars .bar { width: 70%; max-width: 46px; background: linear-gradient(180deg, var(--gold), var(--brown)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar-val { font-size: 12px; color: var(--ink-soft); }
.bars .bar-lab { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* ---------- 详情侧栏 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(43,43,40,.45); z-index: 90; animation: fadeIn .2s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw; z-index: 91;
  background: var(--card); box-shadow: -12px 0 40px rgba(43,43,40,.2);
  overflow-y: auto; padding: 26px 26px 40px; animation: slideIn .22s;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer h3 { font-size: 22px; color: var(--brown-deep); margin-bottom: 4px; }
.drawer .close-x { position: absolute; top: 16px; right: 16px; }
.drawer .avatar-lg {
  width: 88px; height: 88px; border-radius: 50%; margin: 14px 0 6px;
  background: var(--paper-deep) center/cover no-repeat; border: 3px solid var(--gold);
  display: flex; align-items: center; justify-content: center; font-family: var(--serif);
  font-size: 34px; color: var(--brown);
}
.dl { margin: 16px 0; }
.dl .row { display: flex; padding: 8px 0; border-bottom: 1px dashed var(--paper-deep); font-size: 14px; }
.dl .row .k { width: 84px; color: var(--ink-soft); flex: none; }
.dl .row .v { flex: 1; color: var(--ink); word-break: break-all; }
.dl .row .v .lunar-sub { display: block; color: var(--gold); font-size: 12.5px; margin-top: 2px; }
.drawer .sec-title { font-family: var(--serif); font-size: 15px; color: var(--brown-deep); margin: 22px 0 10px; letter-spacing: 1px; }
.rel-list .rel-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.rel-list .rel-item .tag { flex: none; font-size: 12px; color: var(--gold); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; }
.bio { font-size: 14px; color: var(--ink-soft); line-height: 1.8; white-space: pre-wrap; }
.drawer .op-row { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(43,43,40,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .2s; }
.modal {
  background: var(--card); border-radius: 14px; width: 520px; max-width: 100%;
  max-height: 92vh; overflow-y: auto; padding: 26px 28px;
  box-shadow: 0 24px 70px rgba(43,43,40,.28);
  animation: popIn .2s;
}
@keyframes popIn { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 19px; color: var(--brown-deep); margin-bottom: 18px; letter-spacing: 1px; }
.modal .field { margin-bottom: 14px; }
.modal .field > label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.modal .field input[type=text], .modal .field textarea, .modal .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; outline: none; font-family: inherit;
}
.modal .field textarea { min-height: 90px; resize: vertical; }
.modal .field input:focus, .modal .field textarea:focus { border-color: var(--gold); }
.modal .radio-row { display: flex; gap: 10px; }
.modal .radio-row .opt {
  flex: 1; text-align: center; padding: 9px 0; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; cursor: pointer; background: #fff;
}
.modal .radio-row .opt.active { border-color: var(--brown); background: rgba(109,76,47,.08); color: var(--brown-deep); font-weight: 600; }
.modal .btn-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.datefield { display: flex; gap: 8px; align-items: center; }
.datefield .date-btn {
  flex: 1; text-align: left; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px;
  background: #fff; color: var(--ink-soft); font-size: 14px;
}
.datefield .date-btn.set { border-style: solid; color: var(--ink); }
.datefield .date-btn .sub { display: block; font-size: 12px; color: var(--gold); }

/* ---------- 农历日期选择器 ---------- */
.dp .cal-tabs { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.dp .cal-tabs .t { flex: 1; padding: 9px 0; text-align: center; background: #fff; border: none; font-size: 14px; color: var(--ink-soft); }
.dp .cal-tabs .t.active { background: var(--brown); color: #fff; font-weight: 600; }
.dp .wheels { display: flex; gap: 10px; }
.dp .wheel-col { flex: 1.3; }
.dp .wheel-col.wide { flex: 2; }
.dp .wheel {
  height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; scroll-snap-type: y mandatory; position: relative;
}
.dp .wheel::before, .dp .wheel::after {
  content: ""; position: sticky; left: 0; right: 0; height: calc(50% - 22px); display: block; z-index: 1;
  background: linear-gradient(#fff, rgba(255,255,255,.6)); pointer-events: none;
}
.dp .wheel::after { background: linear-gradient(rgba(255,255,255,.6), #fff); }
.dp .wheel .opt-w { height: 44px; scroll-snap-align: center; display: flex; align-items: center; justify-content: center; }
.dp .wheel .opt-w span {
  font-size: 14.5px; padding: 3px 12px; border-radius: 6px; color: var(--ink);
}
.dp .wheel .opt-w.sel span { background: rgba(109,76,47,.12); color: var(--brown-deep); font-weight: 700; }
.dp .wheel .opt-w.leap span { color: var(--cinnabar); }
.dp .conv {
  margin-top: 16px; background: rgba(168,137,76,.08); border: 1px solid rgba(168,137,76,.25);
  border-radius: 10px; padding: 12px 16px; font-size: 13.5px; color: var(--brown-deep);
  min-height: 46px;
}
.dp .conv b { font-family: var(--serif); }
.dp .hint { margin-top: 6px; font-size: 12px; color: var(--ink-soft); }

/* ---------- toast ---------- */
#toast-root { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 26px rgba(0,0,0,.25); animation: popIn .18s;
}
.toast.err { background: var(--cinnabar); }
.toast.ok { background: var(--ok); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .page { padding: 18px 12px 80px; }
  .topbar { padding: 0 12px; }
  .drawer { width: 100vw; max-width: 100vw; }
  .modal { padding: 20px 16px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .gen-label { display: none; }
}

/* ---------- 顶栏链接 ---------- */
.toplink { color: var(--brown); font-size: 15px; text-decoration: none; padding: 8px 12px; margin-left: 8px; border-radius: 8px; }
.toplink:hover { color: var(--cinnabar); background: rgba(168,50,50,.08); text-decoration: none; }

/* ---------- 个人信息 ---------- */
.profile-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px 30px; }
.profile-row { display: flex; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--paper-deep); }
.profile-row:last-of-type { border-bottom: none; }
.profile-row label { width: 110px; color: var(--ink-soft); font-size: 14px; flex: none; }
.profile-row span { color: var(--ink); font-size: 15px; }
.profile-actions { display: flex; gap: 12px; margin-top: 22px; }

/* ---------- 用户管理表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
.table th {
  text-align: left; padding: 12px 14px; background: rgba(109,76,47,.06);
  color: var(--brown-deep); font-weight: 600; font-family: var(--serif); white-space: nowrap;
}
.table td { padding: 11px 14px; border-top: 1px solid var(--paper-deep); white-space: nowrap; }
.table tr:hover td { background: rgba(168,137,76,.05); }
.table select {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
  background: #fff; outline: none; font-family: inherit; color: var(--ink);
}
.table select:disabled { background: var(--paper-deep); color: #999; }
.table .ops { display: flex; gap: 4px; }

/* 礼簿统计可视化卡片 */
.stat-card { flex: 1; min-width: 120px; }
.stat-card .stat-num { font-size: 22px; font-family: var(--serif); color: var(--cinnabar, #a83232); font-weight: 700; }
.stat-card .stat-label { color: var(--ink-soft); font-size: 12px; margin-top: 4px; }

/* ---------- 移动端底部导航（APK 固定底部、按键加大） ---------- */
.mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 99; display: flex; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.06); padding-bottom: env(safe-area-inset-bottom); }
.mn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 10px 4px; text-decoration: none; color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.mn-item .mn-ic { font-size: 24px; line-height: 1; }
.mn-item.active { color: var(--cinnabar); }
.mn-item:hover { color: var(--cinnabar); }
.mn-item:active { color: var(--cinnabar); }

/* ---------- 主页模块门户 ---------- */
.portal-page { padding-top: 16px; }
.portal-hero { text-align: center; margin: 6px 0 26px; }
.portal-hero h2 { font-size: 26px; color: var(--brown-deep); margin: 0; letter-spacing: 2px; }
.portal-hero .desc { color: var(--ink-soft); font-size: 14px; }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.portal-card { --ac: var(--cinnabar); display: block; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 20px; text-align: center; text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.portal-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,.10); border-color: var(--ac); }
.portal-ic { font-size: 44px; line-height: 1; }
.portal-title { font-size: 19px; font-weight: 700; color: var(--ink); margin: 14px 0 6px; }
.portal-desc { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.portal-go { margin-top: 14px; font-size: 14px; color: var(--ac); font-weight: 600; }

/* ---------- 礼簿详情：Tab 与大气录入表单 ---------- */
.ledger-tabs { display: flex; gap: 10px; margin: 16px 0 4px; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.ltab { background: none; border: none; padding: 12px 22px; font-size: 16px; font-weight: 600; color: var(--ink-soft); cursor: pointer; position: relative; }
.ltab.active { color: var(--cinnabar); }
.ltab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 3px; background: var(--cinnabar); border-radius: 2px; }
.ltab .ltab-cnt { font-size: 13px; color: var(--gold); margin-left: 4px; }
.ledger-pane { margin-top: 2px; }
.ledger-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-items: end; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 14px 0; }
.ledger-form .lf-field { display: flex; flex-direction: column; gap: 5px; }
.ledger-form .lf-field label { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.ledger-form .lf-field input { height: 44px; font-size: 15px; }
.ledger-form .lf-add { height: 44px; padding: 0 24px; font-size: 15px; font-weight: 600; }

/* ---------- 礼簿卡片图标美化 ---------- */
.ledger-card { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px 18px; }
.ledger-card .lc-ic { font-size: 38px; flex: none; }
.ledger-card .lc-body { flex: 1; min-width: 0; }
.ledger-card .ledger-type-tag { position: absolute; top: 10px; right: 12px; font-size: 12px; padding: 2px 10px; border-radius: 12px; font-weight: 600; }
.ledger-card.red .ledger-type-tag { background: rgba(168,50,50,.12); color: #a83232; }
.ledger-card.white .ledger-type-tag { background: rgba(90,90,110,.12); color: #5a5a6e; }
.ledger-card.red { background: linear-gradient(135deg, #fff 55%, #fdeaea); }
.ledger-card.white { background: linear-gradient(135deg, #fff 55%, #eef1f5); }
.ledger-card .ledger-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.ledger-card .ledger-meta { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.ledger-card .ledger-count { font-size: 13px; color: var(--gold); margin-top: 6px; font-weight: 600; }

/* ---------- 家谱卡片图标美化 ---------- */
.tree-card .tc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.tree-card .tc-ic { font-size: 40px; }
.tree-card .meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ================= 家谱工作台统一排版优化 ================= */
/* 工作台 Tabs */
.workbench-tabs { display: flex; gap: 2px; margin: 2px 0 20px; border-bottom: 2px solid var(--line); overflow-x: auto; }
.workbench-tabs .tab { padding: 13px 20px; font-size: 15px; color: var(--ink-soft); background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; white-space: nowrap; }
.workbench-tabs .tab.active { color: var(--cinnabar); border-bottom-color: var(--cinnabar); font-weight: 700; }
.workbench-tabs .tab:hover { color: var(--brown-deep); }

/* 通用表格统一 */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
.table th { background: var(--paper); color: var(--brown-deep); font-weight: 600; padding: 12px 14px; text-align: left; border-bottom: 2px solid var(--line); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table td { padding: 12px 14px; border-top: 1px solid var(--paper-deep); white-space: nowrap; }
.table tbody tr:nth-child(even) { background: rgba(168,137,76,.05); }
.table tr:hover td { background: rgba(168,137,76,.09); }
.table .ops { display: flex; gap: 4px; justify-content: flex-end; }

/* 工具栏输入框统一高度 */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text], .toolbar select { height: 40px; }

/* 信息块标题统一 */
.page .section-title, .page .wb-section h3, .page h3.blk { font-size: 17px; font-weight: 700; color: var(--brown-deep); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }

/* 通用面板/卡片圆角阴影统一 */
.page .card, .page .panel, .page .info-card, .page .blk { border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
/* =========================================================
   世系图 & 字辈谱 —— 专业美化（v7.4 竖式书籍）
   追加到基准 style 末尾，覆盖同名样式为增强版
   ========================================================= */
:root {
  --red: #b3271e;
  --book-paper: #f7f0e0;
  --book-paper-deep: #efe4cc;
  --book-line: #c9b691;
  --ink-line: #3d4f44;
}

/* ---------- 世系树容器（纸面感） ---------- */
.tree-scroll {
  overflow: auto; padding: 34px 20px 44px;
  border: 1px solid var(--book-line); border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(168,137,76,.04), transparent 10%, transparent 90%, rgba(168,137,76,.04)),
    linear-gradient(180deg, #fdfaf2, #f6efe0);
  box-shadow: inset 0 0 46px rgba(168,137,76,.05), 0 4px 16px rgba(85,58,34,.06);
}

/* ---------- 缩放条 ---------- */
.tree-zoombar {
  display: flex; align-items: center; gap: 6px; margin-bottom: 12px;
}
.tree-zoom-btn {
  min-width: 32px; height: 32px; border: 1px solid var(--book-line); border-radius: 8px;
  background: var(--card); color: var(--brown-deep); font-size: 16px; cursor: pointer;
  font-family: var(--serif); transition: all .15s;
}
.tree-zoom-btn:hover { border-color: var(--gold); color: var(--red); box-shadow: 0 2px 8px rgba(168,137,76,.18); }
.tree-zoom-pct { min-width: 54px; text-align: center; font-size: 13px; color: var(--brown-deep); font-family: var(--serif); }

/* ---------- 世代标签 ---------- */
.gen-label {
  writing-mode: vertical-lr; text-orientation: upright;
  font-family: var(--serif); font-size: 13px; color: var(--red);
  border: 1px solid var(--gold); border-radius: 8px; padding: 12px 6px;
  background: linear-gradient(180deg, rgba(168,137,76,.16), rgba(168,137,76,.06));
  margin-right: 18px; flex: none; align-self: flex-start; position: sticky; left: 0; z-index: 5;
  box-shadow: 0 2px 6px rgba(168,137,76,.12); letter-spacing: 4px;
}

/* ---------- 图形模式节点（古籍卷轴卡片） ---------- */
.node {
  position: absolute; width: 124px; text-align: center; cursor: pointer;
  background: linear-gradient(180deg, #fffdf6, #f8f1e2);
  border: 1px solid var(--book-line); border-radius: 10px; padding: 10px 6px 8px;
  transition: transform .15s, box-shadow .15s; z-index: 2;
}
.node:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(85,58,34,.14); z-index: 8; }
.node .photo {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 7px;
  border: 2px solid var(--gold); background: var(--paper-deep) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 25px; color: var(--brown);
  overflow: hidden; position: relative;
}
.node.female .photo { border-color: var(--cinnabar); }
.node.deceased .photo { filter: grayscale(.75); opacity: .85; }
.node.deceased .nm { color: #9a9184; }
.node.root .photo { border-color: var(--red); box-shadow: 0 0 0 3px rgba(181,67,42,.14), 0 2px 8px rgba(85,58,34,.16); }
.node .nm { font-size: 14px; font-weight: 700; color: var(--ink); font-family: var(--serif); letter-spacing: 1px; }
.node .yr { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.node .spouse-tag {
  display: inline-block; font-size: 10px; color: var(--gold); border: 1px solid var(--gold);
  border-radius: 10px; padding: 0 6px; margin-left: 3px; background: rgba(168,137,76,.08);
}
.node .fangxu-tag {
  display: inline-block; font-size: 10px; color: var(--red); border: 1px solid var(--cinnabar);
  border-radius: 10px; padding: 0 5px; margin-left: 3px; background: rgba(181,67,42,.06);
}
.node.selected { border-color: var(--red); box-shadow: 0 0 0 3px rgba(181,67,42,.14), 0 6px 16px rgba(85,58,34,.16); }

/* ---------- 关系连线 ---------- */
.rel-line { stroke: var(--book-line); stroke-width: 1.4; fill: none; }
.rel-dot { fill: var(--gold); }
.node.selected ~ svg .rel-line { stroke: var(--red); }

/* ---------- 书籍式·竖式古籍 ---------- */
.book-vwrap {
  display: flex; flex-direction: row-reverse; flex-wrap: wrap; align-items: flex-start; gap: 22px;
  background:
    linear-gradient(90deg, rgba(168,137,76,.05), transparent 7%, transparent 93%, rgba(168,137,76,.05)),
    linear-gradient(180deg, #fbf6e9, #f2e9d4);
  border: 1px solid var(--book-line); border-radius: 6px;
  box-shadow: inset 0 0 50px rgba(168,137,76,.06), 0 6px 22px rgba(85,58,34,.10);
  padding: 34px 22px 24px; min-height: 300px; position: relative;
}
/* 书眉 */
.book-vwrap::before {
  content: '族谱 · 世系'; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  font-family: var(--serif); font-size: 13px; letter-spacing: 8px; color: rgba(168,137,76,.5);
  white-space: nowrap;
}
.book-vwrap::after { display: none; }
.book-gen {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
  background: linear-gradient(180deg, #fffdf4, #f6eeda);
  border: 1px solid var(--book-line); border-radius: 10px;
  box-shadow: 0 2px 8px rgba(85,58,34,.05);
  padding: 14px 16px;
  width: auto; max-width: 100%;
}
.book-gen-tag {
  font-family: var(--serif); color: #fff; font-weight: 700; font-size: 16px;
  letter-spacing: 6px; text-align: center; align-self: center; margin-bottom: 12px;
  background: linear-gradient(180deg, #c0492e, #a83825);
  border-radius: 20px; padding: 4px 20px; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(181,67,42,.25);
}
.book-gen-body { display: flex; flex-direction: row; flex-wrap: wrap; gap: 16px; align-items: flex-start; justify-content: flex-start; }
.book-vcard {
  writing-mode: vertical-rl; text-orientation: mixed;
  background: linear-gradient(180deg, #fffdf4, #f6eeda);
  border: 1px solid var(--book-line); border-left: 2px solid var(--gold);
  border-radius: 4px; padding: 14px 10px; min-height: 120px; max-height: 380px;
  cursor: pointer; transition: all .18s; letter-spacing: 2px;
  box-shadow: 0 2px 5px rgba(85,58,34,.05);
}
.book-vcard:hover {
  box-shadow: 0 6px 18px rgba(181,67,42,.12);
  transform: translateY(-2px); border-left-color: var(--red);
}
.book-vcard.female { border-left-color: var(--cinnabar); }
.book-vcard.deceased { background: linear-gradient(180deg,#f4efe6,#eae3d5); }
.book-vcard.deceased .bv-name { color: #9a9184; }
.bv-name { font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--ink); }
.bv-fangxu {
  font-style: normal; font-size: 11px; color: var(--gold);
  border: 1px solid var(--gold); border-radius: 4px; padding: 1px 5px; letter-spacing: 0;
  background: rgba(168,137,76,.06);
}
.bv-rel { font-size: 13px; color: var(--red); margin-top: 12px; }
.bv-year { font-size: 12px; color: var(--ink-soft); margin-top: 12px; }
.bv-extra { font-size: 12px; color: var(--ink-soft); margin-top: 12px; }
.book-foot { text-align: center; color: var(--gold); font-family: var(--serif); margin-top: 22px; letter-spacing: 4px; font-size: 14px; }

/* ---------- 吊线式 ---------- */
.thread-node {
  position: absolute; min-width: 96px; text-align: center; cursor: pointer; z-index: 3;
  background: linear-gradient(180deg, #fffdf6, #f6efdf);
  border: 1px solid var(--book-line); border-top: 2px solid var(--gold);
  border-radius: 6px; padding: 8px 10px;
  box-shadow: 0 2px 6px rgba(85,58,34,.06); transition: all .15s;
}
.thread-node:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(85,58,34,.14); }
.thread-node .tn-name { font-family: var(--serif); font-weight: 700; font-size: 14px; color: var(--ink); letter-spacing: 1px; }
.thread-node .tn-sub { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.thread-node .tn-spouse { font-size: 11px; color: var(--red); margin-top: 3px; }
.thread-node .fangxu-tag {
  display: inline-block; font-size: 10px; color: var(--gold); border: 1px solid var(--gold);
  border-radius: 9px; padding: 0 5px; margin-left: 2px;
}
.thread-line { stroke: var(--book-line); stroke-width: 1.4; fill: none; }
.marriage-line { stroke: var(--cinnabar); stroke-width: 1; stroke-dasharray: 4 3; fill: none; opacity: .6; }

/* ---------- 字辈谱 ---------- */
.zibei-card .zibei-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.zibei-poem {
  font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: 16px; color: var(--brown-deep);
  text-align: center; padding: 28px 22px; line-height: 2;
  background:
    linear-gradient(180deg, rgba(168,137,76,.06), rgba(168,137,76,.12)),
    repeating-linear-gradient(0deg, transparent 0 40px, rgba(168,137,76,.05) 40px 41px);
  border: 1px solid rgba(168,137,76,.35); border-radius: 12px; margin-top: 6px;
  word-break: break-all; text-shadow: 0 1px 0 rgba(255,255,255,.5);
}
.zb-sentence { display: inline-block; padding: 2px 6px; margin: 0 2px; }
/* 字辈逐字卡片（印章款） */
.zb-poem-chars {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin-top: 16px; padding: 18px 12px;
  background: var(--paper-deep); border: 1px dashed var(--gold); border-radius: 12px;
}
.zb-pchar {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 52px; padding: 8px 6px 6px;
  border: 1px solid var(--book-line); border-radius: 10px; background: var(--card);
  position: relative; box-shadow: 0 2px 5px rgba(85,58,34,.04); transition: all .15s;
}
.zb-pchar:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(168,137,76,.14); }
.zb-pchar b { font-family: var(--serif); font-size: 24px; color: var(--brown-deep); line-height: 1.2; }
.zb-pchar i { font-style: normal; font-size: 10.5px; color: var(--ink-soft); }
.zb-pchar em {
  position: absolute; top: -8px; right: -6px; font-style: normal;
  font-size: 10px; color: #fff; background: var(--cinnabar); border-radius: 8px; padding: 0 6px;
}
.zb-pchar.st-match { border-color: rgba(64,145,108,.5); background: rgba(64,145,108,.05); }
.zb-pchar.st-match b { color: #2d6a4f; }
.zb-pchar.st-mismatch { border-color: rgba(214,138,60,.6); background: rgba(214,138,60,.08); }
.zb-pchar.st-mismatch b { color: #b3541e; }
.zb-pchar.st-empty, .zb-pchar.st-future { opacity: .55; }
.zb-pchar.st-beyond { border-style: dashed; border-color: var(--gold); }
/* 字辈统计 */
.zb-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.zb-stat {
  flex: 1 1 112px; min-width: 112px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 8px;
  transition: all .15s;
}
.zb-stat:hover { border-color: var(--gold); box-shadow: 0 3px 10px rgba(168,137,76,.1); }
.zb-stat b { display: block; font-size: 28px; font-family: var(--serif); color: var(--brown-deep); line-height: 1.2; }
.zb-stat span { font-size: 12px; color: var(--ink-soft); }
.zb-stat.ok b { color: #40916c; }
.zb-stat.warn b { color: #d68a3c; }
.zb-stat.gray b { color: #999; }
.zb-stat.blue b { color: #5a7fb4; }
.zb-stat.rate { border-color: rgba(168,137,76,.5); background: rgba(168,137,76,.08); }
.zb-stat.rate b { color: var(--gold); }
/* 偏离提示 */
.zb-tips {
  margin-top: 14px; padding: 14px 16px;
  background: rgba(214,138,60,.07); border: 1px solid rgba(214,138,60,.32); border-radius: 10px;
  font-size: 13px; color: #8a5a20; line-height: 1.9;
}
.zb-tip-title { font-weight: 700; margin-bottom: 4px; }
.zb-tip { padding-left: 8px; }
/* 状态徽章 */
.zb-status {
  display: inline-block; padding: 3px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.zb-status.st-match { color: #2d6a4f; background: rgba(64,145,108,.14); }
.zb-status.st-mismatch { color: #b3541e; background: rgba(214,138,60,.16); }
.zb-status.st-empty { color: #777; background: rgba(0,0,0,.05); }
.zb-status.st-beyond { color: #3d5a80; background: rgba(90,127,180,.14); }
/* 字辈对照字符 */
.zibei-char {
  display: inline-block; font-family: var(--serif); font-size: 17px; color: var(--red);
  border: 1px solid rgba(181,67,42,.35); border-radius: 8px; padding: 2px 10px; margin: 3px 4px 3px 0;
  background: rgba(181,67,42,.06);
}
.zibei-char.main { border-color: var(--gold); background: rgba(168,137,76,.16); font-weight: 700; color: var(--brown-deep); }
.zb-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 2px 0 8px; vertical-align: middle; }
.zb-dot.st-match { background: #40916c; }
.zb-dot.st-mismatch { background: #d68a3c; }
.zb-dot.st-empty { background: #bbb; }
.zb-dot.st-beyond { background: #5a7fb4; }

/* ========== 世系图 & 工作台 按钮美化（v7.3.3+） ========== */
/* 世系图工具栏 */
.tree-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center;
  margin: 0 0 16px; padding: 12px 16px;
  background: linear-gradient(180deg, #fffdf6, #f8f1e3);
  border: 1px solid var(--book-line); border-radius: 12px;
  box-shadow: 0 2px 8px rgba(85,58,34,.05);
}
.tree-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.tm-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 20px;
  border: 1px solid var(--book-line); background: var(--card);
  color: var(--brown-deep); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .18s; box-shadow: 0 1px 3px rgba(85,58,34,.06);
}
.tm-btn .tm-ic { font-size: 16px; }
.tm-btn:hover { border-color: var(--gold); box-shadow: 0 2px 8px rgba(168,137,76,.18); transform: translateY(-1px); }
.tm-btn.active {
  background: linear-gradient(180deg, #c0492e, #a83825); color: #fff;
  border-color: #a83825; box-shadow: 0 3px 10px rgba(181,67,42,.3);
}
.tree-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.tf-btn {
  padding: 6px 18px; border-radius: 16px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  font-size: 13px; cursor: pointer; transition: all .18s;
}
.tf-btn:hover { border-color: var(--gold); color: var(--brown-deep); }
.tf-btn.active {
  background: linear-gradient(180deg, #c0492e, #a83825); color: #fff;
  border-color: #a83825; font-weight: 600; box-shadow: 0 2px 6px rgba(181,67,42,.25);
}
/* 家族资料次级标签 */
.archive-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.archive-head { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.atab {
  padding: 7px 18px; border-radius: 18px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  font-size: 14px; cursor: pointer; transition: all .18s;
}
.atab:hover { border-color: var(--gold); color: var(--brown-deep); }
.atab.active {
  background: linear-gradient(180deg, #c0492e, #a83825); color: #fff;
  border-color: #a83825; font-weight: 600; box-shadow: 0 2px 8px rgba(181,67,42,.25);
}

/* ========== 导出/导入下拉菜单（v7.3.5+ 修复平铺占位，收为下拉） ========== */
.menu-wrap { position: relative; display: inline-block; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; z-index: 60;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(43,43,40,.16); padding: 6px;
  display: none;
}
.menu.open { display: block; animation: menuIn .15s; }
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.menu-item {
  padding: 9px 14px; font-size: 14px; color: var(--ink); border-radius: 7px;
  cursor: pointer; white-space: nowrap;
}
.menu-item:hover { background: rgba(109,76,47,.08); color: var(--brown-deep); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 8px; }
/* APK 窄屏：菜单不溢出屏幕右缘 */
@media (max-width: 640px) {
  .menu { min-width: 170px; }
}

/* ========== 世系图全屏层（v7.3.6+ 修复点击模式全屏，样式曾随合并丢失） ========== */
.tree-fs {
  position: fixed; inset: 0; z-index: 85;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.tree-fs-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  height: 50px; padding: 0 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.tree-fs-title { font-weight: 600; font-size: 15px; color: var(--brown-deep); letter-spacing: 1px; }
.tree-fs-close {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.tree-fs-close:active { background: rgba(168,137,76,.14); }
.tree-fs-body {
  flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
  padding: 12px 10px 20px;
}
.tree-fs-body .tree-zoombar { flex: none; }
.tree-fs-body .tree-scroll { flex: 1; min-height: 0; margin-top: 8px; }
.tree-fs-body .tree-zoom-btn { width: 42px; height: 42px; font-size: 18px; }
.tree-fs-body .tree-zoom-pct { font-size: 13px; min-width: 50px; }
