:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --in: #059669;
  --out: #dc2626;
  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

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

html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.5;
}

button, input, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; }

/* ---------- 布局 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: #111827; color: #fff;
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.topbar .brand { font-size: 17px; font-weight: 700; flex: 1; }
.topbar .who { font-size: 13px; opacity: .85; display: flex; align-items: center; gap: 8px; }
.topbar .who button { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 8px; padding: 3px 10px; font-size: 13px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 14px 96px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; padding: 10px 4px 8px; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar button .ico { font-size: 19px; line-height: 1; }
.tabbar button.on { color: var(--brand); font-weight: 700; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 62px; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 14px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--out); }
.btn.block { width: 100%; }
.btn.big { padding: 14px; font-size: 17px; font-weight: 700; }
.btn:active { opacity: .85; }

/* ---------- 记一笔 ---------- */
.kindswitch { display: flex; gap: 10px; margin-bottom: 12px; }
.kindswitch button { flex: 1; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 16px; }
.kindswitch button.on-in { border-color: var(--in); background: #ecfdf5; color: var(--in); }
.kindswitch button.on-out { border-color: var(--out); background: #fef2f2; color: var(--out); }

.amountbox input { font-size: 30px; font-weight: 700; padding: 12px; letter-spacing: .5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 14px; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photos .ph { position: relative; width: 78px; height: 78px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph button { position: absolute; right: 2px; top: 2px; border: 0; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; line-height: 1; padding: 0; }
.photos .add { width: 78px; height: 78px; border: 1px dashed var(--line); border-radius: 10px; background: #fff; font-size: 26px; color: var(--muted); }

/* ---------- 流水 ---------- */
.filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.filters .full { grid-column: 1 / -1; }
.list { display: grid; grid-template-columns: 1fr; gap: 10px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.item .head { display: flex; align-items: baseline; gap: 8px; }
.item .amt { font-size: 19px; font-weight: 700; }
.item .amt.in { color: var(--in); }
.item .amt.out { color: var(--out); }
.item .tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: var(--muted); }
.item .meta { font-size: 13px; color: var(--muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.item .remark { font-size: 14px; margin-top: 6px; white-space: pre-wrap; word-break: break-all; }
.item .mini { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.item .mini img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.item .ops { margin-top: 8px; display: flex; gap: 8px; justify-content: flex-end; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }

/* ---------- 汇总 ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; box-shadow: var(--shadow); }
.kpi .v { font-size: 20px; font-weight: 800; margin-top: 2px; word-break: break-all; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v.in { color: var(--in); } .kpi .v.out { color: var(--out); }
.chartbox { width: 100%; overflow-x: auto; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; vertical-align: middle; margin-right: 4px; }
.catbar { margin-bottom: 8px; }
.catbar .t { display: flex; justify-content: space-between; font-size: 13px; }
.catbar .bar { height: 8px; background: #f3f4f6; border-radius: 999px; overflow: hidden; margin-top: 3px; }
.catbar .bar > i { display: block; height: 100%; }

.accts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.acct { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.acct .v { font-size: 18px; font-weight: 700; }

/* ---------- 管理 ---------- */
table.tb { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tb th, table.tb td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
table.tb th { color: var(--muted); font-weight: 600; }
.subtabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- 登录 ---------- */
.login { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.login .logo { text-align: center; font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.login .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(17,24,39,.92); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; }

/* 改密码弹窗 */
.modal-ov { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-ov .modal { width: 100%; max-width: 360px; margin: 0; }

.tip { background: var(--brand-soft); border: 1px solid #bfdbfe; color: #1e40af; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }

@media (min-width: 720px) {
  .list { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .accts { grid-template-columns: repeat(4, 1fr); }
  .wrap { padding-bottom: 24px; }
  .tabbar { position: sticky; top: 52px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); max-width: 1100px; margin: 0 auto; }
  .tabbar button { flex-direction: row; gap: 6px; font-size: 14px; padding: 12px 6px; }
}
