/* ===== 重置与基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #FF8C42;
  --primary-light: #FFB088;
  --primary-dark: #E06B2C;
  --accent: #4ECDC4;
  --accent-dark: #3DB5AD;
  --bg: #FFF8F0;
  --card: #FFFFFF;
  --text: #3D3D3D;
  --text-light: #888;
  --success: #4CAF50;
  --danger: #FF5252;
  --warning: #FFC107;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --max-width: 520px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page { display: none; min-height: 100vh; max-width: var(--max-width); margin: 0 auto; }
.page.active { display: block; }
.hidden { display: none !important; }

/* ===== 登录页 ===== */
#loginPage {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
}
#loginPage.active { display: flex; }

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo {
  font-size: 64px;
  margin-bottom: 16px;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.login-card h1 {
  font-size: 26px;
  color: var(--primary);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 28px;
}

.member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.member-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  width: 100px;
  background: var(--card);
  border-radius: var(--radius);
  border: 2px solid transparent;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
}

.member-chip:hover, .member-chip:active {
  border-color: var(--primary);
  transform: scale(1.05);
}

.member-chip .chip-avatar { font-size: 36px; }
.member-chip .chip-name { font-size: 14px; font-weight: 600; }

.pin-section { margin-top: 24px; }
.pin-display { font-size: 20px; color: var(--text-light); margin-bottom: 16px; }

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.pin-dots span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  transition: all 0.2s;
}

.pin-dots span.filled {
  background: var(--primary);
}

.pin-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 8px;
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 240px;
  margin: 0 auto;
}

.pin-btn {
  aspect-ratio: 1;
  border: none;
  background: var(--card);
  border-radius: var(--radius-sm);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
}

.pin-btn:active { transform: scale(0.92); background: var(--primary-light); }
.pin-clear, .pin-back { font-size: 14px; color: var(--text-light); }

/* ===== 顶部栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-avatar {
  font-size: 32px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
}

.topbar-name { font-size: 17px; font-weight: 700; }
.topbar-member { font-size: 12px; opacity: 0.85; }

.topbar-points {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.points-num {
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: transform 0.3s;
}

.points-num.bump { animation: bump 0.4s; }

@keyframes bump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); color: #FFD700; }
}

.points-label { font-size: 11px; opacity: 0.8; }

.btn-icon {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:active { background: rgba(255,255,255,0.35); }

/* ===== Tab 导航 ===== */
.tabs {
  display: flex;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  position: sticky;
  top: 72px;
  z-index: 90;
}

.tab-btn {
  flex: 1;
  padding: 12px 4px;
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-content { display: none; padding: 16px; padding-bottom: 80px; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }

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

/* ===== 积分看板 ===== */
.dashboard-hero {
  display: flex;
  justify-content: center;
  padding: 12px 0 20px;
}

.hero-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.hero-circle::before {
  content: '⭐';
  position: absolute;
  top: -12px;
  right: -8px;
  font-size: 28px;
  animation: spin 4s linear infinite;
}

/* 空状态提示 */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 14px;
  line-height: 1.8;
}

/* 头像预览 */
.avatar-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar-preview-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}
.avatar-preview-img.hidden {
  display: none;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hero-points {
  font-size: 52px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.hero-label {
  font-size: 14px;
  color: rgba(255,255,255,0.85);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 12px;
}

.section-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.today-info {
  font-size: 12px;
  color: var(--text-light);
}

/* 行为网格 */
.behavior-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.behavior-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  border: 2px solid transparent;
}

.behavior-card:active {
  transform: scale(0.95);
}

.behavior-card .b-icon {
  font-size: 32px;
  line-height: 1;
}

.behavior-card .b-name {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.behavior-card .b-points {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.behavior-card .b-category {
  font-size: 10px;
  color: var(--text-light);
  background: var(--bg);
  padding: 1px 8px;
  border-radius: 20px;
}

/* 点击动画 */
.plus-anim {
  position: fixed;
  font-size: 28px;
  font-weight: 800;
  color: var(--success);
  pointer-events: none;
  z-index: 999;
  animation: floatUp 0.8s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}

/* ===== 奖励商店 ===== */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.goal-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 12px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.goal-card.disabled {
  opacity: 0.5;
}

.goal-card .g-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.goal-card .g-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.goal-card .g-cost {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.goal-card .g-cost-label {
  font-size: 11px;
  color: var(--text-light);
}

.goal-card .g-redeem {
  width: 100%;
  padding: 8px;
  margin-top: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.goal-card .g-redeem:disabled {
  background: #ccc;
}

.goal-card .g-redeem:not(:disabled):active {
  background: var(--primary-dark);
}

/* ===== 历史记录 ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.history-item.negative { border-left: 4px solid var(--danger); }

.history-item .h-icon {
  font-size: 28px;
  width: 44px;
  text-align: center;
}

.history-item .h-info {
  flex: 1;
}

.history-item .h-title {
  font-size: 14px;
  font-weight: 600;
}

.history-item .h-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

.history-item .h-points {
  font-size: 18px;
  font-weight: 800;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.history-item .h-points.negative {
  color: var(--danger);
}

.history-item .h-delete {
  font-size: 18px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  background: none;
  border: none;
}

.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* ===== 统计 ===== */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 12px;
  text-align: center;
}

.stat-icon { font-size: 28px; margin-bottom: 6px; }
.stat-val { font-size: 26px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.stat-name { font-size: 12px; color: var(--text-light); }

.daily-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 140px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 8px 8px;
}

.daily-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.daily-bar-fill {
  width: 70%;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(to top, var(--primary), var(--primary-light));
  min-height: 4px;
  transition: height 0.5s;
  position: relative;
}

.daily-bar-fill.today {
  background: linear-gradient(to top, var(--accent-dark), var(--accent));
}

.daily-bar-val {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
}

.daily-bar-label {
  font-size: 10px;
  color: var(--text-light);
}
.daily-bar-weekday {
  font-size: 10px;
  color: var(--text-light);
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.ranking-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg);
  color: var(--text-light);
  flex-shrink: 0;
}

.ranking-rank.gold { background: #FFD700; color: #fff; }
.ranking-rank.silver { background: #C0C0C0; color: #fff; }
.ranking-rank.bronze { background: #CD7F32; color: #fff; }

.ranking-item .r-icon { font-size: 24px; }
.ranking-item .r-name { flex: 1; font-size: 14px; font-weight: 600; }
.ranking-item .r-count { font-size: 13px; color: var(--text-light); }
.ranking-item .r-points { font-size: 16px; font-weight: 700; color: var(--primary); }

/* ===== 设置 ===== */
.settings-group {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.settings-group .section-header { margin-top: 0; }

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.settings-row label {
  font-size: 14px;
  font-weight: 600;
  width: 60px;
  flex-shrink: 0;
}

.settings-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #E0E0E0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
}

.settings-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.setting-item .s-icon { font-size: 24px; }
.setting-item .s-name { flex: 1; font-size: 14px; font-weight: 600; }
.setting-item .s-points { font-size: 14px; font-weight: 700; color: var(--primary); }
.setting-item .s-pin { font-size: 11px; color: var(--text-light); }
.setting-item .s-delete {
  font-size: 18px;
  color: var(--danger);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 8px;
}

/* ===== 按钮 ===== */
.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:active { background: var(--primary-dark); }

.btn-secondary {
  flex: 1;
  padding: 12px;
  border: 1px solid #E0E0E0;
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-sm { width: auto; padding: 6px 14px; font-size: 13px; }

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}

.danger-text { color: var(--danger); }

.btn-logout {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: #f5f5f5;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.app-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
  font-size: 12px;
}

.footer-tip { margin-top: 4px; opacity: 0.7; }

/* ===== 模态弹窗 ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 88%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}

.modal-card h3 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--text);
}

.modal-body { margin-bottom: 20px; }

.modal-body .form-group {
  margin-bottom: 18px;
}

.modal-body .form-group:last-child {
  margin-bottom: 0;
}

.modal-body .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.modal-body .form-group input,
.modal-body .form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #E0E0E0;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 2000;
  animation: fadeIn 0.2s;
  max-width: 80%;
  text-align: center;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== 响应式 ===== */
@media (min-width: 520px) {
  body { background: var(--bg); }
  .page { box-shadow: 0 0 40px rgba(0,0,0,0.06); }
}

@media (max-width: 360px) {
  .behavior-grid { grid-template-columns: repeat(2, 1fr); }
  .behavior-card .b-icon { font-size: 28px; }
}
