:root {
  --paper: #f7f6f3;
  --panel: #ffffff;
  --ink: #1a1917;
  --ink-soft: #57544d;
  --ink-mute: #8a867d;
  --line: #e4e1da;
  --line-soft: #efede8;
  --accent: #993c1d;
  --accent-soft: #faece7;
  --ok: #3b6d11;
  --ok-soft: #eaf3de;
  --warn: #854f0b;
  --warn-soft: #faeeda;
  --err: #a32d2d;
  --err-soft: #fcebeb;
  --blue: #185fa5;
  --blue-soft: #e6f1fb;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

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

.side {
  width: 216px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand {
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.side-brand .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.side-brand small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-mute);
  letter-spacing: 0;
  margin-top: 1px;
}
.side-nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.side-nav button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 9px 11px;
  border-radius: 7px;
  cursor: pointer;
  margin-bottom: 2px;
}
.side-nav button:hover { background: var(--paper); color: var(--ink); }
.side-nav button.on { background: var(--ink); color: #fff; }
.side-foot {
  padding: 12px 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-mute);
}
.side-foot button {
  background: none; border: 0; color: var(--ink-mute);
  font-family: inherit; font-size: 12px; cursor: pointer; padding: 4px 0;
}
.side-foot button:hover { color: var(--accent); }

.main { flex: 1; min-width: 0; padding: 28px 32px 56px; }
.main-head { margin-bottom: 22px; }
.main-head h1 { font-size: 21px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.main-head p { margin: 0; font-size: 13px; color: var(--ink-mute); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-head h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-head h2 .k {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-mute);
  background: var(--paper);
  padding: 2px 7px;
  border-radius: 4px;
}
.card-desc { font-size: 12.5px; color: var(--ink-mute); margin: -10px 0 16px; line-height: 1.6; }

/* ---------- 指标 ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px 16px;
}
.metric .lab { font-size: 12px; color: var(--ink-mute); margin-bottom: 5px; }
.metric .val { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.metric .sub { font-size: 11.5px; color: var(--ink-mute); margin-top: 3px; }
.metric.warn .val { color: var(--warn); }
.metric.err .val { color: var(--err); }
.metric.ok .val { color: var(--ok); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--ink-mute); margin-top: 5px; line-height: 1.5; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; }
input.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

.secret-row { display: flex; gap: 8px; }
.secret-row input { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .86; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: #cbc6bb; background: var(--paper); }
.btn.danger { background: #fff; color: var(--err); border-color: #e8c9c9; }
.btn.sm { padding: 5px 11px; font-size: 12px; }
.btn.xs { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; padding: 0 20px 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-mute);
  padding: 0 12px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-mute); }
.ellipsis { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- 提示块 ---------- */
.note {
  font-size: 12.5px;
  padding: 11px 14px;
  border-radius: var(--radius);
  line-height: 1.6;
  margin-bottom: 14px;
}
.note.info { background: var(--blue-soft); color: var(--blue); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.err { background: var(--err-soft); color: var(--err); }
.note code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  background: rgba(255,255,255,.55);
  padding: 1px 5px;
  border-radius: 4px;
}

pre.raw {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  background: #2c2c2a;
  color: #e8e6e1;
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow: auto;
  max-height: 260px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 12px 0 0;
}

/* ---------- 邮件测试 ---------- */
.mail-test {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.mail-test-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.mail-test-row input {
  flex: 1;
  min-width: 0;
}
.mail-test .note {
  margin-bottom: 10px;
}
.mail-test .hint {
  margin-top: 10px;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 356px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
}
.login-box h1 { font-size: 19px; font-weight: 600; margin: 0 0 5px; }
.login-box p { font-size: 13px; color: var(--ink-mute); margin: 0 0 22px; }

/* ---------- 趋势条 ---------- */
.trend { display: flex; align-items: flex-end; gap: 6px; height: 76px; }
.trend .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.trend .bar {
  width: 100%;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  opacity: .82;
}
.trend .bar.low { background: #d3cfc6; }
.trend .day { font-size: 10.5px; color: var(--ink-mute); }

.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 16px; font-size: 12.5px; color: var(--ink-mute); }

.empty-row { padding: 40px; text-align: center; color: var(--ink-mute); font-size: 13px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 200;
  max-width: 88vw;
}

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .side-brand { border-bottom: 0; border-right: 1px solid var(--line-soft); white-space: nowrap; }
  .side-nav { display: flex; padding: 8px; gap: 4px; }
  .side-nav button { white-space: nowrap; margin: 0; }
  .side-foot { display: none; }
  .main { padding: 20px 16px 48px; }
  .table-wrap { margin: 0 -16px -16px; padding: 0 16px 16px; }
}
