/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f5f6f8;
  color: #222;
  line-height: 1.5;
  font-size: 14px;
}

a { color: #4a8af4; text-decoration: none; }

/* 通用容器 */
.container {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* 表单页头部 */
.form-header {
  background: linear-gradient(135deg, #4a8af4 0%, #3a7ae0 100%);
  color: #fff;
  padding: 28px 20px 24px;
  text-align: center;
}

.form-header h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-header p {
  font-size: 13px;
  opacity: 0.9;
}

.form-header .tip {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 12px;
  font-size: 12px;
}

/* 字段分组 */
.field-group {
  background: #eef3fb;
  border-radius: 8px;
  margin: 16px;
  padding: 16px;
}

.field-group .group-label {
  font-size: 12px;
  color: #5a7aab;
  margin-bottom: 10px;
}

/* 单个字段 */
.field {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
}

.field:last-child { border-bottom: none; }

.field-label {
  font-size: 14px;
  color: #333;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.field-label .required {
  color: #f5222d;
  font-size: 14px;
  line-height: 1;
}

/* 输入框 */
.input, .textarea {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  padding: 8px 0;
  color: #222;
}

.input::placeholder, .textarea::placeholder {
  color: #bbb;
}

.textarea {
  resize: none;
  min-height: 60px;
  font-family: inherit;
}

.text-input {
  border-bottom: 1px solid #e8e8e8;
  padding-bottom: 10px;
}

/* 选项 */
.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid #d0d0d0;
  border-radius: 16px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.option.active {
  background: #4a8af4;
  color: #fff;
  border-color: #4a8af4;
}

.option-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  cursor: pointer;
  padding: 6px 0;
}

.option-radio input { display: none; }

.option-radio .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid #c0c0c0;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s;
}

.option-radio input:checked + .dot {
  border-color: #4a8af4;
}

.option-radio input:checked + .dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a8af4;
}

.option-radio .label { font-size: 14px; }

/* 文件上传 */
.upload-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: #fff;
  border: 1px solid #4a8af4;
  color: #4a8af4;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.upload-btn:hover { background: #eef3fb; }

.upload-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  background: #f5f6f8;
  border-radius: 4px;
}

.upload-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.upload-preview .file-info {
  flex: 1;
  font-size: 12px;
  color: #666;
}

.upload-preview .remove-btn {
  color: #f5222d;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
}

/* 学科网格（多列） */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.subject-group-title {
  grid-column: 1 / -1;
  font-size: 12px;
  color: #888;
  margin: 6px 0 2px;
}

.subject-group-title:first-child { margin-top: 0; }

/* 提交按钮 */
.submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  padding: 12px 16px;
  z-index: 10;
}

.form-error {
  max-width: 720px;
  margin: 0 auto 10px;
  background: #fff2f0;
  border: 1px solid #ffccc7;
  color: #cf1322;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.submit-bar .container-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 22px;
  padding: 12px 0;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #4a8af4 0%, #3a7ae0 100%);
  color: #fff;
}

.btn-primary:active { opacity: 0.85; }

.btn-primary:disabled {
  background: #c0c0c0;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: #4a8af4;
  border: 1px solid #4a8af4;
}

/* 成功提示 */
.success-page {
  text-align: center;
  padding: 60px 24px;
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: #4a8af4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 40px;
  animation: pop 0.4s ease-out;
}

@keyframes pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.success-page h2 {
  font-size: 20px;
  color: #222;
  margin-bottom: 8px;
}

.success-page p {
  color: #888;
  font-size: 14px;
  margin-bottom: 24px;
}

.success-page .id {
  background: #eef3fb;
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
  color: #4a8af4;
  margin-bottom: 24px;
  word-break: break-all;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 9999;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==================== 登录页 ==================== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #4a8af4 0%, #3a7ae0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.login-card h1 {
  text-align: center;
  font-size: 22px;
  color: #222;
  margin-bottom: 6px;
}

.login-card .subtitle {
  text-align: center;
  color: #888;
  font-size: 13px;
  margin-bottom: 28px;
}

.login-card .form-field {
  margin-bottom: 16px;
}

.login-card .form-field label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}

.login-card .form-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.login-card .form-field input:focus {
  border-color: #4a8af4;
}

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

.login-card .login-btn:disabled { background: #c0c0c0; }

.login-card .role-tabs {
  display: flex;
  background: #f5f6f8;
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
}

.login-card .role-tab {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}

.login-card .role-tab.active {
  background: #fff;
  color: #4a8af4;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.login-card .tip-box {
  background: #fff7e6;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: #874d00;
  margin-top: 16px;
  line-height: 1.6;
}

/* ==================== 后台页面 ==================== */
.dashboard {
  min-height: 100vh;
  background: #f5f6f8;
  padding-bottom: 20px;
}

.dashboard-header {
  background: linear-gradient(135deg, #4a8af4 0%, #3a7ae0 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.dashboard-header h1 {
  font-size: 17px;
  font-weight: 500;
}

.dashboard-header .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.dashboard-header .logout-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

/* 统计卡片 */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
}

.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 14px 12px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 22px;
  font-weight: 600;
  color: #4a8af4;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

/* 筛选条 */
.filter-bar {
  background: #fff;
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
}

.filter-bar input[type=text],
.filter-bar input[type=search] {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
}

.filter-bar select {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
  outline: none;
}

/* 记录列表 */
.records-list {
  padding: 12px 16px;
}

.record-card {
  background: #fff;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
}

.record-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #f0f0f0;
}

.record-name {
  font-size: 15px;
  font-weight: 500;
  color: #222;
}

.record-id {
  font-size: 11px;
  color: #999;
  font-family: monospace;
}

.record-time {
  font-size: 12px;
  color: #888;
}

.record-row {
  display: flex;
  font-size: 13px;
  line-height: 1.8;
}

.record-row .label {
  color: #888;
  width: 88px;
  flex-shrink: 0;
}

.record-row .value {
  color: #333;
  flex: 1;
  word-break: break-all;
}

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.record-tag {
  background: #eef3fb;
  color: #4a8af4;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.record-cert {
  display: inline-block;
  margin-top: 4px;
}

.record-cert img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #f0f0f0;
}

.video-mark-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.video-mark-row .label {
  font-size: 13px;
  color: #555;
}

.video-mark-row .checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.video-mark-row input[type=checkbox] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4a8af4;
}

.video-mark-row .status {
  font-size: 12px;
  color: #999;
  margin-left: 6px;
}

.video-mark-row .status.completed { color: #52c41a; }

.record-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #666;
  cursor: pointer;
}

.btn-sm.danger {
  border-color: #ff7875;
  color: #ff4d4f;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 14px;
}

.loading {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h3 {
  font-size: 16px;
  font-weight: 500;
}

.modal-head .close {
  cursor: pointer;
  font-size: 20px;
  color: #999;
  padding: 0 4px;
}

.modal-body {
  padding: 16px;
}

.modal-body img {
  max-width: 100%;
  border-radius: 6px;
}

/* 响应式 */
@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat-card .stat-value { font-size: 18px; }
  .subjects-grid { grid-template-columns: repeat(2, 1fr); }
  .record-row .label { width: 76px; font-size: 12px; }
}

/* ============ 用户管理 ============ */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab {
  flex: 1;
  padding: 10px;
  border: 1px solid #e0e0e0;
  background: #f8f8f8;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: #666;
  transition: all .2s;
}
.tab.active {
  background: #4a90d9;
  color: #fff;
  border-color: #4a90d9;
}
.user-form-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.user-form-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: #333;
}
.user-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.user-form input,
.user-form select {
  flex: 1;
  min-width: 130px;
  padding: 9px 10px;
  border: 1px solid #ddd;
  border-radius: 7px;
  font-size: 14px;
  box-sizing: border-box;
}
.user-form .btn {
  flex: 0 0 auto;
  min-width: 80px;
}
.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.user-name {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}
.user-meta {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}
.user-locked {
  font-size: 16px;
  opacity: .4;
}
.user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.visibility-label {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.visibility-label.visible {
  background: #e8f5e9;
  color: #388e3c;
}
.visibility-label.hidden {
  background: #f5f5f5;
  color: #999;
}
.btn-sm {
  padding: 4px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  background: #fff;
  color: #333;
  transition: all .2s;
}
.btn-sm:hover { background: #f0f0f0; }
.btn-sm.primary { background: #4a90d9; color: #fff; border-color: #4a90d9; }
.btn-sm.primary:hover { background: #3a7fc8; }
.btn-sm.secondary { background: #f5f5f5; color: #666; }
.btn-sm.secondary:hover { background: #e8e8e8; }
.btn-sm.danger { background: #fff; color: #e53935; border-color: #e53935; }
.btn-sm.danger:hover { background: #e53935; color: #fff; }


/* ========== 提交成功弹窗 ========== */
#successModal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

#successModal .sm-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
}

#successModal .sm-box {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px 28px;
  width: 300px;
  max-width: calc(100vw - 48px);
  text-align: center;
  transform: scale(0.8);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}

#successModal .sm-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #4a8af4, #3a7ae0);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 32px;
  animation: smPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

@keyframes smPop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

#successModal .sm-title {
  font-size: 20px;
  font-weight: 600;
  color: #222;
  margin-bottom: 10px;
}

#successModal .sm-msg {
  font-size: 14px;
  color: #888;
  line-height: 1.7;
  margin-bottom: 16px;
}

#successModal .sm-id {
  background: #eef3fb;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #4a8af4;
  margin-bottom: 20px;
  word-break: break-all;
}

#successModal .sm-id strong { color: #3a7ae0; }

#successModal .sm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#successModal .sm-btn-primary {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #4a8af4, #3a7ae0);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
#successModal .sm-btn-primary:hover { opacity: 0.88; }

#successModal .sm-btn-link {
  background: none;
  border: none;
  color: #999;
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
#successModal .sm-btn-link:hover { color: #666; }