/* ===================================
   Reset & Base
   =================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #EDEDED;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  color: #1A1A1A;
  -webkit-font-smoothing: antialiased;
}

/* ===================================
   App Container
   =================================== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  position: relative;
  background: #EDEDED;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===================================
   Top Navigation Bar
   =================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 8px 0 4px;
  background: #EDEDED;
  border-bottom: 0.5px solid #D4D4D4;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

.top-title {
  font-size: 17px;
  font-weight: 600;
  color: #1A1A1A;
  letter-spacing: 0.2px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* ===================================
   Icon Buttons (shared)
   =================================== */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  color: #1A1A1A;
  transition: background 0.12s;
  flex-shrink: 0;
}

.icon-btn:active {
  background: rgba(0,0,0,0.06);
}

/* ===================================
   Chat Area
   =================================== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar */
.chat-area::-webkit-scrollbar { width: 0; }

/* ===================================
   Time Divider
   =================================== */
.time-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}

.time-divider span {
  font-size: 12px;
  color: #999;
  background: rgba(0,0,0,0.06);
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

/* ===================================
   Message Row
   =================================== */
.message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* AI messages: left aligned */
.ai-row {
  flex-direction: row;
  padding-right: 60px;
}

/* User messages: right aligned */
.user-row {
  flex-direction: row-reverse;
  padding-left: 60px;
}

/* ===================================
   Avatar
   =================================== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar svg,
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.user-avatar {
  background: #5BAF6A;
}

/* ===================================
   Message Content & Bubble
   =================================== */
.message-content {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.sender-name {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
  padding-left: 2px;
}

.bubble {
  display: inline-block;
  padding: 10px 13px;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
  max-width: 100%;
}

/* AI bubble: white with left triangle */
.ai-bubble {
  background: #FFFFFF;
  color: #1A1A1A;
  border-radius: 0 8px 8px 8px;
}

.ai-bubble::before {
  content: '';
  position: absolute;
  top: 12px;
  left: -7px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 8px 5px 0;
  border-color: transparent #FFFFFF transparent transparent;
}

/* User bubble: WeChat green with right triangle */
.user-bubble {
  background: #95EC69;
  color: #1A1A1A;
  border-radius: 8px 0 8px 8px;
}

.user-bubble::after {
  content: '';
  position: absolute;
  top: 12px;
  right: -7px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent #95EC69;
}

/* Image bubble */
.image-bubble {
  padding: 3px;
  background: transparent;
  border-radius: 8px;
  max-width: 220px;
}

.image-bubble::before,
.image-bubble::after {
  display: none;
}

.image-bubble img {
  width: 100%;
  max-width: 220px;
  max-height: 280px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  cursor: pointer;
}

/* ===================================
   Voice Message Bubble
   =================================== */
.voice-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 80px;
  padding: 10px 14px;
}

.voice-wave-icon {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 18px;
}

.voice-wave-icon span {
  display: inline-block;
  width: 3px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.85;
}

.voice-wave-icon span:nth-child(1) { height: 6px; }
.voice-wave-icon span:nth-child(2) { height: 12px; }
.voice-wave-icon span:nth-child(3) { height: 18px; }
.voice-wave-icon span:nth-child(4) { height: 12px; }
.voice-wave-icon span:nth-child(5) { height: 6px; }

.voice-duration {
  font-size: 14px;
  color: #555;
}

/* ===================================
   Typing Indicator (AI thinking)
   =================================== */
.typing-row .bubble {
  padding: 14px 16px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 12px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #AAAAAA;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* ===================================
   Bill Card (AI structured response)
   =================================== */
.bill-card {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  min-width: 220px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.bill-card-header {
  background: #07C160;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bill-card-header .bill-icon { font-size: 18px; }
.bill-card-header .bill-title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.bill-card-body {
  padding: 12px 14px;
}

.bill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
}

.bill-row .label { color: #888; }
.bill-row .value { color: #1A1A1A; font-weight: 500; }
.bill-row .amount { color: #E74C3C; font-size: 18px; font-weight: 700; }
.bill-row .income { color: #07C160; font-size: 18px; font-weight: 700; }

.bill-card-footer {
  padding: 8px 14px 12px;
  border-top: 0.5px solid #F0F0F0;
  font-size: 12px;
  color: #AAA;
  text-align: center;
}

/* ===================================
   Bottom Bar
   =================================== */
.bottom-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 6px 8px;
  background: #F7F7F7;
  border-top: 0.5px solid #D4D4D4;
  flex-shrink: 0;
  min-height: 56px;
  /* Safe area padding for iOS */
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

/* ===================================
   Text Input Wrapper
   =================================== */
.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  min-height: 36px;
  max-height: 120px;
}

.text-input {
  width: 100%;
  min-height: 36px;
  max-height: 120px;
  padding: 7px 11px;
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
  border-radius: 6px;
  font-size: 15px;
  color: #1A1A1A;
  resize: none;
  outline: none;
  line-height: 1.4;
  overflow-y: auto;
  transition: border-color 0.15s;
  font-family: inherit;
}

.text-input:focus {
  border-color: #C8C8C8;
}

.text-input::placeholder { color: #BBBBBB; }

/* Hold-to-speak button */
.hold-to-speak {
  width: 100%;
  height: 36px;
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
  border-radius: 6px;
  font-size: 15px;
  color: #1A1A1A;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s;
  font-family: inherit;
}

.hold-to-speak:active,
.hold-to-speak.pressing {
  background: #D9D9D9;
}

.hold-to-speak.cancel-mode {
  background: #FF4444;
  color: white;
  border-color: #FF4444;
}

/* ===================================
   Send Button
   =================================== */
.send-btn {
  padding: 0 14px;
  height: 36px;
  background: #07C160;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
  transition: background 0.12s;
}

.send-btn:active { background: #06AD56; }

/* ===================================
   Right Icons (emoji + plus)
   =================================== */
.right-icons {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

/* ===================================
   Plus Panel
   =================================== */
.plus-panel {
  background: #F7F7F7;
  border-top: 0.5px solid #D4D4D4;
  padding: 20px 16px;
  flex-shrink: 0;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.plus-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.plus-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.plus-item-icon {
  width: 60px;
  height: 60px;
  background: #FFFFFF;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  transition: background 0.12s;
}

.plus-item:active .plus-item-icon {
  background: #E8E8E8;
}

.plus-item span {
  font-size: 12px;
  color: #666;
}

/* ===================================
   Recording Overlay
   =================================== */
.recording-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.recording-panel {
  background: rgba(0,0,0,0.72);
  border-radius: 16px;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 180px;
}

.recording-mic-icon {
  width: 72px;
  height: 72px;
  background: #07C160;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: micPulse 1s infinite ease-in-out;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(7,193,96,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(7,193,96,0); }
}

.recording-waves {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
}

.recording-waves span {
  display: inline-block;
  width: 4px;
  background: rgba(255,255,255,0.8);
  border-radius: 2px;
  animation: waveBar 0.8s infinite ease-in-out;
}

.recording-waves span:nth-child(1) { animation-delay: 0.0s; }
.recording-waves span:nth-child(2) { animation-delay: 0.1s; }
.recording-waves span:nth-child(3) { animation-delay: 0.2s; }
.recording-waves span:nth-child(4) { animation-delay: 0.3s; }
.recording-waves span:nth-child(5) { animation-delay: 0.4s; }
.recording-waves span:nth-child(6) { animation-delay: 0.3s; }
.recording-waves span:nth-child(7) { animation-delay: 0.2s; }
.recording-waves span:nth-child(8) { animation-delay: 0.1s; }
.recording-waves span:nth-child(9) { animation-delay: 0.0s; }

@keyframes waveBar {
  0%, 100% { height: 6px; }
  50% { height: 28px; }
}

.recording-hint {
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  text-align: center;
  line-height: 1.4;
}

.recording-hint.cancel { color: #FF6B6B; }

/* ===================================
   Image Preview Overlay
   =================================== */
.image-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.image-preview-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px;
  max-width: 90vw;
}

.image-preview-content img {
  max-width: 80vw;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 10px;
}

.preview-actions {
  display: flex;
  gap: 20px;
}

.preview-cancel,
.preview-send {
  padding: 10px 32px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.preview-cancel {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.preview-send {
  background: #07C160;
  color: #fff;
}

/* ===================================
   Toast Notification
   =================================== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.72);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  pointer-events: none;
  white-space: nowrap;
  animation: fadeIn 0.15s ease;
}

/* ===================================
   Responsive: slightly wider on tablet
   =================================== */
@media (min-width: 540px) {
  .app-container {
    box-shadow: 0 0 40px rgba(0,0,0,0.15);
  }
}

/* ===================================
   Bill Modal (账单查看页)
   =================================== */
.bill-modal {
  position: absolute;
  inset: 0;
  background: #F2F2F7;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  animation: slideInUp 0.25s ease;
}

@keyframes slideInUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.bill-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 4px 0 8px;
  background: #EDEDED;
  border-bottom: 0.5px solid #D4D4D4;
  flex-shrink: 0;
}

.bill-modal-title {
  font-size: 17px;
  font-weight: 600;
  color: #1A1A1A;
  letter-spacing: 0.2px;
}

/* 月度汇总条 */
.bill-modal-summary {
  display: flex;
  justify-content: space-around;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 0.5px solid #E8E8E8;
  flex-shrink: 0;
}

.bill-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bill-summary-label {
  font-size: 12px;
  color: #999;
}

.bill-summary-value {
  font-size: 18px;
  font-weight: 700;
}

.bill-summary-value.expense { color: #E74C3C; }
.bill-summary-value.income  { color: #07C160; }
.bill-summary-value.net     { color: #1A1A1A; }

.bill-summary-divider {
  width: 0.5px;
  background: #E0E0E0;
  margin: 2px 0;
}

/* 账单列表滚动区 */
.bill-modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0 20px;
  -webkit-overflow-scrolling: touch;
}

.bill-modal-body::-webkit-scrollbar { width: 0; }

/* 每天一组 */
.bill-date-group {
  margin-bottom: 10px;
}

.bill-date-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 16px 6px;
}

.bill-date-label {
  font-size: 13px;
  color: #888;
  font-weight: 500;
}

.bill-date-totals {
  display: flex;
  gap: 10px;
}

.bill-date-expense {
  font-size: 13px;
  color: #E74C3C;
}

.bill-date-income {
  font-size: 13px;
  color: #07C160;
}

/* 每天的账单卡片组 */
.bill-items-group {
  background: #fff;
  border-radius: 12px;
  margin: 0 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* 单条账单行 */
.bill-item {
  display: flex;
  align-items: center;
  padding: 11px 14px;
  gap: 12px;
  border-bottom: 0.5px solid #F5F5F5;
  position: relative;
  transition: background 0.12s;
  cursor: pointer;
}

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

.bill-item:active {
  background: #F9F9F9;
}

/* 分类图标圆圈 */
.bill-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

/* 中间信息区 */
.bill-item-info {
  flex: 1;
  min-width: 0;
}

.bill-item-category {
  font-size: 15px;
  font-weight: 500;
  color: #1A1A1A;
  line-height: 1.3;
}

.bill-item-desc {
  font-size: 12px;
  color: #AAAAAA;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 金额 */
.bill-item-amount {
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.bill-item-amount.expense { color: #E74C3C; }
.bill-item-amount.income  { color: #07C160; }

/* 右侧箭头 > */
.bill-item-edit-btn {
  background: none;
  border: none;
  padding: 0 0 0 8px;
  cursor: pointer;
  color: #C7C7CC;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color 0.12s;
}

.bill-item-edit-btn:active { color: #999; }

/* 空状态 */
.bill-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 14px;
  color: #AAAAAA;
}

.bill-empty .empty-icon { font-size: 48px; }
.bill-empty .empty-text { font-size: 15px; }

/* ===================================
   Edit Bottom Sheet（账单编辑弹窗）
   =================================== */
.edit-sheet {
  position: absolute;
  inset: 0;
  z-index: 1400;
}

.edit-sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  animation: fadeIn 0.2s ease;
}

.edit-sheet-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #F2F2F7;
  border-radius: 16px 16px 0 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  animation: slideInUp 0.25s ease;
}

.edit-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 0.5px solid #E0E0E0;
}

.edit-sheet-title {
  font-size: 16px;
  font-weight: 600;
  color: #1A1A1A;
}

.edit-sheet-cancel {
  background: none;
  border: none;
  font-size: 15px;
  color: #888;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.edit-sheet-save {
  background: none;
  border: none;
  font-size: 15px;
  color: #07C160;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.edit-sheet-save:active { opacity: 0.7; }

.edit-delete-wrap {
  padding: 12px 16px 4px;
}

.edit-delete-btn {
  width: 100%;
  padding: 14px;
  background: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  color: #E74C3C;
  cursor: pointer;
  font-family: inherit;
}

.edit-delete-btn:active { opacity: 0.7; }

.edit-sheet-body {
  padding: 8px 0;
}

.edit-field {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  background: #fff;
  border-bottom: 0.5px solid #F5F5F5;
  gap: 16px;
}

.edit-field:last-child { border-bottom: none; }

.edit-field label {
  font-size: 15px;
  color: #666;
  width: 36px;
  flex-shrink: 0;
}

.edit-field input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: #1A1A1A;
  background: transparent;
  text-align: right;
  font-family: inherit;
}

.edit-field input[type="date"] {
  color: #1A1A1A;
}

.edit-field input::placeholder { color: #CCCCCC; }

.edit-type-btns {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.edit-type-btn {
  padding: 5px 18px;
  border-radius: 16px;
  border: 1.5px solid #E0E0E0;
  background: #F7F7F7;
  font-size: 14px;
  cursor: pointer;
  color: #888;
  font-family: inherit;
  transition: all 0.12s;
}

.edit-type-btn.active[data-type="expense"] {
  background: #FFF0F0;
  border-color: #E74C3C;
  color: #E74C3C;
  font-weight: 600;
}

.edit-type-btn.active[data-type="income"] {
  background: #F0FFF4;
  border-color: #07C160;
  color: #07C160;
  font-weight: 600;
}

/* 分类选择行（可点击） */
.edit-field-picker {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.edit-field-picker:active { background: #F9F9F9; }

.edit-picker-value {
  flex: 1;
  text-align: right;
  font-size: 15px;
  color: #1A1A1A;
  margin-right: 4px;
}

.edit-picker-value.placeholder { color: #CCCCCC; }

/* ===================================
   Category Picker（分类选择器）
   =================================== */
.cat-picker {
  position: absolute;
  inset: 0;
  z-index: 1500;
}

.cat-picker-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  animation: fadeIn 0.2s ease;
}

.cat-picker-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #F2F2F7;
  border-radius: 16px 16px 0 0;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  animation: slideInUp 0.25s ease;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.cat-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px 12px 16px;
  flex-shrink: 0;
  border-bottom: 0.5px solid #E0E0E0;
}

.cat-picker-title {
  font-size: 16px;
  font-weight: 600;
  color: #1A1A1A;
}

.cat-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 8px;
  -webkit-overflow-scrolling: touch;
}

.cat-picker-body::-webkit-scrollbar { width: 0; }

/* 分组 */
.cat-section { margin-bottom: 14px; }

.cat-section-label {
  font-size: 12px;
  color: #999;
  margin-bottom: 8px;
  font-weight: 500;
}

/* 分类芯片网格 */
.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-chip {
  padding: 7px 16px;
  background: #fff;
  border: 1.5px solid #E8E8E8;
  border-radius: 20px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  line-height: 1.3;
}

.cat-chip:active { background: #F0F0F0; }

.cat-chip.selected {
  background: #E8F8EE;
  border-color: #07C160;
  color: #07C160;
  font-weight: 600;
}

.cat-chip.custom-chip {
  border-style: dashed;
  border-color: #BBBBBB;
  color: #888;
  background: transparent;
}

/* 自定义分类输入行 */
.cat-custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 4px;
  border-top: 0.5px solid #E8E8E8;
  flex-shrink: 0;
}

.cat-custom-row input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: 1.5px solid #E0E0E0;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  font-family: inherit;
  background: #fff;
}

/* ===================================
   Profile Editor
   =================================== */
#topTitle { cursor: pointer; }
#menuBtn  { cursor: pointer; }

.profile-modal {
  position: absolute;
  inset: 0;
  z-index: 1600;
  background: #F2F2F7;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: #F2F2F7;
  border-bottom: 0.5px solid #E0E0E0;
  flex-shrink: 0;
}

.profile-header-title {
  font-size: 17px;
  font-weight: 600;
  color: #1A1A1A;
}

.profile-back-btn { color: #07C160; }

.profile-save-btn {
  background: none;
  border: none;
  font-size: 15px;
  color: #07C160;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.profile-save-btn:active { opacity: 0.7; }

.profile-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 40px;
}

.profile-group-label {
  font-size: 13px;
  color: #888;
  padding: 0 16px 8px;
}

.profile-card {
  background: #fff;
  border-top: 0.5px solid #E0E0E0;
  border-bottom: 0.5px solid #E0E0E0;
  margin-bottom: 24px;
}

.profile-item {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  gap: 12px;
  cursor: pointer;
  min-height: 52px;
}

.profile-item-label {
  font-size: 15px;
  color: #1A1A1A;
  width: 40px;
  flex-shrink: 0;
}

.profile-avatar-thumb {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  margin-left: auto;
}

.profile-avatar-thumb img,
.profile-avatar-thumb svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.profile-divider {
  height: 0.5px;
  background: #F0F0F0;
  margin-left: 16px;
}

.profile-name-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: #1A1A1A;
  text-align: right;
  background: transparent;
  font-family: inherit;
  cursor: text;
}
.profile-name-input::placeholder { color: #C7C7CC; }

.cat-custom-row input:focus { border-color: #07C160; }

.cat-custom-row button {
  padding: 0 18px;
  height: 38px;
  background: #07C160;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

/* ===================================
   Month Bill Modal（月账单三层导航）
   =================================== */

.month-modal {
  position: absolute;
  inset: 0;
  background: #F2F2F7;
  z-index: 1200;
  overflow: hidden;
  animation: slideInUp 0.25s ease;
}

/* 每一层视图：全屏覆盖，同一时刻只显示一层 */
.month-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #F2F2F7;
}

/* 向右滑入（深入：列表→月详→日详） */
.month-view.slide-in-right {
  animation: monthSlideInRight 0.22s ease forwards;
}

/* 向左滑入（返回：日详→月详→列表） */
.month-view.slide-in-left {
  animation: monthSlideInLeft 0.22s ease forwards;
}

@keyframes monthSlideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes monthSlideInLeft {
  from { transform: translateX(-28%); opacity: 0.6; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* 内容滚动区 */
.month-modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0 20px;
  -webkit-overflow-scrolling: touch;
}

.month-modal-body::-webkit-scrollbar { width: 0; }

/* 通用卡片容器（圆角白底，与日账单列表一致） */
.month-items-card {
  background: #fff;
  border-radius: 12px;
  margin: 0 12px 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* ---- 月份列表每行 ---- */
.month-list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 0.5px solid #F5F5F5;
  cursor: pointer;
  transition: background 0.12s;
  gap: 12px;
}

.month-list-item:last-child { border-bottom: none; }
.month-list-item:active     { background: #F9F9F9; }

.month-list-info { flex: 1; }

.month-list-label {
  font-size: 16px;
  font-weight: 600;
  color: #1A1A1A;
  margin-bottom: 4px;
}

.month-list-stats {
  display: flex;
  gap: 12px;
  font-size: 13px;
}

.month-list-expense { color: #E74C3C; }
.month-list-income  { color: #07C160; }

.month-list-arrow {
  color: #C7C7CC;
  flex-shrink: 0;
}

/* ---- 月详情中每天一行 ---- */
.day-list-item {
  display: flex;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 0.5px solid #F5F5F5;
  cursor: pointer;
  transition: background 0.12s;
  gap: 12px;
}

.day-list-item:last-child { border-bottom: none; }
.day-list-item:active     { background: #F9F9F9; }

.day-list-info  { flex: 1; }

.day-list-label {
  font-size: 15px;
  font-weight: 500;
  color: #1A1A1A;
}

.day-list-count {
  font-size: 12px;
  color: #AAAAAA;
  margin-top: 2px;
}

.day-list-amounts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.day-list-amount-expense {
  font-size: 15px;
  font-weight: 600;
  color: #E74C3C;
}

.day-list-amount-income {
  font-size: 13px;
  font-weight: 500;
  color: #07C160;
}

.day-list-arrow {
  color: #C7C7CC;
  flex-shrink: 0;
  margin-left: 4px;
}

/* ===================================
   Year Bill Modal（年账单，与月账单共用内部 CSS 类）
   =================================== */
.year-modal {
  position: absolute;
  inset: 0;
  background: #F2F2F7;
  z-index: 1200;
  overflow: hidden;
  animation: slideInUp 0.25s ease;
}

/* ===================================
   Bill Calendar Modal（账单日历）
   =================================== */
.cal-modal {
  position: absolute;
  inset: 0;
  background: #F2F2F7;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  animation: slideInUp 0.25s ease;
}

.cal-month-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.cal-month-title {
  font-size: 17px;
  font-weight: 600;
  color: #1A1A1A;
  white-space: nowrap;
}

.cal-week-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #fff;
  border-bottom: 0.5px solid #E8E8E8;
  flex-shrink: 0;
}

.cal-week-header span {
  text-align: center;
  padding: 8px 0;
  font-size: 12px;
  color: #888;
  font-weight: 500;
}

.cal-week-header span:first-child { color: #E74C3C; }
.cal-week-header span:last-child  { color: #5B9BD5; }

.cal-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-content: start;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.cal-grid::-webkit-scrollbar { width: 0; }

.cal-cell {
  border-right: 0.5px solid #F0F0F0;
  border-bottom: 0.5px solid #F0F0F0;
  padding: 6px 3px 5px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}

.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:active { background: #F5F5F5; }
.cal-cell.empty  { cursor: default; background: #FAFAFA; }
.cal-cell.today .cal-day-num {
  background: #07C160;
  color: #fff;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}

.cal-day-num {
  font-size: 14px;
  font-weight: 500;
  color: #1A1A1A;
  line-height: 1;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}

.cal-cell:nth-child(7n+1) .cal-day-num { color: #E74C3C; }
.cal-cell:nth-child(7n+1).today .cal-day-num { color: #fff; }
.cal-cell:nth-child(7n)   .cal-day-num { color: #5B9BD5; }
.cal-cell:nth-child(7n).today .cal-day-num   { color: #fff; }

.cal-expense {
  font-size: 10px;
  color: #E74C3C;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-income {
  font-size: 10px;
  color: #07C160;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bill-view-toggle {
  display: flex;
  background: #fff;
  border-bottom: 0.5px solid #E8E8E8;
  flex-shrink: 0;
}

.bill-toggle-btn {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.bill-toggle-btn.active {
  color: #07C160;
  border-bottom-color: #07C160;
  font-weight: 600;
}

/* 类别视图：分类行 */
.cat-stat-item {
  display: flex;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 0.5px solid #F5F5F5;
  gap: 12px;
}

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

.cat-stat-count {
  font-size: 12px;
  color: #AAAAAA;
  margin-top: 2px;
}

/* ===================================
   账单搜索弹窗
   =================================== */

.search-bar-wrap {
  padding: 14px 16px 16px;
  background: #fff;
  border-bottom: 0.5px solid #EBEBEB;
  flex-shrink: 0;
}

/* 外层行：输入框 + 搜索按钮 */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 胶囊形输入行 */
.search-input-row {
  flex: 1;
  display: flex;
  align-items: center;
  background: #F2F2F7;
  border-radius: 26px;
  padding: 0 14px;
  height: 48px;
  gap: 8px;
}

.search-bar-icon { color: #AAAAAA; flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  color: #1A1A1A;
  background: transparent;
  min-width: 0;
}

.search-input::placeholder { color: #C0C0C0; }

.search-clear {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 右侧圆形绿色搜索按钮 */
.search-submit-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #07C160;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(7,193,96,0.35);
  transition: background 0.15s, transform 0.1s;
}

.search-submit-btn:active {
  background: #06ad56;
  transform: scale(0.94);
}

/* 搜索结果摘要条 */
.search-summary {
  padding: 9px 16px;
  font-size: 13px;
  color: #888;
  background: #FAFAFA;
  border-bottom: 0.5px solid #EBEBEB;
  flex-shrink: 0;
}

.search-summary b { color: #1A1A1A; }

/* 初始占位 */
.search-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 80px 0 40px;
}

.search-placeholder .empty-icon { font-size: 52px; }
.search-placeholder .empty-text { font-size: 15px; color: #AAAAAA; }
.search-placeholder .empty-hint  { font-size: 13px; color: #C8C8C8; }

/* 关键词高亮 */
mark.kw {
  background: #FFF3CD;
  color: #E67E00;
  border-radius: 3px;
  padding: 0 2px;
  font-style: normal;
}

/* 搜索结果日期标签 */
.search-date-label {
  font-size: 12px;
  color: #999;
  padding: 10px 16px 4px;
  font-weight: 500;
}

/* ===================================
   类别视图 — 占比进度条（重构布局）
   =================================== */

.cat-pct-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
  border-bottom: 0.5px solid #F5F5F5;
  cursor: pointer;
  transition: background 0.12s;
}
.cat-pct-item:last-child { border-bottom: none; }
.cat-pct-item:active     { background: #F9F9F9; }

/* 图标圆圈 */
.cat-pct-icon-wrap {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

/* 右侧内容区（竖向两行） */
.cat-pct-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* 第一行：名称 + 百分比 + 金额 + 箭头 */
.cat-pct-row1 {
  display: flex;
  align-items: center;
}

.cat-pct-name-pct {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.cat-pct-name {
  font-size: 15px;
  font-weight: 500;
  color: #1A1A1A;
  white-space: nowrap;
}

.cat-pct-pct {
  font-size: 12px;
  font-weight: 500;
}
.cat-pct-pct.expense { color: #E74C3C; }
.cat-pct-pct.income  { color: #07C160; }

.cat-pct-amount-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cat-pct-amount {
  font-size: 15px;
  font-weight: 600;
}
.cat-pct-amount.expense { color: #E74C3C; }
.cat-pct-amount.income  { color: #07C160; }

/* 第二行：进度条 + 笔数 */
.cat-pct-row2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-pct-bar-bg {
  flex: 1;
  height: 4px;
  background: #EFEFEF;
  border-radius: 2px;
  overflow: hidden;
}

.cat-pct-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.cat-pct-bar-fill.expense { background: #E74C3C; }
.cat-pct-bar-fill.income  { background: #07C160; }

.cat-pct-count {
  font-size: 11px;
  color: #AAAAAA;
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

/* ===================================
   订阅到期提醒条
   =================================== */
.sub-wall {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFF3CD;
  border-top: 1px solid #FFD960;
  padding: 10px 14px;
  flex-shrink: 0;
}
.sub-wall-icon { font-size: 18px; }
.sub-wall-text {
  flex: 1;
  font-size: 13px;
  color: #7A5F00;
  line-height: 1.4;
}
.sub-wall-btn {
  background: #FF9500;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.sub-wall-btn:active { opacity: 0.85; }

/* ===================================
   订阅支付弹窗
   =================================== */
.sub-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sub-modal.hidden { display: none !important; }

.sub-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.sub-modal-box {
  position: relative;
  width: 100%;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: slideInUp 0.25s ease;
}

.sub-modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: #F2F2F7;
  border: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 14px;
  color: #888;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.sub-modal-logo { font-size: 36px; }
.sub-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #1A1A1A;
}
.sub-modal-price {
  font-size: 28px;
  font-weight: 700;
  color: #FF3B30;
  margin: 2px 0;
}
.sub-modal-price span { font-size: 36px; }
.sub-modal-price em  { font-size: 16px; font-style: normal; color: #888; }

.sub-modal-desc {
  font-size: 13px;
  color: #888;
  text-align: center;
}

.sub-qr-wrap {
  width: 180px; height: 180px;
  border: 1px solid #E5E5E5;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 4px 0;
}

.sub-qr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #AAAAAA;
  font-size: 13px;
}

.sub-qr-spinner {
  width: 28px; height: 28px;
  border: 3px solid #EEEEEE;
  border-top-color: #07C160;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sub-qr-img {
  width: 180px; height: 180px;
  object-fit: cover;
  border-radius: 12px;
}

.sub-qr-hint {
  font-size: 13px;
  color: #555;
}
.sub-qr-polling {
  font-size: 12px;
  color: #AAAAAA;
}
.sub-qr-polling.paid {
  color: #07C160;
  font-weight: 600;
}

