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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #f2f3f7;
  color: #1f2330;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
#appInner { max-width: 480px; margin: 0 auto; position: relative; }

.topbar {
  background: linear-gradient(135deg, #6a5af9, #8f6ed5);
  color: #fff;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  letter-spacing: 1px;
  position: relative;
}
.lock-btn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.2); border: none; color: #fff; font-size: 16px; border-radius: 8px; padding: 2px 8px; }

/* 模糊锁屏：未登录时整个应用内容模糊，并覆盖密码框 */
body.locked { overflow: hidden; }
body.locked #appInner,
body.locked .topbar { filter: blur(10px); -webkit-filter: blur(10px); pointer-events: none; user-select: none; }
.lock-screen { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; display: none; align-items: center; justify-content: center; background: rgba(20, 22, 35, 0.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 9999; padding: 24px; }
.lock-screen.show { display: flex; }
.lock-box { background: #fff; border-radius: 18px; padding: 24px 20px; width: 100%; max-width: 320px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3); }
.lock-title { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.lock-sub { font-size: 13px; color: #8a8f9c; margin-bottom: 18px; }
.lock-err { color: #e8543f; font-size: 13px; min-height: 18px; margin: 8px 0; }

.summary {
  margin: 12px;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  background: linear-gradient(135deg, #6a5af9 0%, #4a76e2 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(106, 90, 249, 0.25);
}
.sum-label { font-size: 13px; opacity: 0.9; margin-bottom: 6px; }
.sum-value { font-size: 22px; font-weight: 700; }
.sum-value.debt { color: #ffd84d; }
.sum-value.recv { color: #6ff0a0; }

.block { margin: 12px; }
.block-title { font-size: 15px; font-weight: 600; margin: 6px 2px 10px; display: flex; align-items: center; gap: 6px; }
.plus { color: #6a5af9; font-weight: 700; }
.book { font-size: 16px; }

.form { background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); }
.type-toggle { display: flex; gap: 8px; margin-bottom: 12px; }
.type-btn { flex: 1; padding: 10px; border: 1px solid #e2e4ec; border-radius: 10px; background: #f7f8fc; color: #6b7080; font-size: 14px; }
.type-btn.active { background: #6a5af9; color: #fff; border-color: #6a5af9; }

.field {
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid #e2e4ec;
  border-radius: 10px;
  font-size: 15px;
  background: #fafbfe;
}
.field:focus { outline: none; border-color: #6a5af9; }

.btn-primary { width: 100%; padding: 13px; border: none; border-radius: 10px; background: #4a76e2; color: #fff; font-size: 16px; font-weight: 600; }
.btn-primary:active { background: #3a64c8; }

.list { display: flex; flex-direction: column; gap: 12px; }
.card { background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); }
.card-title { font-size: 17px; font-weight: 700; }
.card-name { font-size: 14px; color: #4a4e5a; margin-top: 4px; word-break: break-all; }
.card-note { font-size: 13px; color: #8a8f9c; margin: 4px 0 8px; word-break: break-all; }
.card-remain { font-size: 14px; color: #e8543f; font-weight: 600; margin-bottom: 12px; }
.card-actions { display: flex; gap: 8px; }
.card-actions .btn { flex: 1; padding: 9px 0; border: none; border-radius: 9px; font-size: 14px; font-weight: 600; color: #fff; }
.btn.green { background: #2bb673; }
.btn.blue { background: #4a90e2; }
.btn.red { background: #e8543f; }

.empty { text-align: center; color: #9aa0ad; padding: 40px 0; font-size: 14px; }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal.show { display: flex; }
.modal-box { background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 360px; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; text-align: center; }
.modal-sub { font-size: 13px; color: #8a8f9c; text-align: center; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .btn-primary, .modal-actions .btn-ghost { flex: 1; }
.btn-ghost { width: 100%; padding: 13px; border: 1px solid #e2e4ec; border-radius: 10px; background: #fff; color: #6b7080; font-size: 15px; }

.history-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.history-item { border: 1px solid #eef0f5; border-radius: 10px; padding: 10px; font-size: 13px; }
.history-item .h-amt { font-weight: 700; color: #2bb673; }
.history-item .h-meta { color: #8a8f9c; margin-top: 4px; word-break: break-all; }
.history-empty { text-align: center; color: #9aa0ad; padding: 20px 0; }
