/* ===== 全局变量与基础样式 ===== */
:root {
  --primary: #4A90D9;
  --primary-dark: #357ABD;
  --primary-light: #E8F0FE;
  --accent: #F5A623;
  --accent-dark: #D4901E;
  --bg: #F0F2F5;
  --card-bg: #FFFFFF;
  --text: #333333;
  --text-light: #666666;
  --text-muted: #999999;
  --success: #52C41A;
  --danger: #FF4D4F;
  --border: #E8E8E8;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }

/* ===== 导航栏 ===== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(74,144,217,0.3);
}
.navbar h1 { font-size: 1.1rem; font-weight: 600; }
.navbar-btn {
  background: rgba(255,255,255,0.2); border: none; color: #fff;
  padding: 6px 14px; border-radius: 20px; font-size: 0.85rem; cursor: pointer;
  transition: background 0.2s;
}
.navbar-btn:active { background: rgba(255,255,255,0.35); }
.navbar-back {
  background: none; border: none; color: #fff; font-size: 1.2rem;
  cursor: pointer; padding: 4px 8px; margin-right: 8px; display: flex; align-items: center;
}

/* ===== 容器 ===== */
.container {
  max-width: 540px; margin: 0 auto; padding: 16px;
}

/* ===== 登录页 ===== */
.login-wrapper {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-logo { font-size: 2.4rem; margin-bottom: 8px; }
.login-title { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.login-subtitle { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 32px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card-bg); border-radius: var(--radius);
  padding: 32px 24px; box-shadow: var(--shadow);
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 0.85rem; font-weight: 500;
  color: var(--text-light); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.95rem; color: var(--text);
  background: #FAFAFA; transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: #fff;
}
.form-textarea { min-height: 60px; resize: vertical; }
.form-select { background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-error { color: var(--danger); font-size: 0.8rem; margin-top: 4px; display: none; }
.form-error.show { display: block; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s; gap: 6px; text-decoration: none;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:active { background: var(--accent-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { background: #d9363e; }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:active { background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 6px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.card-clickable { cursor: pointer; }
.card-clickable:active { transform: scale(0.98); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-title { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.card-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.card-amount { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.card-tag {
  font-size: 0.75rem; padding: 2px 8px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 12px;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { font-size: 0.95rem; }

/* ===== 统计区域 ===== */
.stats-bar {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.stat-item {
  flex: 1; background: var(--card-bg); border-radius: var(--radius-sm);
  padding: 12px 8px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ===== 总结区域 ===== */
.summary-section { margin-top: 20px; }
.summary-title {
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--primary-light);
}
.summary-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 0.9rem;
}
.summary-row:last-child { border-bottom: none; }
.summary-row-label { color: var(--text-light); }
.summary-row-value { font-weight: 600; color: var(--text); }
.summary-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; margin-top: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm); color: #fff;
}
.summary-total-label { font-size: 0.95rem; }
.summary-total-value { font-size: 1.3rem; font-weight: 700; }

/* ===== 记录列表 ===== */
.record-item {
  display: flex; align-items: center; padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}
.record-item:last-child { border-bottom: none; }
.record-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-right: 12px; flex-shrink: 0;
}
.record-icon.cat-transport { background: #E3F2FD; }
.record-icon.cat-hotel { background: #F3E5F5; }
.record-icon.cat-food { background: #FFF3E0; }
.record-icon.cat-taxi { background: #E8F5E9; }
.record-icon.cat-other { background: #F5F5F5; }
.record-info { flex: 1; min-width: 0; }
.record-info-top { display: flex; justify-content: space-between; align-items: center; }
.record-category { font-size: 0.9rem; font-weight: 500; }
.record-amount { font-size: 0.95rem; font-weight: 600; color: var(--accent); }
.record-info-bottom { display: flex; gap: 8px; margin-top: 3px; font-size: 0.78rem; color: var(--text-muted); }
.record-actions { display: flex; gap: 4px; margin-left: 8px; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45); z-index: 200;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-content {
  width: 100%; max-width: 540px;
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px; max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 1.4rem;
  color: var(--text-muted); cursor: pointer; padding: 4px;
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75); color: #fff; padding: 10px 24px;
  border-radius: 20px; font-size: 0.9rem; z-index: 300;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ===== 确认对话框 ===== */
.confirm-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45); z-index: 250;
  display: none; align-items: center; justify-content: center;
}
.confirm-overlay.show { display: flex; }
.confirm-box {
  width: 280px; background: var(--card-bg); border-radius: var(--radius);
  padding: 24px 20px; text-align: center;
}
.confirm-msg { font-size: 0.95rem; margin-bottom: 20px; line-height: 1.5; }
.confirm-btns { display: flex; gap: 12px; }
.confirm-btns .btn { flex: 1; }

/* ===== 分割标题 ===== */
.section-title {
  font-size: 0.9rem; font-weight: 600; color: var(--text-light);
  margin: 20px 0 10px; display: flex; align-items: center; gap: 8px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ===== 微信/移动端适配 ===== */
@media screen and (max-width: 768px) {
  .container { padding: 12px; }
  .login-card { padding: 24px 18px; }
}

/* ===== 管理列表 ===== */
.manage-list { margin-top: 12px; }
.manage-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.manage-item:last-child { border-bottom: none; }
.manage-item-name { font-size: 0.95rem; color: var(--text); }
.manage-item-actions { display: flex; gap: 6px; }
.manage-item-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.manage-item-usage {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 999px;
}
.manage-item-usage.is-used {
  background: #fff1f0;
  color: #cf1322;
}
.manage-item-usage.is-free {
  background: #f6ffed;
  color: #389e0d;
}
