*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --success: #059669;
  --success-light: #ECFDF5;
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== 顶部导航 ===== */
.navbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  z-index: 100;
}
.navbar .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  flex-shrink: 0;
}
.navbar .nav-links {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 4px;
  align-items: center;
}
.navbar .nav-links a {
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  transition: all 0.15s;
}
.navbar .nav-links a:hover { background: var(--primary-light); color: var(--primary); }
.navbar .nav-links a.active { background: var(--primary); color: white; }
.navbar .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  flex-shrink: 0;
}
.navbar .balance {
  background: var(--success-light);
  color: var(--success);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
}
.navbar .username { color: var(--gray-700); font-weight: 500; }
.navbar .btn-logout {
  background: none;
  border: 1px solid var(--gray-300);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-600);
  transition: all 0.15s;
}
.navbar .btn-logout:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ===== 内容区 ===== */
.container { max-width: 900px; margin: 0 auto; padding: 24px; }

/* ===== 登录/注册 ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.auth-card h1 {
  text-align: center;
  font-size: 24px;
  margin-bottom: 4px;
  color: var(--gray-900);
}
.auth-card .subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--gray-400);
  margin-bottom: 28px;
}
.auth-tabs { display: flex; margin-bottom: 24px; border: 1px solid var(--gray-200); border-radius: 10px; overflow: hidden; }
.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  background: white;
  border: none;
  transition: all 0.15s;
}
.auth-tab.active { background: var(--primary); color: white; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #4338CA; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; }
.btn-danger { background: white; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger-light); }
.btn-outline { background: white; color: var(--gray-600); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-100); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== 任务卡片 ===== */
.task-list { display: flex; flex-direction: column; gap: 12px; }
.task-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.15s;
}
.task-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.task-card .task-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.task-card .task-title { font-size: 16px; font-weight: 600; color: var(--gray-900); overflow-wrap: break-word; word-break: break-word; }
.task-card .task-reward {
  background: var(--warning-light);
  color: var(--warning);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.task-card .task-desc { font-size: 14px; color: var(--gray-500); margin-bottom: 12px; line-height: 1.5; overflow-wrap: break-word; word-break: break-word; }
.task-card .task-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--gray-400);
}
.task-card .task-actions { display: flex; gap: 8px; margin-top: 12px; }

/* 状态标签 */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.status-open { background: var(--primary-light); color: var(--primary); }
.status-accepted { background: var(--warning-light); color: var(--warning); }
.status-completed { background: var(--success-light); color: var(--success); }
.status-cancelled { background: var(--danger-light); color: var(--danger); }

/* ===== 页面标题区 ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--gray-900); }

/* ===== 标签切换 ===== */
.tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 2px solid var(--gray-200); }
.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 48px 0; color: var(--gray-400); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ===== 弹窗 ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  animation: slideIn 0.3s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== 汉堡菜单 ===== */
.menu-toggle-checkbox { display: none; }
.menu-toggle-btn {
  display: none;
  width: 44px; height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  z-index: 110;
  padding: 8px;
  margin-left: auto;
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.menu-toggle-btn:hover { background: var(--gray-100); }
.menu-toggle-btn:active { background: var(--gray-200); }
.menu-toggle-btn span {
  display: block;
  width: 22px; height: 2.5px;
  background: var(--gray-600);
  border-radius: 2px;
  transition: all 0.25s;
}
.menu-toggle-checkbox:checked + .menu-toggle-btn span:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}
.menu-toggle-checkbox:checked + .menu-toggle-btn span:nth-child(2) {
  opacity: 0;
}
.menu-toggle-checkbox:checked + .menu-toggle-btn span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* ===== 移动端底部导航 ===== */
.mobile-bottom-nav {
  display: none !important;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  z-index: 110;
  box-shadow: 0 -1px 6px rgba(0,0,0,0.06);
}
.mobile-bottom-nav-inner {
  display: flex;
  max-width: 500px;
  margin: 0 auto;
  padding: 5px 0 env(safe-area-inset-bottom, 5px);
}
.mobile-bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 4px 6px;
  text-decoration: none;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-bottom-nav a:active {
  opacity: 0.7;
}
.mobile-bottom-nav a.active {
  color: var(--primary);
  font-weight: 600;
}
.mobile-bottom-nav .nav-icon {
  font-size: 22px;
  line-height: 1.2;
}

/* ===== 响应式 ===== */

/* 平板 + 手机 (≤ 768px) */
@media (max-width: 768px) {
  /* 底部导航显示 */
  .mobile-bottom-nav {
    display: block !important;
  }
  body {
    padding-bottom: 72px;
  }

  /* 导航栏 — 保持 sticky，不下滑消失 */
  .navbar {
    padding: 0 12px;
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
  }
  .navbar .logo {
    font-size: 15px;
    flex-shrink: 1;
    padding: 14px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100vw - 80px);
  }
  .menu-toggle-btn {
    display: flex;
    order: 3;
    width: 44px; height: 44px;
    margin: 4px 0 4px auto;
    flex-shrink: 0;
  }
  .navbar > .nav-links {
    display: none;
    flex: none;
    order: 4;
    width: 100%;
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    padding: 4px 0 12px;
    border-top: 1px solid var(--gray-100);
  }
  .navbar > .user-info {
    display: none;
    order: 5;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 0 14px;
    border-top: 1px solid var(--gray-100);
  }
  .menu-toggle-checkbox:checked ~ .nav-links {
    display: flex;
  }
  .menu-toggle-checkbox:checked ~ .user-info {
    display: flex;
  }
  /* 菜单内链接 */
  .navbar .nav-links a {
    display: block;
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border-radius: 8px;
  }
  .navbar .user-info .balance {
    font-size: 13px;
  }
  .navbar .user-info .username {
    font-size: 14px;
  }
  .navbar .user-info .btn-logout {
    margin-left: auto;
    font-size: 14px;
    padding: 8px 16px;
  }
  .navbar .user-info a {
    font-size: 14px;
  }

  /* 容器 */
  .container {
    padding: 16px;
    max-width: 100%;
  }

  /* 页面标题 */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-header h2 { font-size: 20px; }

  /* 任务卡片 */
  .task-card { padding: 14px; overflow: hidden; }
  .task-card .task-header {
    flex-direction: column;
    gap: 8px;
  }
  .task-card .task-title {
    font-size: 15px;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  .task-card .task-reward {
    align-self: flex-start;
    font-size: 13px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .task-card .task-desc {
    font-size: 13px;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  .task-card .task-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  .task-card .task-actions {
    flex-wrap: wrap;
  }

  /* 标签切换 */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* 表单 */
  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 16px;   /* 防止 iOS 自动缩放 */
    padding: 12px 14px;
  }
  .form-group label { font-size: 14px; }

  /* 按钮 */
  .btn {
    font-size: 14px;
    padding: 12px 20px;
    min-height: 44px;  /* 触控友好 */
  }
  .btn-sm {
    padding: 8px 14px;
    min-height: 36px;
    font-size: 13px;
  }

  /* 登录页 */
  .auth-card {
    padding: 24px 20px;
    margin: 16px;
    max-width: 100%;
    border-radius: 12px;
  }
  .auth-card h1 { font-size: 22px; }

  /* Toast */
  .toast {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 82px;
    text-align: center;
    border-radius: 12px;
    animation: slideUp 0.3s ease;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  /* 后台管理 */
  .admin-layout { flex-direction: column; }
  .sidebar {
    width: 100% !important;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    padding: 0;
  }
  .sidebar a {
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .sidebar a.active {
    border-left-color: transparent;
    border-bottom-color: var(--primary);
  }
  .main-content { padding: 16px; }

  /* 统计卡片 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stat-card { padding: 12px; }
  .stat-card .stat-value { font-size: 20px; }

  /* 表格 — 横向滚动 */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
  }
  .table-wrapper table { min-width: 600px; }
  .main-content table:not(.table-wrapper table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .main-content th,
  .main-content td {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* 搜索栏 */
  .search-bar {
    flex-direction: column;
    gap: 8px;
  }
  .search-bar input,
  .search-bar select {
    width: 100%;
  }

  /* 弹窗 */
  .modal {
    width: calc(100% - 32px);
    max-width: 420px;
    margin: 16px;
    padding: 20px;
  }

  /* 设置页 */
  .settings-card { padding: 16px; }
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* 窄屏手机 (≤ 480px) */
@media (max-width: 480px) {
  body {
    font-size: 14px;
    padding-bottom: 66px;
  }

  .navbar .logo { font-size: 13px; }
  .navbar { min-height: 48px; padding: 0 10px; }

  .container { padding: 12px; }
  .page-header h2 { font-size: 18px; }

  .task-card { padding: 12px; border-radius: 8px; }
  .task-card .task-title { font-size: 14px; }

  .mobile-bottom-nav-inner { padding: 4px 0 env(safe-area-inset-bottom, 4px); }
  .mobile-bottom-nav a { font-size: 10px; padding: 4px 2px 5px; }
  .mobile-bottom-nav .nav-icon { font-size: 20px; }

  .auth-card {
    padding: 20px 16px;
    margin: 12px;
  }
  .auth-card h1 { font-size: 20px; }
  .auth-tab { font-size: 13px; padding: 8px; }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .stat-card .stat-value { font-size: 18px; }
  .stat-card .stat-label { font-size: 11px; }

  .modal {
    width: calc(100% - 24px);
    padding: 16px;
  }

  .settings-card { padding: 12px; }
  .settings-card h3 { font-size: 15px; }

  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
}
