/* 结算业务管理系统 · 样式
   轻量、自包含、无外部依赖；适配服务器部署（离线可用） */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e4e8ef;
  --txt: #1f2937;
  --muted: #6b7280;
  --blue: #2563eb;
  --blue-d: #1e40af;
  --teal: #0d9488;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--txt); font-size: 14px; line-height: 1.55;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 布局 ── */
html, body { height: 100%; }
.layout {
  display: flex; height: 100vh; overflow: hidden;
}
.side {
  position: fixed; left: 0; top: 0; bottom: 0; width: 216px;
  background: #12213b; color: #dbe4f1; flex-shrink: 0;
  display: flex; flex-direction: column; overflow-y: auto;
}
.side .brand { padding: 18px 16px 14px; font-weight: 700; font-size: 15px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.side .brand small { display: block; font-weight: 400; font-size: 11px; color: #93a6c4; margin-top: 4px; }
.side nav { flex: 1; padding: 10px 8px; }
.side nav a {
  display: block; padding: 9px 12px; margin: 2px 0; border-radius: 8px;
  color: #c6d2e6; font-size: 13.5px;
}
.side nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--blue); color: #fff; }
.side nav .grp {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 10px 12px; margin: 2px 0;
  border: none; border-radius: 8px; background: none;
  color: #8ba0c0; font-size: 12px; letter-spacing: .5px;
  font-family: inherit; cursor: pointer; text-align: left;
}
.side nav .grp:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav .grp.open { color: #fff; }
.side nav .grp-link {
  display: block; width: 100%; padding: 10px 12px; margin: 2px 0;
  border-radius: 8px; color: #8ba0c0; font-size: 12px; letter-spacing: .5px;
  text-decoration: none; cursor: pointer;
}
.side nav .grp-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav .sub { display: none; padding: 2px 0 6px; }
.side nav .sub.show { display: block; }
.side nav .sub a { padding-left: 28px; }
.side .foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #93a6c4; }
.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  margin-left: 216px; height: 100vh; overflow-y: auto;
}
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.topbar .who { color: var(--muted); font-size: 13px; }
.content { padding: 22px 24px 56px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ── 卡片与网格 ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin: 14px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card .k { color: var(--muted); font-size: 12.5px; }
.card .v { font-size: 24px; font-weight: 700; margin-top: 4px; }
.card .v.sm { font-size: 18px; }
.card .d { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.good .v { color: var(--ok); }
.card.warn .v { color: var(--warn); }
.card.bad .v { color: var(--err); }
.card.blue .v { color: var(--blue); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin: 14px 0; }
.panel h3 { margin: 0; padding: 14px 18px; font-size: 14.5px; border-bottom: 1px solid var(--line); }
.panel .body { padding: 8px 18px 16px; overflow-x: auto; }

/* ── 表格 ── */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: #fafbfc; position: sticky; top: 0; }
tr:hover td { background: #f7faff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; line-height: 18px; }
.tag.blue { background: #e8f0fe; color: var(--blue-d); }
.tag.teal { background: #e0f5f3; color: var(--teal); }
.tag.gray { background: #eef1f5; color: var(--muted); }
.tag.green { background: #e7f7ec; color: var(--ok); }
.tag.orange { background: #fdf0e2; color: var(--warn); }
.tag.red { background: #fdecec; color: var(--err); }
.tag.yellow { background: #fefbe6; color: #a16207; }

/* ── 表单 ── */
form .row { margin: 10px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  border: 1px solid #d5dbe5; border-radius: 8px; padding: 7px 10px; font-size: 13.5px;
  background: #fff; color: var(--txt); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
textarea { min-height: 64px; width: 100%; }
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 8px 16px;
  background: var(--blue); color: #fff; font-size: 13.5px; cursor: pointer;
}
.btn:hover { background: var(--blue-d); }
.btn.ghost { background: #fff; color: var(--txt); border: 1px solid #d5dbe5; }
.btn.ghost:hover { background: #f3f5f9; }
.btn.danger { background: var(--err); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.ok { background: var(--ok); }

/* ── 消息 ── */
.flash { padding: 10px 16px; border-radius: 8px; margin: 10px 0; font-size: 13.5px; }
.flash.ok { background: #e7f7ec; color: #166534; border: 1px solid #bbf7d0; }
.flash.err { background: #fdecec; color: #991b1b; border: 1px solid #fecaca; }

/* ── 其他 ── */
.muted { color: var(--muted); }
.blue { color: var(--blue); }
.small { font-size: 12px; }
.mt { margin-top: 12px; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.progress { background: #eef1f5; border-radius: 20px; height: 8px; overflow: hidden; min-width: 90px; }
.progress i { display: block; height: 100%; background: var(--teal); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #12213b, #1e40af); }
.login-box { background: #fff; border-radius: 14px; padding: 34px 38px; width: 340px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-box h1 { font-size: 19px; margin: 0 0 4px; }
.login-box .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 20px; }
.login-box input { width: 100%; margin: 6px 0 12px; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.pill { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px; font-size: 12.5px; }
.pill b { color: var(--blue); }

/* ── 移动端汉堡菜单 ── */
.burger {
  display: none; position: fixed; top: 10px; left: 12px; z-index: 60;
  background: #12213b; color: #fff; border: none; border-radius: 8px;
  width: 40px; height: 40px; font-size: 20px; cursor: pointer; line-height: 1;
}
.mask { display: none; }
/* 手机端右上角用户区（整页导航模式） */
.mbar {
  display: none; position: fixed; top: 10px; right: 12px; z-index: 60;
  align-items: center; gap: 10px; background: #12213b; color: #fff;
  padding: 8px 12px; border-radius: 8px; font-size: 12px; white-space: nowrap;
}
.mbar a { color: #ffc4bb; text-decoration: none; font-size: 12px; }
.mbar a:hover { text-decoration: underline; }
body.in-frame .mbar { display: none !important; }

/* ── 手机端响应式 ── */
@media (max-width: 768px) {
  .burger { display: block; }
  .mbar { display: flex; }
  .mask {
    display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
    z-index: 65; opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .mask.show { opacity: 1; pointer-events: auto; }
  .layout { height: auto; min-height: 100vh; overflow: visible; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: 258px; z-index: 70;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 2px 0 18px rgba(0, 0, 0, .2);
  }
  .side.open { transform: translateX(0); }
  .main { width: 100%; margin-left: 0; height: auto; overflow: visible; }
  .topbar {
    padding: 12px 14px 12px 60px; align-items: center; gap: 8px;
  }
  .topbar > div:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .who { font-size: 12px; white-space: nowrap; }
  .content { padding: 14px 12px 40px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .card { padding: 12px 14px; }
  .card .v { font-size: 20px; }
  .card .v.sm { font-size: 16px; }
  .panel h3 { padding: 12px 14px; font-size: 14px; }
  .panel .body { padding: 6px 14px 14px; }
  th, td { padding: 6px 8px; font-size: 12px; }
  .flex { gap: 8px; }
  form .row { gap: 8px; }
  input[type=text], input[type=search], input[type=password], input[type=number],
  input[type=date], input[type=month], select, textarea {
    font-size: 16px; /* 防 iOS 聚焦自动放大（含 search/month） */
  }
  .btn { padding: 9px 14px; }
  .btn.sm { padding: 6px 10px; }
  .flex input[type=text] { max-width: 100%; }
  .login-box { width: 90%; max-width: 340px; padding: 26px 22px; }
  .grid2 { grid-template-columns: 1fr; gap: 10px; }
  .pill-row { gap: 6px; }
  .pill { padding: 6px 10px; font-size: 12px; }
  /* 客户列表：手机上隐藏次要列（24 列中保留 状态/企业ID/公司名称/蓝桥签约人/省份/城市/操作） */
  table.ctable th:nth-child(1), table.ctable td:nth-child(1),
  table.ctable th:nth-child(2), table.ctable td:nth-child(2),
  table.ctable th:nth-child(3), table.ctable td:nth-child(3),
  table.ctable th:nth-child(6), table.ctable td:nth-child(6),
  table.ctable th:nth-child(8), table.ctable td:nth-child(8),
  table.ctable th:nth-child(9), table.ctable td:nth-child(9),
  table.ctable th:nth-child(10), table.ctable td:nth-child(10),
  table.ctable th:nth-child(11), table.ctable td:nth-child(11),
  table.ctable th:nth-child(12), table.ctable td:nth-child(12),
  table.ctable th:nth-child(14), table.ctable td:nth-child(14),
  table.ctable th:nth-child(15), table.ctable td:nth-child(15),
  table.ctable th:nth-child(16), table.ctable td:nth-child(16),
  table.ctable th:nth-child(17), table.ctable td:nth-child(17),
  table.ctable th:nth-child(18), table.ctable td:nth-child(18),
  table.ctable th:nth-child(19), table.ctable td:nth-child(19),
  table.ctable th:nth-child(20), table.ctable td:nth-child(20),
  table.ctable th:nth-child(21), table.ctable td:nth-child(21),
  table.ctable th:nth-child(22), table.ctable td:nth-child(22) { display: none; }
}

/* ── 分页 ── */
.rh { font-size: 11px; color: #8695ab; margin-top: 2px; white-space: nowrap; }
/* ── 费率表：纵向全宽 + 区间为主 ── */
.bands-stack { display: flex; flex-direction: column; gap: 14px; }
.bands-stack .panel { width: 100%; }
.band-head { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.band-head b { font-size: 14px; }
.bands-stack table { min-width: 420px; }
.bands-stack td input.up { width: 76px; vertical-align: middle; }
.bands-stack .rg { font-size: 13.5px; font-weight: 600; color: #2b3c55; margin-left: 10px; vertical-align: middle; white-space: nowrap; }
.bands-stack tr.cap-row td { background: #fdf6e3; }
.bands-stack tr.cap-row .rg { color: #8a6d1a; }
.bands-stack .panel .body { overflow-x: auto; }
/* 编辑模式：默认只读展示（v），编辑时切 input（e） */
#bandsBody .e { display: none; width: 76px; }
#bandsBody .v { white-space: nowrap; }
#bandsBody.editing .v { display: none; }
#bandsBody.editing .e { display: inline-block; }
#bandsBody.editing .rg { margin-left: 0; }
.bands-stack .tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: #eef4ff; color: #2b6bd6; font-size: 12px;
}
#bandsBody.editing tr.cap-row td { background: #fdf6e3; }
/* 伙伴结算政策参数表 */
.tbl-params { min-width: 640px; }
.tbl-params th, .tbl-params td { text-align: center; padding: 8px 10px; white-space: nowrap; }
.tbl-params td span.v { font-size: 14px; font-weight: 600; color: #2b3c55; }
.tbl-params td input.e { text-align: center; }
.pager { display: flex; align-items: center; gap: 6px; padding: 12px 18px; flex-wrap: wrap; }
.pager .pg {
  display: inline-block; min-width: 30px; text-align: center; padding: 4px 8px;
  border-radius: 6px; font-size: 12.5px; border: 1px solid var(--line); color: var(--txt);
}
.pager a.pg:hover { background: #f3f5f9; text-decoration: none; }
.pager .pg.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.pager .pg.dot { border: none; color: var(--muted); }
.pager .dis { opacity: .45; pointer-events: none; }

/* ── 表格容器：隐藏原生滚动条，只留自定义横向滚动条 ── */
.table-wrap { overflow: auto; scrollbar-width: none; }
.table-wrap::-webkit-scrollbar { display: none; width: 0; height: 0; }
.pager.sticky {
  position: sticky; bottom: 0; background: #fff;
  border-top: 1px solid var(--line); z-index: 5;
}
@media (max-width: 768px) {
  .table-wrap { height: auto !important; }
}

/* ── 自定义横向滚动条（常显，贴容器可视区底部，不覆盖内容）── */
.hbar {
  /* 固定在视口底部：任何滚动位置都能拖动横向滚动，不用滚到表格最底 */
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 999;
  height: 16px; padding: 0 6px; margin: 0;
  background: rgba(240, 242, 246, 0.97); border-top: 1px solid var(--line);
  user-select: none; touch-action: none;
}
.hbar-track { position: relative; height: 100%; width: 100%; }
.hbar-thumb {
  position: absolute; top: 2px; bottom: 2px; left: 0;
  background: #a8b3c4; border-radius: 6px; cursor: grab; min-width: 40px;
}
.hbar-thumb:hover { background: #8fa0b5; }
.hbar-thumb:active { cursor: grabbing; background: #7a8ca3; }
/* 隐藏容器原生横向滚动条（webkit），由自定义横条接管 */
.table-wrap::-webkit-scrollbar:horizontal { display: none; height: 0; }
@media (max-width: 768px) {
  .hbar { display: none !important; }
}

/* ── 三级菜单（二级折叠组）── */
.side nav .grp2 {
  display: block; width: 100%; padding: 7px 12px 7px 18px; margin: 2px 0;
  border: none; border-radius: 8px; background: none;
  color: #9fb0cd; font-size: 12.5px; font-family: inherit;
  cursor: pointer; text-align: left;
}
.side nav .grp2:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav .grp2.open { color: #fff; }
.side nav .sub2 { display: none; padding: 2px 0 6px; }
.side nav .sub2.show { display: block; }
.side nav .sub2 a { padding-left: 42px; font-size: 13px; }
.side nav .ph {
  display: block; padding: 7px 12px 7px 28px; color: #5f7395; font-size: 12.5px;
  cursor: default;
}

/* ── 多标签页（iframe 标签系统）── */
.tabbar {
  display: flex; align-items: stretch; flex-shrink: 0; height: 40px;
  background: #e9eef5; border-bottom: 1px solid #d4dce8;
}
.tabscroll {
  display: flex; align-items: stretch; flex: 1; min-width: 0;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.tabscroll::-webkit-scrollbar { height: 6px; }
.tabbar-user {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  padding: 0 16px; background: #e9eef5; border-left: 1px solid #d4dce8;
  font-size: 13px; color: #5a6b84; white-space: nowrap;
}
.tabbar-user a { color: #c0392b; text-decoration: none; font-size: 13px; }
.tabbar-user a:hover { text-decoration: underline; }
.tab {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 0 12px; max-width: 220px; border-right: 1px solid #d4dce8;
  background: #f2f6fb; color: #5a6b84; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: #eaf0f9; }
.tab.active { background: #fff; color: #1a2b45; font-weight: 600; box-shadow: inset 0 -2px 0 var(--blue); }
.tab .t { overflow: hidden; text-overflow: ellipsis; }
.tab .x {
  width: 16px; height: 16px; line-height: 15px; text-align: center;
  border-radius: 50%; color: #9aa8bd; font-size: 13px; flex-shrink: 0;
}
.tab .x:hover { background: #e0e7f1; color: #c0392b; }
.panes { flex: 1; min-height: 0; display: flex; background: #fff; position: relative; }
.pane { flex: 1; min-width: 0; display: none; }
.pane.active { display: flex; }
.pane iframe { width: 100%; height: 100%; border: 0; display: block; }
.tab-empty {
  display: none;
  margin: 40px auto; color: #9aa8bd; font-size: 14px; text-align: center;
}
/* 顶层标签模式：main 不再整页滚动，滚动交给 iframe */
body.has-tabber .main { overflow: hidden; }
/* iframe 内：隐藏侧栏/顶栏，内容全宽 */
body.in-frame .side,
body.in-frame .burger,
body.in-frame .mask,
body.in-frame .topbar { display: none !important; }
body.in-frame .main { margin-left: 0; }
@media (max-width: 900px) {
  body.has-tabber .main { overflow: hidden; }
  body.has-tabber .panes { height: calc(100vh - 40px); flex: none; }
}
/* 手机端整页模式：标签栏紧凑，单标签当前页 */
@media (max-width: 768px) {
  .tabbar { height: 38px; }
  .tab { max-width: 140px; padding: 0 10px; font-size: 12px; }
  .tabbar-user { padding: 0 10px; gap: 8px; font-size: 12px; }
  .tabbar-user a { font-size: 12px; }
  .tabscroll::-webkit-scrollbar { height: 0; }
  body.has-tabber .panes { height: calc(100vh - 38px); }
  /* 触控友好：按钮/输入加大命中区 */
  .btn { min-height: 40px; }
  .btn.sm { min-height: 34px; }
  input[type=text], input[type=password], input[type=number], input[type=date], select {
    min-height: 40px; }
  .panel .body { -webkit-overflow-scrolling: touch; }
  /* 顶层 shell 内容顶部为汉堡按钮让位（iframe 内无汉堡，不加） */
  body:not(.in-frame) .content { padding-top: 56px; }
}
/* 编辑模式才显示的追加行 */
.bands-stack tr.e-only { display: none; }
#bandsBody.editing tr.e-only { display: table-row; }

/* ── 蓝桥对账明细：底部固定合计条 ── */
.b-sum {
  position: fixed; left: 0; right: 0; bottom: 16px; z-index: 998;
  background: #eef1f6; border-top: 1px solid var(--line);
  padding: 6px 14px; font-size: 13px; color: #334;
  display: flex; gap: 18px; align-items: center; justify-content: center;
  white-space: nowrap; overflow-x: auto; user-select: none;
}
.b-sum b { font-weight: 600; }
.b-sum .blue { color: #1d4ed8; }
.b-sum .red { color: #dc2626; }

/* ── 移动端：卡片视图 与 切换按钮 ── */
.m-switch { display: none; }
#cardsView { display: none; }

.bcard {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(30,40,60,.04);
}
.bcard-h { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.bcard-h b.blue { font-size: 14px; }
.bcard-body { line-height: 1.7; }
.bcard-nums {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px;
  font-size: 13px; background: #f6f8fb; border-radius: 8px; padding: 6px 10px;
}
.bcard-nums b { font-size: 14px; }
.bcard-nums .red { color: #dc2626; }
.bcard-foot {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
}

/* 移动端（≤768px）：默认卡片视图，表格隐藏，切换按钮显示 */
@media (max-width: 768px) {
  .b-sum { bottom: 0; justify-content: flex-start; gap: 10px; font-size: 12px; padding: 6px 10px; }
  .m-switch { display: flex; gap: 8px; margin: 10px 0; }
  .m-switch .btn.active { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
  #cardsView { display: block; }
  #tableView { display: none; }
}
