:root {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
  --warn-bg: #fef3c7;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: #f3f4f6; padding: 1px 6px; border-radius: 4px; }

.admin-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}
.admin-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.admin-brand {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}
.admin-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.admin-nav a { color: var(--text-muted); }
.admin-nav a:hover { color: var(--text); text-decoration: none; }
.admin-user { color: var(--text-muted); font-size: 13px; }

.admin-main { padding: 24px 0 48px; }
.admin-footer {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 0;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 560px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.page-header h1 { margin: 0; font-size: 22px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 17px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.form label span code { background: transparent; padding: 0; }
.form input[type="text"],
.form input[type="password"],
.form input[type="number"],
.form input[type="email"],
.form textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
.form input:focus, .form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.form-actions { display: flex; gap: 10px; }
.form label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.link-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; font: inherit; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.inline-form { display: inline; margin: 0; padding: 0; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table th { background: #f9fafb; font-weight: 600; color: var(--text-muted); }
.table tr:last-child td { border-bottom: none; }
.table td.actions { display: flex; gap: 8px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.badge-on { background: #d1fae5; color: #065f46; }
.badge-off { background: #f3f4f6; color: #6b7280; }

.muted { color: var(--text-muted); font-size: 12px; }
.empty {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.qr-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.qr-card {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: grab;
  user-select: none;
}
.qr-card.dragging { opacity: 0.4; }
.qr-card.drag-over { border-color: var(--primary); background: #eef2ff; }
.qr-card__img {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
}
.qr-card__img img { max-width: 100%; max-height: 100%; }
.qr-card__caption-form { display: flex; gap: 6px; }
.qr-card__caption-form input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
}
.qr-card__actions { display: flex; align-items: center; justify-content: space-between; }

.bg-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
}
.bg-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.positioner-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}
.positioner {
  position: relative;
  width: 280px;
  max-width: 100%;
  background: #f3f4f6;
  border-radius: 12px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.positioner__bg {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.positioner__bg--empty {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: repeating-linear-gradient(
    45deg,
    #e5e7eb 0 8px,
    #f3f4f6 8px 16px
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
}
.positioner__qr {
  position: absolute;
  transform: translate(-50%, -50%);
  aspect-ratio: 1 / 1;
  border: 2px dashed rgba(37, 99, 235, 0.85);
  background: rgba(37, 99, 235, 0.08);
  border-radius: 6px;
  cursor: move;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}
.positioner__qr img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
  padding: 4px;
  background: #fff;
  border-radius: 4px;
}
.positioner__qr-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}
.positioner__handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #2563eb;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  touch-action: none;
}
.positioner__readout {
  text-align: center;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 账户设置页 ---------- */
.account-card { padding-top: 18px; }
.account-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.account-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  flex-shrink: 0;
}
.account-username { font-size: 16px; font-weight: 600; color: #111827; }

.section-h {
  font-size: 14px;
  margin: 8px 0 -4px;
  color: var(--text);
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.password-field { gap: 6px; }
.password-input {
  position: relative;
  display: flex;
}
.password-input input {
  flex: 1;
  padding-right: 40px !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.toggle-visible {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}
.toggle-visible:hover { opacity: 1; background: #f3f4f6; }
.toggle-visible.is-shown { opacity: 1; }

.password-strength {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.password-strength__bar {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}
.password-strength__fill {
  height: 100%;
  width: 0%;
  background: #dc2626;
  border-radius: 3px;
  transition: width 0.2s, background 0.2s;
}
.password-strength__label {
  font-size: 12px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.password-rules {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 12px;
  color: #6b7280;
}
@media (max-width: 480px) {
  .password-rules { grid-template-columns: 1fr; }
}
.password-rules li {
  padding-left: 18px;
  position: relative;
  transition: color 0.15s;
}
.password-rules li::before {
  content: '○';
  position: absolute;
  left: 4px;
  color: #cbd5e1;
}
.password-rules li.ok { color: #059669; }
.password-rules li.ok::before { content: '✓'; color: #059669; }
.password-rules li.fail { color: #dc2626; }
.password-rules li.fail::before { content: '✗'; color: #dc2626; }

.match-ok { color: #059669; font-size: 12px; }
.match-fail { color: #dc2626; font-size: 12px; }

.danger-card { border-color: #fde68a; background: #fffbeb; }
.danger-card h2 { color: #92400e; }
.danger-card ul { padding-left: 18px; }
.danger-card li { margin: 4px 0; }

.login-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 360px;
  padding: 28px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 18px; color: var(--text-muted); font-size: 13px; }
