/* 任意码 - 管理后台样式 */

:root {
  --ink: #1a1d21;
  --ink-2: #565c66;
  --ink-3: #8b919b;
  --line: #e3e5e9;
  --line-2: #eef0f3;
  --bg: #f7f8fa;
  --card: #fff;
  --blue: #2563eb;
  --blue-d: #1d4ed8;
  --blue-l: #eff4ff;
  --green: #0f9d6e;
  --green-l: #eaf7f2;
  --red: #dc2626;
  --red-l: #fef3f3;
  --amber: #b45309;
  --amber-l: #fdf7ec;
  --r: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a { color: inherit; text-decoration: none; }

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

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- 登录 ---------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
}

.login-card h1 { font-size: 19px; margin-bottom: 4px; }

.login-card > p {
  margin: 0 0 20px;
  color: var(--ink-2);
  font-size: 13px;
}

.login-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
}

.login-foot a { color: var(--blue); }

/* ---------- 布局 ---------- */

.shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100vh;
}

.side {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.2px;
}

.side-logo i {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-style: normal;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: none;
  border-radius: var(--r);
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.side-link:hover { background: var(--line-2); color: var(--ink); }

.side-link.active {
  background: var(--blue-l);
  color: var(--blue-d);
  font-weight: 500;
}

.side-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-user {
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.side-user b { color: var(--ink-2); font-weight: 500; }

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

.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h2 { font-size: 15px; }
.topbar .sp { flex: 1; }

.content {
  padding: 20px 24px 40px;
  display: grid;
  gap: 16px;
  align-content: start;
  max-width: 1240px;
}

/* ---------- 卡片 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.card-hd {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.card-hd h3 { font-size: 14.5px; }

.card-tip {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-left: auto;
}

/* ---------- 统计 ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.stat {
  background: var(--card);
  padding: 14px 16px;
}

.stat .k {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.stat .v {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}

.stat .v.accent { color: var(--blue); }

/* ---------- 表单 ---------- */

.field { margin-bottom: 12px; }

.field > label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 5px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fcfcfd;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

.input:hover, .select:hover, .textarea:hover { border-color: #cfd4dc; }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--blue);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.textarea { min-height: 72px; resize: vertical; }
.select { cursor: pointer; }

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hint { margin-top: 5px; font-size: 12px; color: var(--ink-3); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  font-size: 13.5px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}

.btn:hover { background: #f2f4f7; border-color: #d5d9df; }
.btn:disabled { opacity: .45; cursor: not-allowed; background: var(--card); }

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 500;
}

.btn-primary:hover { background: var(--blue-d); border-color: var(--blue-d); }

.btn-danger { color: var(--red); border-color: #f0cdcd; }
.btn-danger:hover { background: var(--red-l); border-color: #e8b4b4; }

.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---------- 工具栏 ---------- */

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar .select { width: auto; min-width: 110px; }

/* ---------- 表格 ---------- */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--ink-2);
  background: #fafbfc;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

td.num { font-variant-numeric: tabular-nums; }

td.mono {
  font-family: var(--mono);
  font-size: 12px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.ops { white-space: nowrap; }
td.ops .btn + .btn { margin-left: 5px; }

/* ---------- 标签 ---------- */

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 12px;
  background: var(--line-2);
  color: var(--ink-2);
}

.tag.ok { background: var(--green-l); color: var(--green); }
.tag.warn { background: var(--amber-l); color: var(--amber); }
.tag.danger { background: var(--red-l); color: var(--red); }
.tag.brand { background: var(--blue-l); color: var(--blue-d); }

/* ---------- 分页 ---------- */

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- 图表 ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 140px;
  padding-top: 8px;
}

.bar-wrap {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
}

.bar {
  width: 100%;
  max-width: 42px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
  opacity: .82;
}

.bar-wrap:hover .bar { opacity: 1; }

.bar-num {
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.bar-lbl {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 空状态 ---------- */

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

/* ---------- 弹窗 ---------- */

.mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 28, .42);
  display: none;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

.mask.show { display: grid; }

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 12px 40px rgba(15, 20, 30, .18);
}

.modal h3 { font-size: 16px; margin-bottom: 14px; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

.modal-actions .btn-primary { min-width: 84px; }

.qr-view {
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  margin-bottom: 14px;
}

.qr-view img { width: 200px; height: 200px; object-fit: contain; image-rendering: pixelated; }

.detail-list {
  font-size: 12.5px;
  display: grid;
  gap: 5px;
}

.detail-list > div { display: flex; gap: 8px; }
.detail-list dt { color: var(--ink-3); width: 56px; flex: none; }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.detail-pre {
  margin: 10px 0 0;
  padding: 10px;
  max-height: 180px;
  overflow: auto;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- 提示 ---------- */

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  z-index: 200;
}

.toast {
  max-width: 320px;
  padding: 10px 14px;
  border-radius: var(--r);
  background: #23272e;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(15, 20, 30, .22);
  animation: toast-in .16s ease-out;
}

.toast.ok { background: #10805c; }
.toast.err { background: #b91c1c; }

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- 响应式 ---------- */

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }

  .side {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 8px 10px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    gap: 4px;
  }

  .side-logo { padding: 0 10px 0 4px; white-space: nowrap; }
  .side-link { white-space: nowrap; }
  .side-foot { display: none; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .row2 { grid-template-columns: 1fr; }
}
