:root {
  --primary: #ff6a2c;
  --primary-soft: #fff1ea;
  --primary-dark: #e8551a;
  --text: #1f2328;
  --text-2: #5b6572;
  --text-3: #98a1ac;
  --line: #eceff3;
  --bg: #f5f6f8;
  --card: #ffffff;
  --green: #12b76a;
  --green-soft: #e9f9f1;
  --red: #f04438;
  --red-soft: #fdecea;
  --amber: #f79009;
  --amber-soft: #fff6e8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
}

* { 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: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.app { max-width: 560px; margin: 0 auto; padding: 0 14px; }

/* ---------- 顶部 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 12px;
  background: linear-gradient(180deg, var(--bg) 72%, rgba(245, 246, 248, 0));
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 15px;
}
.topbar .sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-top: 2px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card-title { font-weight: 600; font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; }
.card-title .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; border: 0; border-radius: 11px; cursor: pointer;
  font-size: 15px; font-weight: 600; padding: 12px 16px;
  background: var(--primary); color: #fff; transition: .15s;
  font-family: inherit; width: auto;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; display: block; }
.btn.ghost { background: var(--primary-soft); color: var(--primary-dark); }
.btn.gray { background: #f0f2f5; color: var(--text-2); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; display: block; font-weight: 500; }
.label .req { color: var(--red); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; padding: 11px 13px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 11px; background: #fbfcfd;
  color: var(--text); outline: none; transition: border-color .15s, background .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); background: #fff; }
.textarea { min-height: 78px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2398a1ac' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.inline { display: flex; align-items: center; gap: 10px; }
.inline .input { flex: 1; }
.unit { color: var(--text-2); font-size: 14px; white-space: nowrap; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.switch-row .label { margin: 0; font-size: 15px; color: var(--text); font-weight: 500; }
.switch-row .desc { font-size: 12px; color: var(--text-3); margin-top: 2px; font-weight: 400; }

/* 开关 */
.switch { position: relative; width: 48px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #d7dce3; border-radius: 999px;
  transition: .2s; cursor: pointer;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%; transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* ---------- 选择芯片 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 10px; background: #f2f4f7; color: var(--text-2);
  font-size: 14px; cursor: pointer; border: 1px solid transparent; transition: .15s;
}
.chip:active { transform: scale(.97); }
.chip.on { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); font-weight: 600; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 3px 9px; border-radius: 7px; font-weight: 500;
}
.tag.gray { background: #f0f2f5; color: var(--text-2); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.orange { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- 汇总数字 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stat { background: #f8f9fb; border-radius: 12px; padding: 12px 10px; text-align: center; }
.stat .num { font-size: 20px; font-weight: 700; letter-spacing: -.4px; }
.stat .num.green { color: var(--green); }
.stat .num.red { color: var(--red); }
.stat .num.primary { color: var(--primary); }
.stat .cap { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- 收款条 ---------- */
.paybar {
  margin-top: 12px; padding: 13px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #fff5f0, #fff9f5);
  border: 1px solid #ffe2d3;
}
.paybar .row { display: flex; justify-content: space-between; align-items: baseline; }
.paybar .k { font-size: 13px; color: var(--text-2); }
.paybar .v { font-size: 17px; font-weight: 700; }
.paybar .v.green { color: var(--green); }
.paybar .v.red { color: var(--red); }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 13px 0;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.item:last-child { border-bottom: 0; }
.item .idx {
  width: 26px; height: 26px; border-radius: 8px; background: #f2f4f7;
  display: grid; place-items: center; font-size: 12px; color: var(--text-2);
  font-weight: 600; flex: 0 0 auto;
}
.item .body { flex: 1; min-width: 0; }
.item .name { font-weight: 600; font-size: 15px; }
.item .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .right { text-align: right; flex: 0 0 auto; }
.item .money { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.item .money.green { color: var(--green); }
.item .money.red { color: var(--red); }

/* 列表卡片（首页） */
.act-card { cursor: pointer; }
.act-card .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.act-card .title { font-weight: 600; font-size: 16px; }
.act-card .desc { font-size: 13px; color: var(--text-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-card .foot { display: flex; gap: 14px; margin-top: 11px; font-size: 13px; color: var(--text-2); }
.act-card .foot b { color: var(--text); font-weight: 600; }

/* ---------- 空态 ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty .icon { font-size: 40px; margin-bottom: 10px; }
.empty .txt { font-size: 14px; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; background: #fff;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 86vh; overflow-y: auto; animation: up .22s ease;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-title { font-weight: 700; font-size: 17px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.sheet-title .close { color: var(--text-3); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }

/* Toast */
.toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(20, 24, 30, .9); color: #fff; padding: 11px 18px;
  border-radius: 11px; font-size: 14px; z-index: 200; max-width: 80vw;
  text-align: center; animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 底部操作条 ---------- */
.fixed-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.fixed-bar .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }
.fixed-bar .btn { flex: 1; }

/* ---------- 字段编辑器 ---------- */
.fld-row {
  display: flex; align-items: center; gap: 8px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.fld-row:last-child { border-bottom: 0; }
.fld-row .grip { color: var(--text-3); cursor: grab; font-size: 15px; }
.fld-row .fname { flex: 1; font-size: 14px; }
.fld-row .ftype { font-size: 11px; color: var(--text-3); background: #f2f4f7; padding: 2px 7px; border-radius: 6px; }
.fld-row .del { color: var(--red); font-size: 13px; cursor: pointer; padding: 4px 6px; }

/* ---------- 收款码 ---------- */
.qr-box { text-align: center; padding: 14px; background: #fbfcfd; border-radius: 12px; border: 1px dashed var(--line); }
.qr-box img { max-width: 220px; width: 100%; border-radius: 10px; }

/* ---------- 表格（对账） ---------- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 460px; }
.table th {
  text-align: left; color: var(--text-3); font-weight: 500; font-size: 12px;
  padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num-col { font-variant-numeric: tabular-nums; text-align: right; }
.table .ops { display: flex; gap: 6px; white-space: nowrap; }
.link { color: var(--primary-dark); font-size: 13px; cursor: pointer; }
.link.gray { color: var(--text-3); }
.link.red { color: var(--red); }

/* ---------- 详情头部 ---------- */
.hero { padding: 18px 16px; border-radius: var(--radius); background: linear-gradient(135deg, #fff4ee, #fffaf7); border: 1px solid #ffe4d6; margin-bottom: 12px; }
.hero h1 { font-size: 20px; margin: 0 0 6px; line-height: 1.35; }
.hero .desc { font-size: 13px; color: var(--text-2); margin-top: 8px; white-space: pre-wrap; }
.hero .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- 步骤 ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.step { flex: 1; text-align: center; font-size: 12px; color: var(--text-3); padding: 6px 4px; border-radius: 8px; background: #f2f4f7; }
.step.on { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

/* ---------- 说明块 ---------- */
.note { font-size: 12px; color: var(--text-3); line-height: 1.65; }
.note b { color: var(--text-2); }

/* ---------- 加载 ---------- */
.loading { text-align: center; padding: 40px; color: var(--text-3); font-size: 14px; }

@media (max-width: 360px) {
  .stats { gap: 6px; }
  .stat .num { font-size: 17px; }
}
