:root {
  --paper: #f6f5f1;
  --surface: #ffffff;
  --ink: #191813;
  --ink-2: #5c574d;
  --ink-3: #8d8779;
  --line: #e5e1d7;
  --line-soft: #efede6;
  --accent: #2e6b57;
  --accent-deep: #1f4b3d;
  --accent-soft: #e9f1ec;
  --warn: #8a5a26;
  --warn-soft: #f7efe4;
  --danger: #9c3b33;
  --danger-soft: #f8ecea;
  --shadow: 0 1px 2px rgba(25, 24, 19, 0.04), 0 8px 24px rgba(25, 24, 19, 0.05);
  --radius: 14px;
  --sidebar: 236px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

::selection { background: #d8e6de; }

/* ---------- 基础控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: #d6d1c4; background: #fbfaf7; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: #efede6; }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #ecd6d3; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

.field { margin-bottom: 18px; }
.field > label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  margin-bottom: 7px;
}
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: #b9c9c0;
  box-shadow: 0 0 0 3px rgba(46, 107, 87, 0.1);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.65; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

/* ---------- 登录 ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
.auth-brand {
  position: relative;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #1d2b26;
  color: #eef2ef;
  overflow: hidden;
}
.auth-brand::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% 20%;
  height: 70%;
  background: radial-gradient(closest-side, rgba(126, 178, 155, 0.35), transparent);
}
.auth-brand .mark { display: flex; align-items: center; gap: 10px; font-size: 15px; letter-spacing: 0.14em; }
.auth-brand h1 {
  font-size: 40px;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0 0 14px;
}
.auth-brand p { color: #a9bbb3; max-width: 24em; margin: 0; font-size: 14px; }
.auth-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.auth-card { width: 100%; max-width: 348px; }
.auth-card h2 { font-size: 22px; font-weight: 600; margin: 0 0 6px; letter-spacing: 0.01em; }
.auth-card .sub { color: var(--ink-3); margin: 0 0 30px; font-size: 13px; }
.auth-card .btn-primary { width: 100%; height: 42px; margin-top: 6px; }
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #eed9d6;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 16px;
}
.auth-foot { margin-top: 22px; font-size: 12px; color: var(--ink-3); }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 26px 18px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fbfaf7;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 26px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: #1d2b26; color: #dfe9e3;
  display: grid; place-items: center;
  font-size: 13px; letter-spacing: 0.04em;
}
.brand-name { font-size: 15px; letter-spacing: 0.06em; }
.brand-role { font-size: 11px; color: var(--ink-3); letter-spacing: 0.08em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--ink-2); font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: #f1efe8; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 500; }
.nav a svg { width: 16px; height: 16px; opacity: 0.75; }

.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.who { display: flex; align-items: center; gap: 10px; padding: 4px 10px 10px; }
.who-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #e4e9e5; color: var(--accent-deep);
  display: grid; place-items: center; font-size: 12px;
}
.who-email { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-quiet { color: var(--ink-3); font-size: 12px; cursor: pointer; }
.link-quiet:hover { color: var(--ink); }

.main { flex: 1; min-width: 0; padding: 30px 38px 60px; }
.main-inner { max-width: 1080px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-head h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: 0.01em; }
.page-head .sub { color: var(--ink-3); font-size: 13px; margin: 0; }
.actions { display: flex; gap: 10px; }

/* ---------- 卡片 / 概览 ---------- */
.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
}
.stat .k { font-size: 12px; color: var(--ink-3); letter-spacing: 0.03em; }
.stat .v { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.stat .foot { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.cols { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.card-body { padding: 6px 18px 14px; }

.rank { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.rank:last-child { border-bottom: 0; }
.rank .n { width: 18px; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.rank .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .p { color: var(--ink-3); font-size: 12px; }
.bar { height: 4px; border-radius: 2px; background: var(--line-soft); width: 90px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #9dbcae; }

/* ---------- 表格 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.search { position: relative; width: 260px; }
.search input { padding-left: 34px; height: 36px; }
.search svg { position: absolute; left: 11px; top: 10px; width: 15px; height: 15px; color: var(--ink-3); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 500; font-size: 11.5px; letter-spacing: 0.05em;
  color: var(--ink-3); padding: 11px 16px; background: #fbfaf7;
  border-bottom: 1px solid var(--line);
}
td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfbf8; }
.cell-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cover {
  width: 40px; height: 40px; border-radius: 9px; flex: 0 0 40px;
  background: #e8e6de; background-size: cover; background-position: center;
  display: grid; place-items: center; color: #8d8779; font-size: 13px;
}
.cell-title .meta { min-width: 0; }
.cell-title .t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.cell-title .s { font-size: 12px; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 20px;
  font-size: 11.5px; letter-spacing: 0.02em; white-space: nowrap;
  background: #f2f0e9; color: var(--ink-2);
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.pill-on { background: var(--accent-soft); color: var(--accent-deep); }
.pill-free { background: #f0eee6; color: #6d6553; }
.pill-vip { background: #eef1f6; color: #4b5a75; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-off { background: #f3f1ec; color: #8d8779; }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

.row-actions { display: flex; justify-content: flex-end; gap: 4px; opacity: 0.7; transition: opacity 0.15s ease; }
tr:hover .row-actions { opacity: 1; }
.row-actions button { border: 0; background: transparent; padding: 5px 8px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-size: 12.5px; }
.row-actions button:hover { background: #f1efe8; color: var(--ink); }
.row-actions .del:hover { background: var(--danger-soft); color: var(--danger); }

.empty { padding: 56px 20px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }

.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #efede6, #f7f5ef, #efede6); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- 抽屉 ---------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(25, 24, 19, 0.28);
  opacity: 0; transition: opacity 0.2s ease; z-index: 40;
}
.drawer-mask.open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 92vw;
  background: var(--surface); z-index: 41; display: flex; flex-direction: column;
  box-shadow: -20px 0 60px rgba(25, 24, 19, 0.12);
  transform: translateX(100%); transition: transform 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { font-size: 17px; margin: 0; font-weight: 600; }
.drawer-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--ink-3); width: 30px; height: 30px; border-radius: 8px; }
.icon-btn:hover { background: #f1efe8; color: var(--ink); }

.drop {
  border: 1px dashed #d5d0c3; border-radius: 12px; padding: 18px;
  text-align: center; color: var(--ink-3); cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop:hover { border-color: #a9c2b5; background: #fafcfa; }
.drop strong { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 3px; font-size: 13px; }
.drop .file { color: var(--accent-deep); font-size: 12.5px; margin-top: 8px; word-break: break-all; }
.progress { height: 4px; background: var(--line-soft); border-radius: 3px; overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease; }

.thumb-row { display: flex; gap: 12px; align-items: center; }
.thumb { width: 56px; height: 56px; border-radius: 10px; background: #efede6 center/cover no-repeat; flex: 0 0 56px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.switch:first-of-type { border-top: 0; }
.switch .txt strong { display: block; font-size: 13px; font-weight: 500; }
.switch .txt span { font-size: 12px; color: var(--ink-3); }
.toggle { position: relative; width: 40px; height: 22px; flex: 0 0 40px; }
.toggle input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: relative; z-index: 1; }
.toggle span { position: absolute; inset: 0; background: #dedad0; border-radius: 20px; transition: background 0.18s ease; }
.toggle span::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform 0.18s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(18px); }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(25, 24, 19, 0.32); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { color: var(--ink-2); font-size: 13.5px; margin: 0 0 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; }
.choice { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.choice button { flex: 1; min-width: 70px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.choice button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); }

.toast-wrap { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; }
.toast {
  background: #1d2b26; color: #eef2ef; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow); animation: rise 0.2s ease both;
}
.toast.bad { background: #43201c; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.boot { min-height: 100vh; display: grid; place-items: center; color: var(--ink-3); font-size: 13px; letter-spacing: 0.08em; }

@media (max-width: 1080px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 20px 16px 50px; }
  .search { width: 100%; }
  table .hide-sm { display: none; }
}
