/* ========== 基础样式 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif; background: #f5f5f5; color: #1f2937; }
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: #fff; position: relative; display: flex; flex-direction: column; }

/* ========== 顶部栏 ========== */
.top-bar {
  padding: 16px 20px 12px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ========== 页面容器 ========== */
.page { display: none; flex: 1; overflow-y: auto; padding-bottom: 80px; }
.page.active { display: block; }

/* ========== 底部导航 ========== */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 6px 0; font-size: 11px; color: #9ca3af;
  cursor: pointer; transition: color 0.2s; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tab-item.active { color: #3b82f6; }
.tab-icon { font-size: 22px; margin-bottom: 2px; }

/* ========== 记账页 ========== */
.record-form { padding: 20px; }
.amount-section {
  text-align: center; margin-bottom: 24px;
}
.amount-input-wrap {
  display: flex; align-items: baseline; justify-content: center; gap: 4px;
}
.amount-prefix { font-size: 32px; font-weight: 700; color: #3b82f6; }
.amount-input {
  font-size: 48px; font-weight: 700; color: #1f2937;
  border: none; outline: none; width: 200px;
  background: transparent; text-align: left;
  caret-color: #3b82f6;
}
.amount-input::placeholder { color: #d1d5db; }
.quick-amounts {
  display: flex; gap: 8px; justify-content: center; margin-top: 12px;
}
.quick-amount {
  padding: 6px 14px; border-radius: 20px;
  background: #f3f4f6; font-size: 13px; color: #6b7280;
  cursor: pointer; transition: all 0.2s; border: none;
}
.quick-amount:active { background: #e0e7ff; color: #3b82f6; transform: scale(0.95); }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: #6b7280; margin-bottom: 6px; }
.form-input, .form-select {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid #e5e7eb; font-size: 15px;
  background: #f9fafb; color: #1f2937; outline: none;
  transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus { border-color: #3b82f6; background: #fff; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn-submit {
  width: 100%; padding: 14px; border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff; font-size: 16px; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.2s;
  margin-top: 8px;
}
.btn-submit:active { transform: scale(0.98); opacity: 0.9; }

/* ========== 明细页 ========== */
.list-header {
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  background: #f9fafb; border-bottom: 1px solid #e5e7eb;
}
.list-header-info { font-size: 13px; color: #6b7280; }
.list-header-info span { color: #3b82f6; font-weight: 600; }

.list-filters {
  padding: 10px 16px; display: flex; gap: 8px;
  border-bottom: 1px solid #f3f4f6; background: #fff;
  overflow-x: auto;
}
.filter-select {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid #e5e7eb; font-size: 13px;
  background: #f9fafb; color: #374151; outline: none;
  flex-shrink: 0;
}

.list-date-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px 4px; font-size: 13px; color: #9ca3af;
  background: #f9fafb; border-bottom: 1px solid #f3f4f6;
}

.list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.15s;
}
.list-item:active { background: #f9fafb; }
.list-item-left { display: flex; align-items: center; gap: 12px; }
.list-item-icon { font-size: 24px; }
.list-item-info { display: flex; flex-direction: column; gap: 2px; }
.list-item-category { font-size: 15px; font-weight: 500; }
.list-item-note { font-size: 12px; color: #9ca3af; }
.list-item-right { display: flex; align-items: center; gap: 8px; }
.list-item-amount { font-size: 16px; font-weight: 600; color: #ef4444; }
.list-item-delete {
  width: 24px; height: 24px; border-radius: 50%;
  border: none; background: transparent; color: #d1d5db;
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; opacity: 0;
}
.list-item:hover .list-item-delete { opacity: 1; }
.list-item-delete:active { background: #fef2f2; color: #ef4444; }

.empty-state { text-align: center; padding: 60px 20px; color: #9ca3af; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ========== 统计页 ========== */
.stats-section { padding: 16px 20px; }
.stats-summary {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;
  margin-bottom: 20px;
}
.stats-card {
  text-align: center; padding: 14px 8px;
  background: #f9fafb; border-radius: 12px;
}
.stats-card-value { font-size: 18px; font-weight: 700; color: #3b82f6; }
.stats-card-label { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.stats-compare {
  text-align: center; padding: 10px; font-size: 13px; color: #6b7280;
  margin-bottom: 16px;
}
.stats-subtitle { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: #374151; }
.chart-container { position: relative; height: 240px; margin-bottom: 16px; }

.category-bar-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; gap: 12px;
}
.category-bar-left { display: flex; align-items: center; gap: 8px; min-width: 80px; }
.category-bar-right { display: flex; align-items: center; gap: 10px; flex: 1; }
.category-bar-track {
  flex: 1; height: 8px; background: #f3f4f6; border-radius: 4px; overflow: hidden;
}
.category-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }

.member-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.member-stat-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; background: #f9fafb; border-radius: 10px;
}

/* ========== 设置页 ========== */
.settings-section { padding: 20px; }
.settings-group {
  margin-bottom: 24px;
}
.settings-title { font-size: 15px; font-weight: 600; color: #374151; margin-bottom: 12px; }
.settings-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: #f9fafb; border-radius: 12px;
  margin-bottom: 8px;
}
.settings-item-label { font-size: 14px; color: #374151; }
.settings-item-desc { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.settings-btn {
  padding: 8px 16px; border-radius: 8px; font-size: 13px;
  border: none; cursor: pointer; font-weight: 500; transition: all 0.2s;
}
.settings-btn:active { transform: scale(0.96); }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-danger { background: #fef2f2; color: #ef4444; }
.btn-outline { background: #fff; color: #374151; border: 1.5px solid #e5e7eb; }

/* ========== Toast ========== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  padding: 10px 24px; border-radius: 10px; font-size: 14px;
  color: #fff; opacity: 0; transition: all 0.3s ease; z-index: 9999;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }

/* ========== Modal ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; }
.modal-box {
  background: #fff; border-radius: 16px; padding: 24px;
  width: 300px; text-align: center;
}
.modal-msg { font-size: 15px; color: #374151; margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; padding: 10px; border-radius: 10px; font-size: 14px; border: none; cursor: pointer; }
.btn-cancel { background: #f3f4f6; color: #374151; }
.btn-danger { background: #ef4444; color: #fff; }

/* ========== 隐藏的文件输入 ========== */
.hidden-input { display: none; }

/* ========== 响应式 ========== */
@media (min-width: 481px) {
  #app { box-shadow: 0 0 20px rgba(0,0,0,0.08); }
}
