/* ============================================================
 * style.css —— 家族电子族谱（手机优先，电脑兼容）
 * 配色：传统红(#8a1f1f) + 米黄(#f7f2e8) + 金(#e6be5a)
 * ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #8a1f1f;
  --primary-light: #a83232;
  --gold: #e6be5a;
  --bg: #f7f2e8;
  --card: #ffffff;
  --text: #2c2c2c;
  --muted: #888;
  --male: #4a90d9;
  --female: #e88aa0;
  --border: #e5ddc8;
}
html, body {
  height: 100%;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "楷体", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ---------- 顶部栏 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.header-title { font-size: 17px; font-weight: 600; }
.icon-btn { color: #fff; font-size: 20px; padding: 4px 8px; }

/* ---------- 主内容区 ---------- */
.app-main {
  min-height: calc(100vh - 48px - 56px);
  padding: 12px;
  padding-bottom: 80px;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: 56px; display: flex;
  background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px; gap: 2px;
}
.tab-ico { font-size: 20px; }
.tab.active { color: var(--primary); }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: 6px; font-size: 14px;
  background: #fff; border: 1px solid var(--border); color: var(--text);
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-danger { background: #c0392b; color: #fff; border-color: #c0392b; }
.btn-ghost { background: transparent; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--card); border-radius: 10px; padding: 14px;
  margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.panel-title {
  font-size: 15px; font-weight: 600; margin-bottom: 10px;
  color: var(--primary); border-left: 3px solid var(--primary); padding-left: 8px;
  display: flex; justify-content: space-between; align-items: center;
}

/* ---------- 字段 ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; background: #fff; font-family: inherit;
}
.field textarea { resize: vertical; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.info-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.info-row:last-child { border-bottom: none; }
.info-row > span { color: var(--muted); }
.info-block { margin: 8px 0; }
.info-block b { color: var(--primary); }

/* ---------- 标签 ---------- */
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: #eee; }
.tag-m { background: #d6e8fb; color: #2c6cb0; }
.tag-f { background: #fbe4ec; color: #c0487a; }
.tag-dark { background: #555; color: #fff; }
.tag-live { background: #d4edda; color: #28783a; }
.tag-lock { background: #fff3cd; color: #856404; }
.role-badge { padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.role-admin { background: #8a1f1f; color: #fff; }
.role-editor { background: #2c7873; color: #fff; }
.role-viewer { background: #888; color: #fff; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 24px;
  background: linear-gradient(180deg, #8a1f1f 0%, #a83232 60%, #f7f2e8 100%);
}
.login-logo {
  width: 88px; height: 88px; border-radius: 50%; background: var(--gold);
  color: var(--primary); font-size: 48px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  border: 4px solid #fff; margin-bottom: 16px; font-family: "楷体", serif;
}
.login-title { color: #fff; font-size: 24px; margin-bottom: 4px; }
.login-sub { color: rgba(255,255,255,0.85); font-size: 13px; margin-bottom: 28px; }
.login-form { width: 100%; max-width: 340px; background: #fff; padding: 20px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
.login-tip { margin-top: 18px; color: rgba(255,255,255,0.9); font-size: 12px; text-align: center; line-height: 1.7; }
.candidate-box { margin-top: 12px; width: 100%; max-width: 340px; }
.candidate-empty { background: #fff3cd; color: #856404; padding: 10px; border-radius: 6px; font-size: 13px; }
.candidate-ok { background: #d4edda; color: #28783a; padding: 10px; border-radius: 6px; font-size: 13px; }
.candidate-title { color: #fff; font-size: 13px; margin-bottom: 8px; }
.candidate-list { background: #fff; border-radius: 8px; padding: 8px; }
.candidate-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.candidate-item:last-child { border-bottom: none; }

/* ---------- 首页 ---------- */
.me-card {
  display: flex; gap: 14px; align-items: center;
  background: linear-gradient(135deg, #8a1f1f, #a83232);
  color: #fff; padding: 18px; border-radius: 12px; margin-bottom: 14px;
}
.me-avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--gold);
  color: var(--primary); font-size: 26px; font-weight: bold;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.me-info h2 { font-size: 18px; margin-bottom: 4px; }
.me-meta { font-size: 13px; opacity: 0.9; margin-bottom: 10px; }
.me-actions { display: flex; gap: 8px; }
.me-actions .btn { padding: 5px 12px; font-size: 12px; }

.quick-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px;
}
.quick-item {
  background: var(--card); border-radius: 10px; padding: 14px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.qi-ico { font-size: 24px; }

.overview { color: #555; margin-bottom: 8px; }
.rules { background: #fdf6e3; padding: 10px; border-radius: 6px; color: #856404; }

.rel-group { margin-bottom: 12px; }
.rel-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.rel-cards { display: flex; gap: 8px; flex-wrap: wrap; }
.person-card {
  background: #fafafa; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; min-width: 80px; text-align: center;
}
.pc-role { font-size: 11px; color: var(--muted); }
.pc-name { font-size: 14px; font-weight: 600; }
.pc-meta { font-size: 11px; color: var(--muted); }

.about { color: #666; font-size: 13px; }

/* ---------- 族人列表 ---------- */
.toolbar { margin-bottom: 10px; display: flex; gap: 8px; }
.search-input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 20px; font-size: 14px; background: #fff;
}
.filter-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-bar select { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff; }

.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-row {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.mr-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: bold; font-size: 16px;
}
.mr-avatar.male { background: var(--male); }
.mr-avatar.female { background: var(--female); }
.mr-main { flex: 1; }
.mr-name { font-size: 15px; font-weight: 600; }
.mr-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mr-arrow { color: var(--muted); font-size: 20px; }

.fab {
  position: fixed; right: 16px; bottom: 76px; width: 52px; height: 52px;
  border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; box-shadow: 0 4px 12px rgba(138,31,31,0.4); z-index: 40;
}

/* ---------- 详情页 ---------- */
.detail-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
  background: linear-gradient(135deg, #8a1f1f, #a83232); color: #fff;
  padding: 18px; border-radius: 12px;
}
.dh-avatar { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 26px; font-weight: bold; }
.dh-avatar.male { background: var(--male); }
.dh-avatar.female { background: var(--female); }
.dh-info h2 { font-size: 20px; margin-bottom: 4px; }
.dh-meta { opacity: 0.9; font-size: 13px; }
.detail-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.bio { color: #444; white-space: pre-wrap; }
.old-record { background: #fdf6e3; padding: 10px; border-radius: 6px; font-family: "楷体", serif; color: #5d4037; }
.special-list { display: flex; flex-direction: column; gap: 6px; }

/* ---------- 表单 ---------- */
.form .panel { margin-bottom: 12px; }
.form-actions { display: flex; gap: 10px; padding: 12px 0; }
.form-actions .btn { flex: 1; }
.warn { background: #fff3cd; color: #856404; padding: 10px; border-radius: 6px; font-size: 13px; margin-top: 8px; }

/* ---------- 隐私开关 ---------- */
.privacy-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.privacy-item:last-child { border-bottom: none; }
.privacy-title { font-weight: 600; }
.privacy-desc { font-size: 12px; color: var(--muted); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 24px; transition: 0.2s; }
.switch span::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: #fff; border-radius: 12px; max-height: 90vh; overflow-y: auto; width: 100%; max-width: 480px; }
.modal-wide { max-width: 560px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 600; color: var(--primary); }
.modal-close { color: var(--muted); font-size: 18px; }
.modal-body { padding: 16px; }
.modal-actions { display: flex; gap: 10px; padding: 0 16px 16px; }
.modal-actions .btn { flex: 1; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.toast { background: rgba(0,0,0,0.8); color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 13px; opacity: 0; transform: translateY(-10px); transition: 0.25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #28783a; }
.toast-error { background: #c0392b; }

/* ---------- 加载/空状态 ---------- */
.loading { text-align: center; color: var(--muted); padding: 30px; }
.empty { text-align: center; color: var(--muted); padding: 30px; font-size: 14px; }

/* ---------- 五世表 ---------- */
.table5-card { background: #fff; border-radius: 10px; overflow: hidden; }
.table5-head { background: var(--primary); color: #fff; padding: 10px 14px; font-weight: 600; }
.table5 { width: 100%; border-collapse: collapse; }
.table5 th, .table5 td { border: 1px solid var(--border); padding: 8px; vertical-align: top; }
.table5 th { background: #fdf6e3; color: var(--primary); }
.gen-no { width: 70px; text-align: center; font-weight: 600; background: #fafafa; }
.gen-char { color: var(--primary); font-size: 18px; }
.gen-row { display: flex; flex-wrap: wrap; gap: 8px; }
.gen-cell { background: #fafafa; border: 1px solid var(--border); border-radius: 6px; padding: 8px; min-width: 90px; text-align: center; }
.gc-name { font-weight: 600; }
.gc-name.male { color: var(--male); }
.gc-name.female { color: var(--female); }
.gc-meta { font-size: 11px; color: var(--muted); }
.gc-father { font-size: 11px; color: var(--muted); }
.gc-link { font-size: 11px; color: var(--primary); }
.table5-foot { padding: 12px; text-align: center; }

/* ---------- 树状图 ---------- */
.tree-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.tree-toolbar select { padding: 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.tree-canvas {
  width: 100%; height: calc(100vh - 160px); overflow: hidden;
  background: #fafafa; border: 1px solid var(--border); border-radius: 10px;
  touch-action: none; position: relative;
}
.tree-inner {
  position: absolute; transform-origin: 0 0; padding: 30px;
  display: flex; flex-direction: column; align-items: center;
}
.tree-node { display: flex; flex-direction: column; align-items: center; }
.tree-node-center { margin-bottom: 10px; }
.tn-card {
  background: #fff; border: 2px solid var(--border); border-radius: 8px;
  padding: 8px 14px; text-align: center; min-width: 70px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tn-male { border-color: var(--male); }
.tn-female { border-color: var(--female); }
.tn-name { font-weight: 600; font-size: 14px; }
.tn-meta { font-size: 11px; color: var(--muted); }
.tree-children { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.tree-branch { display: flex; flex-direction: column; align-items: center; position: relative; }
.tree-line-v { width: 2px; height: 16px; background: #bbb; }
.tree-line-down { width: 2px; height: 16px; background: #bbb; }
.collapse-btn { margin-top: 4px; font-size: 11px; color: var(--primary); padding: 2px 6px; border: 1px solid var(--primary); border-radius: 4px; }

/* ---------- 家堂轴子 ---------- */
.jiatang-scroll {
  background: linear-gradient(180deg, #fdf6e3 0%, #f5e6c8 100%);
  border: 6px solid #8a1f1f; border-radius: 4px; padding: 20px;
  font-family: "楷体", serif; max-width: 600px; margin: 0 auto;
  color: #5d2e0e;
}
.jiatang-scroll.a3 { max-width: 900px; }
.jt-roof { text-align: center; margin-bottom: 16px; }
.jt-roof-top { height: 20px; background: linear-gradient(180deg, #8a1f1f, #6b1818); border-radius: 4px 4px 0 0; margin: 0 auto; width: 80%; }
.jt-eave { color: #8a1f1f; font-size: 12px; letter-spacing: -2px; margin-top: -2px; }
.jt-title { text-align: center; margin: 16px 0; }
.jt-title-main { font-size: 28px; font-weight: bold; color: #8a1f1f; letter-spacing: 8px; }
.jt-title-sub { font-size: 14px; color: #8a6d3b; margin-top: 4px; }
.jt-body { min-height: 200px; padding: 16px; border: 2px solid #8a1f1f; border-radius: 4px; margin: 12px 0; }
.jt-gen { margin-bottom: 12px; }
.jt-gen-label { font-size: 13px; color: #8a6d3b; margin-bottom: 4px; }
.jt-names { display: flex; flex-wrap: wrap; gap: 10px; }
.jt-name {
  background: #fff; border: 1px solid #8a1f1f; padding: 6px 12px;
  border-radius: 4px; font-size: 16px; min-width: 60px; text-align: center;
}
.jt-empty { text-align: center; color: #8a6d3b; padding: 40px; }
.jt-altar { margin-top: 16px; }
.jt-altar-table { height: 12px; background: #8a1f1f; border-radius: 2px; }
.jt-altar-legs { display: flex; justify-content: space-between; padding: 0 10%; }
.jt-leg { width: 8px; height: 24px; background: #6b1818; }
.jt-foot { text-align: center; font-size: 11px; color: #8a6d3b; margin-top: 12px; }

/* ---------- 家族资料 ---------- */
.timeline { list-style: none; padding-left: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 10px; }
.tl-year { color: var(--primary); font-weight: 600; white-space: nowrap; }
.asset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.asset-item { background: #fafafa; border-radius: 8px; overflow: hidden; text-align: center; }
.asset-item img { width: 100%; height: 120px; object-fit: cover; cursor: pointer; }
.asset-title { padding: 6px; font-size: 13px; font-weight: 600; }
.asset-meta { font-size: 11px; color: var(--muted); padding-bottom: 6px; }

/* ---------- 管理后台 ---------- */
.admin-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 4px; }
.tab-btn { padding: 8px 12px; border-radius: 16px; background: #fff; border: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { border: 1px solid var(--border); padding: 6px; text-align: left; }
.data-table th { background: #fdf6e3; color: var(--primary); }
.data-table input { width: 100%; padding: 4px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-item { background: #fafafa; padding: 8px; border-radius: 6px; font-size: 12px; }
.log-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.log-action { font-weight: 600; color: var(--primary); }
.log-time { color: var(--muted); }
.log-op { color: var(--muted); }

/* ---------- 提示 ---------- */
.hint { font-size: 12px; color: var(--muted); margin: 6px 0; }

/* ---------- 打印样式（家堂轴 / 家谱报告） ---------- */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; left: 0; top: 0; width: 100%; }
  .app-header, .tabbar, #toast-root, #modal-root { display: none !important; }
}
.print-report { padding: 30px; font-family: "楷体", serif; }
.print-report h1 { text-align: center; color: #8a1f1f; margin-bottom: 10px; }
.print-sub { text-align: center; color: #888; margin-bottom: 20px; }
.print-overview { margin-bottom: 20px; padding: 12px; background: #fafafa; border-radius: 6px; }
.print-report table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-report th, .print-report td { border: 1px solid #999; padding: 6px; text-align: center; }
.print-report th { background: #fdf6e3; }

/* ---------- 大屏适配 ---------- */
@media (min-width: 768px) {
  .app-main { max-width: 800px; margin: 0 auto; }
  .quick-grid { grid-template-columns: repeat(6, 1fr); }
  .asset-grid { grid-template-columns: repeat(3, 1fr); }
}
