:root {
  --primary: #c0503a;
  --primary-dark: #a03f2c;
  --primary-light: #fdf1ee;
  --bg: #f6f4f0;
  --card: #ffffff;
  --text: #2f2a26;
  --muted: #8b8178;
  --line: #ece7e1;
  --green: #2e9e6b;
  --amber: #d88a1b;
  --red: #c9463c;
  --shadow: 0 6px 24px rgba(80, 50, 30, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 10%, #fbe3da 0, transparent 45%),
    radial-gradient(circle at 90% 90%, #f3e6d8 0, transparent 40%), var(--bg);
  padding: 24px;
}

.login-card {
  width: 380px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px 36px 34px;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
}
.brand h1 { font-size: 19px; margin: 0; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.field input, .field select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 10px; outline: none; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192, 80, 58, .1);
}
.field .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

.privacy-editor {
  width: 100%;
  min-height: 420px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  background: #fff;
  color: var(--text);
}
.privacy-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192, 80, 58, 0.1);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  background: #f2eee9; color: var(--text); cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-danger { background: #fbeae8; color: var(--red); }
.btn-danger:hover { background: #f7dcd9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 布局 ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.sidebar .brand { padding: 0 8px; margin-bottom: 22px; }
.sidebar .brand h1 { font-size: 16px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 10px; cursor: pointer;
  color: #5d554d; background: transparent; border: none; text-align: left;
}
.nav-item:hover { background: #faf6f2; }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--primary);
  opacity: 0; margin-left: auto;
}
.nav-item.has-badge .dot { opacity: 1; }
.sidebar-footer { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 26px 30px 50px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 22px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ---------------- 卡片 / 统计 ---------------- */
.card {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 20px; border: 1px solid #f3eee9;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -.5px; }
.stat .foot { color: var(--muted); font-size: 12px; margin-top: 8px; }
.stat .accent {
  position: absolute; right: -16px; top: -16px; width: 54px; height: 54px;
  border-radius: 50%; background: var(--primary-light);
}
.stat.amber .value { color: var(--amber); }
.stat.green .value { color: var(--green); }

.section-title { font-size: 16px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--muted); font-weight: 400; font-size: 13px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px;
  outline: none; background: #fff; min-width: 140px;
}
.toolbar input { min-width: 220px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }
.search-wrap { position: relative; }
.search-wrap input { padding-left: 32px; }
.search-wrap::before { content: "⌕"; position: absolute; left: 11px; top: 7px; color: var(--muted); font-size: 16px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  background: #faf8f5; padding: 12px 14px; white-space: nowrap;
}
tbody td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fcfaf8; }
td .title { font-weight: 600; }
td .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.amount.big { font-size: 16px; color: var(--primary); }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px;
  background: #f2f0ed; color: #6d645b; white-space: nowrap;
}
.badge.pending { background: #fdf1e0; color: var(--amber); }
.badge.approved, .badge.paid, .badge.on { background: #e8f6ef; color: var(--green); }
.badge.rejected, .badge.closed { background: #fbeae8; color: var(--red); }
.badge.accepted { background: #e9f0fb; color: #3568b8; }
.badge.completed { background: #e8f6ef; color: var(--green); }
.badge.allowance_pending { background: #fff4e5; color: #c27400; }
.badge.done { background: #e8f6ef; color: var(--green); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.avatar {
  width: 32px; height: 32px; border-radius: 10px; background: var(--primary-light);
  color: var(--primary); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; margin-right: 9px; vertical-align: middle;
}
.user-cell { display: flex; align-items: center; }

.id-photos { display: flex; gap: 6px; }.id-photo {
  width: 54px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #faf8f5;
  display: block;
}
.id-photo:hover { border-color: var(--primary); }

.id-card {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}

/* 小程序品牌设置 */
.brand-upload-row { display: flex; align-items: center; gap: 18px; }
.brand-logo-preview {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  background: linear-gradient(135deg, #c0503a 0%, #d76a4f 100%);
  color: #fff;
  font-size: 38px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(192, 80, 58, 0.22);
}
.brand-logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.brand-preview-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.brand-preview-name { font-size: 20px; font-weight: 700; color: var(--text); }

/* ---------------- 设置 ---------------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.settings-grid .card { padding: 22px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px dashed var(--line); }
.setting-row:last-child { border-bottom: none; }
.setting-row .info { flex: 1; }
.setting-row .info b { display: block; margin-bottom: 4px; }
.setting-row .info span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.setting-row .control { width: 150px; flex-shrink: 0; }
.setting-row input, .setting-row select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; outline: none;
}
.setting-row input:focus { border-color: var(--primary); }
.readonly-value { font-weight: 700; color: var(--primary); }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(47, 42, 38, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: #fff; width: min(760px, 100%); max-height: 86vh; overflow: auto;
  border-radius: 16px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.modal-close { border: none; background: #f4f0ec; width: 32px; height: 32px; border-radius: 9px; cursor: pointer; font-size: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 20px; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 14px; }
.form-grid .field { margin-bottom: 0; }.detail-grid .item { border-bottom: 1px dashed var(--line); padding-bottom: 10px; }
.detail-grid .item span { color: var(--muted); font-size: 12px; display: block; margin-bottom: 4px; }
.detail-grid .item b { font-weight: 500; word-break: break-all; }
.detail-block { margin-bottom: 18px; }
.detail-block h4 { font-size: 13px; color: var(--muted); margin: 0 0 10px; font-weight: 500; }
.detail-block pre { background: #faf8f5; border-radius: 10px; padding: 12px; margin: 0; white-space: pre-wrap; font-family: inherit; line-height: 1.7; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline li .time { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed; left: 50%; top: 26px; transform: translateX(-50%) translateY(-20px);
  background: #2f2a26; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 100;
  max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }

@media (max-width: 860px) {
  .sidebar { width: 70px; padding: 18px 8px; }
  .sidebar .brand h1, .sidebar .brand p, .sidebar-footer, .nav-item span:nth-child(2) { display: none; }
  .nav-item { justify-content: center; font-size: 18px; padding: 13px 0; }
  .nav-item .dot { display: none; }
  .main { padding: 18px; }
  .detail-grid { grid-template-columns: 1fr; }
}
