:root {
  --bg: #edf2f8;
  --ink: #1b2a3a;
  --muted: #5f7388;
  --card: rgba(255, 255, 255, 0.94);
  --line: #d9e3ee;
  --brand: #175fc2;
  --brand-2: #204b85;
  --danger: #c23838;
  --ok: #2d8b57;
  --sidebar: #152234;
  --sidebar-ink: #d8e3f1;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, #e4edf8 0, rgba(228, 237, 248, 0) 42%),
    radial-gradient(circle at 92% 96%, #e4f0e9 0, rgba(228, 240, 233, 0) 46%),
    linear-gradient(145deg, #f3f7fc 0%, #e9eff6 100%);
}
a { color: var(--brand); text-decoration: none; }

.client-body {
  overflow-x: hidden;
}

.gradient-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 0 0, #dbe7f7 0, rgba(219, 231, 247, 0) 48%),
              radial-gradient(circle at 100% 100%, #dcefe2 0, rgba(220, 239, 226, 0) 52%);
  z-index: -1;
}

.client-wrap {
  max-width: 1120px;
  margin: 28px auto;
  padding: 0 16px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}
.client-wrap > .user-bar { grid-column: 1 / -1; }
.client-wrap > .mini { grid-column: 1 / -1; }
.client-wrap { width: 100%; overflow-x: hidden; }
.client-wrap > * { max-width: 100%; }
.client-wrap table { table-layout: fixed; }
.client-wrap th,
.client-wrap td { word-break: break-word; }
.card {
  background: var(--card);
  backdrop-filter: blur(2px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 20px 35px -12px rgba(16, 36, 60, 0.14), 0 2px 5px rgba(16, 36, 60, 0.05);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 28px 42px -16px rgba(16, 36, 60, 0.18), 0 4px 10px rgba(16, 36, 60, 0.06);
}
.card.mini { padding-top: 14px; }
.card.white { background: #fff; }
h1 { margin: 0 0 12px; font-size: 28px; letter-spacing: -.3px; }
h2 { margin: 0 0 10px; font-size: 20px; letter-spacing: -.2px; }
.muted { color: var(--muted); }

.form-grid { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 14px; }
input, select, textarea, button {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
}
input, select, textarea {
  background: rgba(246, 249, 253, 0.95);
}
button {
  border: 0;
  color: #fff;
  background: linear-gradient(125deg, var(--brand), var(--brand-2));
  cursor: pointer;
  border-radius: 999px;
  font-weight: 600;
}
button:hover { filter: brightness(1.05); }

.alert { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.alert.error { background: #ffe9e9; color: var(--danger); }
.alert.success { background: #e9f8ee; color: var(--ok); }
.result-box {
  border: 1px dashed #8ab3e4;
  padding: 12px;
  border-radius: 14px;
  margin-bottom: 12px;
  background: rgba(235, 244, 255, 0.55);
}
.btn-danger { background: linear-gradient(120deg, #cf2e2e, #a81f1f); }
.btn-copy {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.record-link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.record-link-row.compact {
  gap: 8px;
}

.record-link-row a {
  word-break: break-all;
}

.client-banner-wrap {
  margin: 14px 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #f6f9fd;
}

.client-banner-image {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; font-size: 13px; text-align: left; vertical-align: top; }
.td-url { word-break: break-all; }

.guide-lock {
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  background: #000;
}
.guide-canvas {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
}
.guide-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.guide-feature {
  position: fixed;
  right: 8px;
  bottom: 6px;
  color: rgba(255, 255, 255, .15);
  font-size: 11px;
  letter-spacing: .6px;
}

.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(140deg, #eff6ff, #f7fff4); }
.login-box { width: min(90vw, 380px); background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; }

.user-login-body {
  min-height: 100vh;
  background: #efefef;
  display: grid;
  place-items: center;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
.user-login-shell {
  width: min(100%, 420px);
  min-height: 100vh;
  background: #f7f7f8;
}
.user-login-topbar {
  height: 54px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: #132843;
}
.topbar-back {
  color: #233651;
  font-size: 28px;
  line-height: 1;
  margin-left: 8px;
}
.topbar-gap { display: inline-block; }
.user-login-card { padding: 12px 24px 24px; }
.login-brand-wrap { text-align: center; margin: 28px 0 14px; }
.brand-logo {
  width: 116px;
  height: 116px;
  margin: 0 auto 16px;
  border-radius: 24px;
  background: linear-gradient(140deg, #ef9d4b, #cf7626);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 50px;
  font-weight: 700;
}
.brand-logo-img {
  width: 116px;
  height: 116px;
  margin: 0 auto 16px;
  border-radius: 24px;
  object-fit: cover;
  display: block;
}
.user-login-card h1 { text-align: center; margin: 2px 0; font-size: 40px; color: #162742; }
.user-login-card p { text-align: center; color: #98a2ad; margin-bottom: 22px; }

.login-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 14px; border-bottom: 1px solid #e9ecf3; }
.tab-btn {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #7a848f;
  border-radius: 0;
}
.tab-btn.active { color: #4f7de6; border-bottom-color: #4f7de6; }
.login-pane { display: none; }
.login-pane.active { display: grid; }
.login-pane input {
  height: 48px;
  border-radius: 12px;
  border: 1px solid #e4e7ee;
  background: #f2f3f6;
}
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.code-row .btn-light {
  height: 48px;
  border-radius: 12px;
  background: #dfe8ff;
  color: #3b63c7;
}
.inline-check { display: flex; align-items: center; gap: 8px; color: #7f8a96; font-size: 14px; }
.inline-check input { width: 16px; height: 16px; }
.login-submit {
  height: 48px;
  border-radius: 12px;
  font-size: 22px;
  letter-spacing: 2px;
}
.login-forgot { margin-top: 6px; font-size: 14px; color: #7f8a96; }

.avatar-round { border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.avatar-sm { width: 34px; height: 34px; }
.avatar-md { width: 44px; height: 44px; }
.avatar-lg { width: 86px; height: 86px; }
.avatar-preview-wrap { margin-bottom: 12px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-bar { display: flex; justify-content: space-between; align-items: center; }
.top-actions { display: flex; gap: 12px; }
.top-actions a {
  border: 1px solid var(--line);
  background: rgba(246, 249, 253, 0.9);
  color: #1d3551;
  border-radius: 999px;
  padding: 7px 12px;
}

.btn-secondary { background: linear-gradient(120deg, #6f7888, #576072); }
.config-card { max-width: 760px; }
.admin-actions-wrap { display: grid; gap: 8px; }
.admin-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.recharge-form { display: grid; grid-template-columns: 1fr auto; gap: 6px; }

.login-preview-mini {
  width: 280px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
  background: #f7f8fa;
}
.mini-top { text-align: center; font-weight: 700; margin-bottom: 12px; }
.mini-logo-wrap { display: grid; place-items: center; }
.mini-logo-img { width: 76px; height: 76px; object-fit: cover; border-radius: 16px; }
.mini-logo-text {
  width: 76px;
  height: 76px;
  border-radius: 16px;
  background: linear-gradient(140deg, #ef9d4b, #cf7626);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
}
.mini-title { text-align: center; margin-top: 10px; font-weight: 700; }
.mini-sub { text-align: center; color: #8f98a3; margin-top: 6px; font-size: 13px; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  background: linear-gradient(165deg, #182538 0%, #101a2b 100%);
  color: var(--sidebar-ink);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
}
.brand { font-size: 22px; font-weight: 700; letter-spacing: .3px; margin-bottom: 18px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a { color: #bfd0e4; padding: 10px 11px; border-radius: 12px; }
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,.14); color: #fff; }
.sidebar a.disabled { opacity: .5; cursor: not-allowed; }
.nav-group { margin-top: 10px; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: #7e96b5; }
.logout { margin-top: auto; }

.admin-content { padding: 26px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin: 14px 0 16px; }
.stat-card { background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.stat-card span { font-size: 13px; color: var(--muted); display: block; margin-bottom: 5px; }
.stat-card strong { font-size: 28px; }
.table-card { background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.template-list { display: grid; gap: 10px; }
.template-item {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.template-thumb {
  width: 86px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.template-meta { display: grid; gap: 4px; }
.template-actions { display: grid; gap: 8px; }
.template-actions form { margin: 0; }
.template-actions button { min-width: 74px; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .client-wrap { grid-template-columns: 1fr; }
  .user-bar { display: grid; gap: 10px; }
  .top-actions { justify-content: flex-start; }
  .template-item { grid-template-columns: 74px 1fr; }
  .template-thumb { width: 74px; height: 98px; }
  .template-actions { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .record-link-row { align-items: stretch; }
}

@media (min-width: 901px) {
  .user-login-body {
    background: linear-gradient(135deg, #e8f2fe 0%, #eef5ff 40%, #f3f8ff 100%);
    padding: 0;
    align-items: center;
  }
  .user-login-shell {
    width: min(440px, 90vw);
    min-height: auto;
    border-radius: 20px;
    box-shadow: 0 12px 56px rgba(17, 35, 80, 0.16), 0 2px 12px rgba(17, 35, 80, 0.08);
    overflow: hidden;
    background: #fff;
  }
  /* 在PC上隐藏移动端顶部导航栏（含返回按钮） */
  .user-login-topbar { display: none; }
  .user-login-card { padding: 36px 36px 40px; }
  .login-brand-wrap { margin: 0 0 22px; }
}

@media (max-width: 520px) {
  .user-login-shell { width: 100%; }
  .user-login-card { padding: 10px 16px 18px; }
  .brand-logo { width: 100px; height: 100px; font-size: 42px; border-radius: 20px; }
  .brand-logo-img { width: 100px; height: 100px; border-radius: 20px; }
  .user-login-card h1 { font-size: 32px; }
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 20, 31, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}
.confirm-overlay.show { display: flex; }
.confirm-dialog {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #d7dde7;
  box-shadow: 0 18px 42px rgba(8, 18, 32, 0.22);
  overflow: hidden;
}
.confirm-title {
  font-size: 16px;
  font-weight: 700;
  padding: 16px 18px 6px;
  color: #1d2633;
}
.confirm-message {
  padding: 0 18px 14px;
  color: #4e5a69;
  line-height: 1.6;
  word-break: break-word;
}
.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid #e8edf4;
}
.confirm-btn {
  appearance: none;
  border: 0;
  background: #fff;
  height: 46px;
  font-size: 14px;
  cursor: pointer;
}
.confirm-btn.cancel { color: #516070; border-right: 1px solid #e8edf4; }
.confirm-btn.ok { color: #2f63d8; font-weight: 700; }
.confirm-btn:hover { background: #f4f7fc; }
.confirm-btn:active { background: #eaf0fb; }
