/* 站内后台面板 */
.ap-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 16px;
}

.ap-root[hidden] { display: none; }

.ap-scrim {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 32, .34);
  backdrop-filter: blur(8px);
}

.ap-panel,
.ap-login {
  position: relative;
  width: min(760px, 100%);
  max-height: min(86vh, 780px);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 40px 90px -50px rgba(12, 18, 32, .8), inset 0 1px 0 #fff;
  backdrop-filter: blur(30px) saturate(180%);
  overflow: hidden;
  animation: ap-in .34s var(--spring);
}

[data-theme="dark"] .ap-panel,
[data-theme="dark"] .ap-login {
  background: rgba(24, 28, 42, .95);
  border-color: rgba(255, 255, 255, .12);
}

@keyframes ap-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.ap-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(16, 24, 40, .08);
  flex: none;
}

.ap-tabs { display: flex; gap: 2px; margin-left: auto; }

.ap-tabs button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted, #6b7280);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ap-tabs button[aria-selected="true"] { background: rgba(0, 122, 255, .12); color: var(--ios-blue, #007aff); }

.ap-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(16, 24, 40, .1);
  background: rgba(255, 255, 255, .8);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink, #0b0d12);
}

.ap-body { overflow: auto; padding: 14px 16px 18px; }
.ap-body section[hidden] { display: none; }

.ap-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ap-tools .input { height: 34px; font-size: 13px; }
.ap-count { font-size: 12px; color: var(--muted, #6b7280); margin-left: auto; }

.ap-list { display: grid; gap: 8px; }

.ap-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .7);
  border: 1px solid rgba(16, 24, 40, .07);
}

[data-theme="dark"] .ap-row { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .08); }

.ap-row--wrap { flex-wrap: wrap; }

.ap-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  object-fit: contain;
  background: #fff;
  flex: none;
}

.ap-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.ap-main .input { height: 32px; font-size: 13px; max-width: 220px; }
.ap-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.ap-sub { font-size: 12px; color: var(--muted, #6b7280); }

.ap-chips { display: flex; flex-wrap: wrap; gap: 5px; width: 100%; }

.ap-hint { font-size: 12px; color: var(--muted, #6b7280); margin: 10px 2px 0; }

/* 表单 */
.ap-form { display: grid; gap: 12px; max-width: 420px; }
.ap-switches { display: grid; gap: 8px; }

/* 登录 */
.ap-login {
  width: min(360px, 100%);
  padding: 26px 24px;
  display: grid;
  gap: 10px;
  text-align: center;
}

.ap-login-logo {
  width: 52px; height: 52px;
  margin: 0 auto 2px;
  border-radius: 15px;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 700; color: #fff;
  background: linear-gradient(160deg, #0a7bff, #5ac8fa);
}

.ap-login h2 { margin: 0; font-size: 19px; }
.ap-error { color: #e5484d; font-size: 13px; margin: 0; }

/* 弹窗 */
.ap-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 18, 32, .4);
  backdrop-filter: blur(6px);
}

.ap-modal-card {
  width: min(480px, 100%);
  max-height: 86vh;
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 70px -40px rgba(12, 18, 32, .8);
}

[data-theme="dark"] .ap-modal-card { background: #1b2030; color: #eef1f8; }
.ap-modal-card h3 { margin: 0; font-size: 17px; }
.ap-modal-body { display: grid; gap: 10px; }
.ap-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* 后台开启时锁滚动 */
body.admin-open { overflow: hidden; }

@media (max-width: 719px) {
  .ap-panel { max-height: 92vh; border-radius: 20px; }
  .ap-head { flex-wrap: wrap; }
  .ap-tabs { width: 100%; margin: 6px 0 0; }
  .ap-tabs button { flex: 1; padding: 0 6px; }
}

/* 面板里的按钮统一成系统蓝（站点主样式里的紫色不要串进来） */
.ap-root .btn,
.ap-panel .btn {
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(16, 24, 40, .1);
  color: var(--ink, #0b0d12);
  box-shadow: none;
  filter: none;
}

.ap-root .btn-primary,
.ap-panel .btn-primary {
  background: var(--ios-blue, #007aff);
  border-color: transparent;
  color: #fff;
}

.ap-root .btn-danger,
.ap-panel .btn-danger {
  background: rgba(229, 72, 77, .08);
  border-color: rgba(229, 72, 77, .22);
  color: #e5484d;
}

.ap-root .btn-ghost,
.ap-panel .btn-ghost { background: transparent; }

.ap-root .input,
.ap-panel .input {
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(16, 24, 40, .12);
  border-radius: 10px;
}

[data-theme="dark"] .ap-root .input,
[data-theme="dark"] .ap-panel .input {
  background: rgba(255, 255, 255, .08);
  color: #eef1f8;
  border-color: rgba(255, 255, 255, .14);
}

/* 数据面板 */
.ap-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.ap-kpi { padding: 14px; border-radius: 14px; background: rgba(0, 122, 255, .07); text-align: center; }
.ap-kpi b { display: block; font-size: 24px; color: var(--ios-blue); }
.ap-kpi span { font-size: 12px; color: var(--muted, #6b7280); }
.ap-h4 { margin: 18px 2px 8px; font-size: 13px; color: var(--muted, #6b7280); }
.ap-bars { display: grid; gap: 8px; }
.ap-bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.ap-bar-name { width: 120px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-bar { flex: 1; height: 8px; border-radius: 999px; background: rgba(16, 24, 40, .08); overflow: hidden; }
.ap-bar i { display: block; height: 100%; border-radius: 999px; background: var(--ios-blue); }
.ap-bar-num { width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

/* 主题色选择 */
.ap-colors { display: flex; gap: 8px; flex-wrap: wrap; }
.ap-color { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.ap-color.is-on { border-color: #0b0d12; box-shadow: 0 0 0 3px rgba(0, 0, 0, .08); }
