:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1c2333; --mute: #6b7488; --line: #e4e7ee;
  --accent: #2063ce; --accent-2: #3a7be0; --danger: #c0392b;
  --st-pay-bg: #fdf0c7; --st-pay: #8a6500;
  --st-proof-bg: #ffe2cc; --st-proof: #a14a00;
  --st-submit-bg: #dbe7ff; --st-submit: #1f4fb8;
  --st-recv-bg: #ffdce3; --st-recv: #b0264a;
  --st-done-bg: #d5f2de; --st-done: #1e7a3d;
  --st-skip-bg: #e8eaef; --st-skip: #5c6475;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 38px; height: 38px; border-radius: 9px; display: block; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: .5px; }
.brand p { margin: 1px 0 0; color: var(--mute); font-size: 12px; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 14px; cursor: pointer; transition: .12s; }
.btn:hover { border-color: #c5cbd9; background: #fafbfd; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #efc9c4; }
.btn.small { padding: 3px 10px; font-size: 12px; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 110%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px #1c23331f; min-width: 200px; overflow: hidden; z-index: 30; }
.menu-pop a, .menu-pop label, .menu-pop button { display: block; padding: 10px 14px; color: var(--ink); text-decoration: none; cursor: pointer; }
.menu-pop button { width: 100%; text-align: left; border: 0; background: none; border-top: 1px solid var(--line); color: var(--mute); }
.menu-pop a:hover, .menu-pop label:hover, .menu-pop button:hover { background: var(--bg); }

main { padding: 18px 24px 60px; max-width: 1500px; margin: 0 auto; }

/* 汇总卡片 */
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; text-align: left; transition: .12s; position: relative; overflow: hidden; }
.card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px #1c23331a; }
.card.active { outline: 2px solid var(--accent-2); }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.card .lab { display: flex; justify-content: space-between; font-size: 12px; color: var(--mute); }
.card .big { font-size: 20px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.card.recv { --c: var(--st-recv); background: linear-gradient(180deg, #fff, #fff6f8); }
.card.recv .big { color: var(--st-recv); font-size: 23px; }

/* 工具条 */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs { display: flex; background: #e9ecf3; border-radius: 9px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--mute); }
.tabs button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px #1c23331a; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 10px; }
.filters input { width: 220px; }
.chip-btn { border: 1px solid #f0c9a8; background: #fff4e8; color: #a14a00; border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.chip-btn.on { background: #a14a00; color: #fff; }

/* 表格 */
.grid-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 290px); min-height: 200px; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1180px; }
.grid th { position: sticky; top: 0; background: #f7f8fb; text-align: left; font-weight: 600; font-size: 12px; color: var(--mute); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 2; }
.grid td { padding: 8px 10px; border-bottom: 1px solid #eef0f5; vertical-align: middle; white-space: nowrap; }
.grid td.num, .grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.text { white-space: normal; min-width: 220px; max-width: 360px; font-weight: 500; }
.grid tbody tr.row { cursor: pointer; }
.grid tbody tr.row:hover td { background: #f6f8ff; }
.grid tr.unrev td { background: #fffaf2; }
.grid td.mute { color: var(--mute); }
.grid .bal { color: var(--st-recv); font-weight: 600; }
.grid tr.grp td { background: #f2f4f9; font-weight: 600; border-top: 1px solid var(--line); cursor: pointer; }
.grid tr.grp td.num { font-size: 12px; color: var(--ink); }
.grid tr.grp .twist { display: inline-block; width: 14px; color: var(--mute); transition: .12s; }
.grid tr.grp.closed .twist { transform: rotate(-90deg); }
.grid tfoot td { position: sticky; bottom: 0; background: #f7f8fb; font-weight: 600; border-top: 1px solid var(--line); }
.cnt { color: var(--mute); font-weight: 400; margin-left: 8px; font-size: 12px; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; border: 0; }
select.pill { appearance: none; cursor: pointer; padding-right: 10px; text-align: center; }
.st-pay { background: var(--st-pay-bg); color: var(--st-pay); }
.st-proof { background: var(--st-proof-bg); color: var(--st-proof); }
.st-submit { background: var(--st-submit-bg); color: var(--st-submit); }
.st-recv { background: var(--st-recv-bg); color: var(--st-recv); }
.st-done { background: var(--st-done-bg); color: var(--st-done); }
.st-skip { background: var(--st-skip-bg); color: var(--st-skip); }
.tag { display: inline-block; background: #eceffd; color: #3a4aa8; border-radius: 6px; padding: 1px 7px; margin-right: 4px; font-size: 12px; }
.cat { display: inline-block; background: #e6f0fb; color: #25598f; border-radius: 6px; padding: 1px 8px; font-size: 12px; }
.badge-ai { display: inline-block; background: #a14a00; color: #fff; border-radius: 4px; padding: 0 5px; font-size: 10px; font-weight: 700; margin-right: 6px; vertical-align: 1px; }
.thumbs { display: flex; gap: 3px; align-items: center; }
.thumbs img, .thumbs .pdf { width: 30px; height: 30px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); background: #fff; }
.thumbs .pdf { display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #b0264a; background: #fff0f3; }
.thumbs .more { font-size: 11px; color: var(--mute); }
.empty { text-align: center; color: var(--mute); padding: 60px 20px; }

/* 弹窗 */
dialog { border: 0; border-radius: 14px; padding: 0; box-shadow: 0 20px 60px #1c233340; color: var(--ink); max-width: 94vw; }
dialog::backdrop { background: #1c23338c; backdrop-filter: blur(2px); }
#editor { width: 680px; }
.ed-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px 8px; }
.ed-head h2 { margin: 0; font-size: 17px; }
.x { border: 0; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: var(--mute); }
.banner { margin: 4px 22px 0; background: #fff4e8; border: 1px solid #f0c9a8; color: #8a4300; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.ed-body { padding: 10px 22px 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; max-height: 68vh; overflow: auto; }
.ed-body label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--mute); }
.ed-body input, .ed-body select, .ed-body textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; color: var(--ink); background: #fff; }
.ed-body input:focus, .ed-body select:focus, .ed-body textarea:focus { outline: 2px solid #2f55d455; border-color: var(--accent-2); }
.full { grid-column: 1 / -1; }
fieldset.money { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
fieldset.money legend { font-size: 12px; color: var(--mute); padding: 0 6px; }
.calc { grid-column: 1 / -1; display: flex; gap: 12px; }
.calc div { flex: 1; background: #f5f7fc; border-radius: 8px; padding: 8px 12px; display: flex; justify-content: space-between; align-items: baseline; }
.calc span { font-size: 12px; color: var(--mute); }
.calc b { font-variant-numeric: tabular-nums; }
.att-head { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--mute); margin-bottom: 6px; }
.atts { display: flex; flex-wrap: wrap; gap: 10px; }
.att { position: relative; width: 92px; height: 92px; border-radius: 8px; border: 1px solid var(--line); overflow: hidden; cursor: zoom-in; background: #fafbfd; }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att .pdf { height: 100%; display: grid; place-items: center; font-weight: 700; color: #b0264a; }
.att button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #1c2333c0; color: #fff; cursor: pointer; line-height: 1; }
.hint { color: var(--mute); font-size: 12px; margin: 6px 0 0; }
.ed-foot { display: flex; gap: 8px; align-items: center; padding: 12px 22px 18px; }
.grow { flex: 1; }

#lightbox { background: transparent; box-shadow: none; max-width: 96vw; }
#lightbox .x { position: fixed; top: 14px; right: 22px; color: #fff; font-size: 34px; z-index: 5; }
#lbBody img { max-width: 92vw; max-height: 90vh; border-radius: 8px; display: block; }
#lbBody iframe { width: 80vw; height: 88vh; border: 0; background: #fff; border-radius: 8px; }
#help { width: 560px; }
.help-body { padding: 4px 22px 22px; line-height: 1.7; }
.help-body ol { padding-left: 20px; }
.help-body code { background: #eef0f6; border-radius: 4px; padding: 1px 5px; }

.drop-overlay { position: fixed; inset: 0; z-index: 99; background: #1f3a8ad9; color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 600; border: 4px dashed #fff8; margin: 12px; border-radius: 18px; pointer-events: none; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1c2333; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 120; box-shadow: 0 8px 24px #0004; }

@media (max-width: 980px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .top { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  main { padding: 12px; }
  .ed-body { grid-template-columns: 1fr; }
  fieldset.money { grid-template-columns: 1fr 1fr; }
}
