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

:root {
  --primary: #4A90D9;
  --primary-dark: #3A7BC8;
  --primary-light: #6BA5E7;
  --success: #52C41A;
  --warning: #FAAD14;
  --danger: #FF4D4F;
  --bg: #F5F7FA;
  --white: #FFFFFF;
  --text: #333333;
  --text-secondary: #666666;
  --text-hint: #999999;
  --border: #E8E8E8;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ====== 页面容器（全屏不可滚动） ====== */
.page {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  max-width: 480px;
  margin: 0 auto;
}
.page.active { display: flex; flex-direction: column; }

/* 桌面端居中加边框 */
@media (min-width: 481px) {
  .page { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  body { background: #E8E8E8; }
}

/* ====== 头部 ====== */
.header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: calc(16px + var(--safe-top)) 20px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.greeting { font-size: 13px; opacity: 0.8; }
.user-name { font-size: 20px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 10px; }
.current-project {
  font-size: 11px; background: rgba(255,255,255,0.2);
  padding: 4px 10px; border-radius: 10px; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ====== 按钮 ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px; border-radius: 12px; font-size: 15px;
  font-weight: 500; border: none; cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); opacity: 0.9; }
.btn-primary { background: linear-gradient(135deg, var(--primary-light), var(--primary-dark)); color: white; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-block { width: 100%; margin: 6px 0; }
.btn-small { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn-text { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 4px 0; }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px; }
.btn-back { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 15px; padding: 4px 0; }

/* ====== 卡片 ====== */
.card {
  background: var(--white); border-radius: 14px; padding: 16px;
  margin: 10px 14px; box-shadow: var(--shadow);
}

/* ====== 语音区 ====== */
.voice-section { text-align: center; }
.voice-hint { color: var(--text-hint); font-size: 13px; margin-bottom: 12px; }
.voice-btn-container { display: flex; flex-direction: column; align-items: center; }
.voice-btn {
  width: 88px; height: 88px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border: none; cursor: pointer; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 6px 20px rgba(74,144,217,0.35);
  transition: all 0.2s; -webkit-tap-highlight-color: transparent;
}
.voice-btn:active { transform: scale(0.95); }
.voice-btn.recording {
  background: linear-gradient(135deg, #FF6B6B, var(--danger));
  box-shadow: 0 6px 20px rgba(255,77,79,0.35);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.mic-icon { font-size: 36px; }
.voice-status { margin-top: 10px; font-size: 13px; color: var(--text-hint); }
.voice-timer { font-size: 18px; font-weight: 600; color: var(--danger); margin-top: 6px; }
.voice-result {
  margin-top: 12px; padding: 12px; background: rgba(74,144,217,0.06);
  border-radius: 10px; text-align: left;
}
.result-label { font-size: 11px; color: var(--text-hint); }
.result-text { font-size: 15px; font-weight: 500; margin: 6px 0; line-height: 1.5; }

.voice-actions { margin-top: 12px; display: flex; gap: 10px; }

.voice-result-fixed {
  margin: 0 14px 0;
  padding: 14px 16px;
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voice-result-fixed .result-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.5;
  width: 100%;
}
.voice-result-fixed .result-text.placeholder {
  color: var(--text-hint);
  font-weight: 400;
}

/* ====== 快捷操作 ====== */
.quick-actions { display: flex; padding: 12px 8px; }
.action-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  background: none; border: none; cursor: pointer; padding: 8px 4px;
  -webkit-tap-highlight-color: transparent;
}
.action-btn:active { opacity: 0.7; }
.action-icon { font-size: 28px; margin-bottom: 6px; }
.action-btn span:last-child { font-size: 12px; color: var(--text-secondary); }

/* ====== 区块 ====== */
.section { padding: 0 14px; margin-bottom: 12px; flex-shrink: 0; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-header h2 { font-size: 16px; font-weight: 600; }

/* ====== 支出列表 ====== */
.expense-list { background: var(--white); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.expense-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid #F5F5F5;
}
.expense-item:last-child { border-bottom: none; }
.expense-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.expense-icon { font-size: 24px; flex-shrink: 0; }
.expense-info { min-width: 0; }
.expense-desc { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-date { font-size: 11px; color: var(--text-hint); }
.expense-amount { font-size: 15px; font-weight: 600; color: var(--danger); flex-shrink: 0; margin-left: 8px; }
.expense-actions { display: flex; gap: 4px; margin-left: 8px; flex-shrink: 0; }
.btn-delete { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; padding: 4px; }

/* ====== 表单 ====== */
.form { padding: 14px; flex: 1; overflow-y: auto; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 5px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 15px; background: var(--white); color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(74,144,217,0.1);
}
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* ====== 分类选择 ====== */
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.category-btn {
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 4px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--white); cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.category-btn:active { transform: scale(0.96); }
.category-btn.selected { border-color: var(--primary); background: rgba(74,144,217,0.08); }
.category-btn .cat-icon { font-size: 22px; }
.category-btn .cat-name { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }

/* ====== 项目列表 ====== */
.project-list { padding: 0 14px; flex: 1; overflow-y: auto; }
.project-card {
  background: var(--white); border-radius: 12px; padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.project-card:active { transform: scale(0.98); }
.project-name { font-size: 16px; font-weight: 600; }
.project-info { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.project-status {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  font-size: 11px; font-weight: 500;
}
.status-planned { background: rgba(74,144,217,0.1); color: var(--primary); }
.status-ongoing { background: rgba(82,196,26,0.1); color: var(--success); }
.status-completed { background: rgba(250,173,20,0.1); color: var(--warning); }
.project-budget { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.progress-bar { height: 5px; background: #F0F0F0; border-radius: 3px; overflow: hidden; margin-top: 5px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary-light), var(--primary)); border-radius: 3px; transition: width 0.3s; }

/* ====== 项目详情 ====== */
.detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 14px; }
.stat-card {
  background: var(--white); border-radius: 10px; padding: 12px 8px;
  text-align: center; box-shadow: var(--shadow);
}
.stat-value { font-size: 18px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 11px; color: var(--text-hint); margin-top: 3px; }

/* ====== 报表 ====== */
.report-content { flex: 1; overflow-y: auto; padding-bottom: 20px; }
.report-card { text-align: center; }
.report-label { font-size: 13px; color: var(--text-secondary); }
.report-value { font-size: 28px; font-weight: 700; color: var(--primary); margin-top: 6px; }

/* ====== 页头 ====== */
.page-header {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  background: var(--white); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.page-header h2 { flex: 1; font-size: 17px; }

/* ====== 空状态 ====== */
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-hint); font-size: 14px; }

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: calc(60px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.78); color: white; padding: 10px 20px;
  border-radius: 20px; font-size: 13px; z-index: 9999;
  opacity: 0; transition: opacity 0.25s; pointer-events: none;
  white-space: nowrap; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; }

/* ====== 滚动条美化 ====== */
.page::-webkit-scrollbar { width: 3px; }
.page::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }

/* ====== 安全区域 ====== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .page { padding-bottom: env(safe-area-inset-bottom); }
}
