/* 发卡中心 · 统一设计系统
   浅色底 + 高对比主色，兼顾后台长时间盯屏幕和对外页面的可读性。 */

:root {
  --bg: #f4f6fb;
  --bg-grad: radial-gradient(1200px 600px at 12% -10%, #e8ecff 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #e6fbff 0%, transparent 55%);
  --panel: #ffffff;
  --panel-2: #fafbfe;
  --border: #e2e7f1;
  --border-strong: #ccd5e6;
  --text: #16203a;
  --text-2: #46536e;
  --muted: #77839c;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef0ff;
  --ok: #0f9d58;
  --ok-soft: #e7f7ef;
  --warn: #c2740a;
  --warn-soft: #fdf3e2;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --info: #0b7ac7;
  --info-soft: #e8f4fd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-2: 0 8px 24px -6px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; font-weight: 650; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 1em; }

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

.wrap { max-width: 1140px; margin: 0 auto; padding: 28px 20px 64px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 48px 20px 64px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card.tight { padding: 14px 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 180px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.hidden { display: none !important; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13.5px; font-weight: 560;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: #f7f9fd; border-color: #b9c4da; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }

.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.94); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eef1f8; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

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

label.field { display: block; margin-bottom: 12px; }
label.field > span.lbl {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 5px;
}
label.field > span.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

input[type=text], input[type=password], input[type=number], input[type=search],
input[type=email], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { min-height: 74px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a6b0c4; }
input[readonly] { background: var(--panel-2); color: var(--text-2); }

.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.check input { width: auto; margin: 0; }

/* ---------------- 徽章 ---------------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.7;
  background: #eef1f7; color: var(--text-2);
  border: 1px solid transparent;
}
.badge-ok      { background: var(--ok-soft);     color: #0a6b3d; }
.badge-warn    { background: var(--warn-soft);   color: #8a5307; }
.badge-danger  { background: var(--danger-soft); color: #9b1c13; }
.badge-info    { background: var(--info-soft);   color: #0a5f9c; }
.badge-primary { background: var(--primary-soft);color: var(--primary-600); }

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

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-weight: 620; font-size: 12.5px; color: var(--text-2);
  background: var(--panel-2); padding: 9px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.tbl td { padding: 9px 12px; border-bottom: 1px solid #eef1f7; vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #fafbfe; }
table.tbl td.acts { white-space: nowrap; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }

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

.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-1);
}
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat.accent { border-left: 3px solid var(--primary); }
.stat.ok { border-left: 3px solid var(--ok); }
.stat.warn { border-left: 3px solid var(--warn); }
.stat.danger { border-left: 3px solid var(--danger); }

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

.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; margin-bottom: 14px; border: 1px solid transparent;
}
.alert-info { background: var(--info-soft); color: #0a5f9c; border-color: #cfe6f7; }
.alert-ok { background: var(--ok-soft); color: #0a6b3d; border-color: #c8ecdb; }
.alert-warn { background: var(--warn-soft); color: #8a5307; border-color: #f5e0bb; }
.alert-danger { background: var(--danger-soft); color: #9b1c13; border-color: #f7d4d0; }

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

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-box {
  width: 100%; max-width: 380px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-2); padding: 32px 30px;
}
.auth-logo {
  width: 46px; height: 46px; border-radius: 13px; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c5cf0 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 19px; letter-spacing: -.5px;
}

/* ---------------- 模态 ---------------- */

.modal-mask {
  position: fixed; inset: 0; background: rgba(18, 26, 44, .48);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow-2); width: 100%; max-width: 560px;
  margin: auto;
}
.modal.wide { max-width: 820px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}
.x-btn {
  border: none; background: transparent; font-size: 20px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.x-btn:hover { background: #eef1f8; color: var(--text); }

/* ---------------- Toast ---------------- */

#toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end;
}
.toast {
  padding: 10px 15px; border-radius: var(--radius-sm);
  background: #1e2942; color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow-2); max-width: 380px;
  animation: toast-in .18s ease-out;
}
.toast.ok { background: #0f7a48; }
.toast.err { background: #b42318; }
.toast.warn { background: #9a5b06; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------- 后台外壳 ---------------- */

.shell { display: flex; min-height: 100vh; }

.side {
  width: 208px; flex: 0 0 208px;
  background: #fff; border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .brand {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px 16px; font-weight: 700; font-size: 15px;
}
.side .brand .dot {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--primary), #7c5cf0);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; font-weight: 560;
  cursor: pointer; user-select: none; border: none; background: transparent;
  font-family: inherit; text-align: left; width: 100%;
}
.nav-item:hover { background: #f2f5fb; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-600); font-weight: 650; }
.nav-item .cnt {
  font-size: 11.5px; padding: 1px 7px; border-radius: 999px;
  background: #eef1f7; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.nav-item.active .cnt { background: #dde2ff; color: var(--primary-600); }
.side .spacer { flex: 1; }
.side .who { padding: 10px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 20px; flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 20px; }

.filters {
  display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 14px;
}
.filters > * { flex: 0 0 auto; }
.filters input[type=search], .filters input[type=text] { width: 200px; }
.filters select { width: auto; min-width: 120px; }

.pager {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  margin-top: 12px; font-size: 13px; color: var(--muted);
}

.kv { display: grid; grid-template-columns: 118px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.code-line {
  font-family: var(--mono); font-size: 14px; letter-spacing: .3px;
  background: var(--panel-2); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 11px; word-break: break-all;
}

pre.code {
  background: #1b2337; color: #dfe6f5; border-radius: var(--radius-sm);
  padding: 14px 16px; overflow-x: auto; font-size: 12.8px; line-height: 1.65;
  font-family: var(--mono);
}
pre.code .c { color: #8c9bb8; }
pre.code .s { color: #9ee6a8; }
pre.code .k { color: #8fb8ff; }

.method {
  display: inline-block; min-width: 52px; text-align: center;
  padding: 1px 8px; border-radius: 5px; font-size: 11.5px; font-weight: 700;
  font-family: var(--mono);
}
.method.get { background: var(--info-soft); color: #0a5f9c; }
.method.post { background: var(--ok-soft); color: #0a6b3d; }

/* 条形趋势图（不引外部图表库，纯 div） */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 112px; padding-top: 8px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; min-width: 0; }
.bars .bar i {
  display: block; width: 100%; max-width: 34px; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #6f66f0, var(--primary));
  min-height: 2px;
}
.bars .bar span { font-size: 10.5px; color: var(--muted); white-space: nowrap; transform: rotate(-38deg); }

/* ---------------- 对外页面 ---------------- */

.hero { text-align: center; padding: 56px 20px 34px; }
.hero h1 { font-size: 34px; letter-spacing: -.02em; margin-bottom: 12px; }
.hero p { font-size: 16px; color: var(--text-2); max-width: 620px; margin: 0 auto 24px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.feature { display: flex; gap: 12px; align-items: flex-start; }
.feature .ico {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--primary-soft); color: var(--primary-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.feature h3 { margin: 2px 0 3px; font-size: 14.5px; }
.feature p { margin: 0; font-size: 13px; color: var(--muted); }

.top-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.top-nav .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.top-nav .brand .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #7c5cf0);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.top-nav .links { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; overflow-x: auto; padding: 10px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .side .brand { padding: 0 12px 0 6px; }
  .side .spacer, .side .who { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { padding: 16px 14px 48px; }
  .modal-mask { padding: 16px 10px; }
}
