:root {
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-light: #e8f0fe;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #059669;
  --success-bg: #d1fae5;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 8px 22px rgba(26, 115, 232, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

/* 顶部导航栏 */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1a73e8, #4285f4);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary);
  color: #fff;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-muted);
}

.role-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

.role-pill.admin {
  background: #fef3c7;
  color: #b45309;
}

/* 页面容器 */
.container {
  max-width: 1180px;
  margin: 24px auto;
  padding: 0 20px 48px;
}

.survey-container {
  max-width: 780px;
  margin: 28px auto;
  padding: 0 16px 56px;
}

/* 问卷星风格顶部横幅 */
.survey-hero {
  background: linear-gradient(135deg, #0d47a1 0%, #1a73e8 55%, #3b82f6 100%);
  color: #ffffff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
}

.survey-hero.standalone {
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.survey-hero h1 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.35;
}

.survey-hero p {
  margin: 0;
  font-size: 15px;
  opacity: 0.92;
  white-space: pre-wrap;
}

/* 卡片 */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 16px;
  border: 1px solid rgba(229, 231, 235, 0.7);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.question-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.question-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.q-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.q-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  flex: 1;
}

.q-req {
  color: var(--danger);
  margin-left: 4px;
  font-weight: 700;
}

.q-type-tag {
  font-size: 12px;
  color: var(--text-muted);
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 表单控件 */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}

.input, .textarea, .select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.textarea {
  resize: vertical;
  min-height: 92px;
}

.input-sm {
  padding: 6px 10px;
  font-size: 13px;
}

/* 选项列表 */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.choice-item:hover {
  border-color: var(--primary);
  background: #f8fbff;
}

.choice-item input[type="radio"],
.choice-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}

/* 评分按钮 (1-10) */
.rating-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rating-btn {
  min-width: 42px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.rating-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

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

/* 胶囊按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

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

.btn-outline:hover:not(:disabled) {
  background: var(--primary-light);
}

.btn-secondary {
  background: #fff;
  color: #374151;
  border-color: #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-danger-outline {
  background: #fff;
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 5px 13px;
  font-size: 13px;
}

.btn-lg {
  padding: 12px 34px;
  font-size: 16px;
}

/* 状态标签 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-draft { background: #f3f4f6; color: #4b5563; }
.badge-published { background: var(--success-bg); color: var(--success); }
.badge-closed { background: var(--warning-bg); color: var(--warning); }
.badge-expired { background: var(--danger-bg); color: var(--danger); }
.badge-real { background: #dbeafe; color: #1d4ed8; }
.badge-sim { background: #f3e8ff; color: #7e22ce; }

/* 页面头部工具栏 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 登录/注册卡片 */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #e8f0fe 0%, #f0f2f5 60%);
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(26, 115, 232, 0.12);
  padding: 32px 28px;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-header h1 {
  margin: 10px 0 6px;
  font-size: 22px;
  color: #111827;
}

.auth-header p {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row .input {
  flex: 1;
}

/* 表格 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

.table th, .table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: #f8fbff;
}

/* 统计柱状条 */
.stat-bar-row {
  margin-bottom: 10px;
}

.stat-bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 4px;
}

.stat-bar-track {
  height: 12px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a73e8, #60a5fa);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* 选项卡 */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding-bottom: 10px;
}

/* 网格布局 */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* 提示框 */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warn { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }

/* Toast 通知 */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 11px 18px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  background: #1f2937;
  max-width: 360px;
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.info { background: #1a73e8; }

/* 模态框 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.22);
}

.modal-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

/* 生成器配置卡片 */
.gen-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.gen-q-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.gen-editor {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.gen-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
}

.gen-sum {
  font-weight: 400;
}

.gen-opt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}

.gen-opt-row:last-child {
  border-bottom: none;
}

.gen-opt-badge {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gen-opt-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.gen-prob-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.gen-prob-wrap .gen-prob {
  width: 84px;
  text-align: right;
}

.gen-percent {
  font-size: 13px;
  color: var(--text-muted);
}

.gen-cand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.gen-cand-row .gen-cand-text {
  flex: 1;
  min-width: 0;
}

@media (max-width: 768px) {
  .gen-cand-row {
    flex-wrap: wrap;
  }
  .gen-cand-row .gen-cand-text {
    flex: 1 1 100%;
  }
  .gen-opt-label {
    white-space: normal;
  }
}

/* 响应式适配 */
@media (max-width: 768px) {
  .topbar-inner {
    height: auto;
    padding: 10px 14px;
    flex-wrap: wrap;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .survey-hero {
    padding: 24px 18px;
  }
  .survey-hero h1 {
    font-size: 21px;
  }
  .card {
    padding: 16px;
  }
}
