:root {
  --bg: #f7f5f1;
  --panel: #ffffff;
  --ink: #3c3832;
  --ink-2: #6f665c;
  --ink-3: #a49a8d;
  --line: #eae5dc;
  --accent: #9a7b53;
  --accent-soft: #f2ece2;
  --green: #6b8f71;
  --red: #b5544a;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(60, 56, 50, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}

a { color: var(--accent); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, #efe9de 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, #eae4d8 0%, transparent 50%),
    var(--bg);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 40px 32px 32px;
  box-shadow: 0 12px 48px rgba(60, 56, 50, .10);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: 6px;
  font-weight: 500;
  text-align: center;
}

.login-card .sub {
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  margin-bottom: 28px;
  letter-spacing: 1px;
}

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

.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--line);
}

.brand .name {
  font-size: 20px;
  letter-spacing: 5px;
  font-weight: 500;
}

.brand .tag {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 5px;
  letter-spacing: 1px;
}

.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  cursor: pointer;
  margin-bottom: 3px;
  font-size: 14px;
  transition: .15s;
  user-select: none;
}

.nav-item:hover { background: #faf8f4; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  border-radius: 9px;
  padding: 1px 6px;
  line-height: 16px;
}

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-3);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h2 { font-size: 17px; margin: 0; font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--ink-2); }

.content { padding: 22px 24px 60px; }

/* ---------- 组件 ---------- */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 500;
}

.card-title .spacer { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 14px; margin-bottom: 18px; }

.stat {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat .label { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.stat .value { font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--ink-3); margin-left: 3px; }
.stat.accent .value { color: var(--accent); }
.stat.green .value { color: var(--green); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #d9d1c4; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #8b6e49; border-color: #8b6e49; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #e8d5d2; }
.btn.danger:hover { background: #fdf5f4; }
.btn.sm { height: 28px; padding: 0 11px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 11px; color: var(--ink-3); margin-top: 5px; }

.input, select.input, textarea.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fdfcfa;
  outline: none;
  transition: .15s;
}

textarea.input { height: auto; padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(154, 123, 83, .09); }

.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--ink-3); font-weight: 500; font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfaf7; }
td .sub { color: var(--ink-3); font-size: 12px; margin-top: 3px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f4f1ea;
  color: var(--ink-2);
  font-size: 11px;
  margin: 0 4px 4px 0;
  white-space: nowrap;
}

.tag.green { background: #edf3ee; color: #557a5b; }
.tag.gold { background: #f5eee2; color: #8a6b42; }
.tag.red { background: #fbeeec; color: #a64f46; }
.tag.gray { background: #f2f0ec; color: #8d857a; }

.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  padding: 7px 15px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13px;
  transition: .15s;
}
.pill:hover { border-color: #d9d1c4; }
.pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.empty { text-align: center; color: var(--ink-3); padding: 44px 0; font-size: 13px; }

.toast-wrap { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(60, 56, 50, .93);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  animation: toastIn .2s ease;
  max-width: 80vw;
}
.toast.err { background: rgba(168, 74, 66, .95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(40, 37, 33, .38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 500;
  padding: 6vh 16px 40px;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 640px;
  padding: 24px;
  box-shadow: 0 18px 60px rgba(40, 37, 33, .2);
}
.modal.wide { max-width: 860px; }
.modal h3 { margin: 0 0 18px; font-size: 17px; font-weight: 500; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 720px) { .split { grid-template-columns: 1fr; } }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { display: none; }
.switch .track { width: 40px; height: 22px; border-radius: 999px; background: #dfd9cf; position: relative; transition: .18s; flex: 0 0 40px; }
.switch .track::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .18s; box-shadow: 0 1px 3px rgba(0, 0, 0, .16); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }

.alert { background: #fdf6ef; border: 1px solid #f0e2d0; color: #8a6b42; border-radius: 10px; padding: 12px 14px; font-size: 12.5px; line-height: 1.7; }

.uploader { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb { width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: #f2efe9; position: relative; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .del { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; line-height: 18px; text-align: center; cursor: pointer; }
.thumb.add { display: flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: 22px; cursor: pointer; border-style: dashed; }
.thumb.add:hover { border-color: var(--accent); color: var(--accent); }

.trend { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding-top: 10px; }
.trend .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.trend .bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #c4a97f, #9a7b53); border-radius: 6px 6px 3px 3px; min-height: 3px; transition: .3s; }
.trend .bar-label { font-size: 11px; color: var(--ink-3); }
.trend .bar-count { font-size: 11px; color: var(--ink-2); }

.login-err { color: var(--red); font-size: 12.5px; margin-top: 10px; text-align: center; min-height: 18px; }

.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 26px;
  letter-spacing: 6px;
  color: var(--accent);
  text-align: center;
  padding: 16px;
  background: var(--accent-soft);
  border-radius: 12px;
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { padding: 0 14px; }
  .content { padding: 14px 14px 50px; }
  .card { padding: 16px; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
