:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #fff;
  --line: #e4e7ec;
  --line2: #eef0f3;
  --text: #1d2433;
  --sub: #667085;
  --muted: #98a2b3;
  --brand: #e8590c;
  --brand-d: #c2410c;
  --brand-l: #fff4ec;
  --blue: #2563eb;
  --blue-l: #eff4ff;
  --green: #15803d;
  --green-l: #ecfdf3;
  --red: #dc2626;
  --red-l: #fef2f2;
  --amber: #b45309;
  --amber-l: #fffbeb;
  --gray-l: #f2f4f7;
  --side: #1b2130;
  --r: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
[v-cloak] { display: none; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.side {
  width: 208px; flex-shrink: 0; background: var(--side); color: #c9cfdb;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.side .logo { padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.side .logo small { display: block; font-weight: 400; color: #8b93a7; font-size: 12px; margin-top: 2px; letter-spacing: 0; }
.side .group { padding: 14px 18px 4px; font-size: 12px; color: #6b7389; }
.side a.item {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 18px; color: #c9cfdb;
  border-left: 3px solid transparent; text-decoration: none;
}
.side a.item:hover { background: rgba(255,255,255,.04); color: #fff; }
.side a.item.on { background: rgba(232,89,12,.14); color: #fff; border-left-color: var(--brand); }
.side .badge { background: var(--brand); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; line-height: 18px; min-width: 18px; text-align: center; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center;
  padding: 0 20px; gap: 12px; position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 600; font-size: 16px; flex: 1; }
.topbar .me { color: var(--sub); font-size: 13px; display: flex; gap: 12px; align-items: center; }
.menu-btn { display: none; background: none; border: 0; font-size: 22px; padding: 0 4px; cursor: pointer; color: var(--text); }
.refresh-app-btn { display: none; width: 32px; height: 32px; padding: 0; justify-content: center; font-size: 20px; line-height: 1; }
.content { padding: 18px 20px 40px; }

/* ---------- 卡片 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 16px; }
.card-h { padding: 12px 16px; border-bottom: 1px solid var(--line2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h3 { font-size: 15px; flex: 1; }
.card-b { padding: 14px 16px; }
.card-b.p0 { padding: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .k { color: var(--sub); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 400; color: var(--sub); margin-left: 2px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.warn { border-color: #fcd9bd; background: var(--brand-l); }
.stat.click { cursor: pointer; }
.stat.click:hover { border-color: var(--brand); }

.todo { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.todo a { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); text-decoration: none; }
.todo a:hover { border-color: var(--brand); background: var(--brand-l); }
.todo a b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.todo a span { color: var(--sub); font-size: 12px; }
.todo a.hot b { color: var(--brand); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line2); text-align: left; white-space: nowrap; vertical-align: middle; }
.tbl th { background: #f9fafb; color: var(--sub); font-weight: 500; position: sticky; top: 0; z-index: 1; }
.tbl tr:hover td { background: #fcfcfd; }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.c, .tbl th.c { text-align: center; }
.tbl td.wrap { white-space: normal; min-width: 160px; }
.tbl tfoot td { background: #f9fafb; font-weight: 600; }
.tbl tr.click { cursor: pointer; }
.tbl .sub { color: var(--muted); font-size: 12px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- 标签 ---------- */
.tag { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 12px; line-height: 20px; background: var(--gray-l); color: var(--sub); white-space: nowrap; }
.tag.blue { background: var(--blue-l); color: var(--blue); }
.tag.green { background: var(--green-l); color: var(--green); }
.tag.red { background: var(--red-l); color: var(--red); }
.tag.amber { background: var(--amber-l); color: var(--amber); }
.tag.brand { background: var(--brand-l); color: var(--brand-d); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--muted); }
.sub { color: var(--sub); }

/* ---------- 表单 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap; line-height: 20px; font-family: inherit;
}
.btn:hover { border-color: #c7ccd6; background: #fafafa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); border-color: #f5c2c2; }
.btn.danger:hover { background: var(--red-l); }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn.link { border: 0; background: none; color: var(--blue); padding: 2px 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  font: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid #d0d5dd; border-radius: 6px; background: #fff; color: var(--text);
  min-width: 0; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(232,89,12,.12); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input:disabled, select:disabled, textarea:disabled { background: #f9fafb; color: var(--sub); }
textarea { resize: vertical; min-height: 60px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line2); }
.filters > * { width: auto; }
.filters input, .filters select { width: 140px; }
.filters input.wide { width: 220px; }

.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form .f { display: flex; flex-direction: column; gap: 4px; }
.form .f.full { grid-column: 1 / -1; }
.form .f.half { grid-column: span 2; }
.form label.l { font-size: 12px; color: var(--sub); }
.form label.l .req { color: var(--red); }
.form .hint { font-size: 12px; color: var(--muted); }
.radios { display: flex; flex-wrap: wrap; gap: 6px; }
.radios label {
  border: 1px solid #d0d5dd; border-radius: 6px; padding: 5px 12px; cursor: pointer; font-size: 13px; user-select: none; background: #fff;
}
.radios label.on { border-color: var(--brand); background: var(--brand-l); color: var(--brand-d); }
.radios input { display: none; }
.section-t { grid-column: 1 / -1; font-weight: 600; font-size: 13px; padding-top: 8px; border-top: 1px dashed var(--line); margin-top: 4px; display: flex; gap: 10px; align-items: center; }
.section-t:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.section-t .sub { font-weight: 400; font-size: 12px; }
.calc-box { grid-column: 1 / -1; background: #f9fafb; border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; }
.calc-box b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------- 弹窗 ---------- */
body:has(.modal-mask) { overflow: hidden; }
.modal-mask { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 20px 40px rgba(0,0,0,.18); }
.modal.lg { max-width: 920px; }
.modal.xl { max-width: 1100px; }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line2); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { flex: 1; font-size: 16px; }
.modal-h .x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-b { padding: 16px 18px; max-height: calc(100vh - 200px); overflow-y: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line2); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 详情 ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 20px; }
.kv > div { display: flex; gap: 8px; font-size: 13px; }
.kv > div > span:first-child { color: var(--sub); flex-shrink: 0; width: 84px; }
.kv-t { font-weight: 600; margin: 14px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line2); }
.kv-t:first-child { margin-top: 0; }
.slip { width: 100%; border-collapse: collapse; }
.slip td { padding: 7px 10px; border-bottom: 1px solid var(--line2); }
.slip td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.slip tr.total td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--text); }
.slip tr.minus td:last-child { color: var(--red); }
.slip td .sub { font-size: 12px; }
.warnings { background: var(--amber-l); border: 1px solid #fde68a; border-radius: 6px; padding: 8px 12px; color: var(--amber); font-size: 13px; margin-bottom: 12px; }
.warnings div + div { margin-top: 4px; }
.note { background: var(--blue-l); border-radius: 6px; padding: 8px 12px; color: #1e40af; font-size: 13px; margin-bottom: 12px; }
.logs { font-size: 12px; color: var(--sub); }
.logs div { padding: 4px 0; border-bottom: 1px dashed var(--line2); }
.progress { height: 6px; background: var(--gray-l); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--brand); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--sub); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; white-space: nowrap; }
.tabs a.on { color: var(--brand-d); border-bottom-color: var(--brand); font-weight: 600; }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 16px; color: var(--sub); font-size: 13px; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.bars .b { flex: 1; background: #fcd9bd; border-radius: 2px 2px 0 0; position: relative; min-height: 2px; }
.bars .b:hover { background: var(--brand); }
.bars .b span { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; margin-bottom: 4px; z-index: 2; }
.bars .b:hover span { display: block; }
.bars-x { display: flex; gap: 3px; font-size: 10px; color: var(--muted); }
.bars-x span { flex: 1; text-align: center; }

/* ---------- 采购代付 ---------- */
.pay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.pay-card { margin: 0; }
.pay-top { display: flex; gap: 14px; }
.pay-top .qr { width: 120px; height: 120px; border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in; flex-shrink: 0; background: #fff; }
.pay-top .empty-qr { display: flex; align-items: center; justify-content: center; color: var(--muted); cursor: default; }
.pay-top .amt { font-size: 22px; font-weight: 700; color: var(--brand-d); font-variant-numeric: tabular-nums; }
.pay-card .links { display: flex; gap: 14px; margin-top: 10px; font-size: 13px; flex-wrap: wrap; }
.pay-card .reimb { margin-top: 10px; font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.badge-n { background: var(--brand); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; margin-left: 4px; }
@media (max-width: 860px) { .pay-grid { grid-template-columns: 1fr; } }

.acc-qr { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.acc-qr img { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in; background: #fff; }
.qr-up { display: flex; gap: 12px; align-items: center; }
.qr-up img { width: 110px; height: 110px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

.inv-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 6px; font-size: 13px; }
.inv-name { font-weight: 600; word-break: break-all; }

.pimg { display: flex; gap: 12px; align-items: center; }
.pimg img { width: 84px; height: 120px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in; background: #fff; }
.pimg-act { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; font-size: 13px; }
.pimg-empty { display: flex; align-items: center; justify-content: center; width: 180px; height: 72px; border: 1px dashed #c7ccd6; border-radius: 6px; color: var(--sub); cursor: pointer; font-size: 13px; background: #fafbfc; }
.pimg-empty:hover { border-color: var(--brand); color: var(--brand-d); }
.pimg-empty.req { border-color: var(--brand); color: var(--brand-d); background: var(--brand-l); }
.pimg-empty.dis { cursor: default; color: var(--muted); }

.vbox { display: flex; flex-direction: column; gap: 6px; }
.vbox-in { width: 260px; font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.vbox-in.bad { border-color: var(--red); background: var(--red-l); }
.vbox-cands { font-size: 12px; color: var(--sub); display: flex; gap: 10px; flex-wrap: wrap; }
.vbox-cands a { font-variant-numeric: tabular-nums; }
.vbox-cands .bad { color: var(--red); }
.vbox-dup { background: var(--red-l); color: var(--red); border: 1px solid #f5c2c2; border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.vbox-ok { color: var(--green); font-size: 12px; }

/* ---------- 提示 ---------- */
.restart-bar { position: sticky; top: 0; z-index: 200; background: var(--red); color: #fff; padding: 8px 16px; font-size: 13px; text-align: center; }
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast div { background: var(--text); color: #fff; padding: 8px 16px; border-radius: 6px; font-size: 13px; box-shadow: 0 6px 16px rgba(0,0,0,.2); max-width: 90vw; }
.toast div.err { background: var(--red); }
.toast div.ok { background: var(--green); }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1b2130 0%, #2a3247 100%); padding: 20px; }
.login .box { background: #fff; border-radius: 12px; padding: 32px 28px; width: 100%; max-width: 360px; box-shadow: 0 24px 48px rgba(0,0,0,.3); }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.login p { color: var(--sub); margin: 0 0 22px; font-size: 13px; }
.login .f { margin-bottom: 14px; }
.login .f label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.login input { padding: 9px 12px; font-size: 14px; }
.login .btn { width: 100%; justify-content: center; padding: 9px; font-size: 15px; }
.login .install-app { display: block; margin-top: 10px; }
.login .install-btn { color: var(--brand-d); border-color: #f5c49f; background: var(--brand-l); }
.install-guide { display: grid; gap: 14px; }
.install-guide > div { display: flex; align-items: center; gap: 12px; }
.install-guide b { display: inline-flex; width: 28px; height: 28px; flex: 0 0 28px; align-items: center; justify-content: center; border-radius: 50%; background: var(--brand); color: #fff; }
.install-guide p { margin: 2px 0 0; color: var(--sub); font-size: 13px; }

/* ---------- 移动端 ---------- */
.m-only { display: none; }
@media (max-width: 860px) {
  .side { position: fixed; left: -220px; z-index: 50; transition: left .2s; }
  .side.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .side-mask { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 40; }
  .menu-btn { display: block; }
  .refresh-app-btn { display: inline-flex; }
  .content { padding: 12px 10px 40px; }
  .topbar { padding: 0 12px; }
  .topbar .install-btn { padding: 4px 9px; font-size: 12px; }
  .topbar .me .name { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat .v { font-size: 18px; }
  .form { grid-template-columns: 1fr 1fr; gap: 10px; }
  .form .f.half { grid-column: 1 / -1; }
  .filters input, .filters select, .filters input.wide { width: calc(50% - 4px); }
  .orders-mobile-actions { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line2); }
  .orders-mobile-actions .btn:first-child { flex: 1; }
  .order-filters { display: none; }
  .order-filters.mobile-open { display: flex; }
  .order-summary { padding: 10px 16px; gap: 8px 12px !important; }
  .order-summary > span { flex: 0 0 calc(25% - 9px); min-width: 0; }
  .order-summary > span:nth-of-type(7) { flex-basis: 100%; }
  .order-summary > span:nth-of-type(8) { display: none; }
  .order-summary .btn { width: 100%; justify-content: center; }
  .order-mobile-list { border-top: 1px solid var(--line2); }
  .order-mobile-item { min-height: 78px; padding: 8px 12px; border-bottom: 1px solid var(--line2); cursor: pointer; display: grid; grid-template-columns: auto minmax(72px, 1fr) minmax(150px, 156px) 8px; grid-template-rows: auto auto auto auto; align-items: center; gap: 3px 6px; }
  .order-mobile-no { grid-column: 2; grid-row: 1; color: var(--muted); font-size: 10px; line-height: 14px; }
  .order-mobile-time { grid-column: 2; grid-row: 3; color: var(--muted); font-size: 9px; line-height: 15px; white-space: nowrap; }
  .order-mobile-name { grid-column: 2; grid-row: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12px; line-height: 16px; }
  .order-mobile-amounts { grid-column: 3; grid-row: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; min-width: 0; }
  .order-mobile-amounts > span { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .order-mobile-amounts small { color: var(--muted); font-size: 8px; line-height: 11px; }
  .order-mobile-amounts b, .order-mobile-amounts .num { overflow: hidden; text-overflow: ellipsis; font-size: 10px; font-weight: 600; line-height: 13px; white-space: nowrap; }
  .order-mobile-item > .tag { grid-column: 3; grid-row: 1; justify-self: end; padding: 0 4px; font-size: 10px; line-height: 16px; }
  .order-mobile-person { grid-column: 3; grid-row: 3; min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 4px; overflow: hidden; }
  .order-mobile-person small { flex: 0 0 auto; color: var(--muted); font-size: 8px; line-height: 15px; }
  .order-mobile-person b { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--sub); font-size: 10px; font-weight: 500; line-height: 15px; white-space: nowrap; }
  .order-mobile-todos { grid-column: 2 / 4; grid-row: 4; min-width: 0; display: flex; flex-wrap: wrap; gap: 3px; padding-top: 2px; }
  .order-mobile-todos .tag { padding: 0 4px; font-size: 9px; line-height: 15px; }
  .order-mobile-arrow { grid-column: 4; grid-row: 1 / 5; color: var(--muted); font-size: 18px; line-height: 18px; }
  .modal-mask { padding: 0; }
  .modal, .modal.lg, .modal.xl { border-radius: 0; min-height: 100vh; max-width: none; }
  .modal-b { max-height: none; }
  .m-hide { display: none !important; }
  .m-only { display: block; }
  .kv { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .form { grid-template-columns: 1fr; }
}
@media print {
  .side, .topbar, .no-print, .modal-f, .modal-h .x { display: none !important; }
  .modal-mask { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; max-width: none; }
  .modal-b { max-height: none; overflow: visible; }
  body { background: #fff; }
}
