:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #dfe4ec;
  --text: #1d2430;
  --muted: #6b7684;
  --accent: #1f4e79;
  --accent-soft: #e8eff7;
  --good: #1f7a4d;
  --warn: #b3261e;
  --highlight: #fff6c2;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* 必须放在所有 display 规则之前声明优先级：
   [hidden] 与类选择器特异性相同，若不加 !important，
   .batch-bar{display:flex} 这类规则会让 hidden 属性失效。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  padding-bottom: 40px;
}

/* ── 顶栏 ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--accent); color: #fff;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; letter-spacing: .5px; }
.settings { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.settings label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.mini { width: 88px; }

/* ── 汇总卡片 ── */
.cards {
  display: grid; gap: 12px; padding: 16px 24px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.card-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.card-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card.highlight { background: var(--highlight); border-color: #e0c94a; }
.card.highlight .card-value { color: var(--warn); }
.card.muted .card-value { font-size: 20px; color: var(--muted); }

/* ── 标签页 ── */
.tabs { display: flex; gap: 4px; padding: 0 24px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line); border-bottom: none;
  background: #eef1f6; color: var(--muted);
  padding: 9px 18px; border-radius: 8px 8px 0 0;
  cursor: pointer; font: inherit; font-size: 13px;
}
.tab.active { background: var(--panel); color: var(--accent); font-weight: 600; }

/* ── 面板 ── */
.panel {
  display: none; margin: 0 24px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) var(--radius); padding: 16px;
}
.panel.active { display: block; }

/* ── 工具栏 ── */
.toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding-bottom: 12px;
}
.toolbar.sub { border-top: 1px dashed var(--line); padding-top: 12px; }
.toolbar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }

/* ── 表单 ── */
.entry-form {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end;
  background: var(--accent-soft); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.entry-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.entry-form label.grow { flex: 1 1 200px; }
.entry-form label.calc {
  display: block; white-space: nowrap; align-self: flex-end;
  font-size: 13px; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 12px;
}
.entry-form label.calc b { font-variant-numeric: tabular-nums; color: var(--accent); }
.form-actions { display: flex; gap: 8px; }

input, select {
  font: inherit; padding: 6px 9px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--text);
}
input[type="number"] { width: 118px; text-align: right; font-variant-numeric: tabular-nums; }
input[type="date"] { width: 148px; }
input[type="text"] { min-width: 160px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ── 按钮 ── */
.btn {
  font: inherit; font-size: 13px; cursor: pointer;
  padding: 7px 15px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--text);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #17608f; color: #fff; }
.btn.ghost { background: #f7f9fc; }
.btn.tiny { padding: 3px 9px; font-size: 12px; }
.btn.danger:hover { border-color: var(--warn); color: var(--warn); }

/* ── 登录页 ── */
body.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(140deg, #1f4e79 0%, #123a5c 60%, #0d2942 100%);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--panel); border-radius: 14px; padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.auth-card h1 { margin: 0 0 6px; font-size: 21px; color: var(--accent); }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--muted);
}
.auth-card input { padding: 10px 12px; font-size: 15px; }
.btn.block { width: 100%; padding: 11px; font-size: 15px; margin-top: 4px; }
.auth-notice {
  margin: 0; padding: 10px 12px; border-radius: 6px;
  background: var(--highlight); color: #7a5c00; font-size: 13px;
}
.auth-error {
  margin: 16px 0 0; padding: 10px 12px; border-radius: 6px;
  background: #fdeaea; color: var(--warn); font-size: 13px;
}
.auth-foot {
  margin: 18px 0 0; text-align: center;
  color: var(--muted); font-size: 12px;
}

/* ── 门户顶栏身份区 ── */
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.who b { font-size: 14px; }
.scope-tag {
  padding: 2px 9px; border-radius: 10px; font-size: 12px;
  background: rgba(255, 255, 255, .18);
}
.scope-tag.warn { background: #b3261e; }

/* ── 计费区间条 ── */
.period-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 12px;
  background: #fff; border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: var(--radius);
}
.period-title { font-size: 13px; font-weight: 600; color: var(--accent); }
.period-title b {
  margin-left: 6px; padding: 1px 7px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 600;
}
.period-bar label { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.period-bar input[type="datetime-local"] { width: 190px; }
.period-sep { color: var(--accent); font-weight: 700; }
.period-note { font-size: 12px; color: var(--muted); }
.period-note b { color: var(--warn); }
.quick-picks { display: flex; gap: 4px; flex-wrap: wrap; }
.hint.warn { color: var(--warn); font-weight: 600; }

/* ── 搜索主入口 ── */
.search-hero {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px; margin-bottom: 12px;
  background: var(--accent-soft); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.search-hero input[type="text"] {
  flex: 1 1 340px; min-width: 260px;
  font-size: 16px; padding: 10px 14px;
  border: 2px solid var(--accent);
}

/* ── 筛选条 ── */
.filter-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 14px; margin: -6px 0 12px;
  font-size: 13px; color: var(--muted);
}
.filter-bar label { display: flex; align-items: center; gap: 5px; }
.filter-bar label.check { cursor: pointer; }

/* ── 批量操作条 ── */
.batch-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 12px;
  background: #fff8e1; border: 1px solid #e0c94a; border-radius: var(--radius);
}
.batch-bar label { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.batch-bar input[type="number"] { width: 86px; }
.batch-bar input[type="text"] { min-width: 130px; }
.batch-info { font-size: 14px; }
.batch-info b { color: var(--warn); font-variant-numeric: tabular-nums; }

/* ── 快速结账 ── */

/* 区间回显刻意不复用 .period-bar：那个是 flex 单行，而这里要串好几段
   「含今天」「有 N 天没同步」「有空档」的说明，挤成一行就没人看了。 */
.quick-echo {
  padding: 10px 14px; margin-bottom: 12px; line-height: 1.7;
  font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.quick-echo.warn {
  color: #7a5b00; background: #fff8e1; border-color: #e0c94a;
}
.sub-title {
  margin: 18px 0 8px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.sub-title .hint { font-weight: 400; }

/* 归组的勾选计数。和出账栏的「已选 N 条」是两套口径（那边只算有钱的），
   同时出现时必须一眼能分开，所以这里单独上色加粗，不蹭 .hint 的灰。 */
#qGroupCount { color: var(--accent); font-weight: 700; font-size: 13px; }

/* 几个输入框的宽度。
   本来是写在标签上的 style="width:..."，但门户的 CSP 是 style-src 'self'，
   行内样式会被浏览器整条拦掉（控制台里那句 "Applying inline style violates..."），
   结果就是框子宽度全失效。CSP 不给行内样式开口子——开了 XSS 就能顺着写样式，
   所以宽度只能待在样式表里。以后加控件也照这个来，别再往 HTML 里写 style。 */
#vMinUsd  { width: 90px; }
#qGroup   { width: 200px; }
#qMoveTo  { width: 160px; }

/* ── 粘贴区 ── */
.paste-zone {
  border: 2px dashed var(--accent); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; text-align: center;
  color: var(--accent); background: var(--accent-soft);
  cursor: text; font-size: 14px;
}
.paste-zone:focus { outline: none; background: #dbe8f5; border-style: solid; }
kbd {
  background: #fff; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 6px; font: inherit; font-size: 12px;
}

.entry-details { margin-bottom: 12px; }
.entry-details summary {
  cursor: pointer; padding: 8px 12px; font-size: 13px; color: var(--muted);
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 6px;
}
.entry-details[open] summary { border-radius: 6px 6px 0 0; }
.entry-details .entry-form { margin-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }

/* ── 对话框 ── */
dialog {
  border: none; border-radius: var(--radius); padding: 22px;
  max-width: min(94vw, 1000px); box-shadow: 0 20px 60px rgba(0,0,0,.3);
  color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 6px; font-size: 17px; }
.table-wrap.short { max-height: 320px; margin: 12px 0; }
.dialog-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.dialog-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.dialog-row label.chk { flex-direction: row; align-items: center; gap: 6px; }
/* .grow 原来只在 .entry-form 下有定义，对话框里那几个 class="grow"
   （付款备注、指派清单的供应商输入框）一直是写了没生效的。 */
.dialog-row label.grow { flex: 1 1 220px; }
.dialog-actions {
  display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
.dialog-actions .hint { margin-right: auto; }
#pasteTable th { padding: 5px; }
#pasteTable th select { width: 100%; font-size: 12px; padding: 4px; }
#pasteTable td { font-size: 12px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }

/* ── 表格 ── */
.table-wrap { overflow-x: auto; max-height: 62vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--accent); color: #fff; font-weight: 600;
  padding: 9px 10px; text-align: left; white-space: nowrap;
}
/* 可排序表头：箭头用 data-arrow 渲染，省得每次重排都动 DOM 结构 */
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { filter: brightness(1.12); }
thead th.sorted { text-decoration: underline; text-underline-offset: 3px; }
thead th[data-arrow]::after { content: attr(data-arrow); font-size: 11px; }

tbody td { padding: 7px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: var(--accent-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.strong, .num.strong { font-weight: 700; color: var(--accent); }
th.act, td.act { width: 1%; white-space: nowrap; text-align: center; }
tbody tr { cursor: default; }
#vendorTable tbody tr { cursor: pointer; }

/* 表格内可直接编辑的单元格 */
.cell-input {
  width: 100%; min-width: 74px; padding: 3px 6px;
  border: 1px solid transparent; border-radius: 4px;
  background: #fff; font: inherit; font-size: 13px;
}
.cell-input:hover { border-color: var(--line); }
.cell-input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.cell-input.num { text-align: right; font-variant-numeric: tabular-nums; }
/* 汇率与顶栏默认值不同的行，一眼能挑出来（"哪些是 6.7"） */
.cell-input.fx-odd { background: #fff6e0; border-color: #e8c98a; font-weight: 600; }
td:has(> .cell-input) { padding: 3px 6px; }
#billTable th:nth-child(10), #billTable td:nth-child(10) { width: 92px; }
tfoot td {
  padding: 9px 10px; border-top: 2px solid var(--accent);
  font-weight: 700; background: #f2f5f9; font-variant-numeric: tabular-nums;
}
.empty { padding: 28px; text-align: center; color: var(--muted); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; }
.tag.ok { background: #e3f4ea; color: var(--good); }
.tag.off { background: #fdeaea; color: var(--warn); }
.tag.part { background: #fff3d6; color: #9a6b00; }
.tag.over { background: #e0ecff; color: #14508c; }
.tag.master { background: #1f4e79; color: #fff; font-weight: 700; }
.tag.muted { background: #f0f2f5; color: #a4adb8; }

/* ── ① 查库页的账本三列 ────────────────────────────────────────
   CSP 是 style-src 'self'，行内 style="..." 会被浏览器直接拦掉，
   所有宽度和配色都必须落在这个文件里。 */
.vendor-settles { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
/* 第 10 列=重复、第 11 列=结算单，两列都放一排标签，撑住宽度免得换行成面条。
   2026-09-26 撤掉「已结算U/未结算U」后整表左移一列，这两条规则跟着挪；
   以后再改表头列数务必回来核对——nth-child 按位置认人，错了不报错，只会歪。 */
#vendorTable th:nth-child(10), #vendorTable td:nth-child(10) { min-width: 130px; }
#vendorTable th:nth-child(11), #vendorTable td:nth-child(11) { min-width: 150px; }
/* 用户名格：名字 +「含 N 子号」徽章。供应商管理员名下的子账号已经折叠进
   这一行（见 rollup.py），徽章是唯一的出处线索，不能被挤到换行外面去。 */
.vendor-name { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
#vendorTable th:nth-child(2), #vendorTable td:nth-child(2) { min-width: 150px; }
.dup-cell { white-space: normal; }
.dup-cell.zero { color: #c3c9d2; text-align: center; }
/* 已出账 < 区间消耗：这段消耗还有一部分没进账本，是最该被看见的一种状态 */
.gap-text { color: #9a6b00; font-weight: 600; }
/* 已出账 > 区间消耗、但有跨端点账单能解释（那张整个算进来了）：蓝色，核对一下即可 */
.over-text { color: #14508c; font-weight: 600; }
/* 已出账 > 区间消耗且没有任何解释：这就是重复出账的现场，必须是红的。
   红色只留给这一种——跨端点的账单天天都会超，全标红等于没标。 */
.over-bad { color: var(--warn); font-weight: 700; }
/* 0 值压暗，免得一整列 0 和真数字糊在一起 */
td.num.zero { color: #c3c9d2; }
/* 重复且已经开进结算单：多算的钱已经落在某张 JS 单上，比单纯重复严重一档 */
.tag.bad { background: #fdeaea; color: var(--warn); font-weight: 700; }

.section-title {
  margin: 20px 0 10px; font-size: 15px; color: var(--accent);
  padding-bottom: 6px; border-bottom: 2px solid var(--accent-soft);
}
.mode-banner {
  margin: 0 24px; padding: 8px 14px;
  background: #fff8e1; border: 1px solid #e0c94a;
  border-radius: 0 0 6px 6px; font-size: 12px; color: #7a5c00;
}
.pwd-show {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0; padding: 14px 16px;
  background: #f2f5f9; border: 1px dashed var(--accent); border-radius: 8px;
}
.pwd-show code {
  flex: 1; font-size: 18px; font-family: Consolas, monospace;
  letter-spacing: 1px; color: var(--accent); user-select: all;
}
code {
  background: #eef1f6; padding: 1px 6px; border-radius: 4px;
  font-family: Consolas, monospace; font-size: 12px;
}
.tag.srv { background: #e6eefc; color: #1a4f8a; font-weight: 600; }
.tag.settle { background: #ede4fb; color: #5b2f9e; font-weight: 600; font-family: Consolas, monospace; }
.muted-text { color: #a4adb8; font-size: 12px; }

/* 结算单展开的明细行 */
td.detail-cell {
  background: #f7f9fc; padding: 12px 18px;
  border-left: 3px solid var(--accent); white-space: normal;
}
.detail-title { font-weight: 700; color: var(--accent); margin: 6px 0 4px; font-size: 12px; }
.detail-line {
  font-family: Consolas, monospace; font-size: 12px;
  padding: 2px 0; color: #444;
}
.detail-line.warn-line { color: var(--warn); font-weight: 600; }

/* ── 分段切换（归集状态 / 服务器）── */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg-btn {
  border: none; background: #fff; color: var(--muted);
  padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg-btn:last-child { border-right: none; }
.seg-btn b { margin-left: 4px; font-variant-numeric: tabular-nums; }
.seg-btn:hover { background: var(--accent-soft); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* ── 展开区里的明细小表 ── */
.mini-table {
  width: 100%; border-collapse: collapse; margin: 6px 0 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  font-size: 12px;
}
.mini-table th {
  position: static; background: #e8eef7; color: var(--accent);
  padding: 6px 9px; text-align: left; font-weight: 600; white-space: nowrap;
}
.mini-table td { padding: 5px 9px; border-top: 1px solid var(--line); white-space: nowrap; }
.mini-table tbody tr:hover td { background: var(--accent-soft); }
.mini-table tfoot td {
  border-top: 2px solid var(--accent); background: #f2f5f9;
  font-weight: 700; padding: 6px 9px;
}
.mini-table .empty { padding: 14px; }

/* 可点击穿透的结算单号 */
.link-tag { border: none; cursor: pointer; font: inherit; }
.link-tag:hover { background: var(--accent); color: #fff; }

/* 穿透跳转后的高亮提示 */
@keyframes flashRow {
  0%, 100% { background: transparent; }
  30%      { background: #fff3c4; }
}
tr.flash td { animation: flashRow 1.6s ease; }
/* 计费区间：不换行，窄了也能一眼读完 */
.period-cell {
  white-space: nowrap; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#reconcileTable tbody tr:not(:has(.detail-cell)) { cursor: default; }
#reconcileTable .strong { font-size: 14px; }
.batch-bar .divider {
  width: 1px; height: 22px; background: #e0c94a; margin: 0 2px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); color: var(--text); }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #23303f; color: #fff; padding: 11px 22px;
  border-radius: 24px; font-size: 13px; z-index: 99;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.toast.error { background: var(--warn); }

/* ── ⑤-上 区间结算（A 区间费用 / B 已支付 / C 待支付）──
   列宽写在这里而不是行内 style，因为 CSP 是 style-src 'self'，
   行内 style="..." 会被浏览器直接丢掉，表格就会排得七扭八歪。 */
.period-table th:nth-child(2), .period-table td:nth-child(2) { width: 72px; }
.period-table th:nth-child(3), .period-table td:nth-child(3),
.period-table th:nth-child(4), .period-table td:nth-child(4),
.period-table th:nth-child(5), .period-table td:nth-child(5) { width: 128px; }
.period-table th:nth-child(6), .period-table td:nth-child(6) { width: 88px; }
.period-table th:nth-child(7), .period-table td:nth-child(7) { width: 210px; }
.period-table .strong { font-size: 14px; }
/* 待支付 C 是这张表的结论列，要比别的列显眼 */
.period-table td:nth-child(5) { color: var(--warn); font-weight: 700; }

/* 口径说明。数字离开系统后没人记得它是怎么算的，所以一直挂在表底下。 */
.caliber {
  margin: 8px 0 20px; padding: 8px 12px;
  background: #f7f9fc; border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  font-size: 12px; line-height: 1.7; color: var(--muted);
}

/* ── ② 重复账单体检横幅 ── */
.dup-banner {
  margin-bottom: 12px; padding: 10px 14px;
  background: #fdeaea; border: 1px solid #e8a9a4;
  border-left: 4px solid var(--warn); border-radius: var(--radius);
}
.dup-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--warn);
}
.dup-head b { font-size: 16px; }
.dup-head .btn { margin-left: 4px; }
.dup-body { margin-top: 10px; }
.dup-body .mini-table { background: #fff; }

@media (max-width: 720px) {
  .topbar, .cards, .tabs, .panel { padding-left: 12px; padding-right: 12px; }
  .panel { margin: 0 12px; }
}
