/* ============================================================
   ahlum&enger的赚钱消费日记 · 粉色简约可爱风
   ============================================================ */
:root {
  --pink: #FF8FAB;
  --pink-deep: #F06292;
  --pink-soft: #FFC2D4;
  --bg: #FFF0F5;
  --card: #FFFFFF;
  --ink: #5B4752;
  --ink-soft: #A98B99;
  --line: #FFE3EC;
  --income: #4CBB8A;
  --expense: #FF7E9A;
  --shadow: 0 6px 20px rgba(240, 98, 146, 0.14);
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ---------- 顶部 ---------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 10px;
  background: linear-gradient(135deg, #FFB6C9, #FF8FAB);
  box-shadow: 0 4px 16px rgba(240, 98, 146, 0.25);
}
.app-title {
  display: flex; align-items: center; gap: 10px;
}
.title-emoji { font-size: 26px; }
.app-title h1 {
  font-size: 18px; color: #fff; font-weight: 700; letter-spacing: .5px;
}

/* ---------- 主体 ---------- */
#app {
  padding: calc(72px + env(safe-area-inset-top, 0px)) 16px
           calc(86px + var(--safe-bottom));
  max-width: 560px;
  margin: 0 auto;
}
.page { display: none; animation: fadeIn .25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* ---------- 分段 & 周期选择 ---------- */
.segmented {
  display: flex; background: #FFE3EC; border-radius: 999px; padding: 4px; margin-bottom: 12px;
}
.seg-btn {
  flex: 1; border: none; background: transparent; padding: 8px 0;
  border-radius: 999px; color: var(--ink-soft); font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--pink-deep); box-shadow: 0 2px 8px rgba(240,98,146,.18); }

.period-picker {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.arrow {
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: #fff; color: var(--pink-deep); font-size: 24px; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow);
}
.period-label { font-size: 17px; font-weight: 700; color: var(--ink); }

/* ---------- 人物切换 ---------- */
.person-switch {
  display: flex; gap: 10px; margin-bottom: 14px;
}
.person-btn {
  flex: 1; padding: 12px 0; border: 2px solid var(--pink-soft); border-radius: 16px;
  background: #fff; color: var(--ink-soft); font-size: 16px; font-weight: 700; cursor: pointer;
}
.person-btn.active { background: var(--pink); color: #fff; border-color: var(--pink); box-shadow: var(--shadow); }

/* ---------- 录入表单 ---------- */
.entry-form { margin-bottom: 14px; }
.form-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.form-row label { width: 42px; font-size: 14px; color: var(--ink-soft); flex-shrink: 0; }
.form-row input {
  flex: 1; border: 2px solid var(--line); border-radius: 14px; padding: 11px 14px;
  font-size: 16px; color: var(--ink); outline: none; background: #FFFBFD;
}
.form-row input:focus { border-color: var(--pink); background: #fff; }
.form-row input::placeholder { color: #E4C6D2; }

.btn-primary {
  width: 100%; padding: 14px 0; border: none; border-radius: 16px;
  background: linear-gradient(135deg, #FF9EBB, #F06292); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
}
.btn-primary:active { transform: scale(.98); }
.btn-expense { background: linear-gradient(135deg, #FF8FAB, #FF6B8A); }
.btn-annual { background: linear-gradient(135deg, #FFB36B, #F0925B); }
.btn-import {
  width: 100%; padding: 13px 0; margin-bottom: 14px; border: 2px dashed var(--pink);
  border-radius: 16px; background: #FFF5F8; color: var(--pink-deep);
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-import:active { transform: scale(.98); }

/* ---------- 汇总条 ---------- */
.summary-strip {
  display: flex; gap: 10px; margin-bottom: 14px;
}
.summary-item {
  flex: 1; background: #fff; border-radius: 16px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow);
}
.summary-item .s-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.summary-item .s-value { font-size: 17px; font-weight: 800; }
.s-income .s-value { color: var(--income); }
.s-expense .s-value { color: var(--expense); }
.s-balance .s-value { color: var(--pink-deep); }

/* ---------- 明细列表 ---------- */
.detail-list { display: flex; flex-direction: column; gap: 10px; }
.detail-item {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer;
}
.detail-emoji { font-size: 22px; }
.detail-main { flex: 1; min-width: 0; }
.detail-top { display: flex; align-items: center; gap: 8px; }
.detail-person {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #FFE3EC; color: var(--pink-deep);
}
.detail-category { font-size: 15px; font-weight: 600; color: var(--ink); }
.detail-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.detail-amount { font-size: 16px; font-weight: 800; white-space: nowrap; }
.amount-in { color: var(--income); }
.amount-out { color: var(--expense); }
.detail-empty { text-align: center; color: var(--ink-soft); padding: 30px 0; font-size: 14px; }

/* ---------- 目标页 ---------- */
.goal-block { margin-bottom: 16px; }
.goal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.goal-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.goal-row label { width: 70px; font-size: 14px; color: var(--ink-soft); flex-shrink: 0; }
.goal-row input {
  flex: 1; border: 2px solid var(--line); border-radius: 14px; padding: 11px 14px;
  font-size: 16px; color: var(--ink); outline: none; background: #FFFBFD;
}
.goal-row input:focus { border-color: var(--pink); background: #fff; }

.progress-wrap { margin-top: 14px; }
.progress-bar {
  height: 16px; background: #FFE3EC; border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 999px; transition: width .5s ease;
  background: linear-gradient(90deg, #FF9EBB, #F06292);
}
.progress-fill.good { background: linear-gradient(90deg, #7BD3A5, #4CBB8A); }
.progress-fill.slow { background: linear-gradient(90deg, #FFB36B, #F0925B); }
.progress-fill.bad  { background: linear-gradient(90deg, #FF8FAB, #FF5F7E); }
.progress-text { margin-top: 8px; font-size: 13px; color: var(--ink-soft); text-align: center; }

.goal-sub-row {
  display: flex; justify-content: space-between; font-size: 13px;
  color: var(--ink); margin-top: 10px;
}
.goal-sub-row:first-child { margin-top: 12px; }
.goal-sub-row span:last-child { font-weight: 700; }
.goal-sub-total { color: var(--pink-deep); font-weight: 700; border-top: 1px dashed var(--pink-soft); padding-top: 8px; }
.mini-bar {
  height: 10px; background: #FFE3EC; border-radius: 999px; overflow: hidden; margin-top: 4px;
}
.mini-fill {
  height: 100%; width: 0; border-radius: 999px; transition: width .5s ease;
}
.mini-fill.good { background: linear-gradient(90deg, #7BD3A5, #4CBB8A); }
.mini-fill.slow { background: linear-gradient(90deg, #FFB36B, #F0925B); }
.mini-fill.bad  { background: linear-gradient(90deg, #FF8FAB, #FF5F7E); }
.goal-empty { text-align: center; color: var(--ink-soft); font-size: 13px; padding: 14px 0 4px; }
.big-total {
  font-size: 15px; color: var(--ink); background: #FFF5F8; border-radius: 12px;
  padding: 10px 14px; margin-bottom: 10px;
}
.big-total b { color: var(--pink-deep); }

.nag-box {
  border: 2px solid var(--pink-soft); background: #FFF9FB; text-align: center;
  font-size: 15px; line-height: 1.6; min-height: 60px; display: flex; align-items: center; justify-content: center;
}

/* ---------- 底部 tab ---------- */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + var(--safe-bottom));
}
.tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-soft); font-size: 11px; padding: 4px 0;
}
.tab-ico { font-size: 22px; filter: grayscale(1) opacity(.6); transition: .2s; }
.tab.active { color: var(--pink-deep); font-weight: 700; }
.tab.active .tab-ico { filter: none; transform: translateY(-1px); }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(91,71,82,.35); z-index: 40;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 380px; }
.modal h3 { font-size: 17px; margin-bottom: 14px; color: var(--ink); }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn-primary { flex: 2; }
.btn-ghost {
  flex: 1; padding: 13px 0; border: 2px solid var(--line); border-radius: 14px;
  background: #fff; color: var(--ink-soft); font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-danger {
  flex: 1; padding: 13px 0; border: none; border-radius: 14px;
  background: #FFE3EC; color: #E0486B; font-size: 15px; font-weight: 700; cursor: pointer;
}

/* ---------- 导入账单弹窗 ---------- */
.import-modal { max-height: 85vh; display: flex; flex-direction: column; }
.import-field { margin-bottom: 12px; }
.import-label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 8px; }
.import-field .person-switch { margin-bottom: 0; }
.import-field input[type="file"] {
  width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px;
  font-size: 14px; color: var(--ink); background: #FFFBFD; box-sizing: border-box;
}
.import-hint { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
#import-preview { overflow-y: auto; flex: 1; min-height: 0; margin-top: 4px; }
.import-summary {
  font-size: 14px; color: var(--ink); background: #FFF5F8; border-radius: 12px;
  padding: 10px 14px; margin-bottom: 10px;
}
.import-summary b { color: var(--pink-deep); }
.import-list { display: flex; flex-direction: column; gap: 8px; }
.import-item {
  display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px;
}
.import-item-main { flex: 1; min-width: 0; }
.import-item-peer {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.import-item-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.import-cat {
  border: 2px solid var(--line); border-radius: 10px; padding: 6px 8px;
  font-size: 13px; color: var(--ink); background: #FFFBFD; max-width: 96px; flex-shrink: 0;
}
.import-del {
  border: none; background: #FFE3EC; color: #E0486B; width: 26px; height: 26px;
  border-radius: 50%; font-size: 13px; cursor: pointer; flex-shrink: 0; line-height: 1;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%) translateY(20px);
  background: rgba(91,71,82,.9); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 总计卡片 ---------- */
.total-card { margin-bottom: 12px; }
.total-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.total-emoji { font-size: 20px; }
.total-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.total-line {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 14px; color: var(--ink-soft);
}
.t-in { color: var(--income); font-weight: 700; }
.t-out { color: var(--expense); font-weight: 700; }
.total-balance {
  border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px;
  font-weight: 700; color: var(--ink);
}
.total-combined {
  border: 2px solid var(--pink-soft);
  background: linear-gradient(135deg, #FFF9FB, #FFF0F5);
}
