:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e3e6ea;
  --line-2: #eef0f3;
  --ink: #17202b;
  --ink-2: #4a5563;
  --ink-3: #7b8794;
  --brand: #1f3a5f;
  --brand-2: #2d5f96;
  --accent: #0f6fbf;
  --high: #c62828;
  --high-bg: #fdecea;
  --high-line: #f2b8b3;
  --mid: #b56a00;
  --mid-bg: #fff5e6;
  --mid-line: #f0cfa0;
  --low: #8a7a00;
  --low-bg: #fdfbe4;
  --low-line: #e6dd9b;
  --ok: #1a7f52;
  --ok-bg: #e8f6ef;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 12px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 登录页 ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #eef2f7 0%, #e3e9f1 55%, #dbe3ee 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--panel); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .14); padding: 34px 32px 28px;
  border: 1px solid var(--line);
}
.login-card h1 {
  font-size: 19px; margin: 0 0 4px; letter-spacing: .3px; color: var(--brand);
}
.login-card .sub { color: var(--ink-3); font-size: 12.5px; margin-bottom: 22px; }
.login-card label {
  display: block; font-size: 12.5px; color: var(--ink-2); margin: 14px 0 6px;
  font-weight: 600;
}
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; background: #fbfcfd; color: var(--ink);
}
.login-card input:focus {
  outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(45, 95, 150, .12); background: #fff;
}
.login-card button {
  width: 100%; margin-top: 22px; padding: 11px; border: none; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 14.5px; font-weight: 600;
  cursor: pointer; letter-spacing: .5px;
}
.login-card button:hover { background: var(--brand-2); }
.login-err {
  margin-top: 14px; padding: 9px 12px; background: var(--high-bg);
  border: 1px solid var(--high-line); color: var(--high); border-radius: 8px;
  font-size: 12.5px;
}
.login-foot {
  margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line-2);
  font-size: 11.5px; color: var(--ink-3); line-height: 1.7;
}

/* ── 骨架 ───────────────────────────────────────────────── */
.top {
  height: 54px; background: var(--brand); color: #fff; display: flex;
  align-items: center; padding: 0 20px; gap: 16px; position: sticky; top: 0; z-index: 40;
}
.top .brand { font-weight: 700; font-size: 15px; letter-spacing: .4px; }
.top .brand small { font-weight: 400; opacity: .72; margin-left: 8px; font-size: 12px; }
.top .spacer { flex: 1; }
.top .who { font-size: 12.5px; opacity: .9; }
.top .who b { font-weight: 600; }
.top a.btn-lite {
  color: #fff; border: 1px solid rgba(255, 255, 255, .35); padding: 5px 12px;
  border-radius: 6px; font-size: 12.5px;
}
.top a.btn-lite:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }

.tabs { background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 20px;
        display: flex; gap: 2px; position: sticky; top: 54px; z-index: 30; overflow-x: auto; }
.tabs button {
  background: none; border: none; padding: 12px 16px; font-size: 13.5px;
  color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; font-family: inherit;
}
.tabs button:hover { color: var(--brand); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.wrap { padding: 20px; max-width: 1560px; margin: 0 auto; }
.view { display: none; }
.view.on { display: block; }

/* ── 卡片 / 网格 ────────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px;
}
.card > h3 {
  margin: 0 0 12px; font-size: 14px; color: var(--brand); letter-spacing: .3px;
  display: flex; align-items: center; gap: 8px;
}
.card > h3 .hint { font-weight: 400; font-size: 12px; color: var(--ink-3); }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .g4, .g3, .g2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .g4, .g3, .g2 { grid-template-columns: 1fr; } }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
       padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .n { font-size: 27px; font-weight: 700; line-height: 1.15; font-family: var(--mono); }
.kpi .l { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.kpi .x { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
.kpi.high .n { color: var(--high); }
.kpi.mid .n { color: var(--mid); }
.kpi.low .n { color: var(--low); }
.kpi.ok .n { color: var(--ok); }

/* 可点击下钻的统计卡 */
.kpi.clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.kpi.clickable:hover { border-color: var(--brand); box-shadow: 0 3px 14px rgba(31,58,95,.13);
                       transform: translateY(-1px); }
.kpi.clickable:hover .x { color: var(--brand); }
.kpi.clickable:active { transform: translateY(0); }

/* ── 徽章 ───────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.75;
}
.b-high { background: var(--high-bg); color: var(--high); border: 1px solid var(--high-line); }
.b-mid { background: var(--mid-bg); color: var(--mid); border: 1px solid var(--mid-line); }
.b-low { background: var(--low-bg); color: var(--low); border: 1px solid var(--low-line); }
.b-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #b6e0cc; }
.b-grey { background: #f1f3f5; color: var(--ink-2); border: 1px solid var(--line); }
.b-blue { background: #eaf2fb; color: var(--brand-2); border: 1px solid #c4daf0; }

/* ── 表格 ───────────────────────────────────────────────── */
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th {
  text-align: left; background: #f8f9fb; color: var(--ink-2); font-weight: 600;
  font-size: 12px; padding: 9px 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
}
table.tb td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.tb tbody tr:hover { background: #fafbfc; }
table.tb tr.row-high { background: #fffafa; }
table.tb tr.row-mid { background: #fffdf8; }
table.tb tr.row-low { background: #fffef7; }
table.tb tr.row-none { background: #fbfcfd; }
table.tb td.num { font-family: var(--mono); text-align: right; }
/* 访客明细：整行可点，点开在下面插一行链路详情 */
table.tb tbody tr.clickable { cursor: pointer; }
table.tb tbody tr.clickable:hover { background: #f2f6fb; }
table.tb tbody tr.clickable .gd-btn { color: var(--brand-2); font-size: 12px;
                                      font-weight: 600; white-space: nowrap; }
table.tb tbody tr.gd > td { background: #f8fafc; padding: 12px 14px;
                            border-bottom: 2px solid var(--line); }
table.tb tbody tr.gd .chain { padding: 0; }
.tb-scroll { max-height: 640px; overflow: auto; border: 1px solid var(--line);
             border-radius: 8px; }

/* ── 链路 ───────────────────────────────────────────────── */
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 3px 0; }
.node {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: 6px; font-size: 12.5px; border: 1px solid var(--line);
  background: #f7f8fa; color: var(--ink-2); white-space: nowrap;
}
/* 老大 2026-09-22：
   · 我方公司 → **绿色**（原先用红色，与「风险红」撞在一起，看不出差别）
   · 命中关联风险的公司 → **红色**（.hit 必须排在 .group 之后才盖得住） */
.node.group { background: #e8f5ec; border-color: #b3ddc4;
              color: #15653f; font-weight: 600; }
.node.soe { background: #eaf2fb; border-color: #c4daf0; color: var(--brand-2); }
.node.marker { background: transparent; border-style: dashed; color: var(--ink-3);
               font-size: 11.5px; }
.node.external { background: #f4f6f8; color: var(--ink-3); }
/* 访客视图：非我方、非本集团的实体一律显示成「其他」（虚线框表示被屏蔽） */
.node.masked { background: #f4f6f8; border-style: dashed; color: var(--ink-3); }
.node.hit { background: var(--high-bg); border-color: var(--high-line);
            color: var(--high); font-weight: 700; }
.node .amb { font-size: 10px; background: var(--mid-bg); color: var(--mid);
             padding: 0 4px; border-radius: 3px; margin-left: 2px; }
/* ── 节点之间的贸易量（老大 2026-09-22）──────────────────────
   数值用中性灰蓝标签，与「风险红 / 橙」和「我方绿」都不撞色。
   单位小字跟在数字后面（历史链路是吨，在线编制默认万元）。 */
.chain .amt {
  font-size: 11.5px; color: #55606e; background: #f4f6f9;
  border: 1px solid #e3e8ee; border-radius: 5px;
  padding: 1px 5px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chain .amt i { font-style: normal; font-size: 10px; color: #939dab; margin-left: 2px; }
.arrow { color: #c3c9d1; font-size: 12px; }

/* ── 表单 / 控件 ────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.fld { display: flex; flex-direction: column; gap: 4px; }
.fld span { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.fld.wide { flex-basis: 100%; }
.fld span a { font-weight: 600; color: var(--brand-2); margin-left: 6px;
              text-decoration: none; }
.fld span a:hover { text-decoration: underline; }

/* ── 可见月份多选（账户管理） ─────────────────────────────── */
.mpick { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 9px 12px;
         border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd;
         max-width: 100%; max-height: 172px; overflow: auto; }
.mpick label { display: inline-flex; align-items: center; gap: 5px;
               font-size: 12.5px; color: var(--ink); cursor: pointer;
               white-space: nowrap; }
.mpick input { margin: 0; accent-color: var(--brand); cursor: pointer; }
.mpick .pend { color: var(--ink-3); font-size: 11px; }
select, input[type=text], input[type=password], input[type=date] {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 13px; background: #fbfcfd; color: var(--ink); font-family: inherit;
  min-width: 130px;
}
select:focus, input:focus {
  outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(45, 95, 150, .12);
}
button.bt {
  padding: 7px 14px; border: 1px solid var(--brand); background: var(--brand);
  color: #fff; border-radius: 7px; font-size: 13px; cursor: pointer; font-family: inherit;
}
button.bt:hover { background: var(--brand-2); border-color: var(--brand-2); }
button.bt.ghost { background: #fff; color: var(--brand); }
button.bt.ghost:hover { background: #f2f6fa; }
button.bt.sm { padding: 4px 10px; font-size: 12px; }
button.bt.danger { background: #fff; color: var(--high); border-color: var(--high-line); }
button.bt.danger:hover { background: var(--high-bg); }
button.bt[disabled] { opacity: .45; cursor: not-allowed; }

/* ── 柱状图 ─────────────────────────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px;
        padding: 8px 0 0; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
             align-items: center; gap: 2px; min-width: 26px; }
.bars .seg { width: 100%; border-radius: 3px 3px 0 0; }
.bars .seg.high { background: #d9534f; }
.bars .seg.mid { background: #e8a33d; }
.bars .seg.low { background: #cbbb3a; }
.bars .lb { font-size: 10px; color: var(--ink-3); white-space: nowrap;
            transform: scale(.92); }
.bar-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-2);
              margin-top: 8px; }
.bar-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px;
                margin-right: 4px; }

/* ── 其他 ───────────────────────────────────────────────── */
.muted { color: var(--ink-3); font-size: 12.5px; }
.mono { font-family: var(--mono); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.notice {
  padding: 10px 13px; border-radius: 8px; font-size: 12.5px; line-height: 1.7;
  background: #f4f8fd; border: 1px solid #d6e4f5; color: var(--ink-2);
  margin-bottom: 14px;
}
.notice.warn { background: var(--mid-bg); border-color: var(--mid-line); }
.notice.bad { background: var(--high-bg); border-color: var(--high-line); }
.empty { padding: 40px; text-align: center; color: var(--ink-3); font-size: 13px; }
.row-rel { cursor: pointer; }
.row-rel:hover { background: #f4f8fd !important; }
/* 展开区外框。padding:0 —— 让「标题带」贴到边框上，与左侧级别色条一起
   构成一个明确的「这是某一行的展开块」；内边距由 .detail-hd / .detail-bd 各自给。 */
.detail-box { background: #fff; border: 1px solid var(--line); border-radius: 8px;
              border-left: 4px solid var(--brand-2); overflow: hidden;
              padding: 0; margin-top: 0; }
.dl { display: grid; grid-template-columns: 108px 1fr; gap: 4px 10px; font-size: 12.5px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; color: var(--ink); }
.cross-item { padding: 8px 0; border-bottom: 1px dashed var(--line-2); font-size: 12.5px; }
.cross-item:last-child { border-bottom: none; }
.cross-item b { color: var(--high); }
/* 已列入核心任职豁免名单的交叉：只作中危，弱化显示 */
.cross-item.waived { background: #fffdf8; border-left: 3px solid var(--mid); padding-left: 9px; }
.cross-item.waived b { color: var(--mid); }

/* ══ 历史记录：列表行「链路摘要」 vs 展开区「完整链路」 ══════════════
   老大 2026-09-22：原先列表行和展开区各画一遍链路、**两处都带贸易量**，
   看着像两条不同的链路，「找不到哪个对应哪个」。现在分工：
     · 摘要（列表行）= 只有公司名，一行看完，超长中间省略；
     · 全文（展开区）= 带贸易量 + 箭头 + 风险标色，**带数字的只此一处**。 */
.chain-brief { flex-wrap: nowrap; overflow: hidden; gap: 4px; }
.chain-brief .node { padding: 1px 7px; font-size: 12px; }
.chain-brief .sep { color: #c3c9d1; font-size: 11px; flex: none; }
.chain-brief .gap-n { color: var(--ink-3); font-size: 12px; flex: none;
                       letter-spacing: 1px; }
.chain-brief .more { color: var(--ink-3); font-size: 11px; flex: none;
                     background: #f4f6f9; border: 1px solid #e3e8ee;
                     border-radius: 5px; padding: 1px 6px; margin-left: 2px; }
.chain-full { padding: 4px 0 2px; }
td.td-chain { max-width: 620px; }
th.th-chain { min-width: 340px; }

/* 来源列里补一行「上传人 · 时间」（在线编制的记录才有） */
.src-who { font-size: 11px; color: var(--ink-3); margin-top: 3px; line-height: 1.35; }

/* 被展开的那一行：左侧级别色条 + 底色，明确「下面这块是它的」 */
tr.row-open > td { background: #f1f6fc !important; }
tr.row-open > td:first-child { box-shadow: inset 3px 0 0 var(--brand-2); }

/* 展开行：给它挂上明确的边界，别和列表行糊在一起 */
tr.det-row > td { padding: 0 12px 14px; background: #fbfcfe;
                  border-bottom: 2px solid var(--line); }
/* ⚠ 基础样式在 .detail-box 原规则里（已改为 padding:0，让标题带贴边），
   这里只叠加「按级别换左侧色条」。 */
.detail-box.lv-high { border-left-color: var(--high); }
.detail-box.lv-mid { border-left-color: var(--mid); }
.detail-box.lv-low { border-left-color: #cbbb3a; }
.detail-box.lv-none { border-left-color: #b9c2cc; }
.detail-hd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
             padding: 9px 12px; background: #f5f7fa;
             border-bottom: 1px solid var(--line); }
.detail-hd .det-name { font-size: 13.5px; }
.detail-hd .det-meta { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }
.detail-hd .det-close { margin-left: 4px; }
.detail-bd { padding: 12px 14px 14px; }
.dsec { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line-2); }
.dsec-t { font-size: 12.5px; font-weight: 600; margin: 0 0 6px; color: var(--ink);
          display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dsec-t.high { color: var(--high); }
.dsec-t.mid { color: var(--mid); }
.det-raw { margin-top: 12px; font-size: 12.5px; }
.det-raw summary { cursor: pointer; color: var(--ink-3); }
.det-raw > div { margin-top: 8px; line-height: 2; }
.det-raw .rw { padding: 1px 6px; border-radius: 5px; background: #f4f6f9;
               border: 1px solid #e3e8ee; }
.det-raw .rw.diff { background: var(--mid-bg); border-color: var(--mid-line);
                    color: #8a5200; font-weight: 600; }

/* ══ 编辑留痕 ═════════════════════════════════════════════════ */
table.tb.tb-edits tbody td { padding: 7px 10px; font-size: 12.5px;
                             vertical-align: top; }
table.tb.tb-edits tbody tr:hover { background: #f7fafd; }
table.tb.tb-edits tbody tr.e-has-del { background: #fdf6f6; }
table.tb.tb-edits tbody tr.e-has-del:hover { background: #fbecec; }
.e-ts { white-space: nowrap; color: var(--ink-2);
        font-variant-numeric: tabular-nums; }
.e-who { font-weight: 600; }
.e-res { white-space: nowrap; }
.e-res span { display: inline-block; min-width: 22px; margin-right: 3px;
              border-radius: 4px; padding: 0 4px; font-size: 11.5px;
              font-variant-numeric: tabular-nums; }
.d-add { background: #e8f5ec; color: #15653f; }
.d-chg { background: var(--mid-bg); color: #8a5200; }
.d-del { background: var(--high-bg); color: var(--high); font-weight: 700; }
.e-det { color: var(--ink-2); line-height: 1.7; word-break: break-all; }
.edit-sum { display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
            padding: 10px 14px; border-bottom: 1px solid var(--line);
            background: #fbfcfd; }
.sm-chip { font-size: 12px; background: #fff; border: 1px solid var(--line);
           border-radius: 20px; padding: 3px 11px; color: var(--ink-2); }
.sm-chip b { color: var(--brand); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end;
         padding-top: 10px; font-size: 12.5px; color: var(--ink-3); }
.loading { padding: 30px; text-align: center; color: var(--ink-3); font-size: 13px; }
.toast {
  position: fixed; right: 22px; bottom: 22px; background: var(--brand); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow);
  z-index: 100; opacity: 0; transform: translateY(8px); transition: .2s;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: none; }
.toast.err { background: var(--high); }
