/* ============================================================
   支付平台控制台 v2 · 统一深色主题
   纯手写，无构建、无 CDN 依赖：所有字体走系统栈，所有图标走内联 SVG/Unicode。
   配色语义固定：绿=成功  红=失败  黄=警告  蓝=中性  灰=停用
   ============================================================ */

:root {
  /* 底色三层：页面底 / 卡片 / 卡片内嵌 */
  --bg: #0b1020;
  --surface: #131a2e;
  --surface-2: #1a2338;
  --surface-3: #212c46;
  --border: #263149;
  --border-strong: #33415e;

  /* 文字三层 */
  --text: #e6ebf5;
  --text-dim: #b3bed3;
  --muted: #8493ad;

  /* 语义色 */
  --ok: #22c55e;
  --ok-bg: rgba(34, 197, 94, 0.12);
  --bad: #ef4444;
  --bad-bg: rgba(239, 68, 68, 0.12);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.12);
  --idle: #64748b;
  --idle-bg: rgba(100, 116, 139, 0.16);
  --accent: #3b82f6;
  --accent-bg: rgba(59, 130, 246, 0.12);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.32);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* 数字统一等宽，金额列右对齐才不会跳动 */
.num, .mono, td.num, th.num {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

/* ---------------- 布局骨架 ---------------- */

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

.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.sidebar .brand .logo {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
  flex: 0 0 26px;
}
.sidebar .brand .txt { font-weight: 600; font-size: 14px; letter-spacing: .2px; }
.sidebar .brand .txt small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }

.nav-group { margin-bottom: 4px; }
.nav-group > .nav-title {
  padding: 10px 16px 5px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 16px;
  color: var(--text-dim);
  font-size: 13.5px;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--accent-bg);
  border-left-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
.nav-item svg { width: 15px; height: 15px; flex: 0 0 15px; opacity: .85; }

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

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.topbar .right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar .who { color: var(--muted); font-size: 12.5px; }

.content { padding: 18px 20px 40px; flex: 1; min-width: 0; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card > h2 {
  margin: 0 0 12px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.card > h2 .hint { font-weight: 400; font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* ---------------- 指标块 ---------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.stat .k { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.stat .v {
  font-size: 22px; font-weight: 600;
  font-variant-numeric: tabular-nums; font-family: var(--mono);
  line-height: 1.25; word-break: break-all;
}
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.stat.ok .v { color: var(--ok); }
.stat.bad .v { color: var(--bad); }
.stat.warn .v { color: var(--warn); }
.stat.info .v { color: var(--info); }

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

.table-wrap {
  overflow-x: auto;              /* 表格窄了就横向滚，不撑破布局 */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: max-content; }
table.tbl th, table.tbl td {
  padding: 9px 11px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl th {
  background: var(--surface-2); color: var(--muted);
  font-weight: 500; font-size: 12px; position: sticky; top: 0; z-index: 1;
}
table.tbl td.wrap { white-space: normal; min-width: 200px; }
table.tbl td.num, table.tbl th.num { text-align: right; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .id { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }

/* ---------------- 徽标 ---------------- */

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 11.5px; line-height: 1.7; white-space: nowrap;
  background: var(--idle-bg); color: var(--text-dim);
  border: 1px solid transparent;
}
.badge.ok   { background: var(--ok-bg);   color: #86efac; border-color: rgba(34,197,94,.3); }
.badge.bad  { background: var(--bad-bg);  color: #fca5a5; border-color: rgba(239,68,68,.3); }
.badge.warn { background: var(--warn-bg); color: #fcd34d; border-color: rgba(245,158,11,.3); }
.badge.info { background: var(--info-bg); color: #7dd3fc; border-color: rgba(56,189,248,.3); }
.badge.idle { background: var(--idle-bg); color: #cbd5e1; border-color: rgba(100,116,139,.35); }
.badge.acc  { background: var(--accent-bg); color: #93c5fd; border-color: rgba(59,130,246,.32); }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); font-size: 13px; font-family: var(--font);
  cursor: pointer; transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: #44557a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover:not(:disabled) { background: #2f6fe0; border-color: #2f6fe0; }
.btn.danger { background: var(--bad-bg); border-color: rgba(239,68,68,.4); color: #fca5a5; }
.btn.danger:hover:not(:disabled) { background: rgba(239,68,68,.22); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

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

label.field { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--text-dim); }
label.field > span.lbl { display: block; margin-bottom: 4px; }

/*
 * 字段说明内联在 label 里（.lbl > .lbl-hint）。
 *
 * 为什么内联而不是放在控件下面：.filters 用 align-items:flex-end 对齐各 field 的底边，
 * 只有某一栏多一行说明文字，它的 field 就被撑高、控件下沿抬高，其余栏目矮一截，
 * 三个下拉框看起来参差不齐。内联到 label 行内（同一行、右侧）不增加 field 高度，
 * 下沿保持对齐；而下方的 .hint 保留给卡片里那些不需要与其他栏对齐的说明。
 */
.lbl-hint {
  margin-left: 8px;
  font-weight: 400;
  font-size: 11.5px;
  color: var(--muted);
}
/* label 行放不下时（窄屏）让说明另起一行，而不是把标签挤成两行错位 */
@media (max-width: 860px) {
  .lbl-hint { display: block; margin: 2px 0 0; }
}
label.field .req { color: var(--bad); margin-left: 2px; }
input[type=text], input[type=password], input[type=number],
input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; padding: 7px 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--font);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, .16);
}
input::placeholder, textarea::placeholder { color: #5d6b85; }
textarea { resize: vertical; min-height: 66px; font-family: var(--mono); font-size: 12.5px; }
select { cursor: pointer; }
.hint { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filters label.field { margin-bottom: 0; min-width: 132px; }
.filters .grow { flex: 1; min-width: 180px; }

/* ---------------- 状态块（加载/空/错误） ---------------- */

.state {
  padding: 34px 18px; text-align: center;
  color: var(--muted); font-size: 13px;
}
.state .ico { font-size: 22px; opacity: .5; display: block; margin-bottom: 8px; }
.state .txt { margin-bottom: 4px; }
.state .why { font-size: 12px; opacity: .75; }
.state.err { color: #fca5a5; }
.state.err .ico { color: var(--bad); opacity: .8; }

.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid var(--border-strong); border-top-color: var(--info);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 页面级提示条 */
.notice {
  padding: 9px 13px; border-radius: var(--radius-sm);
  font-size: 12.5px; margin-bottom: 13px;
  border: 1px solid transparent;
}
.notice.ok   { background: var(--ok-bg);   color: #86efac; border-color: rgba(34,197,94,.3); }
.notice.bad  { background: var(--bad-bg);  color: #fca5a5; border-color: rgba(239,68,68,.3); }
.notice.warn { background: var(--warn-bg); color: #fcd34d; border-color: rgba(245,158,11,.3); }
.notice.info { background: var(--info-bg); color: #7dd3fc; border-color: rgba(56,189,248,.3); }

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

.pager {
  display: flex; align-items: center; gap: 9px;
  margin-top: 12px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap;
}
.pager .pages { margin-left: auto; display: flex; gap: 6px; }

/* ---------------- 键值详情 ---------------- */

.kv { display: grid; grid-template-columns: 132px 1fr; gap: 7px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-all; font-family: var(--mono); font-size: 12.5px; }

pre.code {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px;
  overflow: auto; font-family: var(--mono); font-size: 12px;
  color: var(--text-dim); max-height: 340px; margin: 0;
  white-space: pre-wrap; word-break: break-all;
}

/* ---------------- 抽屉 ---------------- */

.drawer-mask {
  position: fixed; inset: 0; background: rgba(3, 7, 18, .68);
  z-index: 60; display: flex; justify-content: flex-end;
}
.drawer {
  width: min(680px, 100%); height: 100%; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border);
  padding: 18px 20px 40px; box-shadow: var(--shadow);
}
.drawer h3 { margin: 0 0 4px; font-size: 15px; }
.drawer .drawer-sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.drawer .close {
  float: right; background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 6px;
}
.drawer .close:hover { color: var(--text); }

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

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-box { width: min(400px, 100%); }
.login-box .card { padding: 26px 24px; }
.login-box h1 { margin: 0 0 4px; font-size: 19px; }
.login-box .lead { color: var(--muted); font-size: 12.5px; margin-bottom: 20px; }
.login-box .foot { text-align: center; margin-top: 15px; font-size: 12px; color: var(--muted); }

/* ---------------- 首页入口卡 ---------------- */

.portal { max-width: 1000px; margin: 0 auto; padding: 40px 20px; }
.portal > h1 { font-size: 22px; margin: 0 0 5px; }
.portal > .lead { color: var(--muted); margin-bottom: 26px; font-size: 13px; }
.portal .links { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); }
.portal .link-card {
  display: block; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); transition: border-color .12s, transform .12s;
}
.portal .link-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.portal .link-card h3 { margin: 0 0 5px; font-size: 15px; }
.portal .link-card p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------------- 响应式：手机可看 ---------------- */

@media (max-width: 900px) {
  .grid.cols-4, .grid.cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 10px 0;
  }
  .sidebar .brand { padding-bottom: 10px; }
  .sidebar .nav-inner { display: flex; overflow-x: auto; gap: 4px; padding: 0 8px; }
  .nav-group { margin: 0; }
  .nav-group > .nav-title { display: none; }
  .nav-item { border-left: none; border-radius: var(--radius-sm); white-space: nowrap; padding: 6px 11px; }
  .nav-item.active { border-left: none; }
  .nav-item svg { display: none; }
  .content { padding: 14px 12px 34px; }
  .topbar { padding: 10px 12px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv .k { margin-top: 7px; }
}
@media (max-width: 460px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr; }
  .stat .v { font-size: 19px; }
}