:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e6ee;
  --text: #1f2733;
  --muted: #6b7585;
  --primary: #2f6fed;
  --primary-d: #1f56c4;
  --warn: #b9430a;
  --warn-bg: #fdeee3;
  --ok: #1d7a44;
  --header-bg: #eef2f8;
  --hdata-bg: #fff6d6;
  --row-alt: #fafbfd;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* 顶栏 */
.topbar {
  height: 52px;
  flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.brand { font-size: 16px; font-weight: 600; }
.brand .ver {
  font-size: 11px; font-weight: 400; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-left: 6px;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.src-name { color: var(--muted); font-size: 12px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 7px; padding: 6px 12px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: #c4ccda; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.primary:disabled { background: #b9c4d8; border-color: #b9c4d8; cursor: not-allowed; }
.btn.ghost { background: transparent; }

/* 主体双栏 */
.body { flex: 1 1 auto; display: flex; min-height: 0; }
.panel {
  flex: 0 0 300px; width: 300px;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px; overflow-y: auto;
}
.body.collapsed .panel { display: none; }

.card { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--text); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.field input, .field select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text);
}
.hint { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 0; padding-left: 18px; }

.preview { flex: 1 1 auto; min-width: 0; overflow: auto; padding: 14px; }
.summary { margin-bottom: 12px; font-size: 13px; }
.summary .abn { color: var(--warn); }
.summary .ok { color: var(--ok); }

/* 凭证块分组 */
.block { margin-bottom: 22px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.block-head {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--header-bg); font-weight: 600; border-bottom: 1px solid var(--border);
}
.block-head .pc { color: var(--muted); font-weight: 400; }
.block-head .badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; }
.badge.abn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: #e6f4ec; color: var(--ok); }

/* 表格 */
table.voucher { border-collapse: collapse; width: max-content; min-width: 100%; table-layout: fixed; }
table.voucher th, table.voucher td {
  border: 1px solid var(--border); padding: 4px 8px; font-size: 12px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; position: relative;
}
table.voucher thead th { background: var(--header-bg); text-align: left; font-weight: 600; }
table.voucher tr.hdata td { background: var(--hdata-bg); }
table.voucher tr:nth-child(even) td { background: var(--row-alt); }
table.voucher tr.abn td { color: var(--warn); }

/* 列宽拖动手柄 */
.resize-handle {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 2;
}
.resize-handle::after {
  content: ""; position: absolute; top: 25%; right: 3px; width: 2px; height: 50%;
  background: #c4ccda; border-radius: 2px;
}
.resize-handle:hover::after { background: var(--primary); }

/* 状态栏 */
.statusbar {
  flex: 0 0 auto; height: 30px; border-top: 1px solid var(--border);
  background: var(--surface); display: flex; align-items: center; padding: 0 16px;
  font-size: 12px; color: var(--muted);
}

/* 预览工具条 */
.toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  font-size: 13px; flex-wrap: wrap;
}
.toolbar .spacer { flex: 1 1 auto; }
/* v2: data-hide 控制显示（用属性选择器而非 hidden，避免与 hidden 默认行为混淆） */
[data-hide] { display: none !important; }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.btn.warn { color: var(--warn); border-color: var(--warn-bg); }
.btn.warn:hover { background: var(--warn-bg); }
.sel-count { color: var(--muted); font-size: 12px; }
.chk-only-abn { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--warn); cursor: pointer; }
.chk-only-abn input { accent-color: #d97706; }

/* 凭证块勾选 */
.block-head .chk {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none;
}
.block-head .chk input { accent-color: var(--primary); }
