/* 佰万记账 —— 手机端样式（多巴胺粉彩风：奶油底 + 杏桃/薄荷/樱粉/奶油黄 + 橄榄绿 + 深棕） */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --brand: #7d8b5a;
  --brand-dark: #6a7849;
  --bg: #f5f1e8;
  --card: #fffdf9;
  --ink: #3b332a;
  --ink-2: #a59781;
  --income: #c96a4a;
  --expense: #7d8b5a;
  --line: #e9e2d4;
  --peach: #f9e7cf;
  --mint: #e5eed3;
  --pink: #fbe3da;
  --butter: #f8efd2;
  --brown: #453a2f;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 15px; overscroll-behavior: none;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.auth-view {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #f9e7cf 0%, #fbe3da 50%, #e5eed3 100%); padding: 24px;
}
.auth-card {
  background: var(--card); border-radius: 20px; padding: 32px 24px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(80, 30, 0, .35); text-align: center;
}
.auth-logo { font-size: 44px; }
.auth-card h1 { font-size: 24px; margin: 8px 0 4px; letter-spacing: 2px; }
.auth-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 20px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; padding: 9px; border: none; background: transparent; border-radius: 8px;
  font-size: 15px; color: var(--ink-2);
}
.auth-tab.active { background: var(--card); color: var(--brand); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.auth-card input {
  width: 100%; padding: 13px 14px; margin-bottom: 12px; border: 1.5px solid var(--line);
  border-radius: 12px; font-size: 15px; background: #fbfaf8; outline: none;
}
.auth-card input:focus { border-color: var(--brand); }
.auth-msg { margin-top: 12px; color: var(--income); font-size: 13px; min-height: 18px; }
.code-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 12px; }
.code-row input { flex: 1; min-width: 0; margin-bottom: 0; }
.send-code-btn {
  flex-shrink: 0; border: 1.5px solid var(--brand); color: var(--brand); background: var(--mint);
  border-radius: 12px; padding: 0 12px; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.send-code-btn:disabled { opacity: .5; }
.auth-tip { margin-top: 10px; font-size: 12px; color: var(--ink-2); text-align: center; }

/* ---------- 登录中状态 ---------- */
.loading-mask {
  position: fixed; inset: 0; background: rgba(255,255,255,.5); z-index: 70;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.btn-primary { position: relative; }
.btn-primary.loading { opacity: .85; pointer-events: none; display: flex; align-items: center; justify-content: center; gap: 9px; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: zg-spin .7s linear infinite; flex-shrink: 0;
}
@keyframes zg-spin { to { transform: rotate(360deg); } }

/* ---------- 按钮 ---------- */
.btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: 12px; background: var(--brand);
  color: #fff; font-size: 16px; font-weight: 600;
}
.btn-primary:active { background: var(--brand-dark); }
.btn-ghost {
  padding: 13px 20px; border: none; border-radius: 12px; background: var(--bg); color: var(--ink-2); font-size: 15px;
}

/* ---------- 顶栏（奶油底 + 深棕字，参考图同款） ---------- */
.topbar {
  background: var(--bg); color: var(--ink); padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 8px; }
.breadcrumb { flex: 1; font-size: 15px; font-weight: 600; white-space: nowrap; overflow-x: auto; }
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb .crumb { opacity: .6; padding: 2px 2px; }
.breadcrumb .crumb.current { opacity: 1; font-weight: 700; }
.breadcrumb .sep { opacity: .45; margin: 0 4px; }
.icon-btn {
  background: var(--peach); color: var(--ink); border: none; border-radius: 10px;
  width: 34px; height: 34px; font-size: 16px;
}

/* ---------- 文件夹主体 ---------- */
.folder-body { padding: 12px 12px calc(86px + env(safe-area-inset-bottom)); }
.summary-card {
  display: flex; gap: 8px; background: transparent; border-radius: 14px; padding: 0; margin-bottom: 12px;
  box-shadow: none; cursor: pointer;
}
.sum-item { flex: 1; text-align: center; border-radius: 16px; padding: 13px 2px; }
.sum-item.income { background: var(--peach); }
.sum-item.expense { background: var(--mint); }
.sum-item.profit { background: var(--butter); }
.sum-item span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.sum-item b { font-size: 16px; }
.sum-item.income b { color: var(--income); }
.sum-item.expense b { color: var(--expense); }
.sum-item.profit b { color: var(--brown); }
.summary-card:active { opacity: .8; }
.summary-hint { display: block; text-align: center; font-size: 11px; color: var(--ink-2); margin-top: 8px; }

/* ---------- 收支明细列表 ---------- */
.sheet-tall { max-height: 78vh; display: flex; flex-direction: column; }
.trans-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; max-height: 55vh; margin-bottom: 12px; }
.trans-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 4px;
  border-bottom: 1px solid #f2ece4;
}
.trans-row:last-child { border-bottom: none; }
.tr-icon {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
}
.tr-icon.income { background: #f7ded1; color: var(--income); }
.tr-icon.expense { background: var(--mint); color: var(--expense); }
.tr-main { flex: 1; min-width: 0; cursor: pointer; }
.tr-note { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-meta { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.tr-amt { font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.tr-amt.income { color: var(--income); }
.tr-amt.expense { color: var(--expense); }
.tr-del { border: none; background: transparent; font-size: 16px; padding: 6px; flex-shrink: 0; }

/* 弹层层级：修改表单必须压在明细列表之上 */
#transListSheet { z-index: 40; }
#transSheet { z-index: 45; }

.item-list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px;
  padding: 13px 14px; box-shadow: 0 1px 4px rgba(0,0,0,.05); position: relative;
}
.item:active { background: #f7f2e8; }
.item-icon { font-size: 26px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: var(--peach); border-radius: 10px; flex-shrink: 0; }
/* 多巴胺：图标底色循环 杏桃→薄荷→樱粉→奶油黄 */
.item:nth-child(4n+2) .item-icon { background: var(--mint); }
.item:nth-child(4n+3) .item-icon { background: var(--pink); }
.item:nth-child(4n) .item-icon { background: var(--butter); }
.item-icon img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.item-del {
  border: none; background: transparent; color: var(--ink-2); font-size: 18px; padding: 8px;
}
.empty-tip { text-align: center; color: var(--ink-2); padding: 48px 20px; font-size: 14px; line-height: 1.8; }

/* ---------- 底部动作栏 ---------- */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.action-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; border: none; font-size: 12px; color: var(--ink);
}
.a-icon { font-size: 22px; }
.action-btn:active { opacity: .6; }

/* ---------- 拍照标注 ---------- */
.editor-view {
  position: fixed; inset: 0; background: #1c1917; z-index: 50; display: flex; flex-direction: column;
}
.editor-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px; color: #fff;
}
.editor-title { font-size: 14px; font-weight: 600; }
.editor-btn {
  background: rgba(255,255,255,.14); color: #fff; border: none; border-radius: 10px;
  padding: 8px 14px; font-size: 14px; text-decoration: none; display: inline-block;
}
.editor-btn.save { background: var(--brand); font-weight: 600; }
.editor-canvas-wrap { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; }
#editorCanvas { max-width: 100%; max-height: 100%; touch-action: none; }
.editor-tools { display: flex; gap: 10px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); justify-content: center; }
.tool-btn {
  background: rgba(255,255,255,.12); color: #fff; border: none; border-radius: 12px;
  padding: 11px 16px; font-size: 14px;
}
.tool-btn.active { background: var(--brand); font-weight: 600; }
.editor-hint { color: rgba(255,255,255,.55); font-size: 12px; text-align: center; padding: 0 16px 14px; line-height: 1.5; }

/* 放大镜 */
.loupe {
  position: absolute; width: 132px; height: 132px; border-radius: 50%;
  overflow: hidden; border: 2.5px solid rgba(255,255,255,.85);
  box-shadow: 0 4px 20px rgba(0,0,0,.5); pointer-events: none; z-index: 5;
}
.loupe canvas { width: 100%; height: 100%; display: block; }
.loupe-dot {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  background: #ff3b30; border-radius: 50%; border: 1.5px solid #fff;
}

/* PDF 导出按钮（深棕，参考图 TODAY 卡同款） */
.pdf-btn {
  width: 100%; padding: 12px; margin-bottom: 12px; border: none; border-radius: 12px;
  background: var(--brown); color: #fff; font-size: 15px; font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.pdf-btn:active { opacity: .85; }

/* 危险按钮 */
.btn-ghost.danger { color: var(--income); }
.btn-ghost:disabled { opacity: .4; }

/* ---------- 轻提示 toast：不阻挡操作 ---------- */
.toast {
  position: fixed; top: 16%; left: 50%; transform: translateX(-50%);
  background: rgba(69, 58, 47, .95); color: #fff;
  padding: 11px 24px; border-radius: 24px; font-size: 15px; font-weight: 600;
  z-index: 99; pointer-events: none; box-shadow: 0 4px 18px rgba(0,0,0,.25);
  opacity: 1; transition: opacity .3s;
}
.toast.out { opacity: 0; }

/* ---------- 弹层 ---------- */
.sheet-mask, .preview-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); width: 100%; border-radius: 20px 20px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}
.sheet h3 { font-size: 17px; margin-bottom: 16px; text-align: center; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg-btn {
  flex: 1; padding: 10px; border: none; background: transparent; border-radius: 8px; font-size: 15px; color: var(--ink-2);
}
.seg-btn.active[data-type="income"] { background: #fff; color: var(--income); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.seg-btn.active[data-type="expense"] { background: #fff; color: var(--expense); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.sheet input {
  width: 100%; padding: 13px 14px; margin-bottom: 12px; border: 1.5px solid var(--line);
  border-radius: 12px; font-size: 15px; background: #fbfaf8; outline: none;
}
.sheet input:focus { border-color: var(--brand); }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions .btn-primary { flex: 1; }

/* ---------- 预览 ---------- */
.preview-mask { align-items: stretch; background: rgba(15,12,10,.96); }
.preview-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px; color: #fff;
}
.preview-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.preview-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; overflow: auto; }
.preview-body img { max-width: 100%; max-height: 100%; }
.preview-fallback { color: #ddd; font-size: 14px; text-align: center; line-height: 2; }
