:root {
  --brand: #2F6B53;
  --brand-dark: #245240;
  --brand-soft: #E8F1EC;
  --earth: #7FA98F;
  --earth-soft: #E3EDE6;
  --text: #1F2421;
  --text-2: #6B7570;
  --text-3: #9AA39E;
  --bg: #F4F7F4;
  --card: #FFFFFF;
  --line: #E3EAE4;
  --danger: #C0392B;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(31, 36, 33, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(47, 107, 83, 0.09), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(156, 194, 171, 0.16), transparent 46%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 400px;
  max-width: 100%;
  background: var(--card);
  border-radius: 20px;
  padding: 40px 36px 28px;
  box-shadow: 0 16px 48px rgba(31, 36, 33, 0.1);
}

.login-seal {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: block;
  object-fit: cover;
  margin-bottom: 18px;
}

.login-title {
  margin: 0;
  font-size: 24px;
  letter-spacing: 1px;
  color: var(--text);
}

.login-sub {
  margin: 6px 0 30px;
  color: var(--text-2);
  font-size: 13px;
}

.login-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.login-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #DDE6DF;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  background: #F7FAF7;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 83, 0.12);
  background: #fff;
}

.login-error {
  min-height: 22px;
  color: var(--danger);
  font-size: 12.5px;
  padding-top: 8px;
}

.login-btn {
  width: 100%;
  height: 46px;
  margin-top: 12px;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s;
}

.login-btn:hover { background: var(--brand-dark); }
.login-btn:disabled { background: #C8D3CD; cursor: default; }

.login-hint {
  margin: 20px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------------- 布局 ---------------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--line);
}

.brand-seal {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: block;
  object-fit: cover;
}

.brand-name {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-3);
}

.nav {
  padding: 12px 10px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.nav-item:hover { background: #F4F7F4; color: var(--text); }

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 500;
}

.nav-icon { font-size: 13px; opacity: 0.8; }

.sidebar-foot {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.logout {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 13px;
}

.logout:hover { border-color: #E3C7C2; color: var(--danger); }

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 32px 48px;
  max-width: 1440px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  /* 吸顶：页面滚动后标题与刷新按钮不跟着滚走 */
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 12px 0 10px;
  margin: -26px 0 12px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.page-desc {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.refresh-time { font-size: 12px; color: var(--text-3); }

.btn-mini {
  height: 32px;
  padding: 0 14px;
  border: 1px solid #DDE6DF;
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.btn-mini:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------- 统计卡 ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--brand-soft);
  opacity: 0.7;
}

.stat-label {
  font-size: 13px;
  color: var(--text-2);
}

.stat-value {
  font-size: 30px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.stat-foot {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

.stat-foot b { color: var(--brand); font-weight: 600; }

/* ---------------- 面板 ---------------- */
.panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.legend { font-size: 12px; color: var(--text-2); }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 5px 0 12px;
}

.dot-brand { background: var(--brand); }
.dot-earth { background: var(--earth); }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 180px;
  padding-top: 10px;
  border-bottom: 1px solid var(--line);
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
  width: 100%;
  justify-content: center;
}

.bar {
  width: 12px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
}

.bar-brand { background: var(--brand); }
.bar-earth { background: var(--earth); }

.chart-x {
  display: flex;
  gap: 8px;
  padding-top: 6px;
}

.chart-x span {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}

.burial-list { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }

.burial-row { font-size: 13px; }

.burial-top {
  display: flex;
  justify-content: space-between;
  color: var(--text-2);
  margin-bottom: 6px;
}

.burial-top b { color: var(--text); font-weight: 600; }

.burial-track {
  height: 8px;
  border-radius: 4px;
  background: #F2F0EB;
  overflow: hidden;
}

.burial-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #4C8A70, var(--brand));
  transition: width 0.4s ease;
}

/* ---------------- 表格 ---------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.search {
  width: 300px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid #DDE6DF;
  border-radius: 9px;
  font-size: 13.5px;
  background: #fff;
  outline: none;
}

.search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 107, 83, 0.1); }

.toolbar-hint { font-size: 12.5px; color: var(--text-3); }

.table-wrap {
  overflow-x: auto;
  /* 滚动时表头不出画：横向滚动条不挤压内容 */
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  /* 固定列宽 + 单行省略：避免窄屏时每格折成两三行、行高暴涨 */
  table-layout: fixed;
  min-width: 720px;
}

.table th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: #F8FBF8;
}

.table td {
  padding: 12px;
  border-bottom: 1px solid #F4F2ED;
  color: var(--text);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 单元格内的多行结构也要能截断，否则会撑破列宽 */
.table td > div,
.table td .cell-name > div:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 列宽：固定版式下按比例分配，各页面切换时列位置不再跳动 */
#recentTable th:nth-child(1), #tombsTable th:nth-child(1) { width: 23%; }
#recentTable th:nth-child(2), #tombsTable th:nth-child(2) { width: 17%; }
#recentTable th:nth-child(3), #tombsTable th:nth-child(3) { width: 12%; }
#recentTable th:nth-child(4), #tombsTable th:nth-child(4) { width: 10%; }
#recentTable th:nth-child(5), #tombsTable th:nth-child(5) { width: 16%; }
#recentTable th:nth-child(6), #tombsTable th:nth-child(6) { width: 13%; }
#recentTable th:nth-child(7), #tombsTable th:nth-child(7) { width: 9%; text-align: right; }

#usersTable th:nth-child(1) { width: 28%; }
#usersTable th:nth-child(2) { width: 22%; }
#usersTable th:nth-child(3) { width: 15%; }
#usersTable th:nth-child(4) { width: 13%; }
#usersTable th:nth-child(5) { width: 22%; }

#familiesTable th:nth-child(1) { width: 19%; }
#familiesTable th:nth-child(2) { width: 8%; }
#familiesTable th:nth-child(3) { width: 17%; }
#familiesTable th:nth-child(4) { width: 9%; }
#familiesTable th:nth-child(5) { width: 9%; }
#familiesTable th:nth-child(6) { width: 18%; }
#familiesTable th:nth-child(7) { width: 20%; }

.table tbody tr:hover { background: #F8FBF8; }
.table tbody tr:last-child td { border-bottom: none; }

.cell-sub { font-size: 12px; color: var(--text-3); }

.cell-name { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  background: var(--brand-soft);
  color: var(--brand);
  white-space: nowrap;
}

.pill-earth { background: var(--earth-soft); color: #4E7A62; }
.pill-plain { background: #F0F4F1; color: var(--text-2); }

.link {
  border: none;
  background: transparent;
  color: var(--brand);
  font-size: 12.5px;
  padding: 0;
}

.link:hover { text-decoration: underline; }

.btn-view {
  height: 28px;
  padding: 0 10px;
  border: 1px solid #DCE6E0;
  background: #fff;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--brand);
  white-space: nowrap;
}

.btn-view:hover { background: var(--brand-soft); }

/* 操作列：右对齐并收紧左侧留白，窄屏时按钮才不会被省略号吃掉 */
#recentTable td:last-child,
#tombsTable td:last-child {
  padding-left: 0;
  padding-right: 10px;
  text-align: right;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 14px;
  font-size: 12.5px;
  color: var(--text-2);
}

.pager button {
  min-width: 30px;
  height: 30px;
  border: 1px solid #DDE6DF;
  background: #fff;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-2);
}

.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: 0.45; cursor: default; }

/* ---------------- 抽屉 ---------------- */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(24, 32, 28, 0.34);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  animation: fade 0.18s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  width: 520px;
  max-width: 100%;
  background: var(--bg);
  height: 100%;
  overflow-y: auto;
  animation: slide 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slide { from { transform: translateX(28px); opacity: 0.6; } to { transform: none; opacity: 1; } }

.drawer-head {
  position: sticky;
  top: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.drawer-head h3 { margin: 0; font-size: 16px; }

.close {
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-3);
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.close:hover { background: #F0F4F1; color: var(--text); }

.drawer-body { padding: 18px 22px 40px; }

.d-title { font-size: 20px; font-weight: 600; margin-bottom: 10px; }

.d-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

.d-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.d-photos img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  background: #E6EDE8;
}

.d-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
}

.d-card h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.d-row {
  display: flex;
  padding: 6px 0;
  font-size: 13.5px;
}

.d-row .k { width: 88px; color: var(--text-2); flex-shrink: 0; }
.d-row .v { flex: 1; word-break: break-all; }

.d-person {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #F8FBF8;
}

.d-person-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.d-person-name { font-size: 15px; font-weight: 600; }

.d-remark {
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(31, 36, 33, 0.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 90;
}

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
  /* 中等屏幕先让次要列退场，主要列才不会被挤成碎片 */
  #recentTable th:nth-child(5), #recentTable td:nth-child(5),
  #tombsTable th:nth-child(5), #tombsTable td:nth-child(5),
  #usersTable th:nth-child(2), #usersTable td:nth-child(2),
  #familiesTable th:nth-child(7), #familiesTable td:nth-child(7) { display: none; }
  .table { min-width: 620px; }
}

@media (max-width: 1000px) {
  /* 再退一档：只保留最核心的列 */
  #recentTable th:nth-child(6), #recentTable td:nth-child(6),
  #tombsTable th:nth-child(6), #tombsTable td:nth-child(6),
  #usersTable th:nth-child(4), #usersTable td:nth-child(4),
  #familiesTable th:nth-child(2), #familiesTable td:nth-child(2) { display: none; }
  .table { min-width: 420px; }
}

@media (max-width: 820px) {
  .sidebar { width: 68px; }
  .brand > div:last-child, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-icon { font-size: 16px; }
  .main { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr; }
  .search { width: 180px; }
  .topbar { margin: -18px 0 10px; }
}
