*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #e63946;
  --primary-hover: #c92a36;
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --text-main: #1a1a2e;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition-fast: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-main);
  background-color: var(--bg-light);
}

/* 登录页面 */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff5f5 0%, #f8f9fa 100%);
}

.login-box {
  background: var(--bg-white);
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  height: 60px;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text-main);
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.login-hint {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, #e63946, #ff6b6b);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.25);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  background: var(--bg-light);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* 管理后台容器 */
.admin-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 管理后台头部 */
.admin-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-brand .logo-img {
  height: 36px;
}

.admin-brand span {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
}

.admin-nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-btn:hover {
  background: var(--bg-light);
  color: var(--text-main);
}

.nav-btn.active {
  background: var(--primary-color);
  color: white;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

#current-time {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 主内容区 */
.admin-main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
  width: 100%;
}

/* Tab样式 */
.admin-tab {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.tab-header-left h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.tab-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 数据表格 */
.data-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: var(--bg-light);
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #fefefe;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-light);
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-inactive {
  background: #fef3c7;
  color: #92400e;
}

.status-expired {
  background: #fee2e2;
  color: #991b1b;
}

.level-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.level-vip {
  background: #dbeafe;
  color: #1e40af;
}

.level-svip {
  background: #fce7f3;
  color: #9d174d;
  font-weight: 600;
}

.action-btns {
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 4px 8px;
  border: none;
  background: var(--bg-light);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--primary-color);
  color: white;
}

.action-btn.delete:hover {
  background: #dc2626;
}

/* 表格底部 */
.table-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.record-count {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 筛选栏 */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-group select,
.filter-group input {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.search-group {
  flex: 1;
  min-width: 200px;
}

.search-group input {
  flex: 1;
}

/* 统计页面 */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 24px;
}

.stat-card {
  background: var(--bg-light);
  padding: 20px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  font-size: 40px;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stats-section {
  padding: 0 24px 24px;
}

.stats-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
}

.distribution-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dist-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dist-label {
  width: 80px;
  font-size: 14px;
  color: var(--text-main);
}

.dist-bar-wrapper {
  flex: 1;
  height: 24px;
  background: var(--bg-light);
  border-radius: 12px;
  overflow: hidden;
}

.dist-bar {
  height: 100%;
  border-radius: 12px;
  transition: width 0.5s ease;
}

.dist-bar.vip {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.dist-bar.svip {
  background: linear-gradient(90deg, #ec4899, #f472b6);
}

.dist-value {
  width: 50px;
  text-align: right;
  font-weight: 600;
  color: var(--text-main);
}

/* 弹窗 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 550px;
  max-height: 85vh;
  overflow-y: visible;
  box-shadow: var(--shadow-md);
}

#fatemaster-form {
  padding: 20px 24px;
  max-height: 80vh;
  overflow-y: visible;
}

#fatemaster-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

#fatemaster-form .form-group {
  margin-bottom: 12px;
}

#fatemaster-form .form-group label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

#fatemaster-form .form-group input,
#fatemaster-form .form-group select,
#fatemaster-form .form-group textarea {
  padding: 8px 12px;
  font-size: 13px;
}

#fatemaster-form .form-group textarea {
  min-height: 60px;
  resize: none;
}

#fatemaster-form .required {
  color: #dc2626;
}

#fatemaster-form .form-actions {
  margin-top: 16px;
  padding-top: 16px;
}

#fatemaster-form .btn {
  padding: 8px 20px;
  font-size: 13px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-main);
}

#member-form {
  padding: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* Toast提示 */
.toast {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a2e;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 9999;
  box-shadow: var(--shadow-md);
}

.toast.show {
  display: block;
  animation: slideIn 0.3s ease;
}

.toast.success {
  background: #059669;
}

.toast.error {
  background: #dc2626;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* 响应式 */
@media (max-width: 768px) {
  .admin-header-inner {
    flex-direction: column;
    gap: 12px;
  }

  .admin-nav {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }

  .admin-actions {
    width: 100%;
    justify-content: space-between;
  }

  .tab-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ===== 命理师表单优化样式 ===== */

/* 更大的弹窗 */
.modal-lg {
  max-width: 700px;
}

/* 表单分组 */
.form-section {
  margin-bottom: 24px;
  padding: 20px;
  background: var(--bg-light);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-color);
}

.form-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

/* 必填标记 */
.required {
  color: #dc2626;
  font-weight: bold;
}

/* 表单提示文字 */
.form-hint {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
  font-style: italic;
}

/* 优化的输入框 */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

/* 标签样式 */
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

/* 按钮优化 */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(230, 57, 70, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.35);
}

.btn-outline {
  background: white;
  color: var(--text-secondary);
  padding: 10px 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline:hover {
  background: var(--bg-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}