/* 爸爸账目流水 —— 移动优先样式 */
:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e6e8eb;
  --blue: #1f6feb;
  --blue-d: #1758bd;
  --income: #16a34a;
  --expense: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #1f6feb, #2f86f6);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 2px 8px rgba(31, 111, 235, .25);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar h1 { font-size: 17px; font-weight: 600; margin: 0; flex: 1; text-align: center; }
.topbar-link {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  white-space: nowrap;
}
.topbar-link.ghost { background: transparent; width: 56px; }
.topbar-back { color: #fff; text-decoration: none; font-size: 15px; white-space: nowrap; }

/* ---------- 容器 ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 12px 12px 0; }
.bottom-space { height: 84px; }

/* ---------- 提示 ---------- */
.toast {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 10px;
  word-break: break-all;
}
.toast.ok { background: #e8f7ee; color: #12683a; border: 1px solid #b7e4c7; }
.toast.bad { background: #fdeaea; color: #9b1c1c; border: 1px solid #f5c2c2; }

/* ---------- 汇总卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.stat-k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-v { font-size: 19px; font-weight: 700; letter-spacing: -.2px; font-variant-numeric: tabular-nums; }
.stat-v.income { color: var(--income); }
.stat-v.expense { color: var(--expense); }
.stat-v.balance { color: var(--blue); }

.filter-tip {
  font-size: 12px;
  color: var(--muted);
  background: #eef3fd;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

/* ---------- 筛选 ---------- */
.filter {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.filter-row { display: flex; gap: 8px; margin-bottom: 8px; }
.filter-row:last-child { margin-bottom: 0; }
.fld {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: #fbfcfd;
  appearance: none;
  font-family: inherit;
}
.fld:focus { outline: 2px solid rgba(31, 111, 235, .25); border-color: var(--blue); background: #fff; }
select.fld {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}
.reset { display: inline-block; font-size: 12px; color: var(--muted); text-decoration: none; padding: 6px 4px 0; }

/* ---------- 按钮 ---------- */
.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-d); }
.btn.ghost { background: #eef0f3; color: #374151; }
.btn.block { display: block; width: 100%; padding: 13px; font-size: 15px; }

/* ---------- 列表卡片 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef0f3;
  color: #4b5563;
  white-space: nowrap;
}
.tag-in { background: #e8f7ee; color: #12683a; }
.tag-out { background: #eef2f7; color: #475569; }
.tag-img { background: #eef3fd; color: #1758bd; }
.card-amt {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.2px;
  white-space: nowrap;
}
.card-amt.income { color: var(--income); }
.card-amt.expense { color: var(--expense); }
.card-title { font-size: 15px; font-weight: 500; margin-top: 6px; word-break: break-all; }
.card-remark {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.balance-mini { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ops { display: flex; align-items: center; gap: 4px; }
.op {
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 6px 8px;
  font-family: inherit;
  cursor: pointer;
}
.op.danger { color: var(--expense); }
.inline { display: inline; margin: 0; }

/* ---------- 缩略图 ---------- */
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 2px; }
.thumbs.manage { flex-wrap: wrap; overflow: visible; }
.thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #eef0f3;
  flex: 0 0 auto;
  cursor: zoom-in;
}
.thumb-item { position: relative; }
.thumb-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--expense);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.empty {
  background: var(--card);
  border-radius: var(--radius);
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 2px 8px;
}
.pg {
  font-size: 14px;
  color: var(--blue);
  text-decoration: none;
  background: var(--card);
  border-radius: 10px;
  padding: 9px 14px;
  box-shadow: var(--shadow);
}
.pg.disabled { color: #b3b8bf; background: #f0f1f3; box-shadow: none; }
.pg-info { font-size: 12.5px; color: var(--muted); }

/* ---------- 表单 ---------- */
.form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.field { display: block; margin-bottom: 14px; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
textarea.fld { resize: vertical; min-height: 76px; }
.seg { display: flex; gap: 8px; }
.seg-item {
  flex: 1;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  color: var(--muted);
  background: #fbfcfd;
  cursor: pointer;
}
.seg-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg-item.on-in { border-color: var(--income); background: #e8f7ee; color: #12683a; font-weight: 600; }
.seg-item.on-out { border-color: var(--expense); background: #fdeaea; color: #9b1c1c; font-weight: 600; }
.upload-box { display: flex; gap: 8px; }
.up-btn {
  flex: 1;
  text-align: center;
  border: 1px dashed #c3cbd6;
  border-radius: 10px;
  padding: 12px 8px;
  font-size: 13.5px;
  color: var(--blue);
  background: #f8fafd;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.up-btn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.form-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

/* ---------- 浮动按钮 ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 28px;
  line-height: 52px;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(31, 111, 235, .38);
  z-index: 30;
}

/* ---------- 图片大图遮罩 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .88);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-v { font-size: 18px; }
}

/* ============================================================
   扩展样式：登录页 / 导航 tab / 记事 / 附件（v2）
   ============================================================ */

/* ---------- 导航 tab ---------- */
.tabs {
  max-width: 720px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tabs-inner {
  flex: 1;
  display: flex;
  background: #e9edf3;
  border-radius: 10px;
  padding: 3px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.tab.on {
  background: #fff;
  color: var(--blue);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.tabs-exit {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef3fb 0%, #f6f8fb 55%, #eaf0fb 100%);
  padding: 20px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: var(--card);
  border-radius: 18px;
  padding: 28px 22px 22px;
  box-shadow: 0 10px 34px rgba(16, 24, 40, .10);
  text-align: center;
}
.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1f6feb, #4b96f8);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  line-height: 56px;
  box-shadow: 0 8px 20px rgba(31, 111, 235, .32);
}
.login-title { font-size: 19px; margin: 0 0 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login-form { text-align: left; }
.login-input {
  text-align: center;
  letter-spacing: .32em;
  font-size: 18px;
  padding: 12px;
}
.login-btn { margin-top: 16px; }
.login-foot { color: #9aa3af; font-size: 12px; margin-top: 16px; }
.field { display: block; margin-bottom: 12px; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }

/* ---------- 记事 ---------- */
.note-card .card-title { font-size: 16px; font-weight: 600; margin: 2px 0 6px; }
.note-brief {
  color: #4b5563;
  font-size: 13.5px;
  white-space: normal;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-time { font-size: 13px; color: var(--muted); font-weight: 500; }
.attach-line { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attach-chip {
  font-size: 12px;
  color: #374151;
  background: #f3f5f9;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 记事编辑：已有附件列表 */
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.attach-name {
  flex: 1;
  color: var(--blue);
  text-decoration: none;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.attach-item .op { font-size: 13px; }

/* 内容框自适应 */
textarea.auto-grow { resize: vertical; min-height: 120px; line-height: 1.6; overflow: hidden; }

/* 多选上传按钮 */
.upload-box { display: flex; gap: 10px; flex-wrap: wrap; }
.up-btn { position: relative; overflow: hidden; }
.up-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* 附件缩略图删除按钮定位 */
.thumb-item { position: relative; }
.thumb-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  line-height: 22px;
  padding: 0;
  cursor: pointer;
}

/* 空状态与提示 */
.hint { color: #9aa3af; font-size: 12px; margin-top: 6px; line-height: 1.5; }

/* 表单底部按钮纵向排列（编辑页） */
.form-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.form-actions .btn.ghost { text-align: center; }

/* ---------- 编辑页：已有图片「先标记、保存后才删除」 ---------- */
.thumb-item[hidden] { display: none; }
.pending-box {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px dashed #e5b5b5;
  border-radius: 10px;
  background: #fff7f7;
}
.pending-head { font-size: 12px; color: #c0392b; }
.pending-list { list-style: none; margin: 6px 0 0; padding: 0; }
.pending-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0;
}
.pending-undo {
  border: 0;
  background: transparent;
  color: #1f6feb;
  font-size: 12px;
  padding: 2px 6px;
  cursor: pointer;
}
