:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #1f2329;
  --muted: #6b7280;
  --blue: #185fa5;
  --blue-bg: #e6f1fb;
  --red: #a32d2d;
  --red-bg: #fcebeb;
  --green: #27500a;
  --green-bg: #eaf3de;
  --amber: #854f0b;
  --amber-bg: #faeeda;
  --gray-bg: #f1efe8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
h1 { font-size: 16px; font-weight: 500; margin: 0; }
h2 { font-size: 14px; font-weight: 500; margin: 0; }
h3 { font-size: 13px; font-weight: 500; margin: 18px 0 8px; color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); align-self: center; }
.brand .sub { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 8px; align-items: center; }

button {
  font: inherit; padding: 6px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover { border-color: #c9ced6; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select {
  font: inherit; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); color: var(--text);
}

main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
}
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 24px; font-weight: 500; margin-top: 2px; }
.card.is-bad .v { color: var(--red); }
.card.is-good .v { color: var(--green); }
.card.is-warn .v { color: var(--amber); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-head-right { display: flex; gap: 10px; align-items: center; }
.tabs { display: flex; gap: 4px; }
.tab { border: none; background: transparent; padding: 5px 12px; border-radius: 6px; color: var(--muted); }
.tab.active { background: var(--blue-bg); color: var(--blue); }
.meta { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
tr:last-child td { border-bottom: none; }
.col-shop { min-width: 180px; }
.col-op { min-width: 200px; }
.shop-name { font-weight: 500; }
.shop-code { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.b-matched { background: var(--green-bg); color: var(--green); }
.b-mismatched { background: var(--red-bg); color: var(--red); }
.b-not_settled { background: var(--amber-bg); color: var(--amber); }
.b-no_ys, .b-no_sl, .b-error { background: var(--gray-bg); color: #444441; }
.b-pending { background: var(--gray-bg); color: #444441; }

.metric { font-variant-numeric: tabular-nums; }
.metric .row { display: flex; justify-content: space-between; gap: 8px; }
.metric .row span:first-child { color: var(--muted); }
.metric .diff { color: var(--red); }
.metric .diff.zero { color: var(--muted); }
.metric.muted { color: var(--muted); }
.metric .na { font-style: italic; opacity: .75; }

/* 营业总额是判定项，加底色突出 */
#tbl th.col-total { background: var(--gray-bg); }
.th-sub { font-weight: 400; font-size: 11px; opacity: .7; margin-left: 2px; }

.op { display: flex; gap: 6px; flex-wrap: wrap; }
.op button { padding: 4px 8px; font-size: 12px; }
.note { color: var(--muted); font-size: 12px; margin-top: 4px; }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.link { color: var(--blue); text-decoration: none; }
.hidden { display: none !important; }

.modal { position: fixed; inset: 0; background: rgba(31,35,41,.35); display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow: auto; }
.modal-box { background: var(--surface); border-radius: 12px; width: 560px; max-width: 100%; border: 1px solid var(--border); }
.modal-head, .modal-foot { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-foot { border-bottom: none; border-top: 1px solid var(--border); }
.modal-body { padding: 4px 18px 18px; }
.modal-body label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.modal-body label input, .modal-body label select { display: block; width: 100%; margin-top: 4px; color: var(--text); }
.modal-body label.chk { display: flex; align-items: center; gap: 8px; }
.modal-body label.chk input { width: auto; margin: 0; }
