:root {
  /* 默认主题 (简约白/Light) */
  --primary: #667EEA;
  --primary-light: #EBF0FF;
  --bg-page: #F5F7FA;
  --bg-card: #FFFFFF;
  --text-main: #2D3748;
  --text-muted: #718096;
  --border-color: #E2E8F0;
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --radius-md: 12px;
  --radius-lg: 16px;
  
  /* 功能色 */
  --success: #48BB78;
  --warning: #ED8936;
  --error: #F56565;
}

[data-theme="warm"] {
  /* 暖色主题 (Warm) */
  --primary: #ED8936;
  --primary-light: #FFF5F0;
  --bg-page: #FFF9F5;
  --bg-card: #FFFFFF;
  --text-main: #4A4A4A;
  --text-muted: #8D766B;
  --border-color: #FBD38D;
  --shadow-card: 0 4px 6px -1px rgba(237, 137, 54, 0.1);
}

[data-theme="dark"] {
  /* 深色主题 (Dark) */
  --primary: #667EEA;
  --primary-light: rgba(102, 126, 234, 0.2);
  --bg-page: #1A202C;
  --bg-card: #2D3748;
  --text-main: #F7FAFC;
  --text-muted: #A0AEC0;
  --border-color: #4A5568;
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

/* 布局容器 */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 80px; /* 留出底部导航空间 */
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
}

/* 标题 */
.page-header {
  text-align: center;
  margin-bottom: 32px;
  padding-top: 20px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 表单元素 */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 16px;
  outline: none;
  transition: all 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 16px;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  height: 52px;
  font-size: 18px;
}

/* 用户选择卡片 */
.user-selector {
  display: flex;
  gap: 16px;
}

.user-card {
  flex: 1;
  background: var(--bg-page);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.user-card:active {
  transform: scale(0.95);
}

.user-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.user-avatar {
  font-size: 40px;
  margin-bottom: 8px;
  display: inline-block;
  padding: 10px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

/* 底部导航 */
.navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-card);
  padding: 12px 0;
  border-top: 1px solid var(--border-color);
  z-index: 100;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.navbar-container {
  display: flex;
  justify-content: space-around;
  max-width: 480px;
  margin: 0 auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 12px;
  gap: 4px;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 24px;
}

/* 列表样式 */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-title {
  font-weight: 500;
  color: var(--text-main);
}

.list-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 统计概览 */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--border-color);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin: 8px 0;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* 工具类 */
.text-center { text-align: center; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }

/* 动画 */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 90%;
  max-width: 320px;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  border-left: 4px solid var(--primary);
  animation: slideDown 0.3s ease-out;
}

.toast.error { border-left-color: var(--error); }
.toast.success { border-left-color: var(--success); }

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 主题选择器 */
.theme-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.theme-option {
  flex: 1;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-page);
}

.theme-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* Dashboard 对比卡片 */
.comparison-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
}

.comparison-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.comparison-user {
  flex: 1;
  text-align: center;
}

.comparison-avatar {
  font-size: 36px;
}

.comparison-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 4px;
}

.comparison-status {
  font-size: 13px;
  margin-top: 4px;
}

.comparison-weight {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

.comparison-vs {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 12px;
}

/* 打卡热力图 */
.checkin-heatmap {
  margin-top: 12px;
}

.heatmap-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.heatmap-grid {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  justify-content: center;
}

.heatmap-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 32px;
}

.heatmap-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.heatmap-dots {
  display: flex;
  gap: 3px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-color);
}

.dot.user1-dot {
  background: #667eea;
}

.dot.user2-dot {
  background: #ed8936;
}

.dot.user1-checked {
  background: #667eea;
}

.dot.user2-checked {
  background: #ed8936;
}

.dot.empty {
  background: var(--border-color);
  opacity: 0.4;
}

/* 图表容器 */
.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 16px;
}

.chart-wrapper {
  height: 200px;
}

/* 视图切换器 (for history page) */
.view-switcher {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.view-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn.active {
  background: var(--primary);
  color: white;
}

/* 双人对比视图 (for history page) */
.compare-date-header {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-main);
}

.compare-grid {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.compare-column {
  flex: 1;
  text-align: center;
}

.compare-user-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
}

.compare-avatar {
  font-size: 32px;
}

.compare-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.compare-data {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compare-item {
  background: var(--bg-page);
  padding: 10px 8px;
  border-radius: 8px;
}

.compare-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.compare-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.compare-vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 4px;
  min-height: 200px;
}

/* 移动端优化 */
@media (max-width: 480px) {
  .compare-grid {
    flex-direction: column;
    gap: 16px;
  }

  .compare-column {
    width: 100%;
    background: var(--bg-page); /* 给每列加个背景区分 */
    padding: 12px;
    border-radius: 12px;
  }
  
  .compare-data {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 两列排布数据，节省垂直空间 */
    gap: 8px;
  }
  
  .compare-item {
     background: var(--bg-card); /* 内部项目背景反白 */
  }

  .compare-vs-divider {
    display: none; /* 移动端隐藏VS竖线，改用上下排列自然分隔 */
  }
}

/* 日历中的双人打卡标记 */
.calendar-dots {
  display: flex;
  justify-content: center;
  gap: 2px;
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.calendar-day {
  background: var(--bg-page);
  border-radius: 8px;
  padding: 8px 0;
  text-align: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.calendar-day:hover {
  background: var(--primary-light);
}

.calendar-day.today {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.calendar-day.checked {
  background: var(--success);
  color: white;
}

.calendar-day.other-month {
  visibility: hidden;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.calendar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.calendar-weekday {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
}
