/* ===== 林大记账 移动端样式 ===== */
:root {
  --blue: #2f6bff;
  --blue-d: #1f4fd0;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1a1d24;
  --gray: #8a91a0;
  --line: #eceef3;
  --orange: #ff7a29;
  --gray2: #9aa2b1;
  --green: #22a35c;
  --red: #e5484d;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* ---- 顶部 ---- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--blue);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  box-shadow: 0 2px 8px rgba(47,107,255,.25);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; }
#topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.owner-switch { display: flex; background: rgba(255,255,255,.18); border-radius: 20px; padding: 3px; }
.seg {
  border: 0; background: transparent; color: rgba(255,255,255,.85);
  padding: 6px 16px; border-radius: 16px; font-size: 14px; cursor: pointer;
}
.seg.on { background: #fff; color: var(--blue); font-weight: 600; }

/* ---- 页面 ---- */
#pages { padding: 12px 14px; }
.page { display: block; }
.card {
  background: var(--card); border-radius: 16px; padding: 18px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05); margin-bottom: 14px;
}
.hint { color: var(--gray); font-size: 13px; margin: 10px 4px; }

/* 记一笔 */
.amt-wrap { display: flex; align-items: baseline; border-bottom: 2px solid var(--blue); padding: 8px 2px; margin-bottom: 14px; }
.amt-symbol { font-size: 28px; color: var(--blue); font-weight: 700; margin-right: 8px; }
.amt-wrap input {
  flex: 1; border: 0; outline: 0; font-size: 44px; font-weight: 700;
  color: var(--text); background: transparent; min-width: 0;
}
.field-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.field-label { color: var(--gray); font-size: 15px; }
.field-row input[type="text"], .field-row input[type="datetime-local"], .field-row input[type="number"] {
  border: 0; outline: 0; text-align: right; font-size: 16px; color: var(--text); flex: 1; background: transparent;
}
.field-value { font-size: 16px; font-weight: 600; color: var(--blue); }
.book-top {
  font-size: 12px; font-weight: 400; background: rgba(255,255,255,.18);
  padding: 2px 8px; border-radius: 10px; vertical-align: middle; margin-left: 6px; cursor: pointer;
}
.book-item {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px;
  cursor: pointer;
}
.book-item.on { border-color: var(--blue); background: #eef3ff; }
.book-item .bi-name { font-size: 15px; font-weight: 600; }
.book-item .bi-meta { color: var(--gray); font-size: 12px; }
.book-item .bi-del { color: var(--red); font-size: 13px; padding: 4px 8px; border: 0; background: transparent; cursor: pointer; }
.book-new { display: flex; gap: 8px; align-items: stretch; margin-top: 4px; }
.book-new input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 15px; }
.book-new .btn-primary { margin-top: 0; width: auto; padding: 12px 18px; font-size: 15px; flex: none; }
.note-row input { text-align: right; }
.mini-switch { display: flex; background: var(--bg); border-radius: 18px; padding: 2px; }
.mini-switch .seg { color: var(--gray); padding: 5px 14px; font-size: 14px; }
.mini-switch .seg.on { background: var(--blue); color: #fff; font-weight: 600; }

.btn-primary {
  width: 100%; margin-top: 18px; border: 0; background: var(--blue); color: #fff;
  font-size: 17px; font-weight: 600; padding: 14px; border-radius: 14px; cursor: pointer;
}
.btn-primary:active { background: var(--blue-d); }
.btn-danger {
  width: 100%; margin-top: 10px; border: 0; background: var(--red); color: #fff;
  font-size: 16px; font-weight: 600; padding: 13px; border-radius: 14px; cursor: pointer;
}
.btn-plain {
  border: 0; background: var(--bg); color: var(--blue); padding: 10px 16px;
  border-radius: 12px; font-size: 15px; cursor: pointer;
}
.btn-plain.danger { color: var(--red); }

/* 工具栏 */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.toolbar-title { font-weight: 600; }
.toolbar-note { color: var(--gray); font-size: 13px; }

/* ---- 列表 ---- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--card); border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); display: flex; align-items: center; gap: 10px;
}
.item .check { width: 24px; height: 24px; border: 2px solid var(--line); border-radius: 7px; flex: none; display: none; }
.item.batch .check { display: block; }
.item.batch .check.on { background: var(--blue); border-color: var(--blue); position: relative; }
.item.batch .check.on::after { content: "✓"; color: #fff; font-size: 15px; position: absolute; left: 3px; top: -2px; }
.item-main { flex: 1; min-width: 0; }
.item-top { display: flex; align-items: baseline; gap: 8px; }
.item-amt { font-size: 18px; font-weight: 700; }
.item-amt.owner-li { color: #9c5bff; }
.item-note { color: var(--text); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--gray); font-size: 12px; margin-top: 2px; }
.tag {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; flex: none;
}
.tag.orange { background: #ffe9dc; color: var(--orange); }
.tag.gray { background: #eef0f4; color: var(--gray2); }
.tag.blue { background: #e4ecff; color: var(--blue); }
.tag.green { background: #e2f6ea; color: var(--green); }
.tag.purple { background: #f0e8ff; color: #9c5bff; }
.tag.plat { background: #fff3d6; color: #c78a00; }
.item .tag { align-self: center; }
.g-btn { flex: none; padding: 6px 12px; font-size: 13px; border-radius: 10px; background: #e4ecff; color: var(--blue); font-weight: 600; }

/* 流水页最下面：两个组平行显示 */
.flow-groups { display: flex; gap: 10px; margin-top: 16px; }
.fg-col { flex: 1; min-width: 0; }
.fg-title {
  font-size: 13px; color: var(--gray); font-weight: 600; margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.fg-title::before {
  content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--blue); display: inline-block;
}
.fg-card {
  background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); cursor: pointer;
}
.fg-card:active { background: var(--bg); }
.fgc-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fgc-amt { font-size: 15px; font-weight: 700; color: var(--blue); margin-top: 2px; }
.fgc-meta { font-size: 11px; color: var(--gray); margin-top: 1px; }
.fg-empty { margin: 0; font-size: 12px; }

/* 流水视图切换：常规/合并 */
.flow-tabs { display: flex; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 10px; }
.flow-tabs .ft {
  flex: 1; border: 0; background: transparent; padding: 9px 0; font-size: 14px;
  color: var(--gray); border-radius: 9px; cursor: pointer;
}
.flow-tabs .ft.on { background: var(--blue); color: #fff; font-weight: 600; }
.ft-amt { font-weight: 600; font-size: 12px; opacity: .85; }

/* 合并流水卡片 */
.merged-card {
  background: var(--card); border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  margin-bottom: 8px; overflow: hidden;
}
.mc-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; cursor: pointer; }
.mc-head:active { background: var(--bg); }
.mc-plat { font-weight: 600; font-size: 15px; }
.mc-amt { color: var(--blue); font-weight: 700; font-size: 15px; }
.mc-body { border-top: 1px solid var(--line); padding: 2px 14px; }
.mc-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.mc-row:last-child { border-bottom: 0; }
.mc-note { color: var(--gray); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.mc-amt2 { font-weight: 600; color: var(--text); flex: none; }

/* 组卡片 */
.group-sec {
  font-size: 13px; color: var(--gray); font-weight: 600;
  margin: 14px 2px 8px; display: flex; align-items: center; gap: 6px;
}
.group-sec:first-child { margin-top: 0; }
.group-sec::before {
  content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--blue); display: inline-block;
}
.group-card {
  background: var(--card); border-radius: 14px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05); display: flex; flex-direction: column; gap: 6px;
}
.group-card .gc-top { display: flex; align-items: center; justify-content: space-between; }
.group-card .gc-name { font-size: 16px; font-weight: 600; }
.group-card .gc-amt { font-size: 18px; font-weight: 700; color: var(--blue); }
.group-card .gc-meta { color: var(--gray); font-size: 13px; }
.gc-actions { display: flex; gap: 8px; margin-top: 6px; }
.gc-actions .btn-plain { padding: 7px 10px; font-size: 12px; flex: 1; text-align: center; }
.gc-actions .danger { background: #fdeeee; }

/* ---- 底部弹层 ---- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,.12);
  display: flex; flex-direction: column; gap: 12px;
  max-height: 75vh; overflow-y: auto;
}
.sheet.hidden { display: none; }
.hidden { display: none !important; }
.sheet-title { font-size: 16px; font-weight: 600; text-align: center; }
.sheet input[type="text"], .sheet select, .sheet input[type="number"], .sheet input[type="datetime-local"] {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; width: 100%; background: #fff;
}
.group-sheet .opt {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer; margin-bottom: 8px;
}
.group-sheet .opt:active { background: var(--bg); }
.sheet-new { display: flex; flex-direction: column; gap: 8px; }
.sheet-new-label { font-size: 12px; color: var(--gray); }

/* 组详情 */
.gd-meta { color: var(--gray); font-size: 14px; text-align: center; }
.gd-actions { display: flex; gap: 8px; justify-content: center; }
.gd-actions .btn-plain { flex: 1; text-align: center; }

/* ---- 统计 ---- */
.stat-tabs { display: flex; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.stat-tabs .st {
  flex: 1; border: 0; background: transparent; padding: 9px 0; font-size: 14px;
  color: var(--gray); border-radius: 9px; cursor: pointer;
}
.stat-tabs .st.on { background: var(--blue); color: #fff; font-weight: 600; }
.stat-card { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.stat-card .sc-title { font-size: 14px; color: var(--gray); margin-bottom: 8px; }
.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.stat-row:last-child { border-bottom: 0; }
.stat-row .sr-label { font-size: 15px; }
.stat-row .sr-amt { font-weight: 700; font-size: 16px; }
.stat-row .sr-amt.total { color: var(--blue); font-size: 18px; }
.stat-row .sr-sub { color: var(--gray); font-size: 12px; }

/* ---- 底部导航 ---- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 25;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
#tabbar .tab {
  flex: 1; border: 0; background: transparent; padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--gray); font-size: 11px; cursor: pointer;
}
#tabbar .tab .tab-icon { font-size: 20px; line-height: 1; }
#tabbar .tab.on { color: var(--blue); font-weight: 600; }

hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* 流水条目右侧操作区 */
.item-ops { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.item-ops .g-btn { padding: 5px 10px; font-size: 12px; }
.item-ops .del-btn { padding: 5px 10px; font-size: 12px; background: #fdeeee; }
.item-ops .tag { align-self: flex-end; }

/* 平台下拉 + 同步行 */
.plat-select {
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  font-size: 15px; background: #fff; color: var(--text); flex: 0 0 auto; min-width: 96px;
}
.sync-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sync-status { font-size: 13px; color: var(--gray); }
