/* ===== 全局重置 & 基础 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #1677ff;
  --primary-light: #e8f0fe;
  --primary-dark: #0d5bd6;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-hint: #999999;
  --border: #f0f0f0;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 108px;
  --nav-height: 60px;
  --blue: #1677ff;
  --green: #00b578;
  --orange: #ff7d00;
  --red: #ff3141;
  --purple: #7b61ff;
  --cyan: #00bcd4;
  --pink: #ff4081;
  --teal: #009688;
  --gradient: linear-gradient(135deg, #1677ff 0%, #7b61ff 100%);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

/* ===== 顶栏 ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--gradient);
  color: white;
  padding: 8px 16px 0;
  padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
  box-shadow: 0 2px 8px rgba(22, 119, 255, 0.3);
  transition: transform 0.3s ease;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left i,
.header-right i {
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: background 0.2s;
}

.header-left i:active,
.header-right i:active {
  background: rgba(255, 255, 255, 0.3);
}

.header-right {
  display: flex;
  gap: 4px;
}

.header-center {
  flex: 1;
}

.search-bar {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 6px 14px;
  gap: 8px;
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.search-bar i {
  font-size: 14px;
  opacity: 0.8;
}

.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  color: white;
  font-size: 14px;
  width: 100%;
  caret-color: white;
}

.search-bar input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.header-tabs {
  display: flex;
  gap: 0;
  margin-top: 10px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.header-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.7;
  cursor: pointer;
  position: relative;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.tab.active {
  opacity: 1;
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: white;
  border-radius: 2px;
}

/* ===== 主内容区 ===== */
.app-main {
  padding: calc(var(--header-height) + 16px) 16px 16px;
  max-width: 500px;
  margin: 0 auto;
}

/* ===== 用户卡片 ===== */
.user-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.user-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  background: var(--gradient);
  opacity: 0.06;
  border-radius: 50%;
}

.user-avatar img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--primary-light);
  object-fit: cover;
}

.user-info {
  flex: 1;
}

.user-name {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-level {
  font-size: 10px;
  background: linear-gradient(135deg, #ff7d00, #ffb300);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.user-balance {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0;
  letter-spacing: -0.5px;
}

.balance-num {
  font-size: 28px;
}

.balance-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 4px;
}

.user-actions {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.user-actions span {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-actions span i {
  font-size: 13px;
}

/* ===== 快捷功能 ===== */
.quick-actions {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 12px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px 4px;
}

.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: background 0.2s, transform 0.15s;
}

.action-item:active {
  background: var(--border);
  transform: scale(0.95);
}

.action-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.action-icon.blue { background: var(--blue); }
.action-icon.green { background: var(--green); }
.action-icon.orange { background: var(--orange); }
.action-icon.red { background: var(--red); }
.action-icon.purple { background: var(--purple); }
.action-icon.cyan { background: var(--cyan); }
.action-icon.pink { background: var(--pink); }
.action-icon.teal { background: var(--teal); }
.action-icon.light { background: #e8e8e8; color: #666; }

.action-item span {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

/* ===== 资产卡片 ===== */
.asset-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.asset-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.asset-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.asset-more {
  font-size: 12px;
  color: var(--text-hint);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.asset-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.asset-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.asset-item:nth-last-child(-n+2) {
  border-bottom: none;
}

.asset-label {
  font-size: 12px;
  color: var(--text-hint);
}

.asset-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.asset-value.debt {
  color: var(--red);
}

/* ===== 账单流水 ===== */
.bill-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}

.bill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.bill-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.bill-more {
  font-size: 12px;
  color: var(--text-hint);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bill-list {
  display: flex;
  flex-direction: column;
}

.bill-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.bill-item:last-child {
  border-bottom: none;
}

.bill-item:active {
  background: var(--border);
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
}

.bill-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.bill-icon.blue-bg { background: var(--blue); }
.bill-icon.green-bg { background: var(--green); }
.bill-icon.orange-bg { background: var(--orange); }
.bill-icon.red-bg { background: var(--red); }
.bill-icon.purple-bg { background: var(--purple); }

.bill-info {
  flex: 1;
  min-width: 0;
}

.bill-title {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bill-desc {
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bill-amount {
  text-align: right;
  flex-shrink: 0;
}

.bill-amount .amount {
  font-size: 15px;
  font-weight: 600;
}

.bill-amount .amount.income {
  color: var(--green);
}

.bill-amount .amount.expense {
  color: var(--text-primary);
}

.bill-amount .time {
  font-size: 11px;
  color: var(--text-hint);
  display: block;
  margin-top: 2px;
}

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--nav-height);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  transition: color 0.2s, transform 0.15s;
  color: var(--text-hint);
  min-width: 60px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item:active {
  transform: scale(0.92);
}

.nav-item i {
  font-size: 22px;
}

.nav-item span {
  font-size: 10px;
  font-weight: 500;
}

/* ===== 响应式微调 ===== */
@media (max-width: 420px) {
  .action-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .user-balance {
    font-size: 20px;
  }
  
  .balance-num {
    font-size: 24px;
  }
  
  .asset-items {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 600px) {
  .app-main {
    padding-left: 24px;
    padding-right: 24px;
    max-width: 600px;
  }
  
  .action-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* 通用过渡 */
* {
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}