* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6f9;
  --card: #fff;
  --border: #e3e8ee;
  --muted: #73798a;
  --text: #1f2430;
  --accent: #1B4332;
  --accent2: #2D6A4F;
  --up: #2d8c6e;
  --down: #c0392b;
}
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; }
body { display: flex; flex-direction: column; }

/* 顶部标题栏（随页滚走，非 sticky） */
.topbar {
  flex: 0 0 auto;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff; padding: 14px 20px; display: flex; align-items: baseline; gap: 12px;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar .sub { font-size: 12px; opacity: .85; }

/* 锁定区：页签栏 + 筛选 + 标题/选项栏 整体 sticky */
.sticky-head {
  flex: 0 0 auto;
  z-index: 50; background: var(--card);
  border-bottom: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

/* 页签栏 */
.tabs { display: flex; flex-wrap: wrap; gap: 0; padding: 0 12px; border-bottom: 1px solid var(--border); position: relative; }
.tab-spacer { flex: 1; }
.tab-option {
  border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 10px 12px; font-size: 17px; line-height: 1;
}
.tab-option:hover { color: var(--text); }
.tab-menu {
  position: absolute; top: 100%; right: 6px; z-index: 120;
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); min-width: 120px;
}
.tab-menu div { padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--text); text-align: left; }
.tab-menu div:hover { background: #f0f2f5; }
.tabs button {
  border: none; border-bottom: 3px solid transparent; background: none; color: var(--muted);
  padding: 10px 14px; cursor: pointer; font-size: 14px; font-weight: 500; position: relative;
}
.tabs button .tab-close {
  display: none; position: absolute; top: 8px; right: 3px;
  width: 15px; height: 15px; line-height: 14px; text-align: center;
  border-radius: 50%; font-size: 12px; color: var(--muted);
}
.tabs button:hover .tab-close { display: block; }
.tabs button .tab-close:hover { background: var(--border); color: #c0392b; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button:hover { color: var(--text); }

/* 筛选行 */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 10px 16px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.field select, .field input, .poptions input, .acc-row input {
  border: 1px solid var(--border); border-radius: 4px; padding: 7px 9px; font-size: 14px;
  color: var(--text); background: #fff; min-width: 0;
}
.field select:focus, .field input:focus, .poptions input:focus, .acc-row input:focus { outline: none; border-color: var(--accent2); }
.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 4px; padding: 8px 20px;
  font-size: 14px; cursor: pointer;
}
.primary:hover { background: var(--accent2); }

/* 期间快捷按钮 */
.quick { display: flex; gap: 4px; align-items: flex-end; align-self: flex-end; }
.quick button {
  border: 1px solid var(--border); background: #fff; color: var(--muted); padding: 7px 10px;
  border-radius: 4px; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.quick button:hover { color: var(--accent); border-color: var(--accent2); }
.quick button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 页签 head（标题栏 + 选项栏） */
.phead { padding: 8px 16px 6px; }
.ptitle { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.phead .hint { color: var(--muted); font-size: 12px; }

/* 选项栏 */
.poptions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-bottom: 6px; }
.poptions input[type="text"] { flex: 1; min-width: 160px; }
.poptions #vouBillno { flex: 0 0 auto; min-width: 0; width: 72px; }
.poptions .search-box { flex-basis: 100%; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap; }
.chk input { cursor: pointer; }

/* 维度勾选按钮 */
.dim-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.dim-btn {
  border: 1px solid var(--border); background: #fff; color: var(--muted); padding: 5px 14px;
  border-radius: 4px; cursor: pointer; font-size: 13px;
}
.dim-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.export-last { margin-left: auto; }

/* 科目筛选行（在选项栏上方） */
.acc-row { position: relative; margin-bottom: 6px; display: flex; gap: 8px; }
.acc-row input { flex: 1; }
.acc-row .search-inline { flex: 1.8; min-width: 240px; }
.acc-suggest {
  position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 4px; max-height: 260px; overflow-y: auto; display: none; z-index: 70; box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.acc-suggest .item { padding: 7px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.acc-suggest .item:hover { background: #f0f4f3; }
.acc-suggest .item .code { color: var(--muted); font-size: 12px; }

/* 内容区 */
.panels { flex: 1 1 auto; min-height: 0; padding: 14px 16px; display: flex; flex-direction: column; }
.panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 12px; }
/* 表格横向/纵向滚动容器（宽表），表头锁定在容器内 */
.table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
.table-wrap table { width: max-content; min-width: 100%; }
.panels .table-wrap thead th { top: 0; }
.card-head { flex: 0 0 auto; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.panels .card-head { z-index: 30; background: var(--card); }
.card-head .meta { font-weight: normal; color: var(--muted); font-size: 12px; margin-right: auto; }
.card-head .dim-btn { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500; }
.card-head .dim-btn:hover { opacity: .88; }
.card-head .dim-btn:disabled { background: #c9ced4; border-color: #c9ced4; color: #fff; cursor: not-allowed; opacity: .9; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: #f7f9fb; text-align: right; padding: 8px 10px;
  border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 500; white-space: nowrap;
}
td.sel-td, th.sel-td { width: 32px; text-align: center; padding: 6px 4px; }
.sel-td input { cursor: pointer; margin: 0; }
tr.sel { background: #eaf5f2; }
thead th.l, tbody td.l { text-align: left; }
tbody td { padding: 7px 10px; border-bottom: 1px solid #f0f2f5; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #fafbfc; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f0f6f2; }
.badge-d { color: #fff; background: #3b6ef5; border-radius: 3px; font-size: 11px; padding: 1px 5px; }
.badge-c { color: #fff; background: #e07b39; border-radius: 3px; font-size: 11px; padding: 1px 5px; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px; }
.count { color: var(--muted); font-size: 12px; padding: 6px 4px; }

/* 分页（底部锁定） */
.pager { flex: 0 0 auto; z-index: 45; background: var(--bg); border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: center; align-items: center; padding: 10px 16px; }
.pager button { border: 1px solid var(--border); background: #fff; padding: 6px 12px; border-radius: 4px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .info { color: var(--muted); font-size: 12px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 8px; width: min(920px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal-head .close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 0; overflow-y: auto; }
.modal-body table th { top: 0; }
.modal-body .sec-title { padding: 10px 16px; font-weight: 600; font-size: 13px; color: var(--accent); }
.att-link { color: var(--accent2); text-decoration: none; }
.att-link:hover { text-decoration: underline; }

/* 右侧抽屉（附件/审批预览） */
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 720px; max-width: 92vw;
  background: #fff; z-index: 150; box-shadow: -4px 0 18px rgba(0,0,0,.16);
  display: flex; flex-direction: column;
}
.drawer-resizer {
  position: absolute; left: 0; top: 0; width: 7px; height: 100%;
  cursor: ew-resize; z-index: 2; background: transparent;
}
.drawer-resizer:hover, .drawer-resizer.active { background: var(--accent2); opacity: .5; }
.drawer-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px;
}
.drawer-head .close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.drawer-head .close:hover { color: var(--text); }
.drawer-body { flex: 1 1 auto; overflow: auto; min-height: 0; }
.drawer-body iframe { width: 100%; height: 100%; border: none; display: block; }

/* 分屏布局（整个凭证页签左右分屏：左凭证卡 + 右附件卡） */
.split-root { display: flex; flex-direction: row; height: 100%; width: 100%; min-height: 0; }
.split-left-pane { flex: 0 0 auto; width: 55%; min-width: 240px; height: 100%; overflow: hidden; }
.split-right-pane { flex: 1 1 auto; min-width: 320px; height: 100%; overflow: hidden; }
.split-resizer { flex: 0 0 auto; width: 6px; cursor: col-resize; }
.split-resizer:hover, .split-resizer:active { background: var(--accent2); opacity: .5; }
.split-tabs { flex: 0 0 auto; display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 6px; }
.split-tab { border: none; background: none; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.split-tab:hover { color: var(--text); }
.split-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.split-tab.dragging { opacity: .4; }
.split-content { flex: 1 1 auto; overflow: hidden; min-height: 0; }
.split-content iframe { width: 100%; height: 100%; border: none; display: block; }
body.resizing { user-select: none; cursor: col-resize; }

@media (max-width: 640px) {
  .field { width: 100%; }
  table { font-size: 12px; }
  thead th, tbody td { padding: 6px 7px; }
  .poptions input[type="text"] { min-width: 100%; }
  .dim-btn { padding: 5px 10px; }
}

/* 主内容区表格表头锁定（top = sticky-head 高度 + card-head 高度，避开筛选栏和标题行） */
.panels thead th { top: var(--thead-top, var(--sticky-h, 0)); }

/* 导出按钮 */
.export-btn {
  border: 1px solid var(--border); background: #fff; color: var(--muted); padding: 4px 12px;
  border-radius: 4px; cursor: pointer; font-size: 12px; margin-left: 8px;
}
.export-btn:hover { color: var(--accent); border-color: var(--accent2); }

/* 分页每页大小 */
.pager .pgsz { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.pager .pgsz select { border: 1px solid var(--border); border-radius: 4px; padding: 4px 6px; font-size: 12px; }

/* 明细账汇总行 */
.sum-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fbfcfe; border-bottom: 1px solid var(--border); }
.sum-table td { padding: 6px 10px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sum-table td.l { text-align: left; color: var(--muted); width: 90px; }
.sum-table tr:last-child td { border-bottom: none; }

/* 明细账每月发生 */
.monthly { padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); background: #fbfcfe; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.monthly .mh { color: var(--text); font-weight: 500; }
.monthly .m-item { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 明细账小计行 */
tbody tr.sum-row td { background: #f2f5f8; font-weight: 600; color: var(--text); }
tbody tr.sum-row td.l { color: var(--accent); }

/* 表头过滤 */
thead th .th-label { display: block; }
thead th .th-filter {
  display: block; width: 100%; margin-top: 3px; padding: 3px 5px; font-size: 11px;
  border: 1px solid var(--border); border-radius: 3px; font-weight: normal;
  color: var(--text); background: #fff; text-align: left; min-width: 48px;
}
thead th .th-filter:focus { outline: none; border-color: var(--accent2); }