:root {
  --bg: #f5f6f8;
  --panel: #fff;
  --line: #e6e8ec;
  --text: #1a1d24;
  --muted: #737a87;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;
  --side: #151821;
  --side-text: #a7aebd;
  --r: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.dot { width: 10px; height: 10px; border-radius: 3px; background: #3b82f6; flex-shrink: 0; }
.brand-title { color: #fff; font-weight: 600; font-size: 14px; }
.brand-sub { font-size: 11px; color: #5d6472; }

.nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: 7px;
  color: var(--side-text); font-size: 13.5px;
  margin-bottom: 1px; text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.16); color: #fff; font-weight: 500; }
.ni { width: 15px; text-align: center; opacity: .75; font-size: 12px; }
.nav-sep {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: #474e5c; padding: 14px 11px 6px;
}

.side-footer {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; justify-content: space-between;
}
.me { display: flex; align-items: center; gap: 8px; color: #cdd3de; font-size: 13px; }
.avatar {
  width: 24px; height: 24px; border-radius: 6px; background: #2f3646; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.link-btn { background: none; border: 0; color: #6b7280; cursor: pointer; font-size: 12.5px; padding: 0; }
.link-btn:hover { color: #f87171; }

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

.topbar {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.muted-link { color: var(--muted); font-size: 13px; }

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

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: -2px 0 14px; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12.5px; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid4 { grid-template-columns: repeat(2, 1fr); } .grid3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 720px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .sidebar { width: 60px; } .brand div, .nav-item span:not(.ni), .side-footer { display: none; } }

/* ---------------- 统计卡 ---------------- */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -.4px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.err { color: var(--err); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #fafbfc;
}
td { padding: 11px 12px; border-bottom: 1px solid #f0f1f4; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; line-height: 18px; white-space: nowrap;
}
.tag-ok { background: #ecfdf5; color: var(--ok); }
.tag-warn { background: #fffbeb; color: var(--warn); }
.tag-err { background: #fef2f2; color: var(--err); }
.tag-mute { background: #f3f4f6; color: #6b7280; }
.tag-info { background: #eff6ff; color: var(--primary); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13px; font-family: inherit;
  cursor: pointer; transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: #f7f8fa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { color: var(--err); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); padding: 0 6px; }
.btn-block { width: 100%; }

/* ---------------- 表单 ---------------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email],
input[type=search], select, textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
select { cursor: pointer; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 140px; }
.row > .shrink { flex: 0 0 auto; min-width: 0; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.check input { width: auto; height: auto; margin: 0; }

/* ---------------- 提示 ---------------- */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); font-size: 13px; }
.loading { text-align: center; padding: 40px; color: var(--muted); font-size: 13px; }

/* ---------------- 登录页 ---------------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
/* 平台管理员：深蓝冷色 */
.login-admin {
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
}
/* 商户：浅灰绿暖色 */
.login-merchant {
  background: linear-gradient(160deg, #ecfdf5 0%, #f8fafc 100%);
}

.login-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.login-tag {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  z-index: 2;
}
.login-tag-admin { background: #2563eb; color: #fff; box-shadow: 0 4px 12px -2px rgba(37,99,235,.5); }
.login-tag-merchant { background: #059669; color: #fff; box-shadow: 0 4px 12px -2px rgba(5,150,105,.5); }

.login-card {
  width: 100%; background: #fff; border-radius: 14px;
  padding: 34px 28px 24px; box-shadow: 0 10px 40px -12px rgba(16,24,40,.18);
  border: 1px solid var(--line);
}
.login-admin .login-card { border-top: 3px solid #2563eb; }
.login-merchant .login-card { border-top: 3px solid #059669; }

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand .brand-title { color: var(--text); font-size: 15px; }
.login-brand .brand-sub { color: var(--muted); }

.login-hint {
  font-size: 11.5px; color: #9ca3af; line-height: 1.7;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid #f0f1f4;
}
.login-hint .mono { color: #6b7280; font-size: 11px; }

.login-switch {
  display: block; text-align: center; margin-top: 16px;
  font-size: 12.5px; color: #94a3b8; text-decoration: none;
}
.login-switch:hover { color: #64748b; text-decoration: underline; }

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed; top: 18px; right: 18px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px; border-radius: 9px; font-size: 13px; color: #fff;
  background: #374151; box-shadow: 0 8px 24px -8px rgba(0,0,0,.3);
  opacity: 0; transform: translateY(-6px); transition: all .2s ease;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: none; }
.toast-ok { background: var(--ok); }
.toast-err { background: var(--err); }
.toast-warn { background: var(--warn); }

/* ---------------- 模态框 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,20,30,.42);
  display: flex; align-items: center; justify-content: center; z-index: 900; padding: 20px;
  overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: 0 24px 64px -20px rgba(0,0,0,.35); max-height: 90vh; overflow-y: auto;
}
.modal-lg { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.modal-body { padding: 18px 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfc;
  border-radius: 0 0 12px 12px;
}
.close-x { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }

/* ---------------- 其他 ---------------- */
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 13px; color: var(--muted); }
.pager-btns { display: flex; gap: 6px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.hint-red { color: var(--err); font-weight: 500; }
.chip {
  display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11.5px;
  background: #f3f4f6; color: #4b5563; margin-right: 4px; margin-bottom: 3px;
}
.pre { background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
