/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-light: #e8f0fe;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e0e4e8;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
  color: #fff;
  padding: 20px 24px;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 { font-size: 22px; font-weight: 600; }
.header .subtitle { font-size: 14px; opacity: 0.85; margin-top: 4px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 13px; opacity: 0.9; }
.header-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.header-btn:hover { background: rgba(255,255,255,0.25); }

/* ===== Container ===== */
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }

/* ===== Main Layout ===== */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .main-layout { grid-template-columns: 1fr; }
  .preview-panel { order: -1; }
}

/* ===== Panel ===== */
.form-panel, .preview-panel, .history-panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 16px; font-weight: 600; }
.badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* ===== Form ===== */
#qrForm { padding: 20px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.required { color: #e74c3c; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
.form-group input::placeholder { color: #bbb; }
.form-group textarea { resize: vertical; min-height: 60px; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon { font-size: 16px; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ===== Preview ===== */
.preview-panel { position: sticky; top: 24px; }
.preview-empty {
  padding: 60px 20px;
  text-align: center;
  color: #bbb;
}
.preview-empty .empty-icon { font-size: 64px; margin-bottom: 12px; opacity: 0.5; }
.preview-empty p { font-size: 14px; line-height: 1.8; }

.preview-content { padding: 20px; }
.qr-display {
  text-align: center;
  margin-bottom: 16px;
}
.qr-display img {
  width: 320px;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}
.qr-info {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.qr-text {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 16px;
  white-space: pre-wrap;
  word-break: break-all;
}
.preview-actions {
  display: flex;
  gap: 8px;
}
.preview-actions .btn { flex: 1; justify-content: center; }

/* ===== History ===== */
.history-tools {
  display: flex;
  gap: 8px;
}
.history-tools input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  width: 200px;
  outline: none;
}
.history-tools input:focus { border-color: var(--primary); }
.history-tools select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.history-table-wrapper { overflow-x: auto; }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.history-table th {
  background: #f9fafb;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.history-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.history-table tr:hover td { background: #f9fafb; }
.history-table .cell-code { font-family: 'Courier New', monospace; font-size: 12px; }
.history-table .cell-actions { white-space: nowrap; }
.history-table .ql-btn {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  border: none;
  transition: all 0.15s;
}
.ql-btn-view {
  background: var(--primary-light);
  color: var(--primary);
  margin-right: 4px;
}
.ql-btn-view:hover { background: var(--primary); color: #fff; }
.ql-btn-del {
  background: #fef2f2;
  color: #dc2626;
}
.ql-btn-del:hover { background: #dc2626; color: #fff; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.page-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-info { font-size: 13px; color: var(--text-secondary); }

/* ===== Modal ===== */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; }
.modal.active { display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; text-align: center; }
.modal-body img { width: 320px; height: 320px; border: 1px solid var(--border); border-radius: 8px; }
.modal-body .qr-text { margin-top: 12px; text-align: left; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #323232;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Loading ===== */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #bbb;
  font-size: 14px;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8eaf6 0%, #f5f5f5 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  padding: 48px 40px 36px;
  width: 400px;
  max-width: 90vw;
  text-align: center;
}

.login-card .logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-card h1 {
  font-size: 20px;
  color: #1a1a2e;
  margin-bottom: 4px;
  font-weight: 600;
}

.login-card .subtitle {
  font-size: 13px;
  color: #888;
  margin-bottom: 32px;
}

.login-card .form-group {
  text-align: left;
  margin-bottom: 20px;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
  font-weight: 500;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.login-card input:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}

.login-card .login-btn {
  width: 100%;
  padding: 12px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.login-card .login-btn:hover {
  background: #1557b0;
}

.login-card .login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-card .error {
  color: #e53935;
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

.login-card .error.show {
  display: block;
}

/* ===== 密码修改弹窗 ===== */

/* ===== 密码修改弹窗（独立命名，不与预览弹窗冲突） ===== */
.pwd-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.pwd-modal.show {
  display: flex;
}

.pwd-modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 380px;
  max-width: 90vw;
}

.pwd-modal-box h3 {
  margin-bottom: 20px;
  font-size: 16px;
  margin-top: 0;
}

.pwd-field {
  margin-bottom: 16px;
}

.pwd-field label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
}

.pwd-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}

.pwd-field input:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}

.pwd-error {
  color: #e53935;
  font-size: 12px;
  margin-top: 8px;
  display: none;
}

.pwd-error.show {
  display: block;
}

.pwd-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.pwd-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: none;
}

.pwd-btn-cancel {
  background: #f5f5f5;
  color: #666;
}

.pwd-btn-confirm {
  background: #1a73e8;
  color: #fff;
}

.pwd-btn-confirm:hover {
  background: #1557b0;
}
