* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --blue: #2563eb;
  --blue-d: #1d4ed8;
  --red: #e02b2b;
  --ink: #16202e;
  --ink2: #5a6b80;
  --line: #e3e8ef;
  --bg: #f2f5f9;
  --card: #fff;
  --radius: 14px;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--blue); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 16px; }
input[type=date] { -webkit-appearance: none; appearance: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar .ttl { flex: 1; font-size: 17px; font-weight: 600; text-align: center; }
.topbar .ibtn {
  min-width: 44px; height: 36px; border: 0; background: transparent; color: var(--ink);
  font-size: 15px; border-radius: 10px; padding: 0 8px;
}
.topbar .ibtn:active { background: #eef2f8; }

/* ---------- 页面 ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 12px 12px 110px; }
.page { padding: 12px 12px 110px; max-width: 720px; margin: 0 auto; }

/* ---------- 列表 ---------- */
.searchbar { margin-bottom: 10px; }
.searchbar input {
  width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; outline: none;
}
.card {
  display: block; background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(20,40,80,.06);
  color: inherit;
}
.card:active { background: #f7f9fc; }
.card .r1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .no { font-size: 13px; color: var(--ink2); letter-spacing: .3px; }
.card .amt { font-size: 17px; font-weight: 700; color: var(--red); white-space: nowrap; }
.card .cust { font-size: 16px; font-weight: 600; margin: 6px 0 4px; }
.card .r3 { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink2); }
.empty { text-align: center; color: var(--ink2); padding: 60px 20px; font-size: 15px; }

/* ---------- 列表左滑删除 ---------- */
.swipe {
  position: relative; overflow: hidden; margin-bottom: 10px;
  border-radius: var(--radius); touch-action: pan-y;
}
.swipe .card { margin-bottom: 0; position: relative; z-index: 1; will-change: transform; }
.swipe .card.slide { transition: transform .2s ease; }
.swipe .sw-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 84px; z-index: 0;
  border: 0; background: var(--red); color: #fff; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.swipe .sw-del:active { background: #c42020; }

/* ---------- 底部按钮条 ---------- */
.fabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, #fff 70%, rgba(255,255,255,.85));
  border-top: 1px solid var(--line);
  display: flex; gap: 10px;
  max-width: 720px; margin: 0 auto;
}
.fabbar .inner { max-width: 720px; margin: 0 auto; width: 100%; display: flex; gap: 10px; }
.btn {
  flex: 1; height: 50px; border: 0; border-radius: 12px; font-size: 16px; font-weight: 600;
  background: #eef2f8; color: var(--ink); display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 0 12px;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-d); }
.btn.danger { background: #fdeaea; color: var(--red); }
.btn[disabled] { opacity: .5; }
.btn.ghost { background: #fff; border: 1px solid var(--line); }

/* ---------- 表单 ---------- */
.fld { background: var(--card); border-radius: var(--radius); padding: 4px 14px; margin-bottom: 12px; }
.fld > .lab { font-size: 13px; color: var(--ink2); padding: 10px 0 2px; }
.fld > input, .fld > select, .fld > textarea {
  width: 100%; border: 0; outline: none; padding: 9px 0 12px; background: transparent;
  font-size: 16px;
}
.fld.one { padding: 12px 14px; }
.row2 { display: flex; gap: 12px; }
.row2 > * { flex: 1; min-width: 0; }
.sect-title { font-size: 14px; font-weight: 600; color: var(--ink2); margin: 18px 4px 8px; display: flex; justify-content: space-between; align-items: center; }
.sect-title .add { color: var(--blue); font-weight: 600; font-size: 14px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 8px 14px; font-size: 14px; color: var(--ink);
}
.chip:active { background: #eef2f8; }

/* ---------- 明细行 ---------- */
.item {
  background: var(--card); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden;
}
.item .hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px 0; font-size: 13px; color: var(--ink2);
}
.item .hd .del { color: var(--red); font-size: 14px; background: none; border: 0; padding: 4px 0; }
.item .bd { padding: 0 14px 12px; }
.item label { display: block; font-size: 13px; color: var(--ink2); margin-top: 8px; }
.item input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 8px 0;
  outline: none; background: transparent; font-size: 16px;
}
.item .amt { text-align: right; font-size: 15px; color: var(--ink2); padding-top: 8px; }
.item .amt b { color: var(--red); font-size: 17px; }

/* ---------- 合计条 ---------- */
.totalbar {
  background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.totalbar .t1 { font-size: 13px; color: var(--ink2); }
.totalbar .t2 { font-size: 20px; font-weight: 700; color: var(--red); }
.cn { font-size: 13px; color: var(--ink2); margin-top: 2px; }

/* ---------- 客户自动补全 ---------- */
.custwrap { position: relative; overflow: visible; }
.sug {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(20,40,80,.16); max-height: 300px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sug-item { padding: 11px 14px; border-bottom: 1px solid #f0f3f7; cursor: pointer; }
.sug-item:last-child { border-bottom: 0; }
.sug-item:active { background: #eef3fb; }
.sug-name { font-size: 15px; font-weight: 600; }
.sug-sub { font-size: 12px; color: var(--ink2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 发票预览 ---------- */
.paper {
  background: #fff; border-radius: 8px; padding: 20px 16px 16px; box-shadow: 0 1px 3px rgba(20,40,80,.08);
  font-size: 13px; color: #1a2331; overflow-x: auto;
}
.paper .co-name { text-align: center; font-size: 19px; font-weight: 700; letter-spacing: 1px; }
.paper .co-line { text-align: center; font-size: 12px; color: #5c6678; }
.paper .co-rule { height: 4px; border-top: 1.5px solid #8a94a6; border-bottom: 1px solid #ccd5e0; margin: 6px 0 10px; }
.paper .doc-title {
  text-align: center; font-size: 18px; font-weight: 700; letter-spacing: 6px;
  margin: 6px 0 10px; padding-bottom: 6px; position: relative; text-indent: 6px;
}
.paper .doc-title::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 150px; height: 2px; background: #1a2331; border-radius: 2px;
}
.paper .meta { display: flex; gap: 8px; margin-bottom: 10px; }
.paper .meta-l { flex: 1 1 62%; min-width: 0; }
.paper .meta-r { flex: 1 1 38%; min-width: 0; }
.paper .meta div { line-height: 1.75; word-break: break-all; }
.paper table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.paper th, .paper td { border: 1px solid #7d8798; height: 27px; padding: 1px 5px; font-size: 12px; }
.paper th { font-weight: 700; text-align: center; background: #e8eef6; }
.paper td.c { text-align: center; }
.paper tr.sum td { background: #f9fbfd; font-weight: 700; }
.paper .total-line { font-weight: 700; }
.paper .note-line { color: #5c6678; }
.paper .line { margin-top: 6px; line-height: 1.75; }
.paper .pay-title {
  text-align: center; font-size: 17px; font-weight: 700; letter-spacing: 4px;
  margin: 16px 0 8px; text-indent: 4px;
}
.paper .pay-box {
  background: #f9fbfd; border: 1px solid #d6dfea; border-radius: 4px;
  padding: 9px 14px; line-height: 2;
}
.paper .paper-foot {
  text-align: center; color: #96a0b0; font-size: 11px;
  margin-top: 14px; padding-top: 7px; border-top: 1px solid #e6ebf2;
}

.mv-preview { margin-bottom: 12px; }

/* ---------- 登录 ---------- */
.login-wrap { max-width: 380px; margin: 0 auto; padding: 18vh 22px 0; }
.login-wrap h1 { font-size: 22px; text-align: center; margin: 0 0 6px; }
.login-wrap p.sub { text-align: center; color: var(--ink2); font-size: 14px; margin: 0 0 24px; }
.login-wrap input {
  width: 100%; height: 50px; border: 1px solid var(--line); border-radius: 12px;
  padding: 0 14px; outline: none; background: #fff;
}
.login-wrap .btn { width: 100%; margin-top: 14px; height: 50px; }
/* 用 CSS 遮蔽代替 type=password：浏览器不会识别成密码框，就不会弹「保存密码」 */
.masked { -webkit-text-security: disc; }

/* ---------- 其它 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: rgba(22,32,46,.92); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 14px; z-index: 200; max-width: 80vw; text-align: center;
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }
.mask {
  position: fixed; inset: 0; background: rgba(10,18,30,.45); z-index: 150;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.dialog { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 340px; }
.dialog h3 { margin: 0 0 10px; font-size: 17px; }
.dialog .acts { display: flex; gap: 10px; margin-top: 18px; }
.loading { text-align: center; color: var(--ink2); padding: 40px; }
.linkline { font-size: 13px; color: var(--blue); word-break: break-all; margin-top: 6px; }
.hint { font-size: 12px; color: var(--ink2); padding: 0 2px 8px; }
