:root {
  --auth-primary: #7c5cff;
  --auth-primary-dark: #6a4df0;
  --auth-bg: #f3f4fb;
  --auth-card: #fff;
  --auth-text: #1f2340;
  --auth-muted: #8b90a8;
  --auth-border: #e8eaf3;
  --auth-danger: #e74c3c;
  --auth-success: #27ae60;
  --auth-warning: #f39c12;
  --auth-info: #3498db;
}

* { box-sizing: border-box; }
body.auth-body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #f5f3ff 0%, #eef2ff 50%, #f8f9fd 100%);
  color: var(--auth-text);
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--auth-card);
  border-radius: 24px;
  padding: 36px 32px 28px;
  box-shadow: 0 20px 60px rgba(124, 92, 255, 0.12);
  border: 1px solid rgba(124, 92, 255, 0.08);
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo {
  width: 72px; height: 72px; margin: 0 auto 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, #8b7bff, #6a4df0);
  color: #fff; font-size: 28px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
}
.auth-brand h1 {
  margin: 0; font-size: 28px; color: var(--auth-primary);
}
.auth-brand p {
  margin: 6px 0 0; color: var(--auth-muted); font-size: 14px;
}

.auth-field { margin-bottom: 18px; }
.auth-field label {
  display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px;
}
.auth-field input, .auth-field textarea, .auth-field select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--auth-border); font-size: 14px;
  outline: none; transition: border .2s, box-shadow .2s;
}
.auth-field input:focus, .auth-field textarea:focus, .auth-field select:focus {
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

.auth-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; font-size: 13px;
}
.auth-row label { display: flex; align-items: center; gap: 6px; color: var(--auth-muted); cursor: pointer; }
.auth-link { color: var(--auth-primary); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }

.btn-auth {
  width: 100%; border: none; border-radius: 999px; padding: 14px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, #8b7bff, #6a4df0);
  color: #fff; box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
  transition: transform .15s, box-shadow .15s;
}
.btn-auth:hover { transform: translateY(-1px); }
.btn-auth:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.auth-footer {
  margin-top: 20px; text-align: center; font-size: 13px; color: var(--auth-muted);
}
.auth-footer a { color: var(--auth-primary); text-decoration: none; margin: 0 8px; }
.auth-https-hint { text-align: center; margin-top: 14px; font-size: 13px; color: var(--auth-muted); }
.https-login-link { color: var(--auth-primary); text-decoration: underline; }
.https-login-link:hover { opacity: 0.85; }

.auth-error {
  background: #fff0f0; color: var(--auth-danger); border: 1px solid #ffd6d6;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px;
}
.auth-error:empty,
.auth-error.hidden { display: none !important; }

.hidden { display: none !important; }

/* Admin layout */
.admin-body { background: var(--auth-bg); min-height: 100vh; }
.admin-top {
  background: #fff; border-bottom: 1px solid var(--auth-border);
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
}
.admin-top-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.admin-top-brand h1 { margin: 0; font-size: 18px; color: var(--auth-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-header-logo {
  width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.admin-header-logo-img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.admin-main { max-width: 1200px; margin: 0 auto; padding: 24px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; border-radius: 16px; padding: 20px; border: 1px solid var(--auth-border);
  box-shadow: 0 4px 16px rgba(0,0,0,.04);
}
.stat-card .num { font-size: 32px; font-weight: 800; }
.stat-card .label { font-size: 13px; color: var(--auth-muted); margin-top: 4px; }
.stat-card.purple .num { color: var(--auth-primary); }
.stat-card.green .num { color: var(--auth-success); }
.stat-card.orange .num { color: var(--auth-warning); }
.stat-card.blue .num { color: var(--auth-info); }

.quick-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px;
}
.quick-btn {
  background: #fff; border: 1px solid var(--auth-border); border-radius: 14px;
  padding: 18px 12px; text-align: center; cursor: pointer; transition: .15s;
}
.quick-btn:hover, .quick-btn.active { border-color: var(--auth-primary); background: #f8f6ff; }
.quick-btn .ico { font-size: 28px; display: block; margin-bottom: 6px; }
.quick-btn .txt { font-size: 13px; font-weight: 600; }

.panel {
  background: #fff; border-radius: 16px; border: 1px solid var(--auth-border);
  padding: 20px; margin-bottom: 20px; display: none;
}
.panel.active { display: block; }
.panel-title { font-size: 16px; font-weight: 700; margin: 0 0 16px; }
.panel-hint { color: var(--auth-muted); font-size: 13px; margin: -8px 0 16px; line-height: 1.5; }
.settings-status { font-size: 13px; margin: 0 0 12px; min-height: 20px; }
.settings-status.ok { color: #16a34a; }
.settings-status.err { color: #dc2626; }
.settings-status.pending { color: #d97706; }
.site-preview-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 16px;
  background: var(--auth-card); border: 1px solid var(--auth-border); border-radius: 12px;
}
.site-preview-logo {
  width: 48px; height: 48px; border-radius: 12px; background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.site-preview-img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.site-preview-text strong { display: block; font-size: 16px; margin-bottom: 4px; }
.site-preview-text p { margin: 0; color: var(--auth-muted); font-size: 13px; line-height: 1.5; }
.img-upload-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload-preview { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; border: 1px solid var(--auth-border); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td {
  padding: 10px 8px; border-bottom: 1px solid var(--auth-border); text-align: left;
}
.admin-table th { color: var(--auth-muted); font-weight: 600; }

.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--auth-border);
}

.field-hint { font-size: 12px; color: var(--auth-muted); margin-top: 6px; line-height: 1.5; }

.contact-config-card {
  background: linear-gradient(180deg, #faf9ff 0%, #fff 100%);
  border: 1px solid var(--auth-border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 8px;
}
.contact-channels { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.contact-channel {
  border: 1px solid var(--auth-border);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.contact-channel.active {
  border-color: rgba(124, 92, 255, 0.45);
  box-shadow: 0 4px 20px rgba(124, 92, 255, 0.1);
  background: linear-gradient(180deg, #f8f6ff 0%, #fff 100%);
}
.contact-channel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; font-weight: 600; font-size: 14px; cursor: pointer;
  margin: 0;
}
.contact-channel-head input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--auth-primary); cursor: pointer; }
.contact-channel-body { padding: 0 16px 16px; }
.contact-channel-body.hidden { display: none; }
.contact-qr-preview-wrap { position: relative; display: inline-block; margin-top: 12px; }
.contact-qr-preview {
  width: 120px; height: 120px; object-fit: contain; border-radius: 12px;
  border: 1px solid var(--auth-border); background: #fff; padding: 6px;
}
.contact-qr-rm {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: 50%; border: none; background: var(--auth-primary); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(124,92,255,.35);
}
.vip-config-card {
  background: linear-gradient(180deg, #fffbeb 0%, #fff 100%);
  border: 1px solid #fde68a; border-radius: 14px; padding: 16px; margin-bottom: 8px;
}

.ui-select, .ui-input {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--auth-border); font-size: 14px; background: #fff;
  outline: none; transition: border .2s, box-shadow .2s;
}
.ui-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b90a8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.ui-select:focus, .ui-input:focus {
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12);
}

.auth-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b90a8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.btn-sm {
  border-radius: 10px; font-weight: 600;
  background: linear-gradient(135deg, #8b7bff, #6a4df0);
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.2);
  transition: transform .12s, filter .12s;
}
.btn-sm:hover { transform: translateY(-1px); filter: brightness(1.03); }
.btn-sm:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm.outline { box-shadow: none; }
.btn-sm.danger { background: var(--auth-danger); box-shadow: 0 4px 12px rgba(231,76,60,.25); }
.btn-sm + .btn-sm { margin-left: 6px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .stat-grid, .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 16px; max-width: 480px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--auth-border);
}
.modal-head h3 { font-size: 16px; margin: 0; color: var(--auth-primary); }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--auth-muted); line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--auth-border);
}
