/* 流量查询 (原 ipfindprice) — 并入 ppool 后作为原生 tab。
   样式全部 scope 到 #tab-balance, 配色/字体对齐 ppool, 不污染其它 tab。 */
#tab-balance {
  --panel: #fff;
  --ink: #333;
  --muted: #888;
  --line: #ddd;
  --ok: #2d6a4f;
  --bad: #e94560;
  --warn: #e67e22;
  --info: #0f3460;
  --accent: #0f3460;
  --accent2: #cfe0f0;
  --sel: #f0f7ff;
  color: var(--ink);
  /* 字号基准: 页面上的字号都是相对它算的 (calc(var(--fs) ± Npx)), 工具栏「字号」改的就是它 (balance.js setFontSize) */
  --fs: 14px;
  font-size: var(--fs);
}
#tab-balance .bal-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
#tab-balance .stats { display: flex; gap: 10px; flex-wrap: wrap; }
#tab-balance .stat { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; min-width: 84px; cursor: pointer; user-select: none; transition: border-color .12s, box-shadow .12s; }
#tab-balance .stat:hover { border-color: var(--accent); }
#tab-balance .stat.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--sel); }
#tab-balance .stat b { display: block; font-size: calc(var(--fs) + 5px); font-variant-numeric: tabular-nums; color: #0f3460; }
#tab-balance .stat span { font-size: calc(var(--fs) - 1px); color: var(--muted); }
#tab-balance .avail-hint { font-size: calc(var(--fs) - 1px); text-decoration: none; border-bottom: 1px dashed currentColor; }
#tab-balance .avail-hint:empty { display: none; }
/* 字号: 显示设置, 放在卡片这一排的最右边 */
#tab-balance .font-pick { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: calc(var(--fs) - 1px); color: var(--muted); white-space: nowrap; }
#tab-balance .font-pick select { width: auto; padding: 4px 6px; }
#tab-balance .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 14px; display: flex; flex-direction: column; }
#tab-balance .panel h2 { margin: 0 0 10px; font-size: var(--fs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
#tab-balance input[type=search], #tab-balance input[type=text], #tab-balance input[type=password], #tab-balance input[type=number], #tab-balance input[type=date], #tab-balance input:not([type]), #tab-balance select, #tab-balance textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 3px; background: #fff; padding: 6px 8px; font: inherit; font-size: var(--fs); color: inherit;
}
#tab-balance textarea { min-height: 64px; resize: vertical; }
#tab-balance #batchPaste { font-family: Consolas, monospace; font-size: calc(var(--fs) - 1px); }
#tab-balance .row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
#tab-balance button { border: 1px solid var(--accent); border-radius: 3px; background: var(--accent); color: #fff; padding: 5px 12px; font: inherit; font-size: calc(var(--fs) - 1px); cursor: pointer; }
#tab-balance button.ghost { background: #fff; color: var(--accent); }
#tab-balance button.ghost.on { background: var(--sel); border-color: var(--accent); }
#tab-balance button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
#tab-balance button:disabled { opacity: 0.5; cursor: not-allowed; }
#tab-balance .toolbar-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
#tab-balance .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 0; }
#tab-balance .toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; flex-shrink: 0; }
#tab-balance .toolbar label.conc { display: inline-flex; align-items: center; gap: 6px; font-size: calc(var(--fs) - 1px); color: var(--muted); white-space: nowrap; }
#tab-balance .toolbar label.conc input { width: 56px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 3px; background: #fff; font: inherit; }
#tab-balance .toolbar label.conc select { width: auto; }
/* 搜索框放在工具栏最前面: 全局规则把输入框设成 100% 宽 (会独占一整行), 这里改成「起步 150px, 这一行有富余再变宽, 最宽 250px」——
   折行是按起步宽度算的, 所以一行摆不下的时候先让搜索框让出地方, 而不是把后面的按钮挤到下一行 */
#tab-balance .toolbar input.bal-search { flex: 1 1 150px; width: auto; min-width: 130px; max-width: 250px; padding: 5px 9px; font-size: calc(var(--fs) - 1px); }
/* 一组挨着的按钮: 窗口窄了要折行的时候整组一起折, 不会把其中一个单独挤到下一行 */
#tab-balance .toolbar .tb-group { display: inline-flex; align-items: center; gap: 8px; flex-wrap: nowrap; white-space: nowrap; }
/* 「设置」按钮旁边那句当前状态 (定时 关 · 代理 开); 定时开着的时候用绿色, 点一下打开「设置」 */
#tab-balance .set-brief { font-size: calc(var(--fs) - 1px); color: var(--muted); text-decoration: none; white-space: nowrap; }
#tab-balance .set-brief:hover { color: var(--accent); text-decoration: underline; }
#tab-balance .set-brief.on { color: var(--ok); }
#tab-balance .set-brief.warn { color: var(--warn); } /* AI 没配置: 有图片验证码的站点查不了 */
#tab-balance .set-brief:empty { display: none; }
/* 「设置」弹窗里的分区 (定时查询 / 代理设置) */
#tab-balance .set-sec { min-width: 0; }
#tab-balance .set-sec + .set-sec { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 2px; }
#tab-balance .set-h { font-weight: 600; margin-bottom: 8px; }
#tab-balance .set-tip { margin-top: 4px; font-size: calc(var(--fs) - 2px); color: var(--muted); line-height: 1.5; }
#tab-balance #set_ai_msg:empty { display: none; }
/* 「设置」里东西多: 窗口矮的时候中间那段自己滚, 标题和「关闭」一直看得见 */
#tab-balance #setDlg .dlg-b { max-height: calc(100vh - 170px); overflow: auto; }
/* 「再筛」的选项有几个很长, 不限宽的话整个下拉被最长的那项撑开, 把后面的按钮挤到下一行 (展开后选项照常显示全) */
#tab-balance .toolbar label.conc select#sub { max-width: 210px; }
#tab-balance .toolbar .job-status { display: inline-flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 360px; }
#tab-balance .toolbar .job-meta { white-space: nowrap; flex-shrink: 0; }
#tab-balance .toolbar .progress { width: 88px; flex-shrink: 0; margin: 0; height: 6px; background: #e5e9f0; border-radius: 3px; }
#tab-balance .toolbar .progress > i { display: block; height: 100%; background: var(--accent); width: 0%; }
#tab-balance .toolbar .job-steps { flex: 1; min-width: 100px; max-height: 36px; overflow: auto; font-family: Consolas, monospace; font-size: calc(var(--fs) - 1px); line-height: 1.35; color: var(--muted); white-space: nowrap; }
#tab-balance .toolbar .job-steps .now { color: var(--accent); font-weight: 500; }
#tab-balance .toolbar .job-steps .ok { color: var(--ok); }
#tab-balance .toolbar .job-steps .bad { color: var(--bad); }
#tab-balance .toolbar .job-steps > div { display: inline; margin-right: 12px; }
#tab-balance .pager { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; white-space: nowrap; margin-top: 10px; font-size: calc(var(--fs) - 1px); color: var(--muted); overflow-x: auto; }
#tab-balance .pager select, #tab-balance .pager input[type=number] { width: auto; border: 1px solid var(--line); border-radius: 3px; background: #fff; padding: 3px 8px; font: inherit; }
#tab-balance .pager .page-info { font-variant-numeric: tabular-nums; }
/* 表格的高度是 balance.js 的 fitTable 算的 (撑到窗口底, 跟着窗口大小 / 字号变); 这里的数只在算出来之前用一下 */
#tab-balance .table-wrap { max-height: calc(100vh - 330px); overflow: auto; border: 1px solid var(--line); border-radius: 3px; }
#tab-balance table { width: 100%; border-collapse: collapse; font-size: var(--fs); background: #fff; }
#tab-balance th, #tab-balance td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; white-space: normal; }
#tab-balance th { font-size: calc(var(--fs) - 1px); text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); position: sticky; top: 0; background: #f8f9fa; z-index: 1; white-space: nowrap; }
#tab-balance th.sortable { cursor: pointer; user-select: none; }
#tab-balance th.sortable:hover { color: var(--ink); }
#tab-balance th.sortable.asc::after { content: " \25B2"; font-size: calc(var(--fs) - 3px); }
#tab-balance th.sortable.desc::after { content: " \25BC"; font-size: calc(var(--fs) - 3px); }
#tab-balance tr:hover { background: #f0f7ff; }
#tab-balance tr.selected { background: var(--sel); }
#tab-balance td.step { font-family: Consolas, monospace; font-size: calc(var(--fs) - 1px); max-width: 200px; white-space: pre-wrap; word-break: break-word; }
#tab-balance td.step.queue { color: var(--muted); }
#tab-balance td.step.running { color: var(--accent); }
#tab-balance td.step.ok { color: var(--ok); }
#tab-balance td.step.fail { color: var(--bad); }
#tab-balance td.step.stop { color: var(--warn); }
#tab-balance td.note { font-size: calc(var(--fs) - 1px); max-width: 180px; white-space: pre-wrap; word-break: break-word; color: #7a5a00; }
#tab-balance th.num, #tab-balance td.num { white-space: nowrap; padding-left: 8px; padding-right: 10px; }
#tab-balance td.remain.num { white-space: pre-wrap; }
#tab-balance td.site { overflow-wrap: anywhere; min-width: 110px; }
#tab-balance td.acct { overflow-wrap: anywhere; min-width: 118px; }
#tab-balance td.acct .acct-hint { margin-top: 3px; font-size: calc(var(--fs) - 1px); }
/* 按站点分组: 一个站点有几个账号时, 序号 / 站点名 / 站点状态这几格竖着合并 (rowspan), 账号各占一行。
   同一个站点的账号之间用浅虚线隔开, 站点和站点之间还是实线; 合并的那几格不跟着某一行的勾选 / 悬停变色 (它是整个站点的) */
#tab-balance td.site .acct-n { margin-top: 4px; font-size: calc(var(--fs) - 2px); line-height: 1.45; }
#tab-balance tr.multi:not(.g-last) > td:not([rowspan]) { border-bottom: 1px dashed #dfe3e8; }
/* 合并的那几格竖着居中。以前顶着上边放: 第二个账号那一行左边是空的 (最左边还有它自己的勾选框), 看着像「一行什么都没有的站点」——
   居中以后站点名落在这几个账号的中间, 哪一行都不「缺」站点 */
#tab-balance tr.multi > td[rowspan] { background: #fff; vertical-align: middle; }
#tab-balance tr.multi > td[rowspan].gsel { background: var(--sel); }
/* 这个站点的几个账号左边连一条竖线, 和左边合并的站点格括成一组 (一眼看出这几行是同一个站点的) */
#tab-balance tr.multi > td.acct { border-left: 3px solid var(--accent2); padding-left: 10px; }
/* 勾选框那一格下面不画虚线: 左边这一块 (勾选框 + 合并的站点格) 中间没有横线, 才像一个整体; 虚线只隔开右边的账号 */
#tab-balance tr.multi:not(.g-last) > td.ck { border-bottom-color: transparent; }
#tab-balance .ops-grid { display: grid; grid-template-columns: auto auto; gap: 4px; justify-content: start; }
#tab-balance .ops-grid button { white-space: nowrap; padding: 4px 8px; }
#tab-balance td.bal, #tab-balance td.remain { color: var(--ok); font-weight: 500; }
#tab-balance td.total { color: var(--warn); font-weight: 500; }
#tab-balance td.bal.zero, #tab-balance td.remain.zero { color: var(--bad); font-weight: 700; }
#tab-balance .err { color: var(--bad); font-size: calc(var(--fs) - 1px); margin-top: 4px; min-width: 100px; max-width: 200px; white-space: pre-wrap; word-break: break-word; line-height: 1.35; }
/* font-weight / margin 显式写回: ppool style.css 的 .tag 是 600 + margin:1px, 不盖掉的话这里的标签会变粗、行距变乱 */
#tab-balance .tag { display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: calc(var(--fs) - 1px); font-weight: 400; margin: 0; border: 1px solid var(--line); white-space: nowrap; }
/* 站点状态是个链接 (点了跳到站点管理看这个站点): 样子还是标签, 颜色不跟着链接变蓝, 悬停时边框加深提示能点 */
#tab-balance a.tag.st-link { color: inherit; text-decoration: none; cursor: pointer; }
#tab-balance a.tag.st-link:hover { border-color: currentColor; background: var(--sel); }
#tab-balance .tag.usable { color: var(--ok); border-color: #b7d7c5; background: #eef7f1; }
#tab-balance .tag.unusable, #tab-balance .tag.wrong_password { color: var(--bad); border-color: #e3bcb5; background: #faf0ee; }
#tab-balance .tag.unsupported { color: var(--warn); border-color: #e2d0a4; background: #fbf5e8; }
#tab-balance .tag.unknown { color: var(--muted); }
#tab-balance .tag.svc_ok { color: var(--ok); border-color: #b7d7c5; background: #eef7f1; }
#tab-balance .tag.svc_warn { color: var(--warn); border-color: #e2d0a4; background: #fbf5e8; }
#tab-balance .tag.svc_bad { color: #fff; border-color: var(--bad); background: var(--bad); }
#tab-balance .tag.svc_unknown { color: var(--muted); }
#tab-balance .svc-reason { margin-top: 4px; font-size: calc(var(--fs) - 1px); color: var(--muted); min-width: 90px; max-width: 170px; white-space: normal; line-height: 1.35; }
#tab-balance .svc-reason.bad { color: var(--bad); }
#tab-balance td.exp .exp-bad { color: var(--bad); font-weight: 700; }
#tab-balance td.exp .exp-warn { color: var(--warn); font-weight: 700; }
#tab-balance td.exp .exp-hm { font-size: calc(var(--fs) - 1px); font-weight: 400; opacity: .75; }
/* 日期下面那行小字 (剩 N 天 · 来源) 屏幕窄的时候可以折行, 不把整列撑宽 */
#tab-balance td.exp .exp-sub { margin-top: 3px; font-size: calc(var(--fs) - 1px); color: var(--muted); white-space: normal; }
/* 「到期」是空的时候写的原因 (没查过 / 没查成 / 没有额度 / 站点没给): 就三四个字, 不折行 —— 整列都没有日期时这一列很窄, 折行会一个字一行竖着排 */
#tab-balance td.exp .exp-sub.why { white-space: nowrap; }
#tab-balance td.exp .exp-sub.bad { color: var(--bad); }
#tab-balance td.exp .exp-sub.warn { color: var(--warn); }
#tab-balance .mono { font-family: Consolas, monospace; font-size: calc(var(--fs) - 1px); }
#tab-balance .muted { color: var(--muted); }
#tab-balance .pkg { border-left: 3px solid var(--accent2); padding: 2px 0 2px 8px; margin: 2px 0; font-size: calc(var(--fs) - 1px); }
#tab-balance a { color: var(--info); }
/* margin:auto 必须显式写: ppool style.css 的 `* { margin:0 }` 盖掉了 dialog 默认的 margin:auto, 不补回弹窗会贴在视口左上角 */
#tab-balance dialog { border: 1px solid var(--line); border-radius: 6px; padding: 0; width: min(520px, calc(100vw - 32px)); background: #fff; color: var(--ink); margin: auto; }
#tab-balance dialog::backdrop { background: rgba(0,0,0,.4); }
#tab-balance .dlg-h { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
#tab-balance .dlg-b { padding: 14px 16px; display: grid; gap: 10px; }
#tab-balance .dlg-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
#tab-balance .field label { display: block; font-size: calc(var(--fs) - 1px); color: var(--muted); margin-bottom: 4px; }
/* 「添加」弹窗: 一排筛选 (站点状态下拉 / 勾选情况 / 搜索) + 一排计数和全选, 下面是账号列表 */
#tab-balance .add-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#tab-balance .add-filters select { width: auto; max-width: 250px; }
#tab-balance .add-filters input { flex: 1 1 180px; width: auto; min-width: 150px; }
#tab-balance .add-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: calc(var(--fs) - 1px); }
#tab-balance .add-bar .grow { flex: 1; }
#tab-balance .add-list { max-height: 48vh; overflow: auto; border: 1px solid var(--line); border-radius: 3px; padding: 0 10px; }
#tab-balance .add-list label { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid #eee; cursor: pointer; }
#tab-balance .add-list label:last-child { border-bottom: 0; }
#tab-balance .add-list label:hover { background: var(--sel); }
#tab-balance .add-list .empty { padding: 14px 0; color: var(--muted); }
