/* ============ PayGateway Admin UI ============ */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e6e9f2;
  --text: #1c2333;
  --text-2: #6b7280;
  --primary: #4f46e5;
  --primary-h: #4338ca;
  --success: #059669;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --sidebar-bg: #10162a;
  --sidebar-w: 232px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ================= 登录页：左右分屏 ================= */
.login-wrap {
  min-height: 100vh;
  display: flex;
}
.login-left {
  flex: 1.1;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(99, 102, 241, .35), transparent 60%),
    radial-gradient(ellipse 50% 60% at 85% 90%, rgba(14, 165, 233, .22), transparent 60%),
    linear-gradient(150deg, #111827 0%, #1e1b4b 55%, #312e81 100%);
  color: #fff;
  padding: 64px 72px;
  display: flex; flex-direction: column;
}
.ll-brand { font-size: 17px; font-weight: 700; letter-spacing: 1px; color: #a5b4fc; }
.login-left h1 {
  font-size: 34px; font-weight: 800; line-height: 1.35;
  letter-spacing: -.5px; margin: auto 0 0; max-width: 480px;
}
.ll-sub { color: rgba(255,255,255,.55); font-size: 14px; margin: 14px 0 0; letter-spacing: 1px; }
.ll-feats { list-style: none; margin: 40px 0 auto; padding: 0; max-width: 420px; }
.ll-feats li {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 0; font-size: 14px; color: rgba(255,255,255,.82);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.ll-feats li:last-child { border-bottom: none; }
.ll-feats .fi {
  width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px;
  background: rgba(99, 102, 241, .3); border: 1px solid rgba(129, 140, 248, .5);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #c7d2fe;
}
.ll-foot { color: rgba(255,255,255,.35); font-size: 12px; letter-spacing: .5px; }

.login-right {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 40px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(30, 27, 75, .1);
  padding: 44px 40px 36px;
}
.lc-title { font-size: 24px; font-weight: 750; letter-spacing: -.3px; }
.lc-sub { color: var(--text-2); font-size: 13px; margin: 8px 0 30px; }
.login-error { color: var(--danger); font-size: 12.5px; text-align: center; margin-top: 14px; min-height: 18px; }

@media (max-width: 860px) {
  .login-left { display: none; }
  .login-right { flex: 1; }
}

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field input {
  width: 100%;
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 11px 14px; font-size: 14px;
  background: #fafbfe; color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.field input::placeholder { color: #9ca3af; }

/* ================= 主界面布局：左侧菜单 ================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  font-weight: 700; color: #e0e7ff; font-size: 16px; letter-spacing: .5px;
  padding: 22px 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  border: none; background: none; cursor: pointer;
  padding: 10px 14px; border-radius: 9px;
  font-size: 13.5px; color: #94a3b8; text-align: left;
  transition: all .15s; width: 100%;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { color: #e2e8f0; background: rgba(255,255,255,.06); }
.nav-item.active {
  color: #fff; background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 4px 14px rgba(79, 70, 229, .35);
}
.nav-item.active svg { opacity: 1; }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.07); }
.me-box { display: flex; align-items: center; gap: 10px; padding: 2px 4px 12px; }
.me-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase;
}
.me-meta { min-width: 0; }
.me-name { color: #e2e8f0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { color: #64748b; font-size: 11.5px; }
.foot-actions { display: flex; gap: 8px; }
.btn-foot {
  flex: 1; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04);
  color: #94a3b8; font-size: 11.5px; padding: 6px 0; border-radius: 8px;
  cursor: pointer; transition: all .15s;
}
.btn-foot:hover { color: #e2e8f0; background: rgba(255,255,255,.1); }
.btn-foot.danger:hover { color: #fca5a5; border-color: rgba(220, 38, 38, .4); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }

.main { flex: 1; padding: 24px 28px; max-width: 1400px; width: 100%; margin: 0 auto; }
.page { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title { font-weight: 600; margin-bottom: 14px; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 24, 40, .08); }
.stat-card.wide { grid-column: span 2; }
.stat-label { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.5px; }
.stat-value.success { color: var(--success); }
.stat-value.danger { color: var(--danger); }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-2); padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px; border-bottom: 1px solid #f0f2f8;
  font-size: 13px; vertical-align: middle;
}
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #f8f9fe; }
.table tbody tr:last-child td { border-bottom: none; }
.td-ellipsis { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-row td { text-align: center; color: var(--text-2); padding: 32px 0; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block; padding: 2px 10px;
  font-size: 12px; border-radius: 999px; font-weight: 500;
}
.badge.on      { background: #ecfdf5; color: var(--success); }
.badge.off     { background: #fef2f2; color: var(--danger); }
.badge.ok      { background: #ecfdf5; color: var(--success); }
.badge.pending { background: #fffbeb; color: var(--warn); }
.badge.fail    { background: #fef2f2; color: var(--danger); }
.badge.refund  { background: #f5f3ff; color: #7c3aed; }
.badge.expired { background: #f3f4f6; color: var(--text-2); }
.badge.role    { background: #eef2ff; color: var(--primary); }
.badge.key     { background: #f3f4f6; color: var(--text-2); font-family: Consolas, monospace; }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  border: 1px solid transparent; border-radius: 9px;
  padding: 8px 16px; font-size: 13px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 12px; font-size: 14px; font-weight: 600; }
.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #4338ca); color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .3);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(79, 70, 229, .4); transform: translateY(-1px); }
.btn-primary:active { transform: none; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f1f3f9; }
.btn-ghost.danger { color: var(--danger); border-color: #fecaca; }
.btn-ghost.danger:hover { background: #fef2f2; }
.btn-link {
  border: none; background: none; color: var(--primary);
  cursor: pointer; font-size: 13px; padding: 2px 6px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.input, select.input {
  border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 12px; font-size: 13px;
  background: var(--card); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.input::placeholder { color: #9ca3af; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input { width: 180px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; color: var(--text-2); font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  animation: fade .15s ease;
}
.modal {
  width: 460px; max-width: 92vw; max-height: 86vh; overflow: auto;
  background: var(--card); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .2);
  padding: 24px;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal .field input, .modal .field textarea, .modal .field select { width: 100%; }
.modal .field input:focus, .modal .field select:focus { background: #fff; }
.key-box {
  display: flex; gap: 8px; align-items: center;
  background: #f8f9fe; border: 1px dashed var(--border);
  border-radius: 8px; padding: 8px 12px;
  font-family: Consolas, monospace; font-size: 12px;
  word-break: break-all;
}

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #111827; color: #fff;
  padding: 10px 18px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: slidein .2s ease;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; } }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .sidebar-foot { display: flex; align-items: center; gap: 12px; }
  .me-box { padding: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 16px; }
}

/* 可点击复制单元格 */
.copyable { cursor: pointer; }
.copyable:hover { color: var(--primary, #4f46e5); text-decoration: underline; }

/* ============ 个人信息 ============ */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px 24px; }
.profile-item { padding: 10px 14px; background: var(--bg-2, #f7f8fc); border-radius: 10px; }
.pi-label { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.pi-value { font-size: 14px; color: var(--text); word-break: break-all; }
