:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #1b2230;
  --muted: #5d6573;
  --faint: #8a909b;
  --line: #e3e0d8;
  --line-strong: #cfcac0;
  --accent: #14514a;
  --accent-ink: #ffffff;
  --accent-soft: #e4efec;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --err: #b42318;
  --err-soft: #fdecea;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 34, 48, .05), 0 4px 16px rgba(27, 34, 48, .04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  padding-bottom: 120px;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.top-inner, .wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.top-inner { padding-top: 22px; padding-bottom: 18px; }
.brand { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.top h1 { margin: 4px 0 2px; font-size: 24px; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
.top h1 span { display: block; font-size: 15px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.who { margin: 6px 0 0; font-size: 13px; color: var(--faint); }

.wrap { padding-top: 20px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 14px;
}
h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.3; font-weight: 650; }
h2 .en, .bi .en { display: block; font-size: 13px; font-weight: 400; color: var(--faint); }
h2 .en { font-size: 14px; margin-top: 2px; }
.step { margin: 0 0 6px; font-size: 13px; color: var(--accent); font-weight: 600; }
.intro { margin: 8px 0 0; color: var(--muted); }
.intro strong { color: var(--ink); }
.req { color: var(--err); font-weight: 600; margin-left: 3px; }

.notice { border-radius: 10px; padding: 10px 14px; font-size: 14px; margin: 0 0 14px; }
.notice.preview { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0d9ae; }
.notice.warn { background: var(--err-soft); color: var(--err); }
.notice.ok { background: var(--ok-soft); color: var(--ok); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* consent */
.summary-zh { margin: 16px 0 12px; background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; }
.summary-zh summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 15px; }
.summary-zh ul { margin: 10px 0 2px; padding-left: 20px; font-size: 14px; color: var(--ink); }
.summary-zh li { margin: 4px 0; }
.consent-text {
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 18px 10px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #333a46;
  background: #fbfaf7;
}
.consent-text h3 { font-size: 14.5px; margin: 16px 0 4px; color: var(--ink); }
.consent-text p { margin: 8px 0; }
.consent-text p.lead { font-weight: 600; color: var(--ink); }
.consent-text ul { margin: 6px 0; padding-left: 20px; }
.consent-text .foot { font-size: 12px; color: var(--faint); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 16px; }
.provider { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; margin: 14px 0 18px; }
.provider dt { color: var(--faint); }
.provider dd { margin: 0; }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check.big { padding: 14px; border: 1.5px solid var(--line-strong); border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.check.big:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check.none { margin-top: 10px; font-size: 14px; color: var(--muted); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn {
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 550;
  min-height: 44px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:not(:disabled):hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.btn.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font-weight: 500; }
.btn.link.danger { color: var(--err); }
.btn.add {
  width: 100%;
  border-style: dashed;
  color: var(--accent);
  background: transparent;
  margin-top: 8px;
}
.btn.add:not(:disabled):hover { background: var(--accent-soft); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* fields */
.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 14px; }
.w-full { grid-column: span 6; }
.w-half { grid-column: span 3; }
.w-third { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 4px; font-size: 14.5px; font-weight: 550; }
.label .bi { display: inline; }
.label .bi .en { display: inline; margin-left: 6px; font-size: 12px; }
.pre { font-style: normal; font-size: 11.5px; font-weight: 500; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.hint { font-size: 12.5px; color: var(--faint); }
input[type=text], input[type=email], input[type=tel], input[type=date], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 46px;
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
textarea { min-height: 84px; resize: vertical; }
.money { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; min-height: 46px; }
.money:focus-within { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.money input { border: 0 !important; outline: none !important; padding-left: 4px; min-width: 0; }
.money .cur { padding-left: 12px; color: var(--faint); }
.money .per { padding-right: 12px; color: var(--faint); font-size: 14px; white-space: nowrap; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span {
  display: flex; flex-direction: column; justify-content: center;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 14px; min-height: 46px; cursor: pointer; font-size: 15px;
}
.seg-opt span small { color: var(--faint); font-size: 11.5px; }
.seg-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg-opt input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.sub { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 650; font-size: 15px; display: flex; flex-direction: column; gap: 2px; }
.sub .hint { font-weight: 400; }

.err input, .err select, .err textarea, .err .money, .err .seg-opt span { border-color: var(--err); background-color: var(--err-soft); }
.err .label { color: var(--err); }
.list.err .list-head { color: var(--err); }

/* sections */
.sec { padding: 0; overflow: hidden; }
.sec-head {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.sec-no {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 650;
  background: var(--accent-soft); color: var(--accent);
}
.sec-title .zh { font-weight: 650; font-size: 17px; }
.sec-meta { display: flex; align-items: center; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.total { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.total small { font-size: 11px; color: var(--faint); }
.total strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.chip { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.chip.todo { background: var(--warn-soft); color: var(--warn); }
.chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.opt { background: #eef0f3; color: var(--muted); }
.chev { width: 10px; height: 10px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(45deg); margin: -4px 4px 0 2px; transition: transform .15s; }
.open > .sec-head .chev, .open > .item-head .chev, .open > .group-head .chev { transform: rotate(-135deg); margin-top: 4px; }
.sec-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.note { margin: 12px 0 14px; font-size: 14px; color: var(--muted); }
.sec-body > .grid { margin-top: 14px; }
.sec-foot { display: flex; justify-content: flex-end; margin-top: 18px; }

/* repeatable items */
.list { margin-top: 6px; }
.list-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; font-weight: 650; font-size: 15px; }
.list-head .hint { font-weight: 400; }
.item { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fbfaf7; }
.item.open { background: #fff; border-color: var(--line-strong); }
.item-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 0; background: none; cursor: pointer; text-align: left; min-height: 48px;
}
.item-no { width: 22px; height: 22px; border-radius: 6px; background: #eceae4; display: grid; place-items: center; font-size: 12px; font-weight: 650; flex: none; }
.item-sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.item-body { padding: 4px 12px 14px; }
.item-actions { display: flex; justify-content: space-between; align-items: center; }

/* expense groups */
.groups { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.group { border: 1px solid var(--line); border-radius: 12px; }
.group-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 0; background: none; cursor: pointer; text-align: left; }
.group-head .bi { flex: 1; }
.group-head .zh { font-weight: 600; }
.sub-total { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.group > .grid { padding: 4px 14px 14px; }

/* submit bar */
.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 12px max(16px, calc((100vw - 760px) / 2 + 16px)) calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.progress { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.p-bar { height: 6px; border-radius: 99px; background: #eceae4; overflow: hidden; }
.p-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.fine { text-align: center; font-size: 13px; color: var(--faint); margin: 18px 0; }

/* done */
.done h2 { margin-top: 6px; }
.tick { width: 48px; height: 48px; border-radius: 50%; background: var(--ok-soft); position: relative; }
.tick::after { content: ""; position: absolute; left: 17px; top: 11px; width: 11px; height: 20px; border-right: 3px solid var(--ok); border-bottom: 3px solid var(--ok); transform: rotate(45deg); }
.email-line { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 18px; font-weight: 600; }
.email-line a { color: var(--accent); }
.docs { padding-left: 22px; margin: 16px 0; }
.docs li { margin: 10px 0; }
.docs small { display: block; color: var(--faint); font-size: 12.5px; }
.center { text-align: center; }
.center .contact { font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .card:not(.sec) { padding: 18px 16px; }
  .w-half, .w-third { grid-column: span 6; }
  .sec-head { grid-template-columns: auto 1fr auto; padding: 14px 14px; gap: 10px; }
  .sec-meta { grid-column: 2 / 3; grid-row: 2; justify-content: flex-start; flex-direction: row-reverse; justify-content: flex-end; gap: 12px; }
  .total { flex-direction: row; align-items: baseline; gap: 6px; }
  .sec-head .chev { grid-column: 3; grid-row: 1; }
  .sec-body { padding: 4px 14px 16px; }
  .top h1 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
