/* ===== 全局样式 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2572f5;
  --primary-light: #5b9aff;
  --primary-dark: #1a5cd4;
  --accent: #fe7e2e;
  --accent-light: #ffa060;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-light: #8c8c9a;
  --border: #e5e6eb;
  --success: #25b864;
  --warning: #fa8c16;
  --danger: #f5222d;
  --shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== 登录页 ===== */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #2572f5 0%, #1a5cd4 60%, #1448b8 100%);
}

.login-box {
  background: var(--card);
  border-radius: 16px;
  padding: 40px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(37,114,245,0.25);
}

.login-box h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
  color: var(--primary-dark);
}

.login-box .subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 30px;
}

.login-box .form-group {
  margin-bottom: 20px;
}

.login-box label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.login-box input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}

.login-box input:focus {
  border-color: var(--primary);
}

.login-box .btn-login {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #f56610 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
}

.login-box .btn-login:hover {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(254,126,46,0.35);
}

.login-box .btn-login:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.login-box .error-msg {
  color: var(--danger);
  font-size: 12px;
  text-align: center;
  margin-top: 10px;
  display: none;
}

/* ===== 主布局 ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: var(--primary-dark);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar .logo {
  padding: 24px 20px;
  font-size: 18px;
  font-weight: bold;
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar .logo span {
  color: var(--accent-light);
  font-weight: 400;
}

.sidebar nav {
  padding: 16px 0;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  gap: 10px;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover {
  color: white;
  background: rgba(255,255,255,0.08);
}

.sidebar nav a.active {
  color: white;
  background: rgba(254,126,46,0.2);
  border-left-color: var(--accent);
}

.sidebar nav a .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar .sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
}

.sidebar .sidebar-footer a {
  color: #888;
  text-decoration: none;
  padding: 0;
  border-left: none;
  font-size: 12px;
}

.sidebar .sidebar-footer a:hover {
  color: var(--danger);
  background: transparent;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 24px;
  max-width: calc(100% - 220px);
}

/* 顶部栏 */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.top-bar h2 {
  font-size: 20px;
  color: var(--text);
}

.top-bar .user-info {
  font-size: 13px;
  color: var(--text-light);
}

/* ===== 通用组件 ===== */
/* 卡片 */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card .card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 按钮 */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #e04040;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 表单 */
.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 200px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* 表格 */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table th {
  background: #fafafa;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tr:hover {
  background: #fafafa;
}

table .actions {
  display: flex;
  gap: 8px;
}

/* 状态标签 */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.tag-success {
  background: #f6ffed;
  color: #52c41a;
  border: 1px solid #b7eb8f;
}

.tag-warning {
  background: #fffbe6;
  color: #faad14;
  border: 1px solid #ffe58f;
}

.tag-danger {
  background: #fff2f0;
  color: #ff4d4f;
  border: 1px solid #ffccc7;
}

/* ===== 数据看板 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-value.pink {
  color: var(--primary);
}

.stat-card .stat-value.blue {
  color: var(--primary);
}

.stat-card .stat-value.green {
  color: var(--success);
}

.stat-card .stat-value.orange {
  color: var(--accent);
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* 排名列表 */
.rank-list {
  list-style: none;
}

.rank-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.rank-item:last-child {
  border-bottom: none;
}

.rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: #f0f0f0;
  color: #999;
  flex-shrink: 0;
}

.rank-badge.top1 {
  background: #fff7e6;
  color: var(--accent);
}

.rank-badge.top2 {
  background: #e6f0ff;
  color: var(--primary);
}

.rank-badge.top3 {
  background: #f6ffed;
  color: var(--success);
}

.rank-name {
  flex: 1;
  font-size: 14px;
}

.rank-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
}

/* ===== 图片上传 ===== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
}

.upload-area:hover {
  border-color: var(--primary);
  background: rgba(37,114,245,0.03);
}

.upload-area .upload-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.upload-area .upload-text {
  font-size: 14px;
  color: var(--text-light);
}

.upload-area .upload-hint {
  font-size: 12px;
  color: #ccc;
  margin-top: 6px;
}

/* 图片网格 */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.image-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fafafa;
}

.image-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.image-card .image-info {
  padding: 8px;
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.image-card .image-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
}

.image-card .image-actions button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: white;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.image-card:hover .image-actions button {
  opacity: 1;
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideIn 0.2s;
}

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal h3 {
  font-size: 17px;
  margin-bottom: 20px;
}

.modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state .empty-text {
  font-size: 14px;
}

/* ===== 加载 ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 0.3s;
  max-width: 300px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #333; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    overflow: visible;
  }

  .sidebar .logo {
    font-size: 12px;
    padding: 16px 8px;
    text-align: center;
  }

  .sidebar nav a {
    padding: 12px 0;
    justify-content: center;
    font-size: 0;
  }

  .sidebar nav a .icon {
    font-size: 20px;
    margin: 0;
  }

  .sidebar nav a .nav-text {
    display: none;
  }

  .sidebar .sidebar-footer {
    display: none;
  }

  .main-content {
    margin-left: 60px;
    max-width: calc(100% - 60px);
    padding: 16px;
  }

  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 分类标签选择 */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.category-tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.category-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* 商户选择器 */
.merchant-selector {
  margin-bottom: 16px;
}

.merchant-selector select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  min-width: 200px;
  outline: none;
}

.merchant-selector select:focus {
  border-color: var(--primary);
}

/* 隐藏 */
.hidden {
  display: none !important;
}
