:root {
  --bg: #f3f5f4; --paper: #ffffff; --ink: #1b2420; --muted: #66746d; --line: #dfe5e1;
  --accent: #1f7a55; --accent-ink: #ffffff; --accent-soft: #e2f1ea;
  --me: #1f7a55; --me-ink: #ffffff; --them: #ffffff; --them-ink: #1b2420; --bot: #eef3f0;
  --warn: #a35c00; --warn-soft: #fbf0dc; --bad: #b3261e; --bad-soft: #fbe4e2; --ok: #1f7a55; --ok-soft: #e2f1ea;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101513; --paper: #171e1a; --ink: #e2ebe6; --muted: #93a39a; --line: #2a342f;
    --accent: #4cc493; --accent-ink: #0d1411; --accent-soft: #1c2e26;
    --me: #2f8f67; --me-ink: #ffffff; --them: #1e2722; --them-ink: #e2ebe6; --bot: #1a2420;
    --warn: #e7b25b; --warn-soft: #2d2415; --bad: #f08a80; --bad-soft: #351d1b; --ok: #4cc493; --ok-soft: #1c2e26;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font); -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.btn { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 7px 12px; }
.btn:hover { border-color: var(--accent); }
.btn { white-space: nowrap; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], textarea, select {
  border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- 聊天气泡（用户端和后台共用） ---------- */
.msgs { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.row { display: flex; flex-direction: column; max-width: 82%; }
.row.right { align-self: flex-end; align-items: flex-end; }
.row.left { align-self: flex-start; align-items: flex-start; }
.row.center { align-self: center; max-width: 96%; width: 96%; }
.meta { font-size: 11.5px; color: var(--muted); margin: 0 4px 2px; }
.bubble { padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow); }
.right .bubble { background: var(--me); color: var(--me-ink); border-bottom-right-radius: 4px; }
.left .bubble { background: var(--them); color: var(--them-ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.left.bot .bubble { background: var(--bot); }
.bubble.img { padding: 4px; background: var(--paper) !important; border: 1px solid var(--line); }
.bubble.img img { display: block; max-width: 220px; max-height: 280px; border-radius: 10px; cursor: zoom-in; }
.card { background: var(--paper); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.card .title, #cRes .title { font-weight: 600; margin: 6px 0 4px; }

/* ---------- 核单结果 ---------- */
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.tbl table { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 500; background: var(--bg); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl code { font-family: var(--mono); font-size: 12.5px; user-select: all; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.b-paid_notified { background: var(--ok-soft); color: var(--ok); }
.b-paid_notify_retrying { background: var(--warn-soft); color: var(--warn); }
.b-paid_notify_dead { background: var(--bad-soft); color: var(--bad); }
.b-unpaid { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* ---------- 图片查看 ---------- */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 50; }
.viewer img { max-width: 96vw; max-height: 92vh; }

/* ---------- 弹层 ---------- */
.sheet-mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--paper); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto; }
@media (min-width: 700px) { .sheet-mask { align-items: center; } .sheet { border-radius: 16px; } }
.sheet h3 { margin: 0 0 10px; font-size: 17px; }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 60; font-size: 14px; max-width: 90vw; }
