* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* 登录页 */
.page { display: none; }
.page.active { display: flex; flex-direction: column; }

#loginPage, #registerPage {
  min-height: 100vh;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px 30px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-box h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-size: 22px;
}
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  color: #666;
  margin-bottom: 6px;
  font-size: 14px;
}
.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus {
  border-color: #667eea;
}
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn:active { opacity: 0.8; }
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.btn-secondary {
  background: transparent;
  color: #667eea;
  border: 1px solid #667eea;
  margin-top: 12px;
}
.login-error {
  color: #e74c3c;
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  min-height: 20px;
}

.login-register-link {
  text-align: center;
  margin-top: 16px;
}

.login-register-link a {
  color: #667eea;
  text-decoration: none;
  font-size: 14px;
}

/* 首页 */
#homePage {
  min-height: 100vh;
  background: #f5f5f5;
}
.home-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.month-selector {
  display: flex; align-items: center; gap: 4px;
  font-size: 16px; cursor: pointer; font-weight: 600;
}
.month-selector svg { width: 16px; height: 16px; }
.tab-content { padding: 16px 20px 100px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* 统计卡片 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.sub-income {
  font-size: 15px;
  color: #27ae60;
  margin-top: 4px;
  font-weight: 600;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.stat-card .label {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 22px;
  font-weight: 700;
  color: #333;
}
.stat-card .value.income { color: #27ae60; }
.stat-card .value.expense { color: #e74c3c; }
.stat-card.full { grid-column: 1 / -1; }
.stat-summary {
  display: flex;
  justify-content: space-between;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.stat-summary .item { text-align: center; flex: 1; }
.stat-summary .item .label { font-size: 13px; color: #999; margin-bottom: 4px; }
.stat-summary .item .val { font-size: 20px; font-weight: 700; }
.stat-summary .item .val.green { color: #27ae60; }
.stat-summary .item .val.red { color: #e74c3c; }
.stat-summary .item .val.orange { color: #f39c12; }
.stat-summary .item .val.purple { color: #9b59b6; }

/* 最近7天收入柱状图 */
.weekly-chart {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.weekly-chart-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 0;
}
.weekly-chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 150px;
  gap: 8px;
}
.weekly-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  cursor: pointer;
}
.weekly-bar-col:active { opacity: 0.7; }
.weekly-bar-amount {
  font-size: 10px;
  color: #667eea;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
}
.weekly-bar {
  width: 100%;
  max-width: 32px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
  min-height: 4px;
  transition: height 0.3s ease;
}
.weekly-bar-date {
  font-size: 11px;
  color: #999;
  margin-top: 6px;
}

/* 日收入详情页 */
#dailyDetailPage { min-height: 100vh; background: #f5f5f5; }
.daily-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px 0;
}
.daily-nav-btn {
  background: none; border: none; color: #667eea;
  font-size: 14px; cursor: pointer; padding: 6px 0;
}
.daily-nav-btn:active { opacity: 0.6; }
.daily-nav-date {
  font-size: 15px; font-weight: 600; color: #333;
}
.scope-toggle {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid #667eea;
  background: #fff;
  color: #667eea;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.scope-toggle.active {
  background: #667eea;
  color: #fff;
}
.daily-summary {
  background: #fff;
  border-radius: 12px;
  padding: 24px 16px;
  margin: 16px 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.daily-summary-amount {
  font-size: 32px;
  font-weight: 700;
  color: #27ae60;
}
.daily-summary-label {
  font-size: 13px;
  color: #999;
  margin-top: 4px;
}

/* 我的页面 */
.profile-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.profile-card .avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  margin: 0 auto 12px;
}
.profile-card .name { font-size: 18px; font-weight: 600; color: #333; }
.refresh-btn {
  margin-top: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: #fff;
  border-radius: 12px;
  padding: 12px;
  width: 100%;
  font-size: 15px;
  cursor: pointer;
}
.refresh-btn:active { opacity: 0.8; }
.logout-btn {
  margin-top: 20px;
  background: #fff;
  border: 1px solid #e74c3c;
  color: #e74c3c;
  border-radius: 12px;
  padding: 12px;
  width: 100%;
  font-size: 15px;
  cursor: pointer;
}
.logout-btn:active { background: #ffeaea; }

/* 底部导航 */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  padding: 6px 20px 18px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  z-index: 10;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer; padding: 4px 12px; color: #999; font-size: 11px; gap: 2px;
  transition: color 0.2s;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: #667eea; }
.record-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  margin-top: -15px;
}
.record-btn:active { transform: scale(0.9); }

/* 记录页 */
#recordPage {
  min-height: 100vh;
  background: #f5f5f5;
}
.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-header .back {
  font-size: 22px;
  cursor: pointer;
  background: none;
  border: none;
  color: #fff;
  padding: 4px;
}
.page-header h2 { font-size: 18px; font-weight: 600; }

.type-switch {
  display: flex;
  margin: 16px 20px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.type-switch .type-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 15px;
  cursor: pointer;
  border: none;
  background: #fff;
  color: #999;
  transition: all 0.2s;
}
.type-switch .type-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.category-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 20px;
  margin-bottom: 16px;
}
.category-item {
  background: #fff;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  color: #666;
}
.category-item.active {
  border-color: #667eea;
  color: #667eea;
  background: #f0f2ff;
}

.record-form {
  padding: 0 20px 30px;
  overflow: hidden;
}
.record-form .form-group { margin-bottom: 14px; }
.record-form .form-group input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
}
.record-form .form-group label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 6px;
}
.record-form .form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  background: #fff;
  box-sizing: border-box;
  max-width: 100%;
}
.record-form .form-group input:focus { border-color: #667eea; }
.computed-amount {
  background: #f0f2ff;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  margin-bottom: 16px;
  font-size: 14px;
  color: #666;
}
.computed-amount .total {
  font-size: 28px;
  font-weight: 700;
  color: #667eea;
  margin-top: 4px;
}
.submit-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.submit-btn:active { opacity: 0.8; }

/* 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: 8px;
  font-size: 14px;
  z-index: 999;
  display: none;
}
.toast.show { display: block; }

/* 排行预览 */
.ranking-preview {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.ranking-title { font-size: 15px; font-weight: 600; color: #333; }
.ranking-detail-btn { font-size: 13px; color: #667eea; cursor: pointer; }
.ranking-list, .ranking-detail-list { display: flex; flex-direction: column; }
.ranking-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.ranking-item:last-child { border-bottom: none; }
.ranking-index {
  width: 24px; height: 24px; border-radius: 50%;
  background: #eee; color: #999; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin-right: 12px; flex-shrink: 0;
}
.ranking-index.top {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.ranking-boss { flex: 1; font-size: 14px; color: #333; }
.ranking-amount { font-size: 15px; font-weight: 600; color: #27ae60; }
.ranking-empty { text-align: center; color: #999; padding: 20px 0; font-size: 14px; }

/* 排行详情页 */
#rankingPage { min-height: 100vh; background: #f5f5f5; }
.ranking-filters { padding: 16px 20px; }
.filter-row { display: flex; gap: 10px; margin-bottom: 12px; }
.filter-row .form-group { flex: 1; min-width: 0; margin-bottom: 0; text-align: center; }
.filter-row .form-group label { text-align: center; }
.filter-row .form-group input {
  width: 100%; padding: 10px 4px; border: 1px solid #e0e0e0;
  border-radius: 10px; font-size: 12px; outline: none; background: #fff;
  text-align: center; box-sizing: border-box;
  -webkit-appearance: none; appearance: none;
}
.filter-row .form-group input:focus { border-color: #667eea; }
.sort-switch {
  display: flex; background: #fff; border-radius: 10px;
  overflow: hidden; border: 1px solid #e0e0e0; flex: 1;
}
.sort-btn {
  flex: 1; padding: 10px 8px; text-align: center; font-size: 13px;
  cursor: pointer; border: none; background: #fff; color: #999; transition: all 0.2s;
}
.sort-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.ranking-detail-list { padding: 0 20px 30px; }
.ranking-detail-item {
  background: #fff; border-radius: 12px; padding: 14px 16px;
  margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.ranking-detail-top { display: flex; align-items: center; }
.ranking-detail-stats {
  display: flex; justify-content: space-between;
  margin-top: 8px; padding-left: 36px; font-size: 12px; color: #999;
}

/* 接单列表页 */
#orderListPage { min-height: 100vh; background: #f5f5f5; }
.order-list { padding: 12px 20px 30px; }
.order-date-group { margin-bottom: 16px; }
.order-date-label {
  font-size: 13px; color: #999; font-weight: 600;
  margin-bottom: 8px; padding-left: 4px;
}
.order-item {
  background: #fff; border-radius: 12px; padding: 14px 16px;
  margin-bottom: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  cursor: pointer; transition: background 0.15s;
}
.order-item:active { background: #f8f8f8; }
.order-item-top { display: flex; justify-content: space-between; align-items: center; }
.order-item-boss { font-size: 15px; font-weight: 600; color: #333; }
.order-item-amount { font-size: 15px; font-weight: 600; color: #27ae60; }
.order-item-bottom { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: #999; }
.order-loading { text-align: center; padding: 16px; color: #999; font-size: 14px; }

/* 编辑弹窗 */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 100;
  display: none; justify-content: center; align-items: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px; padding: 24px;
  width: 90%; max-width: 400px; max-height: 80vh; overflow-y: auto;
}
.modal-box h3 { font-size: 18px; margin-bottom: 16px; color: #333; }
.modal-box .form-group { margin-bottom: 14px; }
.modal-box .form-group label { display: block; font-size: 14px; color: #666; margin-bottom: 6px; }
.modal-box .form-group input {
  width: 100%; padding: 10px 12px; border: 1px solid #e0e0e0;
  border-radius: 10px; font-size: 14px; outline: none; background: #fff;
  box-sizing: border-box;
}
.modal-box .form-group input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
}
.modal-box .form-group input:focus { border-color: #667eea; }
.modal-actions { display: flex; gap: 12px; margin-top: 16px; }
.modal-actions button { flex: 1; padding: 12px; border-radius: 10px; font-size: 15px; cursor: pointer; border: none; }
.modal-actions .btn-cancel { background: #f0f0f0; color: #666; }
.modal-actions .btn-save {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff;
}
.modal-actions .btn-delete { background: #e74c3c; color: #fff; }

/* 可点击的统计卡片 */
.stat-card.clickable { cursor: pointer; transition: transform 0.15s; }
.stat-card.clickable:active { transform: scale(0.97); }
.stat-summary .item.clickable { cursor: pointer; }
.stat-summary .item.clickable:active { opacity: 0.7; }
.mine-stats {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  width: 100%;
}
.mine-stat-item {
  flex: 1;
  background: #f8f9fa;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.mine-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #333;
}
.mine-stat-value.green { color: #27ae60; }
.mine-stat-label {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}
.mine-stat-item { cursor: pointer; }
.mine-stat-item:active { opacity: 0.7; }
.horizontal-chart {
  padding: 16px;
}
.hbar-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.hbar-index {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e0e0e0;
  color: #666;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 10px;
}
.hbar-index.top { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }
.hbar-label {
  width: 60px;
  font-size: 14px;
  color: #333;
  font-weight: 600;
  text-align: left;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbar-track {
  flex: 1;
  height: 22px;
  background: #f0f0f0;
  border-radius: 11px;
  overflow: hidden;
  position: relative;
  margin: 0 10px;
}
.hbar-fill {
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 11px;
  min-width: 4px;
  transition: width 0.4s ease;
}
.hbar-value {
  font-size: 14px;
  font-weight: 700;
  color: #667eea;
  text-align: right;
  flex-shrink: 0;
  min-width: 45px;
}

/* 月份选择器弹窗 */
.month-picker-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 100;
  display: none; justify-content: center; align-items: center;
}
.month-picker-overlay.show { display: flex; }
.month-picker {
  background: #fff; border-radius: 16px; padding: 24px;
  width: 85%; max-width: 360px;
}
.month-picker-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.month-picker-header button {
  background: none; border: none; font-size: 20px; cursor: pointer; color: #667eea; padding: 4px 8px;
}
.month-picker-header span { font-size: 18px; font-weight: 600; color: #333; }
.month-picker-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.month-picker-grid button {
  padding: 12px 0; border-radius: 10px; border: 1px solid #e0e0e0;
  background: #fff; font-size: 14px; color: #333; cursor: pointer; transition: all 0.15s;
}
.month-picker-grid button.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; border-color: transparent;
}
.month-picker-grid button:active { transform: scale(0.95); }
.month-picker-actions { display: flex; gap: 12px; margin-top: 16px; }
.month-picker-actions button {
  flex: 1; padding: 12px; border-radius: 10px; font-size: 15px; cursor: pointer; border: none;
}
.month-picker-actions .btn-cancel { background: #f0f0f0; color: #666; }
.month-picker-actions .btn-confirm {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff;
}

/* 自动补全 */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid #e0e0e0; border-top: none;
  border-radius: 0 0 10px 10px; max-height: 180px; overflow-y: auto;
  z-index: 50; display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.ac-list.show { display: block; }
.ac-item {
  padding: 10px 14px; font-size: 14px; color: #333;
  cursor: pointer; border-bottom: 1px solid #f5f5f5;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:active, .ac-item.active { background: #f0f2ff; color: #667eea; }
.ac-item .ac-highlight { color: #667eea; font-weight: 600; }

/* 下拉刷新 */
.pull-indicator {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 0; overflow: hidden; color: #999; font-size: 13px;
  transition: height 0.2s;
}
.pull-indicator.visible { height: 40px; }
.pull-indicator.refreshing .pull-arrow {
  animation: spin 0.8s linear infinite;
}
.pull-arrow {
  width: 18px; height: 18px; transition: transform 0.2s;
}
.pull-arrow.flipped { transform: rotate(180deg); }
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
