/* AK License 后台 · 统一样式（浅色） */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --line: #e6eaf2;
  --bg: #f4f6fb;
  --white: #ffffff;
  --green: #16a34a;
  --green-soft: #eaf7ee;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

button { font-family: inherit; cursor: pointer; }

input, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  background: var(--white);
  color: var(--text-2);
  border-color: var(--line);
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #cbd5e1; color: var(--text); }

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

.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); border-color: transparent; }

.btn-danger { color: var(--red); border-color: #f3cccc; background: #fff; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 10% -10%, #dbeafe 0%, rgba(219, 234, 254, 0) 60%),
    radial-gradient(800px 400px at 100% 110%, #e0e7ff 0%, rgba(224, 231, 255, 0) 60%),
    var(--bg);
}

.login-card {
  width: 940px;
  max-width: 100%;
  min-height: 520px;
  background: var(--white);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .12);
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.login-brand {
  background: linear-gradient(160deg, #1e40af 0%, #2563eb 55%, #3b82f6 100%);
  color: #fff;
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-brand::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .16);
  right: -160px;
  bottom: -180px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .5px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
}

.brand-title {
  font-size: 30px;
  line-height: 1.35;
  font-weight: 600;
  margin: 0 0 14px;
}

.brand-desc {
  font-size: 14px;
  line-height: 1.8;
  color: rgba(255, 255, 255, .78);
  margin: 0;
}

.brand-points { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.brand-point { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: rgba(255,255,255,.9); }
.brand-dot { width: 6px; height: 6px; border-radius: 50%; background: #93c5fd; flex: none; }

.brand-foot { font-size: 12px; color: rgba(255, 255, 255, .55); }

.login-form {
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-form h1 { font-size: 22px; margin: 0 0 8px; font-weight: 600; }
.login-form .sub { color: var(--text-3); font-size: 13.5px; margin: 0 0 30px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; }

.login-form .btn-primary { width: 100%; padding: 11px; margin-top: 8px; }

.alert {
  display: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #f3cccc;
}
.alert.show { display: block; }

/* ---------------------------------------------------------------- 后台框架 */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: none;
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 22px 20px;
  border-bottom: 1px solid var(--line);
}

.side-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

.side-title { font-weight: 600; font-size: 15px; }
.side-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: #f6f8fc; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }

.nav-icon {
  width: 18px; height: 18px; flex: none;
  display: flex; align-items: center; justify-content: center;
  opacity: .8;
}

.nav-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.side-foot { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); }

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

.topbar {
  height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-2); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}

.content { padding: 26px 28px 40px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label { font-size: 13px; color: var(--text-3); margin-bottom: 10px; }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -.5px; }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }
.stat-value.blue { color: var(--primary); }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.card-title { font-size: 15px; font-weight: 600; }
.card-tools { display: flex; align-items: center; gap: 10px; }
.card-tools input { width: 220px; }
.card-tools select { width: 130px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 12.5px;
  padding: 11px 16px;
  background: #fafbfe;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td { padding: 13px 16px; border-bottom: 1px solid #f1f4f9; vertical-align: middle; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: none; }

.mono { font-family: "SF Mono", Consolas, "Courier New", monospace; font-size: 12.5px; color: var(--text-2); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-allowed { background: var(--green-soft); color: var(--green); }
.tag-pending { background: var(--amber-soft); color: var(--amber); }
.tag-denied { background: var(--red-soft); color: var(--red); }

.dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty { padding: 56px 20px; text-align: center; color: var(--text-3); font-size: 13.5px; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; font-size: 13px; color: var(--text-3); }
.pager-btns { display: flex; gap: 8px; }

.hint { font-size: 12.5px; color: var(--text-3); line-height: 1.7; }

/* 弹窗 */
.modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask.show { display: flex; }

.modal {
  background: var(--white);
  border-radius: 14px;
  width: 480px;
  max-width: 100%;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
  overflow: hidden;
}

.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.modal-body { padding: 20px 22px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-14px);
  background: #0f172a;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 9px;
  opacity: 0;
  pointer-events: none;
  transition: all .22s;
  z-index: 99;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .login-card { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .sidebar { width: 76px; }
  .side-title, .side-sub, .nav-item span.label, .side-foot { display: none; }
  .nav-item { justify-content: center; }
}

/* ============================================================
   手机端（<= 640px）
   侧栏变底部标签栏，表格变卡片，表单全宽
   ============================================================ */
@media (max-width: 640px) {

  html, body { overflow-x: hidden; }

  /* iOS 上输入框小于 16px 会触发自动放大，这里统一提到 16px */
  input, select, textarea { font-size: 16px; }

  /* ---------------- 登录页
     .login-brand 已在 1080 断点隐藏，这里只收内边距 */
  .login-wrap {
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    align-items: flex-start;
  }
  .login-card { min-height: auto; border-radius: 14px; }
  .login-form { padding: 30px 20px 34px; }
  .login-form h1 { font-size: 20px; }
  .login-form .sub { margin-bottom: 22px; }

  /* ---------------- 框架：侧栏 -> 底部标签栏 */
  .layout { display: block; }

  .sidebar {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    border-right: none;
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 14px rgba(15, 23, 42, .07);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 40;
  }

  .side-brand, .side-foot, .side-sub { display: none; }

  .nav {
    flex-direction: row;
    align-items: stretch;
    padding: 6px 6px 4px;
    gap: 2px;
    flex: 1;
  }

  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 7px 2px 6px;
    font-size: 11px;
    text-align: center;
    border-radius: 10px;
  }

  .nav-item span.label { display: block; }
  .nav-icon, .nav-icon svg { width: 21px; height: 21px; }

  .main { padding-bottom: 0; }

  /* ---------------- 顶栏 */
  .topbar {
    height: 54px;
    padding: 0 14px;
    gap: 10px;
  }
  .topbar h2 { font-size: 15px; }
  .topbar-right { gap: 8px; font-size: 12px; }
  #serverTime, #adminName { display: none; }
  .avatar { width: 28px; height: 28px; font-size: 12px; }

  /* ---------------- 内容区 */
  .content {
    padding: 12px 10px calc(84px + env(safe-area-inset-bottom));
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
    margin-bottom: 12px;
  }
  .stat { padding: 12px 14px; border-radius: 10px; }
  .stat-label { font-size: 12px; margin-bottom: 5px; }
  .stat-value { font-size: 21px; }

  .card { border-radius: 10px; }

  .card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .card-title { font-size: 14px; }
  .card-tools { flex-wrap: wrap; gap: 8px; }
  .card-tools input { flex: 1 1 100%; width: 100%; }
  .card-tools select { flex: 1 1 auto; width: auto; min-width: 0; }
  .card-tools .btn { flex: 0 0 auto; padding: 9px 14px; }

  /* ---------------- 表格 -> 卡片 */
  .card table { display: block; }
  .card thead { display: none; }
  .card tbody { display: block; }

  .card tbody tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 10px 12px;
    padding: 2px 0 10px;
    background: var(--white);
  }
  .card tbody tr:hover { background: var(--white); }
  .card tbody tr:last-child td { border-bottom: none; }

  .card td {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 5px 14px;
    border-bottom: none;
    font-size: 13px;
    line-height: 1.55;
    min-width: 0;
  }

  .card td[data-label]::before {
    content: attr(data-label);
    flex: none;
    width: 62px;
    color: var(--text-3);
    font-size: 12.5px;
    line-height: 1.55;
  }

  /* 第一格当标题：openid / 时间 */
  .card td.cell-openid,
  .card td.cell-time {
    display: block;
    padding-top: 11px;
    font-weight: 600;
  }
  .card td.cell-time { color: var(--text) !important; padding-bottom: 2px; }
  .card td.cell-openid .mono { font-weight: 400; }

  .card td.cell-actions { padding-top: 9px; }
  .row-actions { justify-content: flex-start; flex: 1; }
  .row-actions .btn { flex: 1; padding: 9px 10px; }

  .empty { padding: 40px 18px; }

  .pager { padding: 10px 14px; font-size: 12.5px; }

  /* ---------------- 账号设置 */
  #view-settings > .card { max-width: 100% !important; }
  #view-settings > .card > div[style] { padding: 16px !important; }
  #view-settings .mono {
    font-size: 12px;
    word-break: break-all;
    white-space: normal;
  }
  #view-settings .btn-primary { width: 100%; padding: 11px; }

  /* ---------------- 弹窗 */
  .modal-mask { padding: 14px; }
  .modal { width: 100%; border-radius: 12px; }
  .modal-head { padding: 16px 16px; }
  .modal-body { padding: 16px 16px; }
  .modal-foot { padding: 12px 16px; }
  .modal-foot .btn { flex: 1; padding: 11px; }

  .toast {
    top: auto;
    bottom: calc(78px + env(safe-area-inset-bottom));
    max-width: calc(100% - 32px);
    text-align: center;
  }
}

/* 超窄屏（<= 360px）再收一点 */
@media (max-width: 360px) {
  .card td[data-label]::before { width: 54px; }
  .stat-value { font-size: 19px; }
  .nav-item { font-size: 10px; }
}

