/* ===========================================================
   串知粤管理端
   配色思路：C 端是红色主导的卖场，管理端反过来。
   红色在这里只留给「危险」和「金额」，界面骨架用冷灰和蓝，
   否则满屏红色时真正要警示的东西就淹没了。
   =========================================================== */

:root {
  --ink:      #16181d;   /* 正文 */
  --ink-2:    #5b6270;   /* 次要文字 */
  --ink-3:    #949bab;   /* 弱化文字 */
  --line:     #e4e7ec;   /* 分隔线 */
  --line-2:   #f0f2f5;   /* 更浅的分隔 */
  --surface:  #ffffff;
  --canvas:   #f7f8fa;   /* 页面底色，偏冷 */
  --side:     #1d2430;   /* 侧栏，冷灰蓝 */
  --side-2:   #2a3342;
  --blue:     #1a5fb4;   /* 主操作，沿用小程序的辅助蓝 */
  --blue-bg:  #e8f0fa;
  --red:      #e4393c;   /* 金额与危险，沿用品牌红 */
  --red-bg:   #fdecec;
  --amber:    #c47a00;   /* 待核对，沿用小程序 badge-warn 的色 */
  --amber-bg: #fff5df;
  --green:    #157a52;
  --green-bg: #e6f4ee;
  --r:        6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.55 "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* 金额、编码、日期一律等宽数字，否则列对不齐，对账时特别难看 */
.num, td.num, .money, .code { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

a { color: var(--blue); text-decoration: none; }
button { font: inherit; }

/* ===================== 骨架 ===================== */
.shell { display: flex; min-height: 100vh; }

.side {
  width: 208px; flex-shrink: 0; background: var(--side); color: #c4cbd8;
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.side-brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--side-2); }
.side-brand b { display: block; color: #fff; font-size: 16px; letter-spacing: .5px; }
.side-brand span { display: block; color: #7a8496; font-size: 12px; margin-top: 4px; }

.nav { padding: 10px 0; flex: 1; }
.nav-group { color: #6b7587; font-size: 11px; padding: 14px 20px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: #c4cbd8; font-size: 14px; border-left: 3px solid transparent;
}
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.on { background: var(--side-2); color: #fff; border-left-color: var(--blue); font-weight: 600; }
.nav .n-count {
  margin-left: auto; background: var(--amber); color: #23180a;
  border-radius: 9px; padding: 0 7px; font-size: 11px; font-weight: 700; line-height: 18px;
}
.nav .n-count.red { background: var(--red); color: #fff; }

.side-foot { padding: 14px 20px; border-top: 1px solid var(--side-2); font-size: 12px; color: #6b7587; }

.main { flex: 1; min-width: 0; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar .sub { color: var(--ink-3); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--ink-2); font-size: 13px; }

.view { padding: 20px 24px 60px; }

/* ===================== 通用块 ===================== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-2);
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-note { color: var(--ink-3); font-size: 12px; }

.hint {
  background: var(--blue-bg); border: 1px solid #cfe0f5; color: #1b4a86;
  border-radius: var(--r); padding: 11px 14px; font-size: 13px; line-height: 1.7; margin-bottom: 16px;
}
.hint.warn { background: var(--amber-bg); border-color: #f0e0bb; color: #7a5000; }
.hint.danger { background: var(--red-bg); border-color: #f6cccd; color: #a52126; }

/* ===================== 指标条 ===================== */
.metrics { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.metric {
  flex: 1 1 160px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 16px;
}
.metric .m-l { color: var(--ink-3); font-size: 12px; }
.metric .m-v { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.4px; }
.metric .m-s { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.metric.alert { border-color: #f0e0bb; background: var(--amber-bg); }
.metric.alert .m-v { color: var(--amber); }
.metric.money .m-v { color: var(--red); }

/* ===================== 工具条 ===================== */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.bar .spacer { flex: 1; }

input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px;
  font: inherit; color: var(--ink); background: #fff; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,95,180,.12); }
input[type=text]::placeholder, textarea::placeholder { color: #b3b9c5; }
textarea { width: 100%; line-height: 1.6; resize: vertical; }
select { cursor: pointer; }
label.fl { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: var(--r); padding: 6px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c8cdd6; background: #fafbfc; }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #164f96; }
.btn.danger { color: var(--red); border-color: #f0c8c9; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { border: none; background: #fff; padding: 6px 14px; cursor: pointer; color: var(--ink-2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--blue); color: #fff; font-weight: 600; }

/* ===================== 表格 ===================== */
.tw { overflow-x: auto; }
.tw table { min-width:680px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th {
  color: var(--ink-2); font-size: 12px; font-weight: 600; background: #fafbfc;
  /* .tw 上的 overflow-x:auto 会让它成为 sticky 的滚动容器，
     这里再写 top:56px 会把表头整体往下推、盖住第一行。必须是 0。 */
  position: sticky; top: 0; z-index: 5; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
tbody tr:hover { background: #fafbfc; }
tbody tr.flagged { background: #fffdf6; }
tbody tr.flagged:hover { background: #fff9e9; }
td.r, th.r { text-align: right; }
td.money { color: var(--red); font-weight: 600; }
td .code { color: var(--ink-3); font-size: 12px; }
.tname { font-weight: 600; }
.tsub { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.acts { display: flex; gap: 6px; justify-content: flex-end; }

.empty-row { text-align: center; color: var(--ink-3); padding: 48px 20px; }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--ink-2); font-size: 13px; }
.pager .spacer { flex: 1; }

/* ===================== 徽章 ===================== */
.tag {
  display: inline-block; border-radius: 4px; padding: 1px 7px;
  font-size: 12px; line-height: 19px; white-space: nowrap;
}
.tag.grey  { background: var(--line-2); color: var(--ink-2); }
.tag.blue  { background: var(--blue-bg); color: var(--blue); }
.tag.amber { background: var(--amber-bg); color: var(--amber); }
.tag.red   { background: var(--red-bg); color: var(--red); }
.tag.green { background: var(--green-bg); color: var(--green); }

/* ===================== 弹层 ===================== */
.mask { position: fixed; inset: 0; background: rgba(20,24,32,.44); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: #fff; border-radius: 8px; width: 560px; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column; }
.modal.wide { width: 860px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x { margin-left: auto; border: none; background: none; font-size: 22px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 0 4px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 10px; justify-content: flex-end; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.full { grid-column: 1 / -1; }

.kv { display: flex; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { width: 96px; color: var(--ink-3); flex-shrink: 0; }
.kv .v { flex: 1; }

/* ===================== 时间轴 ===================== */
.tl { padding-left: 4px; }
.tl-i { display: flex; gap: 12px; padding: 7px 0; font-size: 13px; }
.tl-i .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); margin-top: 7px; flex-shrink: 0; }
.tl-i:first-child .dot { background: var(--blue); }
.tl-i .at { color: var(--ink-3); width: 132px; flex-shrink: 0; }

/* ===================== 简易条形图（不引第三方库，离线可用）=========== */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .bl { width: 96px; flex-shrink: 0; color: var(--ink-2); }
.bar-row .bt { flex: 1; background: var(--line-2); border-radius: 3px; height: 18px; overflow: hidden; }
.bar-row .bf { height: 100%; background: var(--blue); border-radius: 3px; }
.bar-row .bv { width: 110px; text-align: right; flex-shrink: 0; font-weight: 600; }

/* ===================== 登录 ===================== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--side); padding: 24px; }
.login {
  width: 380px; max-width: 100%; background: #fff; border-radius: 10px; padding: 34px 34px 28px;
}
.login h1 { margin: 0 0 4px; font-size: 21px; }
.login p.s { margin: 0 0 26px; color: var(--ink-3); font-size: 13px; }
.login .f { margin-bottom: 14px; }
.login .btn { width: 100%; padding: 10px; margin-top: 8px; }
.login .tip { margin-top: 18px; font-size: 12px; color: var(--ink-3); line-height: 1.7; }

.toast {
  position: fixed; left: 50%; top: 74px; transform: translateX(-50%);
  background: #1d2430; color: #fff; padding: 9px 18px; border-radius: var(--r);
  font-size: 13px; z-index: 300; max-width: 70vw;
}
.toast.err { background: var(--red); }

.f input,.f select,.f textarea { width:100%; }
.filter-form { align-items:flex-end; }
.filter-form .f { width:170px; }
.field-help { margin:5px 0 0; color:var(--ink-2);font-size:12px; }
.form-error { margin-top:16px;padding:12px;background:var(--red-bg);color:#a52126;border:1px solid #f6cccd;border-radius:var(--r); }
.loading-state { padding:48px 24px;text-align:center;color:var(--ink-2); }
.menu-toggle { display:none; }
.login-mark { display:grid;place-items:center;background:var(--red);color:#fff;width:44px;height:44px;border-radius:10px;font-size:25px;font-weight:700;margin-bottom:22px; }
.thumb { width:58px;height:58px;object-fit:cover;border-radius:6px;background:var(--canvas); }
.acts { flex-wrap:wrap; }
.kv .v { min-width:0;overflow-wrap:anywhere; }
.modal-body h4 { margin:24px 0 10px; }
.check-line { display:flex;align-items:center;gap:8px; }
.media-grid { display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:16px; }
.media-grid .thumb { width:100%;height:150px; }
.json-view { white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.7 Consolas,monospace;padding:16px;background:var(--canvas); }
.task-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.task-card{display:flex;align-items:center;justify-content:space-between;background:var(--canvas);border:1px solid var(--line);border-radius:6px;padding:16px;color:var(--ink-2)}.task-card:hover{border-color:var(--blue);background:var(--blue-bg)}.task-card b{color:var(--ink);font-size:24px}.entity-picker{display:flex;align-items:center;gap:10px;min-height:36px}.picked-label{flex:1;overflow-wrap:anywhere}.entity-picker input[type=hidden]{display:none}.content-row{padding:16px;margin:12px 0;border:1px solid var(--line);border-radius:6px;background:var(--canvas)}.content-row>.btn{margin-top:12px}.save-bar{position:sticky;bottom:0;padding:16px;background:var(--surface);border:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:16px;z-index:10}.settings-form>.panel{margin-bottom:16px}.report-results{margin-top:16px}.report-results>.panel,.report-results>.grid2{margin-top:16px}.upload-file{display:block;margin-top:8px;max-width:100%}.filter-form .f:only-child{max-width:300px}
@media (max-width:1080px) { .side{width:176px}.side-brand{padding:18px 14px}.nav a{padding:9px 14px}.topbar .sub{display:none}.view{padding:18px 16px 50px}.grid3{grid-template-columns:1fr 1fr} }
@media (max-width:700px) { .side{position:fixed;left:0;top:56px;height:calc(100vh - 56px);z-index:30;transform:translateX(-100%);transition:transform .16s}.nav-open .side{transform:translateX(0)}.menu-toggle{display:inline-block}.topbar{padding:0 12px;gap:8px}.topbar .who{display:none}.view{padding:14px 10px 40px}.grid2,.grid3{grid-template-columns:1fr}.mask{padding:10px}.modal{max-height:94vh}.modal-body{padding:16px}.filter-form .f{width:calc(50% - 6px)} }
@media (prefers-reduced-motion:reduce) { *{scroll-behavior:auto !important;transition:none !important} }
@media(max-width:900px){.task-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.task-card{padding:12px}.task-card b{font-size:20px}}
